Housing costs are overstated for single people IMO. If you are single, want to live in SF, and okay with a roommate then it’s not hard to find a rent-controlled room (70% of rentals in SF are rent-controlled) and pay $1600-$2000.
I wouldn't advise an SF->PA commute to a newcomer. You'd have to restrict your housing search to sites within a reasonable walking/biking distance to the Caltrain. Much easier to just focus on something that's within a reasonable walking/biking distance of Stanford.
That's a really big caveat. Most places you don't need to spend that much for a one bedroom apartment.