malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, v[1010];   long double p[1010][1010], a[1010], d[1010];   int work() {     int k;     long double x = 1e100L;     for (int i = 1; i <= n; i++)       if (!v[i] && (d[i] + a[i]) / (1 - a[i]) <= x)         x = (d[i] + a[i]) / (1 - a[i]), k = i;     v[k] = 1, d[k] = (d[k] + a[k]) / (1 - a[k]);     if (k == 1) return 1;     for (int i = 1; i <= n; i++)       if (!v[i]) d[i] += a[i] * p[i][k] * (d[k] + 1), a[i] *= 1 - p[i][k];     return 0;   }   int main() {     cin >> n;     for (int i = 1, x; i <= n; i++) {       for (int j = 1; j <= n; j++) cin >> x, p[i][j] = 0.01L * x;       a[i] = 1;     }     a[n] = 0;     for (int i = 1; i <= n; i++)       if (work()) {         cout << fixed << setprecision(15) << d[1];         return 0;       }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int c, d, x, y, a, b;     cin >> a >> b >> x >> y >> c >> d;     if (c == 0 and d == 0) {       if ((a == x and b == y) or (a == -x and b == -y) or (a == y and b == -x) or           (a == -y and b == x))         cout <<  YES  << endl;       else         cout <<  NO  << endl;       return 0;     }     bool possible = false;     long long int X = x, Y = y;     if ((c * (x - a) + d * (y - b)) % (c * c + d * d) == 0 and         (d * (x - a) - c * (y - b)) % (c * c + d * d) == 0)       possible = true;     x = -Y, y = X;     if ((c * (x - a) + d * (y - b)) % (c * c + d * d) == 0 and         (d * (x - a) - c * (y - b)) % (c * c + d * d) == 0)       possible = true;     x = -X, y = -Y;     if ((c * (x - a) + d * (y - b)) % (c * c + d * d) == 0 and         (d * (x - a) - c * (y - b)) % (c * c + d * d) == 0)       possible = true;     x = Y, y = -X;     if ((c * (x - a) + d * (y - b)) % (c * c + d * d) == 0 and         (d * (x - a) - c * (y - b)) % (c * c + d * d) == 0)       possible = true;     if (possible)       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   int chkmax(T& a, T b) {     if (b > a) {       a = b;       return 1;     }     return 0;   }   template <class T>   int chkmin(T& a, T b) {     if (b < a) {       a = b;       return 1;     }     return 0;   }   template <class iterator>   void output(iterator begin, iterator end, ostream& out = cerr) {     while (begin != end) {       out << (*begin) <<    ;       begin++;     }     out << endl;   }   template <class T>   void output(T x, ostream& out = cerr) {     output(x.begin(), x.end(), out);   }   void fast_io() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   const int INF = 1e9;   const int N = 26;   const int A = 5e4 + 10;   vector<int> value;   int p[N][A * N];   signed main() {     fast_io();     int n;     cin >> n;     for (int i = 0; i < 2 * n; ++i) {       int x;       cin >> x;       value.push_back(x);     }     sort(value.begin(), value.end());     int sum = 0;     for (int i = 2; i < 2 * n; ++i) {       sum += value[i];     }     for (int i = 0; i < N; ++i) {       for (int j = 0; j < A * N; ++j) {         p[i][j] = -1;       }     }     p[0][0] = -2;     for (int i = 2; i < value.size(); ++i) {       int cur = value[i];       for (int j = n - 1; j > 0; --j) {         for (int x = cur; x < A * N; ++x) {           if (p[j - 1][x - cur] != -1 && p[j][x] == -1) {             p[j][x] = i;           }         }       }     }     int best = INF;     for (int i = 0; i < N * A; ++i) {       if (abs(i - (sum - i)) < abs(best - (sum - best)) && p[n - 1][i] != -1) {         best = i;       }     }     vector<int> type(2 * n);     type[1] = 1;     for (int i = n - 1; i > 0; --i) {       type[p[i][best]] = 1;       best -= value[p[i][best]];     }     vector<vector<int> > ans(2);     for (int i = 0; i < 2 * n; ++i) {       ans[type[i]].push_back(value[i]);     }     sort(ans[0].begin(), ans[0].end());     sort(ans[1].rbegin(), ans[1].rend());     for (auto v : ans) {       for (auto x : v) {         cout << x <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     int sum = accumulate(a.begin(), a.end(), 0);     vector<vector<int>> dp(n + 1, vector<int>(2, -1));     function<int(int, int)> solve = [&](int idx, int cur) {       if (idx == n) return 0;       if (dp[idx][cur] != -1) return dp[idx][cur];       int res = 0;       if (cur == 0)         res = max(a[idx] + solve(idx + 1, !cur), solve(idx + 1, cur));       else         res = min(solve(idx + 1, !cur), a[idx] + solve(idx + 1, cur));       return dp[idx][cur] = res;     };     int ans = solve(0, 0);     cout << sum - ans <<     << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int nmax = 3e5 + 42;   int n, m;   struct edge {     int u, v, c;   };   edge inp[nmax];   edge make_edge(int u, int v, int c) {     edge x;     x.u = u;     x.v = v;     x.c = c;     return x;   }   bool cmp(edge a, edge b) { return a.c < b.c; }   int ans[nmax], new_values[nmax];   int main() {     cin >> n >> m;     int a, b, c;     for (int i = 1; i <= m; i++) {       scanf( %i%i%i , &a, &b, &c);       inp[i] = make_edge(a, b, c);     }     sort(inp + 1, inp + m + 1, cmp);     for (int i = 1; i <= m; i++) {       int j = i + 1;       while (j <= m && inp[i].c == inp[j].c) j++;       for (int k = i; k < j; k++) {         new_values[inp[k].v] = max(new_values[inp[k].v], ans[inp[k].u] + 1);       }       for (int k = i; k < j; k++) {         ans[inp[k].v] = new_values[inp[k].v];       }       i = j - 1;     }     int outp = 0;     for (int i = 1; i <= n; i++) outp = max(outp, ans[i]);     cout << outp << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1 << 28;   int x[24 + 2], y[24 + 2];   int dist[24 + 2][24 + 2];   int dp[(1 << 24) + 2];   int nxt[(1 << 24) + 2];   int n;   int sqr_dis(int a, int b) {     return (x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]);   }   int solve(int mask) {     if (!mask) return 0;     int &ret = dp[mask];     if (ret != -1) return ret;     int i, j, k;     ret = inf;     for (i = 0; i < n; i++)       if (mask & (1 << i)) {         for (j = 0; j < n; j++)           if (mask & (1 << j)) {             k = dist[0][i + 1] + dist[i + 1][j + 1] + dist[j + 1][0] +                 solve((mask & ~(1 << i)) & ~(1 << j));             if (k < ret) {               ret = k;               nxt[mask] = (1 << i) | (1 << j);             }           }         break;       }     return ret;   }   int main() {     int i, j, k;     scanf( %d %d %d , &x[0], &y[0], &n);     for (i = 1; i <= n; i++) scanf( %d %d , &x[i], &y[i]);     for (i = 0; i <= n; i++)       for (j = 0; j <= n; j++) dist[i][j] = dist[j][i] = sqr_dis(i, j);     k = 1 << n;     for (i = 0; i < k; i++) dp[i] = -1;     printf( %d n , solve(k - 1));     printf( 0 );     k--;     while (k) {       for (i = 0; i < n; i++)         if (nxt[k] & (1 << i)) printf(  %d , i + 1);       printf(  0 );       k ^= nxt[k];     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, arr[1000], dp[1000][10];   int solve(int i, int flag) {     if (i >= n) return 0;     if (dp[i][flag] != -1) return dp[i][flag];     if (arr[i] == 0)       dp[i][flag] = 1 + solve(i + 1, 0);     else if (arr[i] == 1) {       if (flag == 0 || flag == 1) {         dp[i][flag] = min(solve(i + 1, 2), 1 + solve(i + 1, 0));       } else         dp[i][flag] = 1 + solve(i + 1, 0);     } else if (arr[i] == 2) {       if (flag == 0 || flag == 2) {         dp[i][flag] = min(1 + solve(i + 1, 0), solve(i + 1, 1));       } else         dp[i][flag] = 1 + solve(i + 1, 0);     } else {       if (flag == 0) {         dp[i][flag] =             min(solve(i + 1, 2), min(1 + solve(i + 1, 0), solve(i + 1, 1)));       } else if (flag == 1) {         dp[i][flag] = min(solve(i + 1, 2), 1 + solve(i + 1, 0));       } else {         dp[i][flag] = min(solve(i + 1, 1), 1 + solve(i + 1, 0));       }     }     return dp[i][flag];   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> arr[i];     memset(dp, -1, sizeof(dp));     cout << solve(0, 0) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void hike() {     int64_t n;     cin >> n;     string s, t;     cin >> s >> t;     vector<int64_t> f;     for (int64_t i = 0; i < n; ++i) {       if (s[i] != t[i]) {         f.push_back(i);       }     }     if (f.size() != 2) {       cout <<  No n ;       return;     }     char x1 = s[f[0]], y1 = t[f[0]];     char x2 = s[f[1]], y2 = t[f[1]];     s[f[0]] = y2;     t[f[1]] = x1;     if (s == t) {       cout <<  Yes n ;       return;     }     s[f[0]] = x1;     t[f[1]] = y2;     s[f[1]] = y1;     t[f[0]] = x2;     if (s == t) {       cout <<  Yes n ;       return;     }     cout <<  No n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int64_t t = 1;     cin >> t;     while (t--) hike();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, i;     cin >> t;     for (i = 0; i < t; i++) {       string s;       cin >> s;       int j = 0, k, l = s.length(), sum = 0;       while (j < l) {         if (s[j] ==  1 ) {           k = j;           j++;           while (s[j] ==  0 ) j++;           if (j - k > 1 && s[j] ==  1 ) sum = sum + j - k - 1;         } else           j++;       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 100;   long long int v[N];   inline void outv(vector<long long int> v) {     for (long long int i = 0; i < v.size(); i++) {       cout << v[i] <<    ;     }     cout <<   n ;   }   inline long long int pow(long long int x, long long int n) {     long long int ans = 1;     while (n > 0) {       if (n & 1) ans *= x;       x *= x;       n >>= 1;     }     return ans;   }   int solve() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     string n;     cin >> n;     int even = 0;     int s = 0;     int z = 0;     for (auto c : n) {       if ((c) % 2 == 0) even++;       s += c -  0 ;       if (c ==  0 ) z++;     }     if (s % 3 == 0 && even > 1 && z > 0) return cout <<  red  <<   n , 0;     ;     return cout <<  cyan  <<   n , 0;     ;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     int t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, k;     scanf( %d %d , &n, &k);     switch (k) {       case 1:         printf( -1 n );         break;       case 2:         if (n < 5) {           printf( -1 n );           break;         }         printf( %d n , n - 1);         for (int i = 1; i < n; i++) printf( %d %d n , i, i + 1);         break;       case 3:         if (n < 4) {           printf( -1 n );           break;         }         printf( %d n1 2 n2 3 n , n - 1);         for (int i = 4; i <= n; i++) printf( 3 %d n , i);         break;       default:         printf( -1 n );         break;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const int INF = 1000 * 1000 * 1000 + 7;   const long long LINF = INF * (long long)INF;   const int MAX = 1000 * 100 + 47;   long long A[MAX];   long long P[MAX];   long long Q[MAX];   long long R[MAX];   int main() {     int n;     long long p, q, r;     cin >> n >> p >> q >> r;     for (int i = (0); i < (n); i++) cin >> A[i];     for (int i = (0); i < (n); i++) {       P[i] = p * A[i];       if (i) P[i] = max(P[i], P[i - 1]);       Q[i] = P[i] + q * A[i];       if (i) Q[i] = max(Q[i], Q[i - 1]);       R[i] = Q[i] + r * A[i];       if (i) R[i] = max(R[i], R[i - 1]);     }     cout << R[n - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool ma[101][101];   int m, n;   bool a[101][101];   int steluta(int i, int j) {     int t = 1;     while (j + t <= m && j - t >= 1 && i + t <= n && i - t >= 1 &&            ma[i][j + t] == 1 && ma[i][j - t] == 1 && ma[i - t][j] == 1 &&            ma[i + t][j] == 1) {       a[i][j + t] = 1;       a[i][j - t] = 1;       a[i - t][j] = 1;       a[i + t][j] = 1;       t++;     }     t--;     if (t) a[i][j] = 1;     return t;   }   int main() {     int i, j, ramas = 0, c = 0;     char ch;     cin >> n >> m;     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         cin >> ch;         if (ch ==  * ) {           ma[i][j] = 1;         }       }     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         if (ma[i][j] == 1) {           int val = steluta(i, j);           if (val) {             for (int w = val; w <= val; w++) {               c++;             }           }         }       }     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         if (a[i][j] == 0 && ma[i][j] == 1) {           ramas++;         }       }     }     if (ramas > 0) {       cout <<  -1 ;     } else {       cout << c <<   n ;       for (i = 1; i <= n; i++) {         for (j = 1; j <= m; j++) {           if (ma[i][j] == 1) {             int val = steluta(i, j);             if (val) {               for (int w = val; w <= val; w++) {                 cout << i <<     << j <<     << w <<   n ;               }             }           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dist(double a, double b, double c, double d) {     return sqrt((a - c) * (a - c) + (b - d) * (b - d));   }   int main() {     double x, y, r, a, b, c, d;     cin >> x >> y >> r >> a >> b >> c;     d = dist(x, y, a, b);     if (d - r - c > 0)       printf( %.9lf n , (d - r - c) / 2);     else {       if (d >= abs(r - c) && d <= r + c)         printf( 0.000000000000 n );       else {         if (r > c)           printf( %.9lf n , (r - (d + c)) / 2);         else           printf( %.9lf n , (c - (d + r)) / 2);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T sqr(const T &a) {     return a * a;   }   int x, k, timer, n[3], t[3], y[3], head[3], tail[3];   pair<int, int> z[3][100000];   int main() {     scanf( %d%d%d%d%d%d%d , &k, &n[0], &n[1], &n[2], &t[0], &t[1], &t[2]);     while (1) {       timer++;       if (timer >= t[0] + t[1] + t[2]) {         for (int i = 0; i < (int)3; i++)           if (z[i][tail[i]].first == timer)             y[i] -= z[i][tail[i]].second, tail[i]++;         x = min(n[2] - y[2], min(n[1] - y[1], n[0] - y[0]));         if (x) {           k -= x;           y[2] += x, y[1] += x, y[0] += x;           z[0][head[0]++] = make_pair(timer + t[0], x);           z[1][head[1]++] = make_pair(timer + t[1], x);           z[2][head[2]++] = make_pair(timer + t[2], x);         }         if (k <= 0) {           printf( %d n , timer);           return 0;         }       }     }   }
#include <bits/stdc++.h>   int main(void) {     char z[201], *p;     const int H[] = {0, 1, 2, 3, 4, 2, 6, 7, 5, 6};     int s = 999, n = 2, Q[2][8] = {};     while (n--)       for (gets(p = z); *p; ++Q[n][H[*p++ -  0 ]])         ;     while (s && 8 ^ ++n)       if (Q[1][n]) s = std::min(s, Q[0][n] / Q[1][n]);     printf( %d , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 55;   const int MAXM = 105;   const int inf = 0x3f3f3f3fLL;   struct NODE {     long long a, b;     int c, id;   };   struct ANS {     int prei, prej, prek;     long long val;     ANS() {}     ANS(int _i, int _j, int _k, long long _val)         : prei(_i), prej(_j), prek(_k), val(_val) {}   };   NODE a[MAXN];   long long d[MAXN][MAXN][MAXM];   ANS pre[MAXN][MAXN][MAXM];   bool cmp(NODE a, NODE b) { return a.c < b.c; }   void update(int i, int j, int k, int x, int y, int z, long long val) {     if (j == y) {       j = y;     }     if (d[i][j][k] == -1 || d[i][j][k] < d[x][y][z] + val) {       d[i][j][k] = d[x][y][z] + val;       pre[i][j][k] = ANS(x, y, z, val);     }   }   void printans(int i, int j, int k) {     if (i == 0) return;     printans(i - 1, pre[i][j][k].prej, pre[i][j][k].prek);     printf( %d %I64d n , a[j].id, pre[i][j][k].val);   }   void solved(int cas) {     int n, m;     long long K;     scanf( %d %d %I64d , &m, &n, &K);     for (int i = 1; i <= n; i++) {       scanf( %I64d %I64d %d , &a[i].a, &a[i].b, &a[i].c);       a[i].id = i;     }     sort(a + 1, a + n + 1, cmp);     memset(d, -1, sizeof(d));     a[0].a = a[0].b = 0;     for (int i = 1; i <= n; i++)       for (long long j = a[i].a; j <= a[i].b; j++) {         d[1][i][j - a[i].a] = j;         pre[1][i][j - a[i].a] = ANS(0, -1, -1, j);       }     for (int i = 1; i < m; i++) {       for (int j = i; j <= n; j++) {         for (int k = 0; k <= a[j].b - a[j].a; k++) {           if (d[i][j][k] == -1) continue;           long long lastnum = a[j].a + k;           for (int l = j + 1; l <= n; l++) {             if (a[l].c == a[j].c) continue;             long long temp = lastnum + K;             if (temp >= a[l].a && temp <= a[l].b)               update(i + 1, l, temp - a[l].a, i, j, k, temp);             temp = lastnum * K;             if (temp >= a[l].a && temp <= a[l].b)               update(i + 1, l, temp - a[l].a, i, j, k, temp);           }         }       }     }     long long ans = -1;     int ansi, ansj;     for (int i = m; i <= n; i++)       for (int j = 0; j <= 100; j++) {         if (d[m][i][j] > ans) {           ans = d[m][i][j];           ansi = i;           ansj = j;         }       }     if (ans == -1)       printf( NO n );     else {       printf( YES n );       printans(m, ansi, ansj);     }   }   int main() {     int nT = 1;     for (int i = 1; i <= nT; i++) solved(i);   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = acos(-1.0L);   signed main() {     long long n;     cin >> n;     long double x[n], y[n];     for (long long i = (0); i < (n); ++i) cin >> x[i] >> y[i];     long long ans = 0;     for (long long i = (0); i < (n); ++i) {       vector<long double> v;       for (long long j = (0); j < (n); ++j)         if (j != i) {           v.push_back(atan2(y[j] - y[i], x[j] - x[i]));         }       sort(v.begin(), v.end());       long long f[n - 1], s[n - 1];       long long k = 0;       for (long long j = (0); j < (n - 1); ++j) {         while (k < n - 1 && v[k] < v[j] + pi) ++k;         f[j] = k;         s[j] = (j ? s[j - 1] : 0) + f[j];       }       for (long long j = (0); j < (n - 1); ++j) {         ans += (s[f[j] - 1] - s[j]) - (f[j]) * (f[j] - j - 1);       }     }     cout << ans * (n - 4) / 2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 5;   long long n, k, sum;   long long a[maxn];   long long goal[maxn];   long long max(long long x, long long y) { return x > y ? x : y; }   long long cntmx = -9e18, cntmn = 9e18;   void solve3() {     long long m = k;     for (register int i = n; i >= 1; --i) {       if (m >= (n - i + 1) * (a[i] - a[i - 1])) {         m -= (n - i + 1) * (a[i] - a[i - 1]);       } else {         cntmn = a[i] - m / (n - i + 1);         break;       }     }     if (cntmn == 9e18) cntmn = a[1] - m / n;     m = k;     for (register int i = 1; i <= n; ++i) {       if (m >= i * (a[i + 1] - a[i])) {         m -= i * (a[i + 1] - a[i]);       } else {         cntmx = a[i] + m / i;         break;       }     }     if (cntmx == -9e18) cntmx = a[n] + m;     if (cntmn - cntmx <= 0) {       if (sum % n == 0)         printf( 0 n );       else         printf( 1 n );     } else       printf( %lld n , max(0LL, cntmn - cntmx));   }   int main() {     scanf( %lld%lld , &n, &k);     for (register int i = 1; i <= n; ++i) scanf( %lld , &a[i]), sum += a[i];     sort(a + 1, a + n + 1);     solve3();     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     char mi, ma;     int max = 0, min = INT_MAX;     pair<int, char> p[4];     for (int i = 0; i < 4; ++i) {       cin >> s;       p[i].first = s.length() - 2;       p[i].second = s[0];     }     sort(p, p + 4);     int flag1 = 0, flag2 = 0;     for (int j = 1; j < 4; ++j) {       if (2 * (p[0].first) <= p[j].first) flag1 += 1;     }     for (int j = 0; j < 3; ++j) {       if (p[3].first >= 2 * (p[j].first)) flag2 += 1;     }     if (flag1 == 3 && flag2 != 3)       cout << p[0].second <<   n ;     else if (flag2 == 3 && flag1 != 3)       cout << p[3].second <<   n ;     else       cout <<  C n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j;     long long int x, y;     cin >> n >> x >> y;     y -= n;     if (y < 0)       cout << -1 << endl;     else {       x -= (n - 1);       x -= (1 + y) * (1 + y);       if (x > 0)         cout << -1 << endl;       else {         cout << (1 + y) << endl;         for (int i = 0; i < n - 1; i++) cout << 1 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, ji[300], k, qi, mz[400010];   char s[400010], tp[400010];   int main() {     scanf( %d%s , &n, s + 1);     for (int i = 1; i <= n; i++) {       ji[s[i]]++;     }     for (int i = 0; i < 300; i++)       if (ji[i] & 1) k++;     qi = k;     if (!qi) {       for (k = 1;; k++)         if (n % k == 0) break;       n /= k;       printf( %d n , k);       if (n & 1) {         for (int i = 0, tt = 0; i < 300; i++) {           while (ji[i]) {             mz[++tt] = i;             ji[i]--;             if (tt == k) goto qaz;           }         }       qaz:;         n >>= 1;         for (int i = 1, p = 0; i <= k; i++) {           for (int j = 1; j <= n; j++) {             while (!ji[p]) p++;             ji[p] -= 2;             tp[j] = tp[n * 2 + 2 - j] = p;           }           tp[n + 1] = mz[i];           printf( %s  , tp + 1);         }         return 0;       }       n >>= 1;       for (int i = 1, p = 0; i <= k; i++) {         for (int j = 1; j <= n; j++) {           while (!ji[p]) p++;           ji[p] -= 2;           tp[j] = tp[n * 2 + 1 - j] = p;         }         printf( %s  , tp + 1);       }       return 0;     }     for (;; k++)       if (n % k == 0 && (n / k) & 1) break;     printf( %d n , k);     n /= k;     int tt = 0;     for (int i = 0; i < 300; i++)       if (ji[i] & 1) {         mz[++tt] = i;         ji[i]--;       }     if (tt == k) goto qazz;     for (int i = 0; i < 300; i++) {       while (ji[i]) {         mz[++tt] = i;         ji[i]--;         if (tt == k) goto qazz;       }     }   qazz:;     n >>= 1;     for (int i = 1, p = 0; i <= k; i++) {       for (int j = 1; j <= n; j++) {         while (!ji[p]) p++;         ji[p] -= 2;         tp[j] = tp[n * 2 + 2 - j] = p;       }       tp[n + 1] = mz[i];       printf( %s  , tp + 1);     }     return 0;   }