func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int N = 2e5 + 5;   inline int read() {     int res = 0, ch, flag = 0;     if ((ch = getchar()) ==  - )       flag = 1;     else if (ch >=  0  && ch <=  9 )       res = ch -  0 ;     while ((ch = getchar()) >=  0  && ch <=  9 ) res = res * 10 + ch -  0 ;     return flag ? -res : res;   }   int n, m, cnt;   struct node {     int x, y;   };   node p[N];   vector<int> data;   int bit[N], t[N];   long long ans;   void add(int i) {     while (i <= m) {       bit[i]++;       i += i & -i;     }   }   int sum(int i) {     int res = 0;     while (i > 0) {       res += bit[i];       i -= i & -i;     }     return res;   }   bool cmp(node a, node b) {     if (a.y != b.y) return a.y > b.y;     return a.x < b.x;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &p[i].x, &p[i].y);       data.push_back(p[i].x);     }     sort(data.begin(), data.end());     data.erase(unique(data.begin(), data.end()), data.end());     m = data.size();     for (int i = 1; i <= n; i++)       p[i].x = lower_bound(data.begin(), data.end(), p[i].x) - data.begin() + 1;     sort(p + 1, p + n + 1, cmp);     for (int i = 1; i <= n;) {       int j = i;       while (j < n && p[j].y == p[j + 1].y) j++;       t[i - 1] = 0;       for (int k = i; k <= j; k++) {         if (sum(p[k].x) - sum(p[k].x - 1) == 0) {           add(p[k].x);           cnt++;         }         t[k] = sum(p[k].x);       }       for (int k = i; k <= j; k++)         ans += 1LL * (t[k] - t[k - 1]) * (cnt - t[k] + 1);       i = j + 1;     }     printf( %I64d n , ans);     return 0;   }   