Find all ordered triples $(x, y, z)$ of integers satisfying the following system of equations:

$$
\begin{aligned}
x^{2}-y^{2} & =z \\
3 x y+(x-y) z & =z^{2}
\end{aligned}
$$
If \( z=0 \), then \( x=0 \) and \( y=0 \), and \((x, y, z)=(0,0,0)\).

Let us assume that \( z \neq 0 \), and \( x+y=a \) and \( x-y=b \) where \( a \) and \( b \) are nonzero integers such that \( z=a b \). Then \( x=(a+b) / 2 \) and \( y=(a-b) / 2 \), and the second equations gives \( 3 a^{2}-3 b^{2}+4 a b^{2}=4 a^{2} b^{2} \).

Hence

\[
b^{2}=\frac{3 a^{2}}{4 a^{2}-4 a+3}
\]

and

\[
3 a^{2} \geq 4 a^{2}-4 a+3
\]

which is satisfied only if \( a=1,2 \) or 3.

- If \( a=1 \), then \( b^{2}=1 \). \((x, y, z)=(1,0,1)\) and \((0,1,-1)\) are the only solutions in this case.
- If \( a=2 \), then \( b^{2}=12 / 11 \). There are no solutions in this case.
- If \( a=3 \), then \( b^{2}=1 \). \((x, y, z)=(1,2,-3)\) and \((2,1,3)\) are the only solutions in this case.

To summarize, \((x, y, z)=(0,0,0),(1,0,1),(0,1,-1),(1,2,-3)\) and \((2,1,3)\) are the only solutions.

Comments. 1. The original problem proposal asks for the solutions when \( z=p \) is a prime number.

2. The problem can be asked with a single equation in the form:

\[
3 x y+(x-y)^{2}(x+y)=\left(x^{2}-y^{2}\right)^{2}
\]