What is my mistake in finding this pythagorean triplet? Since Project Euler copyright license requires that you attribute the problem to them, I'd like to add that this is about question 9 there.
I am trying to solve this problem on only two brain cells and can't figure out what am I doing wrong. Here is the system for $(a, b, c) \in \mathbb{N}^3$,
\begin{align*}
a^2 +b^2 &= c^2 \\
a+ b + c &= 1000 \\
a &< b < c
\end{align*}
Here is my approach,
\begin{align*}
a + b + c &= 1000 \\
a + b &= 1000 - c &&\text{Subtract } c\\
a^2 + b^2 + 2ab &= 1000^2 + c^2 - 2000c &&\text{Square both sides}\\
c^2 + 2ab &= 1000^2 + c^2 - 2000c &&\text{Since }a^2 +b^2 = c^2\\
2ab &= 1000^2 - 2000c &&\text{Subtract } c^2\\
\frac{ab}{500} &= 1000 - 2c &&\text{Divide } 1000\\
2c &= 1000 - \frac{ab}{500} &&\text{Rearrange}\\
\end{align*}
Now let $a=5,b=200$,
\begin{align*}
2c &= 1000 - 2\\
2c &= 998 \\
c &= (998 \div 2) = 499 \\
\end{align*}
But certainly these values do not work. I can't see why.

$a = p^2 - q^2\\
b = 2pq\\
c = p^2 + q^2$
For any $(p,q:p>q), (a,b,c)$ will be a pythagorean tripple
$p^2 - q^2 + 2pq + p^2 + q^2 = 1000\\
2p^2 + 2pq = 1000\\
p(q+p) = 500$
$p$ is a factor of $500$
If $p$ is too small, $q$ is too big, and $p^2 - q^2 < 0$
And $p$ is too big, $q< 0$
$\sqrt{250}<p<\sqrt{500}$
$p = 20,$ works
Our triple is $(375,200,425)$ but we need to reorder to meet one of the criteria.
