3. On each of the lines $y=1$ and $y=12$, 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: 80268.

Solution. There are two possibilities.

1) The hypotenuse of the triangle lies on one of the lines, and the vertex of the right angle is on the second line. Let $ABC$ be the given triangle with a right angle at vertex $C$, and $CH$ be its height dropped to the hypotenuse. From the proportionality of the segments of the right triangle, we get that $CH^2 = AH \cdot BH$, i.e., $AH \cdot BH = 121$. Since $AH$ and $BH$ are integers, the following cases are possible: $AH = BH = 11$, $AH = 121$ and $BH = 1$, $AH = 1$ and $BH = 121$.

In the first of these cases, the hypotenuse $AB$, equal to 22, can be placed in $178 \cdot 2 = 356$ ways (200 - 22 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 122, and it can be placed in $2(200 - 122) = 156$ ways. For each position of the hypotenuse, there are two ways to place the vertex - resulting in $2 \cdot 156 = 312$ ways.

2) One of the legs of the triangle (let's call it $BC$) is perpendicular to the given lines, and the second leg ($AC$) lies on one of the given lines. Then the position of the leg $BC$ can be chosen in 200 ways. For each variant of the placement of the leg $BC$, the 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 $356 + 312 + 79600 = 80268$ ways.