func_code_string: #include <bits/stdc++.h>   using namespace std;   string s;   const int MAXN = 100005;   int tz[4 * MAXN], tx[4 * MAXN], ty[4 * MAXN];   int cntz(int v, int tl, int tr, int l, int r) {     if (l > r) return 0;     if (tl == l && r == tr) return tz[v];     int tm = (tl + tr) / 2;     return cntz(2 * v, tl, tm, l, min(tm, r)) +            cntz(2 * v + 1, tm + 1, tr, max(tm + 1, l), r);   }   int cnty(int v, int tl, int tr, int l, int r) {     if (l > r) return 0;     if (tl == l && r == tr) return ty[v];     int tm = (tl + tr) / 2;     return cnty(2 * v, tl, tm, l, min(tm, r)) +            cnty(2 * v + 1, tm + 1, tr, max(tm + 1, l), r);   }   int cntx(int v, int tl, int tr, int l, int r) {     if (l > r) return 0;     if (tl == l && r == tr) return tx[v];     int tm = (tl + tr) / 2;     return cntx(2 * v, tl, tm, l, min(tm, r)) +            cntx(2 * v + 1, tm + 1, tr, max(tm + 1, l), r);   }   void buildz(int v, int tl, int tr) {     if (tl == tr)       tz[v] = (s[tl] ==  z );     else {       int tm = (tl + tr) / 2;       buildz(2 * v, tl, tm);       buildz(2 * v + 1, tm + 1, tr);       tz[v] = tz[2 * v] + tz[2 * v + 1];     }   }   void buildy(int v, int tl, int tr) {     if (tl == tr)       ty[v] = (s[tl] ==  y );     else {       int tm = (tl + tr) / 2;       buildy(2 * v, tl, tm);       buildy(2 * v + 1, tm + 1, tr);       ty[v] = ty[2 * v] + ty[2 * v + 1];     }   }   void buildx(int v, int tl, int tr) {     if (tl == tr)       tx[v] = (s[tl] ==  x );     else {       int tm = (tl + tr) / 2;       buildx(2 * v, tl, tm);       buildx(2 * v + 1, tm + 1, tr);       tx[v] = tx[2 * v] + tx[2 * v + 1];     }   }   int main() {     cin >> s;     int n, l = s.length();     buildz(1, 0, l - 1);     buildy(1, 0, l - 1);     buildx(1, 0, l - 1);     cin >> n;     for (int i = 0, a, b; i < n; ++i) {       cin >> a >> b;       int z = cntz(1, 0, l - 1, a - 1, b - 1);       int y = cnty(1, 0, l - 1, a - 1, b - 1);       int x = cntx(1, 0, l - 1, a - 1, b - 1);       int t = min(x, min(y, z));       z -= t;       y -= t;       x -= t;       if (b - a + 1 <= 2 || (z <= 1 && x <= 1 && y <= 1))         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }   