You are given a stream of points on a 2D plane. Each point has integer coordinates. Implement the `DetectSquares` class: (1) `add(point)`: Adds a new point [x, y] to the data structure. Duplicate points are allowed. (2) `count(point)`: Counts the number of ways to form axis-aligned squares with the given [x, y] as one of the four corners, where the other three corners are points already added.
Axis-Aligned Square Geometry
A square is defined by two diagonally opposite corners. If we are given a point `(x, y)` as one corner, then any other point `(x1, y1)` in the database can potentially be the diagonally opposite corner. For this to form a square: (1) `|x - x1| == |y - y1|` and (2) `|x - x1| > 0`. If these hold, the other two corners must be `(x, y1)` and `(x1, y)`. The number of ways to form this square is `count[(x1, y1)] * count[(x, y1)] * count[(x1, y)]`.