There are many approaches to an answer. Note that the job cannot be done if $n$ is odd. So let $n$ be even, say $n=2m$.
For concreteness, let $n=10$.
Line up the students in increasing order of student number. The first person in the list can choose her study partner in $9$ ways. For every such choice, the so far unpartnered student with smallest student number can choose her study partner in $7$ ways.
For every such choice, the so far unpartnered student with smallest student number can choose her study partner in $5$ ways. For every such choice, the so far unpartnered student with smallest student number can choose her study partner in $3$ ways. That gives a total of $(9)(7)(5)(3)$ ways.
The answer looks a little nicer if we write instead $(9)(7)(5)(3)(1)$.
Maybe to make things look even nicer, we can multiply top, and missing bottom, by $(10)(8)(6)(4)(2)$. We get
$$\frac{10!}{(10)(8)(6)(4)(2)},\quad\text{which is} \frac{10!}{2^5 \cdot 5!}.$$
Now that we have gone through the reasoning got $n=10$, the general case is straightforward. Suppose there are $2m$ students.
The student with lowest student number can choose her partner in $2m-1$ ways. For every such way, the so far unpartnered student with lowest student number can choose her partner in $2m-3$ ways. And then the so far unpartnered student with lowest student number can choose her partner in $2m-5$ ways, and so on, for a total of
$$(2m-1)(2m-3)(2m-5)\cdots(3)(1).$$
The same manipulation as before gives the more compact expression $$\frac{(2m)!}{2^m \cdot m!}.$$
If you specify how many of each size you want it is easy.
For example, splitting $50$ students into groups of sizes $5,5,5,5,6,6,6,6,6$ can be don in $\dfrac{30!}{5!^4 6!^5 4! 3!}$ ways.
In general if you have $n$ students and you split them into $a$ groups of size $x$ and $b$ groups of size $y$ there are $\frac{n!}{x!^ay!^b b!a!}$ ways to do it.
So one way to solve the problem is to calculate the number of ways for each possible way to add up to $n$ using groups of $x$ and $y$. Luckily the non-negative solutions to $ax+by=n$ can be found easily.
Best Answer
First method: Sort people into ten labeled groups and then recognize that you have overcounted. There are $\binom{50}{5,5,\dots,5}=\binom{50}{5}\binom{45}{5}\binom{40}{5}\cdots\binom{10}{5}=\frac{50!}{(5!)^{10}}$ ways that you can do this. Now, we recognize that each outcome we actually counted $10!$ different times. Dividing by $10!$ corrects this mistake giving us a final total of:
$$\frac{50!}{(5!)^{10}}\cdot\frac{1}{10!}$$
Second method: As "division by symmetry" arguments can make people nervous, we can instead approach more carefully to avoid overcounting. As we have 50 distinct people, there must be some obvious way that we can label them and arrange them. I will continue based on ordering the people by height, but you could choose a different ordering if you choose.
Among the 50 people, there must be someone who is shortest. We first pick who the four other people in the shortest person's group is. This can be accomplished in $\binom{49}{4}$ ways. We then remove all of these four people along with the original shortest person from the pool of available people to be placed in groups later.
Next, among the 45 remaining people, there must be someone who is shortest. We pick the four other people in the shortest remaining person's group. This can be accomplished in $\binom{44}{4}$ ways. Continue as before removing these people from the available pool.
Repeat this process until everyone has been assigned a group. This gives a final total number of ways as:
$$\binom{49}{4}\binom{44}{4}\cdots \binom{14}{4}\binom{9}{4}$$
One can check that this answer is equal to the previous answer.