For query point (x,y), pick another point (x2,y) on same row; it defines side length d. Then check the two possible squares above/below.
Store counts of points and counts by row y -> {x: count}.
On count([x,y]), iterate all x2 in same row.
For each, compute d=x2-x and accumulate counts for corners (x,y±d) and (x2,y±d).
Axis-aligned square is uniquely determined by choosing the second point on the same horizontal line (sets side length and direction).
For query point (x,y), pick another point (x2,y) on same row; it defines side length d. Then check the two possible squares above/below.
Store counts of points and counts by row y -> {x: count}.
On count([x,y]), iterate all x2 in same row.
For each, compute d=x2-x and accumulate counts for corners (x,y±d) and (x2,y±d).
Axis-aligned square is uniquely determined by choosing the second point on the same horizontal line (sets side length and direction).