func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 * 2 + 5;   const int maxd = 25;   long long d[maxn], h[maxn], s[maxn], f[maxn], g[maxn];   int f_fst[maxd][maxn], f_snd[maxd][maxn], g_fst[maxd][maxn], g_snd[maxd][maxn];   void GetMax(long long a[], int &r0, int &r1, int x0, int x1, int y0, int y1) {     if (a[x0] > a[y0]) {       r0 = x0;       r1 = x1 != x0 && a[x1] > a[y0] ? x1 : y0;     } else if (a[x0] < a[y0]) {       r0 = y0;       r1 = y1 != y0 && a[y1] > a[x0] ? y1 : x0;     } else {       r0 = x0;       if (x0 == y0)         r1 = a[x1] > a[y1] ? x1 : y1;       else         r1 = y0;     }   }   void BuildRMQ(long long a[maxn], int fst[][maxn], int snd[][maxn], int n) {     for (int k = 0; (1 << k) <= n; k++)       for (int i = 1; i + (1 << k) - 1 <= n; i++)         if (k == 0)           fst[k][i] = snd[k][i] = i;         else {           int j = i + (1 << k - 1);           GetMax(a, fst[k][i], snd[k][i], fst[k - 1][i], snd[k - 1][i],                  fst[k - 1][j], snd[k - 1][j]);         }   }   pair<int, int> QueryRMQ(long long a[maxn], int fst[][maxn], int snd[][maxn],                           int n, int x, int y) {     for (int k = maxd - 1; k >= 0; k--)       if ((y - x + 1) >> k) {         int i = x, j = y - (1 << k) + 1;         pair<int, int> ret;         GetMax(a, ret.first, ret.second, fst[k][i], snd[k][i], fst[k][j],                snd[k][j]);         return ret;       }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %I64d , &d[i]);       s[i + 1] = s[i] + d[i];     }     for (int i = 1; i <= n; i++) {       scanf( %I64d , &h[i]);       h[i + n] = h[i];       s[i + n + 1] = s[i + n] + d[i];     }     for (int i = 1; i <= n * 2; i++) {       f[i] = h[i] * 2LL - s[i];       g[i] = h[i] * 2LL + s[i];     }     BuildRMQ(f, f_fst, f_snd, n * 2);     BuildRMQ(g, g_fst, g_snd, n * 2);     for (int i = 0; i < m; i++) {       int ai, bi;       scanf( %d%d , &ai, &bi);       if (ai <= bi) ai += n;       bi++;       ai--;       pair<int, int> fmax = QueryRMQ(f, f_fst, f_snd, n * 2, bi, ai);       pair<int, int> gmax = QueryRMQ(g, g_fst, g_snd, n * 2, bi, ai);       long long ans;       if (fmax.first != gmax.first)         ans = f[fmax.first] + g[gmax.first];       else         ans = max(f[fmax.first] + g[gmax.second], f[fmax.second] + g[gmax.first]);       printf( %I64d n , ans);     }     return 0;   }   