4. In the coordinate plane, there are 100 points. Let $N$ be the number of triples of points $(A, B, C)$ that satisfy the following conditions: the vertices are chosen from these 100 points, the y-coordinates of $A$ and $B$ are the same, and the x-coordinates of $B$ and $C$ are the same. Find the maximum value of $N$.
4. Take point $(x, y)(1 \leqslant x, y \leqslant 10)$.

Since the y-coordinates of points $A$ and $B$ are the same, and the x-coordinates of points $B$ and $C$ are the same, for each point $B$, there are 9 possible positions for $A$ and 9 possible positions for $C$.
Thus, $N=100 \times 9 \times 9=8100$.
Consider the 100 points.

Assume these points lie on $k$ horizontal lines, and let the number of points on these $k$ lines be $a_{1}, a_{2}, \cdots, a_{k}$.

Calculate the number of triples $(A, B, C)$ on the first horizontal line $l$ where the x-coordinates of $B$ and $C$ are the same.

For any point $C$ not on line $l$, there is at most one point $B$ on $l$ with the same x-coordinate.

If such a point $B$ exists, then there are exactly $a_{1}-1$ such triples.

Thus, the number of triples on line $l$ is at most $\left(a_{1}-1\right)\left(100-a_{1}\right)$.
Therefore, $N \leqslant \sum_{j=1}^{k}\left(a_{j}-1\right)\left(100-a_{j}\right)$.
By $a_{1}+a_{2}+\cdots+a_{k}=100$, we get
$N \leqslant 101 \sum_{j=1}^{k} a_{j}-\sum_{j=1}^{k} a_{j}^{2}-100 k$
$$
=10100-\sum_{j=1}^{k} a_{j}^{2}-100 k \text {. }
$$

By the Cauchy-Schwarz inequality, we have
$$
\begin{array}{l}
\sum_{j=1}^{k} a_{j}^{2} \geqslant \frac{1}{k}\left(\sum_{j=1}^{k} a_{j}\right)^{2}=\frac{10000}{k} \\
\Rightarrow N \leqslant 10100-\left(\frac{10000}{k}+100 k\right) \\
\leqslant 10100-2000=8100 .
\end{array}
$$