malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   template <class T>   inline T biton(T n, T pos) {     return n | ((T)1 << pos);   }   template <class T>   inline T bitoff(T n, T pos) {     return n & ~((T)1 << pos);   }   template <class T>   inline T ison(T n, T pos) {     return (bool)(n & ((T)1 << pos));   }   template <class T>   inline T gcd(T a, T b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   inline int nxt() {     int aaa;     scanf( %d , &aaa);     return aaa;   }   inline long long lxt() {     long long aaa;     scanf( %lld , &aaa);     return aaa;   }   inline double dxt() {     double aaa;     scanf( %lf , &aaa);     return aaa;   }   template <class T>   inline T bigmod(T p, T e, T m) {     T ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % m;       p = (p * p) % m;     }     return (T)ret;   }   template <class T>   istream& operator>>(istream& is, vector<T>& input) {     for (T& in : input) is >> in;     return is;   }   template <class T>   ostream& operator<<(ostream& os, const vector<T>& input) {     bool isFirst = true;     for (T out : input) {       if (isFirst) {         os << out;         isFirst = false;       } else         os <<     << out;     }     return os;   }   void solve() {     int r = nxt(), g = nxt(), b = nxt(), w = nxt();     if (r == 0 || g == 0 || b == 0) {       int cnt = 0;       if (r & 1) cnt++;       if (g & 1) cnt++;       if (b & 1) cnt++;       if (w & 1) cnt++;       if (cnt > 1) {         cout <<  No n ;         return;       }       cout <<  Yes n ;       return;     }     int mn = min({r, g, b});     r -= mn, g -= mn, b -= mn;     w += (mn * 3);     for (int i = 0; i < min(mn, 5); i++) {       r += i;       g += i;       b += i;       w -= (i * 3);       int cnt = 0;       if (r & 1) cnt++;       if (g & 1) cnt++;       if (b & 1) cnt++;       if (w & 1) cnt++;       if (cnt <= 1) {         cout <<  Yes n ;         return;       }     }     cout <<  No n ;   }   int main() {     cout.setf(ios::fixed);     cout.precision(10);     int tc = nxt();     while (tc--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const int INF = 1000000000;   int s(int first) {     int r = 0;     while (first) {       r += first % 10;       first /= 10;     }     return r;   }   int main() {     long long m;     cin >> m;     long long b = 1000 * 1000 * 1000;     long long r = b * b;     r = 9 * r % m;     r = 9 * r % m;     r = (m - (r + 1) % m) % m;     cout << 1 + r <<     << b * b + r << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[2000], y[2000], c[2000];   vector<int> poss;   multiset<int> xx[2000];   vector<pair<int, int> > events;   map<pair<int, int>, int> M;   long long int sum = 0, ans = 0;   int update(int e, int m) {     if (e < 0) return 0;     auto it = M.upper_bound(make_pair(e, 2e9));     it--;     if (it->first.second != e) {       pair<int, int> p = it->first;       int v = it->second;       M.erase(it);       M[make_pair(p.first, e)] = v;       M[make_pair(e + 1, p.second)] = v;     }     it = M.upper_bound(make_pair(e, 2e9));     it--;     if (it->second < m) return 0;     pair<int, int> p = make_pair(e, e);     while (it->second >= m) {       p.first = it->first.first;       sum -= (long long int)(it->first.second - it->first.first + 1) * it->second;       it = M.erase(it);       if (it == M.begin())         break;       else         it--;     }     M[p] = m;     sum += (long long int)(p.second - p.first + 1) * m;     return 0;   }   int main() {     int i;     int n, k, L;     scanf( %d %d %d , &n, &k, &L);     poss.push_back(-1), poss.push_back(L);     for (i = 0; i < n; i++) {       scanf( %d %d %d , &x[i], &y[i], &c[i]), c[i]--;       poss.push_back(y[i]);     }     sort(poss.begin(), poss.end());     poss.resize(unique(poss.begin(), poss.end()) - poss.begin());     int j;     for (i = 1; i < poss.size(); i++) {       int yy = poss[i] - poss[i - 1];       for (j = 0; j < n; j++) {         if (y[j] > poss[i - 1]) {           events.push_back(make_pair(y[j], j));           xx[c[j]].insert(x[j]);         }       }       M.clear();       M[make_pair(0, L - 1)] = L, sum = (long long int)L * L;       for (j = 0; j < k; j++) {         if (xx[j].empty()) break;         int p = -1;         for (auto it = xx[j].begin(); it != xx[j].end(); it++)           update(*it - 1, p + 1), p = *it;         update(L - 1, p + 1);       }       if (j < k) break;       sort(events.begin(), events.end(), greater<pair<int, int> >());       int l = L;       for (j = 0; j < events.size(); j++) {         int u = events[j].second;         long long int nn = (long long int)yy * (l - events[j].first);         nn %= 1000000007;         ans += nn * (sum % 1000000007), ans %= 1000000007;         auto it = xx[c[u]].lower_bound(x[u]);         it = xx[c[u]].erase(it);         int a = (it == xx[c[u]].end()) ? L - 1 : *it - 1;         int b = (it == xx[c[u]].begin()) ? 0 : *(--it) + 1;         update(a, b);         if (xx[c[u]].empty()) break;         l = events[j].first;       }       for (j = 0; j < k; j++) xx[j].clear();       events.clear();     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long xpow(long long a, long long b) {     if (!b) return 1;     if (b == 1) return a;     if (b & 1) {       return ((a * xpow(a, b - 1)));     } else {       long long p = xpow(a, b / 2);       return ((p * p));     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long w, m;     cin >> w >> m;     vector<long long> v(102, 0);     long long x = m, k = 0;     while (x) {       v[k] = x % w;       x /= w;       k++;     }     bool f = 0;     for (long long i = 0; i < 102; i++) {       if (v[i] == 1 || !v[i]) {         continue;       } else {         if (v[i] == w - 1 || v[i] == w) {           v[i + 1]++;         } else {           cout <<  NO ;           f = 1;           break;         }       }     }     if (!f) cout <<  YES ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[5111], y, yy;   int lmax[5111], cnt[5111], llmax;   int N, i, j, k;   int main() {     scanf( %d , &N);     for (i = 1; i <= N; i++) scanf( %I64d , &a[i]);     for (llmax = 0, i = 1; i <= N; i++) {       lmax[i] = 0;       cnt[i] = 0;       y = a[i];       while ((y & 1) == 0) {         y >>= 1;         cnt[i]++;       }       for (j = i - 1; j >= 1; j--) {         k = i - j;         if (k > cnt[i]) {           if (a[j] % y == 0 && lmax[j] > lmax[i]) lmax[i] = lmax[j];         } else {           yy = y << (cnt[i] - k);           if (a[j] % yy == 0 && ((a[j] / yy) & 1 == 1) && lmax[j] > lmax[i])             lmax[i] = lmax[j];         }       }       lmax[i]++;       if (lmax[i] > llmax) llmax = lmax[i];     }     printf( %d n , N - llmax);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int v[200001], i, n, poz;   bool cmp(int a, int b) { return a < b; }   int main() {     cin >> n;     for (i = 1; i <= n; i++) cin >> v[i];     sort(v + 1, v + n + 1, cmp);     poz = 1;     for (i = 1; i <= n; i++) {       if (v[i] >= poz) poz++;     }     cout << poz - 1;   }
#include <bits/stdc++.h>   using namespace std;   void dropAny(const vector<int> &a, int offset, vector<bool> &used) {     vector<int> next(used.size(), a.size());     for (int i = int(a.size()) - 1; i >= offset; --i) {       next[a[i]] = i;     }     int best = -1;     for (int i = 0; i < (int)used.size(); ++i) {       if (!used[i]) {         continue;       }       if (best == -1 || next[best] < next[i]) {         best = i;       }     }     used[best] = false;     ;   }   struct RangeTree {     int kk;     vector<pair<int, int> > b;     RangeTree(int n) {       kk = 1;       while (kk < n) {         kk *= 2;       }       b.assign(2 * kk + 10, pair<int, int>(-1, -1));     }     int getMaxPos() { return b[1].second; }     int get(int pos) { return b[pos + kk].first; }     void set(int pos, int val) {       ;       int t = pos + kk;       b[t] = pair<int, int>(val, pos);       while (t > 1) {         t /= 2;         b[t] = max(b[2 * t], b[2 * t + 1]);       }     }   };   int main() {     int n, k;     scanf( %d%d , &n, &k);     int maxA = 0;     vector<int> a(n);     vector<pair<int, int> > z(n);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);       z[i] = pair<int, int>(a[i], i);       maxA = max(maxA, a[i] + 1);     }     sort(z.begin(), z.end());     vector<int> next(n, n);     for (int i = 1; i < int(z.size()); ++i) {       if (z[i - 1].first == z[i].first) {         next[z[i - 1].second] = z[i].second;       }     }     for (int i = 0; i < n; ++i) {       ;     };     RangeTree tree(maxA);     int cnt = 0;     int ans = 0;     for (int i = 0; i < n; ++i) {       if (tree.get(a[i]) == -1) {         ;         if (cnt == k) {           int pos = tree.getMaxPos();           ;           tree.set(pos, -1);           cnt--;         }         tree.set(a[i], next[i]);         ans++;         cnt++;       } else {         tree.set(a[i], next[i]);       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int MAX = 1e3 + 5;   const int MOD = 1e9 + 7;   const int64_t INF = INT_MAX;   const int64_t _INF = INT_MIN;   int k, n;   int h[MAX];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> k;     while (k--) {       cin >> n;       for (int i = 1; i <= n; i++) cin >> h[i];       int ans = 0;       sort(h + 1, h + n + 1);       for (int i = 1; i <= n; i++) ans = max(ans, min(h[n - i + 1], i));       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long fac[200001];   long long inv[200001];   long long modexp(long long b, long long e) {     long long ans = 1;     while (e > 0) {       if (e & 1) {         ans = (ans * b) % mod;       }       b = (b * b) % mod;       e >>= 1;     }     return ans;   }   long long comb(long long n, long long k) {     long long ans = (fac[n] * inv[k]) % mod;     ans = (ans * inv[n - k]) % mod;     return ans;   }   int main() {     fac[0] = fac[1] = 1;     inv[0] = inv[1] = 1;     for (int i = 2; i <= 200000; i++) {       fac[i] = (fac[i - 1] * i) % mod;       inv[i] = modexp(fac[i], mod - 2);     }     int n, k;     cin >> n >> k;     vector<pair<int, int> > list;     for (int i = 1; i <= n; i++) {       int a, b;       cin >> a >> b;       list.push_back(make_pair(a, 1));       list.push_back(make_pair(b + 1, -1));     }     sort(list.begin(), list.end());     int maintain = 0;     long long ans = 0;     int selisih;     for (int i = 0; i < list.size(); i++) {       if (i > 0 && list[i].first != list[i - 1].first) {         if (maintain >= k) {           ans += comb(maintain, k) * (list[i].first - selisih);           ans %= mod;         }       }       maintain += list[i].second;       selisih = list[i].first;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long n, i, a, b, x, y, o, z, p, q, sum, c;   int main() {     cin >> n;     vector<long long> v;     for (i = 0; i < n; i++) {       cin >> x;       if (x == 0)         o++;       else         v.push_back(x);     }     sort(v.begin(), v.end());     a = 0;     b = v.size() - 1;     sum += o * (o - 1) / 2;     if (v.size() > 1) {       while (a < b) {         if (v[a] > 0 || v[b] < 0)           break;         else {           if (v[a] + v[b] < 0)             a++;           else if (v[a] + v[b] > 0)             b--;           else {             p = 1;             q = 1;             x = v[a];             a++;             y = v[b];             b--;             while (1) {               if (v[a] == x) {                 p++;                 a++;               } else                 break;             }             while (1) {               if (v[b] == y) {                 q++;                 b--;               } else                 break;             }             sum += p * q;           }         }       }     }     cout << sum;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4 * 1000 * 100 + 10;   int n, c[N], st[N], en[N], who[N], TM;   vector<int> adj[N];   void dfs(int root, int par = 0) {     st[root] = TM++;     who[st[root]] = root;     for (auto u : adj[root])       if (u ^ par) dfs(u, root);     en[root] = TM;   }   struct Node {     int lazy = -1;     long long lol = 0;     void merge(Node L, Node R) { lol = L.lol | R.lol; }     void add(int x) {       if (x == -1) return;       lazy = x;       lol = 1LL << x;     }   } seg[N << 2];   void push(int root) {     seg[root << 1].add(seg[root].lazy), seg[root << 1 | 1].add(seg[root].lazy);     seg[root].lazy = -1;   }   void build(int l = 0, int r = n, int root = 1) {     if (l + 1 == r) {       seg[root].add(c[who[l]]);       return;     }     int mid = l + r >> 1;     build(l, mid, root << 1), build(mid, r, root << 1 | 1);     seg[root].merge(seg[root << 1], seg[root << 1 | 1]);   }   void upd(int s, int e, int w, int l = 0, int r = n, int root = 1) {     if (s <= l && e >= r) {       seg[root].add(w);       return;     }     if (s >= r || e <= l) return;     push(root);     int mid = l + r >> 1;     upd(s, e, w, l, mid, root << 1), upd(s, e, w, mid, r, root << 1 | 1);     seg[root].merge(seg[root << 1], seg[root << 1 | 1]);   }   Node get(int s, int e, int l = 0, int r = n, int root = 1) {     if (s <= l && e >= r) return seg[root];     if (s >= r || e <= l) return seg[0];     push(root);     int mid = l + r >> 1;     Node res;     res.merge(get(s, e, l, mid, root << 1), get(s, e, mid, r, root << 1 | 1));     return res;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int Q;     cin >> n >> Q;     for (int i = 1; i <= n; i++) cin >> c[i];     for (int i = 1, v, u; i < n; i++) {       cin >> v >> u;       adj[v].push_back(u);       adj[u].push_back(v);     }     dfs(1);     build();     while (Q--) {       int t, v, c;       cin >> t;       if (t == 1) {         cin >> v >> c;         upd(st[v], en[v], c);       } else {         cin >> v;         cout << __builtin_popcountll(get(st[v], en[v]).lol) <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int num = 0, num1, num2;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  A ) {         num1 = 0;         for (int j = 0; j < i; j++)           if (s[j] ==  Q ) num1++;         num2 = 0;         for (int j = i + 1; j < s.size(); j++)           if (s[j] ==  Q ) num2++;         num += (num1 * num2);       }     }     cout << num;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int o[100001];   long long int sum[100001];   long long int dp[100001][2];   long long int dp1[100001][2];   long long int on[100001];   long long int a[100001];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       scanf( %lld , &a[i]);     }     long long int max1 = 0;     memset(dp, 0, sizeof dp);     dp[0][0] = 0;     dp[0][1] = 0;     for (int i = 1; i < n; i++) {       if (a[i - 1] == 1)         dp[i][1] = 0;       else {         dp[i][1] = dp[i - 1][1] + a[i - 1] - (a[i - 1] & 1);       }       dp[i][0] = max(dp[i][1], a[i - 1] + (a[i - 1] & 1) - 1 + dp[i - 1][0]);       max1 = max(dp[i][1], max(max1, dp[i][0]));     }     memset(dp1, 0, sizeof dp1);     dp1[n - 1][0] = 0;     dp1[n - 1][1] = 0;     for (int i = n - 2; i >= 0; i--) {       if (a[i] == 1) {         dp1[i][1] = 0;       } else {         dp1[i][1] = dp1[i + 1][1] + a[i] - (a[i] & 1);       }       dp1[i][0] = max(dp1[i][1], a[i] + (a[i] & 1) - 1 + dp1[i - 1][0]);       max1 = max(dp1[i][1], max(max1, dp1[i][0]));     }     for (int i = 0; i < n; i++) {       max1 = max(max1, max(dp[i][0] + dp1[i][1], dp1[i][0] + dp[i][1]));     }     cout << max1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int a[maxn];   int n, x, k;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> x >> k;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     long long ans = 0;     for (int i = 0; i < n; i++) {       long long l = (a[i] - 1) / x;       long long r = l + k;       ans += (long long)(lower_bound(a, a + n, (r + 1) * x) -                          lower_bound(a, a + n, max(r * x, (long long)a[i])));     }     cout << ans << endl;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   int t,f,i,j,p,q,x,y,dx[128],dy[128];   char s[5008];   int main() {       for(dx[ L ]=-(dx[ R ]=1),dy[ D ]=-(dy[ U ]=1),scanf( %d ,&t);               t--; f?0:printf( 0 0 n ))           for(scanf( %s ,s),f=i=p=q=0; s[i]; x||y?++i:                   (printf( %d %d n ,p,q),f=i=strlen(s)))               for(p+=dx[s[i]],q+=dy[s[j=i]],j=x=y=0; s[j]; x+=dx[s[j]],                       y+=dy[s[j]],x==p&&y==q?(x-=dx[s[j]],y-=dy[s[j]]):0,++j);       exit(0);   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout << fixed;     int a1, a2;     cin >> a1 >> a2;     int minutes = 0;     while (a1 > 0 && a2 > 0) {       if (a1 == 1 && a2 == 1) {         break;       }       if (a1 <= 2) {         a1 += 1;         a2 -= 2;       } else if (a2 <= 2) {         a2 += 1;         a1 -= 2;       } else {         a1 += 1;         a2 -= 2;       }       minutes++;     }     cout << minutes;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300 * 1000 + 100;   const long long mod = 1e9 + 7;   const long long inf = 2 * 1e18;   int n, m, k;   int ans = -1;   char c[maxn];   vector<int> adj[maxn];   int cnt[30][maxn];   int d_in[maxn];   bool mark[maxn], mark1[maxn];   void dfs(int v) {     if (mark[v]) {       cout << -1;       exit(0);     } else       mark[v] = true;     if (mark1[v]) {       mark[v] = false;       return;     } else       mark1[v] = true;     for (auto x : adj[v]) {       dfs(x);       for (int j = 0; j <= 26; j++) {         cnt[j][v] = max(cnt[j][v], cnt[j][x]);         ans = max(ans, cnt[j][v]);       }     }     cnt[c[v] -  a ][v]++;     ans = max(ans, cnt[c[v] -  a ][v]);     mark[v] = false;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     string s;     cin >> s;     for (int i = 1; i <= n; i++) c[i] = s[i - 1];     for (int i = 1; i <= m; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       d_in[v]++;     }     for (int i = 1; i <= n; i++) {       dfs(i);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   bool is_prime(int n) {     if (n < 2) {       return false;     }     for (int d = 2; d * d <= n; d++) {       if (n % d == 0) {         return false;       }     }     return true;   }   int main() {     int n;     std::cin >> n;     int m = n, cross = 0;     while (!is_prime(m + cross)) {       cross++;     }     assert(2 * cross <= n);     std::cout << m + cross << std::endl;     for (int i = 1; i <= n; i++) {       std::cout << i <<     << i % n + 1 << std::endl;     }     int jump = std::max(2, cross);     for (int i = 1; i <= cross; i++) {       assert(i < 1 + jump);       assert(i + jump <= n);       std::cout << i <<     << i + jump << std::endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   const long long OO = 1LL << 61;   const long long MOD = 10007;   const int maxn = 100000 + 5;   long long dp[(1 << (16)) + 6];   int ans[20], g[20], mark[20], full;   int main() {     int n, m, a, b, f;     long long y;     while (scanf( %d %I64d %d , &n, &y, &m) != EOF) {       memset(g, 0, sizeof g);       memset(ans, -1, sizeof ans);       memset(mark, 0, sizeof mark);       for (int i = 0; i < m; i++) {         scanf( %d %d , &a, &b);         g[--b] |= (1 << (--a));       }       f = 1;       y -= 2001;       full = (1 << (n)) - 1;       for (int i = 0; i < n && f; i++) {         for (ans[i] = 0;; ans[i]++)           if (!mark[ans[i]]) {             if (ans[i] >= n) {               f = 0;               puts( The times have changed );               break;             }             memset(dp, 0, sizeof dp);             dp[0] = 1;             for (int s = 0; s <= full; s++)               if (dp[s]) {                 int cnt = __builtin_popcount(s);                 for (int k = 0; k < n; k++)                   if (!(s & (1 << (k))))                     if ((ans[k] == -1 || ans[k] == cnt) && ((s & g[k]) == g[k]))                       dp[s | (1 << (k))] += dp[s];               }             if (y >= dp[full])               y -= dp[full];             else {               mark[ans[i]] = 1;               break;             }           }       }       if (!f) continue;       for (int i = 0; i < n; i++)         printf( %d%c , ans[i] + 1, i + 1 == n ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int s[105];   int main() {     int n, x;     while (cin >> n >> x) {       for (int i = 0; i < n; i++) {         cin >> s[i];       }       sort(s, s + n);       int index = lower_bound(s, s + n, x) - s;       if (s[index] == x) {         cout << 1 + x - index << endl;       } else {         cout << x - index << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[111111];   int b[111111];   int main() {     int n, i, j;     vector<pair<int, int> > v;     scanf( %d , &n);     a[0] = a[1] = 1;     for (i = 2; i <= n; i++) {       if (a[i] == 0) {         for (j = i * 2; j <= n; j += i) a[j] = 1;       }     }     for (i = n / 2; i > 0; i--) {       if (a[i] == 0) {         vector<int> w;         for (j = i; j <= n; j += i) {           if (b[j] == 0) w.push_back(j);         }         if (w.size() % 2 == 0) {           for (j = 0; j < w.size(); j += 2) {             v.push_back(make_pair(w[j], w[j + 1]));             b[w[j]] = b[w[j + 1]] = 1;           }         } else {           for (j = 0; j < w.size(); j++) {             if (w[j] % 2 == 0) {               swap(w[j], w.back());               break;             }           }           for (j = 0; j < w.size() - 1; j += 2) {             v.push_back(make_pair(w[j], w[j + 1]));             b[w[j]] = b[w[j + 1]] = 1;           }         }       }     }     printf( %d n , v.size());     for (i = 0; i < v.size(); i++) printf( %d %d n , v[i].first, v[i].second);     return 0;   }