Friendly Points
Easy
Execution time limit is 12 seconds
Runtime memory usage limit is 256 megabytes
Consider n distinct points on a plane.
Two points from that set are said to be friends, when there exists a rectangle with sides parallel to coordinate axes that contains those two points and doesn’t contain any other point from the given set. A rectangle is said to contain a point if the point lies within the rectangle or on its border.
How many pairs of friends are there among the given points?
Input
The first line of the input file contains an integer n, 1 ≤ n ≤ 100000.
The next n lines contain two integers each, the coordinates of the given points. The coordinates don’t exceed 10^9 by absolute value.
Output
Output one integer number — the sought number of pairs of friends.
Examples
Input #1
Answer #1
Submissions 9
Acceptance rate 22%