malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct Node {     int x, y, t;     Node(int x = -1, int y = -1, int t = 0) : x(x), y(y) {}   };   Node a[1005];   string G[1005];   int row[1005], col[1005];   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> G[i];       G[i] =     + G[i];     }     memset(row, 0, sizeof(row));     memset(col, 0, sizeof(col));     int cnt = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (G[i][j] ==  * ) {           row[i]++;           col[i]++;           int flag = 0;           for (int k = 0; k < cnt; k++) {             if (a[k].x == i || a[k].y == j) {               flag = 1;               if (a[k].x == i)                 a[k].t = -a[k].x;               else if (a[k].y == j)                 a[k].t = a[k].y;               break;             }           }           if (!flag && cnt < 10) a[cnt++] = Node(i, j);         }       }     }     int cntr = 0, cntc = 0;     for (int i = 1; i <= n; i++) {       if (row[i] > 1) cntr++;     }     for (int i = 1; i <= m; i++) {       if (col[i] > 1) cntc++;     }     if (cnt > 2 || cntr > 1 || cntc > 1)       cout <<  NO  << endl;     else {       cout <<  YES  << endl;       if (cnt == 0)         cout << 1 <<     << 1 << endl;       else if (cnt == 1)         cout << a[0].x <<     << a[0].y << endl;       else {         if (a[0].t != 0 && a[1].t != 0) {           int x, y;           if (a[0].t > 0)             x = -a[1].t, y = a[0].t;           else             x = -a[0].t, y = a[1].t;           cout << x <<     << y << endl;         } else if (a[0].t != 0) {           if (a[0].t > 0)             cout << a[1].x <<     << a[0].y << endl;           else             cout << a[0].x <<     << a[1].y << endl;         } else if (a[1].t != 0) {           if (a[1].t < 0)             cout << a[1].x <<     << a[0].y << endl;           else             cout << a[0].x <<     << a[1].y << endl;         } else {           cout << a[0].x <<     << a[1].y << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 17;   vector<int> adj[N];   int n, k;   int cnt[N];   bool mark[N];   long long int ans = 0;   int findCentroid(int v, int n, int &ans, int par = -1) {     int sum = 1;     int mx = 0;     for (int u : adj[v]) {       if (u != par && !mark[u]) {         int x = findCentroid(u, n, ans, v);         sum += x;         mx = max(mx, x);       }     }     mx = max(mx, n - sum);     if (mx <= n / 2) {       ans = v;     }     return sum;   }   int getSubTreeSize(int v, int par = -1) {     int res = 1;     for (int u : adj[v]) {       if (par != u && !mark[u]) {         res += getSubTreeSize(u, v);       }     }     return res;   }   void addToCnt(int v, int plus, int depth = 1, int par = -1) {     if (depth > k) return;     cnt[depth] += plus;     for (int u : adj[v]) {       if (u != par && !mark[u]) {         addToCnt(u, plus, depth + 1, v);       }     }   }   void findMiddleCentroidPaths(int v, int depth = 1, int par = -1) {     if (k - depth >= 0) ans += cnt[k - depth];     for (int u : adj[v]) {       if (u != par && !mark[u]) {         findMiddleCentroidPaths(u, depth + 1, v);       }     }   }   void findBeginCentroidPaths(int v, int depth = 0, int par = -1) {     if (depth == k) {       ans++;       return;     }     for (int u : adj[v]) {       if (u != par && !mark[u]) {         findBeginCentroidPaths(u, depth + 1, v);       }     }   }   void centroidDecomposition(int root, int siz) {     int centroid;     findCentroid(root, siz, centroid);     mark[centroid] = true;     findBeginCentroidPaths(centroid);     for (int v : adj[centroid]) {       if (mark[v]) continue;       findMiddleCentroidPaths(v);       addToCnt(v, +1);     }     for (int v : adj[centroid]) {       if (mark[v]) continue;       addToCnt(v, -1);     }     for (int v : adj[centroid]) {       if (!mark[v]) {         centroidDecomposition(v, getSubTreeSize(v));       }     }     mark[centroid] = false;   }   int main() {     cin >> n >> k;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       u--;       v--;       adj[v].push_back(u);       adj[u].push_back(v);     }     centroidDecomposition(0, n);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   char a[105][105];   int main() {     ios::sync_with_stdio(false);     int n, m;     cin >> n >> m;     for (int i = 1; i <= m; i++)       for (int j = 1; j <= n; j++) cin >> a[i][j];     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) cout << a[j][i] << a[j][i];       cout << endl;       for (int j = 1; j <= m; j++) cout << a[j][i] << a[j][i];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, test, n, m, value;     cin >> test;     while (test--) {       int s = 0;       cin >> n >> m;       for (i = 1; i <= n; i++) {         cin >> value;         s += value;       }       if (s == m) {         printf( YES n );       } else {         printf( NO n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e4 + 5;   int a[maxn];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     while (m--) {       int l, r, x;       scanf( %d%d%d , &l, &r, &x);       int cnt1 = 0, cnt2 = 0;       for (int i = l; i <= r; i++) {         if (a[i] < a[x]) cnt1++;         if (a[i] == a[x]) cnt2++;       }       if (cnt1 + l - 1 < x && cnt2 + cnt1 + l - 1 >= x)         puts( Yes );       else         puts( No );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, int> getFactors(long long n) {     long long num = n;     long long sqrn = sqrt(n);     map<long long, int> ret;     for (long long i = 2; i <= sqrn; i++)       while (num % i == 0) {         ret[i]++;         num /= i;       }     if (num > 1 && num != n) ret[num]++;     return ret;   }   void solve(long long n) {     map<long long, int> factors = getFactors(n);     if (factors.size() == 0) {       cout << 1 <<   n  << 0 <<   n ;       return;     }     vector<long long> keys;     for (auto &p : factors) keys.push_back(p.first);     if (keys.size() > 2 ||         (keys.size() == 2 && (factors[keys[0]] > 1 || factors[keys[1]] > 1))) {       cout << 1 <<   n ;       cout << keys[0] * keys[1] <<   n ;       return;     }     if (keys.size() == 1 && factors[keys[0]] > 2) {       cout << 1 <<   n ;       cout << keys[0] * keys[0] <<   n ;       return;     }     cout << 2 <<   n ;   }   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     long long n;     cin >> n;     solve(n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int v[100005], u[100005], w[100005], dist[100005];   vector<pair<int, int> > edges[100005];   priority_queue<pair<int, int>, vector<pair<int, int> >,                  greater<pair<int, int> > >       pq;   int main() {     int n, m, s, l;     while (cin >> n >> m >> s) {       for (int i = 0; i < m; ++i) {         cin >> v[i] >> u[i] >> w[i];         edges[v[i]].push_back(make_pair(u[i], w[i]));         edges[u[i]].push_back(make_pair(v[i], w[i]));       }       cin >> l;       pq.push(make_pair(0, s));       memset(dist, 0x3f, sizeof(dist));       dist[s] = 0;       int c, d, nxt;       while (pq.size()) {         c = pq.top().second;         pq.pop();         for (int i = 0; i < edges[c].size(); ++i) {           nxt = edges[c][i].first;           if (dist[nxt] > dist[c] + edges[c][i].second) {             dist[nxt] = dist[c] + edges[c][i].second;             pq.push(make_pair(dist[nxt], nxt));           }         }       }       int tmp;       int cnt = 0;       for (int i = 1; i <= n; ++i)         if (dist[i] == l) ++cnt;       for (int i = 0; i < m; ++i) {         if (dist[u[i]] < l && dist[u[i]] + w[i] > l) {           tmp = dist[u[i]] + w[i];           if (dist[v[i]] + tmp - l >= l) ++cnt;         }         if (dist[v[i]] < l && dist[v[i]] + w[i] > l) {           tmp = dist[v[i]] + w[i];           if (dist[u[i]] + tmp - l > l) ++cnt;         }       }       cout << cnt <<   n ;       for (int i = 1; i <= n; ++i) edges[i].clear();       while (pq.size()) pq.pop();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1000000 + 10;   const int Mod = 998244353;   const int alp = 3;   int n, S;   int C[MAX];   int dp[MAX];   namespace opt {   int N;   int a[MAX], b[MAX], w[MAX], tmp[MAX];   int Pow(int a, int b) {     int k = 1;     for (; b; b /= 2, a = (long long)a * a % Mod)       if (b % 2 == 1) k = (long long)k * a % Mod;     return k;   }   void FFT(int *a, int S, int d) {     if (d == N) return;     FFT(a, S, d << 1);     FFT(a, S + d, d << 1);     for (int i = S, j = S, p = 0; i < N / 2; i += d, j += d << 1, p += d) {       int G = a[j], K = a[j + d];       tmp[i] = ((long long)G + (long long)w[p] * K) % Mod;       tmp[i + N / 2] = ((long long)G + (long long)w[p + N / 2] * K) % Mod;     }     for (int i = S; i < N; i += d) a[i] = tmp[i];   }   void conv(int *aa, int *bb, int *c, int n) {     for (int i = 0; i < n; ++i) a[i] = aa[i], b[i] = bb[i];     if (n <= 500) {       for (int i = 0; i < n * 2; ++i) c[i] = 0;       for (int i = 0; i < n; ++i)         for (int j = 0; j < n; ++j)           c[i + j] = (c[i + j] + (long long)a[i] * b[j]) % Mod;       for (int i = 0; i < n; ++i) a[i] = b[i] = 0;       return;     }     N = 1;     for (; N < n; N <<= 1)       ;     N <<= 1;     w[0] = 1;     w[1] = Pow(alp, (Mod - 1) / N);     for (int i = 2; i <= N; ++i) w[i] = (long long)w[i - 1] * w[1] % Mod;     FFT(a, 0, 1);     FFT(b, 0, 1);     for (int i = 0; i < N; ++i) a[i] = (long long)a[i] * b[i] % Mod;     for (int i = 0; i < N; ++i) b[i] = a[i ? (N - i) : 0];     FFT(b, 0, 1);     int InvN = Pow(N, Mod - 2);     for (int i = 0; i < N; ++i) {       c[i] = (long long)b[i] * InvN % Mod;       a[i] = b[i] = 0;     }   }   }  // namespace opt   int a[MAX], b[MAX], c[MAX];   void solve(int l, int r) {     if (r == l + 1) return;     int mid = (l + r) / 2;     solve(l, mid);     int i;     int need = r - l;     for (long long i = 0; i < need; i++) a[i] = b[i] = 0;     if (l > 0) {       for (long long i = 0; i < mid - l; i++) a[i] = dp[i + l];       for (long long i = 0; i < need; i++) b[i] = dp[i];       opt::conv(a, b, c, need);       for (long long i = 0; i < need; i++) {         c[i] *= 2;         if (c[i] >= Mod) c[i] -= Mod;       }     } else {       for (long long i = 0; i < mid - l; i++) a[i] = b[i] = dp[i + l];       opt::conv(a, b, c, need);     }     for (long long i = 0; i < need; i++) {       a[i] = c[i];       b[i] = C[i];     }     opt::conv(a, b, c, need);     for (long long i = mid; i < r; i++) {       dp[i] += c[i - l];       if (dp[i] >= Mod) dp[i] -= Mod;     }     solve(mid, r);   }   int main() {     int i;     scanf( %d%d , &n, &S);     for (long long i = 1; i <= n; i++) {       int a;       scanf( %d , &a);       C[a] = 1;     }     int N = 1;     for (; N <= S; N *= 2)       ;     dp[0] = 1;     solve(0, N);     for (long long i = 1; i <= S; i++) printf( %d n , dp[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long aX[100001];   long long aY[100001];   int main() {     long long n, k;     cin >> n >> k;     long long x, y;     cin >> x >> y;     long long mod = n * 2;     for (int i = 0; i < n; i++) cin >> aX[i] >> aY[i];     k = k % mod;     long long cx = 0, cy = 0;     for (int i = 1; i <= k; i++) {       cx = 2 * aX[(i - 1) % n] - cx;       cy = 2 * aY[(i - 1) % n] - cy;     }     if (k % 2 == 1)       cx -= x, cy -= y;     else       cx += x, cy += y;     cout << cx <<     << cy << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int arr[100005];   long long int l1[100005];   long long int l2[100005];   long long int d[100005];   long long int e[100005];   long long int tree[100005];   long long int tree2[100005];   void update(long long int idx, long long int val, long long int n) {     while (idx <= n) {       tree[idx] += val;       idx += (idx & -idx);     }   }   long long int read(long long int idx) {     long long int sum = 0;     while (idx > 0) {       sum += tree[idx];       idx -= (idx & -idx);     }     return sum;   }   void update2(long long int idx, long long int val, long long int n) {     while (idx <= n) {       tree2[idx] += val;       idx += (idx & -idx);     }   }   long long int read2(long long int idx) {     long long int sum = 0;     while (idx > 0) {       sum += tree2[idx];       idx -= (idx & -idx);     }     return sum;   }   int corona(int x, int y) {     long long int s = 0, s1, s2;     for (int i = x + 1; i <= y; i++) {       if (l1[i] < l1[i - 1]) {         s++;         break;       }     }     if (s == 0)       return abs(y - x) + 1;     else {       s1 = corona(x, (x + y) / 2);       s2 = corona(((x + y) / 2) + 1, y);       return max(s1, s2);     }   }   int main() {     long long int n, a, q, b, t, c, m, k, x, y, x3 = 0, x4 = 0, x5 = 0;     string s3, s4;     cin >> t;     while (t--) {       cin >> n >> a >> b >> c;       cin >> s3;       for (int i = 0; i < s3.size(); i++) {         if (s3[i] ==  R ) {           if (b > 0) {             b--;             x3++;             l1[i] =  P ;           }         } else if (s3[i] ==  P ) {           if (c > 0) {             c--;             x3++;             l1[i] =  S ;           }         } else if (s3[i] ==  S ) {           if (a > 0) {             a--;             x3++;             l1[i] =  R ;           }         }       }       if (x3 >= ceil(n / 2.0)) {         cout <<  YES n ;         for (int i = 0; i < s3.size(); i++) {           if (l1[i] == 0 && a > 0) {             l1[i] =  R ;             a--;           } else if (l1[i] == 0 && b > 0) {             l1[i] =  P ;             b--;           } else if (l1[i] == 0 && c > 0) {             l1[i] =  S ;             c--;           }           s4 += (char)l1[i];         }         cout << s4 << endl;       } else         cout <<  NO n ;       x3 = 0;       s4 =   ;       memset(l1, 0, sizeof l1);     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int i, A[30], k = 0, B[7];     for (i = 1; i <= 24; i++) {       scanf( %d , &A[i]);     }     for (i = 1; i <= 6; i++) {       if (A[4 * i] == A[4 * i - 1] && A[4 * i - 2] == A[4 * i - 3] &&           A[4 * i] == A[4 * i - 2]) {         B[i] = 1;       } else         B[i] = 0;     }     if (B[1] == 1 && B[2] == 0 && B[3] == 1 && B[4] == 0 && B[5] == 0 &&         B[6] == 0) {       if (A[13] == A[14] && A[13] == A[7] && A[8] == A[7] && A[5] == A[6] &&           A[5] == A[19] && A[19] == A[20] && A[17] == A[18] && A[23] == A[24] &&           A[18] == A[24])         k = 1;       else if (A[13] == A[14] && A[13] == A[23] && A[23] == A[24] &&                A[5] == A[6] && A[5] == A[15] && A[15] == A[16] &&                A[17] == A[18] && A[18] == A[7] && A[7] == A[8])         k = 1;     }     if (1 == B[5] && B[4] == 1 && B[1] == 0 && B[2] == 0 && B[3] == 0 &&         B[6] == 0) {       if (A[1] == A[3] && A[3] == A[6] && A[8] == A[6] && A[5] == A[7] &&           A[7] == A[10] && A[10] == A[12] && A[9] == A[11] && A[9] == A[21] &&           A[23] == A[21])         k = 1;       else if (A[2] == A[4] && A[2] == A[5] && A[5] == A[7] && A[8] == A[6] &&                A[6] == A[9] && A[9] == A[11] && A[10] == A[12] &&                A[12] == A[22] && A[22] == A[24])         k = 1;     }     if (B[1] == 0 && B[2] == 1 && B[3] == 0 && B[4] == 0 && B[5] == 0 &&         B[6] == 1) {       if (A[1] == A[2] && A[1] == A[14] && A[14] == A[16] && A[13] == A[15] &&           A[15] == A[9] && A[9] == A[10] && A[11] == A[12] && A[12] == A[19] &&           A[17] == A[19])         k = 1;       else if (A[3] == A[4] && A[3] == A[13] && A[13] == A[15] &&                A[14] == A[16] && A[14] == A[11] && A[11] == A[12] &&                A[17] == A[19] && A[19] == A[1] && A[1] == A[2])         k = 1;     }     if (k == 1)       printf( YES );     else       printf( NO );     return 0;   }
#include <bits/stdc++.h>   double pi = 3.1415926535897931159979635;   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long cf = 0, cs = 0, c47 = 0, c74 = 0;     string a;     cin >> a;     long long s = a.size();     for (int i = 0; i < s; i++) {       if (a[i] ==  4 ) {         cf++;         if (a[i - 1] ==  7  && i > 0) c74++;       } else if (a[i] ==  7 ) {         cs++;         if (a[i - 1] ==  4  && i > 0) c47++;       }     }     if (cf == 0 && cs == 0)       cout <<  -1 n ;     else       s = max(c47, max(c74, max(cf, cs)));     if (s == cf)       cout <<  4 n ;     else if (s == cs)       cout <<  7 n ;     else if (s == c47)       cout <<  47 n ;     else if (s == c74)       cout <<  74 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int heights(long long int n) {     long long int count = 0, m, k;     for (long long int x = 1; x <= n; x++) {       m = 3 * x * x + x;       if (m > 2 * n)         break;       else {         k = x + n;         if (k % 3 == 0) count++;       }     }     return count;   }   int main() {     long long int n;     cin >> n;     cout << heights(n);     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int w;   string ch(string s, char x, string b) {     int n = s.size();     bool cx = 0;     char mina =  z ;     for (int i = 0; i < n; i++) {       if (s[i] == x && b[i] > s[i]) {         cx = 1;         mina = min(mina, b[i]);       }     }     if (!cx) {       return s;     }     w++;     for (int i = 0; i < n; i++) {       if (s[i] == x) s[i] = mina;     }     return s;   }   void solve() {     w = 0;     int n;     cin >> n;     string a, b;     cin >> a >> b;     for (int i = 0; i < n; i++) {       if (b[i] < a[i]) {         cout <<  -1 n ;         return;       }     }     for (int i = 0; i < 20; i++) {       a = ch(a, ((char)i + 97), b);     }     cout << w <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t) {       t--;       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int SIZE = 84;   const int VERTS = SIZE * SIZE;   int n, m;   int v, s, t;   int pict[SIZE][SIZE];   const int dir[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};   inline bool good(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }   struct Edge {     int a, b;     int flow;     int cap, cost;     int anti;   };   vector<Edge> edges;   vector<int> nbr[VERTS];   void AddEdge(int a, int b, int cap, int cost) {     Edge e1;     e1.a = a;     e1.b = b;     e1.flow = 0;     e1.cap = cap;     e1.cost = cost;     e1.anti = edges.size() + 1;     Edge e2;     e2.a = b;     e2.b = a;     e2.flow = 0;     e2.cap = 0;     e2.cost = -cost;     e2.anti = edges.size();     nbr[a].push_back(edges.size());     nbr[b].push_back(edges.size() + 1);     edges.push_back(e1);     edges.push_back(e2);   }   bool used[VERTS];   int dist[VERTS];   int father[VERTS];   int deq[VERTS];   bool Dijkstra(int &allFlow, int &allCost) {     memset(dist, 63, sizeof(dist));     memset(father, -1, sizeof(father));     memset(used, false, sizeof(used));     dist[s] = 0;     int l = 0, r = 1;     deq[0] = s;     while (l < r) {       int best = deq[l++];       used[best] = true;       for (int i = 0; i < nbr[best].size(); i++) {         int eidx = nbr[best][i];         const Edge &e = edges[eidx];         if (e.flow == e.cap) continue;         int newd = dist[best] + e.cost;         if (dist[e.b] > newd) {           bool first = dist[e.b] > 1000000000;           dist[e.b] = newd;           father[e.b] = eidx;           if (used[e.b]) {             used[e.b] = false;             deq[--l] = e.b;           }           if (first) deq[r++] = e.b;         }       }     }     if (!used[t]) return false;     allFlow++;     int curr = t;     while (curr != s) {       int eidx = father[curr];       Edge &e = edges[eidx];       int pp = e.a;       e.flow++;       edges[e.anti].flow--;       allCost += e.cost;       curr = pp;     }     return true;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) scanf( %d , &pict[i][j]);     s = n * m;     t = n * m + 1;     v = n * m + 2;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if ((i + j) & 1) {           AddEdge(s, i * m + j, 1, 0);           for (int d = 0; d < 4; d++) {             int ni = i + dir[d][0];             int nj = j + dir[d][1];             if (!good(ni, nj)) continue;             AddEdge(i * m + j, ni * m + nj, 1, pict[i][j] != pict[ni][nj]);           }         } else           AddEdge(i * m + j, t, 1, 0);       }     int tflow = 0, tcost = 0;     while (Dijkstra(tflow, tcost))       ;     printf( %d n , tcost);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   const double oula = 0.57721566490153286060651209;   using namespace std;   map<long long, string> mp;   int main() {     std::ios::sync_with_stdio(false);     long long n;     cin >> n;     long long nn = sqrt(n);     string tmp;     for (long long i = 2; i <= nn; i++) {       long long num = i * i;       int co = 2;       while (num <= n) {         tmp = to_string(i) +  ^  + to_string(co);         if (!mp.count(num)) mp[num] = to_string(num);         if (mp[num].size() > tmp.size()) mp[num] = tmp;         co++;         num *= i;       }     }     string ans = to_string(n);     map<long long, string>::iterator it;     for (it = mp.begin(); it != mp.end(); it++) {       tmp =   ;       long long a = n / it->first, b = n % it->first;       if (a > 1) {         if (mp.count(a))           tmp = mp[a];         else           tmp = to_string(a);         tmp +=  * ;       }       tmp += it->second;       if (b) tmp = tmp +  +  + (mp.count(b) ? mp[b] : to_string(b));       if (ans.size() > tmp.size()) ans = tmp;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int N;   int axor[1 << 16];   int degree[1 << 16], s[1 << 16];   vector<pair<int, int>> edge;   set<pair<int, int>> q;   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) {       scanf( %d %d , &degree[i], &s[i]);       q.insert({degree[i], i});     }     for (int i = 0; i < N; i++) {       int x, y;       x = (*q.begin()).second;       if (degree[x] == 0) {         q.erase({degree[x], x});         continue;       }       if (degree[x] > 1)         while (true)           ;       y = s[x] ^ axor[x];       axor[x] ^= y;       if (axor[x] != s[x])         while (true)           ;       axor[y] ^= x;       q.erase({degree[y], y});       q.erase({degree[x], x});       degree[x]--;       degree[y]--;       q.insert({degree[y], y});       if (x == y)         while (true)           ;       edge.push_back({x, y});     }     for (int i = 0; i < N; i++)       if (axor[i] != s[i])         while (true)           ;     printf( %d n , edge.size());     for (auto i : edge) {       printf( %d %d n , i.first, i.second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long int gcd(unsigned long long int a, unsigned long long int b) {     unsigned long long int max = a > b ? a : b;     unsigned long long int min = a < b ? a : b;     if (max % min == 0) return min;     if (max % min == 1) return 1;     return gcd(min, max % min);   }   int main() {     int flag = 0;     unsigned long long int l, r;     cin >> l >> r;     if (l - r < 2) {       cout <<  -1 ;       return 0;     }     unsigned long long int i, j, k;     for (i = l; i <= r - 2; i++) {       for (j = i + 1; j <= r - 1; j++) {         if (gcd(i, j) == 1) {           for (k = j + 1; k <= r; k++) {             if (gcd(j, k) == 1 && gcd(i, k) != 1) {               flag = 1;               cout << i <<     << j <<     << k;               break;             }           }         }         if (flag == 1) break;       }       if (flag == 1) break;     }     if (flag == 0) cout <<  -1 ;     return 0;   }