func_code_string: #include <bits/stdc++.h>   using namespace std;   int min(int a, int b) { return a < b ? a : b; }   long long max(long long a, long long b) { return a > b ? a : b; }   int read() {     int x = 0, w = 1;     char ch = getchar();     while (ch >  9  || ch <  0 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch <=  9  && ch >=  0 ) x = x * 10 + ch -  0 , ch = getchar();     return x * w;   }   void bmax(long long &t1, long long t2) { t1 = max(t1, t2); }   void bmin(long long &t1, long long t2) { t1 = min(t1, t2); }   const int N = 2e5 + 10;   const long long INF = 1e16;   struct Node {     long long mx, mn, ans;     Node(long long _mx = -INF, long long _mn = INF, long long _ans = -INF)         : mx(_mx), mn(_mn), ans(_ans) {}     Node operator+(const Node &tmp) const {       Node res = Node(mx, mn);       res.ans = max(tmp.mx - mn, max(ans, tmp.ans));       bmax(res.mx, tmp.mx);       bmin(res.mn, tmp.mn);       return res;     }   };   int n, m;   long long h[N], s[N];   struct SegmentTree {     Node tr[N << 2];     void Build(int pos, int l, int r) {       if (l == r) {         tr[pos].mx = h[l] + s[l - 1];         tr[pos].mn = s[l - 1] - h[l];         tr[pos].ans = -INF;         return;       }       int mid = (l + r) >> 1;       Build(pos << 1, l, mid);       Build(pos << 1 | 1, mid + 1, r);       tr[pos] = tr[pos << 1] + tr[pos << 1 | 1];     }     Node Query(int pos, int L, int R, int l, int r) {       if (R < l || L > r) return Node();       if (l <= L && R <= r) return tr[pos];       int mid = (L + R) >> 1;       Node res1 = Query(pos << 1, L, mid, l, r),            res2 = Query(pos << 1 | 1, mid + 1, R, l, r);       Node res = res1 + res2;       return res;     }   } Tr;   int main() {     n = read();     m = read();     s[0] = 0;     for (int i = 1; i <= n; i++) s[i] = read(), s[i + n] = s[i];     for (int i = 1; i <= n; i++) h[i] = read() * 2, h[n + i] = h[i];     for (int i = 1; i <= 2 * n; i++) s[i] += s[i - 1];     Tr.Build(1, 1, 2 * n);     while (m--) {       int l = read(), r = read();       Node ans;       if (l <= r)         ans = Tr.Query(1, 1, 2 * n, r + 1, l + n - 1);       else         ans = Tr.Query(1, 1, 2 * n, r + 1, l - 1);       printf( %lld n , ans.ans);     }     return 0;   }   