13.331. Several balls of equal mass for bearings and several piston rings, also of equal mass, were made from a certain grade of metal. If the number expressing the mass of each ball in grams were 2 less than the number of rings made, and the number expressing the mass of each ring in grams were 2 more than the number of balls made, then the number expressing their total mass would exceed twice the difference between the number of rings and balls by 800, and if the number expressing the mass of each item in grams were equal to the number of items of the same kind made, then their total mass would be 881 g. How many balls and rings were made?
Solution.

Let $x$ be the number of balls, $m_{x}$ be the mass of one ball, $y$ be the number of rings, $m_{y}$ be the mass of one ring. According to the conditions, we have the system

$$
\left\{\begin{array}{l}
m_{x}+2=y \\
m_{y}=x+2 \\
x \cdot m_{x}+y \cdot m_{y}-800=2(y-x), \text{ from which } x=25, y=16 \text{ or } x=16, y=25 . \\
x^{2}+y^{2}=881
\end{array}\right.
$$

Answer: 25 balls and 16 rings or 16 balls and 25 rings.