malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     cin >> t;     while (t--) {       vector<string> s(9);       for (long long int i = 0; i < 9; i++) {         cin >> s[i];       }       s[0][0] = s[0][1];       s[1][3] = s[1][4];       s[2][6] = s[2][7];       s[3][1] = s[3][2];       s[4][4] = s[4][5];       s[5][7] = s[5][8];       s[6][2] = s[6][1];       s[7][5] = s[7][4];       s[8][8] = s[8][7];       for (long long int i = 0; i < 9; i++) {         cout << s[i] << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   struct Node {     int l, r;     pair<int, int> v;     int mid() { return (l + r) >> 1; }   };   struct HNode {     int m, p;     long long x, y, r, d;     bool operator<(const HNode &cur) const { return d < cur.d; }   };   Node tree[4 * 250005];   HNode hook[250005];   int n;   vector<int> has;   void push_up(int pos) {     tree[pos].v = min(tree[pos << 1].v, tree[pos << 1 | 1].v);   }   void build(int pos, int l, int r) {     tree[pos].l = l;     tree[pos].r = r;     if (l == r) {       tree[pos].v = make_pair(hook[l].m, l);       return;     }     int mid = tree[pos].mid();     build(pos << 1, l, mid);     build(pos << 1 | 1, mid + 1, r);     push_up(pos);   }   void update(int pos, int idx, int mass) {     if (tree[pos].l == tree[pos].r) {       tree[pos].v.first = mass;       return;     }     int mid = tree[pos].mid();     if (idx <= mid)       update(pos << 1, idx, mass);     else       update(pos << 1 | 1, idx, mass);     push_up(pos);   }   pair<int, int> query(int pos, int l, int r) {     if (l <= tree[pos].l && tree[pos].r <= r) return tree[pos].v;     int mid = tree[pos].mid();     pair<int, int> ret = make_pair(0x3fffffff, 0x3fffffff);     if (l <= mid) ret = min(ret, query(pos << 1, l, r));     if (r > mid) ret = min(ret, query(pos << 1 | 1, l, r));     return ret;   }   int bifind(long long v) {     int l = 1, r = n, mid;     if (hook[r].d <= v) return r;     if (hook[l].d > v) return -1;     while (l + 1 < r) {       mid = (l + r) >> 1;       if (hook[mid].d <= v)         l = mid;       else         r = mid;     }     return l;   }   int main() {     int i, j, k;     while (scanf( %I64d%I64d%d%I64d%d , &hook[0].x, &hook[0].y, &hook[0].p,                  &hook[0].r, &n) != EOF) {       for (i = 1; i <= n; i++)         scanf( %I64d%I64d%d%d%I64d , &hook[i].x, &hook[i].y, &hook[i].m,               &hook[i].p, &hook[i].r);       for (i = 0; i <= n; i++) {         hook[i].r *= hook[i].r;         hook[i].d = (hook[0].x - hook[i].x) * (hook[0].x - hook[i].x) +                     (hook[0].y - hook[i].y) * (hook[0].y - hook[i].y);       }       sort(hook + 1, hook + 1 + n);       has.clear();       has.push_back(0);       build(1, 1, n);       for (i = 0; i < has.size(); i++) {         int rs = bifind(hook[has[i]].r);         while (rs != -1) {           pair<int, int> cur = query(1, 1, rs);           if (cur.first <= hook[has[i]].p) {             update(1, cur.second, 0x3fffffff);             has.push_back(cur.second);           } else             break;         }       }       printf( %d n , has.size() - 1);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( -O3 )   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   using namespace std;   long long n, m, k, i, ost, x, y, ans, a[200010], f[200010], ost1, sum1;   vector<pair<long long, long long>> v3, v1, v2;   pair<long long, long long> sum;   multiset<long long> st, st1;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     for (i = 1; i <= n; i++) cin >> a[i];     cin >> x;     for (i = 0; i < x; i++) {       cin >> y;       f[y]++;     }     cin >> x;     for (i = 0; i < x; i++) {       cin >> y;       f[y] += 2;     }     for (i = 1; i <= n; i++) {       if (f[i] == 1) v1.push_back(make_pair(a[i], i));       if (f[i] == 2) v2.push_back(make_pair(a[i], i));       if (f[i] == 3) v3.push_back(make_pair(a[i], i));     }     sort(v1.begin(), v1.end());     sort(v2.begin(), v2.end());     sort(v3.begin(), v3.end());     x = v3.size();     x = min(x, k);     y = k - x;     if (min((long long)v1.size(), (long long)v2.size()) < y or m < x + y * 2) {       cout << -1 << endl;       return 0;     }     for (i = 0; i < x; i++) {       sum.first += v3[i].first;       a[v3[i].second] = 1e18;     }     for (i = 0; i < y; i++) {       sum.first += v1[i].first;       a[v1[i].second] = 1e18;       sum.first += v2[i].first;       a[v2[i].second] = 1e18;     }     sort(a + 1, a + n + 1);     ost = m - x - 2 * y;     for (i = 1; i <= n; i++) {       if (i <= ost)         st1.insert(a[i]), sum.second += a[i];       else         st.insert(a[i]);     }     ans = sum.first + sum.second;     while (x) {       if (min((long long)v1.size(), (long long)v2.size()) <= y or y > k or           x + (y + 1) * 2 - 1 > m)         break;       if (ost > 0) ost--;       x--;       sum.first -= v3[x].first;       sum.first += v1[y].first + v2[y].first;       st.insert(v3[x].first);       auto it = st.find(v1[y].first);       if (it != st.end())         st.erase(it);       else {         it = st1.find(v1[y].first);         st1.erase(it);         sum.second -= v1[y].first;       }       it = st.find(v2[y].first);       if (it != st.end())         st.erase(it);       else {         it = st1.find(v2[y].first);         st1.erase(it);         sum.second -= v2[y].first;       }       y++;       ost1 = st1.size(), sum1 = sum.second;       it = st1.end();       while (ost1 > ost) {         ost1--;         it--;         sum1 -= *it;       }       for (auto it = st.begin(); it != st.end(); it++) {         ost1++;         if (ost1 > ost) break;         sum1 += *it;       }       ans = min(ans, sum.first + sum1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > ad;   vector<int> cam(0);   vector<bool> vis;   bool k = false;   void dfs(const int &m) {     vis[m] = true;     if (m == ad.size() - 1) {       k = true;     } else       for (int i = 0; i < ad[m].size(); i++) {         if (!vis[ad[m][i]]) dfs(ad[m][i]);         if (k) break;       }     if (k) {       cam.push_back(m);     }   }   int main() {     int n;     cin >> n;     ad.resize(n + 1, vector<int>(0));     vis.resize(n + 1, false);     for (int i = int(2); i < int(n + 1); i += int(1)) {       int x;       cin >> x;       ad[i].push_back(x);       ad[x].push_back(i);     }     dfs(1);     for (int i = cam.size() - 1; i >= 0; i--) cout << cam[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int a[N];   long long sum[N];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];     long long ans_sum = 0;     int ans_len = 0, pos = 1, len = 1;     for (int i = 1; i <= n; i++) {       int l = 0, r = min(i - 1, n - i);       while (l < r) {         int ml = (2 * l + r) / 3, mr = (2 * r + l + 2) / 3;         long long suml = sum[i] - sum[i - ml - 1] + sum[n] - sum[n - ml];         long long sumr = sum[i] - sum[i - mr - 1] + sum[n] - sum[n - mr];         if (suml * (2 * mr + 1) < sumr * (2 * ml + 1))           l = ml + 1;         else           r = mr - 1;       }       long long tmp_sum =           sum[i] - sum[i - l - 1] + sum[n] - sum[n - l] - (l * 2 + 1LL) * a[i];       if (tmp_sum * len > ans_sum * (2 * l + 1))         ans_sum = tmp_sum, ans_len = l, pos = i, len = 2 * l + 1;     }     printf( %d n , ans_len * 2 + 1);     for (int i = pos - ans_len; i <= pos; i++) printf( %d  , a[i]);     for (int i = n - ans_len + 1; i <= n; i++) printf( %d  , a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, p;     scanf( %d%d , &N, &p);     int i;     p--;     string S;     cin >> S;     int sz = S.size(), add = 0, flag = 0, first, last;     for (i = 0; i < sz / 2; i++) {       char c1 = S[i], c2 = S[sz - 1 - i];       if (c1 != c2) {         if (flag == 0) {           first = i;           flag = 1;         }         last = i;       }       add += min(abs(c1 - c2), abs(26 - abs(c1 - c2)));     }     if (p > sz / 2) {       p = sz - 1 - p;     }     if (flag == 0) {       printf( 0 );       return 0;     }     if (p != sz / 2) {       if (last == first) {         printf( %d , abs(p - last) + add);         return 0;       }       if (last < p) {         printf( %d , abs(p - first) + add);         return 0;       }       if (first > p) {         printf( %d , abs(p - last) + add);         return 0;       }       printf(            %d ,           min(2 * (p - first) + (last - p), 2 * (last - p) + (p - first)) + add);       return 0;     }     if (p == sz / 2) {       if (sz % 2) {         printf( %d , p - first + add);         return 0;       } else {         p--;         printf( %d , p - first + add);         return 0;       }     }   }
#include <bits/stdc++.h>   int main() {     int J, M;     float QJ, QM;     int i;     scanf( %d , &J);     scanf( %d , &M);     i = 1;     while (1) {       J = J - i;       if (J < 0) {         printf( Vladik n );         break;       }       i++;       M = M - i;       if (M < 0) {         printf( Valera n );         break;       }       i++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[3001];   void swap(int i, int j) {     int temp = a[i];     a[i] = a[j];     a[j] = temp;   }   int main() {     int n;     cin >> n;     ;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     vector<pair<int, int> > x;     for (int i = 0; i < n; i++) {       int min = a[i];       int sw = i;       for (int j = i + 1; j < n; j++) {         if (a[j] < min) {           min = a[j];           sw = j;         }       }       if (sw != i) {         x.push_back(make_pair(i, sw));         swap(i, sw);       }     }     cout << x.size() << endl;     for (vector<pair<int, int> >::iterator i = x.begin(); i != x.end(); i++) {       cout << (*i).first <<     << (*i).second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Distance(int x1, int y1, int x2, int y2) {     return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);   }   int main() {     int n, m, x1, y1, x2, y2, x3, y3, x4, y4, flag, dis1, dis2;     while (~scanf( %d%d , &n, &m)) {       flag = 0;       if (m > n) {         swap(n, m), flag = 1;       }       if (m == 0) {         x1 = 1, x2 = n;         x3 = 0;         x4 = n - 1;         y1 = y2 = y3 = y4 = 0;       } else {         dis1 = Distance(0, 0, n, m) * 2 + Distance(0, 0, n, 0);         dis2 = Distance(0, 0, n, m - 1) * 2 + Distance(0, 0, n, m);         if (dis1 > dis2) {           x1 = n;           y1 = m;           x2 = 0;           y2 = 0;           x3 = n;           y3 = 0;           x4 = 0;           y4 = m;         } else {           x1 = 0;           y1 = 1;           x2 = n;           y2 = m;           x3 = 0;           y3 = 0;           x4 = n;           y4 = m - 1;         }       }       if (flag) {         swap(x1, y1);         swap(x2, y2);         swap(x3, y3);         swap(x4, y4);       }       printf( %d %d n%d %d n%d %d n%d %d n , x1, y1, x2, y2, x3, y3, x4, y4);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[111], f[(1 << (23))], x[33];   int main() {     while (cin >> n) {       for (int i = 0, _a = (n); i < _a; i++) cin >> a[i];       if (n == 1) {         cout << 1 << endl;         continue;       }       int res = n + 1;       for (int S = 0, _a = ((1 << (n))); S < _a; S++) f[S] = n + 1;       f[1] = 1;       for (int S = (1), _b = ((1 << (n)) - 2); S <= _b; S++) {         int last = -1;         for (int i = (n - 1), _b = (0); i >= _b; i--)           if ((S & (1 << (i)))) {             last = i;             break;           }         int cur = f[S];         if (last == n - 1) {           res = min(res, cur);           continue;         }         int next = last + 1;         bool ok = false;         int nx = 0;         for (int i = 0, _a = (n); i < _a; i++)           if ((S & (1 << (i)))) x[++nx] = a[i];         sort(x + 1, x + nx + 1);         int j = nx, i = 1;         while (i <= j) {           if (x[i] + x[j] == a[next]) {             ok = true;             break;           } else if (x[i] + x[j] > a[next]) {             --j;           } else             ++i;         }         if (!ok) continue;         int S2 = S | (1 << (next));         f[S2] = min(f[S2], max(cur, __builtin_popcount(S2)));         for (int i = 0, _a = (n); i < _a; i++)           if ((S & (1 << (i)))) {             S2 = S - (1 << (i)) + (1 << (next));             f[S2] = min(f[S2], max(cur, __builtin_popcount(S2)));           }       }       if (res > n)         cout << -1 << endl;       else         cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     cin >> a >> b;     long long ans = 0;     while (true) {       if (!a || !b) {         cout << ans;         return 0;       }       if (a == b || (a % b == 0)) {         cout << (a / b + ans);         return 0;       }       if (a > b) {         long long tmp = a / b;         a -= tmp * b;         ans += tmp;       } else {         long long tmp = b / a;         b -= tmp * a;         ans += tmp;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool ckmax(T& x, T y) {     return x < y ? x = y, 1 : 0;   }   template <class T>   bool ckmin(T& x, T y) {     return x > y ? x = y, 1 : 0;   }   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = 0;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f ? x : -x;   }   inline char rdopt() {     char ch = getchar();     while (!isalpha(ch)) ch = getchar();     return ch;   }   const int N = 1 << 20;   int n, m, t1, t2, nq, pre[N];   long long tr[N], ans[N];   vector<int> e1[N], e2[N], u2[N];   vector<pair<int, int> > u1[N], q[N];   struct dsu {     int F[N], siz[N];     inline void init(const int& n = N - 1) {       for (int i = 1, iend = n; i <= iend; ++i) F[i] = i, siz[i] = 1;     }     inline int anc(int x) { return x == F[x] ? x : F[x] = anc(F[x]); }   } d1, d2;   inline void add(int x, long long d) {     for (int i = x; i <= m; i += i & -i) tr[i] += d;   }   inline long long ask(int x) {     long long res = 0;     for (int i = x; i > 0; i -= i & -i) res += tr[i];     return res;   }   inline int query(int tim) {     int res = 0, lim = ask(tim);     for (int i = 19; i >= 0; --i)       if (res + (1 << i) <= m && tr[res + (1 << i)] < lim)         res += 1 << i, lim -= tr[res];     return res;   }   void dfs2(int u) {     for (int i : u2[u]) add(i, 1);     for (pair<int, int> i : q[u]) pre[i.second] = query(i.first);     for (int v : e2[u]) dfs2(v);     for (int i : u2[u]) add(i, -1);   }   void dfs1(int u) {     for (pair<int, int> i : u1[u]) add(i.first, i.second);     for (pair<int, int> i : q[u])       ans[i.second] = ask(i.first) - ask(pre[i.second]);     for (int v : e1[u]) dfs1(v);     for (pair<int, int> i : u1[u]) add(i.first, -i.second);   }   signed main() {     n = read(), m = read();     d1.init(n), d2.init(n), t1 = t2 = n;     for (int i = 1; i <= m; ++i) {       char op = rdopt();       if (op ==  U ) {         int x = read(), y = read(), fx = d1.anc(x), fy = d1.anc(y);         ++t1, d1.F[fx] = d1.F[fy] = d1.F[t1] = t1,               d1.siz[t1] = d1.siz[fx] + d1.siz[fy];         e1[t1].push_back(fx), e1[t1].push_back(fy);       } else if (op ==  M ) {         int x = read(), y = read(), fx = d2.anc(x), fy = d2.anc(y);         ++t2, d2.F[fx] = d2.F[fy] = d2.F[t2] = t2;         e2[t2].push_back(fx), e2[t2].push_back(fy);       } else if (op ==  A ) {         int x = read(), fx = d1.anc(x);         u1[fx].push_back(make_pair(i, d1.siz[fx]));       } else if (op ==  Z ) {         int x = read(), fx = d2.anc(x);         u2[fx].push_back(i);       } else if (op ==  Q ) {         int x = read();         q[x].push_back(make_pair(i, ++nq));       }     }     for (int i = 1, iend = t2; i <= iend; ++i)       if (d2.F[i] == i) dfs2(i);     for (int i = 1, iend = t1; i <= iend; ++i)       if (d1.F[i] == i) dfs1(i);     for (int i = 1; i <= nq; ++i) printf( %lld n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 100;   int n, m, k, a[N];   bool mark[N];   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) cin >> a[i], mark[a[i]] = 1;     deque<int> que;     int ans = 0;     for (int i = 1; i < N; i++) {       while (que.size() && que.front() <= i - m) que.pop_front();       if (mark[i]) que.push_back(i);       if (que.size() >= k)         while (que.size() >= k) que.pop_back(), ans++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   template <typename T>   void read(T &x) {     x = 0;     char op = getchar();     int F = 1;     while (!isdigit(op)) {       if (op ==  - ) F *= -1;       op = getchar();     }     while (isdigit(op)) {       x = (x << 1) + (x << 3) + op -  0 ;       op = getchar();     }     x *= F;   }   template <typename T, typename... Args>   void read(T &x, Args &...args) {     read(x);     read(args...);   }   template <typename T1, typename T2>   void ckmax(T1 &x, T2 y) {     if (x < y) x = y;   }   template <typename T1, typename T2>   void ckmin(T1 &x, T2 y) {     if (x > y) x = y;   }   int a[1005];   int n, m, c;   void work() {     int rec;     cin >> rec;     if (2 * rec <= c) {       for (int i = 1; i <= n; i++) {         if (a[i] > rec || !a[i]) {           a[i] = rec;           cout << i <<   n ;           break;         }       }     } else {       for (int i = n; i >= 1; i--) {         if (a[i] < rec || !a[i]) {           a[i] = rec;           cout << i <<   n ;           break;         }       }     }     fflush(stdout);   }   int main() {     cin >> n >> m >> c;     while (m--) work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int maxn = 1e5 + 100;   long long a[maxn];   map<long long, long long> p[maxn];   vector<int> G[maxn];   long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }   long long ans = 0;   void dfs(int v, int fa) {     for (auto it : p[fa]) {       long long t = gcd(a[v], it.first);       p[v][t] += it.second;       ans = (ans + t % mod * it.second % mod) % mod;     }     p[v][a[v]] += 1;     ans = (ans + a[v]) % mod;     for (int i = 0; i < G[v].size(); i++) {       int to = G[v][i];       if (to == fa) continue;       dfs(to, v);     }   }   int main() {     std::ios::sync_with_stdio(false);     int N;     cin >> N;     for (int i = 1; i <= N; i++) cin >> a[i];     for (int i = 1; i < N; i++) {       int x;       int y;       cin >> x >> y;       G[x].push_back(y);       G[y].push_back(x);     }     dfs(1, 0);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     string str[n];     for (int i = 0; i < n; i++) cin >> str[i];     int brr[m];     for (int i = 0; i < m; i++) cin >> brr[i];     int count = 0;     for (int i = 0; i < m; i++) {       int arr[5] = {0};       for (int j = 0; j < n; j++) {         arr[str[j][i] -  A ]++;       }       int k = *max_element(arr, arr + 5);       count += k * brr[i];     }     cout << count;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double n, a, d;     cin >> n >> a >> d;     vector<int> t;     vector<int> v;     double prev = 0;     int bit = 1;     for (int i = 0; i < n; i++) {       double t1, v1;       cin >> t1 >> v1;       double t2 = 0, t3 = 0, tot = 0;       double dis = 0;       t2 = (double)(v1) / double(a);       dis = a * (t2) * (t2);       dis = (float)dis / (float)2;       if (dis >= d) {         double velo = 2 * a * d;         velo = sqrt(velo);         t2 = velo / a;         tot = t2 + (double)t1;       } else {         dis = d - dis;         t3 = (double)dis / (double)v1;         tot = (double)t2 + t3 + (double)t1;       }       if (tot > prev || bit == 1) {         cout << setprecision(12) << tot << endl;         prev = tot;         bit = 0;       } else {         cout << setprecision(12) << prev << endl;         bit = 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   class Mod {    public:     int mod;     Mod(int mod_ = 1e9 + 7) : mod(mod_) {}     int add(int a, int b) { return (a + b) % mod; }     int mul(long long a, int b) { return (a * b) % mod; }     int pow(long long a, int x) {       int ans = 1;       while (x) {         if (x & 1) {           ans = (ans * a) % mod;         }         x >>= 1;         a = (a * a) % mod;       }       return ans;     }   };   class IO {    public:     static void read(int &val) { scanf( %d , &val); }     static void read(long long &val) { scanf( %lld , &val); }     static void read(char *val) { scanf( %s , val); }     static void read(string &val) {       const int BUFFER_SIZE = 1e5 + 5;       static char buffer[BUFFER_SIZE];       scanf( %s , buffer);       val = buffer;     }     static void read_n(vector<int> &val, int n) {       val.resize(n);       for (int i = 0; i < n; i++) {         scanf( %d , &val[i]);       }     }     static void write(int val) { printf( %d n , val); }     static void write(long long val) { printf( %lld n , val); }     static void write(const char *val) { printf( %s n , val); }     static void write(const string &val) { printf( %s n , val.c_str()); }     static void write(const vector<int> &val) {       for (int i = 0; i < val.size(); i++) {         if (i > 0) {           putchar(   );         }         printf( %d , val[i]);       }       putchar(  n );     }   };   long long gcd_ex(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     long long ans = gcd_ex(b, a % b, y, x);     y -= (a / b) * x;     return ans;   }   class Solver {     long long x;     stringstream ans;     int cnt_ans = 0;     void print(long long x, long long a) {       long long cur = 0;       while (a) {         if (a & 1) {           if (cur > 0) {             ans << cur <<   +   << x << endl;             cnt_ans++;           }           cur += x;         }         a >>= 1;         ans << x <<   +   << x << endl;         cnt_ans++;         x <<= 1;       }     }       public:     void read() { IO::read(x); }     void solve() {       long long e = 1;       while ((e << 1) <= x) {         e <<= 1;       }       print(x, e);       ans << e * x <<   ^   << x << endl;       cnt_ans++;       long long y = ((e * x) ^ x);       long long a, b;       gcd_ex(x, y, a, b);       if (a < 0) {         swap(a, b);         swap(x, y);       }       b = -b;       if (!(a & 1)) {         a += y;         b += x;       }       print(x, a);       print(y, b);       ans << a * x <<   ^   << b * y << endl;       cnt_ans++;       IO::write(cnt_ans);       IO::write(ans.str());     }   };   void init() { ios::sync_with_stdio(false); }   int main() {     init();     int t = 1;     while (t--) {       Solver solver;       solver.read();       solver.solve();     }     return 0;   }