func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Ans {     long long maxm, maxp, lmr, rml;     Ans() { maxm = maxp = lmr = rml = -(1ll << 60); }   } node[100010 << 2];   void Union(Ans &o, Ans a, Ans b) {     o.maxm = max(a.maxm, b.maxm);     o.maxp = max(a.maxp, b.maxp);     o.lmr = max(max(a.lmr, b.lmr), a.maxp + b.maxm);     o.rml = max(max(a.rml, b.rml), a.maxm + b.maxp);   }   long long h[100010], d[100010], n;   void build(int o, int l, int r) {     if (l == r) {       node[o].maxm = 2 * h[l] - (long long)d[l];       node[o].maxp = 2 * h[l] + (long long)d[l];       node[o].rml = -(1ll << 60);       node[o].lmr = -(1ll << 60);       return;     }     build((o << 1), l, ((l + r) >> 1));     build((o << 1 | 1), ((l + r) >> 1) + 1, r);     Union(node[o], node[(o << 1)], node[(o << 1 | 1)]);   }   Ans query(int L, int R, int o = 1, int l = 1, int r = n) {     Ans ret;     if (L > R) return ret;     if (L <= l && r <= R) return node[o];     if (R <= ((l + r) >> 1)) return query(L, R, (o << 1), l, ((l + r) >> 1));     if (L > ((l + r) >> 1))       return query(L, R, (o << 1 | 1), ((l + r) >> 1) + 1, r);     Union(ret, query(L, R, (o << 1), l, ((l + r) >> 1)),           query(L, R, (o << 1 | 1), ((l + r) >> 1) + 1, r));     return ret;   }   int Q;   Ans ansl, ansr;   int main() {     scanf( %d%d , &n, &Q);     for (int i = 1; i <= n; i++) {       cin >> d[i + 1];       d[i + 1] += d[i];     }     for (int i = 1; i <= n; i++) cin >> h[i];     build(1, 1, n);     while (Q--) {       int l, r;       scanf( %d %d , &l, &r);       if (l <= r) {         ansl = query(r + 1, n);         ansr = query(1, l - 1);         cout << max(max(ansr.rml, ansl.rml), ansr.maxp + d[n + 1] + ansl.maxm)              << endl;       } else {         cout << query(r + 1, l - 1).rml << endl;       }     }     return 0;   }   