func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, p, q, r, now;   int a[500050], b[500050], c[500050], id[500050], mxx[500050], mxy[500050];   long long ans;   struct seg {     int mark[500050 << 2], mx[500050 << 2], mn[500050 << 2];     long long sum[500050 << 2];     void push_up(int id) {       sum[id] = sum[id << 1] + sum[id << 1 | 1];       mx[id] = max(mx[id << 1], mx[id << 1 | 1]);       mn[id] = min(mn[id << 1], mn[id << 1 | 1]);     }     void make_con(int l, int r, int id, int val) {       mark[id] = val;       sum[id] = 1ll * val * (r - l + 1);       mx[id] = mn[id] = val;     }     void push_down(int l, int r, int id) {       if (mark[id]) {         int m = l + r >> 1;         make_con(l, m, id << 1, mark[id]);         make_con(m + 1, r, id << 1 | 1, mark[id]);         mark[id] = 0;       }     }     void modify(int L, int R, int val, int l, int r, int id) {       if (r < L || R < l) return;       if (L <= l && r <= R) {         make_con(l, r, id, val);         return;       }       push_down(l, r, id);       int m = l + r >> 1;       modify(L, R, val, l, m, id << 1);       modify(L, R, val, m + 1, r, id << 1 | 1);       push_up(id);     }     long long sumquery(int L, int R, int l, int r, int id) {       if (r < L || R < l) return 0;       if (L <= l && r <= R) {         return sum[id];       }       push_down(l, r, id);       int m = l + r >> 1;       return sumquery(L, R, l, m, id << 1) +              sumquery(L, R, m + 1, r, id << 1 | 1);     }     int lquery(int val, int l, int r, int id) {       if (l == r) return l;       push_down(l, r, id);       int m = l + r >> 1;       if (mn[id << 1] < val) return lquery(val, l, m, id << 1);       return lquery(val, m + 1, r, id << 1 | 1);     }     int rquery(int val, int l, int r, int id) {       if (l == r) return l;       push_down(l, r, id);       int m = l + r >> 1;       if (mx[id << 1 | 1] >= val) return rquery(val, m + 1, r, id << 1 | 1);       return rquery(val, l, m, id << 1);     }   } ST;   bool cmp(int x, int y) { return a[x] < a[y]; }   void modify(int x, int y) {     if (ST.mn[1] >= y) return;     int l = ST.lquery(y, 1, q, 1);     if (l <= x) ST.modify(l, x, y, 1, q, 1);   }   long long query(int x, int y) {     long long rtn = 1ll * (q - x + 1) * (r - y + 1);     if (ST.mx[1] < y) return rtn;     int r = ST.rquery(y, 1, q, 1);     if (x <= r) rtn -= ST.sumquery(x, r, 1, q, 1) - 1ll * (r - x + 1) * (y - 1);     return rtn;   }   int main() {     scanf( %d %d %d %d , &n, &p, &q, &r);     for (int i = 0; i < n; i++) {       scanf( %d %d %d , &a[i], &b[i], &c[i]);       id[i] = i;     }     sort(id, id + n, cmp);     mxx[n] = mxy[n] = 1;     for (int i = n - 1; i >= 0; i--) {       mxx[i] = max(mxx[i + 1], b[id[i]] + 1);       mxy[i] = max(mxy[i + 1], c[id[i]] + 1);     }     for (int i = 1; i <= p; i++) {       while (now < n && a[id[now]] < i) modify(b[id[now]], c[id[now]]), now++;       ans += query(mxx[now], mxy[now]);     }     printf( %I64d n , ans);   }   