func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T read() {     register T sum = 0;     register char cc = getchar();     int sym = 1;     while (cc !=  -  && (cc >  9  || cc <  0 )) cc = getchar();     if (cc ==  - ) sym = -1, cc = getchar();     sum = sum * 10 + cc -  0 ;     cc = getchar();     while (cc >=  0  && cc <=  9 ) sum = sum * 10 + cc -  0 , cc = getchar();     return sym * sum;   }   template <typename T>   inline T read(T &a) {     a = read<T>();     return a;   }   template <typename T, typename... Others>   inline void read(T &a, Others &...b) {     a = read(a);     read(b...);   }   struct Data {     int x, y, p;   } a[200010];   int n, l[200010], r[200010], t[200010];   long long ans1, ans2;   int lowbit(int x) { return x & -x; }   void change(int x, int y) {     for (int i = x; i <= n << 1; i += lowbit(i)) t[i] += y;   }   int query(int x) {     int res = 0;     for (int i = x; i; i -= lowbit(i)) res += t[i];     return res;   }   bool cmp1(const Data &a, const Data &b) { return a.x < b.x; }   bool cmp2(const Data &a, const Data &b) { return a.y > b.y; }   int main() {     read(n);     for (int i = 1; i <= n; i++) {       read(a[i].x, a[i].y);       if (a[i].x > a[i].y) swap(a[i].x, a[i].y);       a[i].p = i;     }     sort(a + 1, a + 1 + n, cmp1);     for (int i = 1; i <= n; i++) {       l[a[i].p] += query(a[i].x) + query(n << 1) - query(a[i].y);       change(a[i].y, 1);     }     memset(t + 1, 0, sizeof(int) * (n << 1));     for (int i = n; i >= 1; i--) {       r[a[i].p] = query(a[i].y);       change(a[i].y, 1);     }     memset(t + 1, 0, sizeof(int) * (n << 1));     sort(a + 1, a + 1 + n, cmp2);     for (int i = 1; i <= n; i++) {       l[a[i].p] += query(n << 1) - query(a[i].y);       change(a[i].x, 1);     }     ans1 = 1ll * n * (n - 1) * (n - 2) / 6;     for (int i = 1; i <= n; i++) {       ans1 -= 1ll * l[i] * r[i];       ans2 += 1ll * (l[i] + r[i]) * (n - l[i] - r[i] - 1);     }     printf( %lld n , ans1 - ans2 / 2);     return 0;   }   