malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:64000000 )   using namespace std;   const int inf32 = 1e9 + 9;   const long long inf64 = 1e18 + 18;   const int N = 6e5 + 5;   const long long mod = 1e9 + 7;   map<int, int> mp;   vector<int> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};   int n, mx;   void go(int &f, int a, int b, int mn) {     if (a * b > mx) {       if (a % b) return;       mp[a] += mn;       f -= mn;       return;     }     go(f, a * b, b, (mn + 1) / 2);     if (a % b) return;     int t = min(f, mn);     mp[a] += t;     f -= t;   }   bool show() {     int rez = 0;     for (auto &x : mp) rez += x.second;     return rez == n;   }   bool check(int j) {     mp.clear();     mp[1] = n;     int half = (n + 1) / 2;     half += n / 100;     for (int i = 0; i < j; ++i) {       int x = primes[i];       int cnt = 0;       bool flag = true;       while (flag) {         flag = false;         for (auto &y : mp) {           if (!y.second || !(y.first % x)) continue;           int t = cnt;           cnt += y.second;           go(y.second, y.first, x, (y.second + 1) / 2);           cnt -= y.second;           flag |= t != cnt;           if (cnt >= half) break;         }         if (cnt >= (n + 1) / 2) break;       }       if (!flag) {         for (auto &y : mp) {           if (y.second > 1 && y.first * x < mx) {             mp[y.first * x] += 1;             --y.second;             ++cnt;           }           if (cnt >= (n + 1) / 2) break;         }         if (cnt < (n + 1) / 2) return false;       }     }     for (auto &y : mp) {       if (y.second > 1) {         for (int i = 0; i < j; ++i) {           int x = primes[i];           for (int i = x; y.second && i * y.first < mx; i *= x) {             if (!mp[y.first * i]) {               mp[y.first * i] = 1;               --y.second;             }           }         }       }     }     if (n > 1000) {       queue<int> lil;       for (int i = 0; i < j; ++i) {         for (int k = i + 1; k < j; ++k) {           int x = primes[i], y = primes[k];           if (!mp[x * y]) lil.push(x * y);           if (!mp[x]) lil.push(x);           if (!mp[y]) lil.push(y);           if (!mp[y * y]) lil.push(y * y);           if (!mp[x * x]) lil.push(x * x);           if (!mp[x * x * y]) lil.push(x * x * y);           if (!mp[x * y * y]) lil.push(x * y * y);           if (!mp[x * x * y * y]) lil.push(x * x * y * y);         }       }       for (auto &x : mp) {         while (x.second > 1) {           while (!lil.empty() && mp[lil.front()]) lil.pop();           if (lil.empty()) return false;           --x.second;           mp[lil.front()] = 1;           lil.pop();         }       }     }     for (auto &x : mp) {       if (x.second > 1) return false;     }     return true;   }   void solve() {     cin >> n;     mx = 2 * n * n;     for (int j = 1; !check(j); ++j)       ;     int cnt = 0;     for (auto &x : mp) {       if (x.second) cout << x.first <<    ;     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static const int INF = 500000000;   template <class T>   void debug(T a, T b) {     for (; a != b; ++a) cerr << *a <<    ;     cerr << endl;   }   int n, len;   char s[1000005];   int var[1000005][4];   int cnt, ind;   int parse() {     if (s[ind] ==  0 ) var[cnt][0] = 1;     if (s[ind] ==  1 ) var[cnt][3] = 1;     if (s[ind] ==  ? ) var[cnt][1] = var[cnt][2] = 1;     ++cnt;     int v = cnt - 1;     if (s[ind] ==  ( ) {       ++ind;       int p = parse(), p2;       char ope = s[ind];       ++ind;       p2 = parse();       for (int i = 0; i < 4; ++i)         if (var[p][i])           for (int j = 0; j < 4; ++j)             if (var[p2][j]) {               int x1 = i & 1, x2 = i >> 1 & 1, y1 = j & 1, y2 = j >> 1 & 1;               int bit;               if (ope ==  & ) bit = (x1 & y1) + (x2 & y2) * 2;               if (ope ==  | ) bit = (x1 | y1) + (x2 | y2) * 2;               if (ope ==  ^ ) bit = (x1 ^ y1) + (x2 ^ y2) * 2;               var[v][bit] = 1;             }     }     ++ind;     return v;   }   int main() {     scanf( %d%s , &n, s);     len = strlen(s);     int root = parse();     if (var[0][2] || var[0][1])       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, n1, m1;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> m;     n1 = n, m1 = m;     if ((n1 == m1 + 1 and !(n1 + m1 % 2)) or n1 > m1 + 1 or         m1 / 2 + (m1 % 2) > n1 + 1 or         (m1 / 2 + (m1 % 2)) == n1 + 1 and !(m1 / 2 + (m1 % 2) + n1 % 2)) {       cout << -1;       exit(0);     }     int p = 0;     for (int i = 0; i < n + m; i++) {       if (n1 > m1 or p == 2)         cout << 0, p = 0, n1--;       else         cout << 1, p++, m1--;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fact[100005];   void criba() {     for (int i = 2; i * i < 100005; i++)       if (fact[i] == 0)         for (int j = i * i; j < 100005; j += i) fact[j] = i;     for (int i = 2; i < 100005; i++)       if (fact[i] == 0) fact[i] = i;   }   bool vis[100005];   set<pair<int, int> > S;   int process(int n, int id) {     int m = n;     set<pair<int, int> >::iterator it;     while (n > 1) {       int f = fact[n];       while (n % f == 0) n /= f;       if (id == 2) {         it = S.lower_bound(make_pair(f, -1));         if (it != S.end() && (*it).first == f) return (*it).second;       } else {         if (id == 0)           S.erase(make_pair(f, m));         else           S.insert(make_pair(f, m));       }     }     return -1;   }   int main() {     criba();     int n, m;     while (cin >> n >> m) {       char op[2];       int x;       for (int i = 0; i < m; i++) {         scanf( %s%d , op, &x);         if (op[0] ==  - ) {           if (vis[x])             process(x, 0), puts( Success ), vis[x] = false;           else             puts( Already off );         } else {           if (vis[x])             puts( Already on );           else {             int num = process(x, 2);             if (num == -1)               puts( Success ), process(x, 1), vis[x] = true;             else               printf( Conflict with %d n , num);           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   ifstream in( pairs.in );   ofstream out( pairs.out );   const int DIM = 1e5 + 5;   int nxt[DIM], val[DIM], pos[DIM];   pair<int, int> tdp[DIM][2], cdp[DIM], arr[2][DIM];   deque<int> chn;   bitset<DIM> oki, mrk, ist;   vector<pair<int, int>> sol;   vector<int> edg[DIM];   pair<int, int> operator+(const pair<int, int> &p1, const pair<int, int> &p2) {     return pair<int, int>(p1.first + p2.first, p1.second + p2.second);   }   pair<int, int> operator-(const pair<int, int> &p1, const pair<int, int> &p2) {     return pair<int, int>(p1.first - p2.first, p1.second - p2.second);   }   void calcdp(int x) {     mrk[x] = true;     pos[x] = 0;     tdp[x][0] = tdp[x][1] = pair<int, int>(0, 0);     for (int y : edg[x]) {       calcdp(y);       tdp[x][0] = tdp[x][0] + max(tdp[y][0], tdp[y][1]);       pair<int, int> aux = tdp[y][0] - max(tdp[y][0], tdp[y][1]) +                            pair<int, int>(1, val[x] != val[y]);       if (tdp[x][1] < aux) tdp[x][1] = aux, pos[x] = y;     }     tdp[x][1] = tdp[x][1] + tdp[x][0];   }   int _nr[2];   void solvedp(int x, bool ok, int nr) {     if (ok and pos[x]) arr[nr][++_nr[nr]] = make_pair(x, pos[x]);     for (int y : edg[x]) solvedp(y, (ok and y == pos[x]) ? false : true, nr);   }   int main(void) {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d %d , &nxt[i], &val[i]);       edg[nxt[i]].push_back(i);     }     pair<int, int> ans;     for (int i = 1; i <= n; ++i)       if (!mrk[i]) {         chn.clear();         for (int x = i; true; x = nxt[x]) {           chn.push_back(x);           if (!oki[x])             oki[x] = true;           else {             while (chn.front() != chn.back())               oki[chn.front()] = false, chn.pop_front();             break;           }         }         pair<int, int> pr1, pr2;         edg[chn[1]].erase(find(edg[chn[1]].begin(), edg[chn[1]].end(), chn[0]));         calcdp(chn[0]);         _nr[0] = 0;         solvedp(chn[0], true, 0);         edg[chn[1]].push_back(chn[0]);         pr1 = max(tdp[chn[0]][0], tdp[chn[0]][1]);         edg[chn[2]].erase(find(edg[chn[2]].begin(), edg[chn[2]].end(), chn[1]));         calcdp(chn[1]);         _nr[1] = 0;         solvedp(chn[1], true, 1);         edg[chn[2]].push_back(chn[1]);         pr2 = max(tdp[chn[1]][0], tdp[chn[1]][1]);         if (pr1 > pr2) {           ans = ans + pr1;           for (int i = 1; i <= pr1.first; ++i) sol.push_back(arr[0][i]);         } else {           ans = ans + pr2;           for (int i = 1; i <= pr2.first; ++i) sol.push_back(arr[1][i]);         }       }     printf( %d %d n , ans.first, ans.second);     for (pair<int, int> pr : sol) printf( %d %d n , pr.first, pr.second);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const int N = 1e6 + 7;   const int INF = 1e9 + 7;   int n, m;   int mid = 0;   int ile[70];   long long mnoz = 1;   long long ans = 0;   bitset<128> maska;   void backtrack(int poz = 1) {     ans += mnoz;     if (poz > mid) return;     for (int i = poz; i <= mid; i++) {       if (!ile[i]) continue;       bitset<128> old_mask = maska;       bitset<128> pom = (maska >> i) | (maska << (m - i));       if ((pom & maska).count() == 0) {         int old_mnoz = mnoz;         maska = maska | pom;         mnoz = mnoz * ile[i];         if (mnoz > INF) mnoz %= INF;         backtrack(i + 1);         maska = old_mask;         mnoz = old_mnoz;       }     }   }   void solve() {     cin >> m >> m >> n;     mid = (m + 1) / 2;     for (int i = 0; i < n; i++) {       int temp;       cin >> temp;       temp = temp % m;       temp = min(temp, m - temp);       ile[temp]++;     }     maska[0] = 1;     backtrack();     cout << ans % INF <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<pair<int, bool> > v[300100];   set<pair<int, int> > Bridges;   vector<pair<pair<int, int>, int> > All;   bool vis[300100], F = 0;   int cnt = 0, num[300100], low[300100], Size[300100], par[300100], a, b;   bool Ok[300100];   void init() {     for (int i = 1; i <= n; i++) par[i] = i, Size[i] = 1;   }   int getparent(int x) {     if (x == par[x]) return x;     return par[x] = getparent(par[x]);   }   void Merge(int x, int y) {     x = getparent(x);     y = getparent(y);     if (Size[x] < Size[y]) swap(x, y);     Size[x] += Size[y];     par[y] = x;   }   void BridgeDFS(int u) {     num[u] = low[u] = cnt++;     for (int i = 0; i < v[u].size(); i++) {       int nxt = v[u][i].first;       if (num[nxt] == -1) {         par[nxt] = u;         BridgeDFS(nxt);         if (num[u] < low[nxt]) Bridges.insert({u, nxt}), Bridges.insert({nxt, u});         low[u] = min(low[u], low[nxt]);       } else if (par[u] != nxt)         low[u] = min(low[u], num[nxt]);     }   }   void DFS(int x, bool f) {     vis[x] = true;     if (x == getparent(b)) F = f;     for (int i = 0; i < v[x].size(); i++) {       int y = getparent(v[x][i].first);       if (!vis[y]) {         DFS(y, f || Ok[y] || v[x][i].second);       }     }   }   int main() {     memset(num, -1, sizeof(num));     memset(par, -1, sizeof(par));     int x, y, w;     cin >> n >> m;     while (m--) {       scanf( %d%d%d , &x, &y, &w);       v[x].push_back({y, w});       v[y].push_back({x, w});       All.push_back({{x, y}, w});     }     cin >> a >> b;     BridgeDFS(1);     init();     for (auto it : All) {       if (Bridges.find(it.first) == Bridges.end()) {         int val = max(it.second, max((int)Ok[getparent(it.first.first)],                                      (int)Ok[getparent(it.first.second)]));         Merge(it.first.first, it.first.second);         Ok[getparent(it.first.first)] =             max((int)Ok[getparent(it.first.first)], val);       }     }     for (auto it : All) {       int x = getparent(it.first.first);       int y = getparent(it.first.second);       if (x != y) {         v[x].push_back({y, it.second});         v[y].push_back({x, it.second});       }     }     if (getparent(a) == getparent(b)) {       int u = getparent(a);       if (Ok[u])         return cout <<  YES , 0;       else         return cout <<  NO , 0;     }     DFS(getparent(a), Ok[getparent(a)]);     if (F)       return cout <<  YES , 0;     else       return cout <<  NO , 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef long double LD;    typedef long long ll;    #define int ll    #define ff(i,a,b) for (int i = a; i < b; i++)    #define bf(i,a,b) for (int i = a; i >= b; i--)    #define all(v) v.begin(),v.end()    #define show(a) for(auto xyz:a)cout<<xyz<<   ;cout<<endl;   #define F first    #define S second   #define pb push_back   #define mp make_pair   #define lb lower_bound      #define ub upper_bound   #define yes cout<< YES <<endl   #define no cout<< NO <<endl   #define one cout<< -1 <<endl   #define pi 3.141592653589793238   #define err() cout<< ================================== <<endl;   #define errA(A) for(auto i:A)   cout<<i<<   ;cout<<endl;   #define err1(a) cout<<#a<<   <<a<<endl   #define err2(a,b) cout<<#a<<   <<a<<   <<#b<<   <<b<<endl   #define err3(a,b,c) cout<<#a<<   <<a<<   <<#b<<   <<b<<   <<#c<<   <<c<<endl   #define err4(a,b,c,d) cout<<#a<<   <<a<<   <<#b<<   <<b<<   <<#c<<   <<c<<   <<#d<<   <<d<<endl   #define intmx INT_MAX    #define intmi INT_MIN   const int MOD=1e9+7;      void solve(){      int n,l,r;      cin>>n>>l>>r;      map<int,int> left,right;      ff(i,0,n){          int x;          cin>>x;          if(i<=l-1)          left[x]++;          else          right[x]++;      }      for(auto &i:left){          int x=min(i.S,right[i.F]);          i.S-=x;          right[i.F]-=x;          //cout<<i.F<<   <<i.S<<endl;      }      int cntl=0,cntr=0;      for(auto i:left)      cntl+=i.S;      for(auto i:right)      cntr+=i.S;      int ans=0;      if(cntl<=cntr){          ans+=cntl;          int d=(cntr-cntl)/2;          int cnt=0;          for(auto i:right){              cnt+=i.S/2;          }          if(cnt<d){              ans+=cnt;              ans+=2*(d-cnt);          }          else          ans+=d;      }      else{          ans+=cntr;          int d=(cntl-cntr)/2;          int cnt=0;          for(auto i:left){              cnt+=i.S/2;          }          if(cnt<d){              ans+=cnt;              ans+=2*(d-cnt);          }          else          ans+=d;      }      cout<<ans<<endl;   }   signed main() {       int t=1;       ios_base::sync_with_stdio(false);       cin.tie(NULL);       cin>>t;       while(t--){           solve();       }   }
#include <bits/stdc++.h>   using namespace std;   int entries[1010000][2];   long long has[1010000];   long long power[1010000];   int main() {     int i, j;     long long ans = 0;     int n, m, u, v, p = 31;     scanf( %d%d , &n, &m);     power[0] = 1;     for (i = 1; i <= n; i++) power[i] = power[i - 1] * p;     for (i = 0; i < m; i++) {       scanf( %d%d , &u, &v);       u--;       v--;       has[u] += power[v];       has[v] += power[u];       entries[i][0] = u;       entries[i][1] = v;     }     for (i = 0; i < m; i++) {       u = entries[i][0];       v = entries[i][1];       if (has[u] + power[u] == has[v] + power[v]) ans++;     }     sort(has, has + n);     for (i = 0; i < n; i = j) {       for (j = i; j < n && has[j] == has[i]; j++)         ;       long long temp = j - i;       ans += temp * (temp - 1) / 2;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long int;   using ii = pair<int, int>;   using vi = vector<int>;   using vl = vector<ll>;   using vii = vector<ii>;   using graph = vector<vi>;   using matrix = graph;   const int MAXN = 1e6 + 5;   const int INF = 0x3f3f3f3f;   const ll INFL = 1e18 + 4;   const ll mod = 1e9 + 7;   graph g;   int h[MAXN];   vi leafs;   bool seen[MAXN];   void dfs(int u) {     seen[u] = 1;     bool yes = 1;     for (auto v : g[u])       if (!seen[v]) {         yes = 0;         h[v] = h[u] + 1;         dfs(v);       }     if (yes) leafs.push_back(h[u]);   }   int main() {     int n;     scanf( %d , &n);     g.assign(n + 1, vi());     int u, v;     for (int i = 1; i < n; ++i) {       scanf( %d %d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     int ans = 0;     seen[1] = 1;     for (auto v : g[1]) {       leafs.clear();       dfs(v);       sort(leafs.begin(), leafs.end());       for (int i = 1; i < (int)leafs.size(); ++i) {         leafs[i] = max(leafs[i], leafs[i - 1] + 1);       }       ans = max(ans, leafs.back());     }     printf( %d n , ans + 1);   }
#include <bits/stdc++.h>   using namespace std;   long long bigmod(long long base, long long power, long long mod) {     if (power == 0)       return 1;     else if (power % 2 == 1) {       long long p1 = base % mod;       long long p2 = (bigmod(base, power - 1, mod)) % mod;       return (p1 * p2) % mod;     } else if (power % 2 == 0) {       long long p1 = (bigmod(base, power / 2, mod)) % mod;       return (p1 * p1) % mod;     }   }   long long ncr(long long n, long long k) {     long long C[n + 1][k + 1];     long long i, j;     for (i = 0; i <= n; i++) {       for (j = 0; j <= min(i, k); j++) {         if (j == 0 || j == i)           C[i][j] = 1;         else           C[i][j] = C[i - 1][j - 1] + C[i - 1][j];       }     }     return C[n][k];   }   long long prime[500008];   long long sp[500008];   void seive() {     for (int i = 2; i <= 500008; i += 2) sp[i] = 2;     for (int i = 3; i <= 500008; i += 2) sp[i] = i;     long long x = sqrt(500008);     for (int i = 3; i <= x; i += 2) {       if (sp[i] == i) {         for (int j = i * i; j <= 500008; j += i) {           sp[j] = i;         }       }     }   }   map<long long, long long> m;   void pf(long long n) {     while (1) {       if (n <= 1) break;       long long x = sp[n];       while (n % x == 0) {         n /= x;         m[x]++;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     long long t = 1;     seive();     while (t--) {       long long k, a, b;       cin >> k >> a >> b;       string s;       cin >> s;       long long n = s.size();       long long x = n / k;       long long y = ceil(n / (1.0 * k));       if (x >= a && y <= b) {         int j = 0;         long long rem = n % k;         for (int i = 1; i <= rem; i++) {           for (int z = 0; z <= x; z++) {             cout << s[j++];           }           cout << endl;         }         for (int i = 1; i <= k - rem; i++) {           for (int z = 0; z < x; z++) {             cout << s[j++];           }           cout << endl;         }       } else         cout <<  No solution  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str1, str2;     cin >> str1 >> str2;     int siz = str1.size();     siz--;     while (siz > -1) {       if (str1[siz] ==  z ) {         str1[siz] =  a ;         siz--;       } else {         str1[siz]++;         break;       }     }     if (siz == -1 || str1 == str2)       cout <<  No such string  << endl;     else       cout << str1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int size = 1000007;   const long long modulo = 1000000007;   const long long INF = 1e9;   const double EPS = 1e-10;   int main() {     cin.sync_with_stdio(0);     int n, m, k;     cin >> n >> m >> k;     int ans = 0;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       if (a == 1) {         if (m > 0)           --m;         else           ++ans;       } else {         if (k > 0)           --k;         else if (m > 0)           --m;         else           ++ans;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int main(void) {     int h, m;     scanf( %d:%d , &h, &m);     while (1) {       m++;       if (m == 60) {         m = 0;         h = (h + 1) % 24;       }       if ((m % 10 == h / 10) && (h % 10 == m / 10)) {         printf( %02d:%02d , h, m);         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, cnt = INT_MAX, c = 0;     cin >> n >> k;     string s, temp =   ;     cin >> s;     int freq[26];     memset(freq, 0, sizeof(freq));     for (int i = 0; i < n; i++) freq[s[i] -  A ]++;     for (int i = 0; i < k; i++) {       if (!freq[i]) return cout << 0 << endl, 0;       cnt = min(cnt, freq[i]);     }     cout << cnt * k << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   int a[222], sum[222];   struct node {     int a, id;   } b[222];   bool cmp(node s, node d) { return s.a < d.a; }   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i], b[i].a = a[i], b[i].id = i;     ;     sum[0] = a[0];     for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + a[i];     sort(b, b + n, cmp);     int ans = -22222;     for (int l = 0; l < n; l++)       for (int r = l; r < n; r++) {         int p = min(k, r - l + 1);         int res = sum[r];         if (l) res -= sum[l - 1];         int i = 0, j = n - 1;         while (p--) {           while (i < n && b[i].id < l || b[i].id > r) i++;           while (j >= 0 && b[j].id >= l && b[j].id <= r) j--;           if (i == n || j == -1) break;           if (b[i].a > b[j].a) break;           res += (b[j].a - b[i].a);           i++;           j--;         }         ans = max(ans, res);       }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const long long mod = 1e9 + 7;   const long long N = 1e5 + 10;   int main() {     ios::sync_with_stdio(false);     long long n;     cin >> n;     vector<pair<long long, long long> > v(n);     for (long long i = 0; i < n; i++) cin >> v[i].first >> v[i].second;     map<long long, long long> m;     for (long long i = 0; i < n; i++) m[v[i].first]++;     long long ans = 0;     for (auto it : m) ans += it.second * (it.second - 1) / 2;     m.clear();     for (long long i = 0; i < n; i++) m[v[i].second]++;     for (auto it : m) ans += it.second * (it.second - 1) / 2;     map<pair<long long, long long>, long long> freq;     for (long long i = 0; i < n; i++) freq[make_pair(v[i].first, v[i].second)]++;     for (auto it : freq) ans -= it.second * (it.second - 1) / 2;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const int N = 4e5 + 7, M = 2760000;   int a[N], prime[N], m, flg[M], f[M], x[N], y[N], nn, mm, tot[M];   template <typename Tp>   inline void read(Tp &x) {     x = 0;     bool f = true;     char ch = getchar();     for (; ch <  0  || ch >  9 ; ch = getchar()) f ^= ch ==  - ;     for (; ch >=  0  && ch <=  9 ; ch = getchar()) x = x * 10 + (ch ^ 48);     x = f ? x : -x;   }   inline void primes() {     m = 0;     std::fill(flg + 1, flg + 2750132, true);     for (int i = 2; i <= 2750131; i++) {       if (flg[i]) {         prime[++m] = i;         f[i] = i;       }       for (int j = 1; j <= m && i * prime[j] <= 2750131; j++) {         flg[i * prime[j]] = false;         f[i * prime[j]] = std::min(f[i], prime[j]);         if (!(i % prime[j])) break;       }     }   }   int main() {     int n;     read(n);     n <<= 1;     for (int i = 1; i <= n; i++) read(a[i]);     std::sort(a + 1, a + n + 1);     primes();     for (int i = 1; i <= n; i++)       if (flg[a[i]])         x[++nn] = a[i];       else         y[++mm] = a[i];     for (int i = mm; i; i--) {       if (tot[y[i]]) {         tot[y[i]]--;         continue;       }       printf( %d  , y[i]);       tot[y[i] / f[y[i]]]++;     }     for (int i = 1; i <= nn; i++) {       if (tot[x[i]]) {         tot[x[i]]--;         continue;       }       printf( %d  , x[i]);       tot[prime[x[i]]]++;     }     return 0;   }