malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int in() {     int x;     scanf( %d , &x);     return x;   }   const long double EPS = 1e-12;   const int INF = 1e9 + 10;   const long long LINF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000 + 100;   const int MN = 1e5 + 10;   vector<int> fir[MN], lst[MN];   int arr[MN];   int n, q, sz;   pair<int, int> inv[MN];   bool lz[4 * MN];   int seg[4 * MN];   void input() {     cin >> n >> q;     for (int i = 0; i < n; ++i) cin >> arr[i];     sort(arr, arr + n);     while (q--) {       int l, r;       cin >> l >> r;       int L = lower_bound(arr, arr + n, l) - arr;       int R = upper_bound(arr, arr + n, r) - arr;       if (L >= R) continue;       --R;       if (L == R) continue;       inv[sz++] = make_pair(L, R);       lst[R].push_back(sz - 1), fir[L].push_back(sz - 1);     }   }   void shift(int segnum, int left, int right) {     if (lz[segnum] == false) return;     int mid = (left + right) >> 1;     lz[2 * segnum] = !lz[2 * segnum], lz[2 * segnum + 1] = !lz[2 * segnum + 1];     lz[segnum] = false;     seg[2 * segnum] = (mid - left + 1) - seg[2 * segnum];     seg[2 * segnum + 1] = (right - mid) - seg[2 * segnum + 1];   }   void upd(int segnum, int left, int right, int l, int r) {     if (r < left || right < l) return;     if (l <= left && right <= r) {       lz[segnum] = !lz[segnum];       seg[segnum] = (right - left + 1) - seg[segnum];       return;     }     shift(segnum, left, right);     int mid = (left + right) >> 1;     upd(2 * segnum, left, mid, l, r);     upd(2 * segnum + 1, mid + 1, right, l, r);     seg[segnum] = seg[2 * segnum] + seg[2 * segnum + 1];   }   int get(int segnum, int left, int right, int l, int r) {     if (r < left || right < l) return 0;     if (l <= left && right <= r) return seg[segnum];     shift(segnum, left, right);     int mid = (left + right) >> 1;     return get(2 * segnum, left, mid, l, r) +            get(2 * segnum + 1, mid + 1, right, l, r);   }   void solve() {     long long ans = 1ll * n * (n - 1) * (n - 2) / 6;     for (int i = 0; i < n; ++i) {       upd(1, 0, n - 1, i, n - 1);       for (int j = 0; j < ((int)(fir[i]).size()); ++j)         upd(1, 0, n - 1, inv[fir[i][j]].first, inv[fir[i][j]].second);       if (i - 1 >= 0) {         for (int j = 0; j < ((int)(lst[i - 1]).size()); ++j)           upd(1, 0, n - 1, inv[lst[i - 1][j]].first, inv[lst[i - 1][j]].second);       }       int t = 0;       if (i - 1 >= 0) t += get(1, 0, n - 1, 0, i - 1);       if (i != n - 1) t += get(1, 0, n - 1, i + 1, n);       upd(1, 0, n - 1, i, n - 1);       long long val = 1ll * t * (t - 1) / 2;       ans -= val;     }     cout << ans <<   n ;   }   int main() {     ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long QuickPow(long long x, long long y) {     long long Res = 1, Temp = x;     while (y) {       if (y & 1) Res = Res * Temp % 1000000007;       Temp = Temp * Temp % 1000000007;       y /= 2;     }     return Res;   }   inline void Swap(long long &x, long long &y) {     long long Temp = x;     x = y;     y = Temp;   }   inline long long Max(long long x, long long y) { return x > y ? x : y; }   inline long long Min(long long x, long long y) { return x < y ? x : y; }   inline void read(long long &x) {     x = 0;     long long f = 1;     char s = getchar();     while (s <  0  || s >  9 ) {       if (s ==  - ) f = -1;       s = getchar();     }     while (s >=  0  && s <=  9 ) {       x = (x << 3) + (x << 1) + (s ^ 48);       s = getchar();     }     x *= f;   }   struct node {     long long v, Index;     node() {}     node(long long V, long long INDEX) {       v = V;       Index = INDEX;     }   };   set<long long> Ans, Bian[100005], Dian[100005];   set<long long>::iterator item;   stack<long long> S;   vector<node> G[100005];   bool InStack[100005];   long long Dfn[100005], Low[100005], Cnt, Col;   void Tarjan(long long x, long long Pre) {     Dfn[x] = Low[x] = ++Cnt;     int l = G[x].size();     for (register long long i = 0; i < l; ++i) {       long long to = G[x][i].v;       if (to == Pre) continue;       if (!Dfn[to]) {         S.push(to);         S.push(x);         S.push(G[x][i].Index);         Tarjan(to, x);         Low[x] = Min(Low[x], Low[to]);         if (Low[to] >= Dfn[x]) {           Col++;           long long u, v;           do {             Bian[Col].insert(S.top());             S.pop();             u = S.top();             S.pop();             v = S.top();             S.pop();             Dian[Col].insert(u);             Dian[Col].insert(v);           } while (u != x || v != to);         }       } else if (Dfn[to] < Dfn[x]) {         S.push(to);         S.push(x);         S.push(G[x][i].Index);         Low[x] = Min(Low[x], Dfn[to]);       }     }   }   int main() {     long long n, m;     read(n);     read(m);     for (register long long i = 1; i <= m; ++i) {       long long u, v;       read(u);       read(v);       G[u].push_back(node(v, i));       G[v].push_back(node(u, i));     }     for (register long long i = 1; i <= n; ++i)       if (!Dfn[i]) Tarjan(i, i);     for (register long long i = 1; i <= Col; ++i)       if (Bian[i].size() == Dian[i].size())         Ans.insert(Bian[i].begin(), Bian[i].end());     int l = Ans.size();     printf( %d n , l);     for (item = Ans.begin(); item != Ans.end(); item++) printf( %lld  , *item);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v, vv, vv2;   int main() {     int t, n, a[1000], k, f = 0;     cin >> n;     if (n == 3) {       for (int i = 1; i <= n; i++) {         if (i % 2 != 0) {           for (int j = 1; j <= n; j++) {             if (j % 2 != 0) {               cout <<  W ;             } else               cout <<  B ;           }           cout << endl;         } else {           for (int k = 0; k < n; k++) {             cout <<  B ;           }           cout << endl;         }       }     } else {       for (int i = 1; i <= n; i++) {         if (i % 2 != 0) {           for (int j = 1; j <= n; j++) {             if (j % 2 != 0)               cout <<  W ;             else               cout <<  B ;           }           cout << endl;         } else {           for (int j = 1; j <= n; j++) {             if (j % 2 != 0)               cout <<  B ;             else               cout <<  W ;           }           cout << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   int tree[4 * MAXN];   int maxTree[4 * MAXN];   int p[MAXN];   int n;   void push(int v) {     if (tree[v]) {       tree[2 * v] += tree[v];       tree[2 * v + 1] += tree[v];       maxTree[2 * v] += tree[v];       maxTree[2 * v + 1] += tree[v];       tree[v] = 0;     }   }   void update(int v, int tl, int tr, int l, int r, int add) {     if (l > r) return;     if (tl == l && tr == r) {       tree[v] += add;       maxTree[v] += add;       return;     }     int tm = (tl + tr) >> 1;     push(v);     update(2 * v, tl, tm, l, min(r, tm), add);     update(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, add);     maxTree[v] = max(maxTree[2 * v], maxTree[2 * v + 1]);   }   int findIndex(int v, int tl, int tr) {     if (tl == tr) return tl;     push(v);     int tm = (tl + tr) >> 1;     if (maxTree[2 * v] > 0) {       return findIndex(2 * v, tl, tm);     } else {       return findIndex(2 * v + 1, tm + 1, tr);     }   }   int main() {     for (int i = 0; i < 4 * MAXN; i++) {       tree[i] = 0;       maxTree[i] = 0;     }     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int pos, op;       scanf( %d %d , &pos, &op);       pos = n - pos + 1;       if (op) {         int number;         scanf( %d , &number);         p[pos] = number;         update(1, 1, n, pos, n, 1);       } else {         p[pos] = -1;         update(1, 1, n, pos, n, -1);       }       if (maxTree[1] > 0) {         int index = findIndex(1, 1, n);         printf( %d n , p[index]);       } else {         printf( -1 n );       }     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   using vi = vector<int>;   using vl = vector<ll>;   using vii = vector<pii>;   using vll = vector<pll>;   #define fi first   #define se second   #define sz(c)  ((int)(c).size())   #define all(c) (c).begin(), (c).end()   #define forn(i, m, n)  for (int i = m, nnnn = (n); i < nnnn; ++i)   #define pb  push_back   #define mp  make_pair   //using int128 = __int128_t;   ll P = 1000000007;       int main(){    ios_base::sync_with_stdio(false);    cin.tie(NULL);    cout.tie(NULL);    int n, t;    cin >> n >> t;    ll prev = 0;    ll segmenttree[4*n];    forn(i, 0, 4*n) segmenttree[i] = -1;       while (t--){     int k;     cin >> k;     cout.flush();     ll low = 1, high = n, curr = 0, index = 1;     while (low <= high){      ll mid = (low + high)/2;      ll temp = segmenttree[index];      if (segmenttree[index] == -1){       cout <<  ?  <<     << low <<     << mid << endl;       cout.flush();       cin >> temp;       cout.flush();       segmenttree[index] = temp;      }       if ((mid - low + 1 - temp) + curr < k) {       curr += (mid - low + 1 - temp);       low = mid + 1;       index = index * 2 + 1;      } else {       high = mid - 1;       index *= 2;      }      //cout << low <<     << high <<   n ;     }     cout <<  !  <<     << low <<   n ;     cout.flush();     if(index % 2 == 0) segmenttree[index]++;     while (index != 0) {      bool add = (index % 2 == 0);      index /= 2;      if (add) segmenttree[index]++;     }    }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     char ch;     int Sum = 0, Count = 0;     n /= 2;     for (int i = 1; i <= n; i++) {       cin >> ch;       if (ch ==  4  || ch ==  7 ) {         Count++;       }       Sum += ch -  0 ;     }     for (int i = 1; i <= n; i++) {       cin >> ch;       if (ch ==  4  || ch ==  7 ) {         Count++;       }       Sum -= ch -  0 ;     }     cout << (Sum == 0 && Count == n * 2 ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   vector<int> v[maxn];   int ma = 0;   int h = 0;   int f = 0;   int root = 0;   int g[maxn];   bool mark[maxn];   void dfs(int k) {     if (mark[k] == false) {       mark[k] = true;     } else {       return;     }     for (int i = 0; i < v[k].size(); i++) {       int child = v[k][i];       if (mark[child] == false) {         g[h]++;         dfs(child);       }     }     if (v[k].size() == 1 && root != k) {       if (g[h] + 1 > ma) {         ma = g[h] + 1;       }       f = 1;     }     if (f == 1) {       g[h]--;     }   }   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       int u;       cin >> u;       if (u == -1) {         mark[i] = true;       } else {         v[i].push_back(u);         v[u].push_back(i);       }     }     for (int i = 1; i <= n; i++) {       if (mark[i] == true) {         mark[i] = false;         root = i;         dfs(i);         h++;       }     }     if (ma == 0) {       cout << 1;       return 0;     }     cout << ma;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, m, k;     cin >> n >> m >> k;     map<long long, long long> cnt1, cnt2;     vector<long long> a(n), b(m);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     for (long long i = 0; i < m; i++) {       cin >> b[i];     }     long long run = 0;     for (long long i = 0; i < n; i++) {       if (a[i] == 0) {         if (run) {           cnt1[run]++;           run = 0;         }       } else {         run++;       }     }     if (run) {       cnt1[run]++;     }     run = 0;     for (long long i = 0; i < m; i++) {       if (b[i] == 0) {         if (run) {           cnt2[run]++;           run = 0;         }       } else {         run++;       }     }     if (run) {       cnt2[run]++;     }     long long ans = 0;     for (long long i = 1; i * i <= k; i++) {       if (k % i == 0) {         long long j = k / i;         auto it1 = cnt1.lower_bound(i);         auto it2 = cnt2.lower_bound(j);         while (it1 != cnt1.end()) {           auto it3 = it2;           long long x = (it1->first - i + 1) * it1->second;           while (it3 != cnt2.end()) {             long long y = (it3->first - j + 1) * it3->second;             ans += x * y;             it3++;           }           it1++;         }         if (i != j) {           it1 = cnt1.lower_bound(j);           it2 = cnt2.lower_bound(i);           while (it1 != cnt1.end()) {             auto it3 = it2;             long long x = (it1->first - j + 1) * it1->second;             while (it3 != cnt2.end()) {               long long y = (it3->first - i + 1) * it3->second;               ans += x * y;               it3++;             }             it1++;           }         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return (b != 0 ? gcd(b, a % b) : a); }   int lcm(int a, int b) { return (a / gcd(a, b) * b); }   int R[] = {1, -1, 0, 0, 1, -1, -1, 1};   int C[] = {0, 0, 1, -1, 1, -1, 1, -1};   int KR[] = {-2, -2, -1, 1, 2, 2, -1, 1};   int KC[] = {1, -1, 2, 2, 1, -1, -2, -2};   struct P {     double x, y;     P(double x = 0.0, double y = 0.0) {       this->x = x;       this->y = y;     }   };   P mkv(P ae, P be) { return P(be.x - ae.x, be.y - ae.y); }   double dtp(P ae, P be) { return (ae.x * be.x + ae.y * be.y); }   double crp(P ae, P be) { return (ae.x * be.y - ae.y * be.x); }   double val(P ae) { return sqrt(dtp(ae, ae)); }   P vresize(P ae, double llen) {     double v = val(ae);     return P(ae.x * llen / v, ae.y * llen / v);   }   double ART(P ae, P be) { return crp(ae, be) / 2.0; }   P rot(P ae, double ang) {     return P(ae.x * cos(ang) - ae.y * sin(ang),              ae.y * cos(ang) + ae.x * sin(ang));   }   int main() {     int a, b, c, d, h, m, n, p, x, y, i, j, k, l, q, r, t, cnt, sm, tmp;     scanf( %d %d %d %d , &a, &b, &c, &d);     sm = max((3.0 * a) / 10.0, a - (a * c / 250.0));     cnt = max((3.0 * b) / 10.0, b - (b * d / 250.0));     if (sm > cnt)       printf( Misha n );     else if (cnt > sm)       printf( Vasya n );     else       printf( Tie n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[11111111];   long long b[11111111];   int len = 0;   long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }   int counter(int x) {     int res = 0;     while (x) {       res++;       x /= 10;     }     return res;   }   void printK(int x, int k) {     int n = counter(x);     n = n - k + 1;     for (int i = 0; i < n - 1; i++) x /= 10;     cout << x % 10 <<   n ;   }   long long g(long long x) {     long long res = 0;     int len = 1;     long long tmp = 9;     while (x > tmp) {       res += tmp * len;       x -= tmp;       tmp *= 10;       len++;     }     res += x * len;     return res;   }   long long f(long long x) {     long long res = 0;     long long tmp = 0;     while (x >= 0) {       res += (1 + x) * x / 2;       if (tmp == 0)         tmp = 9;       else         tmp = tmp * 10;       x -= tmp;     }     return res;   }   int main() {     long long q, k;     cin >> q;     for (int i = 0; i < q; i++) {       cin >> k;       long long m, l = 0, r = 2000000001;       while (l < r - 1) {         m = (l + r) >> 1;         if (f(m) < k) {           l = m;         } else {           r = m;         }       }       k -= f(l);       r = l + 2, l = 0;       while (l < r - 1) {         m = (l + r) >> 1;         if (g(m) < k) {           l = m;         } else {           r = m;         }       }       k -= g(l);       long long n = 0;       long long L = l + 1;       l++;       while (L) {         L /= 10;         n++;       }       n = n - k + 1;       for (int j = 0; j < n - 1; j++) l /= 10;       cout << l % 10 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int q, c, i1, i2;   long long v, u, w;   bool flag;   map<long long, long long> cost;   vector<long long> a, b;   void Rule() {     for (int i = i1 - 1; i >= 0; --i) {       cost[a[i]] += w;     }     for (int i = i2 - 1; i >= 0; --i) {       cost[b[i]] += w;     }   }   long long Cuddle() {     long long ret = 0;     for (int i = i1 - 1; i >= 0; --i) {       ret += cost[a[i]];     }     for (int i = i2 - 1; i >= 0; --i) {       ret += cost[b[i]];     }     return ret;   }   int main() {     scanf( %d , &q);     while (q--) {       scanf( %d , &c);       a.clear(), b.clear();       cin >> v >> u;       while (v) {         a.push_back(v);         if (v % 2)           v = (v - 1) / 2;         else           v /= 2;       }       while (u) {         b.push_back(u);         if (u % 2)           u = (u - 1) / 2;         else           u /= 2;       }       flag = 0;       for (int i = 0; i < ((int)(a).size()); ++i) {         for (int j = 0; j < ((int)(b).size()); ++j) {           if (a[i] == b[j]) {             i1 = i, i2 = j, flag = 1;             break;           }         }         if (flag) break;       }       if (c == 1)         cin >> w, Rule();       else         printf( %I64d n , Cuddle());     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int a[1000100];   long long calc(int idx) {     long long ans = 0;     int x = -1, y = -1;     for (int i = 0; i < idx; i += m) {       ans += (long long)abs(a[i] - a[idx]) * 2;       x = i;     }     for (int i = n - 1; i > idx; i -= m) {       ans += (long long)abs(a[i] - a[idx]) * 2;       y = i;     }     return ans;   }   long long solve(long long l, long long r) {     while (l < r) {       long long ml = (2 * l + r) / 3;       long long mr = (l + 2 * r + 2) / 3;       long long vl = calc(ml);       long long vr = calc(mr);       if (vl < vr)         r = mr - 1;       else if (vl > vr)         l = ml + 1;       else {         l = ml;         r = mr - 1;       }     }     return l;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     int ansid = solve(0, n - 1);     cout << calc(ansid) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solution1(int a, int b, map<pair<int, int>, bool>& mp1,                  map<pair<int, int>, int>& mp2) {     if (a == b) {       mp2[{a, b}] = a;       return;     }     int j = a;     while (j <= b) {       if (j == a) {         if (mp1[{j + 1, b}]) {           mp2[{a, b}] = j;           solution1(j + 1, b, mp1, mp2);           break;         }       } else if (j == b) {         if (mp1[{a, j - 1}]) {           mp2[{a, b}] = j;           solution1(a, j - 1, mp1, mp2);           break;         }       } else {         if (mp1[{a, j - 1}] && mp1[{j + 1, b}]) {           mp2[{a, b}] = j;           solution1(a, j - 1, mp1, mp2);           solution1(j + 1, b, mp1, mp2);           break;         }       }       j++;     }   }   void solve() {     int a;     cin >> a;     map<pair<int, int>, bool> mp1;     map<pair<int, int>, int> mp2;     int x, y;     for (int i = 0; i < a; i++) {       cin >> x >> y;       mp1[{x, y}] = 1;     }     solution1(1, a, mp1, mp2);     vector<vector<int>> v1;     int i = 0;     for (auto x : mp1) {       if (mp2[x.first]) {         cout << x.first.first <<     << x.first.second <<     << mp2[x.first]              << endl;       }     }   }   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     int a;     cin >> a;     while (a--) {       solve();       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k;     cin >> n >> k;     vector<pair<long long int, long long int>> v;     for (long long int i = 0; i < n; i++) {       long long int x;       cin >> x;       v.push_back({x, i + 1});     }     sort(v.begin(), v.end());     vector<long long int> ans;     for (auto i : v) {       if (k >= i.first) {         ans.push_back(i.second);         k = k - i.first;       } else         break;     }     cout << ans.size() <<   n ;     for (auto i : ans) cout << i <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[200005];   map<int, int> mp;   int main() {     int n, k;     cin >> n >> k;     vector<int> v;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       v.push_back(a);     }     sort(v.begin(), v.end());     int ans = 1e9;     for (int i = 0; i < n; i++) {       int zz = v[i];       int cnt = 0;       mp[zz]++;       if (mp[zz] == k) ans = min(ans, arr[zz]);       while (zz > 0) {         zz /= 2;         mp[zz]++;         cnt++;         arr[zz] += cnt;         if (mp[zz] == k) {           ans = min(ans, arr[zz]);         }       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct A {     int a[500000];     int& operator[](const int x) { return a[x + 250000]; }   } f[2];   int a, b, k, t, m;   int main() {     scanf( %d%d%d%d , &a, &b, &k, &t);     m = 2 * k * t + 200;     f[0][a - b] = 1;     for (int i = 1; i <= t << 1; ++i) {       long long sum = 0;       for (int j = -m - k - 1; j <= -m + k - 1; ++j)         sum = (sum + f[(i & 1) ^ 1][j]) % 1000000007;       for (int j = -m; j <= m; ++j) {         sum = (sum - f[(i & 1) ^ 1][j - k - 1] + f[(i & 1) ^ 1][j + k]) %               1000000007;         f[i & 1][j] = sum;       }     }     long long ans = 0;     for (int i = 1; i <= m; ++i) ans = (ans + f[(t << 1) & 1][i]) % 1000000007;     printf( %lld n , (ans + 1000000007) % 1000000007);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void readInt(int &x) {     int neg = 1;     char ch;     while (!isdigit(ch = getchar())) {       if (ch ==  - ) {         neg = -1;       }     }     x = ch -  0 ;     while (isdigit(ch = getchar())) {       x = x * 10 + ch -  0 ;     }     x *= neg;   }   int N;   vector<bool> visited;   vector<bool> isprime;   vector<pair<int, int> > groups;   vector<int> rejected;   void solve(int X);   int main() {     int i, j;     readInt(N);     isprime.resize(N + 1, true);     visited.resize(N + 1);     for (i = 2; i <= (N >> 1); ++i) {       if (isprime[i]) {         for (j = i << 1; j <= (N >> 1); j += i) {           isprime[j] = false;         }       }     }     for (i = N >> 1; i > 1; --i) {       if (isprime[i]) {         solve(i);       }     }     for (i = rejected.size() - 1; i > 0; i -= 2) {       groups.push_back(make_pair(rejected[i], rejected[i - 1]));     }     printf( %d n , (int)groups.size());     for (auto x : groups) {       printf( %d %d n , x.first, x.second);     }     return 0;   }   void solve(int X) {     int i, aux = 0;     for (i = X * 3; i <= N; i += X) {       if (!visited[i]) {         if (aux == 0) {           aux = i;         } else {           visited[aux] = visited[i] = true;           groups.push_back(make_pair(aux, i));           aux = 0;         }       }     }     visited[X] = visited[aux] = visited[X << 1] = true;     if (aux != 0) {       groups.push_back(make_pair(X, aux));       rejected.push_back(X << 1);     } else {       groups.push_back(make_pair(X, X << 1));     }   }