Problem: Find the smallest positive integer $n$ such
that if $n$ squares of a $1000 \times 1000$ chessboard are colored,
then there will exist three colored squares
whose centers form a right triangle with sides
parallel to the edges of the board.

Solution: The answer is $n = 1999$.

For a construction with $n = 1998$,
take a punctured L as illustrated below (with $1000$ replaced by $4$):
\[ \begin{bmatrix} 1 \\ 1 \\ 1 \\ & 1 & 1 & 1 \end{bmatrix}. \]

We now show that if there is no right triangle,
there are at most $1998$ tokens (colored squares).
In every column with more than two tokens,
we have token emit a bidirectional horizontal
death ray (laser) covering its entire row:
the hypothesis is that the death ray won't hit any other tokens.
\begin{center}
\begin{asy}
size(6cm);
for (int i=1; i<=8; ++i) {
  if ((i-1)*(i-3)*(i-5) != 0) draw( (0.5,i)--(8.5,i), red+1, Arrows(TeXHead) );
  for (int j=1; j<=8; ++j) {
    if ( (i-j)/2 == (i-j)#2 )
      filldraw(shift(i-0.5,j-0.5)*unitsquare, opacity(0.2)+gray, gray);
    else
      draw(shift(i-0.5,j-0.5)*unitsquare, gray);
  }
}

draw( (3,2)--(3,7), blue);
draw( (5,4)--(5,8), blue);
void token(pair P) { fill(circle(P, 0.2), black); }
token( (1,1) );
token( (2,1) );
token( (3,2) );
token( (3,6) );
token( (3,7) );
token( (4,1) );
token( (5,4) );
token( (5,8) );
token( (6,5) );
token( (7,3) );
token( (8,1) );
\end{asy}
\end{center}

Assume there are $n$ tokens and that $n > 1000$.
Then obviously some column has more than two tokens,
so at most $999$ tokens don't emit a death ray
(namely, any token in its own column).
Thus there are at least $n-999$ death rays.
On the other hand, we can have at most $999$ death rays total
(since it would not be okay for the whole board to have death rays,
as some row should have more than two tokens).
Therefore, $n \le 999 + 999 = 1998$ as desired.