3. On each of the lines $y=1$ and $y=6$, there are 200 points with abscissas $1,2,3, \ldots, 200$. In how many ways can three points be chosen from the 400 marked points so that they form the vertices of a right triangle?
Answer: $C_{200}^{2} \cdot 4 + 190 \cdot 2 + 174 \cdot 4 = 80676$.

Solution. There are two possibilities.

1) The hypotenuse of the triangle lies on one of the lines, and the vertex of the right angle lies on the other line. Let $A B C$ be the given triangle with a right angle at vertex $C$, and $C H$ be its height dropped to the hypotenuse. From the proportionality of segments of a right triangle, we get that $C H^{2} = A H \cdot B H$, i.e., $A H \cdot B H = 25$. Since $A H$ and $B H$ are integers, the following cases are possible: $A H = B H = 5, A H = 25$ and $B H = 1, A H = 1$ and $B H = 25$.

In the first of these cases, the hypotenuse $A B$, equal to 10, can be placed in $190 \cdot 2 = 380$ ways (200 - 10 ways of placement on each of the two given lines), and the position of vertex $C$ is uniquely determined.

In the second and third cases, the length of the hypotenuse is 26, and it can be placed in $2(200 - 26) = 348$ ways. For each position of the hypotenuse, there are two ways to place the vertex - resulting in $2 \cdot 348 = 696$ ways.

2) One of the legs of the triangle (let's call it $B C$) is perpendicular to the given lines, and the other leg ($A C$) lies on one of the given lines. Then the position of leg $B C$ can be chosen in 200 ways. For each variant of the placement of leg $B C$, vertex $A$ can be placed in 398 ways (all points except the already chosen $B$ and $C$ are suitable) - in total, we get $200 \cdot 398 = 79600$ ways.

In total, we get $380 + 696 + 79600 = 80676$ ways.