malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<bool> primes(100006, false);   void sieve() {     for (long long i = 3; i <= 100006; i += 2) {       primes[i] = 1;     }     for (long long i = 3; i <= 100006; i += 2) {       if (primes[i] == 1) {         for (long long j = i * i; j <= 100006; j += i) {           primes[j] = 0;         }       }     }     primes[2] = 1;     primes[0] = primes[1] = 0;   }   int recpow(int x, int n) {     if (n == 0)       return 1;     else if (n % 2 == 0)       return recpow((x * x), n / 2);     else       return (x * recpow((x * x), (n - 1) / 2));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long k, a, b;     cin >> k >> a >> b;     long long count = 0;     count = a / k;     count += b / k;     if (count == 0)       cout << -1 << endl;     else if (a % k > 0 and b / k == 0)       cout << -1 << endl;     else if (b % k > 0 and a / k == 0)       cout << -1 << endl;     else       cout << count << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int r, c, p;     node() {}     node(int _r, int _c, int _p) { r = _r, c = _c, p = _p; }   };   const int MAXN = 1005;   char g[MAXN][MAXN];   int dist[MAXN][MAXN];   int dx[] = {1, 0, -1, 0};   int dy[] = {0, 1, 0, -1};   int to_int(const char& c) { return c -  0 ; }   bool is_digit(const char& c) {     if ( 1  <= c && c <=  9 ) return true;     return false;   }   void bfs(const int& r, const int& c, node s) {     queue<node> q;     q.push(s);     memset(dist, -1, sizeof dist);     dist[s.r][s.c] = 0;     int xx, yy;     while (!q.empty()) {       s = q.front();       q.pop();       for (int i = 0; i < 4; ++i) {         xx = dx[i] + s.r;         yy = dy[i] + s.c;         if (xx < 0 || xx >= r || yy < 0 || yy >= c || g[xx][yy] ==  T  ||             dist[xx][yy] != -1)           continue;         dist[xx][yy] = dist[s.r][s.c] + 1;         q.emplace(xx, yy, s.p);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int r, c, best, ans;     vector<node> b;     node s, f;     while (cin >> r >> c) {       for (int i = 0; i < r; ++i) {         for (int j = 0; j < c; ++j) {           cin >> g[i][j];           if (is_digit(g[i][j])) b.emplace_back(i, j, to_int(g[i][j]));           if (g[i][j] ==  S ) s = node(i, j, 0);           if (g[i][j] ==  E ) f = node(i, j, 0);         }       }       bfs(r, c, f);       ans = 0;       best = dist[s.r][s.c];       for (node i : b)         if (dist[i.r][i.c] <= best && dist[i.r][i.c] != -1) ans += i.p;       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   inline int read() {     int s = 0, w = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       s = s * 10 + ch -  0 ;       ch = getchar();     }     return s * w;   }   int n;   int a[N];   void solve() {     n = read();     int sum = 0;     for (int i = 1; i <= n; i++) a[i] = read(), sum += a[i];     for (int i = 2; i * i <= sum; i++) {       if (sum % i == 0) {         printf( %d n , n);         for (int i = 1; i <= n; i++) printf( %d  , i);         puts(  );         return;       }     }     printf( %d n , n - 1);     bool ok = 0;     for (int i = 1; i <= n; i++) {       if (!ok && a[i] % 2 == 1) {         ok = 1;         continue;       }       printf( %d  , i);     }     puts(  );   }   int main() {     int T = read();     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int INF = 1e9 + 7;   const int base = 1e9;   const int MAX = 1e5;   const double EPS = 1e-9;   const double PI = acos(-1.);   int main() {     char x;     string s1, s2, res;     vector<char> v(10000);     int c1, c2, cnt = 0, i = 0;     cin >> s1 >> s2;     if ((s1.length() - 1 + s2.length()) % 2 == 1) {       cout <<  Impossible ;       return 0;     }     for (int i = 0; i < s1.length(); i++) {       if (s1.substr(i, 1) ==  | ) {         c1 = cnt;         cnt = 0;       } else {         cnt++;       }     }     c2 = cnt;     if (max(c1, c2) > (s1.length() - 1 + s2.length()) / 2) {       cout <<  Impossible ;       return 0;     }     if (c1 > c2) {       res.append(s2, 0, (s2.length() - (c1 - c2)) / 2);       res.append(s1);       res.append(s2, (s2.length() - (c1 - c2)) / 2,                  (s2.length() + (c1 - c2)) / 2);     } else {       res.append(s2, 0, (s2.length() + (c2 - c1)) / 2);       res.append(s1);       res.append(s2, (s2.length() + (c2 - c1)) / 2,                  (s2.length() - (c2 - c1)) / 2);     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   long long int arr[100050];   vector<vector<long long int>> v(100050);   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) cin >> arr[i];     for (int i = 1; i <= m; i++) {       if (i > 1 && arr[i - 1] != arr[i]) v[arr[i]].push_back(arr[i - 1]);       if (i < m && arr[i] != arr[i + 1]) v[arr[i]].push_back(arr[i + 1]);     }     long long int sum = 0, ans;     for (int i = 1; i < m; i++) sum += abs(arr[i] - arr[i + 1]);     ans = sum;     for (int i = 1; i <= n; i++) {       if (v[i].size() == 0) continue;       sort(v[i].begin(), v[i].end());       long long int y = v[i][v[i].size() / 2];       long long int before = 0, after = 0;       for (int x : v[i]) {         before += abs(x - i);         after += abs(y - x);       }       ans = min(ans, sum - before + after);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> prices;   int main() {     long long int n, p, s = 0;     cin >> n;     for (long long int a = 0; a < n; a++) {       cin >> p;       prices.push_back(p);       s += p;     }     sort(prices.rbegin(), prices.rend());     cin >> n;     for (long long int a = 0; a < n; a++) {       cin >> p;       cout << s - prices[p - 1] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[212345];   int color[212345];   bool vis[212345];   map<int, int> m;   int r = 0;   int dfs(int i) {     if (vis[i]) return 0;     vis[i] = true;     m[color[i]]++;     if (m[r] < m[color[i]]) r = color[i];     int cont = 0;     for (int v : g[i]) {       cont += dfs(v);     }     return 1 + cont;   }   int solve(int i) {     r = -1;     m[-1] = 0;     int cont = dfs(i);     int rr = cont - m[r];     m.clear();     return rr;   }   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < n; ++i) cin >> color[i];     for (int i = 0; i < m; ++i) {       int l, r;       cin >> l >> r;       l--;       r--;       g[l].push_back(r);       g[r].push_back(l);     }     memset(vis, false, sizeof vis);     int cont = 0;     for (int i = 0; i < n; ++i) {       if (vis[i]) continue;       cont += solve(i);     }     cout << cont << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long base = 71;   const long long mod = 1e9 + 9;   int convert(char a) {     if (a >=  a  && a <=  z ) return (a -  a ) + 1;     if (a >=  A  && a <=  Z ) return (a -  A ) + 27;     return (a -  0 ) + 53;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string s;     cin >> s;     int n = (int)s.length();     long long ans = 0;     vector<long long> V(n);     long long H = 0;     long long I = 0;     long long p = 1;     V[0] = 1ll;     for (int i = 0; i < n; ++i) {       H = (H * base % mod + (long long)convert(s[i])) % mod;       I = (I + p * (long long)convert(s[i]) % mod) % mod;       p = (p * base) % mod;       if (i && H == I) V[i] = V[(i - 1) / 2] + 1ll;       ans += V[i];     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   int n, q, a[N], c[N], l[N], r[N];   vector<int> s[N], p[N], b;   set<int> s1, s2, s3, s4, s5, s6, s7;   int main() {     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= q; i++) {       scanf( %d%d , &l[i], &r[i]);       p[l[i]].push_back(i);     }     for (int i = n; i; i--) {       int x;       while (s1.size() && a[x = *s1.begin()] < a[i]) {         s6.insert(x);         c[x]--;         if (!c[x]) s5.insert(x);         s1.erase(x);       }       while (s2.size() && a[x = *s2.begin()] > a[i]) {         s7.insert(x);         c[x]--;         if (!c[x]) s5.insert(x);         s2.erase(x);       }       while (s3.size() && a[x = *s3.begin()] <= a[i]) s3.erase(x);       while (s4.size() && a[x = *s4.begin()] >= a[i]) s4.erase(x);       if (s3.size() && s4.size()) {         auto it = s5.lower_bound(max(*s3.begin(), *s4.begin()));         if (it != s5.end() && (!b.size() || *it < b.back())) {           b = {i, *it};           auto it2 = s1.lower_bound(*it);           it2--;           b.push_back(*it2);           it2 = s2.lower_bound(*it);           it2--;           b.push_back(*it2);           sort(b.begin(), b.end());         }       }       for (int j : p[i]) {         if (b.size() && b.back() <= r[j])           s[j] = b;         else {           if (s3.size()) {             auto it = s6.lower_bound(*s3.begin());             if (it != s6.end() && *it <= r[j]) s[j] = {i, *it - 1, *it};           }           if (s4.size()) {             auto it = s7.lower_bound(*s4.begin());             if (it != s7.end() && *it <= r[j]) s[j] = {i, *it - 1, *it};           }         }       }       c[i] = 2;       s1.insert(i), s2.insert(i), s3.insert(i), s4.insert(i);     }     for (int i = 1; i <= q; i++) {       printf( %d n , s[i].size());       for (auto j : s[i]) printf( %d  , j);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int K = 10;   const int NQ = 160000;   int n, k, q;   int v[NQ];   pair<int, int> lg[K];   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(NULL);     cin >> n >> k >> q;     for (int i = 0; i < n; i++) {       cin >> v[i];     }     for (int i = 0; i < k; i++) {       lg[i].first = -1;       lg[i].second = -1;     }     for (int i = 0; i < q; i++) {       int x, y;       cin >> x >> y;       y--;       if (x == 1) {         if (lg[0].first == -1 || lg[0].first < v[y]) {           lg[0] = make_pair(v[y], y);           sort(lg, lg + k);         }       } else {         bool flag = false;         for (int i = 0; i < k; i++) {           if (lg[i].second == y) {             flag = true;           }         }         cout << (flag ?  YES  :  NO ) << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct __timestamper {};   vector<vector<int>> ga;   vector<vector<int>> gb;   vector<int> comp;   vector<bool> used;   void dfsa(int v) {     used[v] = true;     comp.push_back(v);     for (int u : ga[v]) {       if (!used[u]) {         dfsa(u);       }     }   }   int main() {     int n, m, a, b;     while (scanf( %d%d%d%d , &n, &m, &a, &b) == 4) {       ga = gb = vector<vector<int>>(n);       for (int i = 0; i < m; i++) {         int x, y, c;         scanf( %d%d%d , &x, &y, &c);         --x, --y;         auto& g = (c == a) ? ga : gb;         g[x].push_back(y);         g[y].push_back(x);       }       vector<pair<int, int>> order;       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           order.emplace_back(i, j);         }       }       sort(order.begin(), order.end(),            [&](const pair<int, int>& x, const pair<int, int>& y) {              return x.first * a + x.second * b < y.first * a + y.second * b;            });       vector<int> comp_id(n, -1);       used = vector<bool>(n, false);       int cc = 0;       int cc2 = -2;       for (int i = 0; i < n; i++) {         if (comp_id[i] == -1) {           comp.clear();           dfsa(i);           int cid = (comp.size() >= 4 ? cc++ : cc2--);           for (int x : comp) {             comp_id[x] = cid;           }         }       }       vector<vector<vector<pair<int, int>>>> vs(           n, vector<vector<pair<int, int>>>(n));       vector<vector<int>> dp((1 << cc), vector<int>(n, 1 << 30));       int init_id = (comp_id[0] < 0) ? 0 : (1 << comp_id[0]);       dp[init_id][0] = 0;       vs[0][0].emplace_back(init_id, 0);       vector<int> ans(n, 1 << 30);       for (auto& [cnta, cntb] : order) {         for (auto& [mask, v] : vs[cnta][cntb]) {           if (dp[mask][v] != cnta * a + cntb * b) continue;           ans[v] = min(ans[v], dp[mask][v]);           for (int u : ga[v]) {             if (dp[mask][u] > dp[mask][v] + a) {               assert(comp_id[u] == comp_id[v]);               dp[mask][u] = dp[mask][v] + a;               vs[cnta + 1][cntb].emplace_back(mask, u);             }           }           for (int u : gb[v]) {             if (comp_id[u] == comp_id[v]) continue;             int nmask = mask;             if (comp_id[u] >= 0) {               nmask |= (1 << comp_id[u]);               if (mask == nmask) continue;             }             if (dp[nmask][u] > dp[mask][v] + b) {               dp[nmask][u] = dp[mask][v] + b;               vs[cnta][cntb + 1].emplace_back(nmask, u);             }           }         }       }       for (int i = 0; i < n; i++) {         printf( %d  , ans[i]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool d[400];   void input() {     int i, n, nk, nc, x;     scanf( %d %d , &n, &nk);     scanf( %d , &nc);     for ((i) = 0; (i) < (nc); (i)++) scanf( %d , &x), d[x] = true;     int res = 0, cnt = 0;     for ((i) = (1); (i) <= (n); (i)++) {       cnt++;       if (cnt == nk || d[i]) {         res++;         cnt = 0;       }     }     printf( %d , res);   }   int main() {     input();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct edge {     int v, next;   };   bool islucky[100010];   bool vis[100010];   int A[100010], C[100010];   edge e[2 * 100010];   int beg[100010], f[100010];   int n, m, cnt, tot, ne;   void dfs(int x) {     if (x >= 100010) return;     islucky[x] = true;     dfs(x * 10 + 4);     dfs(x * 10 + 7);   }   void pre_cal() {     memset(islucky, 0, sizeof(islucky));     dfs(0);     islucky[0] = false;   }   void dfs2(int x) {     vis[x] = true;     cnt++;     for (int i = beg[x]; i != -1; i = e[i].next)       if (!vis[e[i].v]) {         dfs2(e[i].v);       }   }   void add(int x, int y) {     e[ne].v = y;     e[ne].next = beg[x];     beg[x] = ne++;   }   void input() {     int x, y;     ne = 0;     memset(beg, 255, sizeof(beg));     for (int i = 0; i < m; i++) {       scanf( %d%d , &x, &y);       add(x, y);       add(y, x);     }     memset(vis, 0, sizeof(vis));     memset(C, 0, sizeof(C));     for (int i = 1; i <= n; i++)       if (!vis[i]) {         cnt = 0;         dfs2(i);         C[cnt]++;       }     tot = 0;     for (int i = 1; i <= n; i++)       if (C[i]) {         A[tot] = i;         C[tot++] = C[i];       }   }   void dp() {     fill(f, f + n + 1, 0x3fffffff);     f[0] = 0;     for (int j = 0; j < tot; j++) {       int num = C[j];       int k = 0;       for (k = 0; (1 << k) <= num; k++) {         for (int i = n; i >= (1 << k) * A[j]; i--)           f[i] = min(f[i], f[i - (1 << k) * A[j]] + (1 << k));         num -= (1 << k);       }       if (num > 0)         for (int i = n; i >= num * A[j]; i--)           f[i] = min(f[i], f[i - num * A[j]] + num);     }     int ans = 0x3fffffff;     for (int i = 1; i <= n; i++)       if (islucky[i] && f[i] < ans) ans = f[i];     if (ans == 0x3fffffff)       printf( -1 n );     else       printf( %d n , ans - 1);   }   int main() {     pre_cal();     while (scanf( %d%d , &n, &m) != EOF) {       input();       dp();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long sum;     vector<int> v;     ios::sync_with_stdio(0);     cin >> n;     sum = (1LL + n) * n / 2LL;     if (sum % 2LL == 0LL) {       sum /= 2LL;       for (int i = n; i >= 1; i--)         if (sum >= i) {           v.push_back(i);           sum -= i;         }       cout <<  0  << endl;       cout << v.size();       for (int i = 0; i < v.size(); i++) cout <<     << v[i];       cout << endl;     } else {       sum /= 2LL;       for (int i = n; i >= 1; i--)         if (sum >= i) {           v.push_back(i);           sum -= i;         }       cout <<  1  << endl;       cout << v.size();       for (int i = 0; i < v.size(); i++) cout <<     << v[i];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   long long n;   long long check(long long x) {     for (long long i = 2; i * i <= x; i++)       if (x % i == 0) return 1;     return 0;   }   long long exgcd(long long a, long long b, long long &x, long long &y) {     long long g = a;     if (b == 0)       x = 1, y = 0;     else       g = exgcd(b, a % b, y, x), y -= (a / b) * x;     return g;   }   int main() {     scanf( %lld , &n);     if (n == 1) return !printf( YES n1 n );     if (n == 4) return !printf( YES n1 3 2 4 n );     if (check(n)) return !printf( NO n );     printf( YES n1 n );     for (register long long i = 2; i <= n - 1; ++i) {       long long x, y;       exgcd(i - 1, n, x, y);       printf( %lld n , ((x * i) % n + n) % n);     }     printf( %lld n , n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000 * 1000 * 1000 + 7;   const long long INF = 2 * 1000 * 1000 + 200;   const long long MAXN = 100 * 1000 + 1;   const long long MLOG = 18;   const long long NMAX = 1 * 1000;   signed main() {     long long n, m, a[200];     a[0] = 0;     long long x, y;     cin >> n;     for (long long i = 1; i <= n; i++) cin >> a[i];     cin >> m;     for (long long i = 0; i < m; i++) {       cin >> x >> y;       a[x - 1] += y - 1;       a[x + 1] += a[x] - y;       a[x] = 0;     }     for (long long i = 1; i <= n; i++) cout << a[i] << endl;   }
#include <bits/stdc++.h>   using namespace std;   ofstream out( biconex.out );   ifstream in( biconex.in );   struct Edge {     int node;     bool is_critic;   };   const int N_MAX = 100000;   vector<Edge> neighbours[1 + N_MAX];   stack<int> component;   int n, m, h, minim = N_MAX + 1, node_ans, Depth, root_sons, depth[1 + N_MAX],                height[1 + N_MAX], main_hour[1 + N_MAX], color[1 + N_MAX];   bool visited[1 + N_MAX], not_in_subgraph[1 + N_MAX], is_critic[1 + N_MAX],       on_stack[1 + N_MAX];   void read() {     cin >> n >> m >> h;     for (int i = 1; i <= n; i++) cin >> main_hour[i];     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       if (main_hour[x] - main_hour[y] == 1 |           (main_hour[x] == 0 & main_hour[y] == h - 1))         neighbours[y].push_back({x, false});       if (main_hour[y] - main_hour[x] == 1 |           (main_hour[y] == 0 & main_hour[x] == h - 1))         neighbours[x].push_back({y, false});     }     for (int i = 1; i <= n; i++) depth[i] = -1;   }   void DFS(int node, int root) {     depth[node] = height[node] = Depth;     component.push(node);     on_stack[node] = true;     Depth++;     for (Edge& son : neighbours[node]) {       if (depth[son.node] == -1) {         DFS(son.node, root);         height[node] = min(height[node], height[son.node]);       } else if (on_stack[son.node])         height[node] = min(height[node], depth[son.node]);     }     if (height[node] == depth[node]) {       int son;       do {         son = component.top();         color[son] = node;         component.pop();         on_stack[son] = false;       } while (son != node);     }   }   int DFS2(int node, int cnt, bool possible_ans) {     cnt++;     visited[node] = true;     for (Edge son : neighbours[node]) {       if (color[node] != color[son.node]) {         possible_ans = false;         continue;       }       if (visited[son.node]) continue;       cnt = DFS2(son.node, cnt, possible_ans);       if (!cnt) possible_ans = false;     }     if (!possible_ans) cnt = 0;     return cnt;   }   void solution() {     for (int i = 1; i <= n; i++)       if (depth[i] == -1) DFS(i, i);     for (int i = 1; i <= n; i++) visited[i] = false;     for (int i = 1; i <= n; i++) {       if (visited[i]) continue;       int cnt = DFS2(i, 0, true);       if (cnt)         if (minim > cnt) {           minim = cnt;           node_ans = i;         }     }   }   void DFS_print(int node) {     cout << node <<    ;     visited[node] = true;     for (Edge son : neighbours[node]) {       if (!visited[son.node]) DFS_print(son.node);     }   }   void print() {     cout << minim <<   n ;     for (int i = 1; i <= n; i++) visited[i] = false;     DFS_print(node_ans);   }   int main() {     read();     solution();     print();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 9;   long long wei[N], p[N], in[N], ans[N], par[N][22], mx[N][22], h[N];   pair<long long, long long> edge[N];   vector<pair<long long, long long> > vec, adj[N];   priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,                  greater<pair<long long, long long> > >       hp[N];   long long FS(long long v) {     if (p[v] < 0) return v;     return p[v] = FS(p[v]);   }   void US(long long u, long long v, long long id) {     long long a = FS(u), b = FS(v);     if (a == b) return;     if (p[a] > p[b]) swap(a, b);     p[a] += p[b];     p[b] = a;     adj[u].push_back({v, id});     adj[v].push_back({u, id});     in[id] = 1;   }   void DFS1(long long u) {     for (pair<long long, long long> v : adj[u])       if (v.first != par[u][0]) {         h[v.first] = h[u] + 1;         par[v.first][0] = u;         mx[v.first][0] = wei[v.second];         for (long long i = 1; i < 22; i++)           par[v.first][i] = par[par[v.first][i - 1]][i - 1];         for (long long i = 1; i < 22; i++)           mx[v.first][i] =               max(mx[v.first][i - 1], mx[par[v.first][i - 1]][i - 1]);         DFS1(v.first);       }   }   pair<long long, long long> LYFT(long long v, long long dis) {     long long maxx = 0;     for (long long i = 21; i >= 0; i--)       if (h[v] - (1 << i) >= dis) maxx = max(maxx, mx[v][i]), v = par[v][i];     return {v, maxx};   }   long long LCA(long long u, long long v) {     if (h[u] > h[v]) swap(u, v);     v = LYFT(v, h[u]).first;     if (u == v) return v;     for (long long i = 21; i >= 0; i--)       if (par[v][i] != par[u][i]) v = par[v][i], u = par[u][i];     return par[u][0];   }   void DFS2(long long u) {     for (pair<long long, long long> v : adj[u])       if (v.first != par[u][0]) {         DFS2(v.first);         if (hp[v.first].size()) ans[v.second] = hp[v.first].top().first - 1;         if (hp[v.first].size() > hp[u].size()) swap(hp[u], hp[v.first]);         while (hp[v.first].size()) {           pair<long long, long long> x = hp[v.first].top();           hp[v.first].pop();           if (x.second < h[u]) hp[u].push(x);         }       }     while (hp[u].size() && hp[u].top().second >= h[u]) hp[u].pop();   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n, m;     cin >> n >> m;     fill(p, p + N, -1);     for (long long i = 0; i < m; i++) {       cin >> edge[i].first >> edge[i].second >> wei[i];       vec.push_back({wei[i], i});     }     sort(vec.begin(), vec.end());     for (long long i = 0; i < m; i++)       US(edge[vec[i].second].first, edge[vec[i].second].second, vec[i].second);     fill(ans, ans + N, -1);     DFS1(1);     for (long long i = 0; i < m; i++)       if (!in[i]) {         long long u = edge[i].first, v = edge[i].second, x = LCA(u, v);         ans[i] = max(LYFT(u, h[x]).second, LYFT(v, h[x]).second) - 1;         hp[u].push({wei[i], h[x]});         hp[v].push({wei[i], h[x]});       }     DFS2(1);     for (long long i = 0; i < m; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double EPS = 1e-9;   int INF = 1 << 30;   long long INFL = 1LL << 60;   int main() {     int n;     cin >> n;     string w;     cin >> w;     int ile = 0;     for (int i = 1; i < n; i += 2) {       if (w[i] ==  a  && w[i - 1] ==  a ) {         w[i] =  b ;         ile++;       }       if (w[i] ==  b  && w[i - 1] ==  b ) {         w[i] =  a ;         ile++;       }     }     cout << ile <<   n  << w;   }