<s>[INST] Find the smallest positive integer which can be written as the sum of the squares of two positive integers in two different ways 
Find the smallest positive integer which can be written as the sum of the squares of two positive integers in two different ways.

I took extremely long to solve this 
I got 
$50= 7^2 + 1^2 $
$50= 5^2 + 5 ^2 $ 
I did it with the trial and error method. 
I'm just curious if this came out during my exams, is there a quicker way to find the answer?
 [/INST] If $p$ is a prime and $p \equiv 1 \bmod 4$, then $p=a^2+b^2$, for some $a,b \in \mathbb N$.
In this case, $2p^2$ has two representations: $p^2+p^2$ and $(a-b)^2+(a+b)^2$.
The second representation ones from $2p^2=|(1+i)(a+bi)^2|^2$.
So, the smallest solution is with $p=5$, for which $a=2$ and $b=1$ and $(a+bi)^2=3-4i$, which give $50=5^2+5^2=1^2+7^2$.
</s>