San Francisco's budget is vastly less efficient than other comparable US cities:
http://www.sfweekly.com/sanfrancisco/the-worst-run-big-city-...
As for people living vs. working in SF, this comment does an excellent job explaining it, with sources:
https://news.ycombinator.com/item?id=10875936
tl;dr: The increase in population due to daily workers commuting in from outside is vastly smaller than in NYC.