malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 5;   int n, k;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> k;     int odd = 0, even = 0, ans = 0;     for (int i = 0; i < n; i++) {       int num;       cin >> num;       if (num % 2)         odd++;       else         even++;     }     for (int i = 0; i < k; i++) {       int num;       cin >> num;       if (num % 2 && even) {         ans++;         even--;       }       if (num % 2 == 0 && odd) {         ans++;         odd--;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long v, n, arr[50005], ans, o = 9999, minans;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> arr[i];       v = max(arr[i], v);       o = min(arr[i], o);       ans += arr[i];     }     minans = ans;     for (int x = 1; x <= n; x++) {       for (int i = 1; i <= v; i++) {         if (arr[x] % i == 0) {           long long nowc = arr[x] / i - arr[x] + o * (i - 1);           minans = min(minans, ans + nowc);         }       }     }     cout << minans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T, N, val[53][53], rk[53][53], fr[103];   vector<int> peo[53];   int pos[53];   void go(bool flg) {     queue<int> q;     for (int i = 1; i <= N; ++i) {       peo[i].clear();       for (int j = 1; j <= N; ++j) peo[i].push_back(j);       sort(peo[i].begin(), peo[i].end(),            [&](int p, int q) { return (val[i][p] < val[i][q]) ^ flg; });       q.push(i);       pos[i] = fr[i] = fr[i + N] = 0;     }     for (int i = 1; i <= N; ++i) {       vector<int> tmp;       for (int j = 1; j <= N; ++j) tmp.push_back(j);       sort(tmp.begin(), tmp.end(),            [&](int p, int q) { return (val[p][i] > val[q][i]) ^ flg; });       for (int j = 0; j < tmp.size(); ++j) rk[i][tmp[j]] = j + 1;     }     while (!q.empty()) {       int t = q.front();       q.pop();       while (!fr[t]) {         int tar = peo[t][pos[t]++];         if (!fr[tar + N] || rk[tar][fr[tar + N]] > rk[tar][t]) {           fr[fr[tar + N]] = 0;           if (fr[tar + N]) q.push(fr[tar + N]);           fr[tar + N] = t;           fr[t] = tar + N;         }       }     }   }   int main() {     for (cin >> T; T; --T) {       cin >> N;       for (int i = 1; i <= N; ++i)         for (int j = 1; j <= N; ++j) cin >> val[i][j];       cout <<  B  << endl;       char c;       cin >> c;       if (c ==  D )         for (int i = 1; i <= N; ++i)           for (int j = 1; j <= N; ++j) val[i][j] = -val[i][j];       int p;       cin >> p;       go(p > N);       while (p != -1) {         cout << fr[p] << endl;         cin >> p;       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     long n;     scanf( %ld n , &n);     std::vector<long> array(n, 0);     for (int p = 0; p < n; p++) {       scanf( %ld  , &array[p]);     }     bool down = 0, possible = 1;     long moves(0);     for (int p = 1; p < n; p++) {       if (array[p - 1] <= array[p]) {         continue;       }       if (down) {         possible = 0;         break;       }       down = 1;       moves = n - p;       if (array[p] > array[0]) {         possible = 0;         break;       }     }     if (down && array[n - 1] > array[0]) {       possible = 0;     }     if (!possible) {       puts( -1 );     } else {       printf( %ld n , moves);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, l[3001][3001], dp[3001][3001], mod = 1000000007;   char cc;   long long find(long long aa, long long bb, long long qq, long long ww) {     if (l[aa][bb] == 2) return 0;     memset(dp, 0, sizeof(dp));     dp[aa][bb] = 1;     for (int i = aa; i <= qq; i++) {       for (int j = bb; j <= ww; j++) {         if (i == aa && j == bb) continue;         if (l[i][j] == 2) continue;         dp[i][j] = dp[i - 1][j] + dp[i][j - 1];         dp[i][j] %= 1000000007;       }     }     return dp[qq][ww] % 1000000007;   }   int main() {     scanf( %lld%lld , &a, &b);     getchar();     for (int i = 1; i <= a; i++) {       for (int j = 1; j <= b; j++) {         l[i][j] = (getchar() ==  . ) ? 1 : 2;       }       getchar();     }     printf( %lld , ((find(1, 2, a - 1, b) * find(2, 1, a, b - 1) % 1000000007 -                      find(1, 2, a, b - 1) * find(2, 1, a - 1, b)) %                         1000000007 +                     1000000007) %                        1000000007);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[100000], p[100000], b[100000];   vector<int> v[100000];   set<int> s;   int main() {     int n, cnt = -1;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];       p[i] = arr[i];     }     sort(p, p + n);     int i, j = 0;     while (s.size() != n) {       i = j;       if (b[i] != -1) cnt++;       while (b[i] != 1) {         b[i] = 1;         v[cnt].push_back(i);         s.insert(i);         i = lower_bound(p, p + n, arr[i]) - p;       }       j++;     }     int ans = 0;     for (int i = 0; i <= cnt; i++) {       if (v[i].size() > 0) ans++;     }     cout << ans << endl;     for (int i = 0; i <= cnt; i++) {       if (v[i].size() > 0) {         cout << v[i].size() <<    ;         for (int j = 0; j < v[i].size(); j++) cout << v[i][j] + 1 <<    ;         cout << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   int r, s, p;   double dp[N][N][N], ans[4];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> r >> s >> p;     dp[r][s][p] = 1.0;     for (int i = r; i >= 0; i--) {       for (int j = s; j >= 0; j--) {         for (int k = p; k >= 0; k--) {           double cur = i * j + j * k + k * i;           if (i && j) dp[i][j - 1][k] += (1.0 * i * j / cur) * dp[i][j][k];           if (j && k) dp[i][j][k - 1] += (1.0 * j * k / cur) * dp[i][j][k];           if (k && i) dp[i - 1][j][k] += (1.0 * k * i / cur) * dp[i][j][k];         }       }     }     for (int i = 1; i <= r; i++) ans[1] += dp[i][0][0];     for (int j = 1; j <= s; j++) ans[2] += dp[0][j][0];     for (int k = 1; k <= p; k++) ans[3] += dp[0][0][k];     cout << fixed << setprecision(12) << ans[1] <<     << ans[2] <<     << ans[3]          <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long getLCM(int a, int b) {     int copyA = a, copyB = b;     int r = a % b;     while (r) {       a = b;       b = r;       r = a % b;     }     int gcd = b;     return 1LL * copyA * copyB / gcd;   }   int main() {     int n, a, b, p, q;     cin >> n >> a >> b >> p >> q;     int divA = n / a;     int divB = n / b;     int divAB = n / getLCM(a, b);     divA -= divAB;     divB -= divAB;     cout << 1LL * divA * p + 1LL * divB * q + 1LL * divAB * max(p, q);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 1005;   bool vis[mx][mx][2];   double dp[mx][mx][2];   double func(int white, int black, int turn) {     if (white <= 0) {       return 0.0;     }     if (black <= 0) {       if (!turn) return 1.0;       return 0.0;     }     if (vis[white][black][turn]) return dp[white][black][turn];     double up, down, p, q, r, ans, x, y;     if (!turn) {       up = white;       down = (double)white + black;       ans = up / down;       p = (1.0 - ans);       ans += p * func(white, black - 1, 1);     } else {       up = black;       down = white + black;       p = up / down;       black--;       q = 0.0;       x = 0.0;       if (black) {         up = black;         down = black + white;         q = up / down;         x = q * func(white, black - 1, 0);       }       r = (1.0 - q);       y = r * func(white - 1, black, 0);       ans = p * (x + y);     }     vis[white][black][turn] = 1;     return dp[white][black][turn] = ans;   }   int main() {     int b, w;     scanf( %d %d , &w, &b);     memset(vis, 0, sizeof(vis));     double ans = func(w, b, 0);     printf( %.15lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long LINF = ~(((long long)0x1) << 63) / 2;   const int INF = 0X3F3F3F3F;   const double eps = 1e-7;   int num[10];   int ok[10];   int main() {     int n, k, i, j, v;     string s, ans, now, ss;     cin >> n >> v;     cin >> s;     for (i = 0; i < n; i++) num[s[i] -  0 ]++;     int minvalue = INF;     for (i = 0; i < 10; i++) {       memset(ok, 0, sizeof(ok));       int now = v, last = -1;       now -= num[i];       ok[i] = 1;       last = i;       for (j = 1; j < 10 && now > 0; j++) {         if (i - j >= 0) {           now -= num[i - j];           ok[i - j] = 1;         }         if (now <= 0) {           last = i - j;           now += num[last];           break;         }         if (i + j < 10) {           now -= num[i + j];           ok[i + j] = 1;         }         if (now <= 0) {           last = i + j;           now += num[last];           break;         }       }       if (last == i) now += num[i];       int value = 0;       ans =   ;       for (j = 0; j < n; j++)         if (ok[s[j] -  0 ] && s[j] -  0  != last)           ans += i +  0 , value += abs(s[j] -  0  - i);         else           ans += s[j];       if (last >= i) {         for (j = 0; j < n && now > 0; j++)           if (ans[j] == last +  0 )             ans[j] = i +  0 , value += abs(ans[j] -  0  - last), now--;       } else {         for (j = n; j >= 0 && now > 0; j--)           if (ans[j] == last +  0 )             ans[j] = i +  0 , value += abs(ans[j] -  0  - last), now--;       }       if (value < minvalue) {         minvalue = value;         ss = ans;       } else if (value == minvalue && ans < ss)         ss = ans;       memset(ok, 0, sizeof(ok));       now = v, last = -1;       now -= num[i];       ok[i] = 1;       last = i;       for (j = 1; j < 10 && now > 0; j++) {         if (i + j < 10) {           now -= num[i + j];           ok[i + j] = 1;         }         if (now <= 0) {           last = i + j;           now += num[last];           break;         }         if (i - j >= 0) {           now -= num[i - j];           ok[i - j] = 1;         }         if (now <= 0) {           last = i - j;           now += num[last];           break;         }       }       if (last == i) now += num[i];       value = 0;       ans =   ;       for (j = 0; j < n; j++)         if (ok[s[j] -  0 ] && s[j] -  0  != last)           ans += i +  0 , value += abs(s[j] -  0  - i);         else           ans += s[j];       if (last >= i) {         for (j = 0; j < n && now > 0; j++)           if (ans[j] == last +  0 )             ans[j] = i +  0 , value += abs(ans[j] -  0  - last), now--;       } else {         for (j = n; j >= 0 && now > 0; j--)           if (ans[j] == last +  0 )             ans[j] = i +  0 , value += abs(ans[j] -  0  - last), now--;       }       if (value < minvalue) {         minvalue = value;         ss = ans;       } else if (value == minvalue && ans < ss)         ss = ans;     }     cout << minvalue << endl;     cout << ss << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, a[100010], l[100010], r[100010], LS[100010], T;   int G[100010][10];   struct MAT {     int data[10][10];     MAT() { memset(data, 0, sizeof(data)); }     MAT operator*(const MAT& ma) const {       MAT ret;       for (int i = 1; i <= 3; ++i)         for (int j = 1; j <= 3; ++j)           for (int k = 1; k <= 3; ++k)             ret.data[i][j] =                 (ret.data[i][j] + 1ll * data[i][k] * ma.data[k][j]) % 1000000007;       return ret;     }   };   MAT A;   int main() {     scanf( %lld%lld , &n, &m);     for (int i = 1; i <= n; ++i) {       scanf( %d%lld%lld , &a[i], &l[i], &r[i]);       LS[++T] = l[i], LS[++T] = r[i] + 1;     }     LS[++T] = 2, LS[++T] = m + 1;     sort(LS + 1, LS + T + 1);     T = unique(LS + 1, LS + T + 1) - LS - 1;     for (int i = 1; i <= n; ++i) {       l[i] = lower_bound(LS + 1, LS + T + 1, l[i]) - LS;       r[i] = lower_bound(LS + 1, LS + T + 1, r[i] + 1) - LS;       G[l[i]][a[i]]++, G[r[i]][a[i]]--;     }     for (int i = 1; i <= 3; ++i) A.data[i][i] = 1;     for (int i = 1; i < T; ++i) {       for (int j = 1; j <= 3; ++j) G[0][j] += G[i][j];       MAT I;       for (int j = 1; j <= 3; ++j)         for (int k = max(1, j - 1); k <= min(3, j + 1); ++k)           if (!G[0][k]) I.data[j][k] = 1;       long long len = LS[i + 1] - LS[i];       for (; len; len >>= 1, I = I * I)         if (len & 1) A = A * I;     }     printf( %d , A.data[2][2]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mx = 10000007;   using pii = pair<long long, long long>;   const long long mod = 1e9 + 7;   const double pi = acos(-1);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       vector<pii> v;       vector<long long> ev, od;       set<long long> s;       for (long long i = 0; i < n; i++) {         s.insert(i + 1);         if ((i + 1) % 2 == 0)           ev.push_back(i + 1);         else           od.push_back(i + 1);       }       if (n == 2) {         cout << 2 << endl;         cout << 1 <<     << 2 << endl;         continue;       }       sort(ev.begin(), ev.end());       sort(od.begin(), od.end());       reverse(ev.begin(), ev.end());       reverse(od.begin(), od.end());       long long d;       if (n % 2 == 0) {         d = ev[0];         s.erase(d);         long long i = 1, j = 0;         while (1) {           if (d % 2 == 0) {             long long a = d;             long long b = ev[i];             s.erase(b);             v.push_back({a, b});             d = (a + b) / 2;             if (s.size() == 0) break;             i++;             if (i > ev.size()) break;           } else {             long long a = d;             long long b = od[j];             s.erase(b);             v.push_back({a, b});             j++;             d = (a + b) / 2;             if (s.size() == 0) break;             if (j > od.size()) break;           }           if (s.size() == 0) break;         }       } else if (n % 2 == 1) {         d = od[0];         s.erase(d);         long long i = 1, j = 0;         while (1) {           if (d % 2 == 1) {             long long a = d;             long long b = od[i];             s.erase(b);             v.push_back({a, b});             d = (a + b) / 2;             if (s.size() == 0) break;             i++;             if (i > od.size()) break;           } else {             long long a = d;             long long b = ev[j];             s.erase(b);             v.push_back({a, b});             j++;             d = (a + b) / 2;             if (s.size() == 0) break;             if (j > ev.size()) break;           }           if (s.size() == 0) break;         }       }       cout << d << endl;       for (long long i = 0; i < v.size(); i++) {         cout << v[i].first <<     << v[i].second << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     vector<double> vv;     vv.push_back(0);     for (double i = 1; i <= 400; i++) {       vv.push_back(180 / i);     }     cin >> t;     while (t--) {       double n;       cin >> n;       bool is = 0;       for (int i = 3; i < vv.size(); i++) {         double x = 0;         bool don = 0;         for (int j = 0; j < i - 2; j++) {           x += vv[i];           if (x == n) {             cout << i << endl;             don = 1;             break;           }         }         if (don) {           is = 1;           break;         }       }       if (!is) cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 20, K = (1 << 16) + 5, M = 2005, mod = 998244353;   int k, sum, a[N], b[N];   bitset<M> f[K];   inline void dfs(register int s, register int now) {     if (!s) return;     register int i;     for (; now * k <= sum && f[s][now * k]; now *= k)       for (i = s; i; i ^= i & -i) ++b[__builtin_ctz(i & -i)];     for (i = s; i; i ^= i & -i)       if (now >= a[__builtin_ctz(i & -i)] &&           f[s ^ i & -i][now - a[__builtin_ctz(i & -i)]]) {         dfs(s ^ i & -i, now - a[__builtin_ctz(i & -i)]);         return;       }   }   priority_queue<pair<int, int> > q;   int main() {     register int n, i, s, t;     scanf( %d%d , &n, &k);     for (i = 0; i ^ n; ++i) scanf( %d , &a[i]), sum += a[i];     t = (1 << n) - 1;     f[0][0] = 1;     for (s = 1; s <= t; ++s) {       for (i = s; i; i ^= i & -i)         f[s] |= f[s ^ i & -i] << a[__builtin_ctz(i & -i)];       for (i = sum / k; i >= 1; --i)         if (f[s][i * k]) f[s][i] = 1;     }     if (!f[t][1])       puts( NO );     else {       puts( YES );       dfs(t, 1);       register pair<int, int> x1, x2;       for (i = 0; i ^ n; ++i) q.push(make_pair(b[i], a[i]));       while (q.size() > 1) {         x1 = q.top();         q.pop();         x2 = q.top();         q.pop();         printf( %d %d n , x1.second, x2.second);         x1.second += x2.second;         while (x1.second % k == 0) x1.second /= k, --x1.first;         q.push(x1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int B[1 << 17];   int R[1 << 17];   vector<int> Add(const vector<int>& a, const vector<int>& b) {     vector<int> res = a;     int i;     for (i = (0); i < (int((b).size())); ++i) res.push_back(b[i]);     return res;   }   int main() {     int n;     scanf( %d , &n);     int i, j;     for (i = (0); i < (n); ++i) {       int a;       scanf( %d , &a);       --a;       R[a] = i;     }     memset(B, 0, sizeof(B));     vector<vector<int> > ret;     vector<vector<int> > ret2;     vector<vector<int> > A[8];     for (i = (0); i < (n); ++i)       if (B[i] == 0) {         int pos = i;         vector<int> v;         while (B[pos] == 0) {           B[pos] = 1;           v.push_back(pos);           pos = R[pos];         }         pos = 0;         int len = int((v).size());         while (len - pos > 4) {           vector<int> r;           for (j = (0); j < (5); ++j) r.push_back(v[pos + j]);           ret.push_back(r);           rotate(r.begin(), r.end() - 1, r.end());           ret2.push_back(r);           pos += 4;         }         if (len - pos > 1) {           vector<int> w;           for (j = (pos); j < (len); ++j) w.push_back(v[j]);           A[len - pos].push_back(w);         }       }     int L[8];     int C[8];     memset(L, 0, sizeof(L));     memset(C, 0, sizeof(C));     for (i = (0); i < (8); ++i) L[i] = int((A[i]).size());     for (i = (0); i < (L[4]); ++i) {       vector<int> r = A[4][i];       ret.push_back(r);       rotate(r.begin(), r.end() - 1, r.end());       ret2.push_back(r);     }     while (C[2] + C[3] != L[2] + L[3]) {       if (C[2] != L[2]) {         vector<int> r = A[2][C[2]];         ++C[2];         vector<int> r2;         if (C[3] != L[3]) {           r2 = A[3][C[3]];           ++C[3];         } else if (C[2] != L[2]) {           r2 = A[2][C[2]];           ++C[2];         }         ret.push_back(Add(r, r2));         rotate(r.begin(), r.end() - 1, r.end());         if (!r2.empty()) rotate(r2.begin(), r2.end() - 1, r2.end());         ret2.push_back(Add(r, r2));         continue;       }       vector<int> r = A[3][C[3]];       ++C[3];       vector<int> r2;       if (C[3] != L[3]) {         r2 = A[3][C[3]];         r2.erase(r2.end() - 1);         ++C[3];       }       ret.push_back(Add(r, r2));       rotate(r.begin(), r.end() - 1, r.end());       if (!r2.empty()) rotate(r2.begin(), r2.end() - 1, r2.end());       ret2.push_back(Add(r, r2));       if (!r2.empty()) {         vector<int> t;         t.push_back(A[3][C[3] - 1][1]);         t.push_back(A[3][C[3] - 1][2]);         A[2].push_back(t);         ++L[2];       }     }     printf( %d n , int((ret).size()));     for (i = (0); i < (int((ret).size())); ++i) {       printf( %d n , int((ret[i]).size()));       for (j = (0); j < (int((ret[i]).size())); ++j)         printf( %d%c , ret[i][j] + 1, j == int((ret[i]).size()) - 1 ?   n  :    );       for (j = (0); j < (int((ret2[i]).size())); ++j)         printf( %d%c , ret2[i][j] + 1,                j == int((ret2[i]).size()) - 1 ?   n  :    );     }     return 0;   };
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 300005;   const long long INF = 0x3f3f3f3f3f3f3f3f;   long long n;   long long Read() {     long long x = 0, f = 1;     char c = getchar();     while (c >  9  || c <  0 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x * 10) + (c ^ 48);       c = getchar();     }     return x * f;   }   void Put1(long long x) {     if (x > 9) Put1(x / 10);     putchar(x % 10 ^ 48);   }   void Put(long long x, char c = -1) {     if (x < 0) putchar( - ), x = -x;     Put1(x);     if (c >= 0) putchar(c);   }   template <typename T>   T Max(T x, T y) {     return x > y ? x : y;   }   template <typename T>   T Min(T x, T y) {     return x < y ? x : y;   }   template <typename T>   T Abs(T x) {     return x < 0 ? -x : x;   }   long long a, d[MAXN], c[MAXN], f[MAXN];   struct node {     long long d, maxf, maxans;     node() {}     node(long long d1, long long maxf1, long long maxans1) {       d = d1;       maxf = maxf1;       maxans = maxans1;     }   } sta[MAXN];   long long pow2(long long x) { return x * x; }   void solve() {     long long ans = Max(0ll, a - (c[n] - c[n - 1])), max_pref, ed = 0;     sta[0].maxans = -INF;     sta[++ed] = node(0, f[n], f[n]);     for (long long l = n - 1; l >= 1; --l) {       max_pref = -INF;       while (ed > 0 && sta[ed].d <= d[l + 1] - d[l]) {         max_pref = Max(max_pref, sta[ed].maxf);         sta[ed--] = node(0, 0, 0);       }       if (max_pref != -INF)         sta[++ed] =             node(d[l + 1] - d[l], max_pref,                  Max(max_pref - pow2(d[l + 1] - d[l]), sta[ed - 1].maxans));       sta[++ed] = node(0, f[l], Max(f[l], sta[ed - 1].maxans));       ans = Max(ans, sta[ed].maxans - f[l - 1]);     }     Put(ans,   n );   }   signed main() {     n = Read(), a = Read();     for (long long i = 1; i <= n; ++i)       d[i] = Read(), c[i] = c[i - 1] + Read(), f[i] = a * i - c[i];     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 2;   bool v[N], use[N];   int main() {     int n, i, j;     long long T;     vector<int> p;     scanf( %d , &n);     for (i = 2; i <= n; ++i) {       if (!v[i]) {         p.push_back(i);         T = i;         T *= i;         while (T <= n) v[T] = 1, T += i;       }     }     vector<pair<int, int> > ret;     vector<int> x;     for (i = p.size() - 1; i >= 1; --i) {       j = p[i];       x.clear();       while (j <= n) {         if (!use[j]) {           x.push_back(j);         }         j = j + 2 * p[i];       }       for (j = 0; j < x.size(); j += 2) {         if (j == x.size() - 1) break;         ret.push_back(make_pair(x[j], x[j + 1]));         use[x[j]] = 1, use[x[j + 1]] = 1;       }       if (x.size() & 1) {         if (p[i] * 2 <= n) {           ret.push_back(make_pair(x.back(), p[i] * 2));           use[x.back()] = 1, use[p[i] * 2] = 1;         }       }     }     x.clear();     for (i = 2; i <= n; i += 2)       if (!use[i]) x.push_back(i);     int sz = x.size() / 2;     sz *= 2;     for (i = 0; i < sz; i += 2) ret.push_back(make_pair(x[i], x[i + 1]));     printf( %d n , (int)ret.size());     for (i = 0; i < ret.size(); ++i)       printf( %d %d n , ret[i].first, ret[i].second);   }