malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct query {     int t = 0, row = 0, col = 0;     long long x = 0;   };   int n, m;   vector<vector<long long>> mat;   void rotate_row(int row) {     long long temp = mat[row][m];     for (int i = m; i > 1; i--) {       mat[row][i] = mat[row][i - 1];     }     mat[row][1] = temp;   }   void rotate_col(int col) {     long long temp = mat[n][col];     for (int i = n; i > 1; i--) {       mat[i][col] = mat[i - 1][col];     }     mat[1][col] = temp;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int T = 1;     while (T--) {       long long q;       cin >> n >> m >> q;       for (int i = 0; i <= n; i++) {         vector<long long> temp(m + 1, 0);         mat.push_back(temp);       }       stack<query> s;       while (q--) {         int t, row, col;         long long x;         query temp;         cin >> t;         if (t == 1) {           cin >> row;           temp.t = t;           temp.row = row;         }         if (t == 2) {           cin >> col;           temp.t = t;           temp.col = col;         }         if (t == 3) {           cin >> row >> col >> x;           temp.row = row;           temp.col = col;           temp.x = x;           temp.t = t;         }         s.push(temp);       }       while (!s.empty()) {         int t = s.top().t;         int row = s.top().row;         int col = s.top().col;         long long x = s.top().x;         if (t == 1) {           rotate_row(row);         }         if (t == 2) {           rotate_col(col);         }         if (t == 3) {           mat[row][col] = x;         }         s.pop();       }       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++) {           cout << mat[i][j] <<    ;         }         cout << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   string s[2020];   long long dp[2020][2020][2], C[2020][2020][2], S[2020][2020][2];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> N >> M;     for (int i = 1; i <= N; i++) {       cin >> s[i];       s[i] =  #  + s[i];     }     for (int i = N; i >= 1; i--)       for (int j = M; j >= 1; j--) {         C[i][j][0] = C[i][j + 1][0] + (s[i][j] ==  R );         C[i][j][1] = C[i + 1][j][1] + (s[i][j] ==  R );         if (i == N && j == M) {           dp[i][j][0] = dp[i][j][1] = 1;         } else {           int r = M - C[i][j + 1][0];           int d = N - C[i + 1][j][1];           dp[i][j][0] = (S[i][j + 1][0] - S[i][r + 1][0]) % 1000000007;           dp[i][j][1] = (S[i + 1][j][1] - S[d + 1][j][1]) % 1000000007;         }         S[i][j][0] = (S[i][j + 1][0] + dp[i][j][1]) % 1000000007;         S[i][j][1] = (S[i + 1][j][1] + dp[i][j][0]) % 1000000007;       }     long long res = dp[1][1][0] + dp[1][1][1];     if (N == 1 && M == 1) res = 1;     res %= 1000000007;     res += 1000000007;     res %= 1000000007;     printf( %lld , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (~scanf( %d , &n)) {       int t = sqrt(n * 1.0);       for (int i = t; i >= 1; i--) {         if (n % i == 0) {           cout << i <<     << n / i << endl;           break;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i;     int a, b;     int draw = 0, awin = 0, bwin = 0;     cin >> a >> b;     for (i = 1; i < 7; i++) {       if (abs(i - a) == abs(i - b))         draw++;       else if (abs(i - a) > abs(i - b))         bwin++;       else         awin++;     }     cout << awin <<     << draw <<     << bwin << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   template <class T>   bool ckmin(T& a, const T& b) {     return b < a ? a = b, 1 : 0;   }   template <class T>   bool ckmax(T& a, const T& b) {     return a < b ? a = b, 1 : 0;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const long double pii = 3.14159265359;   const int MOD = 1000000007;   const char nl =   n ;   const int MX = 200001;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string str;     cin >> str;     vector<int> v(6);     for (int x = 0; x < (6); x++) v[x] = str[x] -  0 ;     vector<int> val(6);     int mn = INT_MAX;     for (int z = 0; z < (10); z++) {       if (z == v[0])         val[0] = 1;       else         val[0] = 0;       for (int b = 0; b < (10); b++) {         if (b == v[1])           val[1] = 1;         else           val[1] = 0;         for (int c = 0; c < (10); c++) {           if (c == v[2])             val[2] = 1;           else             val[2] = 0;           for (int d = 0; d < (10); d++) {             if (d == v[3])               val[3] = 1;             else               val[3] = 0;             for (int e = 0; e < (10); e++) {               if (e == v[4])                 val[4] = 1;               else                 val[4] = 0;               for (int first = 0; first < (10); first++) {                 if (first == v[5])                   val[5] = 1;                 else                   val[5] = 0;                 if (z + b + c == d + e + first)                   ckmin(mn, 6 - (val[0] + val[1] + val[2] + val[3] + val[4] +                                  val[5]));               }             }           }         }       }     }     cout << mn << nl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i;   double x, y, n, a, b, rsa, rsb = 1;   long long cmmdc(long long a, long long b) {     while (a && b) (a > b ? a %= b : b %= a);     return a + b;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> x >> y >> n;     for (b = 1; b <= n; ++b) {       a = max(0LL, (long long)(x * b / y) - 5);       for (i = 0; i < 10; ++i, ++a) {         double gmb = fabs(x * b - y * a) / (y * b);         double fnc = fabs(x * rsb - y * rsa) / (y * rsb);         if (gmb < fnc)           rsb = b, rsa = a;         else if (gmb == fnc && a / cmmdc(a, b) < rsa / cmmdc(rsa, rsb))           rsa = a, rsb = b;       }     }     long long ggg = cmmdc(rsa, rsb);     cout << (long long)(rsa) / ggg <<  /  << (long long)(rsb) / ggg <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, R, C, g[110][110];   vector<int> A, B;   int main() {     scanf( %d %d %d , &N, &R, &C);     for (int i = 1; i <= (N); i++) {       if (i & 1)         A.push_back(i);       else         B.push_back(i);     }     for (int r = 1; r <= (R); r++)       for (int c = 1; c <= (C); c++) {         if ((r + c) % 2 == 0 && A.size()) g[r][c] = A.back(), A.pop_back();         if ((r + c) % 2 == 1 && B.size()) g[r][c] = B.back(), B.pop_back();       }     if (A.size() || B.size())       puts( -1 );     else {       for (int r = 1; r <= (R); r++) {         for (int c = 1; c <= (C); c++) printf( %d  , g[r][c]);         puts(  );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int s[100005];   int mask[25];   struct Reg {     int l, r;   } reg[23][100];   bool test(int p) {     if (p == n) return true;     set<int> q[2];     set<int>::iterator pp;     int now = 1, nxt = 1;     q[0].insert(mask[p] - 1);     for (int i = p; i < n; i++) {       nxt = now;       now = now ^ 1;       for (pp = q[now].begin(); pp != q[now].end(); pp++) {         int mask_n = *pp;         bool ok = false;         for (int j = 1; j <= reg[i][0].l; j++) {           if ((mask[reg[i][j].l] & mask_n) && (mask[reg[i][j].r] & mask_n)) {             ok = true;             break;           }         }         if (ok) {           for (int j = 0; j < i; j++) {             if (mask_n & mask[j]) {               q[nxt].insert((mask_n - mask[j]) | mask[i]);             }           }         }       }       q[now].clear();     }     return (!q[now ^ 1].empty());   }   int main() {     mask[0] = 1;     for (int i = 1; i < 25; i++) mask[i] = (mask[i - 1] << 1);     cin >> n;     for (int i = 0; i < (n); i++) cin >> s[i];     bool ok = true;     for (int i = 1; i < n; i++) {       ok = false;       for (int j = 0; j < i; j++) {         for (int k = 0; k <= j; k++) {           if (s[j] + s[k] == s[i]) {             ok = true;             reg[i][0].l++;             reg[i][reg[i][0].l].l = j;             reg[i][reg[i][0].l].r = k;           }         }       }       if (ok == false) break;     }     if (!ok) {       cout << -1 << endl;       return 0;     }     int l = 1, r = n;     int ret = -1;     while (l <= r) {       int mid = (l + r) / 2;       if (test(mid)) {         r = mid - 1;         ret = mid;       } else {         l = mid + 1;       }     }     cout << ret << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, b, s;     cin >> a >> b >> s;     if (s < abs(a) + abs(b))       cout <<  NO  << endl;     else if (s == abs(a) + abs(b))       cout <<  YES  << endl;     else {       s -= abs(a);       s -= abs(b);       if (s % 2 == 0)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char** argv) {     ios::sync_with_stdio(false);     cin.tie(NULL);     unordered_map<int, int> idx;     int N, x;     cin >> N;     while (N--) {       cin >> x;       if (x) idx[x] = 1;     }     cout << idx.size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static inline void canhazfast() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);   }   template <typename T>   T gcd(T a, T b) {     return b == 0 ? a : gcd(b, a % b);   }   template <typename T>   T extgcd(T a, T b, T &x, T &y) {     T x0 = 1, y0 = 0, x1 = 0, y1 = 1;     while (b) {       T q = a / b;       a %= b;       swap(a, b);       x0 -= q * x1;       swap(x0, x1);       y0 -= q * y1;       swap(y0, y1);     }     x = x0;     y = y0;     return a;   }   int main() {     canhazfast();     static int a[100016];     static char b[100016];     int n;     int l = -1000000000, r = 1000000000;     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i];     cin >> b;     for (int i = 4; i < n; ++i) {       if (b[i] != b[i - 1]) {         if (b[i] ==  0 )           for (int j = 0; j <= 4; ++j) r = min(r, a[i - j] - 1);         else           for (int j = 0; j <= 4; ++j) l = max(l, a[i - j] + 1);       }     }     cout << l <<     << r <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300000;   const long long INF = 1e18;   const int sqrtConst = 550;   const int alphabet = 26;   const long long mod = 998244353;   void solve() {     string s;     cin >> s;     bool has1 = false;     for (int i = 1; i < s.size(); i++) {       if (s[i] ==  1 ) {         has1 = true;         break;       }     }     int cnt = (s.size() + 1) / 2;     if (!has1 && (s.size() % 2)) cnt--;     cout << cnt;   }   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     cout << setprecision(6) << fixed;     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Q, N, M, K, L;   bool board[10001][3];   long long dp[10001][8];   int bitCheck[4][2][2] = {       {{-2, 0}, {-1, 0}}, {{1, 0}, {2, 0}}, {{0, 1}, {0, 2}}, {{0, -1}, {0, -2}}};   void getNextStates(int n, int m, int thisState, int nextState,                      vector<int>& res) {     if (m == 3) {       res.push_back(nextState);       return;     }     if (board[n][m] || (thisState & (1 << m))) {       getNextStates(n, m + 1, thisState, nextState, res);       return;     }     if (n < N - 1) {       if (!board[n + 1][m])         getNextStates(n, m + 1, thisState, nextState | (1 << m), res);     }     if (m < 2) {       if (!board[n][m + 1] && !(thisState & (1 << (m + 1))))         getNextStates(n, m + 2, thisState, nextState, res);     }   }   long long solve(int n, int state) {     if (n == N) {       return 1LL;     }     long long& ret = dp[n][state];     if (~ret) return ret;     ret = 0;     vector<int> next;     getNextStates(n, 0, state, 0, next);     for (int i = 0; i < next.size(); i++) {       ret += solve(n + 1, next[i]);       ret %= 1000000007LL;     }     return ret;   }   int x, y;   long long ret;   void solve2(int n, int cnt) {     if (n == 4) {       if (!cnt) return;       memset(dp, -1, sizeof dp);       long long t = solve(0, 0);       if (cnt % 2)         ret += t;       else         ret -= t;       ret = (ret + 1000000007LL) % 1000000007LL;       return;     }     solve2(n + 1, cnt);     bool flag = true;     for (int j = 0; j < 2; j++) {       int nx = x + bitCheck[n][j][0];       int ny = y + bitCheck[n][j][1];       if (nx < 0 || ny < 0 || nx >= N || ny >= 3 || board[nx][ny]) flag = false;     }     if (!flag) return;     for (int j = 0; j < 2; j++) {       int nx = x + bitCheck[n][j][0];       int ny = y + bitCheck[n][j][1];       board[nx][ny] = 1;     }     solve2(n + 1, cnt + 1);     for (int j = 0; j < 2; j++) {       int nx = x + bitCheck[n][j][0];       int ny = y + bitCheck[n][j][1];       board[nx][ny] = 0;     }   }   int main() {     cin >> N;     board[N][0] = board[N][1] = board[N][2] = 1;     for (int i = 0; i < 3; i++) {       string s;       cin >> s;       for (int j = 0; j < N; j++) {         board[j][i] = s[j] ==  .  ? false : true;         if (s[j] ==  O ) {           y = i;           x = j;         }       }     }     solve2(0, 0);     cout << ret;     cin >> N;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, m, mex = N, ans[N];   pair<int, int> a[N];   int main() {     cin >> n >> m;     for (int i = 1; i <= m; ++i) {       int l, r;       cin >> l >> r;       a[i] = {l, r};       mex = min(mex, r - l + 1);     }     int cur = 0;     cout << mex <<   n ;     for (int i = 1; i <= n; ++i) {       if (cur == mex) cur = 0;       cout << cur++ <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, n, m, l, r, q, nr;     string s;     string t;     cin >> n >> m >> q;     cin >> s >> t;     int cnt[1001] = {0};     for (int i = 0; i <= n - m; i++) {       if (s.substr(i, m) == t) {         cnt[i] = 1;       }     }     l = 0;     r = 0;     for (i = 1; i <= q; i++) {       cin >> l >> r;       nr = 0;       for (j = l - 1; j <= r - m; j++) {         if (cnt[j]) nr++;       }       cout << nr <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool compare(string &s1, string &s2) { return s1.size() < s2.size(); }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     vector<string> s;     string str;     int n, i, j, flag = 0;     cin >> n;     for (i = 0; i < n; i++) {       cin >> str;       s.push_back(str);     }     sort(s.begin(), s.end(), compare);     for (i = 0; i < n - 1; i++) {       j = 0;       while (j < s[i + 1].length()) {         int l = s[i].length();         flag = 0;         if (s[i] == s[i + 1].substr(j, l)) {           flag = 1;           break;         }         j++;       }       if (flag != 1) {         cout <<  NO n ;         break;       }     }     if (flag == 1 || n == 1) {       cout <<  YES n ;       for (i = 0; i < n; i++) {         cout << s[i] <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int a, b, t, c, j, k, T, i, A[1028], B[1028], C[1028];   int main() {     cin >> a >> b;     while (a > 0) {       a--;       t++;       if (t == b) {         t = 0;         a++;       }       j++;     }     cout << j;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3)   using namespace std;   const long long INF = 2e18;   const int maxn = 1e6 + 6;   const int mod = 1e9 + 6;   const double eps = 1e-15;   inline bool read(long long &num) {     char in;     bool IsN = false;     in = getchar();     if (in == EOF) return false;     while (in !=  -  && (in <  0  || in >  9 )) in = getchar();     if (in ==  - ) {       IsN = true;       num = 0;     } else       num = in -  0 ;     while (in = getchar(), in >=  0  && in <=  9 ) {       num *= 10, num += in -  0 ;     }     if (IsN) num = -num;     return true;   }   long long n, m, p;   long long num[maxn];   vector<long long> v;   int vis[maxn];   int getid(long long x) {     return lower_bound(v.begin(), v.end(), x) - v.begin() + 1;   }   long long dp[maxn][2];   long long pre[maxn], first[maxn], sc[maxn];   int main() {     int T;     scanf( %d , &T);     while (T--) {       read(n);       v.clear();       for (int i = 1; i <= n; i++) {         vis[i] = 0;         dp[i][0] = dp[i][1] = 0;         pre[i] = 0;         first[i] = 0;         sc[i] = -(1e9 + 7);       }       for (int i = 1; i <= n; i++) {         read(num[i]);         v.push_back(num[i]);       }       long long maxl = 0;       sort(v.begin(), v.end());       v.erase((unique(v.begin(), v.end())), v.end());       for (int i = 1; i <= n; i++) vis[getid(num[i])]++;       for (int i = 1; i <= n; i++) {         int id = getid(num[i]);         pre[id]++;         dp[id][0] = dp[id][0] + 1;         if (pre[id] == 1) first[id] = max(dp[id - 1][0], dp[id - 1][1]);         if (pre[id] == vis[id]) dp[id][1] = first[id] + vis[id];         sc[id] =             max(sc[id], max(dp[id - 1][0] - pre[id], dp[id - 1][1] - pre[id]));         maxl = max(maxl, sc[id] + pre[id] + 1);         maxl = max(maxl, max(dp[id][0], dp[id][1]));       }       printf( %lld n , n - maxl);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long Mode = 1e9 + 7;   void Modulo(unsigned long long &x) { x = ((x % Mode + Mode) % Mode); }   unsigned long long Pow(unsigned long long x, unsigned long long y) {     unsigned long long res = 1;     for (unsigned long long i = 0; (1ULL << i) <= y; i++, x *= x, Modulo(x))       if (y & (1ULL << i)) res *= x, Modulo(res);     return res;   }   int main() {     unsigned long long n, ans = 1, D = 1;     cin >> n;     D = n;     for (unsigned long long i = 2ULL * n - 1; i > 0; i--) ans *= i, Modulo(ans);     for (unsigned long long i = 1; i <= n - 1; i++) D *= i * i, Modulo(D);     ans *= Pow(D, Mode - 2);     ans *= 2ULL;     Modulo(ans);     ans -= n;     Modulo(ans);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   int vals[N], found[N];   struct node {     node *left, *right;     int val, size, priority;     node(int v) {       val = v, size = 1, priority = rand(), left = NULL, right = NULL;     }   };   int sz(node* t) { return (t) ? t->size : 0; }   void upd_sz(node*& t) {     if (t) t->size = sz(t->left) + 1 + sz(t->right);   }   void split(node* t, node*& l, node*& r, int k) {     if (!t)       l = r = NULL;     else if (sz(t->left) + 1 <= k)       split(t->right, t->right, r, k - sz(t->left) - 1), l = t;     else       split(t->left, l, t->left, k), r = t;     upd_sz(t);   }   void merge(node*& t, node* l, node* r) {     if (!l || !r)       t = l ? l : r;     else if (l->priority >= r->priority)       merge(l->right, l->right, r), t = l;     else       merge(r->left, l, r->left), t = r;     upd_sz(t);   }   int main() {     srand(time(NULL));     int n, m, x, y;     scanf( %d %d , &n, &m);     node* t = NULL;     for (int i = 1; i <= n; i++) {       merge(t, t, new node(i));     }     node* a;     node* b;     while (m--) {       scanf( %d %d , &x, &y);       split(t, a, t, y);       split(a, a, b, y - 1);       if (vals[b->val] == x) {       } else if (vals[b->val] == 0 && found[x] == 0)         vals[b->val] = x;       else {         printf( -1 n );         return 0;       }       found[x] = 1;       merge(a, b, a);       merge(t, a, t);     }     int f = 1;     for (int i = 1; i <= n; i++) {       if (vals[i] == 0) {         while (found[f] != 0) {           f++;         }         vals[i] = f++;       }     }     for (int i = 1; i <= n; i++) {       printf( %d  , vals[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   int n, t[1000001];   struct data {     int num, loc, vis;   } b[1000001];   int a[1000001];   int lowbit(int x) { return x & (-x); }   int Query(int x) {     int sum = 0;     while (x > 0) {       sum = max(sum, t[x]);       x -= lowbit(x);     }     return sum;   }   void Add(int x, int va) {     while (x <= N) {       t[x] = max(t[x], va);       x += lowbit(x);     }   }   bool cmp(data p, data q) { return p.num < q.num; }   bool cmp2(data p, data q) { return p.vis < q.vis; }   int work() {     memset(t, 0, sizeof(t));     for (int i = 1; i <= n; i++) {       b[i].num = a[i];       b[i].vis = i;     }     sort(b + 1, b + n + 1, cmp);     for (int i = 1; i <= n; i++) b[i].loc = n + 1 - i;     sort(b + 1, b + n + 1, cmp2);     int ans = 0;     for (int i = 1; i <= n; i++) {       int nowans = Query(b[i].loc);       Add(b[i].loc, i);       if (nowans == 0) continue;       ans = max(ans, b[i].num ^ b[nowans].num);     }     return ans;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     int ans = work();     for (int i = 1; i <= n / 2; i++) swap(a[i], a[n + 1 - i]);     ans = max(ans, work());     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   string s;   int main() {     cin.tie(0);     std::ios::sync_with_stdio(false);     cin >> n >> k;     cin >> s;     if (k == 2) {       string s1 =   , s2 =   ;       for (int i = 0; i < s.size(); i++)         if (i & 1)           s1 +=  A , s2 +=  B ;         else           s1 +=  B , s2 +=  A ;       int x = 0, y = 0;       for (int i = 0; i < s.size(); i++)         x += (s[i] == s1[i] ? 1 : 0), y += (s[i] == s2[i] ? 1 : 0);       if (x > y)         cout << s.size() - x << endl << s1 << endl;       else         cout << s.size() - y << endl << s2 << endl;       return 0;     }     string h;     int z = 1;     map<int, char> mop;     map<char, int> mops;     for (char c =  A ; c <=  Z ; c++) {       mop[z] = c, mops[c] = z, z++;       if (z > k) break;     }     string t = s;     int ans = 0;     for (int i = 0; i < s.size() - 1; i++) {       if (s[i] == s[i + 1]) {         h = s[i], h += s[i + 1];         int f = i + 1;         for (int j = i + 2; j < s.size(); j++) {           if (s[j] != s[i]) break;           f++;           h += s[j];         }         char prev = s[i - 1], next = h[1];         if (h.size() % 2 == 0)           for (int j = 0; j < h.size(); j += 2) {             for (__typeof((mops).begin()) it = (mops).begin(); it != (mops).end();                  it++)               if (it->first != prev && it->first != next) {                 h[j] = it->first;                 prev = h[j + 1], next = h[j + 3];                 ans++;                 break;               }           }         else {           prev = h[0], next = h[2];           for (int j = 1; j < h.size(); j += 2) {             for (__typeof((mops).begin()) it = (mops).begin(); it != (mops).end();                  it++)               if (it->first != prev && it->first != next) {                 h[j] = it->first;                 prev = h[j + 1];                 next = h[j + 3];                 ans++;                 break;               }           }         }         int n = 0;         for (int j = i; j < f; j++) s[j] = h[n++];         i = f - 1;       }     }     cout << ans << endl;     cout << s << endl;     return 0;   }