func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   long long c;   int last, l, r;   int q[200010];   long long a[400010], ans[200010];   int main() {     scanf( %d%lld , &n, &c);     for (int i = 1; i < 2 * n; i++) scanf( %lld , &a[i]), a[i] += a[i - 1];     for (int i = 1; i <= n; i++) {       while (last < i && a[2 * i - 1] - a[2 * last] >= c) last++;       while (l <= r && a[2 * i - 1] - a[2 * q[l]] >= c) l++;       if (last) ans[i] = ans[last - 1] + c;       if (l <= r) ans[i] = max(ans[i], a[2 * i - 1] + ans[q[l]] - a[2 * q[l]]);       while (l <= r && ans[i] - a[2 * i] >= ans[q[r]] - a[2 * q[r]]) r--;       q[++r] = i;     }     printf( %lld n , ans[n]);   }   