3. In the set of integers, solve the equation

$$
x^{3}+y^{3}=(x+y)^{2}
$$
Solution. The given equation is successively equivalent to the equations

$$
\begin{aligned}
& (x+y)\left(x^{2}-x y+y^{2}\right)=(x+y)^{2} \\
& (x+y)\left(x^{2}-x y+y^{2}-x-y\right)=0
\end{aligned}
$$

From the last equation, we get $x+y=0$ or $x^{2}-x y+y^{2}-x-y=0$.

Let $x+y=0$. Then the solutions are $(k,-k), k \in \mathbb{Z}$.

Let $x^{2}-x y+y^{2}-x-y=0$. This equation is successively equivalent to the equations

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

From the last equation, it follows that $(x-y)^{2},(x-1)^{2},(y-1)^{2} \in\{0,1\}$. The following cases are possible:

- If $(x-y)^{2}=0,(x-1)^{2}=1,(y-1)^{2}=1$, we get the solutions $(0,0)$ and $(2,2)$.
- If $(x-y)^{2}=1,(x-1)^{2}=0,(y-1)^{2}=1$, we get the solutions $(1,0)$ and $(1,2)$.
- If $(x-y)^{2}=1,(x-1)^{2}=1,(y-1)^{2}=0$, we get the solutions $(0,1)$ and $(2,1)$.

Thus, the set of solutions to the given equation is:

$$
\{(k,-k), k \in \mathbb{Z}\} \cup\{(2,2),(1,0),(1,2),(0,1),(2,1)\}
$$