Canada has some decent ranking schools (UofT,Waterloo,UBC,SFU,etc.) and many Canadians don't want to move to the US (plus the Canadian dollar is worth less lately).
[1] http://www.numbeo.com/cost-of-living/rankings.jsp [2] http://www.numbeo.com/cost-of-living/comparison.jsp
Changing the topic... I'm not so sure if Southern Europe is cheaper than Shanghai. The two main cities of Spain rank higher in cost of living than Shanghai, according your link. I guess that defining the "cost of living" is a really complicated problem.
[1]: https://www.glassdoor.com/Salaries/shanghai-software-enginee... [2]: https://www.glassdoor.com/Salaries/vancouver-software-develo...