4. Around a round table, $n>2$ students are sitting. At the beginning, each student has exactly one candy. In each step, each student chooses one of the following two operations:

(i) gives one of their candies to the student to their left or to the student to their right;

(ii) divides all their candies into two sets (not necessarily non-empty) and gives one set to the student to their left and the other to the student to their right.

All operations in one step are performed simultaneously. A distribution of candies is called reachable if it can be obtained in a finite number of steps. How many reachable distributions are there?

(Two distributions are different if at least one student has a different number of candies in them.)

(Kunap)
4. The total number of arrangements (reachable and unreachable) is $\left(\begin{array}{c}2 n-1 \\ n\end{array}\right)$.

Lemma. In two steps, each student can give a candy (if they have one) to a student two places to the left or right of themselves, such that the state of the other students remains unchanged.

Proof. Consider three consecutive students $A, B$, and $C$ from left to right, where $A$ has at least one candy. Let all students perform operation (ii). Then each candy can move arbitrarily one place to the left or right. The first step can be performed such that all candies move to the right, and the second step such that all candies return to the left, except one from student $B$ which will move to the right to student $C$. Thus, one candy from student $A$ ends up with student $C$. The other direction is analogous.

Let $n$ be odd. Since the distance between any two students in one direction is even, using the Lemma, each student can give a candy to any other student in an even number of steps. Therefore, all arrangements are reachable.

Now let $n$ be even. By simple induction, it follows that after each step, at least one candy is located with students at even positions, or with students at odd positions. Arrangements where all candies are with $\frac{n}{2}$ students at even positions or $\frac{n}{2}$ students at odd positions are unreachable, and there are $2\binom{3 n / 2-1}{n}$ such arrangements. It remains to show that all other arrangements are reachable.

Given the Lemma, it is sufficient to show that for each $a=1,2, \ldots, n-1$, it is possible to obtain at least one arrangement where exactly $a$ candies are at even positions. To start, by the Lemma, all candies can be traced to two adjacent students $A$ and $B$, where $A$ is at an even position. Suppose at that moment, without loss of generality, $A$ has $a^{\prime}>a$ candies. In the first move, $A$ will give one candy to student $B$, and $B$ will give one candy to their other neighbor $C$. In the second move, $A$ and $B$ will exchange one candy each, and $C$ will return the candy to student $B$. Now $A$ has $a^{\prime}-1$ candies, and $B$ has the remaining $n-a^{\prime}+1$. Repeating this process $a^{\prime}-a$ times achieves the goal.

Therefore, the number of reachable arrangements is $\binom{2 n-1}{n}$ if $2 \nmid n$, and $\binom{2 n-1}{n}-2\binom{3 n / 2-1}{n}$ if $2 \mid n$.