malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct data {     int le, ri, cnt;     data(int le_ = 0, int ri_ = 0, int cnt_ = 0) {       le = le_;       ri = ri_;       cnt = cnt_;     }   };   const int N = 1e6 + 10;   int seg[4 * N + 10];   int brk[5][4 * N + 10];   int n;   void add(int idx, bool b, int L = 0, int R = n, int id = 1) {     if (L == R - 1) {       brk[b][id]++;       return;     }     int mid = (L + R) / 2;     if (idx < mid)       add(idx, b, L, mid, 2 * id + 0);     else       add(idx, b, mid, R, 2 * id + 1);     seg[id] = seg[2 * id + 0] + seg[2 * id + 1] +               min(brk[0][2 * id + 0], brk[1][2 * id + 1]);     brk[0][id] =         brk[0][2 * id + 1] + max(0, brk[0][2 * id + 0] - brk[1][2 * id + 1]);     brk[1][id] =         brk[1][2 * id + 0] + max(0, brk[1][2 * id + 1] - brk[0][2 * id + 0]);     return;   }   data get(int l, int r, int L = 0, int R = n, int id = 1) {     if (L == l && R == r) return data(brk[0][id], brk[1][id], seg[id]);     int mid = (L + R) / 2;     data le, ri;     if (l < mid) le = get(l, min(r, mid), L, mid, 2 * id + 0);     if (r > mid) ri = get(max(l, mid), r, mid, R, 2 * id + 1);     data ret;     ret.cnt = le.cnt + ri.cnt + min(le.le, ri.ri);     ret.le = ri.le + max(0, le.le - ri.ri);     ret.ri = le.ri + max(0, ri.ri - le.le);     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     string s;     cin >> s, n = s.size();     for (int i = 0; i < s.size(); i++)       if (s[i] ==  ( )         add(i, 0);       else         add(i, 1);     int q;     cin >> q;     while (q--) {       int l, r;       cin >> l >> r, l--;       cout << 2 * get(l, r).cnt << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long f[1 << 10], M = 1000000;   long long l, r, k;   class Matrix {    public:     long long a[3][3];     Matrix(int fib = 0) {       memset(a, 0, sizeof(a));       if (fib) a[1][2] = a[2][1] = a[2][2] = 1;     }     Matrix operator*(const Matrix &v) {       Matrix ret;       for (int i = 1; i <= 2; ++i)         for (int j = 1; j <= 2; ++j)           for (int k = 1; k <= 2; ++k)             ret.a[i][k] = (ret.a[i][k] + a[i][j] * v.a[j][k]) % M;       return ret;     }     void print() { cout << a[1][2] % M << endl; }   };   Matrix one(1);   long long solve(long long l, long long r, long long v) {     l = (l - 1) / v + 1;     r = r / v;     return r - l + 1;   }   Matrix fib(long long u) {     if (u == 1) return one;     Matrix cache = fib(u / 2);     cache = cache * cache;     if (u % 2) cache = cache * one;     return cache;   }   int main() {     cin >> M >> l >> r >> k;     long long ans = 1;     if (k >= 1000000) {       ans = (r - l + 1) / (k - 1) + 2;       while (solve(l, r, ans) < k) --ans;     } else {       for (int i = 1; i + k - 1 <= 1000000; ++i) {         long long tl = (l - 1) / i + 1, tr = r / (i + k - 1);         if (tl <= tr) ans = max(ans, tr);       }     }     fib(ans).print();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) { return (a > b ? a : b); }   long long min(long long a, long long b) { return (a < b ? a : b); }   void algo() {     string s1, s2;     char c;     cin >> s1 >> s2;     long long j = 0, len = s1.size();     for (long long i = 0; i < len; i++) {       c = s1[i];       long long k = j;       if (s1[i + 1] == c && i != len - 1) {         if (c == s2[j])           j++;         else {           cout <<  NO ;           return;         }       } else {         while (c == s2[j]) {           j++;         }       }       if (k == j) {         cout <<  NO ;         return;       }     }     if (j != s2.size())       cout <<  NO ;     else       cout <<  YES ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long t;     cin >> t;     while (t--) {       algo();       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double const EPS = 1.0E-9;   int const MOD = (int)1e9 + 7;   inline void read(char* s) { scanf( %s , s); }   inline void read(int& x) { scanf( %d , &(x)); }   inline void read(long long& x) { scanf( %lld , &x); }   inline void read(double& x) { scanf( %lf , &x); }   inline void writeln(int x) { printf( %d n , x); }   inline void writeln(long long x) { printf( %lld n , x); }   inline void writeln(double x) { printf( %.12f n , x); }   template <typename... T>   void read(T&... args) {     using swallow = int[];     swallow w = {0, (read(args), 0)...};   }   inline long long gcd(long long x, long long y) {     return y == 0 ? x : gcd(y, x % y);   }   inline long long lcm(long long x, long long y) {     return x == 0 && y == 0 ? 0 : x / gcd(x, y) * y;   }   inline long long powmod(long long x, long long n, long long m = MOD) {     long long r = 1;     while (n) {       if (n & 1) r = (r * x) % m;       x = (x * x) % m;       n /= 2;     }     return r;   }   static int leap(int y) { return y % 4 == 0 && y % 100 != 0 || y % 400 == 0; }   static int const month[2][12] = {       {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},       {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};   static const int N = 1 << 18;   static const int M = 1 << 20;   int freq[N];   int n, k;   int f[N];   int h[12];   int hw[5012][512];   static int solve() {     read(n, k);     for (int i = 1; i <= n * k; ++i) {       int a;       read(a);       freq[a]++;     }     for (int i = 1; i <= n; ++i) {       int x;       read(x);       f[x]++;     }     for (int i = 1; i <= k; ++i) {       read(h[i]);     }     for (int i = 0; i < 5012; ++i) {       for (int j = 0; j < 512; ++j) {         if (i == 0 || j == 0) {           hw[i][j] = 0;         } else {           hw[i][j] = 0;           for (int l = 0; l <= k && l <= i; ++l) {             hw[i][j] = std::max(hw[i][j], hw[i - l][j - 1] + h[l]);           }         }       }     }     long long ans = 0;     for (int i = (0), vzq_b = (N); i < vzq_b; ++i) {       int fa = f[i];       ans += hw[freq[i]][fa];     }     writeln(ans);     return 0;   }   int main(int argc, char* argv[]) {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ull = unsigned long long;   const int MAX_LENGTH = 100000 + 8;   const ull B = 100000007ULL;   char s[3][MAX_LENGTH];   ull H[3][MAX_LENGTH], B_to[MAX_LENGTH] = {1ULL};   int id[3] = {0, 1, 2}, len[3];   void init_hash() {     for (int i = 0; i < 3; ++i) {       for (int j = 1; j < len[i] + 1; ++j) {         H[i][j] = H[i][j - 1] * B + s[i][j];       }     }     int n = max(max(len[0], len[1]), len[2]);     for (int i = 1; i < n + 1; ++i) {       B_to[i] = B_to[i - 1] * B;     }   }   inline ull hash_of(ull *h, int b, int l) {     return h[b + l - 1] - h[b - 1] * B_to[l];   }   bool contain(int a, int b) {     if (len[a] < len[b]) return false;     ull bh = H[b][len[b]];     for (int i = 1; i + len[b] <= len[a]; ++i)       if (hash_of(H[a], i, len[b]) == bh) return true;     return false;   }   int overlap(int a, int b) {     int ans = 0;     for (int i = 1; i <= min(len[a], len[b]); ++i) {       if (hash_of(H[a], len[a] - i + 1, i) == hash_of(H[b], 1, i)) ans = i;     }     return ans;   }   int solve() {     int ans = MAX_LENGTH * 3;     for (int i = 0; i < 2; ++i) {       for (int j = i + 1; j < 3; ++j) {         if (contain(i, j) || contain(j, i)) {           int x = len[i] > len[j] ? i : j;           int y = 3 - i - j;           if (contain(x, y) || contain(y, x)) return max(len[x], len[y]);           return len[x] + len[y] - max(overlap(x, y), overlap(y, x));         }       }     }     do       ans = min(ans, len[0] + len[1] + len[2] - overlap(id[0], id[1]) -                          overlap(id[1], id[2]));     while (next_permutation(id, id + 3));     return ans;   }   int main() {     for (int i = 0; i < 3; ++i) {       gets(s[i] + 1);       len[i] = strlen(s[i] + 1);     }     init_hash();     printf( %d n , solve());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     if (a < b) swap(a, b);     if (b == 0) return a;     while (b) {       long long int re = a % b;       a = b;       b = re;     }     return a;   }   vector<int> a[1000 + 10], b[1000 + 10];   vector<int> c1(1000 + 10, 0), c2(1000 + 10, 0);   void dfs(int i, int k, int p) {     if (p)       c1[i] = k;     else       c2[i] = k;     if (p) {       for (int j : a[i]) {         if (c1[j] == 0) dfs(j, k, p);       }     } else {       for (int j : b[i]) {         if (c2[j] == 0) dfs(j, k, p);       }     }   }   int main() {     int n, m1, m2;     cin >> n >> m1 >> m2;     for (int i = 0; i < m1; i++) {       int u, v;       cin >> u >> v;       a[u].push_back(v);       a[v].push_back(u);     }     for (int i = 0; i < m2; i++) {       int u, v;       cin >> u >> v;       b[u].push_back(v);       b[v].push_back(u);     }     int k = 1;     for (int i = 1; i < n + 1; i++) {       if (c1[i] == 0) {         dfs(i, k, 1);         k++;       }     }     k = 1;     vector<pair<long long int, long long int> > ans;     for (int i = 1; i < n + 1; i++) {       if (c2[i] == 0) {         dfs(i, k, 0);         k++;       }     }     map<int, int> mp1, mp2;     for (int i = 0; i < n + 1; i++) {       mp1[i] = i;       mp2[i] = i;     }     for (int i = 1; i < n + 1; i++) {       for (int j = 1; j < n + 1; j++) {         int cai = mp1[c1[i]], caj = mp1[c1[j]], cbi = mp2[c2[i]],             cbj = mp2[c2[j]];         if (cai != caj && cbi != cbj) {           ans.push_back({i, j});           mp1[c1[j]] = mp1[c1[i]] = -1;           mp2[c2[j]] = mp2[c2[i]] = -1;         }       }     }     cout << ans.size() << endl;     for (auto it : ans) cout << it.first <<     << it.second << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   int val[maxn];   int sito[maxn];   int main() {     ios::sync_with_stdio(false);     for (int i = 0; i < maxn; i++) {       sito[i] = true;     }     vector<int> v;     sito[0] = sito[1] = false;     for (int i = 2; i < maxn; i++) {       if (sito[i]) {         v.push_back(i);         if (i < 1000) {           for (int j = i * i; j < maxn; j += i) {             sito[j] = false;           }         }       }     }     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> val[i];       val[i]--;     }     vector<pair<int, int> > ss;     for (int i = 0; i < n;) {       int pos = i;       if (pos == val[pos]) {         i++;         continue;       }       while (pos != val[pos]) {         int l = 0, r = v.size() - 1;         int best = 0;         while (l <= r) {           int mid = (l + r) / 2;           if (pos + v[mid] - 1 <= val[pos]) {             l = mid + 1;             best = max(best, v[mid] - 1);           } else {             r = mid - 1;           }         }         ss.push_back(make_pair(pos + 1, pos + best + 1));         swap(val[pos], val[pos + best]);         pos += best;       }     }     cout << ss.size() << endl;     for (int i = 0; i < ss.size(); i++) {       cout << ss[i].first <<     << ss[i].second <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long sqr(long long x) { return x * x; }   bool done = false;   int p[8][3];   bool same(double x, double y) { return abs(x - y) < 1e-9; }   int cnt = 0;   void backtr(int idx) {     if (done) return;     if (idx == 7) {       cnt++;       map<long long, int> ck;       vector<long long> t(28), v(3, 1);       int idx = 0, idx2 = 0;       long long l1 = -1, l2 = -1, l3 = -1;       for (int i = 0; i < 8; ++i)         for (int j = i + 1; j < 8; ++j) {           t[idx++] = sqr(p[i][0] - p[j][0]) + sqr(p[i][1] - p[j][1]) +                      sqr(p[i][2] - p[j][2]);           if (!ck.count(t[idx - 1])) {             if (idx2 == 3) return;             v[idx2++] = t[idx - 1], ck[t[idx - 1]] = 1;           } else             ck[t[idx - 1]]++;         }       sort(v.begin(), v.end());       if (ck[v[0]] == 12 && ck[v[1]] == 12 && ck[v[2]] == 4 && 2 * v[0] == v[1] &&           v[0] + v[1] == v[2]) {         done = true;         printf( YES n );         for (int i = 0; i < 8; ++i)           printf( %d %d %d n , p[i][0], p[i][1], p[i][2]);       }     } else {       do {         backtr(idx + 1);         if (done) return;       } while (next_permutation(p[idx], p[idx] + 3));       sort(p[idx], p[idx] + 3);     }   }   int main() {     clock_t start_time, end_time;     start_time = clock();     for (int i = 0; i < 8; ++i)       scanf( %d%d%d , &p[i][0], &p[i][1], &p[i][2]), sort(p[i], p[i] + 3);     backtr(0);     if (!done) printf( NO );     end_time = clock();   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 30;   bool vis[N];   int id1 = -1, id2 = -1;   char ch;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string s;     cin >> s;     int n = 27;     for (int i = 0; i < 27; i++) {       if (vis[s[i] -  A ]) {         id2 = i;         ch = s[i];       } else {         vis[s[i] -  A ] = true;       }     }     for (int i = 0; i < 27; i++) {       if (s[i] == ch) {         id1 = i;         break;       }     }     if (id2 == id1 + 1) {       cout <<  Impossible n ;       return 0;     }     if ((id2 - id1 - 1) % 2 == 1) {       int cnt = id2 - id1 - 1;       int rast = cnt / 2, chap = n - id2 - 1;       if (rast + chap + 1 <= 13) {         int rem = 13 - rast - chap - 1;         for (int i = rem; i < id1; i++) cout << s[i];         for (int i = id1 + 1; i <= id1 + cnt / 2 + 1; i++) cout << s[i];         cout <<   n ;         for (int i = rem - 1; i >= 0; i--) cout << s[i];         for (int i = n - 1; i > id2; i--) cout << s[i];         cout << ch;         for (int i = id2 - 1; i >= id2 - cnt / 2; i--) cout << s[i];         cout <<   n ;       } else {         int rem = rast + chap + 1 - 13;         for (int i = 0; i < rem; i++) cout << s[n - rem + i];         for (int i = 0; i < id1; i++) cout << s[i];         for (int i = id1 + 1; i <= id1 + cnt / 2 + 1; i++) cout << s[i];         cout <<   n ;         for (int i = n - rem - 1; i > id2; i--) cout << s[i];         cout << ch;         for (int i = id2 - 1; i >= id2 - cnt / 2; i--) cout << s[i];       }     } else {       int cnt = id2 - id1 - 1;       int rast = cnt / 2, chap = n - id2 - 1;       if (rast + chap + 1 <= 13) {         int rem = 13 - rast - chap - 1;         for (int i = rem; i < id1; i++) cout << s[i];         for (int i = id1 + 1; i <= id1 + cnt / 2; i++) cout << s[i];         cout <<   n ;         for (int i = rem - 1; i >= 0; i--) cout << s[i];         for (int i = n - 1; i > id2; i--) cout << s[i];         cout << ch;         for (int i = id2 - 1; i >= id2 - cnt / 2; i--) cout << s[i];         cout <<   n ;       } else {         int rem = rast + chap + 1 - 13;         for (int i = 0; i < rem; i++) cout << s[n - rem + i];         for (int i = 0; i < id1; i++) cout << s[i];         for (int i = id1 + 1; i <= id1 + cnt / 2; i++) cout << s[i];         cout <<   n ;         for (int i = n - rem - 1; i > id2; i--) cout << s[i];         cout << ch;         for (int i = id2 - 1; i >= id2 - cnt / 2; i--) cout << s[i];       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 4;   void solve() {     int n;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     float min = 4.5 * n;     int mn = (int)min;     if (min - mn > 0) mn++;     int sum = 0;     for (int i = 0; i < n; i++) sum += arr[i];     int req = mn - sum;     if (req <= 0) {       cout << 0 << endl;       return;     }     sort(arr, arr + n);     int ans = 0, i = 0;     while (req > 0) {       req -= 5 - arr[i];       i++;       ans++;     }     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, i;     scanf( %d%d , &n, &k);     char s[n];     scanf( %s , s);     for (i = 0; i < n; ++i) {       if (s[i] ==  G ) {         for (int j = i + k; j < n; j += k) {           if (s[j] ==  # ) {             printf( NO n );             return 0;           } else if (s[j] ==  T ) {             printf( YES n );             return 0;           }         }         printf( NO n );         return 0;       } else if (s[i] ==  T ) {         for (int j = i + k; j < n; j += k) {           if (s[j] ==  # ) {             printf( NO n );             return 0;           } else if (s[j] ==  G ) {             printf( YES n );             return 0;           }         }         printf( NO n );         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, f, r[4];   char names[4][16] = { Gryffindor ,  Hufflepuff ,  Ravenclaw ,  Slytherin };   int main() {     scanf( %d , &n);     vector<vector<int> > v;     v.push_back(vector<int>(4));     for (int k = 0; k < (int)(n); k++) {       char op;       scanf(  %c , &op);       ((void)0);       if (op !=  ? ) {         for (int i = 0; i < (int)(4); i++)           if (op == names[i][0]) {             for (int j = 0; j < (int)(v.size()); j++) v[j][i]++;           }       } else {         vector<vector<int> > nv;         for (int j = 0; j < (int)(v.size()); j++) {           int mx = 1 << 30;           for (int i = 0; i < (int)(4); i++) mx = min(mx, v[j][i]);           for (int i = 0; i < (int)(4); i++)             if (v[j][i] == mx) {               nv.push_back(v[j]);               nv.back()[i]++;             }         }         sort(nv.begin(), nv.end());         nv.erase(unique(nv.begin(), nv.end()), nv.end());         v = nv;       }     }     for (int i = 0; i < (int)(v.size()); i++) {       int mx = 1 << 30;       for (int j = 0; j < (int)(4); j++) mx = min(mx, v[i][j]);       for (int j = 0; j < (int)(4); j++)         if (v[i][j] == mx) r[j] = 1;     }     for (int i = 0; i < (int)(4); i++)       if (r[i]) puts(names[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, L;   char s[100005];   int main() {     scanf( %s , &s);     L = strlen(s);     for (i = 0; i < L; i++) printf( %c , s[i]);     for (i = L - 1; i >= 0; i--) printf( %c , s[i]);   }
#include <bits/stdc++.h>   using namespace std;   int N;   vector<int> adj[200005];   int dfs(int cur, int prv, bool valid) {     int cnt = valid;     for (int nxt : adj[cur])       if (nxt != prv) cnt += dfs(nxt, cur, !valid);     return cnt;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> N;     for (int i = 0, a, b; i < N - 1; i++) {       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     int cnt = dfs(1, 0, true);     cout << min(cnt, N - cnt) - 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, string> m;   int main() {     long long int n, mm, i;     string s, b, s1, b1;     cin >> n >> mm;     for (i = 0; i < n; i++) {       cin >> s >> b;       m[b] = s;     }     char c;     for (i = 0; i < mm; i++) {       cin >> s1 >> b1;       int l = b1.length();       cout << s1 <<     << b1.substr(0, l - 1) <<  ; #  << m[b1.substr(0, l - 1)]            <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000010;   long long n, m, s, l;   vector<pair<long long, long long> > Adj[N];   long long Dis[N], Ans;   set<pair<long long, long long> > Res;   vector<pair<long long, pair<long long, long long> > > Edges;   void Dik() {     for (int i = 0; i <= n; i++) Dis[i] = 1e18;     Dis[s] = 0;     set<pair<long long, long long> > S;     S.insert({0, s});     while (!S.empty()) {       auto Cur = *S.begin();       S.erase(S.begin());       for (int i = 0; i < Adj[Cur.second].size(); i++) {         int to = Adj[Cur.second][i].first;         long long w = Adj[Cur.second][i].second;         if (Dis[to] > Cur.first + w) {           Dis[to] = Cur.first + w;           S.insert({Dis[to], to});         }       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> s;     for (int i = 0; i < m; i++) {       int a, b, w;       cin >> a >> b >> w;       Edges.push_back({w, {a, b}});       Adj[a].push_back({b, w});       Adj[b].push_back({a, w});     }     cin >> l;     if (l == 0) {       cout << 1 << endl;       return 0;     }     Dik();     for (int i = 1; i <= n; i++)       if (Dis[i] == l) Ans++;     for (int i = 0; i < Edges.size(); i++) {       int a = Edges[i].second.first;       int b = Edges[i].second.second;       long long w = Edges[i].first;       if (Dis[a] < l && Dis[a] + w > l && (w - (l - Dis[a])) + Dis[b] >= l) {         Ans++;       }       if (Dis[b] < l && Dis[b] + w > l && (w - (l - Dis[b])) + Dis[a] >= l) {         Ans++;       }       if (Dis[a] < l && Dis[a] + w > l && (w - (l - Dis[a])) + Dis[b] >= l) {         if (Dis[b] < l && Dis[b] + w > l && (w - (l - Dis[b])) + Dis[a] >= l) {           if (w - (l - Dis[a]) == (l - Dis[b])) Ans--;         }       }     }     cout << Ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n, k, x, y;       cin >> n >> k;       if (n > k) {         x = k * (k + 1);         x = x / 2;         cout << x << endl;       } else {         y = n - 1;         x = y * (y + 1);         x = x / 2;         cout << x + 1 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPSILON = 1e-9;   const double PI = acos(0.0) * 2;   const int MOD = 1000000007;   const int INF = 0x3c3c3c3c;   const long long INFL = 0x3c3c3c3c3c3c3c3c;   const int MAX_N = 102;   long long S, X;   long long solve(long long sum, int pos) {     if (sum > S) return 0;     if (pos < 0) return sum == S;     long long ret = 0;     if (X & (1ll << pos)) {       if ((1ll << pos) + sum <= S) ret += 2 * solve(sum + (1ll << pos), pos - 1);     } else {       if ((1ll << (pos + 1)) + sum <= S)         ret += solve(sum + 2 * (1ll << pos), pos - 1);       if (S - sum <= 2 * ((1ll << pos) - 1)) ret += solve(sum, pos - 1);     }     return ret;   }   int main() {     scanf( %lld%lld , &S, &X);     cout << solve(0, 60) - (X == S ? 2 : 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0;     long long q, p = 1;     cin >> q;     for (int i = 0; i < 2; i++) {       for (long long s = 2; s * s <= q; s++) {         if (q % s == 0) {           n++;           p *= s;           q /= s;           break;         }       }     }     if (n == 2 && q > 1 || n == 0) {       cout << 1 << endl;       cout << (n == 0 ? 0 : p) << endl;     } else {       cout << 2 << endl;     }     return 0;   }