eolymp
bolt
Try our new interface for solving problems
Problems

Geysers

Geysers

The valley where Manny, Sid and Diego live can be represented as a two-dimensional plane. We introduce coordinate axes on this plane. The OX axis is horizontal and directed from west to east, the OY axis is vertical and directed from south to north. There are n geysers on this plane, each geyser is a point. Using the data about the location of geysers, friends want to assess how unstable the seismic situation in their valley is.

We call a triple of geysers bad if the triangle which vertices are geysers satisfies all of the following properties:

  • it is non-degenerate
  • rectangular,
  • isosceles,
  • at least one of its sides is parallel to OX or OY,
  • there are no other geysers on the sides of the triangle, except for three that lie at the vertices.

Friends believe that the more bad triplets of geysers, the more unstable the seismic situation. Help them count the number of bad triplets. Two triples are considered different if there is a geyser that is included in one triple and not included in the other.

Input

The first line contains one integer n (1n105) - the number of geysers.

Each of the next n lines contains two integers xi and yi (|xi|, |yi| ≤ 106 ) - coordinates of the point where the i-th geyser is located. It is guaranteed that no two geysers are located at the same point.

Output

Print one integer - the number of bad triplets of geysers.

prb11267.gif

Time limit 2 seconds
Memory limit 128 MiB
Input example #1
6
0 0
2 0
2 1
1 1
1 2
0 2
Output example #1
5
Source 2021 ITMO University, Second personal olympiad, February 13, Problem D