func_code_string: #include <bits/stdc++.h>   using namespace std;   long long inf;   const double eps = 1e-8;   const double pi = acos(-1.0);   template <class T>   long long chkmin(T &a, T b) {     return a > b ? a = b, 1 : 0;   }   template <class T>   long long chkmax(T &a, T b) {     return a < b ? a = b, 1 : 0;   }   template <class T>   T sqr(T a) {     return a * a;   }   template <class T>   T mmin(T a, T b) {     return a < b ? a : b;   }   template <class T>   T mmax(T a, T b) {     return a > b ? a : b;   }   template <class T>   T aabs(T a) {     return a < 0 ? -a : a;   }   template <class T>   long long dcmp(T a, T b) {     return a > b;   }   template <long long *a>   long long cmp_a(long long first, long long second) {     return a[first] < a[second];   }   struct __INIT__ {     __INIT__() { memset(&inf, 0x3f, sizeof(inf)); }   } __INIT___;   namespace io {   const long long SIZE = (1 << 21) + 1;   char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,                                          qu[55];   long long f, qr;   inline void flush() {     fwrite(obuf, 1, oS - obuf, stdout);     oS = obuf;   }   inline void putc(char first) {     *oS++ = first;     if (oS == oT) flush();   }   template <typename A>   inline bool read(A &first) {     for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                                 (iS == iT ? EOF : *iS++))                               : *iS++);          c <  0  || c >  9 ;          c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                          (iS == iT ? EOF : *iS++))                        : *iS++))       if (c ==  - )         f = -1;       else if (c == EOF)         return 0;     for (first = 0; c <=  9  && c >=  0 ;          c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                          (iS == iT ? EOF : *iS++))                        : *iS++))       first = first * 10 + (c & 15);     first *= f;     return 1;   }   inline bool read(char &first) {     while ((first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                                  (iS == iT ? EOF : *iS++))                               : *iS++)) ==     ||            first ==   n  || first ==   r )       ;     return first != EOF;   }   inline bool read(char *first) {     while ((*first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                                   (iS == iT ? EOF : *iS++))                                : *iS++)) ==   n  ||            *first ==     || *first ==   r )       ;     if (*first == EOF) return 0;     while (!(*first ==   n  || *first ==     || *first ==   r ))       *(++first) = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                                 (iS == iT ? EOF : *iS++))                              : *iS++);     *first = 0;     return 1;   }   template <typename A, typename... B>   inline bool read(A &first, B &...second) {     return read(first) && read(second...);   }   template <typename A>   inline bool write(A first) {     if (!first) putc( 0 );     if (first < 0) putc( - ), first = -first;     while (first) qu[++qr] = first % 10 +  0 , first /= 10;     while (qr) putc(qu[qr--]);     return 0;   }   inline bool write(char first) {     putc(first);     return 0;   }   inline bool write(const char *first) {     while (*first) {       putc(*first);       ++first;     }     return 0;   }   inline bool write(char *first) {     while (*first) {       putc(*first);       ++first;     }     return 0;   }   template <typename A, typename... B>   inline bool write(A first, B... second) {     return write(first) || write(second...);   }   struct Flusher_ {     ~Flusher_() { flush(); }   } io_flusher_;   }  // namespace io   using io ::putc;   using io ::read;   using io ::write;   long long a[100005], b[100005], f[100005], g[100005];   long long s[100005], t;   long long n, k;   struct smt {     long long amn, bmn, atg;     long long ls, rs;     smt *l, *r;     smt(long long la, long long ra) {       amn = inf;       bmn = -inf;       atg = 0;       ls = la;       rs = ra;       if (ls == rs) {         l = r = 0;       } else {         long long mid = (ls + rs) >> 1;         l = new smt(ls, mid);         r = new smt(mid + 1, rs);       }     }     void setg(long long first) {       if (ls == rs) {         amn = bmn = g[first];         return;       }       if (first <= l->rs)         l->setg(first);       else         r->setg(first);       amn = mmin(l->amn, r->amn);       bmn = mmin(l->bmn, r->bmn);     }     void push_down() {       l->atg += atg;       l->amn += atg;       r->atg += atg;       r->amn += atg;       atg = 0;     }     void add(long long la, long long ra, long long w) {       if (la <= ls && rs <= ra) {         atg += w;         amn += w;         return;       }       push_down();       if (la <= l->rs) l->add(la, ra, w);       if (ra >= r->ls) r->add(la, ra, w);       amn = mmin(l->amn, r->amn);     }     long long query(long long first, long long rm) {       if (ls > rm) return 0;       if (bmn - k > first) return 0;       if (ls == rs) return ls;       push_down();       if (mmin(first, l->amn) >= r->bmn - k) {         long long ans = r->query(mmin(first, l->amn), rm);         if (ans) return ans;       }       return l->query(first, rm);     }   };   smt *rt;   signed main() {     read(n, k);     rt = new smt(1, n);     for (long long i = 1; i < n; ++i) read(b[i]);     for (long long i = 1; i <= n; ++i) read(a[i]);     for (long long i = 1; i <= n; ++i) {       f[i] = f[i - 1] + a[i - 1] - b[i - 1];     }     for (long long i = 1; i <= n; ++i) {       g[i] = g[i - 1] + b[i - 1] - a[i];     }     long long ans = 0;     for (long long i = n; i; --i) {       rt->setg(i);       while (t && f[s[t]] >= f[i]) {         if (t > 1) {           rt->add(s[t - 1] - 1, n, f[s[t]] - f[s[t - 1]]);         }         --t;       }       s[++t] = i;       if (t > 1) assert(f[s[t]] >= f[s[t - 1]]);       if (t > 1) {         rt->add(s[t - 1] - 1, n, f[s[t - 1]] - f[s[t]]);       }       s[0] = n + 1;       long long l = 1, r = t, mid;       while (l <= r) {         mid = (l + r) >> 1;         if (f[i] - f[s[mid]] <= k)           r = mid - 1;         else           l = mid + 1;       }       chkmax(ans, rt->query(inf, s[r] - 1) - i + 1);     }     write(ans,   n );     return 0;   }   