Under construction

Still being built. Things may change

Axis-Parallel Lines

Interview

Time limit2sMemory limit128 MB

Summary
Given n points, count how many horizontal or vertical lines pass through at least two of them.
Level

Easy3 of 10

Topics
Hash map, Array
Solved
No attempts yet

Problem

There are n points on the plane. Count the number of lines that pass through at least two of the given points and are parallel to the x-axis or the y-axis. If the same coordinate pair appears multiple times, each occurrence is considered a distinct point.

Input

The first line contains the number of points n (1 <= n <= 100,000). Each of the next n lines contains two integers x and y, the coordinates of a point. The same coordinate pair may appear multiple times; each occurrence is considered a distinct point. Each coordinate is an integer with absolute value less than 2^31.

Output

Print the number of lines satisfying the condition.

Examples1

  1. Example 1

    Input
    4
    0 0
    10 10
    0 10
    10 0
    
    Expected output
    4