Rectangles
시간 제한2초메모리 제한1024 MB
서로 다른 n개의 점이 주어질 때, 네 꼭짓점이 모두 주어진 점인 축에 평행한 직사각형의 개수를 센다. 개수가 클 수 있어 단순한 쌍 조합 열거로는 부족하다.
문제
An axis-parallel rectangle is a rectangle with sides parallel to the -axis or the -axis. Also its four vertices are different from each other.
For a set of points in the plane, an axis-parallel rectangle is called to be contained in if it has, as its vertices, four points belonging to .
For example, in the left of Figure J.1, a set of ten points is given in the plane. Then as the right of Figure J.1, there are three axis-parallel rectangles contained in .

Figure J.1 There are three axis-parallel rectangles contained in the given set of points.
Given a set of distinct points in the plane, write a program to output the number of all the axis-parallel rectangles contained in .
입력
Your program is to read from standard input. The input starts with a line containing an integer (), where is the number of points given in the plane. In the following lines, each line contains two integers that represent, respectively, the -coordinate and the -coordinate of a point. These coordinate values are between and and all the given points are distinct.
출력
Your program is to write to standard output. Print exactly one line. The line should contain the number of axis-parallel rectangles contained in the given point set.