malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int a[105], stor[105];   int main() {     int n;     scanf( %d , &n);     int i;     for (i = 0; i < n; i++) scanf( %d , &a[i]);     int j, k = 0, max;     max = a[2] - a[0];     for (i = 1; i < n - 1; i++) {       if (i == 1) {         max = a[2] - a[0];         for (j = 2; j < n - 1; j++) {           if (a[j + 1] - a[j] > max) max = a[j + 1] - a[j];         }       } else {         max = a[1] - a[0];         for (j = 0; j < n; j++) {           if (j == i) {             if (a[j + 1] - a[j - 1] > max) max = a[j + 1] - a[j - 1];           }           if (j + 1 == i) {             if (a[j + 2] - a[j] > max) max = a[j + 2] - a[j];           } else if (a[j + 1] - a[j] > max)             max = a[j + 1] - a[j];         }       }       stor[k++] = max;     }     int min = stor[0];     for (i = 0; i < k; i++) {       if (stor[i] < min) min = stor[i];     }     printf( %d , min);     printf(  n );     return 0;   }
#define _USE_MATH_DEFINES   #include <bits/stdc++.h>   using namespace std;      //template   #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)   #define ALL(v) (v).begin(),(v).end()   using ll=long long int;   const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;   template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}   template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}   //end      void solve(int _rot){      // printf( Case #%d:  ,_rot);      int n;      cin>>n;      string s[3];      rep(i,0,3)cin>>s[i];      rep(_,0,3){         string S=s[_],T=s[(_+1)%3];         string res;            int S0=0,T0=0;         rep(i,0,n*2)if(S[i]== 0 )S0++;         rep(i,0,n*2)if(T[i]== 0 )T0++;         if((S0>n) and (T0<n))continue;         if((S0<n) and (T0>n))continue;         char mx;         if(S0>=n and T0>=n)mx= 0 ;         if(S0<=n and T0<=n)mx= 1 ;            int i1=0,i2=0;         for(;;){            int c1=0,c2=0;            while(i1<n*2 and S[i1]!=mx){               i1++; c1++;            }            while(i2<n*2 and T[i2]!=mx){               i2++; c2++;            }            res+=string(max(c1,c2),mx^ 0 ^ 1 );            res+=mx;            i1=min(i1+1,n*2);            i2=min(i2+1,n*2);            if(i1==n*2 and i2==n*2)break;         }         while(res.size()>n*3)res.pop_back();         while(res.size()<n*3)res+= 0 ;         cout<<res<<  n ;         return;      }   }      int main(){      int t; scanf( %d ,&t);      rep(rot,0,t)solve(rot+1);      return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const int INF = 0x3f3f3f3f;   const double eps = 1e-8;   const long long mod = 10007;   const int N = 110;   int val[110];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       for (int j = i; j <= n; j++) {         for (int k = i; k <= j; k++) {           val[k]++;         }       }     }     int ans = -1;     for (int i = 1; i <= n; i++) {       ans = max(ans, val[i]);     }     printf( %d n , ans);     return 0;   }
#include<bits/stdc++.h>   #define ll long long   #define ii pair<ll,ll>   #define x first   #define y second   using namespace std;   const long o=200005;   ll n,it[2][4*o];   ii a[o];   vector<ii>p[2];   void build(long db,long x,long l,long r)   {       if(l==r)       {           it[db][x]=p[db][l].y;           return;       }       long mid=(l+r)>>1;       build(db,2*x,l,mid);       build(db,2*x+1,mid+1,r);       it[db][x]=min(it[db][2*x],it[db][2*x+1]);   }   ll get(long db,long x,long l,long r,long u,long v)   {       if(u>v || v<l || u>r)           return 1e9;       if(u<=l && r<=v)           return it[db][x];       long mid=(l+r)>>1;       return min(get(db,2*x,l,mid,u,v),get(db,2*x+1,mid+1,r,u,v));   }   int main()   {    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);       cin>>n;    for(long i=1;i<=n;i++)           cin>>a[i].x;          ll kq=0;       for(long i=1;i<=n;i++)       {           cin>>a[i].y;           if(a[i].x<a[i].y)p[0].push_back({a[i].y,a[i].x});           if(a[i].x>a[i].y)p[1].push_back(a[i]);           kq+=abs(a[i].x-a[i].y);       }             sort(p[0].begin(),p[0].end());       sort(p[1].begin(),p[1].end());       if(p[0].size()==0 || p[1].size()==0)       {           cout<<kq;           return 0;       }          build(0,1,0,p[0].size()-1);       build(1,1,0,p[1].size()-1);       ll l=0,r=1e9;       while(l<r)       {           ll mid=(l+r+1)>>1;           bool ok=0;           for(long i=0;i<p[0].size();i++)           if(p[0][i].x-p[0][i].y>=mid)           {               long vt=lower_bound(p[1].begin(),p[1].end(),ii(p[0][i].y+mid,0))-p[1].begin();               if(get(1,1,0,p[1].size()-1,vt,p[1].size()-1)<=p[0][i].y)               {                   ok=1;                   break;               }           }           for(long i=0;i<p[1].size();i++)           if(p[1][i].x-p[1][i].y>=mid)           {               long vt=lower_bound(p[0].begin(),p[0].end(),ii(p[1][i].y+mid,0))-p[0].begin();               if(get(0,1,0,p[0].size()-1,vt,p[0].size()-1)<=p[1][i].y)               {                   ok=1;                   break;               }           }           if(ok)l=mid;           else r=mid-1;       }       cout<<kq-l*2;       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int v[200005];   void read();   int main() {     read();     int k = n - 1;     while (v[k] == v[k + 1]) --k;     cout << k <<   n ;     return 0;   }   void read() {     cin >> n;     for (int i = 1; i <= n; ++i) cin >> v[i];   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 2e9;   const long long infll = 1e18;   double eps = 0.0000001;   ifstream in( input.txt );   ofstream out( output.txt );   ;   long long n;   vector<long long> c;   vector<long long> t;   void init() {     cin >> n;     c.resize(n);     t.resize(n);     for (long long i = 0; i < n; i++) cin >> c[i];     for (long long i = 0; i < n; i++) cin >> t[i];   }   void solve() {     multiset<long long> razn1, razn2;     for (long long i = 0; i < n - 1; i++) {       razn1.insert(c[i + 1] - c[i]);       razn2.insert(t[i + 1] - t[i]);     }     if (razn1 == razn2 && c[0] == t[0] && c[n - 1] == t[n - 1])       cout <<  Yes ;     else       cout <<  No ;   }   signed main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x, y, z, arr[100 * 100005], rearr[100 * 100005];   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     cin >> x >> y;     for (int i = 0; i < x; i++) {       cin >> z;       arr[z]++;     }     z = 0;     for (int i = 1e7; i >= 1; i--) {       z += arr[i];       arr[i / 2] += arr[i] + rearr[i];       rearr[i / 2 + i % 2] += arr[i] + rearr[i];       if (z >= y) {         cout << i << endl;         return 0;       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, k, l, c, d, p, nl, np, x, y, z, a, i;     scanf( %d%d%d%d%d%d%d%d , &n, &k, &l, &c, &d, &p, &nl, &np);     x = (k * l) / nl;     y = c * d;     z = p / np;     if (x < y && x < z) {       a = x;     } else if (y < x && y < z) {       a = y;     } else {       a = z;     }     i = a / n;     printf( %d , i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (1 << 30) - 1;   const long long mod = 1e9 + 9;   map<pair<int, int>, int> mp;   int m;   int v[100010][2];   int vis[100010];   int ans[100010], anscnt;   int up[100010][3];   int down[100010][3];   priority_queue<int> qmax;   priority_queue<int, vector<int>, greater<int> > qmin;   bool check(int a) {     for (int i = 0; i < 3; ++i)       if (up[a][i]) {         int id = up[a][i], cnt = 0;         for (int j = 0; j < 3; ++j) cnt += !down[id][j];         if (cnt == 2) return false;       }     return true;   }   bool Check(int a, int x) {     for (int i = 0; i < 3; ++i)       if (up[a][i]) {         int id = up[a][i], cnt = 0;         if (id == x) continue;         for (int j = 0; j < 3; ++j) cnt += !down[id][j];         if (cnt == 2) return false;       }     return true;   }   void Remove(int a) {     int now;     for (int i = 0; i < 3; ++i)       if (up[a][i]) {         int id = up[a][i];         for (int j = 2; j >= 0; --j)           if (down[id][j]) {             now = down[id][j];             if (now == a) down[id][j] = 0;           }       }     for (int i = 0; i < 3; ++i)       if (down[a][i]) {         int id = down[a][i];         for (int j = 2; j >= 0; --j)           if (up[id][j]) {             now = up[id][j];             if (now == a) up[id][j] = 0;           }       }   }   void Topo() {     anscnt = 0;     for (int i = 1; i <= m; ++i)       if (check(i)) {         qmax.push(i);         qmin.push(i);       }     int cur = 1;     while (1) {       int x;       if (cur % 2) {         if (qmax.empty()) break;         x = qmax.top();         qmax.pop();         if (vis[x]) continue;       } else {         if (qmin.empty()) break;         x = qmin.top();         qmin.pop();         if (vis[x]) continue;       }       if (check(x) == false) continue;       cur++;       vis[x] = 1;       ans[++anscnt] = x;       for (int i = 0; i < 3; ++i)         if (down[x][i]) {           int id = down[x][i];           if (Check(id, x)) {             qmax.push(id);             qmin.push(id);           }         }       Remove(x);     }   }   int main() {     scanf( %d , &m);     for (int i = 1; i <= (m); ++i) {       scanf( %d%d , &v[i][0], &v[i][1]);       mp[make_pair(v[i][0], v[i][1])] = i;     }     for (int i = 1; i <= (m); ++i) {       int id, a = v[i][0], b = v[i][1];       if (mp.find(make_pair(a - 1, b - 1)) != mp.end())         down[i][0] = mp[make_pair(a - 1, b - 1)];       if (mp.find(make_pair(a, b - 1)) != mp.end())         down[i][1] = mp[make_pair(a, b - 1)];       if (mp.find(make_pair(a + 1, b - 1)) != mp.end())         down[i][2] = mp[make_pair(a + 1, b - 1)];       if (mp.find(make_pair(a - 1, b + 1)) != mp.end())         up[i][0] = mp[make_pair(a - 1, b + 1)];       if (mp.find(make_pair(a, b + 1)) != mp.end())         up[i][1] = mp[make_pair(a, b + 1)];       if (mp.find(make_pair(a + 1, b + 1)) != mp.end())         up[i][2] = mp[make_pair(a + 1, b + 1)];     }     Topo();     long long rlt = 0;     for (int i = 1; i <= anscnt; ++i) rlt = (rlt * m % mod + ans[i] - 1) % mod;     printf( %I64d n , rlt);     return 0;   }
#include <bits/stdc++.h>   #pragma optimization_level 3   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   using namespace std;   const long long N = 1e6 + 5;   const long long mod = 1e+9 + 7;   const long long INF = 0x7f7f7f7f7f7f7f7f;   const int INFi = 0x7f7f7f7f;   long long n, k;   long long ch(long long first) {     long long ans = first;     while (first) {       first /= k;       ans += first;     }     return (ans >= n);   }   void bs() {     long long l = 1;     long long r = 1e9;     while (l <= r) {       long long mid = (l + r) / 2;       if (ch(mid))         r = mid - 1;       else         l = mid + 1;     }     cout << (r + 1) << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << fixed;     cout << setprecision(10);     ;     cin >> n >> k;     bs();   }
#include <bits/stdc++.h>   using namespace std;   const long long llInf = 1e18 + 1e17;   const int Inf = 1e9 + 1e8, N = 1e5 + 10, Mod = 1e9 + 7;   int dp[N], t[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     dp[0] = 0;     for (int i = 1; i <= n; i++) {       cin >> t[i];       int ind2 = upper_bound(t + 1, t + i, t[i] - 90) - t - 1,           ind3 = upper_bound(t + 1, t + i, t[i] - 1440) - t - 1;       int val1 = dp[i - 1] + 20;       dp[i] = val1;       int val2 = dp[ind2] + 50, val3 = dp[ind3] + 120;       dp[i] = min({dp[i], val2, val3});     }     for (int i = 1; i <= n; i++) cout << dp[i] - dp[i - 1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5;   vector<long long> edges[N];   long long vdiv[N];   int alreadyPrinted = 0;   void rec(int d, int k, int v, int m) {     if (v == m || alreadyPrinted == N) {       return;     }     if (v == 0) {       cout << 1 <<    ;       alreadyPrinted++;       return;     }     if (d == k) {       for (int i = 0; i < edges[v].size() && alreadyPrinted != N; i++) {         cout << vdiv[edges[v][i]] <<    ;         alreadyPrinted++;       }       return;     }     for (auto u : edges[v]) {       rec(d + 1, k, u, m);     }   }   void solve() {     long long n;     int k;     cin >> n >> k;     vector<long long> div;     for (long long i = 1; i * i <= n; i++) {       if (n % i == 0) {         div.push_back(i);         if (i * i != n) div.push_back(n / i);       }     }     sort(div.begin(), div.end());     int m = div.size();     for (int i = 0; i < m; i++) {       vdiv[i] = div[i];       for (int j = i; j < m; j++) {         if (div[j] % div[i] == 0) edges[j].push_back(i);       }     }     if (k > 0)       rec(1, k, m - 1, m);     else       cout << n <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int a[102][102];   int main() {     int n, m;     cin >> n >> m;     int sum = 0;     for (int i = 0; i < m; i++) {       int x, y, c;       cin >> x >> y >> c;       a[x - 1][y - 1] = c;       sum += c;     }     for (int i = 0; i < n; i++) {       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++) {           int k = 0;           while (k < n && a[i][j] > 0) {             if (a[j][k] > 0) {               int t = min(a[i][j], a[j][k]);               a[j][k] -= t;               a[i][j] -= t;               a[i][k] += t;               sum -= t;             }             k++;           }         }       for (int i = 0; i < n; i++) {         sum -= a[i][i];         a[i][i] = 0;       }     }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long arr[200011];   long long sum[200011];   bool check(int k) {     int i;     for (i = 1; i <= n; i++) sum[i] = 0;     for (i = n; i >= 3; i--) {       if (sum[i] + arr[i] < k) return 0;       long long d = (sum[i] + arr[i] - k) / 3;       long long d3 = d * 3;       d3 = min(d3, arr[i]);       sum[i - 2] += d3 / 3 * 2;       sum[i - 1] += d3 / 3;     }     return sum[2] + arr[2] >= k && sum[1] + arr[1] >= k;   }   int main() {     cin.tie(nullptr);     cout.tie(nullptr);     ios::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       cin >> n;       int i;       for (i = 1; i <= n; i++) cin >> arr[i];       int l = 0, r = 1e9 + 5, mid;       while (l + 1 < r) {         mid = l + r >> 1;         if (check(mid))           l = mid;         else           r = mid;       }       cout << l <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 2 * acos(0.0);   void fastInOut();   int power(int z, int i) {     int zz = 1;     for (int k = 0; k < i; k++) {       zz *= z;     }     return zz;   }   long long power(long long x, long long y) {     long long z = 1;     for (long long i = 0; i < y; i++) z *= x;     return z;   }   unsigned long long power(unsigned long long b, unsigned long long pow) {     if (b == 0)       return 0;     else if (pow == 1)       return b;     else if (pow % 2 == 0)       return power(b * b, pow / 2);     else       return b * power(b * b, pow / 2);   }   int main() {     fastInOut();     int n, x, y, res1 = 0, res2 = 0, sum = 0;     cin >> n;     vector<pair<int, int>> v;     while (n--) {       cin >> x >> y;       v.push_back({x, y});     }     int arr[100000] = {0};     arr[2] = 1;     for (int i = 3; i < 100000; i++) arr[i] = arr[i - 1] + (i - 1);     for (int i = 1; i <= 1000; i++) {       res1 = res2 = 0;       for (int k = 0; k < v.size(); k++) {         if (1 + i == v[k].first + v[k].second) res1++;         if (1 - i == v[k].first - v[k].second) res2++;       }       sum += (arr[res1] + arr[res2]);       res1 = res2 = 0;       if (i > 1 && i < 1000) {         for (int k = 0; k < v.size(); k++) {           if (1000 + i == v[k].first + v[k].second) res1++;           if (1000 - i == v[k].first - v[k].second) res2++;         }       }       sum += (arr[res1] + arr[res2]);     }     cout << sum;   }   void fastInOut() {     ios_base::sync_with_stdio(0);     cin.tie(NULL), cout.tie(NULL);   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long dp[1010][1010], sum[1010];   int main() {     memset(dp, 0, sizeof(dp));     int n, m, r;     cin >> n >> m >> r;     for (int i = 0; i <= 1000; i++) dp[0][i] = 1;     for (int i = 1; i <= r; i++) {       memset(sum, 0, sizeof(sum));       for (int j = 3; j <= 1000; j++) {         sum[j] = (sum[j - 1] + dp[i - 1][j - 2]) % mod;         dp[i][j] = (dp[i][j - 1] + sum[j]) % mod;       }     }     cout << dp[r][n] * dp[r][m] % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 30;   char s[60];   int main() {     cin >> s;     set<string> A;     int n = strlen(s);     for (int i = 0; i < n; ++i) {       string cur;       for (int j = 0; j < n; ++j) {         cur += s[(i + j) % n];       }       A.insert(cur);     }     cout << A.size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     string st;     int l;   };   int n, k, cnt = 0, m;   node a[1000];   bool cmp(const node &x, const node &y) { return (x.l < y.l); }   bool substring(string s1, string s2) {     for (int i = 0; i <= s2.length() - s1.length(); i++) {       bool flag = 1;       for (int j = 0; j < s1.length(); j++) {         if (s2[i + j] != s1[j]) {           flag = 0;           break;         }       }       if (flag) return 1;     }     return 0;   }   bool judge(void) {     for (int i = 1; i < n; i++) {       if (!substring(a[i].st, a[i + 1].st)) {         return 0;       }     }     return 1;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i].st;       a[i].l = a[i].st.length();     }     sort(a + 1, a + n + 1, cmp);     if (judge()) {       cout <<  YES  << endl;       for (int i = 1; i <= n; i++) {         cout << a[i].st << endl;       }     } else {       cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void show(const vector<T> &a) {     for (T x : a) cout << x <<    ;     cout << endl;   }   signed main() {     long long tc;     cin >> tc;     while (tc--) {       long long x, y, z;       cin >> x >> y >> z;       vector<long long> a(3);       a[2] = z;       a[1] = y;       a[0] = x;       sort(a.begin(), a.end());       if (a[2] == a[1]) {         cout <<  YES  << endl;         cout << a[0] <<     << a[0] <<     << a[2] << endl;       } else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d, e, f;     int g = 1000;     cin >> a >> b >> c >> d >> e >> f;     if ((b * d * f) > (a * c * e) || (c == 0 && d != 0) ||         (a == 0 && b != 0 && d != 0))       cout <<  Ron  << endl;     else       cout <<  Hermione  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long f[2000007];   void pre() {     f[0] = 1;     for (int i = 1; i <= 2000001; i++) {       f[i] = i * f[i - 1] % mod;     }   }   long long powmod(long long x, long long n) {     long long res = 1;     while (n) {       if (n & 1) res = res * x % mod;       x = x * x % mod;       n >>= 1;     }     return res;   }   long long C(int n, int k) {     if (k > n) {       return 0;     }     return f[n] * powmod(f[k], mod - 2) % mod * powmod(f[n - k], mod - 2) % mod;   }   int main() {     pre();     int n;     cin >> n;     n++;     long long ans = (2 * C(2 * n - 1, n) + mod - 1) % mod;     cout << ans % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int f = 1, x = 0;     char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) f = -f;       c = getchar();     }     while (isdigit(c)) {       x = (x << 1) + (x << 3) + c -  0 ;       c = getchar();     }     return x * f;   }   const int N = 3e2 + 5;   int n, m, p, q;   pair<int, int> a[N * N];   int id(int i, int j) { return (i - 1) * m + j; }   void work() {     n = read(), m = read();     for (int i = 1; i <= n * m; i++) {       a[i] = (pair<int, int>){read(), i};     }     sort(a + 1, a + 1 + n * m);     for (int i = 1; i <= n * m; i++) {       a[i].second *= -1;     }     int res = 0;     for (int i = 1; i <= n; i++) {       sort(a + id(i, 1), a + id(i, m) + 1);       for (int j = 1; j <= m; j++) {         for (int k = 1; k < j; k++) {           if (a[id(i, j)].second < a[id(i, k)].second) res++;         }       }     }     cout << res <<   n ;   }   int main() {     q = read();     while (q--) work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   long long gcd(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     long long x1, y1;     long long g = gcd(b, a % b, x1, y1);     x = y1;     y1 = x1 - y1 * (a / b);     return g;   }   long long qpow(long long a, long long n) {     long long res = 1;     while (n) {       if (n % 2) {         res = (res * a) % MOD;         n--;       } else {         n = n / 2;         a = (a * a) % MOD;       }     }     return res;   }   long long inv(long long a) { return qpow(a, MOD - 2); }   bool cmp(pair<long long, long long> &p1, pair<long long, long long> &p2) {     if (p1.first != p2.first) return p1.first < p2.first;     return p1.second < p2.second;   }   bool prime(long long n) {     for (long long i = 2; i * i <= n; i++) {       if (n % i == 0) return false;     }     return true;   }   long long sum(long long n) {     long long second = 0;     while (n) {       second += n % 10;       n /= 10;     }     return second;   }   void solve() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long second, x;     cin >> second >> x;     long long c = 0;     vector<long long> a;     for (int i = 0; i < 42; i++) {       if (x & (1LL << i)) {         c++;         second -= (1LL << i);       } else         a.push_back(1LL << (i + 1));     }     if (second < 0) {       cout << 0 <<   n ;       return;     }     sort(a.begin(), a.end(), greater<long long>());     bool ok = false;     for (int i = 0; i < a.size(); i++) {       if (a[i] <= second) {         ok = true;         second -= a[i];       }     }     if (second == 0) {       if (ok)         cout << (1LL << c) <<   n ;       else {         cout << max(0LL, (1LL << c) - 2) <<   n ;       }     } else       cout << 0 <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     while (t--) {       solve();     }     return 0;   }