## Task A-1.2.

Gargamel has caught $N$ Smurfs and distributed them into three bags. When Papa Smurf was moved from the first bag to the second, Grouchy from the second to the third, and Smurfette from the third to the first, the average height of the Smurfs in the first bag decreased by 8 millimeters, while the average heights of the Smurfs in the second and third bags increased by 5 millimeters and 8 millimeters, respectively.

If there were nine Smurfs in the first bag, determine $N$.
## Solution.

Let there be $K$ Smurfs in the second bag and $L$ Smurfs in the third bag. Let $x$, $y$, and $z$ be the heights of Papa Smurf, Grouchy, and Smurfette, respectively.

If the heights of the Smurfs in the first bag are $x, x_{2}, x_{3}, \ldots, x_{9}$, then

$$
\frac{x+x_{2}+\ldots+x_{9}}{9}=8+\frac{z+x_{2}+\ldots+x_{9}}{9}
$$

i.e.,

$$
\frac{x}{9}=8+\frac{z}{9}
$$

Similarly, by considering the average in the second and third bags, we get

$$
5+\frac{y}{K}=\frac{x}{K}, \quad 8+\frac{z}{L}=\frac{y}{L}
$$

We have the system

$$
\begin{aligned}
x & =72+z \\
5 K+y & =x \\
8 L+z & =y
\end{aligned}
$$

If we add all three equations, we get

$$
72=5 K+8 L
$$

Since $K$ and $L$ are natural numbers, we conclude that 8 divides $K$.

It is not possible for $K \geqslant 16$ because then $L$ would be negative, nor is $K=0$ possible because the second bag is not empty (Grouchy was initially in it), so it must be $K=8$.

We conclude that $L=4$. Since $N=K+L+9$, it follows that $N=21$.