The largest classes (CS 61A and CS 61B) have roughly 1800 and 1600 students respectively during peak semesters.
A 20 hour TA is paid ~$2250/mo for approximately 4.5 months per semester, plus ~$7000/semester in tuition remission (so ~$17k). $350 is the total cost for the whole semester per student. 17k/350 is about 50 students per TA, which sounds about right (and even that is a higher than ideal ratio). There are other costs too, but these are the some of the highest.