malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAN = 110;   const int MAM = 60;   int dp[MAN][MAM][2];   int INF = -100000000;   int main() {     string str;     int m;     while (cin >> str >> m) {       int len = str.size();       memset(dp, 0, sizeof(dp));       for (int i = 0; i <= len; ++i) {         for (int j = 0; j <= m; ++j) {           dp[i][j][0] = INF;           dp[i][j][1] = INF;         }       }       dp[0][0][0] = 0;       dp[0][0][1] = 0;       for (int i = 1; i <= len; ++i) {         for (int j = 0; j <= m; ++j) {           if (str[i - 1] ==  F ) {             dp[i][j][0] = max(dp[i - 1][j][0] != INF ? dp[i - 1][j][0] + 1 : INF,                               j > 0 ? dp[i - 1][j - 1][1] : INF);             dp[i][j][1] = max(dp[i - 1][j][1] != INF ? dp[i - 1][j][1] - 1 : INF,                               j > 0 ? dp[i - 1][j - 1][0] : INF);           } else {             dp[i][j][0] =                 max(dp[i - 1][j][1], (j > 0 && dp[i - 1][j - 1][0] != INF)                                          ? dp[i - 1][j - 1][0] + 1                                          : INF);             dp[i][j][1] =                 max(dp[i - 1][j][0], (j > 0 && dp[i - 1][j - 1][1] != INF)                                          ? dp[i - 1][j - 1][1] - 1                                          : INF);           }         }       }       int ans = INF;       for (int i = m; i >= 0; i -= 2) {         ans = max(ans, max(dp[len][i][0], dp[len][i][1]));       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double EPS = 1e-6;   const int INF = (int)(INT_MAX - 100);   const long long mod = (int)(1e+9 + 7);   const int N = (int)(1e5);   int main() {     int n, s;     cin >> n >> s;     char d;     int p, k;     map<int, int, greater<int> > C;     map<int, int> V;     for (int i = 0; i < n; i++) {       cin >> d >> p >> k;       if (d ==  B )         C[p] += k;       else         V[p] += k;     }     k = 0;     vector<pair<int, int> > ans;     for (pair<int, int> x : V) {       if (k == s) break;       k++;       ans.push_back({x.first, x.second});     }     reverse(ans.begin(), ans.end());     for (pair<int, int> x : ans)       cout <<  S   << x.first <<     << x.second <<   n ;     k = 0;     for (pair<int, int> x : C) {       if (k == s) break;       k++;       cout <<  B   << x.first <<     << x.second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<string> V;     for (int i = 0; i < 4; ++i) {       string s;       cin >> s;       V.push_back(s);     }     bool pos = false;     for (int r = 0; r < 3; ++r) {       for (int c = 0; c < 3; ++c) {         int dots = 0, nums = 0;         dots += (V[r][c] ==  . );         nums += (V[r][c] !=  . );         dots += (V[r][c + 1] ==  . );         nums += (V[r][c + 1] !=  . );         dots += (V[r + 1][c] ==  . );         nums += (V[r + 1][c] !=  . );         dots += (V[r + 1][c + 1] ==  . );         nums += (V[r + 1][c + 1] !=  . );         if (dots >= 3 || nums >= 3) pos = true;       }     }     cout << (pos ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> a[1010];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d%d , &a[i].second, &a[i].first);       if (a[i].first < a[i].second) swap(a[i].first, a[i].second);     }     sort(a, a + n);     vector<int> ans;     int last = INT_MIN;     for (int i = 0; i < n; ++i)       if (a[i].second > last) {         ans.push_back(a[i].first);         last = a[i].first;       }     printf( %d n , (int)ans.size());     for (int c : ans) printf( %d  , c);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   long long cd, w, a, b, kq = 0, mod = 1e9 + 7, fact[1000001], sf[1000001],                          p[1000001];   void inp() { cin >> cd >> w >> a >> b; }   long long bigmod(long long hat, long long base) {     if (hat == 0) return 1;     long long k = bigmod(hat / 2, base);     if (hat % 2 == 1) return k * k % mod * base % mod;     return k * k % mod;   }   void create() {     p[0] = fact[0] = sf[0] = 1;     for (long long i = 1; i <= 1000000; i++) {       fact[i] = fact[i - 1] * i % mod;       sf[i] = bigmod(mod - 2, fact[i]);       p[i] = p[i - 1] * w % mod;     }   }   long long C(long long k, long long n) {     if (k > n) return 0;     return fact[n] * sf[k] % mod * sf[n - k] % mod;   }   long long A(long long k, long long n) {     if (k > n) return 0;     return C(k, n) * fact[k] % mod;   }   long long cayley(long long k, long long n) {     if (n == k) return 1;     return k * bigmod(n - k - 1, n) % mod;   }   long long get(long long node) {     return A(node, cd - 2) * cayley(node + 2, cd) % mod * p[cd - node - 2] % mod *            C(node, w - 1) % mod;   }   void do_it() {     create();     for (long long i = 0; i <= cd - 2; i++) kq += get(i), kq %= mod;     cout << kq;   }   int main() {     inp();     do_it();   }
#include <bits/stdc++.h>   const int N = 1e3 + 10;   using namespace std;   int a[N], b[N], c[N];   char str1[N], str2[N], str3[N];   int main() {     int tc;     cin >> tc;     while (tc--) {       long long n, k, sum{0}, suma{0}, sumb{0};       cin >> n >> k;       for (int i = 0; i < n; ++i) {         cin >> a[i];         suma += a[i];       }       for (int i = 0; i < n; ++i) {         cin >> b[i];         sumb += b[i];       }       if (k > 0) {         for (int i = 0; i < n; ++i) {           for (int j = i; j < n - 1; ++j) {             if (a[i] >= a[j + 1]) swap(a[i], a[j + 1]);             if (b[i] <= b[j + 1]) swap(b[i], b[j + 1]);           }         }         for (int i = 0; i < k; ++i) {           if (a[i] < b[i]) swap(a[i], b[i]);         }         for (int i = 0; i < n; ++i) {           sum += a[i];         }         cout << sum <<   n ;       } else         cout << suma <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[3], b[3];   int main() {     int n, m;     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       int c;       cin >> c;       a[c % 2]++;     }     for (int j = 1; j <= m; ++j) {       int c;       cin >> c;       b[c % 2]++;     }     cout << min(a[1], b[0]) + min(b[1], a[0]) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n1, n2, k1, k2;     cin >> n1 >> n2 >> k1 >> k2;     if (n1 > n2) {       cout <<  First  << endl;       return 0;     }     if (n2 > n1) {       cout <<  Second  << endl;       return 0;     }     if (k1 < k2) {       cout <<  Second  << endl;       return 0;     }     if (k2 < k1) {       cout <<  Second  << endl;       return 0;     }     if (n1 == n2 && k1 == k2) {       cout <<  Second  << endl;       return 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005, maxl = 200005, maxsg = 60;   int n, f, SG, cnt, maxx;   int p[maxl], c[maxl], sg[maxl], A[maxn], B[maxn];   bitset<maxl> ok, have[maxsg];   void sieve(int n) {     c[1] = 1;     for (int i = 2; i <= n; i++) {       if (c[i] == 0) p[++cnt] = i, ok[i] = 1;       for (int j = 1; j <= cnt; j++) {         if (i * p[j] > n) break;         c[i * p[j]] = 1;         if (c[i] == 0) ok[i * p[j]] = 1;         if (i % p[j] == 0) break;       }     }   }   int main() {     scanf( %d%d , &n, &f);     for (int i = 1; i <= n; i++) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       A[i] = y - x - 1, B[i] = z - y - 1;       maxx = max(maxx, max(A[i], B[i]));     }     sieve(maxx), ok[f] = 0, have[0] = ok;     for (int i = 1; i <= maxx; i++) {       while (have[sg[i]][i]) sg[i]++;       have[sg[i]] |= (ok << i);     }     for (int i = 1; i <= n; i++) SG ^= sg[A[i]] ^ sg[B[i]];     if (SG == 0)       puts( Bob nAlice );     else       puts( Alice nBob );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void logf(istream_iterator<string> it) {}   template <typename T, typename... Args>   void logf(istream_iterator<string> it, T a, Args... args) {     cout << *it <<  =  << a <<    ;     logf(++it, args...);   }   const double PI = acos(-1);   void solve() {     string s;     cin >> s;     ;     reverse(s.begin(), s.end());     int ans = 0;     int car = 0;     function<void(int)> inc = [&](int idx) {       if (idx == s.size())         s +=  1 ;       else {         if (s[idx] ==  1 ) {           s[idx] =  0 ;           inc(idx + 1);         } else           s[idx] =  1 ;       }     };     for (size_t i = 0; i + 1 < s.size(); i++) {       if (s[i] ==  1 ) {         inc(i);         ans++;       }       if (i + 1 < s.size()) ans++;     }     cout << ans << endl;   }   int main() {     cin.tie(nullptr);     std::ios::sync_with_stdio(false);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int n, q;   int m;   int lastans;   int a[1000][700];   int b[100100];   int sz[1000];   short int cnt[1000][100100];   void remake() {     int pos = 0;     for (int i = 0; i <= m; i++) {       sz[i] = 0;       for (int j = 0; j < 700; a[i][j] = 0, j++) {         if (a[i][j] == -1 || a[i][j] == 0) continue;         cnt[i][a[i][j]]--;         b[pos] = a[i][j];         pos++;       }     }     for (int i = 0; i < n; i++) {       a[i / 333][i % 333] = b[i];       cnt[i / 333][b[i]]++;       sz[i / 333]++;     }   }   int find(int it, int pos) {     int i = 0;     pos--;     while (pos || a[it][i] == -1) {       if (a[it][i] == -1) pos++;       pos--;       i++;     }     int res = a[it][i];     a[it][i] = -1;     return res;   }   void update(int it, int pos, int k) {     pos--;     int t = sz[it] - pos;     int i = 0;     while (pos || a[it][i] == -1) {       if (a[it][i] == -1) pos++;       pos--;       i++;     }     int buf = a[it][i];     a[it][i] = k;     while (t) {       i++;       if (buf != -1) t--;       swap(a[it][i], buf);     }   }   int solve(int r, int k) {     int res = 0;     int pos = 0;     int it = 0;     while (it <= m && sz[it] <= r) {       r -= sz[it];       res += cnt[it][k];       it++;     }     int i = 0;     while (pos < r) {       if (a[it][i] == -1 || a[it][i] == 0) {         i++;         continue;       }       res += (a[it][i] == k);       i++;       pos++;     }     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i / 333][i % 333];       cnt[i / 333][a[i / 333][i % 333]]++;       sz[i / 333]++;     }     m = (n - 1) / 333 + 1;     cin >> q;     while (q--) {       int type, l, r, k;       cin >> type >> l >> r;       l = (l + lastans - 1) % n + 1;       r = (r + lastans - 1) % n + 1;       if (l > r) swap(l, r);       if (type == 1) {         int it = 0;         int pos = 0;         while (pos < l) {           pos += sz[it];           it++;         }         if (pos >= l) {           it--;           pos -= sz[it];         }         int p1 = pos;         int w = it;         it = 0;         pos = 0;         while (pos < r) {           pos += sz[it];           it++;         }         if (pos >= r) {           it--;           pos -= sz[it];         }         k = find(it, r - pos);         cnt[w][k]++;         cnt[it][k]--;         sz[w]++;         sz[it]--;         update(w, l - p1, k);         if (sz[w] > 2 * 333) remake();       } else {         cin >> k;         k = (k + lastans - 1) % n + 1;         lastans = solve(r, k) - solve(l - 1, k);         printf( %d n , lastans);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-11;   const int INFINITE = 0x3f3f3f3f;   template <class T>   inline void checkmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   inline void checkmax(T &a, T b) {     if (b > a) a = b;   }   template <class T>   inline T sqr(T x) {     return x * x;   }   template <class T>   inline T lowbit(T n) {     return (n ^ (n - 1)) & n;   }   template <class T>   inline int countbit(T n) {     return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));   }   typedef vector<int> VI;   typedef vector<VI> VII;   typedef vector<string> VS;   int dx[4] = {1, 0, 0, -1};   int dy[4] = {0, 1, -1, 0};   bool isright(int x1, int y1, int x2, int y2, int x3, int y3) {     int l12 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);     int l23 = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3);     int l31 = (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1);     if (l12 == 0 || l23 == 0 || l31 == 0) return false;     return (l12 + l23 == l31 || l12 + l31 == l23 || l23 + l31 == l12);   }   int main() {     ios::sync_with_stdio(false);     int p[3][2];     cin >> p[0][0] >> p[0][1] >> p[1][0] >> p[1][1] >> p[2][0] >> p[2][1];     if (isright(p[0][0], p[0][1], p[1][0], p[1][1], p[2][0], p[2][1])) {       cout <<  RIGHT n ;       return 0;     }     for (int n = (int)(0); n < (int)(3); n++)       for (int i = (int)(0); i < (int)(4); i++) {         p[n][0] += dx[i], p[n][1] += dy[i];         if (isright(p[0][0], p[0][1], p[1][0], p[1][1], p[2][0], p[2][1])) {           cout <<  ALMOST n ;           return 0;         }         p[n][0] -= dx[i], p[n][1] -= dy[i];       }     cout <<  NEITHER n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll mod = 998244353;   int n, m, t[1 << 19];   struct segTree {     struct {       ll kk, bk, kb, bb;     } a[1 << 20];     void upd(int p, int l, int r) {       int mid = l + r >> 1, v = t[mid] == 1 ? 9 - t[mid + 1] : 0;       a[p].kk = a[p * 2].kb * a[p * 2 + 1].bk % mod;       if (l < mid && mid + 1 < r)         (a[p].kk += a[p * 2].kk * a[p * 2 + 1].kk % mod * v) %= mod;       a[p].bk = a[p * 2].bb * a[p * 2 + 1].bk % mod;       if (mid + 1 < r)         (a[p].bk += a[p * 2].bk * a[p * 2 + 1].kk % mod * v) %= mod;       a[p].kb = a[p * 2].kb * a[p * 2 + 1].bb % mod;       if (l < mid) (a[p].kb += a[p * 2].kk * a[p * 2 + 1].kb % mod * v) %= mod;       a[p].bb = a[p * 2].bb * a[p * 2 + 1].bb % mod;       (a[p].bb += a[p * 2].bk * a[p * 2 + 1].kb % mod * v) %= mod;     }     void build(int p = 1, int l = 1, int r = n) {       if (l == r) {         a[p] = {1, 1, 1, t[l] + 1};         return;       }       int mid = l + r >> 1;       build(p * 2, l, mid);       build(p * 2 + 1, mid + 1, r);       upd(p, l, r);     }     void ins(int x, int p = 1, int l = 1, int r = n) {       if (l == r) {         a[p] = {1, 1, 1, t[l] + 1};         return;       }       int mid = l + r >> 1;       if (x <= mid)         ins(x, p * 2, l, mid);       else         ins(x, p * 2 + 1, mid + 1, r);       upd(p, l, r);     }   } tr;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       char c;       scanf(  %c , &c);       t[i] = c -  0 ;     }     tr.build();     while (m--) {       int p, v;       scanf( %d%d , &p, &v);       t[p] = v;       tr.ins(p);       printf( %lld n , tr.a[1].bb);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int a[1111];   int b[1111];   int c[1111];   int vis[1111];   int pos[5];   int cntp;   int main() {     scanf( %d , &n);     bool flag = 0;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       vis[a[i]]++;     }     for (int i = 1; i <= n; ++i) {       scanf( %d , &b[i]);       if (a[i] != b[i]) {         pos[++cntp] = i;       }     }     int dvis;     for (int i = 1; i <= n; ++i)       if (!vis[i]) {         dvis = i;         break;       }     if (cntp == 1) {       a[pos[1]] = dvis;     } else {       if (b[pos[1]] == dvis && vis[a[pos[1]]] > 1)         a[pos[1]] = dvis;       else         a[pos[2]] = dvis;     }     for (int i = 1; i <= n; ++i) printf( %d  , a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, s1;     int m;     cin >> s;     cin >> m;     int l, r, k, i, j, d, ind;     while (m--) {       cin >> l >> r >> k;       --l;       --r;       d = r - l + 1;       s1 = s.substr(l, d);       for (i = l; i <= r; ++i) {         ind = (i - l + k) % d + l;         s[ind] = s1[i - l];       }     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 100005;   const long long p = 1e9 + 7;   long long a[maxn], n, x, sum;   long long st[maxn], top;   vector<long long> v;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline long long qpow(long long x, long long y) {     long long res = 1;     while (y) {       if (y & 1) res = (res * x % p) % p;       x = (x % p * x % p) % p;       y >>= 1;     }     return res % p;   }   signed main() {     n = read();     x = read();     for (long long i = 1; i <= n; i++) a[i] = read(), sum += a[i];     for (long long i = 1; i <= n; i++) st[++top] = sum - a[i];     sort(st + 1, st + n + 1);     reverse(st + 1, st + n + 1);     while (1) {       long long res = st[top], cnt = 0;       while (top > 0 && res == st[top]) cnt++, top--;       if (cnt % x) {         printf( %d , qpow(x, min(sum, res)));         return 0;       } else {         cnt /= x;         for (long long i = 1; i <= cnt; i++) st[++top] = res + 1;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct NODE {     char name[102];     int to;   };   struct TRIE {     vector<NODE> fold, file;   };   TRIE trie[5][10010];   int cnt[5];   int ans_file, ans_fold;   int track(int index, int tar, int &layer) {     int i, j, count = 0;     if (trie[index][tar].fold.size() < 1) {       return trie[index][tar].file.size();     } else {       for (i = 0, j = trie[index][tar].fold.size(); i < j; ++i) {         count += track(index, trie[index][tar].fold[i].to, layer);       }       layer += trie[index][tar].fold.size();       return (count + trie[index][tar].file.size());     }   }   int main() {     int i, j, index, now;     char in[102], *p;     NODE tmp;     memset(trie, 0, sizeof(trie));     memset(cnt, 0, sizeof(cnt));     while (scanf( %s , in) != EOF) {       p = strtok(in,  :  );       if (p[0] ==  C )         index = 0;       else if (p[0] ==  D )         index = 1;       else if (p[0] ==  E )         index = 2;       else if (p[0] ==  F )         index = 3;       else if (p[0] ==  G )         index = 4;       now = 0;       p = strtok(NULL,    );       while (p != NULL) {         for (i = 0, j = strlen(p); i < j; ++i)           if (p[i] ==  . ) break;         if (i == j) {           for (i = 0, j = trie[index][now].fold.size(); i < j; ++i)             if (!strcmp(trie[index][now].fold[i].name, p)) break;           if (i == j) {             strcpy(tmp.name, p);             tmp.to = ++cnt[index];             trie[index][now].fold.push_back(tmp);             now = cnt[index];           } else {             now = trie[index][now].fold[i].to;           }         } else {           strcpy(tmp.name, p);           trie[index][now].file.push_back(tmp);         }         p = strtok(NULL,    );       }     }     for (i = 0, ans_file = 0, ans_fold = 0; i < 5; ++i) {       for (j = 0, now = trie[i][0].fold.size(); j < now; ++j) {         index = 0;         ans_file = max(ans_file, track(i, trie[i][0].fold[j].to, index));         ans_fold = max(ans_fold, index);       }     }     printf( %d %d n , ans_fold, ans_file);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T[2 * 10010];   vector<int> G[6010];   vector<int> S[6010];   int P[6010];   int C[6010];   map<int, int> M;   bool V[6010];   int mx;   int n = 6010;   void modify(int p, int value) {     for (T[p += n] = value; p > 1; p >>= 1) T[p >> 1] = max(T[p], T[p ^ 1]);   }   int query(int l, int r) {     int res = 0;     for (l += n, r += n; l < r; l >>= 1, r >>= 1) {       if (l & 1) res = max(res, T[l++]);       if (r & 1) res = max(res, T[--r]);     }     return res;   }   void dfs(int u) {     V[u] = true;     int val = 1 + query(0, P[u]);     S[P[u]].push_back(val);     modify(P[u], val);     mx = max(mx, val);     for (int i = 0; i < G[u].size(); i++) {       int v = G[u][i];       if (!V[v]) {         dfs(v);       }     }     S[P[u]].pop_back();     if (!S[P[u]].empty()) {       modify(P[u], S[P[u]].back());     } else {       modify(P[u], 0);     }   }   int main() {     ios::sync_with_stdio(false);     int N;     cin >> N;     for (int i = 1; i <= N; i++) {       cin >> P[i];       C[i] = P[i];     }     for (int i = 0; i < N - 1; i++) {       int u, v;       cin >> u >> v;       G[u].push_back(v);       G[v].push_back(u);     }     sort(C + 1, C + N + 1);     int count = 1;     M[C[1]] = 1;     for (int i = 2; i <= N; i++) {       if (C[i] != C[i - 1]) {         count++;         M[C[i]] = count;       }     }     for (int i = 1; i <= N; i++) {       P[i] = M[P[i]];     }     for (int i = 1; i <= N; i++) {       dfs(i);       memset(V, false, sizeof V);     }     cout << mx <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[200001], n, par;   vector<int> adj[200001];   vector<pair<int, int> > v;   void count(int h, int p) {     cnt[h]++;     for (auto it : adj[h])       if (it ^ p) {         count(it, h);         cnt[h] += cnt[it];       }   }   int ct(int h, int p) {     for (auto it : adj[h])       if (it ^ p) {         if (cnt[it] > n / 2) return ct(it, h);       }     par = p;     return h;   }   vector<pair<int, pair<int, int> > > res;   void dfs(int h, int p) {     for (auto it : adj[h])       if (it ^ p) {         dfs(it, h);       }     v.push_back({h, p});   }   void f(int h, int p) {     v.clear();     dfs(h, p);     v.pop_back();     int t = h;     for (auto it : v) {       res.push_back({p, {t, it.first}});       res.push_back({it.first, {it.second, h}});       t = it.first;     }     res.push_back({p, {t, h}});   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       adj[x].push_back(y);       adj[y].push_back(x);     }     count(1, 0);     int cen = ct(1, 0), cen2 = 0;     for (auto it : adj[cen])       if (par != it && 2 * cnt[it] == n) cen2 = it;     for (auto it : adj[cen])       if (it != cen2) f(it, cen);     for (auto it : adj[cen2])       if (it != cen) f(it, cen2);     printf( %d n , res.size());     for (auto it : res)       printf( %d %d %d n , it.first, it.second.first, it.second.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool f[10];   char s[100005];   int main() {     int n, i, j;     scanf( %d , &n);     scanf( %s , s);     for (i = 0; i < n; i++) {       if (s[i] ==  L ) {         for (j = 0; j < 10; j++)           if (!f[j]) break;         f[j] = 1;       } else if (s[i] ==  R ) {         for (j = 9; j >= 0; j--)           if (!f[j]) break;         f[j] = 1;       } else {         f[s[i] -  0 ] = 0;       }     }     for (i = 0; i < 10; i++) printf( %d , f[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> pr;   bool isp[1001];   void p() {     memset(isp, true, sizeof isp);     isp[0] = isp[1] = false;     for (int i = 2; i < 1001; ++i) {       if (!isp[i]) continue;       pr.push_back(i);       for (int j = 2 * i; j < 1001; j += i) isp[j] = false;     }   }   int main() {     p();     string s;     cin >> s;     int n = s.length();     bool ans = 0;     set<int> st;     for (int i = 0; i < pr.size(); ++i) {       if (pr[i] > n / 2) break;       for (int j = 1; pr[i] * j <= n; ++j) st.insert(pr[i] * j);     }     int cnt[26], mx = 0, ch = -1;     memset(cnt, 0, sizeof cnt);     for (int i = 0; i < n; ++i) {       cnt[s[i] -  a ]++;       if (mx < cnt[s[i] -  a ]) {         mx = cnt[s[i] -  a ];         ch = s[i];       }     }     if (mx >= st.size()) {       cout <<  YES  << endl;       string ans = s;       for (int i = 0; i < n; ++i) ans[i] =    ;       for (set<int>::iterator it = st.begin(); it != st.end(); ++it)         ans[*it - 1] = ch;       cnt[ch -  a ] -= st.size();       int idx = 0;       for (int i = 0; i < 26; ++i)         for (int j = 0; j < cnt[i]; ++j) {           while (ans[idx] !=    ) ++idx;           ans[idx] = i +  a ;         }       cout << ans << endl;     } else       cout <<  NO  << endl;     return 0;   }