Let $S$ be a set of $n$ points in the plane, no $3$ collinear. Determine the maximum number of right-angled triangles with all three vertices as points in $S$.
This is a slightly more difficult and precise question than IMO 1970. For $n=3$, clearly the maximum is one. For $n=4$, we can have four triangles, etc. However, I don't know how to continue.



OK, for record's sake here's a solution.
The answer is $\frac{n(n-2)}{2}$ for even $n$ and $\frac{(n-1)(n-2)}{2}$ for odd $n$. The construction is to draw a circle, and pair up your points to be diametrically opposite (so when $n$ is odd, we have one lonely point not in a pair).
To show that we can't do better, for each point $P$, we count the number of triangles for which $P$ is the right angle. The key insight is that if $X,Y$ form a right angle at $P$, then this is the only right triangle at $P$ involving $X$ or $Y$. Otherwise, if (say) $\angle YPZ=90^{\circ}$, then $X$, $P$, $Z$ are collinear, contradiction. So there are at most $\lfloor\frac{n-1}{2}\rfloor$ triangles that their right angle at $P$.
Applying this to all $n$ choices of $P$ implies the result for even $n$. Some more fiddling is required when $n$ is odd.