L-paths

Time limit: 0.3s Memory limit: 64MB Input: Output:

Back when he was little, Stefan used to look a lot at the sky during the night, hoping to see various kinds of stars and to imagine different kinds of lines which can be drawn amongst them. Looking back at his childhood, he realized that he can now use the computer to refine this process!

Therefore, he gives you the 2D map of the stars during one particular night, and he tells you that there were nn stars on the sky. Furthermore, he also tells you that he is interested in finding the number of parallel L-shaped paths he can find in the given star map.

A parallel L-shaped path is a sequence of three stars which form an L-shape and it is parallel to the coordinate axes. The L can have its sides rotated, as long as it still forms an L. Furthermore, the L can't be degenerated(i.e: a straight line).

Input data

The first line of the input contains nn, the number of stars.

The next line of the input contains the coordinates of the nn stars. All stars are distinct.

Output data

The output contains the number of L-shaped paths we have in the star map.

Constraints and clarifications

  • 1n21051 \leq n \leq 2 \cdot 10^5
  • 0x,y21050 \leq x, y \leq 2 \cdot 10^5
  • For tests worth 2020 points, 1n2001 \leq n \leq 200
  • For tests worth 3030 more points, 1n2 0001 \leq n \leq 2 \ 000.

Example 1

stdin

5
5 5
8 5
5 8
5 0
0 5

stdout

4

Log in or sign up to be able to send submissions!