<s>[INST] Finding integer solutions to $(x-y)^2+(y-z)^2+(z-x)^2=2022$ This was from round A of the Awesomemath Summer Program application. The deadline was yesterday and we can discuss the problems now.

Find all integer triples $(x,y,z)$ which satisfy
$$(x-y)^2+(y-z)^2+(z-x)^2=2022$$

I tried a couple of things. First I noticed $x-y+y-z+z-x=0,$ so if we let $a=x-y, b=y-z,c=z-x$ than we have
$$\begin{align}
a^2+b^2+c^2&=2022 \tag1\\
a+b+c &=0 \tag2\\ 
(a+b+c)^2-2ab-2bc-2ca &=2022 \tag3
\end{align}$$ So,
$$-2ab-2bc-2ca=2022 \tag4$$
so
$$ab+bc+ca=-1011 \tag5$$
However, it is tricky to proceed from here.
I also recalled the factorization
$$x^2+y^2+z^2-xy-yz-zx=\frac{1}{2}((x-y)^2+(y-z)^2+(z-x)^2)=1011 \tag6$$ This also equals $$x(x-y)+y(y-z)+z(z-x) \tag7$$
but this doesn't seem promising.
I also tried to factorize $2022=2 \cdot 3 \cdot 337$, but I am not sure what to do after prime factorizing.
So far, I feel like my first approach is the most promising, but I am not sure how to finish with it.
 [/INST] We have:
$$(x-y)^2+(y-z)^2+(z-x)^2=2(x^2+y^2+z^2)-2(xy+yz+zx)$$
$$(x+y+z)^2=x^2+y^2+z^2+2(xy+yz+zx)$$
Summing these relations we get:
$$(x-y)^2+(y-z)^2+(z-x)^2+(x+y+z)^2=3(x^2+y^2+z^2)$$
$(x-y)^2+(y-z)^2+(z-x)^2=3\times 2\times 337$
$\Rightarrow 3\times 2\times 337+(x+y+z)^2=3(x^2+y^2+z^2)\space\space\space\space\space\space(1)$
Which indicate that:
$3\big|(x+y+z)$
Relation (1) also says not all x , z and z can be a multiple of 3,because $2022$ has only 3 as a factor, but one of them, say x can be,  so the sum of other two i.e y and z must be a multiple of 3. Also $\sqrt {2022}=44.96$. So $x<50$:
Now letting $x=3k$, equation (1) can be reduced as:
$3\times 2\times 337+(3k+y+z)^2=3[(3k)^2+y^2+z^2]\space\space\space\space\space\space (2)$
We value of x as:
$x=3k=3, 6, 9, 12, 15, 18, 30, 33, 36,39, 42, 45, 48$
Putting these in (2) we get an equation in terms of y and z with following restrictions:
$\begin{cases}3\big|y+z\\y<50, z<50\end{cases}$
which is easy to solve. Some examples:
$(x, y, z)=(3, 37, 32), (6,11, 40), (9,14, 43), (12, 7, 41), (15, 20, 49), (18, 13, 47), (30, 1, 35), (33, 38, 4), (36, 7, 41), (39, 10, 44), (42, 8, 37), (45, 11, 40), (48, 14, 43)$
</s>