malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   typedef signed long long ll;      #define _P(...) (void)printf(__VA_ARGS__)   #define FOR(x,to) for(x=0;x<(to);x++)   #define FORR(x,arr) for(auto& x:arr)   #define FORR2(x,y,arr) for(auto& [x,y]:arr)   #define ALL(a) (a.begin()),(a.end())   #define ZERO(a) memset(a,0,sizeof(a))   #define MINUS(a) memset(a,0xff,sizeof(a))   template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}   template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}   //-------------------------------------------------------      int T,N,A[5050],S[5050];      ll dp[5050];      void solve() {    int i,j,k,l,r,x,y; string s;        cin>>T;    while(T--) {     cin>>N;     FOR(i,N) cin>>A[i];     FOR(i,N) cin>>S[i];     FOR(i,N+1) dp[i]=-1LL<<60;          ll ret=0;     FOR(i,N) {      ll ma=0;      for(j=i-1;j>=0;j--) if(A[i]!=A[j]) {       ll nma=ma+abs(S[i]-S[j]);       ma=max(ma,dp[j]+abs(S[i]-S[j]));       dp[j]=max(dp[j],nma);      }      dp[i]=ma;     }     FOR(i,N) ret=max(ret,dp[i]);     cout<<ret<<endl;    }   }         int main(int argc,char** argv){    string s;int i;    if(argc==1) ios::sync_with_stdio(false), cin.tie(0);    FOR(i,argc-1) s+=argv[i+1],s+=  n ; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);    cout.tie(0); solve(); return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename type>   type input() {     type var;     cin >> var;     return var;   }   template <typename type>   void input(type &var) {     cin >> var;     return;   }   template <typename type>   void output(type &var, const char *ch) {     cout << var << ch;   }   int main() {     long long a, b, N, p, r, c, d, e, f;     cin >> N >> p;     vector<pair<long long, long long> > v(N);     vector<double> w(N);     for (int i = 0; i < N; i++) {       cin >> a >> b;       v[i].first = b - a + 1;       v[i].second = b / p - (a - 1) / p;     }     double s = 0;     for (int i = 0; i < N; i++) {       c = v[i].first, e = v[(i + 1) % N].first, d = v[i].second,       f = v[(i + 1) % N].second;       w[i] = 2000 * ((c * e - (c - d) * (e - f)) / (c * e * 1.0));       s += w[i];     }     cout << setiosflags(ios::showpoint) << setiosflags(ios::fixed)          << setprecision(9) << s << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     long long int n, b, c, i;     float a, d;     scanf( %I64d , &n);     a = sqrt(n);     b = floor(a);     for (i = b; i > 0; i--) {       d = n % i;       if (d == 0)         break;       else         continue;     }     c = n / i;     printf( %I64d %I64d , i, c);   }
#include <bits/stdc++.h>   using namespace std;   struct Edge {     int v, u;     long long cap, cost;     Edge() : v(), u(), cap(), cost() {}     Edge(int _v, int _u, long long _cap, long long _cost)         : v(_v), u(_u), cap(_cap), cost(_cost) {}   };   const long long INF1 = (long long)1e9;   const long long INF2 = (long long)1e15;   const int E = (int)4e4;   const int V = 200;   int S, T;   int n, k;   int a[V];   long long c[V];   Edge ed[E];   int edSz;   long long dist[V];   int par[V];   void addEdge(int v, int u, long long cap, long long cost) {     ed[edSz++] = Edge(v, u, cap, cost);     ed[edSz++] = Edge(u, v, 0, -cost);   }   long long flow() {     for (int i = 0; i <= S; i++) dist[i] = INF2;     dist[S] = 0;     bool ch = true;     while (ch) {       ch = false;       for (int i = 0; i < edSz; i++) {         Edge e = ed[i];         if (e.cap <= 0) continue;         if (dist[e.v] == INF2) continue;         long long w = dist[e.v] + e.cost;         if (w >= dist[e.u]) continue;         dist[e.u] = w;         par[e.u] = i;         ch = true;       }     }     long long res = 0;     int v = T;     while (v != S) {       int id = par[v];       ed[id].cap--;       ed[id ^ 1].cap++;       res += ed[id].cost;       v = ed[id].v;     }     return res;   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       a[i]--;     }     for (int i = 0; i < n; i++) scanf( %lld , &c[i]);     S = 2 * n;     T = 2 * n - 1;     for (int i = 0; i < n; i++) addEdge(2 * i, 2 * i + 1, 1, -INF1);     for (int i = 0; i < 2 * n - 1; i++) addEdge(i, T, INF1, 0);     addEdge(S, T, INF1, 0);     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         long long w = (a[i] == a[j] ? 0 : c[a[j]]);         addEdge(2 * i + 1, 2 * j, INF1, w);       }       addEdge(S, 2 * i, INF1, c[a[i]]);     }     long long ans = INF1 * n;     for (int i = 0; i < k; i++) ans += flow();     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long s = 0, w = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) s = s * 10 + ch -  0 , ch = getchar();     return s * w;   }   void put1() { puts( YES ); }   void put2() { puts( NO ); }   const int manx = 3e5 + 5;   ;   long long a[manx], dp[manx];   int main() {     long long n, m, ans = -0x3f3f3f3f;     n = read(), m = read();     for (int i = 1; i <= n; i++) {       a[i] = read();       dp[0] = max((long long)0, dp[0] + a[i]);       dp[1] = max(dp[0], dp[1] + a[i] * m);       dp[2] = max(dp[1], dp[2] + a[i]);       ans = max(ans, dp[2]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int inf = (long long int)1e18 + 10;   long long int dp[102][102] = {{0}};   map<char, long long int> m;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n, k;     string s;     cin >> n >> k;     cin >> s;     m[s[0]] = 1;     dp[0][0] = 1;     dp[1][0] = 1;     dp[1][1] = 1;     for (long long int i = 2; i <= n; i++)       for (long long int j = 0; j <= i; j++) {         if (j <= i - 1) dp[i][j] = dp[i - 1][j];         if (j == 1) {           dp[i][1] += (m.find(s[i - 1]) == m.end());           m[s[i - 1]] = 1;         } else {           dp[i][j] += dp[i - 1][j - 1];           long long int r = -1;           for (long long int k = i - 2; k >= 0; k--) {             if (s[k] == s[i - 1]) {               r = k;               break;             }           }           if (r != -1) dp[i][j] -= dp[r][j - 1];         }       }     long long int ans = 0;     for (long long int i = n; i >= 0; i--) {       if (dp[n][i] >= k) {         ans += k * (n - i);         k = 0;         break;       } else {         ans += dp[n][i] * (n - i);         k -= dp[n][i];       }     }     if (k == 0) {       cout << ans <<   n ;     } else {       cout <<  -1 n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, tem;     cin >> s;     int m = s.size();     for (int i = 0; i < m; i++) {       if (s[i] !=  a ) tem += s[i];     }     int n = tem.size() / 2;     string sub1 = tem.substr(0, n);     string sub2 = s.substr(m - n, m);     if (sub1 == sub2 && tem.size() % 2 == 0) {       for (int i = 0; i < (m - n); i++) {         cout << s[i];       }     } else {       cout <<  :(  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   bool mmax(T &m, const T q) {     if (m < q) {       m = q;       return true;     } else       return false;   }   template <typename T>   bool mmin(T &m, const T q) {     if (m > q) {       m = q;       return true;     } else       return false;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long l, r, k;     cin >> l >> r >> k;     long long p = 1, f = 0;     long long ans = 0;     while (1) {       if (p >= l) {         if (p <= r) {           f = 1;           cout << p <<    ;         } else           break;       }       if ((p) > 1e18 / k) break;       p *= k;     }     if (f == 0) cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool mustnot[100005];   char opr[100005];   int sum[100005];   int apr[100005];   int sat[100005];   int res[100005];   int a[100005];   int n, m, rc;   void work() {     int i;     memset(apr, -1, sizeof(apr));     for (i = 1; i <= m; ++i)       if (opr[i] ==  + ) {         if (sat[a[i]] != i - 1) mustnot[a[i]] = 1;         apr[a[i]] = 0;         sat[a[i]] = i;       } else {         ++sum[sat[a[i]] + 1];         --sum[i];         apr[a[i]] = 1;         sat[a[i]] = i;       }     for (i = 1; i <= n; ++i) {       if (apr[i] == 1) {         if (sat[i] != m) mustnot[i] = 1;       }       if (apr[i] == 0) ++sum[sat[i] + 1], --sum[m + 1];     }     for (i = 1; i <= m; ++i) sum[i] += sum[i - 1];     for (i = 1; i <= m; ++i)       if (sum[i]) mustnot[a[i]] = 1;     for (i = 1; i <= n; ++i)       if (!mustnot[i]) res[++rc] = i;   }   int main() {     int i;     scanf( %d%d n , &n, &m);     for (i = 1; i <= m; ++i) scanf( %c %d n , &opr[i], &a[i]);     work();     printf( %d n , rc);     for (i = 1; i <= rc; ++i) printf( %d  , res[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int Q;     cin >> Q;     while (Q--) {       string s;       cin >> s;       vector<int> num, vec;       int n = s.size();       for (int i = 4; i < n; i++) num.push_back(s[i] -  0 );       n = num.size();       int x = num.back();       unsigned long long ans = 1989;       while (ans % 10 != x) ans++;       num.pop_back();       vec.push_back(x);       ans /= 10;       while (num.size()) {         x = num.back();         ans++;         while (ans % 10 != x) ans++;         ans /= 10;         vec.push_back(x);         num.pop_back();       }       if (ans) cout << ans;       for (int i = n - 1; i >= 0; i--) cout << vec[i];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void chmax(T& a, const T& b) {     if (a < b) a = b;   }   template <typename T>   void chmin(T& a, const T& b) {     if (a > b) a = b;   }   int N, M;   long long dp[3001][3001];   const long long INF = 1e17;   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     cin >> N;     vector<int> A(N), B(N);     for (int i = (0); i < (N); i++) {       cin >> A[i];       A[i] -= i;       B[i] = A[i];     }     sort((B).begin(), (B).end());     B.erase(unique((B).begin(), (B).end()), B.end());     M = B.size();     fill(dp[0], dp[N + 1], INF);     dp[0][0] = 0;     for (int i = (0); i < (N); i++) {       for (int j = (0); j < (M); j++) {         chmin(dp[i + 1][j], dp[i][j] + abs(A[i] - B[j]));         chmin(dp[i][j + 1], dp[i][j]);       }     }     long long ans = INF;     for (int i = (0); i < (M); i++) {       chmin(ans, dp[N][i]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 2000005;   const long long mod = 998244353;   long long n, ans, cn[maxn], pow3[maxn], pow1m[maxn];   void exgcd(long long a, long long b, long long &x, long long &y) {     if (!b) {       x = 1, y = 0;     } else {       exgcd(b, a % b, y, x);       y -= x * (a / b);     }   }   long long inv(long long a) {     long long x, y;     exgcd(a, mod, x, y);     return (x + mod) % mod;   }   long long quickpow(long long a, long long b) {     a %= mod;     (a += mod) %= mod;     long long ans = 1;     while (b) {       if (b & 1) (ans *= a) %= mod;       (a *= a) %= mod;       b >>= 1;     }     return ans;   }   int main() {     cin >> n;     cn[0] = pow3[0] = pow1m[0] = 1;     for (long long i = 1; i <= n; ++i) {       cn[i] = (cn[i - 1] * (n - i + 1) % mod) * inv(i) % mod;     }     for (long long i = 1; i < maxn; ++i) {       pow3[i] = pow3[i - 1] * 3 % mod;       pow1m[i] = mod - pow1m[i - 1];     }     for (long long i = 0; i < n; ++i) {       (ans += cn[i] * pow1m[i + 1] % mod *               ((quickpow(1 - pow3[i], n) - quickpow(-pow3[i], n) + mod) % mod) %               mod) %= mod;     }     (ans *= 3) %= mod;     for (int i = 1; i <= n; ++i) {       (ans += cn[i] * pow1m[i + 1] % mod * pow3[i] % mod *               quickpow(pow3[n], n - i) % mod * 2 % mod) %= mod;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   int main() {     long long int n, m, i, j, x, y, l = INF, u = 0;     cin >> n >> m;     if (m == 0)       cout << n - 1 << endl;     else {       for (i = 0; i < m; i++) {         cin >> x >> y;         if (y < x) swap(x, y);         u = max(u, x);         l = min(l, y);       }       if (l - u > 0)         cout << l - u << endl;       else         cout << 0 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   ostream& operator<<(ostream& a, const vector<int>& b) {     for (auto k : b) cout << k <<    ;     return a;   }   istream& operator>>(istream& a, pair<int, int>& b) {     cin >> b.first >> b.second;     return a;   }   ostream& operator<<(ostream& a, const pair<int, int>& b) {     cout <<  {  << b.first <<  ,   << b.second <<  } ;     return a;   }   template <typename T1, typename T2>   inline void chkmin(T1& x, const T2& y) {     if (x > y) x = y;   }   template <typename T1, typename T2>   inline void chkmax(T1& x, const T2& y) {     if (x < y) x = y;   }   const int INF = 1e9;   mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());   const int MAXN = 2001;   int n;   int dp[MAXN][MAXN];   vector<vector<int>> prefs, preft;   string s, t;   bool have(int i, int j, char k) {     if (j == 0) return preft[i - 1][k -  a ];     return preft[i - 1][k -  a ] - prefs[j - 1][k -  a ];   }   void solve() {     cin >> n;     cin >> s >> t;     prefs.assign(n, vector<int>(26, 0));     preft.assign(n, vector<int>(26, 0));     prefs[0][s[0] -  a ] = 1;     for (int i = 1; i < n; i++) {       prefs[i] = prefs[i - 1];       prefs[i][s[i] -  a ]++;     }     preft[0][t[0] -  a ] = 1;     for (int i = 1; i < n; i++) {       preft[i] = preft[i - 1];       preft[i][t[i] -  a ]++;     }     if (prefs[n - 1] != preft[n - 1]) {       cout <<  -1 n ;       return;     }     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= n; j++) {         dp[i][j] = INF;       }     }     dp[0][0] = 0;     for (int i = 0; i < n; i++) {       dp[i + 1][0] = i + 1;       for (int j = 0; j <= i; j++) {         if (have(i + 1, j, s[j]) && dp[i + 1][j + 1] > dp[i + 1][j]) {           dp[i + 1][j + 1] = dp[i + 1][j];         }         if (s[j] == t[i] && dp[i + 1][j + 1] > dp[i][j]) {           dp[i + 1][j + 1] = dp[i][j];         }         if (dp[i + 1][j + 1] > dp[i][j + 1] + 1) {           dp[i + 1][j + 1] = dp[i][j + 1] + 1;         }       }     }     cout << dp[n][n] <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int q;     cin >> q;     while (q--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x7f7f7f7f;   const int maxn = 1111;   const int mod = 1000000007;   const double eps = 1e-8;   bool vis[maxn][maxn];   int n, k;   vector<pair<int, int> > ans;   bool solve() {     for (int i = 1; i <= n; i++) {       int cnt = 0;       for (int j = 1; j <= n; j++) {         if (vis[i][j]) continue;         if (i == j) continue;         vis[i][j] = vis[j][i] = true;         cnt++;         ans.push_back(make_pair(i, j));         if (cnt == k) break;       }       if (cnt != k) return false;     }     return true;   }   int main() {     while (cin >> n >> k) {       if (!solve())         puts( -1 );       else {         cout << ((int)ans.size()) << endl;         for (int i = 0; i < ((int)ans.size()); i++)           printf( %d %d n , ans[i].first, ans[i].second);       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int i, ar[3];     cin >> ar[0] >> ar[1] >> ar[2];     int person = 0;     for (i = 0; i < 3; i++)       if (ar[i] > 0) {         ar[i]--;         person++;       }     sort(ar, ar + 3);     if (ar[0] > 0 && ar[2] > 0) {       person++;       ar[0]--;       ar[2]--;     }     if (ar[1] > 0 && ar[2] > 0) {       person++;       ar[2]--;       ar[1]--;     }     if (ar[0] > 0 && ar[1] > 0) {       person++;       ar[0]--;       ar[1]--;     }     if (ar[0] && ar[1] && ar[2]) {       person++;     }     cout << person << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int T = 1;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   const int maxm = 1e5 + 5;   const int INF = 0x3f3f3f3f;   int main() {     int l, p, q;     scanf( %d%d%d , &l, &p, &q);     printf( %.10lf n , l * 1.0 / (p + q) * 1.0 * p);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int maxn = 1e6;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n, m, k;     cin >> n >> m >> k;     vector<int> a(maxn, 0);     for (int i = 0; i < n; i++) {       int x;       cin >> x;       x--;       a[x] = 1;     }     int ans = 0;     int cur = 0;     for (int i = 0; i < maxn; i++) {       cur += a[i];       if (i >= m) cur -= a[i - m];       if (cur == k) ans++, cur--, a[i] = 0;     }     cout << ans;   }
//manish kumar patel   #include<bits/stdc++.h>   using namespace std;            #define ll long long   #define ld long double   #define rep(i,a,b) for(ll i=a;i<b;i++)   #define repb(i,a,b) for(ll i=a;i>=b;i--)   #define err() cout<< -------------------------- <<endl;    #define errA(A) for(auto i:A)   cout<<i<<   ;cout<<endl;   #define err1(a) cout<<#a<<   <<a<<endl            #define err2(a,b) cout<<#a<<   <<a<<   <<#b<<   <<b<<endl   #define err3(a,b,c) cout<<#a<<   <<a<<   <<#b<<   <<b<<   <<#c<<   <<c<<endl   #define err4(a,b,c,d) cout<<#a<<   <<a<<   <<#b<<   <<b<<   <<#c<<   <<c<<   <<#d<<   <<d<<endl   #define pb push_back   #define all(A)  A.begin(),A.end()   #define allr(A)    A.rbegin(),A.rend()   #define ft first   #define sd second      #define pii pair<int,int>   #define pll pair<ll,ll>   #define V vector<ll>   #define S set<ll>   #define VV vector<V>   #define Vpll vector<pll>    #define yupp cout<< YES <<endl;   #define nope cout<< NO <<endl;   #define endl   n    // bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)    // {    //     return (a.second < b.second);    // }    // int parent(int i,V &a)   // {   //     if(a[i]==i)   //         return i;   //     return parent(a[i],a);   // }   // void make_par(V &a,int x,int y)   // {   //     int para=parent(x,a);   //     int parb=parent(y,a);   //     a[parb]=para;   // }   // // int comb[1001][1001];   // // rep(i,0,1001)   // // {   // //  rep(j,0,1001)   // //  {   // //   if(i==0 || j==0)   // //   {   // //    comb[i][j]=1;   // //   }   // //   else   // //   {   // //    comb[i][j]=comb[i-1][j-1]+comb[i-1][j];   // //   }   // //  }   // // }   int divi(int n)   {    int kk=-1;    repb(i,sqrt(n)+1,2)    {     if(n%i==0)      return i;    }    return -1;   }   int main()       {              #ifndef ONLINE_JUDGE            clock_t tStart = clock();           freopen( input.txt , r ,stdin);           freopen( output.txt , w ,stdout);           #endif           int t;           cin>>t;           // t=1;                while(t--)           {            int n;            cin>>n;            ll *a=new ll [n];            ll s=0;            rep(i,0,n)            {             cin>>a[i];             s+=a[i];            }            sort(a,a+n);            ll x=0;            rep(i,0,n)            {             x=max(x,a[i]*(n-1)-s);            }            cout<<max(x,((s+n-2)/(n-1))*(n-1)-s)<<endl;           }           #ifndef ONLINE_JUDGE               printf(  nRun Time -> %.10fs n , (double)(clock()-tStart) / CLOCKS_PER_SEC);               #endif   }
#include <bits/stdc++.h>   using namespace std;   bool comp(const pair<int, int> &a, const pair<int, int> &b) {     return (a.first > b.first && a.second < b.second);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int a[4], i;     for (i = 0; i < 4; i++) {       cin >> a[i];     }     sort(a, a + 4);     if (a[1] + a[2] > a[3] || a[2] < a[1] + a[0]) {       cout <<  TRIANGLE ;     } else if (a[1] + a[2] == a[3] || a[2] == a[1] + a[0]) {       cout <<  SEGMENT ;     } else {       cout <<  IMPOSSIBLE ;     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     vector<pair<int, int> > dp(n);     dp[n - 1].second = 0;     dp[n - 1].first = 1;     int mx = 0;     for (int i = n - 2; i > -1; i--) {       if (a[i + 1] > a[i])         dp[i].second = dp[i + 1].second + 1;       else         dp[i].second = 0;       if (a[i] < a[i + 1]) {         dp[i].first = dp[i + 1].first + 1;       } else         dp[i].first = 1;       if (i < n - 2 && a[i + 2] > a[i])         dp[i].second = max(dp[i].second, dp[i + 2].first + 1);       mx = max(mx, dp[i].first);       mx = max(mx, dp[i].second);     }     cout << mx;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   const long long MOD = 1e9 + 7;   long long s, x;   int a[50], n, ans0[1 << 21], ans1[1 << 21];   void work(int* ans, int s, int t) {     int len = (t - s + 1);     for (int i = 0; i < (1 << len); i++) {       int tem = 0;       for (int j = 1; j <= len; j++)         if ((i >> (j - 1)) & 1) {           if (a[s + j - 1] == 0) tem += 1 << j;           if (a[s + j - 1] == 1) tem += 1 << (j - 1);         } else {           if (a[s + j - 1] == 0) tem += 0;           if (a[s + j - 1] == 1) tem += 1 << (j - 1);         }       ans[++ans[0]] = tem;     }   }   int main() {     cin >> s >> x;     n = 0;     long long pp = x;     while (pp > 0) {       a[++n] = pp & 1;       pp = pp / 2;     }     int qq = 0, t = 0;     pp = s;     while (pp > 0) {       qq++;       pp /= 2;     }     n = max(n, qq);     t = n / 2;     work(ans0, 1, t);     work(ans1, t + 1, n);     sort(ans0 + 1, ans0 + ans0[0] + 1);     long long ans = 0;     for (int i = 1; i <= ans1[0]; i++) {       long long tem = s - (((long long)ans1[i]) << t);       ans += upper_bound(ans0 + 1, ans0 + ans0[0] + 1, tem) -              lower_bound(ans0 + 1, ans0 + ans0[0] + 1, tem);     }     if ((s xor 0) == x) ans -= 2;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, x, y;     cin >> n >> x >> y;     if (y < n) {       cout <<  -1  << endl;       return 0;     }     long long a = y - n + 1;     unsigned long long ans = 0;     ans += n - 1 + a * a;     if (ans < x) {       cout <<  -1  << endl;       return 0;     }     a = (y - n) + 1;     cout << a << endl;     for (int i = 0; i < n - 1; i++) cout << 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int size = 50 + 10;   int n, k, aim[size], num[size], ans = -1;   int main() {     cin >> n >> k;     if (k > n) {       cout << -1 << endl;       return 0;     }     for (int i = 1; i <= n; i++) cin >> aim[i];     sort(aim + 1, aim + n + 1);     num[1] = 0;     for (int i = 2; i <= n; i++)       if (aim[i] > aim[i - 1])         num[i] = i - 1;       else         num[i] = num[i - 1];     for (int i = 1; i <= n; i++)       if (aim[i] != aim[i + 1] && n - num[i] == k) ans = aim[i];     if (ans < 0) {       cout << ans << endl;       return 0;     }     cout << ans <<     << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     long long n, m;     long long mn, mx;     cin >> n >> m;     mn = n;     mn = max(0ll, n - 2 * m);     cout << mn <<    ;     long long cnt = 0;     while (m > 0) {       m -= cnt;       cnt++;     }     cout << max(0ll, n - cnt) <<   n ;   }