Socialist candidates gain ground in mayoral races