CF650A.Watchmen

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are nn watchmen on a plane, the ii -th watchman is located at point (xi,yi)(x_{i},y_{i}) .

They need to arrange a plan, but there are some difficulties on their way. As you know, Doctor Manhattan considers the distance between watchmen ii and jj to be xixj+yiyj|x_{i}-x_{j}|+|y_{i}-y_{j}| . Daniel, as an ordinary person, calculates the distance using the formula .

The success of the operation relies on the number of pairs (i,j)(i,j) ( 1<=i<j<=n ), such that the distance between watchman ii and watchmen jj calculated by Doctor Manhattan is equal to the distance between them calculated by Daniel. You were asked to compute the number of such pairs.

输入格式

The first line of the input contains the single integer nn ( 1<=n<=2000001<=n<=200000 ) — the number of watchmen.

Each of the following nn lines contains two integers xix_{i} and yiy_{i} ( xi,yi<=109|x_{i}|,|y_{i}|<=10^{9} ).

Some positions may coincide.

输出格式

Print the number of pairs of watchmen such that the distance between them calculated by Doctor Manhattan is equal to the distance calculated by Daniel.

输入输出样例

  • 输入#1

    3
    1 1
    7 5
    1 5
    

    输出#1

    2
    
  • 输入#2

    6
    0 0
    0 1
    0 2
    -1 1
    0 1
    1 1
    

    输出#2

    11
    

说明/提示

In the first sample, the distance between watchman 11 and watchman 22 is equal to 17+15=10|1-7|+|1-5|=10 for Doctor Manhattan and for Daniel. For pairs (1,1)(1,1) , (1,5)(1,5) and (7,5)(7,5) , (1,5)(1,5) Doctor Manhattan and Daniel will calculate the same distances.

首页