func_code_string: #include <bits/stdc++.h>   using namespace std;   int num, rt[200010], n;   struct data {     int l, r, v;   } tr[200010 * 20];   void insert(int p, int l, int r, int n, int &x) {     x = ++num;     tr[x] = tr[n];     if (l == r) {       tr[x].v++;       return;     }     int mid = l + r >> 1;     if (p <= mid)       insert(p, l, mid, tr[n].l, tr[x].l);     else       insert(p, mid + 1, r, tr[n].r, tr[x].r);     tr[x].v = tr[tr[x].l].v + tr[tr[x].r].v;   }   int ask(int al, int ar, int l, int r, int lx, int x) {     if (x == 0) return 0;     if (al <= l && r <= ar) return tr[x].v - tr[lx].v;     int mid = l + r >> 1, ans = 0;     if (al <= mid) ans = ask(al, ar, l, mid, tr[lx].l, tr[x].l);     if (ar > mid) ans += ask(al, ar, mid + 1, r, tr[lx].r, tr[x].r);     return ans;   }   int ask(int r1, int r2, int l1, int l2) {     if (r1 > r2 || l1 > l2) return 0;     return ask(r1, r2, 1, n, rt[l1 - 1], rt[l2]);   }   int main() {     int m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       insert(x, 1, n, rt[i - 1], rt[i]);     }     for (int i = 1; i <= m; i++) {       int l1, l2, r1, r2;       scanf( %d%d%d%d , &l1, &r1, &l2, &r2);       long long ans = 0;       ans += 1ll * ask(1, r1 - 1, 1, l1 - 1) * ask(r1, n, l1, n);       ans += 1ll * ask(1, r1 - 1, l1, l2) * ask(r1, n, 1, n);       ans += 1ll * ask(1, r1 - 1, l2 + 1, n) * ask(r1, n, 1, l2);       ans += 1ll * ask(r1, r2, 1, l1 - 1) * ask(r1, n, l1, n);       ans += 1ll * ask(r1, r2, l1, l2) *              (ask(r1, n, 1, n) - ask(r1, r2, 1, l1 - 1) - ask(r1, r2, l1, l2));       ans += 1ll * ask(r1, r2, l2 + 1, n) * ask(r2 + 1, n, 1, l2);       ans += 1ll * ask(r1, r2, l1, l2) * (ask(r1, r2, l1, l2) - 1) / 2;       printf( %lld n , ans);     }   }   