Problem C. Count Squares

Author:B. Vasilyev, A. Klenin   Time limit:3 sec
Input file:input.txt   Memory limit:64 Mb
Output file:output.txt  

Statement

Given a set of points with integer coordinates xi, yi, i = 1… N, your program must find all the squares having each of four vertices in one of these points.

Input file format

Input file contains integer N followed by N pairs of integers xi yi.

Output file format

Output file must contain a single integer — number of squares found.

Constraints

 − 104 ≤ xi, yi ≤ 104, 1 ≤ N ≤ 2000. All points in the input are different.

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
4 0 0 4 3 -3 4 1 7
1
2
9
1 1  1 2  1 3  
2 1  2 2  2 3  
3 1  3 2  3 3
6

0.091s 0.017s 13