malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const int LIM = 1e5 + 5;   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     vector<int> x(n), y(n);     for (int i = 0; i < n; i++) cin >> x[i] >> y[i];     if (n % 2) {       cout <<  NO ;       return 0;     } else {       int mid = n / 2;       for (int i = 0; i < mid - 1; i++) {         if (x[i] - x[i + 1] == x[i + mid + 1] - x[i + mid] &&             y[i] - y[i + 1] == y[i + mid + 1] - y[i + mid]) {           continue;         } else {           cout <<  NO ;           return 0;         }       }       cout <<  YES ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isp(const int x) {     if (x <= 1) return false;     for (int i = 2; i * i <= x; ++i)       if (x % i == 0) return false;     return true;   }   int pow(int x, int e, const int MOD) {     int r = 1;     for (; e; e >>= 1, x = (long long)x * x % MOD)       if (e & 1) r = (long long)r * x % MOD;     return r;   }   bool isr(int n, int p) {     for (int i = 2, q = p - 1; i * i <= q; ++i)       if (q % i == 0) {         if (pow(n, i, p) == 1 || pow(n, q / i, p) == 1) return false;       }     return true;   }   int main() {     int n, x;     scanf( %d%d , &n, &x);     if (!isp(n + 1)) return puts( -1 ), 0;     for (--x; x > 1; --x)       if (isr(x, n + 1)) return printf( %d n , x), 0;     return puts( -1 ), 0;   }
#include <bits/stdc++.h>   using namespace std;   long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 3) + (x << 1) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   long long n, w, b, x, c[1005], cost[1005], f[1005][10005], C, a[10005], tot;   long long cmp(long long x, long long y) { return x > y; }   signed main() {     n = read();     w = read();     b = read();     x = read();     for (long long i = 1; i <= n; i++) c[i] = read(), C += c[i];     for (long long i = 1; i <= n; i++) cost[i] = read();     memset(f, -0x3f, sizeof(f));     f[0][0] = w;     for (long long i = 1; i <= n; i++) {       if (i != 1)         for (long long j = 0; j <= C; j++)           f[i][j] = min(f[i - 1][j] + x, w + b * j);       else         for (long long j = 0; j <= C; j++) f[i][j] = f[i - 1][j];       tot = 0;       for (long long k = 1; k <= c[i]; k *= 2) {         a[++tot] = k;         c[i] -= k;       }       if (c[i]) a[++tot] = c[i];       sort(a + 1, a + tot + 1, cmp);       for (long long k = 1; k <= tot; k++) {         for (long long j = C; j >= a[k]; j--) {           if (f[i][j - a[k]] >= cost[i] * a[k])             f[i][j] = max(f[i][j], f[i][j - a[k]] - cost[i] * a[k]);         }       }     }     long long ans = 0;     for (long long i = C; i >= 0; i--) {       if (f[n][i] >= 0) {         ans = i;         break;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void no() { cout <<  NO  << endl; }   void yes() { cout <<  YES  << endl; }   int main() {     int q, n, wyn;     cin >> q;     for (int i = 0; i < q; i++) {       cin >> n;       char a;       string s;       cin >> a;       cin >> s;       if (s.length() == 1 && a >= s[0])         no();       else {         yes();         cout << 2 << endl;         cout << a <<   n  << s << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 10000;   int degree[maxn + 5];   int Cn_i(int n, int i) {     int up = 1;     int down = 1;     for (int t = n; t >= n - i + 1; t--) {       up = up * t;     }     for (int t = i; t >= 1; t--) {       down = down * t;     }     return up / down;   }   int main() {     int n;     while (scanf( %d , &n) != EOF) {       for (int i = 0; i < n; i++) degree[i] = 0;       for (int i = 0; i < n - 1; i++) {         int a, b;         scanf( %d%d , &a, &b);         degree[a]++;         degree[b]++;       }       int ans = 0;       for (int i = 0; i <= n; i++) {         if (degree[i] >= 2) {           ans += Cn_i(degree[i], 2);         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int F[60][60], f[60][60], g[60][60], h[60][60], dp[60][60], fac[60], inv[60],       mod = 1000000007;   int fpow(int a, int b) {     int ans = 1, t = a;     while (b) {       if (b & 1) ans = 1ll * ans * t % mod;       t = 1ll * t * t % mod;       b >>= 1;     }     return ans;   }   int calc(int n, int m, int a, int b) {     int ans = 0;     int cur = 1;     for (int i = 0; i * a <= n && i * b <= m; i++) {       ans = (ans + 1ll * dp[n - i * a][m - i * b] * cur % mod * inv[i]) % mod;       cur = 1ll * cur * (g[a][b] + i) % mod;     }     return ans;   }   int main() {     fac[0] = inv[0] = 1;     for (int i = 1; i <= 51; i++) {       fac[i] = 1ll * fac[i - 1] * i % mod;       inv[i] = fpow(fac[i], mod - 2);     }     int n, m;     scanf( %d%d , &n, &m);     f[0][1] = 1;     dp[0][0] = 1;     for (int i = 1; i <= n; i++) {       for (int j = n + 1; j >= 1; j--) {         F[i - 1][j] = (F[i - 1][j + 1] + f[i - 1][j]) % mod;       }       for (int j = n + 1; j >= 1; j--) {         h[i][j] = 0;         for (int k = 0; k < i; k++) {           h[i][j] = (h[i][j] + 1ll * F[k][j] * F[i - k - 1][j]) % mod;         }         g[i][j] = (h[i][j] - h[i][j + 1] + mod) % mod;       }       for (int j = 1; j <= n + 1; j++) {         for (int x = n; x >= 0; x--) {           for (int y = n + 1; y >= 0; y--) {             dp[x][y] = calc(x, y, i, j);           }         }       }       for (int j = 1; j <= n + 1; j++) {         f[i][j] = dp[i][j - 1];       }     }     printf( %d n , f[n][m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   char s[maxn];   int size[maxn], last[200];   bool isover[maxn];   string ans[maxn], now;   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     cin >> s;     int len = strlen(s);     bool hasdel = false;     now =   ;     for (int no = len - 1; ~no; no--) {       now = s[no] + now;       if (now.size() > 1) {         if (now[0] != now[1]) last[now[0]] = now[1];       }       if (now.size() > 1 && !hasdel) {         if (now[0] == now[1] && now[1] > last[now[1]]) {           now = now.substr(2);           hasdel = true;         }       } else         hasdel = false;       size[no] = now.size();       if (now.size() > 10)         ans[no] = now.substr(0, 5) +  ...  + now.substr(now.size() - 2);       else         ans[no] = now;     }     for (int i = 0; i < len; i++) {       cout << size[i] <<     << ans[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> children[1000005];   int r_1[1000005], r_2[1000005], timer, n, k, p[1000005], mx[1000005 << 2],       inc[1000005 << 2];   stack<int> seq;   vector<int> ans;   void dfs(int node) {     timer++;     r_1[node] = timer;     for (int i = 0; i < children[node].size(); i++) {       int neb = children[node][i];       dfs(neb);     }     r_2[node] = timer;   }   int rt(int r1, int r2, int q1, int q2, int ind, int typ) {     if (q1 > q2) return 0;     if (q1 > r2 || q2 < r1) return 0;     if (q1 <= r1 && q2 >= r2) {       inc[ind] += typ;       return inc[ind] + mx[ind];     } else {       inc[ind * 2] += inc[ind];       inc[ind * 2 + 1] += inc[ind];       inc[ind] = 0;       int mid = (r1 + r2) / 2;       int left = 0, right = 0;       left = rt(r1, mid, q1, q2, ind * 2, typ);       right = rt(mid + 1, r2, q1, q2, ind * 2 + 1, typ);       mx[ind] =           max(mx[ind * 2] + inc[ind * 2], mx[ind * 2 + 1] + inc[ind * 2 + 1]);       return max(left, right);     }   }   int main() {     scanf( %d %d , &n, &k);     for (int i = 0; i < n; i++) scanf( %d , &p[i]);     p[n] = n + 1;     for (int i = 0; i <= n; i++) {       while (seq.size()) {         int top = seq.top();         if (p[top] >= p[i]) break;         children[i].push_back(top);         seq.pop();       }       seq.push(i);     }     dfs(n);     for (int i = n - 1; i >= 0; i--) {       if (i + k <= n) {         ans.push_back(rt(1, timer, r_1[i + k - 1], r_1[i], 1, 0) + 1);         rt(1, timer, r_1[i + k - 1] + 1, r_2[i + k - 1], 1, -1);       }       rt(1, timer, r_1[i] + 1, r_2[i], 1, 1);     }     reverse(ans.begin(), ans.end());     for (int i = 0; i < ans.size(); i++) {       printf( %d  , ans[i]);     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   vector<int> gph[500005];   int n, par[500005], dep[500005], msk[500005];   int dp[500005], sz[500005];   int mx[1 << 22];   int l[23] = {};   void dfs2(int x, vector<pair<int, int> > &v) {     v.push_back(pair<int, int>(dep[x], msk[x]));     for (auto &i : gph[x]) dfs2(i, v);   }   void dfs(int x) {     if (gph[x].empty()) {       mx[msk[x]] = dep[x];       return;     }     for (int i = 1; i < gph[x].size(); i++) {       dfs(gph[x][i]);       vector<pair<int, int> > w;       dfs2(gph[x][i], w);       for (auto &j : w) mx[j.second] = -1;     }     dfs(gph[x][0]);     for (int i = 1; i < gph[x].size(); i++) {       vector<pair<int, int> > w;       dfs2(gph[x][i], w);       for (auto &j : w) {         for (int k = 0; k < 23; k++) {           int val = mx[j.second ^ l[k]];           if (~val) dp[x] = max(dp[x], j.first + val - 2 * dep[x]);         }       }       for (auto &j : w) mx[j.second] = max(mx[j.second], j.first);     }     for (int k = 0; k < 23; k++) {       if (mx[msk[x] ^ l[k]] != -1) {         dp[x] = max(dp[x], mx[msk[x] ^ l[k]] - dep[x]);       }     }     mx[msk[x]] = max(mx[msk[x]], dep[x]);   }   int main() {     scanf( %d , &n);     char ch[6];     for (int i = 0; i < 22; i++) l[i] = (1 << i);     for (int i = 2; i <= n; i++) {       scanf( %d %s , &par[i], ch);       gph[par[i]].push_back(i);       dep[i] = dep[par[i]] + 1;       msk[i] = msk[par[i]] ^ (1 << (*ch -  a ));     }     for (int i = n; i; i--) {       sz[i] = 1;       for (auto &j : gph[i]) sz[i] += sz[j];       sort(gph[i].begin(), gph[i].end(),            [&](const int &a, const int &b) { return sz[a] > sz[b]; });     }     memset(mx, -1, sizeof(mx));     dfs(1);     for (int i = n; i; i--) {       for (auto &j : gph[i]) dp[i] = max(dp[i], dp[j]);     }     for (int i = 1; i <= n; i++) printf( %d  , dp[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int inf = 0x3f3f3f, maxn = 5e5 + 500;   long long gcd(long long x, long long y) {     if (y == 0)       return x;     else       return gcd(y, x % y);   }   long long ksm(long long a, long long b) {     long long r = 1;     while (b) {       if (b & 1) r = (r * a) % mod;       a = a * a % mod;       b >>= 1;     }     return r;   }   int n, m, f[maxn][25] = {0};   int query(int l, int r) {     int sum = 0;     for (int i = 23; i >= 0; i--) {       if (f[l][i] < r && f[l][i] != 0) {         l = f[l][i];         sum += (1 << i);       }     }     if (f[l][0] < r) return -1;     return sum + 1;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> m;     int max1 = 0;     for (int i = 1; i <= n; i++) {       int l, r;       cin >> l >> r;       f[l][0] = max(f[l][0], r);       max1 = max(r, max1);     }     for (int l = 0; l <= max1; l++)       if (l != 0) f[l][0] = max(f[l][0], max(l, f[l - 1][0]));     for (int j = 1; j <= 23; j++)       for (int l = 0; l <= max1; l++) f[l][j] = f[f[l][j - 1]][j - 1];     for (int i = 1; i <= m; i++) {       int l, r;       cin >> l >> r;       int ans = query(l, r);       cout << ans << endl;     }   }
/**     *  Author: N.Nafi1211 || <nomaannafi99@gmail.com> #~#   **/       #include <bits/stdc++.h>   using namespace std;      clock_t startTime;   double getCurrentTime(){    return (double) (clock() - startTime) / CLOCKS_PER_SEC;   }      #define PB push_back      typedef long long ll;   typedef vector<char> vc;   typedef vector<int> vi;   typedef vector<long long> vll;   typedef vector<double> vd;      void solve()   {    string a, b;    cin >> a >> b;    int n = a.length(), m = b.length();       int res = 0;       for(int len=1; len<=min(n, m); ++len) {     for(int i=0; i+len<=n; ++i) {      for(int j=0; j+len<=m; ++j) {       if(a.substr(i, len) == b.substr(j, len)) {        res = max(res, len);       }      }     }    }    int ans = n-res + m-res;    cout << ans <<   n ;    return;      }      int main()   {    ios_base::sync_with_stdio(0);    cin.tie(0);    //startTime = clock();       int t;       cin >> t;       while(t--)     solve();       //printf( %.3lf n , getCurrentTime());    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int test;     cin >> test;     while (test--) {       int n;       cin >> n;       for (int i = 0; i < n; i++) {         cout << 8 <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<pair<int, int> > > adj;   vector<int> in;   vector<int> out;   vector<pair<int, int> > visit;   pair<int, int> cal(int son) {     if (visit[son].first > 0) return visit[son];     if (visit[son].first == -2) return {-1, -1};     visit[son] = {-2, 0};     pair<int, int> temp, ans = {0, 0};     for (int i = 0; i < adj[son].size(); ++i) {       temp = cal(adj[son][i].first);       if (temp.first == -1) return temp;       if (temp.first > ans.first) {         ans.first = temp.first;         ans.second = max(temp.second, adj[son][i].second);       }     }     ++ans.first;     visit[son] = ans;     return visit[son];   }   int main() {     int n, m;     cin >> n >> m;     adj.resize(n + 1);     out.resize(n + 1);     in.resize(n + 1);     visit.resize(n + 1, {-1, 0});     int num1, num2;     for (int i = 0; i < m; ++i) {       cin >> num1 >> num2;       out[num1]++;       in[num2]++;       adj[num1].push_back({num2, i});     }     int node = 0, cnt = 0;     for (int i = 1; i <= n; ++i) {       if (in[i] == 0) {         node = i;         ++cnt;       }     }     if (cnt != 1) {       cout << -1 << endl;       return 0;     }     pair<int, int> temp = cal(node);     if (temp.second == -1 || temp.first != n)       cout << -1 << endl;     else       cout << temp.second + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 2e5 + 5;   pair<long long, long long> a[maxn];   long long n;   long long cnt[maxn][2];   void solve() {     cin >> n;     for (long long i = 1; i <= n; i++)       cnt[i][0] = cnt[i][1] = 0, cin >> a[i].first >> a[i].second;     long long ans = n * (n - 1) * (n - 2) / 6;     for (long long i = 1; i <= n; i++) {       cnt[a[i].first][0]++;       cnt[a[i].second][1]++;     }     for (long long i = 1; i <= n; i++) {       ans -= (cnt[a[i].first][0] - 1) * (cnt[a[i].second][1] - 1);     }     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   const long long int mod = 1e9 + 7;   const long long int MAX = LLONG_MAX;   const long long int MIN = LLONG_MIN;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int n, k;     cin >> n >> k;     long long int a[n];     for (long long int i = 0; i < n; i++) cin >> a[i];     map<long long int, long long int> mp;     long long int c = 0;     deque<long long int> d;     for (long long int i = 0; i < n; i++) {       if (c < k) {         if (mp[a[i]] == 0) {           d.push_front(a[i]);           mp[a[i]]++;           c++;         } else {         }       } else {         long long int x = d.back();         if (mp[a[i]] != 0) {         } else {           mp[x] = mp[x] - 1;           d.pop_back();           d.push_front(a[i]);           mp[a[i]]++;         }       }     }     cout << d.size() <<   n ;     for (auto i = d.begin(); i != d.end(); i++) {       cout << *i <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[100005];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     long i;     for (i = 0; i <= n - 1; i++) cin >> a[i];     sort(a, a + n);     long long pc = 1, qc = 1, rc = 1;     long long b[3];     long long p = a[0], q = a[1], r = a[2];     if (p == q && q == r) {       long long c = 3;       for (i = 3; i <= n - 1; i++)         if (a[i] == p) c++;       cout << c * (c - 1) * (c - 2) / 6;     } else if (p == q) {       long long pc = 2, rc = 1;       for (i = 3; i <= n - 1; i++)         if (a[i] == p)           pc++;         else if (a[i] == r)           rc++;       cout << pc * (pc - 1) * rc / 2;     } else if (q == r) {       long long pc = 1, rc = 2;       for (i = 3; i <= n - 1; i++)         if (a[i] == p)           pc++;         else if (a[i] == r)           rc++;       cout << rc * (rc - 1) * pc / 2;     } else {       long long rc = 1;       for (i = 3; i <= n - 1; i++)         if (a[i] == r) rc++;       cout << rc;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   signed main() {     long long int t;     cin >> t;     vector<long long int> nums = {6, 10, 14, 15};     long long int minS = nums[0] + nums[1] + nums[2];     long long int maxS = nums[0] + nums[1] + nums[3];     while (t--) {       long long int n;       cin >> n;       if (n <= minS)         cout <<  NO n ;       else {         long long int d = n - minS;         if (d == nums[0] || d == nums[1] || d == nums[2]) {           if (n <= maxS)             cout <<  NO n ;           else             cout <<  YES n                   << 6 <<     << 10 <<     << 15 <<     << n - maxS <<   n ;         } else           cout <<  YES n  << 6 <<     << 10 <<     << 14 <<     << d <<   n ;       }     }     return 0;   }
#include<cstdio>   const int N=100005;   int n,a[100005];   inline int ask2(int x){       if(a[x]) return a[x];       printf( ? %d n ,x);       fflush(stdout);       scanf( %d ,a+x);       return a[x];   }   inline int ask(int x){       if(ask2(x)>ask2(x+1)) return 1;       else  return 0;   }   int main(){       scanf( %d ,&n);       a[0]=a[n+1]=1e9;       int l=1,r=n;       int mid=(l+r)/2;       while(r-l>20){           mid=(l+r)/2;           if(ask(mid)) l=mid+1;           else r=mid;       }       for(int i=l-1;i<=r+1;i++)           ask2(i);       for(int i=l;i<=r;i++){           if(a[i]<a[i+1]&&a[i]<a[i-1]){               printf( ! %d n ,i);               return 0;           }       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e3, MOD = (1e9) + 7;   int n, m, k, A[N + 9][N + 9], row[N + 9], col[N + 9], x, y;   char c;   void init() {     for (int i = 0; i < N + 5; ++i) row[i] = col[i] = i;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     init();     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) scanf( %d , &A[i][j]);     }     for (int i = 0; i < k; ++i) {       cin.ignore();       scanf( %c %d %d , &c, &x, &y);       switch (c) {         case  c :           swap(col[x], col[y]);           break;         case  r :           swap(row[x], row[y]);           break;         case  g :           printf( %d n , A[row[x]][col[y]]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void my_dbg() { cout << endl; }   template <typename Arg, typename... Args>   void my_dbg(Arg A, Args... B) {     cout <<     << A;     my_dbg(B...);   }   using ll = long long;   using vi = vector<int>;   using vl = vector<ll>;   using pii = pair<int, int>;   const int inf = INT_MAX;   const int ninf = INT_MIN;   const int mod = 1e9 + 7;   const int maxN = 2e5 + 2;   void solve() {     int n, m;     scanf( %d , &n);     scanf( %d , &m);     vector<pii> a(m);     for (int i = (int)(0); i < (int)(m); i++) {       scanf( %d , &a[i].first);       scanf( %d , &a[i].second);     }     sort(a.begin(), a.end(), [&](pii a, pii b) { return a.second < b.second; });     ll sum = 0, ans = 0;     multiset<int> ms;     for (int i = (int)(0); i < (int)(m); i++) {       while ((int)ms.size() and              (*ms.begin() < a[i].second or (int) ms.size() >= n)) {         sum -= *ms.begin();         ms.erase(ms.begin());       }       sum += a[i].first;       ll cur = sum;       ll rem = n - (int)ms.size() - 1;       cur += rem * a[i].second;       ans = max(ans, cur);       ms.insert(a[i].first);     }     printf( %lld n , ans);   }   int main() {     int t = 1;     scanf( %d , &t);     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     string s;     cin >> s;     long long int a = 0, b = 0, c = 0;     for (int i = 0; i < s.length(); i++) {       if (i > 0 && s[i - 1] ==  v  && s[i] ==  v ) {         a++;         c += b;       } else if (s[i] ==  o ) {         b += a;       }     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, x, nr;   bool kgood(int N, int K) {     int i, ap[10] = {0};     while (N) {       ++ap[N % 10];       N /= 10;     }     for (i = 0; i <= K; ++i)       if (!ap[i]) return false;     return true;   }   int main() {     int i;     scanf( %d%d , &n, &k);     for (i = 0; i < n; ++i) {       scanf( %d , &x);       if (kgood(x, k)) ++nr;     }     printf( %d n , nr);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long add(long long a, long long b) {     a += b;     if (a >= 1000000007) {       a -= 1000000007;     }     return a;   }   long long sub(long long a, long long b) {     a -= b;     if (a < 0) {       a += 1000000007;     }     return a;   }   long long mul(long long a, long long b) { return (a * b) % 1000000007; }   void add_self(long long& a, long long b) { a = add(a, b); }   void sub_self(long long& a, long long b) { a = sub(a, b); }   void mul_self(long long& a, long long b) { a = mul(a, b); }   const long long MAXN = 200010;   long long get(long long val, long long tot) {     long long ans = 0;     long long L = val, R = val + 1 - (val % 2);     while (R <= tot) {       ans += R - L + 1;       L = 2 * L;       R = 2 * R + 1;     }     ans += max(0LL, tot - L + 1);     return ans;   }   int main() {     long long x, k;     cin >> x >> k;     long long lo = 0, hi = 1e18, ans = 0;     while (lo <= hi) {       long long mid = (lo + hi) / 2;       if (get(2 * mid + 1, x) >= k) {         ans = 2 * mid + 1;         lo = mid + 1;       } else {         hi = mid - 1;       }     }     lo = 0;     hi = 1e18;     while (lo <= hi) {       long long mid = (lo + hi) / 2;       if (get(2 * mid, x) >= k) {         ans = max(ans, 2 * mid);         lo = mid + 1;       } else {         hi = mid - 1;       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int flag = 0;     if (s.length() < 7) {       cout <<  NO n ;       return 0;     }     for (int i = 0; i <= s.length() - 7; i++) {       flag = 0;       for (int j = i; j < i + 7; j++) {         if (s[i] == s[j])           continue;         else {           flag = 1;           break;         }       }       if (flag == 0) {         cout <<  YES n ;         return 0;       }     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long d[61];   int ans;   int n, a[200005];   void insert() {     for (int i = 1; i <= n; i++) {       long long x = a[i];       for (int j = 60; j >= 0; j--)         if (x & (1LL << j)) {           if (d[j] == 0) {             d[j] = x;             ans++;             break;           } else             x ^= d[j];         }     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), a[i] ^= a[i - 1];     if (a[n] == 0) {       printf( -1 n );       return 0;     }     insert();     printf( %d n , ans);   }