Under construction

Still being built. Things may change

Each to Their Own Square

Interview

Time limit3sMemory limit1024 MB

Summary
For each test case, count the squares whose four corners are all among the given n points, stopping when n is 0.
Level

Medium5 of 10

Topics
Hash map, Geometry
Solved
No attempts yet

Problem

Ana and Bob enjoy playing with geometry. Last week, while listening to a song about squares, Bob was playing with his wooden blocks and wondered how many squares could be formed using the blocks as vertices, without moving them. Ana had recently learned to program and came up with the idea of writing a program to solve this problem. However, she struggled with it and asked for your help. Since the blocks are small compared to the distances between them, you may treat them as points on a plane.

Input

The input contains multiple test cases. Each test case begins with a line containing a single integer nn, where 4≤n≤10004 \le n \le 1000. The next nn lines each contain two integers xx and yy, the coordinates of a block, where −1000000≤x,y≤1000000-1000000 \le x, y \le 1000000. The input ends with a line containing n=0n = 0, which should not be processed.

Output

For each test case, print one line containing a single integer, the number of squares that can be obtained from the given positions.

Examples1

  1. Example 1

    Input
    6
    1 0
    0 1
    2 1
    1 2
    0 -1
    2 -1
    0
    
    Expected output
    2