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?

Consider the equation $x^2+y^2=z^2+w^2=N.$
This is equivalent to: $x^2-z^2=w^2-y^2=D.$
and we need $D$ to have at least two different factorizations with the factors having the same parity. One approach is thus to find the smallest values of $D$ which satisfy this property. Another approach is to find parametric solutions.
Let $(x-z)=ab$ and $(x+z)=cd$ with $(w-y)=ac$ and $(w+y)=bd$,
which gives the parametric solution: $\dfrac{1}{2}(ab+cd,bd-ac,cd-ab,ac+bd)$.
We have $N=\dfrac{1}{4}(a^2b^2+c^2d^2+b^2d^2+a^2c^2)$.
Now from the fact that $cd-ab$ and $bd-ac$ are distinct positive integers, we can see that no three of $a,b,c,d$ can be the same.
Thus, the lexicographically smallest value for the tuple $(a,b,c,d)$ is $(1,1,2,3)$, which gives the solution $(7,1,5,5)$ and $N=50$. Once we have this solution, it is easily checked that other tuples of $a,b,c,d$ give larger values of $N$.
