func_code_string: #include <bits/stdc++.h>   using namespace std;   int p[200010], q, l[200010], c[200010], par[20][200010];   stack<int> st;   int main() {     int j, i, q, u, v, n;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d%d , &p[i], &l[i]);       l[i] += p[i];     }     scanf( %d , &q);     memset(par, -1, sizeof(par));     for (i = n - 1; i >= 0; i--) {       c[i] = 2e9;       while (!st.empty() && l[st.top()] <= l[i]) st.pop();       if (!st.empty()) {         int last = st.top();         c[i] = c[last] + max(0, p[last] - l[i]);         par[0][i] = last;       } else         c[i] = 0;       for (j = 1; ~par[j - 1][i] && j < 20; j++) {         par[j][i] = par[j - 1][par[j - 1][i]];       }       st.push(i);     }     while (q--) {       int u, v, lo;       scanf( %d%d , &u, &v);       u--;       v--;       lo = u;       for (i = 19; i >= 0; i--) {         if (~par[i][lo] && par[i][lo] <= v) lo = par[i][lo];       }       printf( %d n , c[u] - c[lo]);     }   }   