malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, k;   char s[200];   char p[200];   char ans[200];   bool used[200][30];   bool brute(int pos) {     if (pos == n) {       puts(ans);       exit(0);     }     if (ans[pos] != 0) {       if (pos >= strlen(s) - 1) {         if (p[pos - strlen(s) + 1] ==  0 ) {           bool ok = true;           for (int j = strlen(s) - 1; j >= 0; j--) {             if (ans[pos - j] != s[strlen(s) - 1 - j]) {               ok = false;               break;             }           }           if (ok) return false;         }       }       return brute(pos + 1);     }     memset(used[pos], 0, sizeof used[pos]);     int cnt = k;     bool need_check = false;     if (pos >= strlen(s) - 1) {       need_check = true;       for (int i = strlen(s) - 1; i > 0; i--) {         if (ans[pos - i] != s[strlen(s) - 1 - i]) {           need_check = false;           break;         }       }     }     for (int t = 0; t < k; t++) {       ans[pos] = (char)( a  + t);       if (!need_check) {         if (brute(pos + 1)) return true;       } else {         if (t != s[strlen(s) - 1] -  a ) {           if (brute(pos + 1)) return true;         }       }     }     ans[pos] = 0;     return false;   }   int main() {     scanf( %d %d n , &n, &k);     gets(s);     gets(p);     memset(ans, 0, sizeof ans);     for (int i = 0; i < strlen(p); i++) {       if (p[i] ==  1 ) {         for (int j = 0; j < strlen(s); j++) {           if (ans[i + j] == 0 || ans[i + j] == s[j]) {             ans[i + j] = s[j];           } else {             puts( No solution );             return 0;           }         }       }     }     for (int i = 0; i < strlen(p); i++) {       if (p[i] ==  0 ) {         bool ok = true;         for (int j = 0; j < strlen(s); j++) {           if (ans[i + j] != s[j]) {             ok = false;             break;           }         }         if (ok) {           puts( No solution );           return 0;         }       }     }     for (int i = 0; i < k; i++) {       bool ok = true;       for (int j = 0; j < strlen(s); j++) {         if (s[j] -  a  == i) {           ok = false;           break;         }       }       if (ok) {         for (int j = 0; j < n; j++) {           if (ans[j] == 0) ans[j] = (char)( a  + i);         }         puts(ans);         return 0;       }     }     brute(0);     puts( No solution );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     if (k > n) {       cout <<  -1 ;       return 0;     }     if (n == 1) {       cout <<  a ;       return 0;     }     if (n > 1 && k == 1) {       cout <<  -1 ;       return 0;     }     string str;     char c1 =  a , c2 =  b ;     for (int i = 0; i < n; i++) {       str += c1;       if (i % 2 == 0)         c1 =  b ;       else         c1 =  a ;     }     char ch =  a  + k - 1;     int l = str.size() - 1;     for (int i = 0; i < k - 2; i++) str[l--] = ch--;     cout << str;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, dfsCont, dfs_num[2005], dfs_low[2005], numComp;   vector<vector<int> > lista;   string ans[2005];   vector<int> pila, comp;   map<string, int> names;   bool vis[2005];   void tarjan(int u) {     dfs_low[u] = dfs_num[u] = dfsCont++;     vis[u] = 1;     pila.push_back(u);     for (int i = 0; i < lista[u].size(); i++) {       int v = lista[u][i];       if (dfs_num[v] == -1) tarjan(v);       if (vis[v]) dfs_low[u] = min(dfs_low[u], dfs_low[v]);     }     if (dfs_low[u] == dfs_num[u]) {       while (true) {         int v = pila.back();         comp.push_back(v);         pila.pop_back();         vis[v] = 0;         if (u == v) break;       }       numComp++;     }   }   int main() {     scanf( %d , &n);     lista.assign(n, vector<int>());     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) {         int x;         scanf( %d , &x);         if (x) lista[i].push_back(j);       }     pila.clear();     memset(dfs_low, 0, sizeof dfs_low);     memset(dfs_num, -1, sizeof dfs_num);     memset(vis, 0, sizeof vis);     dfsCont = 0;     numComp = 0;     tarjan(0);     if (numComp == 1 && comp.size() == n)       printf( YES n );     else       printf( NO n );   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m;     cin >> n >> m;     vector<string> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int ans = 1 << 30;     for (int k = 2; k < 100; k++) {       int nn = (n + k - 1) / k * k;       int nm = (m + k - 1) / k * k;       vector<string> b = a;       b.resize(nn,  0 );       for (int i = 0; i < nn; i++) {         b[i].resize(nm,  0 );       }       int cur = 0;       for (int i = 0; i + k <= nn; i += k) {         for (int j = 0; j + k <= nm; j += k) {           int ca = 0;           int cb = 0;           for (int w = 0; w < k; w++) {             for (int h = 0; h < k; h++) {               ca += (b[i + w][j + h] ==  0  ? 0 : 1);               cb += (b[i + w][j + h] ==  1  ? 0 : 1);             }           };           cur += min(ca, cb);         }       };       ans = min(ans, cur);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }
#include<bits/stdc++.h>   #define int long long   using namespace std;   int32_t main()   {   ios::sync_with_stdio(0);   cin.tie(0);   int t;   cin>>t;   while(t--)       {int n,k;        cin>>n>>k;        int ok=1;        int poss=0;        for(int i=0;i<n-1;i++)           {ok=ok*2;            if(ok>=k){poss=1;break;}           }       if(ok<k){cout<< -1 n ;continue;}       vector<int> v;       k--;       for(int i=0;i<n-1;i++)           {//Should I take i+1            int poss=0;            int z=1;            for(int j=0;j<n-i-2;j++)               {z=z*2;                if(z>k){break;}               }           if(z>k)               {v.push_back(i+1);               }           else               {k-=z;               }           }       v.push_back(n);       int visited[n];       memset(visited,0,sizeof(visited));       for(auto x:v)           {               visited[x-1]=1;               cout<<x<<   ;               for(int i=x-1;i>0;i--)                   {                       if(visited[i-1]==1){break;}                       cout<<i<<   ;                   }           }       cout<<  n ;       }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[100005];   int ans = 0;   int csize[100005];   int dfs(int u, int fa) {     csize[u] = 1;     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i];       if (v == fa) continue;       dfs(v, u);       csize[u] += csize[v];       if (csize[v] % 2 == 0) ans++;     }   }   int main() {     int n;     while (cin >> n) {       ans = 0;       for (int i = 0; i <= n; i++) {         g[i].clear();       }       for (int i = 0; i < n - 1; i++) {         int x, y;         cin >> x >> y;         g[x].push_back(y);         g[y].push_back(x);       }       if (n % 2)         cout <<  -1 n ;       else {         dfs(1, 0);         cout << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s[105][105];   int main() {     int i, j, x, y;     scanf( %d , &n);     for (i = 3; i <= 102; i++) {       m = (i * (i - 1) * (i - 2)) / 6;       if (m > n) break;     }     i--;     memset(s, 0, sizeof(s));     for (y = 1; y <= i; y++)       for (x = 1; x <= i; x++)         if (y != x) s[y][x] = 1;     m = i * (i - 1) * (i - 2) / 6;     while (n != m) {       for (j = i; j >= 2; j--)         if (m + j * (j - 1) / 2 <= n) break;       m += j * (j - 1) / 2;       i++;       for (x = 1; x <= j; x++) s[x][i] = s[i][x] = 1;     }     printf( %d n , i);     for (y = 1; y <= i; y++) {       for (x = 1; x <= i; x++) printf( %d , s[y][x]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 11;   const long long MOD = 1e18;   long long a[N], b[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long x, y, l, r;     cin >> x >> y >> l >> r;     vector<long long> v;     long long k = 1, kk = 1;     for (int i = 0; i <= 60; i++) {       a[i] = k;       b[i] = kk;       if (k != -1 && r / k >= x && k * x <= r)         k *= x;       else         k = -1;       if (kk != -1 && r / kk >= y && kk * y <= r)         kk *= y;       else         kk = -1;     }     for (int i = 0; i <= 60; i++)       for (int j = 0; j <= 60; j++)         if (a[i] != -1 && b[j] != -1) {           long long dd = a[i] + b[j];           if (dd >= l && dd <= r) v.push_back(dd);         }     v.push_back(l - 1);     v.push_back(r + 1);     sort(v.begin(), v.end());     long long ans = 0;     for (int i = 1; i < v.size(); i++) ans = max(ans, v[i] - v[i - 1] - 1);     cout << ans << endl;   }
#include <bits/stdc++.h>   int main(void) {     int b_cost, money, b_number;     scanf( %d %d %d , &b_cost, &money, &b_number);     int total_cost;     int loan = 0;     total_cost = b_cost;     for (int i = 2; i <= b_number; i++) {       total_cost += i * b_cost;     }     if (money < total_cost) {       loan = total_cost - money;     }     printf( %d , loan);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   const long long mod = 1e9 + 7;   struct node {     int s, e, next;   } edge[maxn];   int head[maxn], len;   void add(int s, int e) {     edge[len].e = e;     edge[len].next = head[s];     head[s] = len++;   }   void init() {     memset(head, -1, sizeof(head));     len = 0;   }   double dp[maxn];   void dfs(int x, int fa) {     dp[x] = 0;     int ans = 0;     for (int i = head[x]; i != -1; i = edge[i].next) {       int y = edge[i].e;       if (y == fa) continue;       dfs(y, x);       dp[x] += dp[y];       ans++;     }     if (ans == 0)       dp[x] = 0;     else       dp[x] = dp[x] / ans + 1;   }   int main() {     int n;     while (scanf( %d , &n) != EOF) {       init();       int x, y;       for (int i = 1; i < n; i++) {         scanf( %d%d , &x, &y);         add(x, y);         add(y, x);       }       dfs(1, -1);       printf( %.8f n , dp[1]);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, d, h, i;     cin >> n >> d >> h;     if (h == 1) {       if (d == 1 && n == 2) {         cout << 1 <<     << 2 <<   n ;       } else if (d == 2) {         for (i = 1; i < n; i++) cout << 1 <<     << i + 1 <<   n ;       } else {         cout <<  -1 n ;       }     } else if (d > 2 * h) {       cout <<  -1 n ;     } else {       for (i = 1; i <= h; i++) cout << i <<     << i + 1 <<   n ;       for (i = h + 1; i <= d; i++) {         if (i == h + 1)           cout << 1 <<     << i + 1 <<   n ;         else           cout << i <<     << i + 1 <<   n ;       }       for (i = d + 1; i < n; i++) cout << 2 <<     << i + 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200100], sum[200100], qs[200100];   bool bad(pair<long long, long long> &a, pair<long long, long long> &b,            pair<long long, long long> second) {     return (a.second - second.second) * (b.first - a.first) >            (a.second - b.second) * (second.first - a.first);   }   long long at(pair<long long, long long> a, long long x) {     return a.first * x + a.second;   }   int back = 0;   pair<long long, long long> l[200100];   void add(long long first, long long second) {     if (back >= 2 and bad(l[back - 2], l[back - 1], {first, second})) back--;     l[back++] = {first, second};   }   long long query(long long x, int L = 0, int R = back - 1) {     if (L + 1 == R) return max(at(l[L], x), at(l[R], x));     if (L == R) return at(l[L], x);     int mid = (L + R) / 2;     if (at(l[mid], x) < at(l[mid - 1], x)) return query(x, L, mid - 1);     if (at(l[mid], x) < at(l[mid + 1], x)) return query(x, mid + 1, R);     return at(l[mid], x);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++)       scanf( %lld , &a[i]), qs[i] = a[i] + qs[i - 1],                             sum[i] = a[i] * i + sum[i - 1];     long long ans = 0;     add(0, 0);     for (int i = 1; i <= n; i++) {       ans = max(ans, sum[i] + query(qs[i]));       add(-i, -sum[i] + i * qs[i]);     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int m, n, nums[1010][35], P[1010] = {0}, nCr[1010][1010], basis[1010][35],                             sz = 0, pivots[1010];   char buf[1010];   int main() {     int mask = 0x1F, shift = 5;     scanf( %d%d , &m, &n);     for (int i = 0; i < n; i++) {       scanf( %s , buf);       for (int j = 0; j < m; j++) {         nums[i][j >> shift] |= (buf[j] ==  1 ) << (j & mask);       }     }     nCr[0][0] = 1;     for (int i = 1; i <= m; i++) {       nCr[i][0] = nCr[i][i] = 1;       for (int j = 1; j < i; j++) {         nCr[i][j] = (nCr[i - 1][j - 1] + nCr[i - 1][j]) % 1000000007;       }     }     P[0] = 1;     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= i; j++) {         P[i] = (P[i] + 1LL * nCr[i - 1][j - 1] * P[i - j]) % 1000000007;       }     }     for (int i = 0; i < m >> shift; i++) nums[n][i] = 0xFFFFFFFF;     nums[n][m >> shift] = (1 << (m & mask)) - 1;     for (int i = 0; i < m; i++) pivots[i] = -1;     for (int i = 0; i < m; i++) {       int idx = 0;       while (idx <= n && ((nums[idx][i >> shift] >> (i & mask)) & 1) == 0) {         idx++;       }       if (idx == n + 1) continue;       for (int i = 0; i < 35; i++) {         basis[sz][i] = nums[idx][i];       }       for (int j = idx; j <= n; j++) {         if ((nums[j][i >> shift] >> (i & mask)) & 1) {           for (int i = 0; i < 35; i++) {             nums[j][i] ^= basis[sz][i];           }         }       }       pivots[i] = sz;       sz++;     }     for (int i = 0; i < m; i++) {       if (pivots[i] != -1) {         int u = pivots[i];         for (int j = 0; j < sz; j++) {           if (j != u && ((basis[j][i >> shift] >> (i & mask)) & 1))             for (int z = 0; z < 35; z++) {               basis[j][z] ^= basis[u][z];             }         }       }     }     for (int i = 0; i < m; i++) {       if (pivots[i] == -1) {         int u = -1, v = -1;         for (int j = 0; j < sz; j++) {           if ((basis[j][i >> shift] >> (i & mask)) & 1) {             v = u;             u = j;           }         }         if (v != -1) {           for (int z = 0; z < 35; z++) {             basis[sz][z] = basis[u][z] & basis[v][z];           }           for (int j = i + 1; j < m; j++) {             if (pivots[j] != -1 && ((basis[sz][j >> shift] >> (j & mask)) & 1)) {               int u = pivots[j];               for (int k = 0; k < 35; k++) basis[sz][k] ^= basis[u][k];             }           }           for (int j = 0; j < sz; j++) {             if (basis[j][i >> shift] >> (i & mask) & 1) {               for (int k = 0; k < 35; k++) {                 basis[j][k] ^= basis[sz][k];               }             }           }           pivots[i] = sz;           sz++;         }       }     }     int ans = 1, num_ones = 0;     for (int i = 0; i < sz; i++) {       int no = 0;       for (int j = 0; j < m; j++) {         no += (basis[i][j >> shift] >> (j & mask)) & 1;       }       num_ones += no;       ans = 1LL * ans * P[no] % 1000000007;     }     ans = 1LL * ans * P[m - num_ones] % 1000000007;     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000007;   const long long INFLL = 1000000000000000000LL;   const int MAXN = 200009;   int m, x;   vector<int> weights;   stack<int> order;   void print() {     if (order.empty()) return;     int x = order.top();     order.pop();     print();     cout << x <<    ;   }   void solve(int bal, int step) {     if (step == m) {       cout <<  YES  << endl;       print();       exit(0);     }     if (abs(bal) >= 10) return;     for (int w : weights) {       if (step % 2 == 0) {         if (bal + w > 0 && (order.empty() || w != order.top())) {           order.push(w);           solve(bal + w, step + 1);           order.pop();         }       } else {         if (bal - w < 0 && (order.empty() || w != order.top())) {           order.push(w);           solve(bal - w, step + 1);           order.pop();         }       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     for (int i = 1; i <= 10; i++) {       scanf( %1d , &x);       if (x == 1) weights.push_back(i);     }     scanf( %d , &m);     solve(0, 0);     cout <<  NO  << endl;   }
#include <bits/stdc++.h>   int N, head[51], next[99], from[99], to[99], len[99], E, root, M, q[51], fa[51],       count_e[99], f[51][99][51], vi[51][99];   void BFS() {     int H = 0, T = 1, u;     q[1] = root;     while (H < T)       for (int e = head[u = q[++H]]; e; e = next[e])         if (to[e] != fa[u]) fa[q[++T] = to[e]] = u;   }   void F(int n, int e) {     if (vi[n][e]) return;     vi[n][e] = 1;     f[n][e][0] = 1 << 30;     if (!next[head[to[e]]]) {       for (int i = 1; i < n; i++) {         F(n - i, ((e - 1) ^ 1) + 1);         f[n][e][i] = f[n - i][((e - 1) ^ 1) + 1][n - i] + len[e];       }       f[n][e][n] = 0;     } else {       for (int g = head[to[e]]; g; g = next[g])         if (to[g] != from[e]) F(n, g);       for (int i = 1; i <= n; i++) {         int l = 0, r = (1 << 30) - 1;         while (l < r) {           int m = l + r + 1 >> 1;           int count = 0;           for (int g = head[to[e]]; g; g = next[g])             if (to[g] != from[e])               count += std::upper_bound(f[n][g], f[n][g] + n + 1, m - len[g],                                         [](int x, int y) { return x > y; }) -                        f[n][g] - 1;           if (count >= i)             l = m;           else             r = m - 1;         }         f[n][e][i] = l;       }     }   }   int main() {     scanf( %d , &N);     for (int i = 1, u, v, l; i < N; i++) {       scanf( %d%d%d , &u, &v, &l);       next[++E] = head[u], from[E] = u, to[E] = v, len[E] = l, head[u] = E;       next[++E] = head[v], from[E] = v, to[E] = u, len[E] = l, head[v] = E;     }     scanf( %d%d , &root, &M);     BFS();     for (int i = 1, x; i <= M; i++) {       scanf( %d , &x);       while (fa[x] != root) x = fa[x];       for (int e = head[root]; e; e = next[e])         if (to[e] == x) count_e[e]++;     }     int O = 1 << 30;     for (int e = head[root]; e; e = next[e]) {       F(M, e);       O = std::min(O, f[M][e][count_e[e]] + len[e]);     }     printf( %d n , O);     return 0;   }
#include <bits/stdc++.h>   const int mxn = 100000 + 10;   using namespace std;   string s;   string soln;   int main() {     cin >> s;     int n = s.size();     for (int i = 0; i < n; i++)       if (s[i] ==  . )         printf( 0 );       else {         if (s[i + 1] ==  - )           printf( 2 );         else           printf( 1 );         i++;       }     puts(  );   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   const double eps = 1e-9;   const double pi = acos(-1.0);   int main() {     long long n;     cin >> n;     unsigned long long p = 1;     unsigned long long sq = (unsigned long long)(sqrt(n + 0.0) + eps + 1);     bool was = false;     while (p - 1 <= n) {       unsigned long long lf = 1;       unsigned long long rg = min(sq, n / p) + 5;       while (lf < rg - 1) {         unsigned long long mm = (lf + rg) >> 1;         unsigned long long m = 2 * mm - 1;         if ((p - 1) * m + m * (m - 1) / 2 <= n) {           lf = mm;         } else {           rg = mm;         }       }       lf = 2 * lf - 1;       if ((p - 1) * lf + lf * (lf - 1) / 2 == n) {         cout << p * lf << endl;         was = true;       }       p = p * 2;     }     if (!was) puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t1, n, zero, one, cnt, cnt1, i, j;     string s;     cin >> t1;     while (t1--) {       cin >> n;       cnt = 0, zero = 0, one = 0;       for (i = 0; i < n; i++) {         cin >> s;         for (j = 0; j < s.length(); j++) {           if (s[j] ==  0 )             zero++;           else             one++;         }         if (s.length() % 2 != 0) cnt++;       }       cnt1 = 0;       if (zero % 2 != 0) cnt1++;       if (one % 2 != 0) cnt1++;       if (cnt >= cnt1)         cout << n << endl;       else         cout << n - 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long a[n], b[n];     for (long long i = 0; i < n; i++) {       cin >> a[i] >> b[i];     }     for (long long i = 0; i < n; i++) {       if (a[i] != b[i]) {         cout <<  rated ;         return 0;       }     }     for (long long i = 0; i < n - 1; i++) {       if (a[i + 1] > a[i]) {         cout <<  unrated ;         return 0;       }     }     cout <<  maybe ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s1, s2;     cin >> s1 >> s2;     int flag = 0;     if (n % 2 != 0) flag = 1;     int mid;     if (flag)       mid = (n + 1) / 2;     else       mid = n / 2;     int cnt = 0;     for (int i = 0; i < n / 2; i++) {       int l = i, r = n - i - 1;       int a[30];       fill(a, a + 30, 0);       a[s1[l] -  a ]++;       a[s1[r] -  a ]++;       a[s2[l] -  a ]++;       a[s2[r] -  a ]++;       int k = 0;       int b[4];       int counts = 0;       for (int j = 0; j < 30; j++) {         if (a[j]) k++;         if (a[j]) {           b[counts++] = a[j];         }       }       sort(b, b + k);       if (k == 4) {         cnt += 2;         continue;       }       if (k == 3) {         if (s1[l] == s1[r])           cnt += 2;         else           cnt++;       }       if (k == 2) {         if (b[1] == 3) {           cnt++;         }       }     }     if (flag)       if (s1[mid - 1] != s2[mid - 1]) cnt++;     cout << cnt;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     int a[205];     cin >> n >> k;     for (int i = 0; i < 2 * n + 1; i++) {       cin >> a[i];     }     for (int i = 2 * n - 1; k != 0; i--) {       if (a[i] > a[i + 1] + 1 && a[i] > a[i - 1] + 1) {         a[i]--;         k--;       }     }     for (int i = 0; i < 2 * n + 1; i++) {       if (i != 0) cout <<    ;       cout << a[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   int isprime[1010];   int mp[256];   int main() {     isprime[0] = isprime[1] = 1;     for (int i = 2; i <= 1000; i++)       if (!isprime[i])         for (int j = i * 2; j <= 1000; j += i) isprime[j] = 1;     char s[1100], str[1010];     scanf( %s , s);     int l = strlen(s);     for (int i = 0; i < l; i++) {       mp[s[i]]++;       str[i] = 0;     }     str[l] = 0;     int flag = 0;     for (int i = 1; i <= l; i++) {       if (isprime[i]) continue;       int tmp = 0;       for (int j = 1; j <= l; j++) {         if (j % i == 0 && str[j]) {           tmp = str[j];           break;         }       }       if (tmp) {         int k = 1;         while (k * i <= l) {           if (str[k * i] == 0) {             mp[tmp]--;             if (mp[tmp] < 0) {               flag = 1;               break;             }           }           str[k * i] = tmp;           k++;         }       } else {         int p = max_element(mp, mp + 256) - mp;         int k = 1;         while (k * i <= l) {           if (str[k * i] == 0) {             mp[p]--;             if (mp[p] < 0) {               flag = 1;               break;             }           }           str[k * i] = p;           k++;         }       }       if (flag) break;     }     if (flag)       printf( NO n );     else {       printf( YES n );       for (int i = 1; i <= l; i++) {         if (!str[i]) {           int j =  a ;           while (mp[j] == 0) {             j++;           }           str[i] = j;           mp[j]--;         }       }       for (int i = 1; i <= l; i++) printf( %c , str[i]);       printf(  n );     }     return 0;   }