5. Determine for which real numbers $p$ the system

$$
\begin{aligned}
& x^{2} y-2 x=p, \\
& y^{2} x-2 y=2 p-p^{2}
\end{aligned}
$$

has exactly three solutions in the set of real numbers.
SOLUTION. If we multiply the first equation by the unknown $y$ and the second by the unknown $x$, we get on the left side of both equations $x^{2} y^{2}-2 x y$. By comparing the right sides, we have

$$
p y=p(2-p) x .
$$

If $p=0$, the given system looks like this:

$$
\begin{aligned}
& x^{2} y-2 x=0, \\
& y^{2} x-2 y=0,
\end{aligned}
$$

and after a simple rearrangement, it becomes

$$
\begin{aligned}
& x(x y-2)=0, \\
& y(x y-2)=0 .
\end{aligned}
$$

We see that the system has infinitely many solutions: any pair $(x, y)$ of real numbers such that $x y=2$ is a solution. (In addition to these pairs, the only solution is the pair $x=y=0$.)

If $p=2$, we get the system

$$
\begin{aligned}
& x(x y-2)=2, \\
& y(x y-2)=0,
\end{aligned}
$$

which has the unique solution $y=0, x=-1$.

Let's return to equation (1), while further assuming that $p \notin\{0,2\}$. We divide the equation by $p$:

$$
y=(2-p) x \text {. }
$$

By substituting this relation into the first of the given equations, we obtain the cubic equation (for $p \neq 2$)

$$
(2-p) x^{3}-2 x-p=0 .
$$

Solving a cubic equation is generally not as simple as solving a quadratic equation. In our case, however, we can guess one of its roots, $x=-1$. Then we can divide the polynomial $(2-p) x^{3}-2 x-p$ by the root factor $x+1$ without a remainder. By dividing, we get

$$
(2-p) x^{3}-2 x-p=(x+1)\left((2-p) x^{2}+(p-2) x-p\right) .
$$

It is therefore sufficient to solve the quadratic equation

$$
(2-p) x^{2}+(p-2) x-p=0 .
$$

Note that the unknown $y$ is uniquely determined by the unknown $x$ using relation (2). For the given system to have exactly three solutions, the equation (3) must have three distinct solutions. This means that equation (4) must have two distinct solutions, which are also not equal to -1. We will examine when the discriminant $D$ of equation (4) is positive. A simple calculation gives us

$$
D=(p-2)^{2}-4(2-p)(-p)=(2-p)(3 p+2) \text {. }
$$

From this, we see that $D>0$ precisely when $p \in\left(-\frac{2}{3}, 2\right)$. By substituting $x=-1$, we easily see that equation (4) has the root -1 only for $p=\frac{4}{3}$. Therefore, equation (3) has three distinct solutions precisely when $p \in\left(-\frac{2}{3}, 0\right) \cup\left(0, \frac{4}{3}\right) \cup\left(\frac{4}{3}, 2\right)$.

Conversely, if equation (3) has three distinct solutions, the system (2), (3) also has three distinct solutions, which is equivalent to the given system for $p \neq 0$ and $p \neq 2$.

Answer. The given system has exactly three solutions in the set of real numbers precisely when $p \in\left(-\frac{2}{3}, 0\right) \cup\left(0, \frac{4}{3}\right) \cup\left(\frac{4}{3}, 2\right)$.

Note. The problem can be solved in multiple ways - for example, by expressing the unknown $y$ in terms of $x$ from the first equation and substituting it into the second equation, or by dividing the first equation by $x$ and the second by $y$ and subtracting the resulting equations. Both of these methods again lead to the cubic equation (3).