malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     string c =   ;     string t =   ;     cin >> t >> c;     char lt = t[0];     int nt = int(t[1]) - 48;     char lc = c[0];     int nc = int(c[1]) - 48;     int cnt = 16;     vector<pair<char, int> > torre;     vector<pair<char, int> > caballo;     for (int i = -2; i <= 2; i += 4) {       for (int j = -1; j <= 1; j += 2) {         char x = lt + i;         int y = nt + j;         char xx = lt + j;         int yy = nt + i;         if (int(x) < 105 && int(x) > 96 && y < 9 && y > 0) {           cnt++;           torre.push_back(make_pair(x, y));         }         if (int(xx) < 105 && int(xx) > 96 && yy < 9 && yy > 0) {           cnt++;           torre.push_back(make_pair(xx, yy));         }       }     }     for (int i = -2; i <= 2; i += 4) {       for (int j = -1; j <= 1; j += 2) {         char x = lc + i;         int y = nc + j;         char xx = lc + j;         int yy = nc + i;         if (int(x) < 105 && int(x) > 96 && y < 9 && y > 0 && x != lt && y != nt) {           cnt++;           caballo.push_back(make_pair(x, y));         }         if (int(xx) < 105 && int(xx) > 96 && yy < 9 && yy > 0 && xx != lt &&             yy != nt) {           cnt++;           caballo.push_back(make_pair(xx, yy));         }       }     }     for (int i = 0; i < torre.size(); i++) {       for (int j = 0; j < caballo.size(); j++) {         if (torre[i].first == caballo[j].first &&             torre[i].second == caballo[j].second)           cnt--;       }     }     cout << 64 - cnt <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read(int f = 1, int x = 0, char ch =    ) {     while (!isdigit(ch = getchar()))       if (ch ==  - ) f = -1;     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f * x;   }   const int N = 1e5 + 5, oo = 1e9 + 7;   int n, m, a[N], ans[N], b[N], f[N], g[N], l[N], p[N], vis[N];   int get(int i, int x) {     int j = lower_bound(b + 1, b + 1 + m, x) - b - 1;     return vis[j] = 1, ans[i] = b[j];   }   int main() {     n = read();     for (int i = 1; i <= n; ++i) a[i] = read(), f[i] = oo;     ++n, a[n] = f[n] = oo;     m = read();     for (int i = 1; i <= m; ++i) b[i] = read();     sort(b + 1, b + 1 + m);     for (int i = 1; i <= n; ++i)       if (~a[i]) {         int j = lower_bound(f + 1, f + 1 + n, a[i]) - f - 1;         l[i] = j + 1, f[j + 1] = a[i], p[i] = g[j], g[j + 1] = i;       } else         for (int j = n, k = m; k; f[j + 1] = b[k], g[j + 1] = i, --k)           for (; f[j] >= b[k]; --j)             ;     for (int i = l[n], j = n, x = a[n]; i; --i)       if (~a[j])         ~a[p[j]] ? x = a[p[j]] : x = get(p[j], x), j = p[j];       else {         bool flg = false;         for (int k = j - 1; k && !flg; --k)           if (~a[k] && l[k] == i - 1 && a[k] < x) x = a[j = k], flg = true;         for (int k = j - 1; k && !flg; --k)           if (!~a[k]) x = get(j = k, x), flg = true;       }     for (int i = 1; i < n; ++i)       if (ans[i]) a[i] = ans[i];     for (int i = 1, j = 1; i < n; ++i)       if (!~a[i]) {         for (; vis[j]; ++j)           ;         vis[j] = 1, a[i] = b[j];       }     for (int i = 1; i < n; ++i) printf( %d  , a[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n, k;     cin >> n >> k;     string second;     cin >> second;     if (k > 2) {       int c = 0;       for (int i = 1; i < n; i++) {         if (second[i] == second[i - 1]) {           if (i + 1 < n) {             int j = 0;             while (j < k &&                    ((j +  A ) == second[i - 1] || (j +  A ) == second[i + 1]))               j++;             second[i] = j +  A ;           } else {             second[i] = ((second[i - 1] -  A  + 1) % k) +  A ;           }           c++;         }       }       cout << c <<   n ;       cout << second <<   n ;       return;     }     string t =  A , h =  B ;     for (int i = 1; i < n; i++) {       if (t[i - 1] ==  A )         t +=  B ;       else         t +=  A ;       if (h[i - 1] ==  A )         h +=  B ;       else         h +=  A ;     }     int c1 = 0, c2 = 0;     for (int i = 0; i < n; i++) {       if (second[i] != t[i]) c1++;       if (h[i] != second[i]) c2++;     }     cout << min(c1, c2) <<   n ;     if (c1 <= c2)       cout << t <<   n ;     else       cout << h <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Event {     int type;     int p;     int x;   };   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     vector<int> v(n);     for (auto& el : v) {       cin >> el;     }     int q;     cin >> q;     vector<Event> evs(q);     for (auto& ev : evs) {       cin >> ev.type;       if (ev.type == 2) {         cin >> ev.x;       } else {         cin >> ev.p >> ev.x;         ev.p--;       }     }     int mx = 0;     vector<bool> has_ans(n, false);     for (int i = q - 1; i >= 0; i--) {       if (evs[i].type == 1) {         if (!has_ans[evs[i].p]) {           v[evs[i].p] = max(mx, evs[i].x);           has_ans[evs[i].p] = true;         }       } else {         mx = max(evs[i].x, mx);       }     }     for (int i = 0; i < n; i++) {       if (!has_ans[i]) {         v[i] = max(v[i], mx);       }     }     for (auto& el : v) {       cout << el <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     vector<int> one;     vector<int> two;     cin >> n;     for (int i = 0; i < n; i++) {       int t, w;       cin >> t >> w;       if (t == 1)         one.push_back(w);       else         two.push_back(w);     }     sort(one.begin(), one.end());     sort(two.begin(), two.end());     vector<int> pref_one = {0};     vector<int> pref_two = {0};     for (int i = 1; i <= one.size(); i++) {       int val = one[i - 1] + pref_one[i - 1];       pref_one.push_back(val);     }     for (int i = 1; i <= two.size(); i++) {       int val = two[i - 1] + pref_two[i - 1];       pref_two.push_back(val);     }     int res = 1000000;     for (int i = 0; i <= one.size(); i++) {       for (int j = 0; j <= two.size(); j++) {         bool possible = false;         int ans = i + 2 * j;         int w_one = pref_one[one.size() - i];         int w_two = pref_two[two.size() - j];         if (ans >= (w_one + w_two)) possible = true;         if (possible) res = min(res, ans);       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long Mypow(long long X, long long Y) {     if (Y < 0) return 0;     if (Y == 0) return 1;     if (Y == 1) {       return X;     } else {       long long x = Mypow(X, Y / 2);       x *= x;       if (Y % 2)         return (x * X);       else         return x;     }   }   long long n, m, l, r, x;   long long p[100100];   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> p[i];     }     while (m--) {       scanf( %I64d %I64d %I64d , &l, &r, &x);       if (x < l || x > r) {         printf( Yes n );         continue;       }       int sum = 0;       for (int i = l; i <= r; i++) {         if (p[i] < p[x]) {           sum++;         }       }       if (x == l + sum) {         printf( Yes n );       } else {         printf( No n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007, dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};   const double eps = 1e-8;   void read(int &k) {     k = 0;     char x = getchar();     while (x <  0  || x >  9 ) x = getchar();     while (x >=  0  && x <=  9 ) {       k = k * 10 - 48 + x;       x = getchar();     }   }   int n, tra[128], lx, ly, Lx[10010], Ly[10010], a[2100][2100], ll, rr, tx, ty,       nx, ny, k;   pair<pair<int, int>, pair<int, int> > ope[1010];   pair<int, int> dd[5000000];   char s[10];   void update(int type, int &x) {     if (!type)       x = lower_bound(Lx + 1, Lx + lx + 1, x) - Lx;     else       x = lower_bound(Ly + 1, Ly + ly + 1, x) - Ly;   }   int main() {     tra[ R ] = 0;     tra[ D ] = 1;     tra[ L ] = 2;     tra[ U ] = 3;     scanf( %d , &n);     nx = 0;     ny = 0;     Lx[++lx] = 0;     Ly[++ly] = 0;     Ly[++ly] = Lx[++lx] = 1000000003;     Ly[++ly] = Lx[++lx] = -1000000003;     Lx[++lx] = 1;     Ly[++ly] = 1;     for (int i = 1; i <= n; i++) {       scanf( %s%d , s, &k);       ope[i].first = make_pair(nx, ny);       nx += dx[tra[s[0]]] * k;       ny += dy[tra[s[0]]] * k;       ope[i].second = make_pair(nx, ny);       Lx[++lx] = nx;       Ly[++ly] = ny;       Lx[++lx] = nx + 1;       Ly[++ly] = ny + 1;     }     sort(Lx + 1, Lx + lx + 1);     lx = unique(Lx + 1, Lx + lx + 1) - Lx - 1;     sort(Ly + 1, Ly + ly + 1);     ly = unique(Ly + 1, Ly + ly + 1) - Ly - 1;     for (int i = 1; i <= n; i++) {       update(0, ope[i].first.first);       update(1, ope[i].first.second);       update(0, ope[i].second.first);       update(1, ope[i].second.second);       if (ope[i].first.first == ope[i].second.first) {         if (ope[i].first.second > ope[i].second.second)           swap(ope[i].first.second, ope[i].second.second);         for (int j = ope[i].first.second; j <= ope[i].second.second; j++)           a[ope[i].first.first][j] = 1;       } else {         if (ope[i].first.first > ope[i].second.first)           swap(ope[i].first.first, ope[i].second.first);         for (int j = ope[i].first.first; j <= ope[i].second.first; j++)           a[j][ope[i].first.second] = 1;       }     }     a[1][1] = 2;     for (dd[ll = rr = 0] = make_pair(1, 1); ll <= rr; ll++) {       for (int dir = 0; dir < 4; dir++) {         tx = dd[ll].first + dx[dir];         ty = dd[ll].second + dy[dir];         if (tx > 0 && tx <= lx && ty > 0 && ty <= ly && !a[tx][ty])           a[tx][ty] = 2, dd[++rr] = make_pair(tx, ty);       }     }     long long ans = 0;     for (int i = 1; i <= lx; i++)       for (int j = 1; j <= ly; j++)         if (a[i][j] <= 1) ans += 1ll * (Lx[i + 1] - Lx[i]) * (Ly[j + 1] - Ly[j]);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, dist1, dist2, i, blank;     string s, t;     for (i = 0; i < 300; i++) cout <<  a ;     cout << endl;     cin >> dist1;     if (dist1 == 0) return 0;     for (i = 0; i < 300; i++) cout <<  b ;     cout << endl;     cin >> dist2;     if (dist2 == 0) return 0;     blank = dist1 + dist2 - 300;     dist1 -= blank;     dist2 -= blank;     n = dist1 + dist2;     s =   ;     for (i = 0; i < n; i++) s +=  a ;     if (dist2 == n) {       cout << s << endl;       cin >> dist2;       return 0;     }     for (i = 0; i < n - 1; i++) {       t = s;       t[i] =  b ;       cout << t << endl;       cin >> dist2;       if (dist2 == 0) return 0;       if (dist2 < dist1) s[i] =  b ;       dist1 = min(dist2, dist1);     }     s[n - 1] =  b ;     cout << s << endl;     cin >> dist2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct tp {     int l, r;   };   int n;   vector<tp> t;   bool comp(tp a, tp b) { return a.l < b.l or a.l == b.l and a.r < b.r; }   int main() {     cout.sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       int l, r;       cin >> l >> r;       t.push_back({l, r});     }     sort(t.begin(), t.end(), comp);     int cl = -1;     int cr = -1;     int ans = 0;     for (int i = 0; i < t.size(); i++) {       if (t[i].l > cr) {         ans += 1;         cl = t[i].l;         cr = t[i].r;       } else if (t[i].l <= cr and t[i].r > cr) {         continue;       } else if (t[i].l <= cr and t[i].r <= cr) {         cl = t[i].l;         cr = t[i].r;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 140000;   int sx[MAX + 10], ex[MAX], sy[MAX + 10], ey[MAX];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++)       scanf( %d %d %d %d , &sx[i], &sy[i], &ex[i], &ey[i]);     vector<pair<int, int> > px, py;     for (int i = 0; i < n; i++) {       px.push_back(make_pair(sx[i], -i - 1));       px.push_back(make_pair(ex[i], i + 1));     }     sort(px.begin(), px.end());     set<int> rec;     int rx = -1, ry = -1;     for (int i = 0; i < (int)px.size(); i++) {       if (px[i].second < 0) {         rec.insert(-1 * px[i].second);       } else {         rec.erase(px[i].second);       }       if ((int)rec.size() >= n - 1) {         py.clear();         for (set<int>::iterator it = rec.begin(); it != rec.end(); it++) {           py.push_back(make_pair(sy[*it - 1], -1 * (*it)));           py.push_back(make_pair(ey[*it - 1], *it));         }         sort(py.begin(), py.end());         int inter = 0;         for (int j = 0; j < (int)py.size(); j++) {           if (py[j].second < 0)             inter++;           else             inter--;           if (inter >= n - 1) rx = px[i].first, ry = py[j].first;         }       }     }     printf( %d %d n , rx, ry);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 13 * 16, M = 1e9 + 7;   int n, m, k;   struct zz {     int a[N][N];   } A;   inline zz cf(zz x, zz y) {     zz z;     memset(z.a, 0, sizeof z.a);     for (int i = 0; i < (1 << m) * (k + 1); i++)       for (int j = 0; j < (1 << m) * (k + 1); j++)         for (int l = 0; l < (1 << m) * (k + 1); l++)           z.a[i][j] = (z.a[i][j] + (long long)x.a[i][l] * y.a[l][j]) % M;     return z;   }   inline zz ksm(zz x, int y) {     zz ans;     memset(ans.a, 0, sizeof ans.a);     for (int i = 0; i < (1 << m) * (k + 1); i++) ans.a[i][i] = 1;     for (; y; y >>= 1, x = cf(x, x))       if (y & 1) ans = cf(ans, x);     return ans;   }   int main() {     scanf( %d%d%d , &n, &k, &m);     for (int i = 0; i < 1 << m; i++)       for (int j = 0; j <= k; j++) {         int num = 1;         for (int l = 0; l < m; l++)           if ((1 << l) & i) num++;         A.a[(i >> 1) * (k + 1) + j][i * (k + 1) + j] = 1;         if (j < k)           A.a[(i >> 1 | (1 << (m - 1))) * (k + 1) + j + 1][i * (k + 1) + j] = num;       }     A = ksm(A, n);     int ans = 0;     for (int i = 0; i < 1 << m; i++) (ans += A.a[i * (k + 1) + k][0]) %= M;     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   set<int> b[127];   set<int>::iterator it, itt;   int n, m, l, r, c[200005];   char s, ch[2], a[200005];   void upd(int v, int d) {     while (v <= n) {       c[v] += d;       v += v & -v;     }   }   int find(int x) {     int cur = 0, ans = 0;     for (int i = 20; i >= 0; i--) {       ans += (1 << i);       if (ans >= n || cur + c[ans] >= x)         ans -= (1 << i);       else         cur += c[ans];     }     return ans + 1;   }   int gsum(int v) {     int sum = 0;     while (v > 0) {       sum += c[v];       v -= v & -v;     }     return sum;   }   int main() {     scanf( %d%d , &n, &m);     scanf( %s , a + 1);     for (int i = 1; i <= n; i++) b[a[i]].insert(i);     for (int i = 1; i <= n; i++) upd(i, 1);     for (int i = 0; i < m; i++) {       scanf( %d%d%s , &l, &r, ch);       s = ch[0];       l = find(l);       r = find(r);       it = b[s].lower_bound(l);       while (it != b[s].end() && *it <= r)         upd(*it, -1), a[*it] =  # , itt = it, it++, b[s].erase(itt);     }     for (int i = 1; i <= n; i++)       if (gsum(i) - gsum(i - 1) == 1) printf( %c , a[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1 << 17;   const int INF = 7 << 28;   struct T {     int maxa, minr;     T() : maxa(0), minr(INF) {}     T(int a, int b) : maxa(a), minr(b) {}     T operator+(T t) const { return T(max(maxa, t.maxa), min(minr, t.minr)); }   };   T a[MAXN * 2];   int del[MAXN * 2];   int l[MAXN], r[MAXN], t[MAXN];   void setDel(int i, int d) {     del[i] += d;     a[i].minr -= d;   }   void push(int i) {     setDel(i * 2, del[i]);     setDel(i * 2 + 1, del[i]);     del[i] = 0;   }   void com(int i) {     push(i);     a[i] = a[i * 2] + a[i * 2 + 1];   }   void clear(int i) {     int j;     for (j = 0; (1 << j) < MAXN; j++)       ;     for (; j; j--) push(i >> j);   }   T get(int i) {     clear(i);     T ret = T();     while (i) {       if (~i & 1) ret = a[i + 1] + ret;       i >>= 1;     }     return ret;   }   void modify(int i, T t) {     i += MAXN;     clear(i);     a[i] = t;     del[i] = 0;     i >>= 1;     while (i) {       com(i);       i >>= 1;     }   }   void init() { fill(a, a + MAXN * 2, T()); }   void put(int t) { printf( %d  , t); }   int main() {     int n;     int i, j, k;     int ans = 0;     init();     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d%d%d , &l[i], &r[i], &t[i]);       r[i]++;     }     for (i = 1; i <= n; i++) {       if (max(ans, l[i]) + t[i] <= r[i]) {         put(0);         modify(i, T(t[i], max(ans, l[i]) - l[i]));         ans = max(ans, l[i]) + t[i];       } else {         int ra, rr;         j = 1;         ra = 0;         rr = INF;         while (j < MAXN) {           push(j);           j = j * 2 + 1;           if (max(a[j].maxa, ra) < min(rr, a[j].minr)) {             ra = max(a[j].maxa, ra);             rr = min(a[j].minr, rr);             j--;           }         }         T temp = get(j);         int move = max(temp.maxa, min(temp.minr, a[j].maxa));         if (max(ans - move, l[i]) + t[i] > r[i] ||             max(ans - move, l[i]) + t[i] >= ans) {           put(-1);           continue;         }         move = min(move, ans - l[i]);         j = 1;         while (j < MAXN) {           j = j * 2 + 1;           if (a[j].maxa < move) j--;         }         put(j - MAXN);         temp = get(j);         move = min(temp.minr, a[j].maxa);         ans -= move;         modify(j - MAXN, T(0, INF));         while (j != 1) {           if (~j & 1) setDel(j + 1, move);           j >>= 1;           com(j);         }         modify(i, T(t[i], max(ans, l[i]) - l[i]));         ans = max(ans, l[i]) + t[i];       }     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     cin >> q;     for (int i = 0; i < q; ++i) {       long long n;       cin >> n;       int a = 0;       int b = 0;       int c = 0;       while (n % 2 == 0) {         n /= 2;         ++a;       }       while (n % 3 == 0) {         n /= 3;         ++b;       }       while (n % 5 == 0) {         n /= 5;         ++c;       }       if (n != 1) {         cout <<   -1   << endl;       } else {         cout << a + b * 2 + c * 3 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, cnt, Max, head[N];   struct Edge {     int to, nxt, val;   } e[N << 1];   int read() {     int x = 0, flg = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) flg = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     return x * flg;   }   void add(int x, int y, int w) {     e[++cnt].to = y;     e[cnt].val = w;     e[cnt].nxt = head[x];     head[x] = cnt;   }   void dfs(int x, int fa, int dis) {     Max = max(Max, dis);     for (int i = head[x]; i; i = e[i].nxt) {       int u = e[i].to;       if (u == fa) continue;       dfs(u, x, dis + e[i].val);     }   }   int main() {     n = read();     int x, y, w;     long long sum = 0;     for (int i = 2; i <= n; ++i) {       x = read(), y = read(), w = read();       add(x, y, w);       add(y, x, w);       sum += 2 * w;     }     dfs(1, 0, 0);     printf( %lld n , sum - Max);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     std::cin >> n;     std::vector<int> v(101);     for (int i = 0; i < n; ++i) {       int temp;       std::cin >> temp;       v[temp]++;     }     int mex_A = -1;     int mex_B = -1;     bool flag1 = 1;     for (int i = 0; i < n; ++i) {       if (v[i] > 1 && flag1) {         mex_A = mex_B = i;       } else if (v[i] >= 1) {         mex_A = i;         flag1 = 0;       } else if (v[i] == 0) {         break;       }     }     std::cout << ++mex_A + ++mex_B <<   n ;   }   int main() {     int x;     cin >> x;     while (x--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct compare {     bool operator()(const pair<int, int>& a, const pair<int, int>& b) {       return true;     }   };   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     int t;     cin >> t;     while (t--) {       int n, x, y;       cin >> n >> x >> y;       vector<int> ans;       for (int i = 1; i <= 50; i++) {         ans.clear();         if ((x - y) % i != 0) continue;         for (int j = x; j <= y; j += i) ans.push_back(j);         if (ans.back() != y || ans.size() > n) continue;         int j = x - i;         while (ans.size() < n && j >= 1) {           ans.push_back(j);           j -= i;         }         j = y + i;         while (ans.size() < n) {           ans.push_back(j);           j += i;         }         break;       }       for (auto ai : ans) cout << ai <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   const int p = 257;   const long long mods = 1610612741;   const int maxn = 200010;   long long hash1[maxn][2];   int cntzero[maxn];   char s[maxn];   int N;   long long pp[maxn];   void gethash(char s[]) {     hash1[0][0] = 0;     hash1[0][1] = 0;     for (int i = 1; i <= N; i++) {       cntzero[i] = cntzero[i - 1];       if (s[i] ==  0 ) {         cntzero[i]++;         hash1[i][0] = (hash1[i - 1][0] * p + (i & 1) + 1) % mods;         hash1[i][1] = (hash1[i - 1][1] * p + ((i + 1) & 1) + 1) % mods;       } else {         hash1[i][0] = hash1[i - 1][0];         hash1[i][1] = hash1[i - 1][1];       }     }     return;   }   void init() {     pp[0] = 1;     for (int i = 1; i <= N; i++) {       pp[i] = (pp[i - 1] * p) % mods;     }   }   long long getsubhash(int L, int R) {     return (hash1[R][L & 1] -             (hash1[L - 1][L & 1] * pp[cntzero[R] - cntzero[L - 1]]) % mods +             mods) %            mods;   }   int main() {     scanf( %d , &N);     scanf( %s , s + 1);     init();     gethash(s);     int q;     scanf( %d , &q);     while (q--) {       int l1, l2, lens;       scanf( %d%d%d , &l1, &l2, &lens);       if (getsubhash(l1, l1 + lens - 1) == getsubhash(l2, l2 + lens - 1))         printf( Yes n );       else         printf( No n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void boost() {     ios_base::sync_with_stdio();     cin.tie(0);     cout.tie(0);   }   const long long maxn = 1e5 + 123;   const long long inf = 1e9 + 123;   const long long mod = 1e9 + 7;   const double infm = 1e-9;   const double pi = acos(-1);   map<char, int> m;   int main() {     boost();     int n;     cin >> n;     string s;     cin >> s;     int ans = 0;     for (int i = 1; i < s.size(); i++) {       if (s[i] == s[i - 1]) {         m[s[i - 1]]++;         m[s[i + 1]]++;         if (m[ B ] == 0) {           s[i] =  B ;         } else if (m[ G ] == 0) {           s[i] =  G ;         } else if (m[ R ] == 0) {           s[i] =  R ;         }         m[s[i - 1]]--;         m[s[i + 1]]--;         ans++;       }     }     cout << ans <<   n  << s;     return 0;   }