What is Moscow's secret to training their programmers so well?

*St. Petersburg

I guess, like a lot of other sports at the college level, having a reputation that attracts the best competitive programmers (and a great coach to go along with it) doesn't hurt: https://en.wikipedia.org/wiki/Andrey_Stankevich

The "Russian hacker" stereotype is not at all fiction. If you've ever worked with developers from any of the former USSR, you'll know what I mean; they are not afraid to be creative and do whatever it takes to solve the problem.

Start training them from a very young age: competitive coders typical start in secondary/high school or even earlier.

Russia has specialized schools to support this kind of education, so are China and many other countries. Thus, they rank very high in IOI and ICPC contests