Under construction

Still being built. Things may change

Art Class

Interview

Time limit1sMemory limit1024 MB

Summary
Given N points above the x-axis, count the distinct intersection points of the slope +1 and slope -1 lines drawn through them, on or above the axis.
Level

Medium5 of 10

Topics
Geometry, Sorting, Hash map
Solved
No attempts yet

Problem

Changha won the subject excellence award for the final project of his art class the year before last. He drew the following picture.

  1. Prepare an empty two-dimensional coordinate plane.
  2. Choose NN points (X_1,Y_1),(X_2,Y_2),⋯ ,(X_N,Y_N)(X\_1, Y\_1), (X\_2, Y\_2), \cdots, (X\_N, Y\_N). Here Y_i>0Y\_i > 0.
  3. Draw a line representing the xx-axis.
  4. For each i=1,2,⋯ ,Ni = 1, 2, \cdots, N, draw two lines through the point (X_i,Y_i)(X\_i, Y\_i) with slopes 11 and −1-1. Do not draw the parts below the xx-axis.

The example drawing is shown below.

Eric thinks the secret of the award is the beautiful harmony of the intersection points in the drawing. He wants to count the distinct intersection points in Changha's drawing. Lines that overlap completely count as one line.

Input

The first line contains an integer NN.

Each of the next NN lines contains two integers X_iX\_i and Y_iY\_i, separated by a space.

Output

Print the number of distinct intersection points in Changha's drawing.

Constraints

  • 1≤N≤2×1051 \le N \le 2 \times 10^5
  • −109≤X_i≤109-10^9 \le X\_i \le 10^9
  • 1≤Y_i≤1091 \le Y\_i \le 10^9

Examples1

  1. Example 1

    Input
    3
    4 3
    6 1
    8 1
    
    Expected output
    9