malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int cap = int(1e5) + 1;   vector<int> graph[cap];   vector<int> cnt(cap);   void dfs(int i, int h) {     cnt[h] ^= 1;     for (int j : graph[i]) dfs(j, h + 1);   }   int main() {     int n;     cin >> n;     int p;     for (int i = 2; i <= n; ++i) {       cin >> p;       graph[p].push_back(i);     }     dfs(1, 0);     int ans = 0;     for (int i = 0; i < n; ++i) ans += cnt[i];     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int days;     int index;   };   bool compare(node lhs, node rhs) { return (lhs.days < rhs.days); }   int main() {     int n, k;     int sum = 0;     scanf( %d%d , &n, &k);     node a[n + 1];     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i].days);       a[i].index = i;     }     sort(a + 1, a + n + 1, compare);     int i = 1;     sum = a[i].days;     while (sum <= k) {       i++;       if (i <= n)         sum += (a[i].days);       else         break;     }     printf( %d n , i - 1);     if (i != 1) {       for (int j = 1; j < i; j++) printf( %d  , a[j].index);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<set<int> > g;   vector<int> ans;   vector<bool> used;   void dfs(int v, int p) {     used[v] = true;     ans.push_back(v);     for (set<int>::iterator i = g[v].begin(); i != g[v].end(); i++) {       if (!used[*i] && g[*i].count(p)) dfs(*i, v);     }   }   int main() {     int n;     scanf( %d , &n);     g.resize(n);     used.resize(n, false);     for (int i = 0; i < 2 * n; i++) {       int a, b;       scanf( %d %d , &a, &b);       a--;       b--;       g[a].insert(b);       g[b].insert(a);       if (g[a].size() > 4 || g[b].size() > 4) {         puts( -1 );         return 0;       }     }     ans.push_back(0);     used[0] = true;     int st, p = -1;     for (set<int>::iterator i = g[0].begin(); i != g[0].end(); i++) {       int temp = 0, mp;       for (set<int>::iterator j = g[0].begin(); j != g[0].end(); j++) {         if (g[*i].count(*j)) {           temp++;           mp = *j;         }       }       if (temp == 1 && n > 6 || temp && n < 7) {         st = *i;         p = mp;         break;       }     }     if (p == -1) {       puts( -1 );       return 0;     }     ans.push_back(p);     used[p] = true;     dfs(st, p);     if (ans.size() != n) {       puts( -1 );       return 0;     }     for (int i = 0; i < ans.size(); i++) {       printf( %d  , ans[i] + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double t, n, i, x, mx, mn, f, j, s, r, y, c, m,         k = 0, W, H, x1, y1, w, h, w1, h1, l, u, d, sw, sh, X, Y, X1, X2, R;     cin >> t;     while (t--) {       cin >> W >> H;       cin >> x >> y >> x1 >> y1;       cin >> w >> h;       w1 = abs(x - x1);       h1 = abs(y - y1);       sw = W - w1;       sh = H - h1;       if (sw < w && sh < h)         cout << -1 << endl;       else {         r = W - x1;         l = x;         u = H - y1;         d = y;         if (max(r, l) >= w || max(u, d) >= h)           printf( %0.7lf n , k);         else {           X = max(r, l);           Y = max(u, d);           X = w - X;           Y = h - Y;           if (X > min(r, l))             R = Y;           else if (Y > min(u, d))             R = X;           else             R = min(X, Y);           printf( %0.7lf n , R);         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 7;   const int maxm = 2e1 + 7;   int n, m;   int ar[maxn];   char ch[maxn];   int main() {     int k;     scanf( %d%d , &n, &k);     int d = (n - k) / 2;     for (int i = 0; i < n; i++) {       ch[i] =  0  + (i % (d + 1) == d);     }     printf( %s n , ch);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC diagnostic ignored  -Wunused-result    #pragma GCC diagnostic ignored  -Wunused-function    using namespace std;   namespace {   namespace shik {   template <class T>   void _R(T &x) {     cin >> x;   }   void _R(int &x) { scanf( %d , &x); }   void _R(int64_t &x) { scanf( %  SCNd64, &x); }   void _R(double &x) { scanf( %lf , &x); }   void _R(char &x) { scanf(  %c , &x); }   void _R(char *x) { scanf( %s , x); }   void R() {}   template <class T, class... U>   void R(T &head, U &...tail) {     _R(head);     R(tail...);   }   template <class T>   void _W(const T &x) {     cout << x;   }   void _W(const int &x) { printf( %d , x); }   void _W(const int64_t &x) { printf( %  PRId64, x); }   void _W(const double &x) { printf( %.16f , x); }   void _W(const char &x) { putchar(x); }   void _W(const char *x) { printf( %s , x); }   template <class T>   void _W(const vector<T> &x) {     for (auto i = x.begin(); i != x.end(); _W(*i++))       if (i != x.cbegin()) putchar(   );   }   void W() {}   template <class T, class... U>   void W(const T &head, const U &...tail) {     _W(head);     putchar(sizeof...(tail) ?     :   n );     W(tail...);   }   template <class T, class F = less<T>>   void sort_uniq(vector<T> &v, F f = F()) {     sort(begin(v), end(v), f);     v.resize(unique(begin(v), end(v)) - begin(v));   }   template <class T>   inline T bit(T x, int i) {     return (x >> i) & 1;   }   template <class T>   inline bool chkmax(T &a, const T &b) {     return b > a ? a = b, true : false;   }   template <class T>   inline bool chkmin(T &a, const T &b) {     return b < a ? a = b, true : false;   }   template <class T>   using MaxHeap = priority_queue<T>;   template <class T>   using MinHeap = priority_queue<T, vector<T>, greater<T>>;   const int N = 1e5 + 10;   int n, k;   vector<int> e[N];   void make_tree(int p) {     for (int i : e[p]) {       e[i].erase(find(begin(e[i]), end(e[i]), p));       make_tree(i);     }   }   pair<int, int> go(int p) {     int s = 0, r = 0, a1 = 0, a2 = 0;     for (int i : e[p]) {       auto t = go(i);       s += t.first;       int x = t.second;       if (x >= a1) {         a2 = a1;         a1 = x;       } else if (x >= a2) {         a2 = x;       }     }     if (a1 + a2 + 1 >= k) {       s++;     } else {       r = a1 + 1;     }     return {s, r};   }   int shik(int _k) {     k = _k;     return go(1).first;   }   int ans[N];   void solve(int l, int r, int al, int ar) {     if (r - l <= 1) return;     if (al == ar) {       for (int i = (l); i <= int(r); i++) ans[i] = al;       return;     }     int m = (l + r) / 2;     int am = shik(m);     ans[m] = am;     solve(l, m, al, am);     solve(m, r, am, ar);   }   void main() {     R(n);     for (int i = 0; i < int(n - 1); i++) {       int a, b;       R(a, b);       e[a].push_back(b);       e[b].push_back(a);     }     make_tree(1);     ans[1] = n;     solve(1, n + 1, n, 0);     for (int i = (1); i <= int(n); i++) W(ans[i]);   }   }  // namespace shik   }  // namespace   int main() {     shik::main();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool adj[110][110];   short color[110];   bool ok = true;   int n, m;   void dfs(int node, int ccolor) {     color[node] = ccolor;     for (int i = 0; i < m; i++) {       if (adj[node][i]) {         if (color[i] == 0) {           dfs(i, ccolor * (-1));         } else if (color[i] == ccolor) {           ok = false;         }       }     }   }   int main() {     cin >> n >> m;     int ai[110], bi[110], a, b, i, j;     for (i = 0; i < m; i++) {       cin >> ai[i] >> bi[i];       if (bi[i] < ai[i]) swap(ai[i], bi[i]);     }     int x1, x2, y1, y2;     for (i = 0; i < m; i++) {       for (j = i + 1; j < m; j++) {         if (ai[i] > ai[j] && ai[i] < bi[j] && bi[i] > bi[j])           adj[i][j] = adj[j][i] = 1;         if (ai[j] > ai[i] && ai[j] < bi[i] && bi[j] > bi[i])           adj[i][j] = adj[j][i] = 1;       }     }     for (i = 0; i < m; i++) {       if (color[i] == 0) dfs(i, 1);     }     if (ok) {       for (i = 0; i < m; i++) {         if (color[i] == 1)           cout <<  i ;         else if (color[i] == -1)           cout <<  o ;       }     } else {       cout <<  Impossible  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long int;   using ld = long double;   template <typename Arg1>   void debug_out(const char* name, Arg1&& arg1) {     cerr << name <<   =   << arg1 <<   ]           <<   n ;   }   template <typename Arg1, typename... Args>   void debug_out(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   =   << arg1 <<  , ;     debug_out(comma + 1, args...);   }   const long long mod = 1e9 + 7;   const long long N = 5e3 + 5, M = 2e5 + 5;   long long n;   long long v[N];   long long solve(long long l, long long r) {     if (r < l) return 0;     long long res = r - l + 1;     long long mn = *min_element(v + l, v + r + 1);     for (long long i = (l); i <= (r); ++i) v[i] -= mn;     long long ans = mn;     for (long long i = (l); i <= (r); ++i) {       if (v[i] == 0) {         ans += solve(l, i - 1);         l = i + 1;       }     }     ans += solve(l, r);     res = min(res, ans);     return res;   }   void Solve_main() {     cin >> n;     for (long long i = (1); i <= (n); ++i) cin >> v[i];     cout << solve(1, n) <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     srand(chrono::high_resolution_clock::now().time_since_epoch().count());     long long tc = 1;     for (long long i = 1; i <= tc; i++) {       Solve_main();     }     cerr <<  [time:  << 1.0 * clock() / CLOCKS_PER_SEC <<  s]  ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > v;   vector<long long> q;   int main() {     long long n, d, a, b, xx, x, y, sum = 0;     cin >> n >> d >> a >> b;     for (long long i = 0; i < n; i++) {       cin >> x >> y;       xx = x * a + y * b;       v.push_back(make_pair(xx, i));     }     sort(v.begin(), v.end());     for (long long i = 0; i < n; i++) {       if (v[i].first + sum <= d) {         q.push_back(v[i].second);         sum += v[i].first;       } else         break;     }     n = q.size();     cout << n << endl;     for (long long i = 0; i < n; i++) {       cout << q[i] + 1 <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7;   const long long INFL = 1e18 + 123;   const double PI = atan2(0, -1);   mt19937 tw(960172);   long long rnd(long long x, long long y) {     static uniform_int_distribution<long long> d;     return d(tw) % (y - x + 1) + x;   }   const int MAXN = 1e5 + 5;   vector<int> graph[MAXN], graph2[MAXN];   int res[MAXN];   bool used[MAXN];   int dfs(int v, vector<int>* g, int c) {     used[v] = true;     if (res[v] == 1 - c) {       cout <<  No n ;       exit(0);     }     res[v] = c;     for (int to : g[v]) {       if (!used[to]) {         dfs(to, g, c);       }     }     return 0;   }   int main() {     cerr << fixed << setprecision(15);     cout << fixed << setprecision(15);     int n, m;     scanf( %d%d , &n, &m);     vector<vector<int>> inp;     for (int i = 0; i < n; ++i) {       int l;       scanf( %d , &l);       inp.push_back({});       for (int j = 0; j < l; ++j) {         int num;         scanf( %d , &num);         --num;         inp.back().push_back(num);       }     }     for (int i = 0; i < m; ++i) {       res[i] = 2;     }     for (int i = 0; i < n - 1; ++i) {       bool flag = false;       for (int j = 0; j < min(((int)(inp[i]).size()), ((int)(inp[i + 1]).size()));            ++j) {         if (inp[i][j] != inp[i + 1][j]) {           flag = true;           if (inp[i][j] > inp[i + 1][j]) {             if (res[inp[i][j]] == 1 || res[inp[i + 1][j]] == 0) {               cout <<  No n ;               return 0;             }             res[inp[i][j]] = 0;             res[inp[i + 1][j]] = 1;           } else {             graph[inp[i + 1][j]].push_back(inp[i][j]);             graph2[inp[i][j]].push_back(inp[i + 1][j]);           }           break;         }       }       if (!flag && ((int)(inp[i]).size()) > ((int)(inp[i + 1]).size())) {         cout <<  No n ;         return 0;       }     }     for (int i = 0; i < m; ++i) {       if (res[i] == 0 && !used[i]) {         dfs(i, graph, res[i]);       }       if (res[i] == 1 && !used[i]) {         dfs(i, graph2, res[i]);       }     }     cout <<  Yes n ;     vector<int> ans;     for (int i = 0; i < m; ++i) {       if (res[i] == 0) {         ans.push_back(i);       }     }     cout << ((int)(ans).size()) <<   n ;     for (int num : ans) {       cout << num + 1 <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     for (int row = -n; row <= n; ++row) {       int top = n - abs(row);       for (int i = 0; i < abs(row); i++) {         cout <<     ;       }       for (int i = 0; i < top; i++) {         cout << i <<    ;       }       for (int i = top; i > 0; i--) {         cout << i <<    ;       }       cout << 0 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > adj[100005];   int m, n, a, b, w;   long long D[100005];   int Tr[100005];   void dijk(int x) {     Tr[x] = 0;     D[x] = 0;     set<pair<long long, int> > s;     s.insert({0, x});     while (s.size() > 0) {       long long d = (*s.begin()).first;       int u = (*s.begin()).second;       s.erase(s.begin());       for (int i = 0; i < adj[u].size(); ++i) {         int v = adj[u][i].second;         int w = adj[u][i].first;         if (D[v] > D[u] + w) {           D[v] = D[u] + w;           s.insert({D[v], v});           Tr[v] = u;         }       }     }   }   int main() {     cin >> n >> m;     for (int i = 1; i <= m; ++i) {       cin >> a >> b >> w;       adj[a].push_back({w, b});       adj[b].push_back({w, a});     }     memset(D, 63, sizeof(D));     dijk(1);     if (D[n] > 1e12) {       cout << -1;       return 0;     }     vector<int> p;     int t = n;     while (t > 0) {       p.push_back(t);       t = Tr[t];     }     reverse(p.begin(), p.end());     for (int i = 0; i < p.size(); ++i) cout << p[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void out(int a) { printf( %d n , a); }   inline void out(int a, int b) { printf( %d %d n , a, b); }   inline void outf(double a) { printf( %3.lf n , a); }   inline void outf(double a, double b) { printf( %3.lf %3.lf n , a, b); }   inline void base() {     ios_base::sync_with_stdio(false);     cin.tie(0);   }   int tour(vector<int> ls) {     while (ls.size() != 1) {       vector<int> nx;       for (int i = 0; i < ls.size(); i += 2) {         if (i + 1 == ls.size()) {           nx.push_back(ls[i]);           break;         }         cout <<  ?   << ls[i] <<     << ls[i + 1] << endl;         char c;         cin >> c;         if (c ==  > ) {           nx.push_back(ls[i]);         } else if (c ==  < ) {           nx.push_back(ls[i + 1]);         } else if (c ==  = ) {           nx.push_back(ls[i]);         }       }       ls = nx;     }     return ls[0];   }   int tour1(vector<int> ls) {     while (ls.size() != 1) {       vector<int> nx;       for (int i = 0; i < ls.size(); i += 2) {         if (i + 1 == ls.size()) {           nx.push_back(ls[i]);           break;         }         cout <<  ?   << ls[i] <<     << ls[i + 1] << endl;         char c;         cin >> c;         if (c ==  > ) {           nx.push_back(ls[i + 1]);         } else if (c ==  < ) {           nx.push_back(ls[i]);         } else if (c ==  = ) {           nx.push_back(ls[i]);         }       }       ls = nx;     }     return ls[0];   }   int main() {     base();     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       if (n == 1) {         cout <<  ! 1 1  << endl;         continue;       }       vector<int> lose;       vector<int> win;       for (int i = 1; i <= n; i += 2) {         if (i + 1 <= n) {           cout <<  ?   << i <<     << i + 1 << endl;           char c;           cin >> c;           if (c ==  > ) {             win.push_back(i);             lose.push_back(i + 1);           } else if (c ==  < ) {             win.push_back(i + 1);             lose.push_back(i);           } else {             win.push_back(i);             lose.push_back(i);           }         } else {           win.push_back(i);           lose.push_back(i);         }       }       int mx = tour(win), mn = tour1(lose);       cout <<  !   << mn <<     << mx << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace ::std;   const long long maxn = 5e5 + 500;   long long seg[4 * maxn];   long long dp[maxn];   long long q[maxn];   long long houp[maxn];   long long a[maxn];   map<long long, long long> last;   map<long long, vector<long long> > las;   void bild() { fill(seg, seg + 4 * maxn, -1); }   void update(long long L, long long R, long long node, long long l, long long r,               long long v) {     if (l <= L && R <= r) {       seg[node] = max(seg[node], v);       return;     }     if (r <= L || R <= l) {       return;     }     seg[2 * node] = max(seg[2 * node], seg[node]);     seg[2 * node + 1] = max(seg[2 * node + 1], seg[node]);     long long mid = (L + R) / 2;     update(L, mid, 2 * node, l, r, v);     update(mid, R, 2 * node + 1, l, r, v);   }   long long findd(long long L, long long R, long long node, long long x) {     long long mid = (L + R) / 2;     if (L + 1 == R) {       return seg[node];     }     if (x < mid) {       return max(seg[node], findd(L, mid, 2 * node, x));     } else {       return max(seg[node], findd(mid, R, 2 * node + 1, x));     }   }   int main() {     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     bild();     for (long long i = 0; i < n; i++) {       long long v = a[i];       if (last.count(v) > 0) {         q[i] = findd(0, n, 1, last[v]);         update(0, n, 1, last[v] + 1, i, last[v]);       } else {         q[i] = -1;       }       last[v] = i;     }     for (long long i = 0; i < n; i++) {       long long v = a[i];       las[v].push_back(i);       if (las[v].size() >= 4) {         q[i] = max(q[i], las[v][las[v].size() - 4]);       }     }     dp[0] = 0;     houp[0] = -1;     for (long long i = 1; i < n; i++) {       if (q[i] == -1) {         houp[i] = -1;         dp[i] = dp[i - 1];       } else {         if (q[i] == 0) {           dp[i] = max(dp[i - 1], 1LL);         } else {           dp[i] = max(dp[i - 1], 1 + dp[q[i] - 1]);         }         if (dp[i] == dp[i - 1]) {           houp[i] = -1;         } else {           houp[i] = q[i];         }       }     }     cout << 4 * dp[n - 1] << endl;     vector<long long> stk;     long long p = n - 1;     while (p >= 0) {       if (houp[p] == -1) {         p--;       } else {         stk.push_back(a[p]);         stk.push_back(a[houp[p]]);         stk.push_back(a[p]);         stk.push_back(a[houp[p]]);         p = houp[p] - 1;       }     }     reverse(stk.begin(), stk.end());     for (long long i = 0; i < stk.size(); i++) {       cout << stk[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   int m, n, nword, R[MAXN], len[MAXN];   map<string, int> M;   string s[MAXN];   vector<int> adj[MAXN], adj2[MAXN];   int super[MAXN], nsuper, number[MAXN], low[MAXN], cnt;   int best[MAXN], rep[MAXN];   bool inStack[MAXN];   int st[MAXN], nst;   int f[MAXN];   long long resR, resLen;   void toLower(string& s) {     for (int i = 0; i < s.size(); i++) {       s[i] = tolower(s[i]);     }   }   int countR(string s) {     int ret = 0;     for (int i = 0; i < s.size(); i++) {       ret += s[i] ==  r ;     }     return ret;   }   void add(string& s) {     toLower(s);     if (M[s] == 0) M[s] = ++nword;     int x = M[s];     len[x] = s.length();     R[x] = countR(s);   }   void input() {     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       cin >> s[i];       add(s[i]);     }     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       string tmp;       int u, v;       cin >> tmp;       add(tmp);       u = M[tmp];       cin >> tmp;       add(tmp);       v = M[tmp];       adj[u].push_back(v);     }   }   void tarjan(int u) {     number[u] = ++cnt;     low[u] = number[u];     inStack[u] = true;     st[++nst] = u;     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i];       if (number[v] == 0) {         tarjan(v);         low[u] = min(low[u], low[v]);       } else if (inStack[v])         low[u] = min(low[u], number[v]);     }     if (low[u] == number[u]) {       nsuper++;       best[nsuper] = u;       super[u] = nsuper;       inStack[u] = false;       while (st[nst] != u) {         int v = st[nst--];         super[v] = nsuper;         inStack[v] = false;         if (R[v] < R[best[nsuper]] ||             (R[v] == R[best[nsuper]] && len[v] < len[best[nsuper]]))           best[nsuper] = v;       }       nst--;     }   }   void dfs(int u) {     f[u] = best[u];     for (int i = 0; i < adj2[u].size(); i++) {       int v = adj2[u][i];       if (f[v] == 0) dfs(v);       if (R[f[v]] < R[f[u]] || (R[f[v]] == R[f[u]] && len[f[v]] < len[f[u]]))         f[u] = f[v];     }   }   void solve() {     for (int i = 1; i <= nword; i++) {       if (number[i] == 0) tarjan(i);     }     for (int i = 1; i <= nword; i++) {       for (int j = 0; j < adj[i].size(); j++) {         int v = adj[i][j];         if (super[i] != super[v]) adj2[super[i]].push_back(super[v]);       }     }     for (int i = 1; i <= nword; i++) {       if (f[i] == 0) dfs(i);     }     for (int i = 1; i <= m; i++) {       int id = M[s[i]];       resR += R[f[super[id]]];       resLen += len[f[super[id]]];     }   }   void output() { printf( %I64d %I64d , resR, resLen); }   int main() {     input();     solve();     output();   }
#include <bits/stdc++.h>   using namespace std;   map<int, bool> mp;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       mp[a] = 1;     }     for (int i = 0; i < 1010; i++) {       if (mp[i] && mp[i + 1] && mp[i + 2]) {         cout <<  YES  << endl;         return 0;       }     }     cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   char s[1010];   int a[1010], num[1010], b[30];   int prime[1010], notprime[1010];   priority_queue<pair<int, char> > pq;   set<pair<int, int> > st;   pair<int, int> c[1010];   int ans[1010];   int cnt;   void init() {     for (int i = 2; i <= 1000; i++) {       if (!notprime[i]) prime[cnt++] = i;       for (int j = 0; j < cnt && i * prime[j] <= 1000; j++) {         notprime[i * prime[j]] = 1;         if (i % prime[j] == 0) break;       }     }     for (int i = 0; i <= 1000; i++) a[i] = i, num[i] = 1;   }   int get(int x) { return a[x] == x ? x : a[x] = get(a[x]); }   void merge(int x, int y) {     int t1 = get(x);     int t2 = get(y);     if (t1 != t2) {       a[max(t1, t2)] = min(t1, t2);       num[min(t1, t2)] += num[max(t1, t2)];     }   }   bool cmp(pair<int, int> x, pair<int, int> y) { return x.first > y.first; }   int main() {     init();     scanf( %s , s);     int l = strlen(s);     for (int i = 0; i < l; i++) b[s[i] -  a ]++;     for (int i = 0; i < 30; i++)       if (b[i]) pq.push({b[i], i +  a });     for (int i = 0; i < cnt && prime[i] <= l; i++)       for (int j = 2; j <= l / prime[i]; j++) merge(prime[i], j * prime[i]);     st.insert({1, 1});     for (int i = 0; i < cnt && prime[i] <= l; i++) {       int r = get(prime[i]);       st.insert({num[r], r});     }     int num = 0, j = 0;     for (auto i : st) c[num++] = i;     sort(c, c + num, cmp);     int flag = 0;     while (pq.size() && j < num) {       pair<int, char> t = pq.top();       pq.pop();       if (t.first >= c[j].first)         ans[c[j].second] = t.second -  a ;       else {         flag = 1;         break;       }       if (t.first - c[j].first > 0) pq.push({t.first - c[j].first, t.second});       j++;     }     if (flag)       printf( NO n );     else {       printf( YES n );       for (int i = 1; i <= l; i++) printf( %c , ans[get(i)] +  a );     }     return 0;   }