See the original puzzles
Take 24 objects in a row. Choose any 5 of them. Call the chosen objects "candy" and the not-chosen objects "dividers". Then arrange the 20 students in a row. The first student gets the amount of candy to the left of the first divider. The second student gets the amount of candy between the first and second divider. The third student gets the amount of candy between the second and third divider. And so on.
Each way to choose 5 objects out of 24 corresponds to a unique way to distribute candy. And each way of distributing candy corresponds to a unique way of choosing 5 objects out of 24. Therefore, the number of ways to give out the candy is C(24,5).
In general, for N students and K pieces of candy, it's C(N+K-1,K).
Class Candy Clash
I think this one is a bit of a headbanger, though it's hidden underneath some math.
In the two classes, there are a total of 40 students. Choose any 20 of them. The students chosen in my class participate in the competition. The students in my colleague's class that were not chosen participate in the competition. In this way, both my class and her class have equally sized teams.
Thus, there are C(40,20)-1 different possibilities (subtracting off 1, so as to eliminate the possibility of having zero students participate).