Tallin - yes, Oslo - yes, Copehangen - yes - the others it depends where you dock.
St P - you only need a visa if you are going ashore by yourself which is not recommended if you do not speak fluent Russian, port is long way from town and no taxis allowed. Do a private tour with Alla, RedOctober or Denrus if you do not want to go with the hoards from the ship.
Formal means formal - suit and tie please or a tuxedo, or a jacket and tie minimum. Short sleeved shirt is not formal wear.