Time limit
2s
Memory limit
128 MB
You are given N distinct points on a two-dimensional plane. Choose four of these points and connect them. Count how many quadrilaterals formed this way are rectangles whose four sides are parallel to either the x-axis or the y-axis.
The rectangle must have positive area, so it must use two distinct x-coordinates and two distinct y-coordinates.
The first line contains the number of points N. (1 <= N <= 5,000)
Each of the next N lines contains the coordinates x and y of one point. Every coordinate is an integer between -1,000,000,000 and 1,000,000,000, inclusive. No two points have the same coordinates.
Print the number of rectangles that can be formed.