func_code_string: #include <bits/stdc++.h>   struct PP {     int l, r, sum, lv, rv, cover;     int mid() { return (l + r) >> 1; }     void doit() { sum = lv = rv = cover ? 0 : dis(); }     int dis() { return r - l; }   } q[100005 * 3];   int max(int a, int b) { return a > b ? a : b; }   void Build(int l, int r, int x) {     q[x].l = l;     q[x].r = r;     q[x].sum = q[x].lv = q[x].rv = q[x].dis();     q[x].cover = -1;     if (l == r - 1) return;     int mid = q[x].mid();     Build(l, mid, (x << 1));     Build(mid, r, ((x << 1) | 1));   }   void pushdown(int x) {     q[(x << 1)].cover = q[((x << 1) | 1)].cover = q[x].cover;     q[(x << 1)].doit();     q[((x << 1) | 1)].doit();     q[x].cover = -1;   }   void Pushup(int x) {     q[x].sum = max(q[(x << 1)].rv + q[((x << 1) | 1)].lv,                    max(q[(x << 1)].sum, q[((x << 1) | 1)].sum));     q[x].lv = q[(x << 1)].lv;     q[x].rv = q[((x << 1) | 1)].rv;     if (q[(x << 1)].sum == q[(x << 1)].dis()) q[x].lv += q[((x << 1) | 1)].lv;     if (q[((x << 1) | 1)].sum == q[((x << 1) | 1)].dis())       q[x].rv += q[(x << 1)].rv;   }   void update(int l, int r, int c, int x) {     if (l <= q[x].l && q[x].r <= r) {       q[x].cover = c;       q[x].doit();       return;     }     if (q[x].cover != -1) pushdown(x);     int mid = q[x].mid();     if (l < mid) update(l, r, c, (x << 1));     if (mid < r) update(l, r, c, ((x << 1) | 1));     Pushup(x);   }   int query(int w, int x) {     if (q[x].sum >= w && q[x].cover == 0) return q[x].l;     if (q[x].cover != -1) pushdown(x);     if (q[(x << 1)].sum >= w)       return query(w, (x << 1));     else if (q[(x << 1)].rv + q[((x << 1) | 1)].lv >= w)       return q[(x << 1)].r - q[(x << 1)].rv;     else if (q[((x << 1) | 1)].sum >= w)       return query(w, ((x << 1) | 1));     else       return -1;   }   struct SS {     int l, r;   } cnt[100005];   int main() {     int i, m, op, a;     int L, B, F;     while (scanf( %d%d%d , &L, &B, &F) != EOF) {       scanf( %d , &m);       Build(0, B + L + F, 1);       for (i = 1; i <= m; i++) {         scanf( %d%d , &op, &a);         if (op == 1) {           int pos = query(B + a + F, 1);           if (pos == -1) {             printf( -1 n );             continue;           }           printf( %d n , pos);           update(pos + B, pos + B + a, 1, 1);           cnt[i].l = pos + B;           cnt[i].r = pos + B + a;         } else           update(cnt[a].l, cnt[a].r, 0, 1);       }     }     return 0;   }   