malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int n, k, a, b, c, d;   std::vector<int> first_path;   std::vector<int> second_path;   bool first_reversed = false;   bool second_reversed = false;   bool failed = false;   void read() {     scanf( %d %d n%d %d %d %d , &n, &k, &a, &b, &c, &d);     --a;     --b;     --c;     --d;     first_path.resize(n);     second_path.resize(n);   }   void fill_with_everything_except(std::vector<int>::iterator begin,                                    std::vector<int>::iterator end,                                    const std::vector<int> &except) {     for (int i = 0; begin != end; ++begin, ++i) {       while (find(except.begin(), except.end(), i) != except.end()) {         ++i;       }       *begin = i;     }   }   void solve() {     if (a > b) {       std::swap(a, b);       first_reversed = true;     }     if (c > d) {       std::swap(c, d);       second_reversed = true;     }     first_path[0] = a;     first_path[n - 1] = b;     if (a == c && b == d) {       fill_with_everything_except(next(begin(first_path)), prev(end(first_path)),                                   std::vector<int>{a, b});       copy(begin(first_path), end(first_path), begin(second_path));     } else {       if (k < n) {         failed = true;         return;       }       if (a == c) {         fill_with_everything_except(next(begin(first_path)),                                     prev(prev(end(first_path))),                                     std::vector<int>{a, b, d});         first_path[n - 2] = d;         copy(begin(first_path), end(first_path), begin(second_path));         std::swap(second_path[n - 1], second_path[n - 2]);       } else if (b == d) {         fill_with_everything_except(next(next(begin(first_path))),                                     prev(end(first_path)),                                     std::vector<int>{a, b, c});         first_path[1] = c;         copy(begin(first_path), end(first_path), begin(second_path));         std::swap(second_path[0], second_path[1]);       } else {         if (k < n + 1 || n == 4) {           failed = true;           return;         }         fill_with_everything_except(next(next(begin(first_path))),                                     prev(prev(end(first_path))),                                     std::vector<int>{a, b, c, d});         first_path[1] = c;         first_path[n - 2] = d;         copy(begin(first_path), end(first_path), begin(second_path));         std::swap(second_path[0], second_path[1]);         std::swap(second_path[n - 1], second_path[n - 2]);       }     }     if (first_reversed) {       reverse(begin(first_path), end(first_path));     }     if (second_reversed) {       reverse(begin(second_path), end(second_path));     }   }   void print() {     if (failed) {       printf( -1 n );     } else {       for (int i = 0; i < n; ++i) {         printf( %d  , first_path[i] + 1);       }       printf(  n );       for (int i = 0; i < n; ++i) {         printf( %d  , second_path[i] + 1);       }     }   }   int main() {     read();     solve();     print();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool chmax(T& a, const T& b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool chmin(T& a, const T& b) {     if (b < a) {       a = b;       return 1;     }     return 0;   }   long long int gcd(long long int a, long long int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long int ceil(long long int a, long long int b) { return (a + b - 1) / b; }   long long int digit(long long int a) { return (long long int)log10(a); }   const long long int MOD = 1e9 + 7, INF = 1e18;   long long int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1},                 dy[8] = {0, 1, 0, -1, -1, -1, 1, 1};   void YN(bool flag) { cout << (flag ?  YES  :  NO ) <<   n ; }   struct point {     long long int r;     long long int x, y;   };   long long int N, K;   int main() {     cin >> N >> K;     vector<long long int> arr(N);     for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {       cin >> arr[i];     }     sort((arr).begin(), (arr).end());     vector<pair<long long int, long long int> > vec;     long long int curr = arr[0], cnt = 1;     for (long long int i = (0), i_end_ = (N - 1); i < i_end_; i++) {       if (arr[i + 1] != curr) {         vec.push_back({curr, cnt});         curr = arr[i + 1];         cnt = 1;       } else {         cnt++;       }     }     vec.push_back({curr, cnt});     N = ((long long int)(vec).size());     vector<long long int> sums_l(N);     vector<long long int> sums_r(N);     vector<long long int> sumn_l(N);     vector<long long int> sumn_r(N);     long long int sum = 0;     for (long long int i = (0), i_end_ = (N - 1); i < i_end_; i++) {       sum += vec[i].second;       sums_l[i + 1] = sums_l[i] + (vec[i + 1].first - vec[i].first) * sum;       sumn_l[i + 1] = sum;     }     sum = 0;     for (long long int i = (0), i_end_ = (N - 1); i < i_end_; i++) {       sum += vec[N - i - 1].second;       sums_r[i + 1] =           sums_r[i] + (vec[N - i - 1].first - vec[N - i - 2].first) * sum;       sumn_r[i + 1] = sum;     }     long long int minv = INF;     for (long long int i = (0), i_end_ = (((long long int)(vec).size()));          i < i_end_; i++) {       long long int rest = K - sums_l[i];       if (rest < 0) continue;       long long int idx =           upper_bound((sums_r).begin(), (sums_r).end(), rest) - sums_r.begin();       idx--;       rest -= sums_r[idx];       long long int score = vec[N - idx - 1].first - vec[i].first;       score -= rest / sumn_r[idx + 1];       chmin(minv, score);     }     for (long long int i = (0), i_end_ = (((long long int)(vec).size()));          i < i_end_; i++) {       long long int rest = K - sums_r[i];       if (rest < 0) continue;       long long int idx =           upper_bound((sums_l).begin(), (sums_l).end(), rest) - sums_l.begin();       idx--;       rest -= sums_l[idx];       long long int score = vec[N - i - 1].first - vec[idx].first;       score -= rest / sumn_l[idx + 1];       chmin(minv, score);     }     cout << max(0ll, minv) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long modpow(long long a, long long b,                    long long mod = (long long)(1e9 + 7)) {     if (!b) return 1;     a %= mod;     return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int mxn = 1e5, mod = 1e9 + 9;   long long ans = 0;   int n;   int x[mxn], y[mxn];   int support[mxn];   bool inqueue[mxn];   map<int, map<int, int> > ds;   priority_queue<int, vector<int>, greater<int> > pq;   priority_queue<int, vector<int>, less<int> > pq2;   int take(int i, int j) {     if (!ds.count(i) || !ds[i].count(j)) return -1;     return ds[i][j];   }   void supportAdjust(int i) {     if (i == -1) return;     support[i] = 0;     for (int d = -1; d <= 1; d++)       if (take(x[i] + d, y[i] - 1) != -1) support[i]++;     if (y[i] == 0) support[i] = 30000;   }   void evaluate(int i) {     if (i == -1) return;     bool b4 = inqueue[i];     inqueue[i] = false;     for (int d = -1; d <= 1; d++)       if (take(x[i] + d, y[i] + 1) != -1)         inqueue[i] |= support[take(x[i] + d, y[i] + 1)] == 1;     inqueue[i] ^= 1;     if (!b4 && inqueue[i]) {       pq.push(i);       pq2.push(i);     }   }   void takeout(int turn) {     int i;     if (turn % 2 == 0) {       while (pq2.size() && !inqueue[pq2.top()]) pq2.pop();       if (!pq2.size()) return;       i = pq2.top();       pq2.pop();     } else {       while (pq.size() && !inqueue[pq.top()]) pq.pop();       if (!pq.size()) return;       i = pq.top();       pq.pop();     }     ans = ((ans * n) % mod + i) % mod;     inqueue[i] = 0;     ds[x[i]].erase(y[i]);     for (int d = -1; d <= 1; d++) supportAdjust(take(x[i] + d, y[i] + 1));     for (int d = -2; d <= 2; d++) evaluate(take(x[i] + d, y[i]));     for (int d = -1; d <= 1; d++) evaluate(take(x[i] + d, y[i] - 1));   }   void solve() {     scanf( %d , &n);     for (int i = 0; i < n; i++) inqueue[i] = 0;     for (int i = 0; i < n; i++) {       scanf( %d , &x[i]);       scanf( %d , &y[i]);       if (!ds.count(x[i])) ds[x[i]] = map<int, int>();       ds[x[i]][y[i]] = i;     }     for (int i = 0; i < n; i++) supportAdjust(i);     for (int i = 0; i < n; i++) evaluate(i);     for (int i = 0; i < n; i++) takeout(i);     cout << ans % mod << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     string number;     cin >> number;     int n = number.length();     int answer;     vector<vector<int> > remainders = {         {}, {1}, {1, 2, 4, 3}, {1, 3, 4, 2}, {1, 4}};     int last_digit = number[n - 1] -  0 ;     if (n == 1) {       answer = (remainders[1][last_digit % 1] + remainders[2][last_digit % 4] +                 remainders[3][last_digit % 4] + remainders[4][last_digit % 2]) %                5;     } else {       int last_two_digits = (number[n - 1] -  0 ) + 10 * (number[n - 2] -  0 );       answer = (remainders[1][last_two_digits % 1] +                 remainders[2][last_two_digits % 4] +                 remainders[3][last_two_digits % 4] +                 remainders[4][last_two_digits % 2]) %                5;     }     cout << answer << endl;   }   int main() {     {       ios::sync_with_stdio(false);       cout << fixed << setprecision(10);     }     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 500005, mod = 1000000007;   long long int a, b, c, d, e, f, g, h[N], arr[N];   string s;   vector<long long int> v;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> a;     long long int ans = 0, tek = 0, cift = 0;     for (long long int i = 1; i <= a; i++) {       cin >> arr[i];       ans += arr[i] / 2;       if (i % 2 == 0)         cift += arr[i] % 2;       else         tek += arr[i] % 2;       if (tek and cift) tek--, cift--, ans++;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 31;   int a[1000010];   long long cnt1[N + 10];   long long cnt2[N + 10];   long long cnt3[N + 10];   long long cnt4[N + 10];   int b[1000010];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = (0); i < (n); ++i) scanf( %d , &a[i]);     int c = 0;     for (int i = (0); i < (n); ++i) {       for (int j = (0); j < (N); ++j)         if ((a[i] >> j) & 1) cnt1[j]++;     }     for (int i = (0); i < (m); ++i) {       scanf( %d , &b[i]);       cnt4[b[i]]++;     }     int res = 0;     int l = 0, r = m;     while (l <= r) {       int mid = (l + r) / 2;       int k = N - 1;       int now = mid;       for (int j = (0); j < (N); ++j) {         cnt3[j] = ((now < cnt4[j]) ? (now) : (cnt4[j]));         now -= cnt3[j];       }       for (int j = (0); j < (N); ++j) cnt2[j] = cnt1[j];       bool f = true;       for (int i = N - 1; i >= 0; --i) {         cnt2[i] += cnt2[i + 1] + cnt2[i + 1];         if (cnt2[i] < cnt3[i]) {           f = false;           break;         } else           cnt2[i] -= cnt3[i];       }       if (f) {         res = mid;         l = mid + 1;       } else         r = mid - 1;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int movei[] = {0, 0, 1, -1, 1, 1, -1, -1};   int movej[] = {1, -1, 0, 0, 1, -1, 1, -1};   const int MXN = 1e5 + 7;   int can(vector<int> &FRQ, int k) {     int mx = 1;     while (true) {       bool makable = true;       int total = 0;       for (int x : FRQ) total += x / mx;       if (total < k) makable = false;       if (!makable) {         mx--;         break;       }       mx++;     }     return k * mx;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       string s;       cin >> s;       vector<int> frq(26, 0);       for (char c : s) frq[c -  a ]++;       int ans = 1;       for (int i = 1; i * i <= k; i++) {         if (k % i == 0) ans = max({ans, can(frq, i), can(frq, k / i)});       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       long long arr[n], arr1[n], arr2[n];       long long F1 = INT_MIN, F2 = INT_MIN;       for (int i = 0; i < n; ++i) {         cin >> arr[i];         F1 = max(F1, arr[i]);       }       for (int i = 0; i < n; ++i) {         arr1[i] = F1 - arr[i];         F2 = max(F2, arr1[i]);       }       for (int i = 0; i < n; ++i) {         arr2[i] = F2 - arr1[i];       }       if ((k - 1) & 1) {         for (int i = 0; i < n; ++i) {           cout << arr2[i] <<    ;         }       } else {         for (int i = 0; i < n; ++i) {           cout << arr1[i] <<    ;         }       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   long long int gcd(long long int a, long long int b) {     return a ? gcd(b % a, a) : b;   }   long long int power(long long int a, long long int b) {     long long int ans = 1;     long long int s = a;     long long int t = b;     while (t) {       if (t % 2 == 1) ans *= s, ans %= 998244353;       s *= s, s %= 998244353;       t /= 2;     }     return ans;   }   long long int inv(long long int k) { return power(k, 998244353 - 2); }   long long int fact[110];   long long int invFact[110];   std::vector<long long int> prime;   int check[110];   std::vector<int> V;   long long int func(long long int k) {     V.clear();     for (int i = 0; i < prime.size(); i++) {       if (k % prime[i] != 0) continue;       int count = 0;       while (k % prime[i] == 0) count++, k /= prime[i];       V.push_back(count);     }     int sum = 0;     for (int i = 0; i < V.size(); i++) sum += V[i];     long long int ans = fact[sum];     for (int i = 0; i < V.size(); i++) ans *= invFact[V[i]], ans %= 998244353;     return ans;   }   std::vector<long long int> P;   int main() {     fact[0] = 1;     for (int i = 1; i <= 100; i++)       fact[i] = fact[i - 1] * i, fact[i] %= 998244353;     for (int i = 0; i <= 100; i++) invFact[i] = inv(fact[i]);     long long int a;     int b;     scanf( %lld%d , &a, &b);     long long int a2 = a;     for (long long int i = 2; i * i <= a; i++) {       if (a2 % i == 0) {         prime.push_back(i);         while (a2 % i == 0) a2 /= i;       }     }     if (a2 > 1) prime.push_back(a2);     for (int i = 1; i <= b; i++) {       long long int c, d;       scanf( %lld%lld , &c, &d);       long long int e = gcd(c, d);       long long int s1 = func(c / e);       long long int s2 = func(d / e);       printf( %lld n , (s1 * s2) % 998244353);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cout << 2000 << endl;     for (int i = 1; i <= 1000; ++i) cout << i <<     << 1 <<     << i <<   2 n ;     for (int i = 1000; i >= 1; --i) cout << i <<     << 1 <<     << i <<   2 n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e3 + 10;   int n, a[N], k, dp[N];   void bsearch() {     long long l = -1, r = 2e9 + 1;     while (l + 1 < r) {       long long mid = (r + l) / 2;       bool check = false;       for (int i = 0; i < n; i++) {         dp[i] = i;         for (int j = 0; j < i; j++) {           if (abs(a[i] - a[j]) > (i - j) * mid) continue;           dp[i] = min(dp[i], dp[j] + i - j - 1);         }         if (dp[i] + n - i - 1 <= k) {           check = true;           break;         }       }       if (check) {         r = mid;       } else {         l = mid;       }     }     cout << r << endl;   }   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     bsearch();   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const double eps = 1e-9;   const int inf = 2000000000;   const long long infLL = 9000000000000000000;   template <typename first, typename second>   ostream &operator<<(ostream &os, const pair<first, second> &p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     os <<  { ;     for (auto it = v.begin(); it != v.end(); ++it) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  } ;   }   template <typename T>   ostream &operator<<(ostream &os, const set<T> &v) {     os <<  [ ;     for (auto it = v.begin(); it != v.end(); ++it) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  ] ;   }   template <typename T>   ostream &operator<<(ostream &os, const multiset<T> &v) {     os <<  [ ;     for (auto it = v.begin(); it != v.end(); ++it) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  ] ;   }   template <typename first, typename second>   ostream &operator<<(ostream &os, const map<first, second> &v) {     os <<  [ ;     for (auto it = v.begin(); it != v.end(); ++it) {       if (it != v.begin()) os <<  ,  ;       os << it->first <<   =   << it->second;     }     return os <<  ] ;   }   void faltu() { cerr <<   n ; }   template <typename T>   void faltu(T a[], int n) {     for (int i = 0; i < n; ++i) cerr << a[i] <<    ;     cerr <<   n ;   }   template <typename T, typename... hello>   void faltu(T arg, const hello &...rest) {     cerr << arg <<    ;     faltu(rest...);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n, cnt1 = 0, cnt2 = 0, x;     cin >> n;     while (n--) {       cin >> x;       if (x == 100) {         cnt1++;       } else {         cnt2++;       }     }     if (cnt1 % 2 == 1) {       cout <<  NO  <<   n ;     } else if (cnt1 == 0 && cnt2 % 2 == 1) {       cout <<  NO  <<   n ;     } else {       cout <<  YES  <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 600005;   int minx[Maxn], tip[Maxn];   int a[Maxn], b[Maxn], c[Maxn];   int n, m, i, h, L, R, t, ans;   void ins(int p, int l, int r, int pos, int data) {     if (l == r) {       minx[p] = data;       return;     }     int mid = (l + r) >> 1;     if (pos <= mid)       ins(p * 2 + 1, l, mid, pos, data);     else       ins(p * 2 + 2, mid + 1, r, pos, data);     minx[p] = min(minx[p * 2 + 1], minx[p * 2 + 2]);   }   void push(int p) {     minx[p * 2 + 1] += tip[p];     tip[p * 2 + 1] += tip[p];     minx[p * 2 + 2] += tip[p];     tip[p * 2 + 2] += tip[p];     tip[p] = 0;   }   void add(int p, int l, int r, int L, int R, int dlt) {     if (L > r || l > R) return;     if (L <= l && R >= r) {       minx[p] += dlt;       tip[p] += dlt;       return;     }     if (tip[p]) push(p);     int mid = (l + r) >> 1;     add(p * 2 + 1, l, mid, L, R, dlt);     add(p * 2 + 2, mid + 1, r, L, R, dlt);     minx[p] = min(minx[p * 2 + 1], minx[p * 2 + 2]);   }   int main() {     scanf( %d%d%d , &n, &m, &h);     for (i = 1; i <= m; i++) scanf( %d , &b[i]);     sort(b + 1, b + m + 1);     for (i = 1; i <= m / 2; i++) swap(b[i], b[m - i + 1]);     for (i = 1; i <= m; i++) b[i] = h - b[i];     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     for (i = 1; i <= m; i++) c[i] = a[i];     sort(c + 1, c + m + 1);     for (i = 1; i <= m; i++) {       t = lower_bound(c + 1, c + m + 1, b[i]) - c;       ins(0, 1, m, i, i - t);     }     ans += (minx[0] >= 0);     for (i = m + 1; i <= n; i++) {       if (a[i] > a[i - m]) {         L = upper_bound(b + 1, b + m + 1, a[i - m]) - b;         R = upper_bound(b + 1, b + m + 1, a[i]) - b - 1;         if (L <= R && L <= m) add(0, 1, m, L, R, 1);       } else if (a[i] < a[i - m]) {         L = upper_bound(b + 1, b + m + 1, a[i]) - b;         R = upper_bound(b + 1, b + m + 1, a[i - m]) - b - 1;         if (L <= R && L <= m) add(0, 1, m, L, R, -1);       }       ans += (minx[0] >= 0);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int len(char* a) {     int count;     for (int i = 0; a[i] !=   0 ; ++i) {       ++count;     }     return count;   }   int main() {     char a[101], b[101], c[101];     int found = 0, i, j;     fscanf(stdin,  %s%s%s , a, b, c);     if (len(a) + len(b) != len(c)) {       fprintf(stdout,  NO );       return 0;     }     for (i = 0; c[i] !=   0 ; ++i) {       for (j = 0; a[j] !=   0 ; ++j) {         if (c[i] == a[j]) {           found = 1;           a[j] = 1;           break;         }       }       if (!found) {         for (j = 0; b[j] !=   0 ; ++j) {           if (c[i] == b[j]) {             found = 1;             b[j] = 1;             break;           }         }       }       if (!found) {         fprintf(stdout,  NO );         return 0;       }       found = 0;     }     fprintf(stdout,  YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e6;   const int Linf = 1e9;   const long long LLinf = (long long)1e18;   const int maxn = 1e5 + 5;   int n, a[maxn];   long long k, res = 0;   int sum[maxn], sum1[maxn], cnt;   map<int, int> mmap;   set<int> s;   void Enter() {     cin >> n >> k;     for (int i = (1); i <= (n); ++i) cin >> a[i], s.insert(a[i]);     cnt = 0;     for (int c : s) mmap[c] = ++cnt;     for (int i = (1); i <= (n); ++i) a[i] = mmap[a[i]];   }   void update(int key, int x, int delta) {     for (; x <= cnt; x += x & -x)       if (key)         sum[x] += delta;       else         sum1[x] += delta;   }   int su(int key, int x) {     int r = 0;     for (; x > 0; x &= x - 1)       if (key)         r += sum[x];       else         r += sum1[x];     return r;   }   void Init() {     int j = 1;     int i = 1;     long long now = 0;     for (int i = (1); i <= (n); ++i) {       now += i - 1 - su(0, a[i]);       update(0, a[i], 1);     }     while (i <= n) {       update(1, a[i], 1);       now += su(0, a[i] - 1) + (su(1, cnt) - su(1, a[i]));       while ((now > k || j <= i) && j <= n) {         now -= su(1, cnt) - su(1, a[j]) + su(0, a[j] - 1);         update(0, a[j], -1);         ++j;       }       ++i;       res += n - j + 1;     }     cout << res;   }   void Solve() {}   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     Enter();     Init();     Solve();   }
#include <bits/stdc++.h>   using namespace std;   char getDiffColor(char a, char b) {     map<char, bool> mp;     mp[a] = true, mp[b] = true;     if (mp.find( R ) == mp.end())       return  R ;     else if (mp.find( G ) == mp.end())       return  G ;     else       return  B ;   }   int main() {     int cnt = 0;     string st;     cin >> cnt >> st;     cnt = 0;     int i = 0;     while (i + 2 < (st.size())) {       if (st[i] == st[i + 1] && st[i] == st[i + 2])         st[i + 1] = getDiffColor(st[i], st[i]), cnt++;       i++;     }     char pre = st[0];     for (int i = 0; i < st.size() - 1; i++)       if (st[i] == st[i + 1])         st[i] = getDiffColor(pre, st[i]), pre = st[i], cnt++;       else         pre = st[i];     cout << cnt <<   n  << st;   }