Problem: There are $a+b$ bowls arranged in a row,
numbered $1$ through $a+b$,
where $a$ and $b$ are given positive integers.
Initially, each of the first $a$ bowls contains an apple,
and each of the last $b$ bowls contains a pear.
A legal move consists of moving an apple from bowl $i$ to bowl $i+1$
and a pear from bowl $j$ to bowl $j-1$,
provided that the difference $i-j$ is even.
We permit multiple fruits in the same bowl at the same time.
The goal is to end up with the first $b$ bowls each containing a pear
and the last $a$ bowls each containing an apple.
Show that this is possible if and only if the product $ab$ is even.

Solution: First we show that if $ab$ is even then the goal is possible.
We prove the result by induction on $a+b$.
\begin{itemize}
  \ii If $\min(a,b) = 0$ there is nothing to check.
  \ii If $\min(a,b) = 1$, say $a=1$, then $b$ is even,
  and we can swap the (only) leftmost apple
  with the rightmost pear by working only with those fruits.
  \ii Now assume $\min(a,b) \ge 2$ and $a+b$ is odd.
  Then we can swap the leftmost apple with rightmost pear by working only with those fruits,
  reducing to the situation of $(a-1, b-1)$ which is possible by induction
  (at least one of them is even).
  \ii Finally assume $\min(a,b) \ge 2$ and $a+b$ is even (i.e.\ $a$ and $b$ are both even).
  Then we can swap the apple in position $1$ with the pear in position $a+b-1$,
  and the apple in position $2$ with the pear in position $a+b$.
  This reduces to the situation of $(a-2, b-2)$ which is also possible by induction.
\end{itemize}

Now we show that the result is impossible if $ab$ is odd.
Define
\begin{align*}
  X &= \text{number apples in odd-numbered bowls} \\
  Y &= \text{number pears in odd-numbered bowls}.
\end{align*}
Note that $X-Y$ does not change under this operation.
However, if $a$ and $b$ are odd,
then we initially have $X = \half(a+1)$ and $Y = \half(b-1)$,
while the target position has $X = \half(a-1)$ and $Y = \half(b+1)$.
So when $ab$ is odd this is not possible.

\begin{remark*}
Another proof that $ab$ must be even
is as follows.

First, note that apples only move right and pears only move left,
a successful operation must take exactly $ab$ moves.
So it is enough to prove that the \emph{number of moves}
made must be even.

However, the number of fruits in odd-numbered bowls
either increases by $+2$ or $-2$ in each move
(according to whether $i$ and $j$ are both even or both odd),
and since it ends up being the same at the end,
the number of moves must be even.

Alternatively, as pointed out in the official solutions,
one can consider the sums of squares of positions of fruits.
The quantity changes by
\[ \left[ (i+1)^2 + (j-1)^2 \right] - (i^2+j^2)
  = 2(i-j) + 2 \equiv 2 \pmod 4 \]
at each step,
and eventually the sums of squares returns to zero, as needed.
\end{remark*}