func_code_string: #include <bits/stdc++.h>   using LL = long long;   const int N = 100000 + 5;   LL D[N], H[N];   int n, m;   struct Unit {     int l, r;     LL Lmax, Rmax, Mmax, sum;     void show() {       printf( l = %d,r = %d n , l, r);       printf( Lmax = %I64d,Rmax = %I64d,Mmax = %I64d,sum = %I64d n , Lmax, Rmax,              Mmax, sum);     }     Unit operator+(const Unit &rhs) const {       Unit ret;       ret.l = l;       ret.r = rhs.r;       ret.Lmax = std::max(Lmax + D[r] + rhs.sum, rhs.Lmax);       ret.Rmax = std::max(Rmax, sum + D[r] + rhs.Rmax);       ret.Mmax = std::max(Mmax, rhs.Mmax);       ret.Mmax = std::max(ret.Mmax, Lmax + D[r] + rhs.Rmax);       ret.sum = sum + D[r] + rhs.sum;       return ret;     }   };   struct SegmentTree {     Unit t[N << 2];     void build(int l, int r, int rt) {       if (l == r) {         t[rt].l = t[rt].r = l;         t[rt].Lmax = t[rt].Rmax = 2 * H[l];         t[rt].sum = 0;         t[rt].Mmax = -1;         return;       }       int mid = l + r >> 1;       build(l, mid, rt << 1);       build(mid + 1, r, rt << 1 | 1);       t[rt] = t[rt << 1] + t[rt << 1 | 1];     }     Unit query(int L, int R, int l, int r, int rt) {       if (L <= l && r <= R) {         return t[rt];       }       int mid = l + r >> 1;       if (L <= mid && mid < R)         return query(L, R, l, mid, rt << 1) +                query(L, R, mid + 1, r, rt << 1 | 1);       if (L <= mid) return query(L, R, l, mid, rt << 1);       return query(L, R, mid + 1, r, rt << 1 | 1);     }   } sgt;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) {       scanf( %I64d , D + i);     }     for (int i = 1; i <= n; ++i) {       scanf( %I64d , H + i);     }     sgt.build(1, n, 1);     while (m--) {       int a, b;       scanf( %d%d , &a, &b);       if (a > b) {         printf( %I64d n , sgt.query(b + 1, a - 1, 1, n, 1).Mmax);       } else {         if (a == 1) {           printf( %I64d n , sgt.query(b + 1, n, 1, n, 1).Mmax);         } else if (b == n) {           printf( %I64d n , sgt.query(1, a - 1, 1, n, 1).Mmax);         } else {           printf(                %I64d n ,               (sgt.query(b + 1, n, 1, n, 1) + sgt.query(1, a - 1, 1, n, 1)).Mmax);         }       }     }     return 0;   }   