#include <bits/stdc++.h>   using namespace std;   const int Maxn = 200005;   struct M {     int val, pos;   };   M a[Maxn], b[Maxn];   int idx[Maxn], idy[Maxn], Nx[Maxn], Ny[Maxn];   int read() {     int sum = 0, t = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) t = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       sum = sum * 10 + c -  0 ;       c = getchar();     }     return sum * t;   }   bool cmp(M x, M y) {     return (x.val < y.val || (x.val == y.val && b[x.pos].val < b[y.pos].val));   }   long long C2(long long x) { return 1ll * x * (x - 1) / 2; }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       a[i].val = read(), b[i].val = read();       a[i].pos = b[i].pos = i;     }     sort(a + 1, a + n + 1, cmp);     int cnt = 0, same = 1;     long long res = 0;     a[0].val = b[0].val = -0x3f3f3f3f;     cnt = 0;     for (int i = 1; i <= n; ++i) {       if (a[i].val != a[i - 1].val)         cnt++, res += C2(same), same = 1;       else {         if (b[a[i].pos].val == b[a[i - 1].pos].val)           same++;         else           res += C2(same), same = 1;       }       idx[a[i].pos] = cnt;     }     res += C2(same);     sort(b + 1, b + n + 1, cmp);     cnt = 0;     for (int i = 1; i <= n; ++i) {       if (b[i].val != b[i - 1].val) cnt++;       idy[b[i].pos] = cnt;     }     for (int i = 1; i <= n; ++i) {       Nx[idx[i]]++;       Ny[idy[i]]++;     }     long long ans = 0;     for (int i = 1; i <= n; ++i) {       ans += C2(Nx[i]) + C2(Ny[i]);     }     ans -= res;     printf( %lld , ans);     return 0;   }   