malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename A, typename B>   ostream& operator<<(ostream& os, const pair<A, B>& x) {     return os <<  (  << x.first <<  ,  << x.second <<  ) ;   }   vector<int> E[505][505];   long long dp[505][505], W[505][505];   vector<pair<int, int>> verts[505][505], hors[505][505];   int main() {     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     vector<int> C(k);     for (int i = 0; i < k; ++i) {       int r, c, d, t;       scanf( %d%d%d%d%d , &r, &c, &d, &t, &C[i]);       vector<bool> has(4);       if (r + c >= t && (r + c - t) % 4 == 0) has[0] = true;       if (r + c >= t && (r + c - t) % 4 == 1) has[1] = true;       if (r + c + d >= t && (r + c + d - t) % 4 == 2) has[2] = true;       if (r + c + d >= t && (r + c + d - t) % 4 == 3) has[3] = true;       int tot = has[0] + has[1] + has[2] + has[3];       assert(tot <= 2);       if (!tot) continue;       if (has[0] && has[2])         verts[r][c].emplace_back(r + d, C[i]);       else if (has[0] && has[3])         hors[r][c].emplace_back(c + d, C[i]);       else if (has[1] && has[2])         hors[r + d][c - d].emplace_back(c, C[i]);       if (has[0]) W[r][c] += C[i];       if (has[1]) W[r + d][c - d] += C[i];       if (has[2]) W[r + d][c] += C[i];       if (has[3]) W[r][c + d] += C[i];     }     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) {         if (!i && !j) continue;         long long val = LLONG_MAX;         long long cost = 0;         for (int k = j; k >= 0; --k) {           cost += W[i][k];           for (auto& x : hors[i][k]) {             if (x.first <= j) cost -= x.second;           }           if (k < j) val = min(val, dp[i][k] + cost - W[i][k]);         }         cost = 0;         for (int k = i; k >= 0; --k) {           cost += W[k][j];           for (auto& x : verts[k][j]) {             if (x.first <= i) cost -= x.second;           }           if (k < i) val = min(val, dp[k][j] + cost - W[k][j]);         }         dp[i][j] = val;       }     printf( %lld n , dp[n - 1][m - 1]);   }
#include <bits/stdc++.h>   using namespace std;   void st() {}   string str;   int n;   int main() {     st();     cin >> n >> str;     if (str.find( L ) == string::npos) {       int x = str.find( R );       int y = str.find( . , x);       printf( %d %d n , x + 1, y + 1);       return 0;     }     if (str.find( R ) == string::npos) {       int x = str.find( L );       int y = str.find( . , x);       printf( %d %d n , y, x);       return 0;     }     int x = str.find( L );     int y = str.find( R );     printf( %d %d n , y + 1, x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 9, LOG = 20;   int n, a, b;   int h[maxn], par[LOG][maxn], siz[maxn];   vector<int> adj[maxn];   void DFS(int v, int p = -1) {     par[0][v] = p;     for (int i = 1; i < LOG; i++) par[i][v] = par[i - 1][par[i - 1][v]];     siz[v] = 1;     for (auto u : adj[v]) {       if (u != p) {         h[u] = h[v] + 1;         DFS(u, v);         siz[v] += siz[u];       }     }   }   int i_par(int v, int d) {     for (int i = 0; i < LOG; i++) {       if (d & (1 << i)) v = par[i][v];     }     return v;   }   int lca(int a, int b) {     if (h[b] > h[a]) swap(a, b);     a = i_par(a, h[a] - h[b]);     if (a == b) return a;     for (int i = LOG - 1; i >= 0; i--) {       if (par[i][a] != par[i][b]) {         a = par[i][a], b = par[i][b];       }     }     return par[0][a];   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n - 1; i++) {       int x, y;       cin >> x >> y;       adj[x].push_back(y), adj[y].push_back(x);     }     DFS(1);     int q;     cin >> q;     while (q--) {       int a, b;       cin >> a >> b;       int p = lca(a, b);       int x = h[a] - h[p] + h[b] - h[p];       if (a == b) {         cout << n <<   n ;         continue;       }       if (x % 2 == 1)         cout << 0 <<   n ;       else {         if (h[a] < h[b]) swap(a, b);         int c = i_par(a, x / 2);         if (c != p) {           int d = i_par(a, x / 2 - 1);           cout << siz[c] - siz[d] <<   n ;         } else {           int d = i_par(a, x / 2 - 1), t = i_par(b, x / 2 - 1);           cout << siz[c] - siz[d] - siz[t] + n - siz[c] <<   n ;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   multiset<int, greater<int>> m1, m2;   int n, m;   int main() {     cin >> n >> m;     for (int i = 0; i < n; ++i) {       int a;       cin >> a;       m1.insert(a);     }     for (int i = 0; i < n; ++i) {       int a;       cin >> a;       m2.insert(a);     }     vector<int> ans;     for (; m1.size();) {       auto a = m1.begin();       auto b = m2.begin();       auto bestfora = m2.lower_bound(m - 1 - *a);       auto bestforb = m1.lower_bound(m - 1 - *b);       if (bestfora == m2.end()) --bestfora;       if (bestforb == m1.end()) --bestforb;       if ((*a + *b) % m > (*a + *bestfora) % m &&           (*a + *b) % m > (*b + *bestforb) % m) {         ans.push_back((*a + *b) % m);         m1.erase(a);         m2.erase(b);       } else if ((*a + *bestfora) % m >= (*a + *b) % m &&                  (*a + *bestfora) % m >= (*b + *bestforb) % m) {         ans.push_back((*a + *bestfora) % m);         m1.erase(a);         m2.erase(bestfora);       } else {         ans.push_back((*b + *bestforb) % m);         m1.erase(bestforb);         m2.erase(b);       }     }     sort(ans.begin(), ans.end(), greater<int>());     for (size_t i = 0; i < ans.size(); ++i) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, spr;     vector<string> valer;     cin >> s;     char h;     int k = (int)s.size();     valer.push_back(s);     for (int i = 1; i < k; i++) {       h = s[k - 1];       for (int j = k - 1; j > 0; j--) {         s[j] = s[j - 1];       }       s[0] = h;       spr = s;       bool t = true;       for (int r = 0; r < (int)valer.size(); r++) {         if (spr == valer[r]) t = false;       }       if (t == true) {         valer.push_back(spr);       }     }     cout << (int)valer.size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, n, m, j, y, pos, fed = 0;   int mice[100001], cheese[100001], taken[100001];   int main() {     scanf( %d %d %d %d , &n, &m, &y, &y);     for (i = 0; i < n; i++) scanf( %d , &mice[i]);     for (i = 0; i < m; i++) scanf( %d , &cheese[i]);     for (i = 0; i < m; i++) taken[i] = -1;     for (i = 0; i < n; i++) {       pos = lower_bound(cheese, cheese + m, mice[i]) - cheese;       if (pos == 0) {         if (taken[pos] == -1) {           taken[pos] = cheese[pos] - mice[i];           fed++;         } else {           taken[pos] = cheese[pos] - mice[i];         }         continue;       }       if (pos == m) {         if (taken[pos - 1] == -1 || taken[pos - 1] == mice[i] - cheese[pos - 1]) {           taken[pos - 1] = mice[i] - cheese[pos - 1];           fed++;         } else if (taken[pos - 1] > mice[i] - cheese[pos - 1]) {           taken[pos - 1] = mice[i] - cheese[pos - 1];         }         continue;       }       {         if ((mice[i] - cheese[pos - 1]) < (cheese[pos] - mice[i])) {           if (taken[pos - 1] == -1 ||               taken[pos - 1] == mice[i] - cheese[pos - 1]) {             taken[pos - 1] = mice[i] - cheese[pos - 1];             fed++;           } else if (taken[pos - 1] > mice[i] - cheese[pos - 1]) {             taken[pos - 1] = mice[i] - cheese[pos - 1];           }         } else if ((mice[i] - cheese[pos - 1]) == (cheese[pos] - mice[i])) {           if (taken[pos - 1] == -1 ||               taken[pos - 1] == mice[i] - cheese[pos - 1]) {             taken[pos - 1] = mice[i] - cheese[pos - 1];             fed++;           } else {             taken[pos] = cheese[pos] - mice[i];             fed++;           }         } else {           if (taken[pos] == -1) {             taken[pos] = cheese[pos] - mice[i];             fed++;           } else {             taken[pos] = cheese[pos] - mice[i];           }         }       }     }     printf( %d n , n - fed);     return 0;   }
#include <bits/stdc++.h>   const long long int inf = LLONG_MAX;   using namespace std;   int main() {     int n, a[4], dp[4005] = {0}, i, j;     dp[0] = 0;     cin >> n >> a[0] >> a[1] >> a[2];     for (i = 1; i <= n; i++) {       for (j = 0; j < 3; j++) {         if (i < a[j]) continue;         if (dp[i - a[j]] != 0)           dp[i] = max((1 + dp[i - a[j]]), dp[i]);         else if (i == a[j])           dp[i] = max(1, dp[i]);       }     }     cout << dp[n];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       for (int i = 0; i < n; i++) cin >> arr[i];       int cnt[n + 1];       memset(cnt, 0, sizeof cnt);       cnt[0] = 1;       int lvl = 0;       int ind = 1;       while (ind < n) {         lvl++;         for (int i = 0; i < cnt[lvl - 1] && i < n; i++) {           int last = -1;           while (ind < n && arr[ind] > last) {             cnt[lvl]++;             last = arr[ind];             ind++;           }         }       }       cout << lvl << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long int dp[1001], sum[1001];   unsigned long long int nCrModp(unsigned long long int n,                                  unsigned long long int r) {     unsigned long long int p = 1000000007;     n = n + r - 1;     r = r - 1;     unsigned long long int C[r + 1];     memset(C, 0, sizeof(C));     C[0] = 1;     for (unsigned long long int i = 1; i <= n; i++) {       for (unsigned long long int j = min(i, r); j > 0; j--)         C[j] = (C[j] + C[j - 1]) % p;     }     return C[r];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     unsigned long long int n, t, i, j, k, ans = 0;     cin >> n;     unsigned long long int ar[n];     for (i = 0; i < n; i++) {       cin >> ar[i];       if (i != 0)         sum[i] = sum[i - 1] + ar[i];       else         sum[i] = ar[i];     }     unsigned long long int prod = 1;     dp[0] = 1;     for (i = 1; i < n; i++) {       dp[i] = nCrModp(sum[i - 1], ar[i]) % 1000000007;       prod *= dp[i];       prod %= 1000000007;     }     cout << prod;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int nax = 1e2 + 5;   string s;   int n, k;   int bonus[26][26];   const int inf = 1e9;   long long int cnt = 0;   int dp[nax][26][nax];   int solve(int i, int prev, int changes) {     if (i >= s.length()) return 0;     if (dp[i][prev][changes] != -inf) return dp[i][prev][changes];     int ans = -inf;     if (changes < k) {       for (int c = 0; c < 26; c++) {         ans = max(ans,                   bonus[prev][c] +                       solve(i + 1, c, changes + ((c == (s[i] -  a )) ? 0 : 1)));       }     } else       ans =           max(ans, bonus[prev][s[i] -  a ] + solve(i + 1, (s[i] -  a ), changes));     return dp[i][prev][changes] = ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> s >> k >> n;     for (int i = 0; i < nax; i++) {       for (int c = 0; c < 26; c++) {         for (int j = 0; j < nax; j++) {           dp[i][c][j] = -inf;         }       }     }     memset(bonus, 0, sizeof(bonus));     for (int i = 0; i < n; i++) {       char x, y;       int b;       cin >> x >> y >> b;       bonus[x -  a ][y -  a ] = b;     }     int ans = -inf;     if (k > 0) {       for (int c = 0; c < 26; c++) {         ans = max(ans, solve(1, c, ((c == (s[0] -  a )) ? 0 : 1)));       }     } else       ans = max(ans, solve(1, s[0] -  a , 0));     cout << ans <<   n ;   }
#include <bits/stdc++.h>   const int MaxN = 5000;   using namespace std;   int a[MaxN + 5];   long long res;   long long dp[MaxN + 5][MaxN + 5];   int n;   long long Solve(int l, int r) {     if (l > r) return 0;     if (l == r) {       return a[l] != 0;     }     int MinPos = l;     for (int i = l; i <= r; i++)       if (a[i] < a[MinPos]) MinPos = i;     long long Min = a[MinPos];     for (int i = l; i <= r; i++) a[i] -= Min;     return min((long long)r - l + 1,                Solve(l, MinPos - 1) + Solve(MinPos + 1, r) + Min);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++)       for (int j = i; j <= n; j++) dp[i][j] = -1;     res = Solve(1, n);     printf( %lld n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cnk[50][50] = {1};   long long calc(long long mask, long long mx, int cnt, int n) {     if (mask > mx) return 0;     if (cnt == 0) return 1;     if (cnt > n + 1) return 0;     if (mask + (1LL << (n + 1)) - 1 <= mx) return cnk[n + 1][cnt];     return calc(mask + (1LL << n), mx, cnt - 1, n - 1) +            calc(mask, mx, cnt, n - 1);   }   bool solve() {     long long n, t;     if (!(cin >> n >> t)) return false;     if ((t - 1) & t) {       printf( 0 n );       return true;     }     int cnt = 0;     for (; t; t /= 2, cnt++)       ;     for (int i = 1; i < 50; ++i)       for (int j = 0; j <= i; ++j) {         cnk[i][j] = 0;         if (j > 0) cnk[i][j] += cnk[i - 1][j - 1];         if (j < i) cnk[i][j] += cnk[i - 1][j];       }     long long ans = calc(0, n + 1, cnt, 60);     if (cnt == 1) ans--;     cout << ans << endl;     return true;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int& x, int y, int mod = 1000000007) {     x += y;     if (x >= mod) x -= mod;     assert(x >= 0 && x < mod);   }   void et() {     puts( -1 );     exit(0);   }   struct Point {     long double x, y;     Point() {}     Point(long double x, long double y) : x(x), y(y) {}     Point operator*(double o) const { return Point(x * o, y * o); }     Point operator+(const Point& o) const { return Point(x + o.x, y + o.y); }     Point operator-(const Point& o) const { return Point(x - o.x, y - o.y); }     bool operator<(const Point& o) const {       return x < o.x || (x == o.x && y < o.y);     }     friend bool operator==(const Point& r1, const Point& r2) {       return r1.x == r2.x && r1.y == r2.y;     }     long double cross(Point b) const { return x * b.y - b.x * y; }     long double dot(Point b) const { return x * b.x + y * b.y; }   };   set<Point> ss;   void add(long double x, long double y) {     Point p = Point(x, y);     auto it = ss.lower_bound({x, 0});     auto pre = it;     pre--;     if (it != ss.end() && (p - *pre).cross(*it - *pre) <= 0) return;     ss.insert(p);     pre = ss.lower_bound(p);     pre--;     if (pre == ss.begin()) return;     auto pp = pre;     pp--;     while (pre != ss.begin() && (*pre - *pp).cross(p - *pre) <= 0) {       ss.erase(pre);       pre = pp;       if (pp == ss.begin()) return;       pp--;     }   }   inline int dcmp(long double x) {     return fabsl(x) < 1e-9 ? 0 : (x > 0 ? 1 : -1);   }   bool ck(long double dam, long double mana) {     auto cur = ss.lower_bound(Point(dam, 0));     if (cur == ss.end()) return 0;     auto pre = cur;     pre--;     long double x = dam - (*pre).x, y = mana - (*pre).y;     Point z = *cur - *pre;     if (dcmp(x * z.y - y * z.x) <= 0) return 1;     return 0;   }   void fmain(int tid) {     scanf( %d%lld , &n, &lm);     int ans = 0, M = 1e6;     ss.insert(Point(0, 0));     for (int(i) = 1; (i) <= (int)(n); (i)++) {       int t, x, y;       scanf( %d%d%d , &t, &x, &y);       x = (x + ans) % M + 1;       y = (y + ans) % M + 1;       if (t == 1)         add(x, y);       else {         bool ok = ck((long double)y / x, (long double)lm / x);         puts(ok ?  YES  :  NO );         if (ok) ans = i;       }     }   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fir = 0;   char s[1100000];   int check() {     for (int i = 0; s[i]; i++) {       if (s[i] ==    ) continue;       if (s[i] ==  # )         return 1;       else         return 0;     }     return 0;   }   int main() {     while (gets(s)) {       if (check()) {         if (fir) putchar(  n );         puts(s);         fir = 0;       } else {         for (int i = 0; s[i]; i++) {           if (s[i] ==    ) continue;           putchar(s[i]);         }         fir = 1;       }     }     if (fir) putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10000000;   bool f[N] = {1, 1};   long long p, q, rub, primepi, res;   long long rev(long long x) {     long long res;     for (res = 0; x; x /= 10) {       res = res * 10 + x % 10;     }     return res;   }   int main() {     cin >> p >> q;     for (long long i = 1; i < N; ++i) {       if (!f[i]) {         primepi++;         for (long long j = i * i; j < N; j += i) f[j] = 1;       }       if (rev(i) == i) rub++;       if (q * primepi <= p * rub) res = i;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   const double eps = 1e-9;   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   struct Point {     int x, y;   };   struct Line {     int A, B, C;     Line(int a = 0, int b = 1, int c = 0) : A(a), B(b), C(c) {       int g = gcd(gcd(abs(A), abs(B)), abs(C));       A /= g;       B /= g;       C /= g;       if (A < 0 || (A == 0 || B < 0)) {         A = -A;         B = -B;         C = -C;       }     }   };   Line getLine(const Point &a, const Point &b) {     int dx = b.x - a.x;     int dy = -(b.y - a.y);     return Line(dy, dx, dy * a.x + dx * a.y);   }   Line perpLine(const Line &li, const Point &p) {     int a = -li.B, b = li.A;     return Line(a, b, p.x * a + p.y * b);   }   bool operator<(const Line &g, const Line &h) {     if (g.A != h.A) return g.A < h.A;     if (g.B != h.B) return g.B < h.B;     return g.C < h.C;   }   const int maxN = 1024;   int N, K;   map<int, vector<Point>> circ;   map<Line, map<int, int>> segs;   int main() {     cin >> N >> K;     for (int i = (0); i < (N); i++) {       int x1, y1, x2, y2;       cin >> x1 >> y1 >> x2 >> y2;       Point a{x1 * 2, y1 * 2};       Point b{x2 * 2, y2 * 2};       Line li = getLine(a, b);       {         if (0) fprintf(stderr,  li: a %d, b %d, c %d n , li.A, li.B, li.C);       };       int pa = a.x * li.B - a.y * li.A;       int push_back = b.x * li.B - b.y * li.A;       if (pa > push_back) swap(pa, push_back);       segs[li][pa + 0]++;       segs[li][push_back + 1]--;     }     for (int i = (0); i < (K); i++) {       int x, y, r;       cin >> x >> y >> r;       circ[r * 2].push_back(Point{x * 2, y * 2});     }     for (auto &s : segs) {       s.second[INT_MIN / 2] = 0;       s.second[INT_MAX / 2] = 0;       {         if (0) fprintf(stderr,  seg n );       };       int prev = 0;       for (auto &e : s.second) {         {           if (0) fprintf(stderr,  %d: %d n , e.first, e.second);         };         e.second = (prev += e.second);         {           if (0) fprintf(stderr,      %d n , prev);         };       }     }     int res = 0;     for (const auto &ci : circ) {       for (int ia = (0); ia < (int((ci.second).size())); ia++) {         for (int ib = (ia + 1); ib < (int((ci.second).size())); ib++) {           Point a = ci.second[ia];           Point b = ci.second[ib];           Point d{b.x - a.x, b.y - a.y};           if (d.x * d.x + d.y * d.y <= ci.first * ci.first * 4) continue;           Point m{a.x + d.x / 2, a.y + d.y / 2};           {             if (0) fprintf(stderr,  M: %d %d n , m.x, m.y);           };           Line li = perpLine(getLine(a, b), m);           {             if (0) fprintf(stderr,  li: a %d, b %d, c %d n , li.A, li.B, li.C);           };           if (!((segs).find(li) != (segs).end())) continue;           int pp = m.x * li.B - m.y * li.A;           {             if (0) cerr <<  DBGDO:   << ( pp ) <<   =   << (pp) << endl;           };           auto it = segs[li].upper_bound(pp);           assert(it != segs[li].begin());           it--;           res += it->second;         }       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 2e5 + 7;   int n, arr[M], d[M], b = 1, t = 0;   bool used[M];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &arr[i]);       d[arr[i]]++;     }     for (int i = 1; i <= n; i++) {       if (d[arr[i]] > 1) {         while (n >= b && d[b]) b++;         if (arr[i] > b || used[arr[i]]) {           t++;           d[arr[i]]--;           d[b]++;           arr[i] = b;         } else           used[arr[i]] = 1;       }     }     printf( %d n , t);     for (int i = 1; i <= n; i++) {       printf( %d  , arr[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   int deg[1000];   int arr[1000][1000];   int jo[1000];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int node, edge;     cin >> node >> edge;     for (int i = 0; i < edge; i++) {       int n1, n2;       cin >> n1 >> n2;       arr[n1 - 1][n2 - 1] = true;       arr[n2 - 1][n1 - 1] = true;       deg[n1 - 1]++;       deg[n2 - 1]++;     }     int res = 0;     int i, j;     while (true) {       int k = 0;       for (i = 0; i < node; i++) {         if (deg[i] == 1) {           jo[k++] = i;           deg[i] = 0;         }       }       if (k == 0) {         break;       }       res++;       for (i = 0; i < k; i++) {         deg[jo[i]] = 0;         for (j = 0; j < node; j++) {           if (arr[jo[i]][j]) deg[j]--;         }       }     }     cout << res <<   n ;     cerr <<  Time :   << (float)clock() / CLOCKS_PER_SEC <<   s  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[111];   char in[1000];   int main() {     int t, m, i, j;     scanf( %d%d , &t, &m);     int aid = 1;     while (t--) {       scanf( %s , in);       int k;       if (in[0] ==  a ) {         scanf( %d , &k);         for (i = 0; i <= m - k; i++) {           for (j = i; j < i + k; j++)             if (a[j] != 0) break;           if (j == i + k) break;         }         if (i <= m - k) {           printf( %d n , aid);           for (j = i; j < i + k; j++) a[j] = aid;           aid++;         } else {           puts( NULL );         }       } else if (in[0] ==  e ) {         bool f = 0;         scanf( %d , &k);         for (i = 0; i < m; i++)           if (a[i] && a[i] == k) {             a[i] = 0;             f = 1;           }         if (!f) puts( ILLEGAL_ERASE_ARGUMENT );       } else {         for (i = 0, j = 0; i < m; i++)           if (a[i]) {             a[j++] = a[i];           }         for (; j < m; j++) a[j] = 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, ans;   bool pr[100003];   bool mark[100003];   vector<int> v;   vector<int> e;   vector<pair<int, int> > res;   int main() {     scanf( %d , &n);     for (int i = 2; i <= n; i++)       if (!pr[i]) {         v.push_back(i);         for (int j = 2 * i; j <= n; j += i) pr[j] = true;       }     int sz = v.size();     for (int i = 1; i < sz && v[i] <= n / 2; i++) {       vector<int> tmp;       for (int j = v[i]; j <= n; j += v[i])         if (!mark[j]) tmp.push_back(j);       int cnt = tmp.size();       if (cnt % 2 == 0) {         for (int j = 0; j < cnt; j += 2) {           res.push_back(pair<int, int>(tmp[j], tmp[j + 1]));           mark[tmp[j]] = mark[tmp[j + 1]] = true;         }       } else if (cnt >= 3) {         res.push_back(pair<int, int>(tmp[0], tmp[2]));         mark[tmp[0]] = mark[tmp[2]] = true;         for (int j = 3; j < cnt; j += 2) {           res.push_back(pair<int, int>(tmp[j], tmp[j + 1]));           mark[tmp[j]] = mark[tmp[j + 1]] = true;         }       }     }     for (int i = 2; i <= n; i += 2)       if (!mark[i]) e.push_back(i);     int cnt = e.size();     for (int i = 0; i + 1 < cnt; i += 2)       res.push_back(pair<int, int>(e[i], e[i + 1]));     ans = res.size();     printf( %d n , ans);     for (int i = 0; i < ans; i++) printf( %d %d n , res[i].first, res[i].second);     return 0;   }