James' Rectangles

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type

James loves rectangles, so he wants to exterminate everyone that dislikes rectangles. In order to convince James that you like rectangles, you are to answer the following question.

Given N points on a 2-D coordinate plane, count the number of rectangles that can be formed by using four points as vertices.

Input Specification

The first line of input contains integer N.

The following N lines of input each contain x_i, y_i, representing points on the coordinate plane.

It's guaranteed that the points are distinct.

Output Specification

Output one integer, the number of rectangles that can be formed with the points given.

NOTE: rectangles may not be axis-aligned.

Constraints

1 \le N \le 1\,000

-10^6 \le x_i, y_i \le 10^6

Subtask 1 [20%]

1 \le N \le 50

-10^3 \le x_i, y_i \le 10^3

Subtask 2 [80%]

No additional constraints.

Sample Input

7
1 1
1 2
2 1
2 2
2 3
3 2
3 3

Sample Output

3

Comments

There are no comments at the moment.