P1665 Square Counting

Description

Given $N$ points on a plane, you need to count the number of squares whose vertices are among these points. Note that the square’s sides do not need to be parallel to the coordinate axes.

Input Format

The first line contains an integer $N$. Each of the next $N$ lines contains two numbers, representing the coordinates of a point.

Output Format

Output a single number, the number of squares.

Explanation/Hint

For $20\%$ of the testdata, $1 \leq N \leq 20$. For $100\%$ of the testdata, $1 \leq N \leq 500$, $-50 \leq X_i, Y_i \leq 50$, and the points are distinct. Translated by ChatGPT 5