func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   struct ask {     int l, r, cur;   } tmp;   long long pre[maxn], suf[maxn], s[maxn], d[maxn], h[maxn], ans[maxn];   vector<ask> V, W;   int n, m, a, b;   long long solve(int l, int r, vector<ask> &V) {     if (l == r) return 0;     int mid = (l + r) >> 1;     long long best;     vector<ask> Vl, Vr, Vt;     pre[mid] = 0;     for (int i = (mid + 1); i <= int(r); i++)       pre[i] = max(pre[i - 1], s[i] - s[mid] + 2 * h[i]);     suf[mid + 1] = 0;     for (int i = (mid); i >= (l); i--)       suf[i] = max(suf[i + 1], s[mid] - s[i] + 2 * h[i]);     for (auto x : V)       if (x.r <= mid)         Vl.push_back(x);       else if (mid + 1 <= x.l)         Vr.push_back(x);       else if (l != x.l || r != x.r) {         ans[x.cur] = max(ans[x.cur], suf[x.l] + pre[x.r]);         Vl.push_back((ask){x.l, mid, x.cur});         Vr.push_back((ask){mid + 1, x.r, x.cur});       }     best = pre[r] + suf[l];     best = max(best, solve(l, mid, Vl));     best = max(best, solve(mid + 1, r, Vr));     for (auto x : V)       if (l == x.l && r == x.r) ans[x.cur] = max(ans[x.cur], best);     return best;   }   void solve2() {     pre[0] = 0;     for (int i = (1); i <= int(n); i++)       pre[i] = max(pre[i - 1], s[i] - s[1] + 2 * h[i]);     suf[n + 1] = 0;     for (int i = (n); i >= (1); i--)       suf[i] = max(suf[i + 1], s[n + 1] - s[i] + 2 * h[i]);     for (auto x : W) ans[x.cur] = max(ans[x.cur], pre[x.l] + suf[x.r]);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = (1); i <= int(n); i++)       scanf( %I64d , &d[i]), s[i + 1] = s[i] + d[i];     for (int i = (1); i <= int(n); i++) scanf( %I64d , &h[i]);     for (int i = (1); i <= int(m); i++) {       scanf( %d%d , &a, &b);       if (a <= b) {         if (3 <= a) V.push_back((ask){1, a - 1, i});         if (b <= n - 2) V.push_back((ask){b + 1, n, i});         if (2 <= a && b <= n - 1) W.push_back((ask){a - 1, b + 1, i});       } else         V.push_back((ask){b + 1, a - 1, i});     }     solve(1, n, V);     solve2();     for (int i = (1); i <= int(m); i++) printf( %I64d n , ans[i]);     return 0;   }   