Building codes aren't the problem, it's zoning. If a developer had an empty acre in SF or Palo Alto, or permission to replace low rise housing with skyscrapers, they'd build.
The cost of building probably does have an effect on the margin, but it is so much less of a factor than restrictions on what can be built.