<s>[INST] If Alice gives Bob $m$ candies, then he'll have $n$ times her candies; if Bob gives Alice $n$ candies, then she'll have $m$ times his candies. I came up with a seemingly innocent problem of recreational mathematics by myself. It goes likes this.

Alice and Bob have some different amount of candies ($>1$ each). If Alice gives Bob $m$ candies, then Bob has $n$ times the candies remaining to Alice, and if Bob gives Alice $n$ candies, then Alice has $m$ times the candies remaining to Bob.
How many candies have Alice and Bob?

I expected infinite solutions, but running a simple Python code (up to 200 iterations) gave me only 4 answers:
$$\begin{array}{cccc}
\text{A} & \text{B} & m & n \\
\hline
7 & 5 & 3 & 2 \\ 
14 & 4 & 8 & 2 \\
11 & 5 & 7 &3 \\
11 & 7 & 8 & 5
\end{array}$$
Apparently the highest amount of candies that Alice/Bob can have is 14.
Does this limit actually exist? If so, how can I prove that?
 [/INST] If we solve the system of equations $$\begin{cases}b+m = n(a-m) \\ a+n = m(b-n)\end{cases}$$ for $a,b$ in terms of $m,n$ we get $a = m+1 + \frac{m^2+m+n+1}{mn-1}$ and $b = n+1 + \frac{n^2+m+n+1}{mn-1}$. By symmetry, we may assume $m \le n$.
We want $\frac{m^2+m+n+1}{mn-1}$ to be an integer. This is easiest to achieve when $\frac{m^2+m+n+1}{mn-1} = 1$. In this case, the equation $m^2+m+n+1 = mn-1$ gives us $n = m + 2 + \frac{4}{m-1}$, which only works out when $m-1$ is $1$, $2$, or $4$. These correspond to $(m,n) = (2,8)$, $(3,7)$, and $(5,8)$.
It remains to check the cases where $\frac{m^2+m+n+1}{mn-1} \ge 2$. Since $m^2 \le mn$, this requires $m+n+1\ge mn-2$, or $(m-1)(n-1) \le 4$. This is true when $m=1$, or for the pairs $(m,n) = (2,2)$, $(2,3)$, $(2,4)$, $(2,5)$, and $(3,3)$. Moreover, when $m=1$, we have $a = 3 + \frac{4}{n-1}$, limiting us to $n=2$, $3$, and $5$.
We can check these finitely many cases and get only the following possibilities for $(a,b)$: $(4, 14)$, $(5, 7)$, $(5, 11)$, $(6, 6)$, and $(7, 11)$ (together with the symmetric cases where $a>b$). Some of these work with multiple values of $m$ and $n$: for example, $a=b=6$ works either with $m=n=2$ or with $m=n=3$.
</s>