func_code_string: #include <bits/stdc++.h>   using namespace std;   int read() {     char c = getchar();     int t = 0, f = 1;     while (c >  9  || c <  0 ) f = (c ==  - ) ? -1 : 1, c = getchar();     while (c >=  0  && c <=  9 ) t = t * 10 + c -  0 , c = getchar();     return t * f;   }   struct node {     int L, R, po, id;     bool operator<(const node &b) const {       if (po == b.po) return R < b.R;       return po < b.po;     }   } p[200005];   int n, Q, K, sq, a[200005], op[200005], id[200005], uid[200005], did[200005],       cnt[200005];   long long sum[200005], st[200005], ans[200005], now;   int main() {     n = read(), K = read(), sq = sqrt(n);     for (int i = 1; i <= n; i++) op[i] = (read() == 1) ? 1 : -1;     for (int i = 1; i <= n; i++)       a[i] = read(), st[i] = sum[i] = sum[i - 1] + a[i] * op[i];     st[n + 1] = 0, sort(st + 1, st + n + 2);     int tp = unique(st + 1, st + n + 2) - st - 1;     for (int i = 0; i <= n; i++) {       id[i] = lower_bound(st + 1, st + tp + 1, sum[i]) - st;       int up = lower_bound(st + 1, st + tp + 1, sum[i] + K) - st;       if (st[up] == sum[i] + K) uid[i] = up;       int down = lower_bound(st + 1, st + tp + 1, sum[i] - K) - st;       if (st[down] == sum[i] - K) did[i] = down;     }     Q = read();     for (int i = 1, x, y, z; i <= Q; i++)       x = read() - 1, y = read(), z = x / sq, p[i] = (node){x, y, z, i};     sort(p + 1, p + Q + 1);     for (int i = p[1].L; i <= p[1].R; i++) now += cnt[did[i]], cnt[id[i]]++;     ans[p[1].id] = now;     for (int i = 2; i <= n; i++) {       int L = p[i - 1].L, R = p[i - 1].R;       while (R < p[i].R) R++, now += cnt[did[R]], cnt[id[R]]++;       while (R > p[i].R) cnt[id[R]]--, now -= cnt[did[R]], R--;       while (L > p[i].L) L--, now += cnt[uid[L]], cnt[id[L]]++;       while (L < p[i].L) cnt[id[L]]--, now -= cnt[uid[L]], L++;       ans[p[i].id] = now;     }     for (int i = 1; i <= Q; i++) printf( %lld n , ans[i]);   }   