malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ui32 = unsigned int;   using i64 = long long;   using f64 = long double;   using ui64 = unsigned long long;   void read(int& x) { scanf( %d , &x); }   void read(int n, vector<int>& a) {     for (int i = 0; i < n; i++) read(a[i]);   }   void read(int n, int* a) {     for (int i = 0; i < n; i++) read(a[i]);   }   void write(int x) { printf( %d n , x); }   void print(int x) { printf( %d  , x); }   void write(int n, vector<int> a) {     for (int i = 0; i < n; i++) printf( %d n , a[i]);   }   void print(int n, int* a) {     for (int i = 0; i < n; i++) printf( %d  , a[i]);   }   void print(string s) { printf( %s n , s.c_str()); }   i64 z[3 * 100007], lcp[3 * 100007], cnt[3 * 100007];   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string s, t;     cin >> s >> t;     string concate = t +  #  + s;     i64 n = (i64)(concate.size()), m = (i64)(t.size());     i64 l = 0;     i64 r = 0;     for (i64 i = 0; i < n; i++) {       if (i > r) {         l = i;         r = i;         while (r < n && concate[r - l] == concate[r]) {           r++;         }         z[i] = r - l;         r--;       } else {         i64 k = i - l;         if (z[k] < r - i + 1)           z[i] = z[k];         else {           l = i;           while (r < n && concate[r - l] == concate[r]) {             r++;           }           z[i] = r - l;           r--;         }       }     }     n = (i64)(s.size());     for (i64 i = m + 2; i < n + m + 1; i++) {       cnt[z[i]]++;     }     for (i64 i = m; i > 0; i--) {       cnt[i - 1] += cnt[i];     }     l = 0;     r = 1;     while (r != m) {       if (t[l] == t[r]) {         l++;         lcp[r] = l;         r++;       } else {         if (l == 0) {           lcp[r] = 0;           r++;         } else {           l = lcp[l - 1];         }       }     }     i64 ans = n * m;     for (i64 i = 0; i < m; i++) {       if (lcp[i] != 0) {         ans -= cnt[i + 1 - lcp[i]];       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int isprime(int n) {     int i;     for (i = 2; i * i <= n; i++) {       if (n % i == 0) return 0;     }     return 1;   }   int main() {     long long int n, k = 0, i = 0, m, x = 0, y, q, r, s, l, t, a, v0, v1, c, b,                      j = 0, d = 0, ct = 0, sum = 0, h[1000009] = {0},                      temp = 10000, fl = 0;     cin >> c >> v0 >> v1 >> a >> l;     for (i = 0;; i++) {       if ((v0 + a * i) <= v1)         c = c - (v0 + a * i);       else         c -= v1;       if (c <= 0) break;       c += l;     }     cout << i + 1;   }
#include <bits/stdc++.h>   using namespace std;   void GO() {     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);   }   const long long INF = 1e9;   const long long mod = (1e9) + 7;   const int maxn = (int)100;   const long double PI = acos(-1.0);   const long double eps = 0.000000001;   mt19937 rnd(time(0));   long long step[19];   long long lower(long long a_0, long long d, long long k) {     long long l = 0, r = INF;     while (r - l > 1) {       long long m = r + l >> 1;       long long a_m = a_0 + d * (m - 1);       long long sum = (a_0 + a_m) * m / 2;       (sum >= k ? r : l) = m;     }     return l;   }   void solve1(long long k) {     for (long long i = 1; i < 19; ++i) {       long long plus = i * (step[i] - step[i - 1]);       if (plus == k) {         cout <<  9 n ;         return;       }       if (k > plus) {         k -= plus;         continue;       }       long long x = (k + i - 1) / i;       k %= i;       long long num = step[i - 1] + x - 1;       string ans = to_string(num);       if (!k) k = i;       cout << ans[k - 1] <<   n ;       return;     }   }   void solve() {     long long k;     cin >> k;     long long a_0 = 1;     for (long long i = 1; i < 19; ++i) {       long long n = step[i] - step[i - 1];       long long a_n = a_0 + i * (n - 1);       long long sum = (a_0 + a_n) * n / 2ll;       if (k == sum) {         cout <<  9 n ;         return;       }       if (k > sum) {         k -= sum;         a_0 = a_n + i + 1;         continue;       }       long long x = lower(a_0, i, k);       long long a_x = a_0 + i * (x - 1);       k -= (a_0 + a_x) * x / 2;       solve1(k);       return;     }   }   signed main() {     GO();     step[0] = 1;     for (int i = 1; i < 19; ++i) step[i] = step[i - 1] * 10ll;     int Q = 1;     cin >> Q;     while (Q--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 7;   int n, nn, m;   int a[N], b[N], c[N];   int f[N];   inline void add(int i, int v) {     for (; i <= n; i += i & -i) f[i] += v;   }   inline int find(int v) {     int i = 0;     for (int k = 20; k >= 0; k--) {       if (i + (1 << k) <= n && f[i + (1 << k)] < v) {         i += 1 << k;         v -= f[i];       }     }     return i + 1;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= m; i++) scanf( %d , a + i);     for (int i = 1; i <= n; i++) {       scanf( %d , c + i);       if (c[i] != -1) b[++nn] = c[i];     }     for (int i = 1; i <= nn; i++) add(i, 1);     nn = 0;     for (int i = 1; i <= n; i++) {       if (c[i] != -1)         nn++;       else {         int k;         for (k = 1; k <= m && a[k] <= nn; k++) add(find(a[k] - k + 1), -1);         nn -= k - 1;       }     }     if (nn == 0) {       printf( Poor stack! n );       return 0;     }     for (int i = 1; i <= nn; i++) printf( %d , b[find(i)]);   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int m;     cin >> m;     int C[m];     for (int i = 0; i < m; ++i) cin >> C[i];     int x, y;     cin >> x >> y;     int sum_1, sum_2;     sum_1 = sum_2 = 0;     int now = 0;     for (int i = 0; i < m; ++i) sum_2 += C[i];     while (sum_1 < x || sum_1 > y || sum_2 < x || sum_2 > y) {       if (now == m) break;       sum_1 += C[now];       sum_2 -= C[now];       ++now;     }     if (now == m)       cout << 0;     else       cout << now + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mxN = 52;   vector<long long> adj[mxN];   signed main() {     long long n;     cin >> n;     long long x = (n * (n - 1)) / 2;     long long a[x - 1][2];     for (long long i = 0; i < x - 1; i++) {       cin >> a[i][0] >> a[i][1];       adj[a[i][0]].push_back(a[i][1]);       adj[a[i][1]].push_back(a[i][0]);     }     long long ans1 = -1, ans2 = -1;     for (long long i = 1; i <= n; i++) {       if (ans1 == -1 && adj[i].size() < n - 1) {         ans1 = i;       } else if (ans2 == -1 && adj[i].size() < n - 1) {         ans2 = i;       }     }     for (long long i = 1; i <= n; i++) {       if (i == ans1 || i == ans2) {         continue;       } else {         long long w1 = -1, w2 = -1;         for (long long j = 0; j < x - 1; j++) {           if (a[j][0] == ans1 && a[j][1] == i) {             w1 = ans1;           } else if (a[j][0] == i && a[j][1] == ans1) {             w1 = i;           } else if (a[j][0] == ans2 && a[j][1] == i) {             w2 = ans2;           } else if (a[j][0] == i && a[j][1] == ans2) {             w2 = i;           }         }         if (w1 == ans1 && w2 != ans2) {           cout << ans1 <<     << ans2 << endl;           return 0;         } else if (w2 == ans2 && w1 != ans1) {           cout << ans2 <<     << ans1 << endl;           return 0;         }       }     }     cout << ans1 <<     << ans2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1010;   int n;   int dp[maxn][256], a[maxn], cur[8];   vector<int> pos[maxn];   int ok(int len) {     int ans = -1;     memset(dp, -1, sizeof(dp));     memset(cur, 0, sizeof(cur));     dp[0][0] = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < 256; j++) {         if (dp[i][j] == -1) continue;         for (int k = 0; k < 8; k++) {           if (j & (1 << k)) continue;           int p = cur[k] + len - 1;           if (pos[k].size() <= p) continue;           dp[pos[k][p] + 1][j | 1 << k] =               max(dp[pos[k][p]][j | 1 << k], dp[i][j]);           if (pos[k].size() <= p + 1) continue;           dp[pos[k][p + 1] + 1][j | 1 << k] =               max(dp[pos[k][p + 1] + 1][j | 1 << k], dp[i][j] + 1);         }       }       cur[a[i]]++;     }     for (int i = 0; i < n + 1; i++) ans = max(ans, dp[i][255]);     if (ans == -1) return ans;     return ans * (len + 1) + (8 - ans) * len;   }   int read() {     int 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 * 10 + ch -  0 ;       ch = getchar();     }     return f * x;   }   int main() {     n = read();     for (int i = 0; i < n; i++) a[i] = read() - 1;     for (int i = 0; i < n; i++) pos[a[i]].push_back(i);     int l = 1, r = n / 8;     while (r - l > 1) {       int mid = (l + r) >> 1;       if (ok(mid) != -1)         l = mid;       else         r = mid;     }     int ans = max(ok(l), ok(r));     if (ans == -1) {       ans = 0;       for (int i = 0; i < 8; i++)         if (pos[i].size()) ans++;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int a[n];     vector<int> c;     for (int i = 0; i < n; i++) a[i] = 0;     for (int i = 0; i < n; i++) {       int k;       cin >> k;       c.push_back(k);       a[k - 1] += 1;     }     queue<int> q;     int ans = 0;     for (int i = 0; i < n; i++) {       if (a[i] == 0) {         q.push(i + 1);         ans++;       }     }     bool done[n];     for (int i = 0; i < n; i++) done[i] = 0;     for (int i = 0; i < n; i++) {       if (q.empty()) break;       if (done[c[i] - 1] == 1) {         a[c[i] - 1]--;         c[i] = q.front();         q.pop();       } else {         if (a[c[i] - 1] == 1) {           done[c[i] - 1] = 1;           a[c[i] - 1]--;         } else if (q.front() > c[i]) {           done[c[i] - 1] = 1;           a[c[i] - 1]--;         } else {           a[c[i] - 1]--;           c[i] = q.front();           q.pop();         }       }     }     cout << ans << endl;     for (int i = 0; i < n; i++) cout << c[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, a, b, c, d;   long long divide(long long x, long long y) { return (x + y - 1) / y; }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> t;     while (t--) {       cin >> a >> b >> c >> d;       if (b >= a)         cout << b <<   n ;       else if (d >= c)         cout <<  -1 n ;       else         cout << divide(a - b, c - d) * c + b <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int sum = 0, sum1 = 0, c = 0;     int n, x, y, d;     cin >> n;     d = n;     while (n--) {       cin >> x;       sum = sum + x;       cin >> y;       sum1 = sum1 + y;       if (x % 2 == 0 && y % 2 == 1 || (y % 2 == 0 && x % 2 == 1)) c++;     }     cout << (sum % 2 == 0 && sum1 % 2 == 0                  ? 0                  : (sum % 2 == 1 && sum1 % 2 == 1 && c > 0 && d > 1 ? 1 : -1))          << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = ~0ULL >> 1;   const int maxV = 3e5 + 10;   const int maxE = 6e5 + 10;   struct EDGE {     int v, nxt;     long long w;     EDGE() {}     EDGE(int vv, int xx, long long ww) { v = vv, nxt = xx, w = ww; }   };   EDGE edg[maxE];   int EH[maxV], etot;   void initG() {     memset(EH, -1, sizeof(EH));     etot = 0;   }   void addEdge(int u, int v, long long w) {     edg[etot] = EDGE(v, EH[u], w);     EH[u] = etot++;   }   int n, m;   short an[maxE];   long long dist[maxV];   short vs[maxV];   struct Node {     int src, id;     long long dst;     Node() {}     Node(int ss, long long dd, int ii) { src = ss, dst = dd, id = ii; }     bool operator<(const Node &rhs) const {       return (rhs.dst < dst) || (dst == rhs.dst && edg[rhs.id].w < edg[id].w);     }   };   void spfa(int s) {     for (int i = 1; i <= n; i++) dist[i] = inf;     memset(vs, 0, sizeof(vs));     memset(an, 0, sizeof(an));     priority_queue<Node> que;     dist[s] = 0;     que.push(Node(s, dist[s], -1));     long long rs = 0;     while (!que.empty()) {       Node now = que.top();       que.pop();       int u = now.src;       int id = now.id;       if (vs[u]) continue;       vs[u] = 1;       if (id != -1) {         rs += edg[id].w;         an[id] = 1;       }       for (int p = EH[u]; ~p; p = edg[p].nxt) {         int v = edg[p].v;         long long w = edg[p].w;         if (dist[v] >= dist[u] + w) {           dist[v] = dist[u] + w;           que.push(Node(v, dist[v], p));         }       }     }     cout << rs << endl;     m <<= 1;     for (int i = 0; i < m; i++)       if (an[i]) cout << (i / 2 + 1) <<    ;     cout << endl;   }   int main() {     int u, v, p;     long long w;     while (~scanf( %d%d , &n, &m)) {       initG();       for (int i = 1; i <= m; i++) {         scanf( %d%d%I64d , &u, &v, &w);         addEdge(u, v, w);         addEdge(v, u, w);       }       scanf( %d , &p);       spfa(p);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 58, SQ = 500;   int LE[maxn], LO[maxn], par[maxn], a[maxn], root[maxn], lazy[maxn], m;   inline void make(int j) {     int lase = -1, laso = -1;     int l = j * SQ;     for (int i = l; i - l < SQ; i++) {       a[i] ^= lazy[j];       if (a[i])         laso = i;       else         lase = i;       LE[i] = lase;       LO[i] = laso;       if (i - l >= m + 1) {         if (a[i])           par[i] = LO[i - (m + 1)];         else           par[i] = LE[i - (m + 1)];       } else         par[i] = -1;       if (par[i] == -1)         root[i] = i;       else         root[i] = root[par[i]];     }     lazy[j] = 0;   }   inline int getlast(int r) {     while ((lazy[r / SQ] && (LE[r] == -1 || LE[r] / SQ != r / SQ)) ||            (!lazy[r / SQ] && (LO[r] == -1 || LO[r] / SQ != r / SQ))) {       r = r / SQ * SQ - 1;     }     if (lazy[r / SQ]) return LE[r];     return LO[r];   }   inline bool P(int r, int l) {     while (r / SQ > l / SQ) {       r = root[r];       r = getlast(r - m - 1);     }     while (r > l) {       r = par[r];     }     return r == l;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, q;     cin >> n >> m >> q;     int lase = -1, laso = -1;     for (int i = 0; i < n; i++) {       long long b;       cin >> b;       b &= 1;       a[i] = b;       if (b)         laso = i;       else         lase = i;       LE[i] = lase;       LO[i] = laso;       if (i % SQ >= m + 1) {         if (b)           par[i] = LO[i - (m + 1)];         else           par[i] = LE[i - (m + 1)];         if (par[i] == -1 || par[i] / SQ < i / SQ) par[i] = -1;       } else         par[i] = -1;       if (par[i] == -1)         root[i] = i;       else         root[i] = root[par[i]];     }     while (q--) {       int t;       cin >> t;       if (t == 1) {         int l, r;         long long d;         cin >> l >> r >> d;         d &= 1;         l--;         r--;         if (!d) continue;         for (int i = l / SQ + 1; i < r / SQ; i++) {           lazy[i] ^= 1;         }         if (l / SQ != r / SQ) {           for (int i = l; i / SQ == l / SQ; i++) {             a[i] ^= 1;           }           for (int i = r / SQ * SQ; i <= r; i++) {             a[i] ^= 1;           }           make(l / SQ);           make(r / SQ);         } else {           for (int i = l; i <= r; i++) {             a[i] ^= 1;           }           make(l / SQ);         }       } else {         int l, r;         cin >> l >> r;         l--;         r--;         if (a[l] == lazy[l / SQ]) {           cout <<  1 n ;           continue;         }         int x = getlast(r);         if (P(x, l))           cout <<  2 n ;         else           cout <<  1 n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, s, p, k, m, t, x, y, ans, res;     cin >> t;     while (t--) {       cin >> n;       long long a[n + 1];       for (int i = 1; i <= n; i++) {         cin >> a[i];       }       ans = 0;       m = INT_MAX;       for (int i = n; i >= 1; i--) {         if (a[i] > m) ans++;         m = min(a[i], m);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long x, long long y) { return x > y ? x : y; }   long long min(long long x, long long y) { return x < y ? x : y; }   long long gcd(long long p, long long q) {     if (q == 0) return p;     return gcd(q, p % q);   }   bool check(long long b, long long p) {     long long m;     while (gcd(p, b) != 1) {       m = gcd(p, b);       while (p % m == 0) p = p / m;       b = m;     }     if (p == 1)       return true;     else       return false;   }   int main() {     long long p, q, b;     int n;     scanf( %d , &n);     while (n--) {       scanf( %I64d%I64d%I64d , &p, &q, &b);       if (p == 0) {         printf( Finite n );         continue;       }       long long mmax = max(p, q);       long long mmin = min(p, q);       long long GCD = gcd(mmax, mmin);       p = q / GCD;       if (check(b, p))         printf( Finite n );       else         printf( Infinite n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long fexp(long long b, long long e) {     long long x = 1;     for (; e; e >>= 1, b = (b * b) % (1000000007))       if (e & 1) x = (x * b) % (1000000007);     return x;   }   long long n, k, ok, i, j, x;   set<long long> S;   signed main() {     ios_base::sync_with_stdio(0);     cin >> n >> k;     ok = 1;     for (x = 1; x <= k && ok; x++) {       S.clear();       for (i = 1; i <= x; i++) {         if (S.count(n % i))           ok = 0;         else           S.insert(n % i);       }     }     cout << (ok ?  Yes  :  No ) << endl;     return 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const static int INF = 1000000000;   int t;   string input;   map<string, string> apa;   int main() {     scanf( %d , &t);     string a, b;     string v =  void ;     apa[v] =  void ;     while (t--) {       cin >> input;       if (input ==  typedef ) {         cin >> a >> b;         string tipe =   ;         int bintang = 0, dan = 0;         for (int i = 0; a[i] !=   0 ; i++) {           if (a[i] ==  * )             bintang++;           else if (a[i] ==  & )             dan++;           else             tipe += a[i];         }         string bener = apa[tipe];         if (bener ==  errtype  || tipe ==  errtype ) {           apa[b] =  errtype ;           continue;         }         if (bintang >= dan) {           for (int i = 0; i < bintang - dan; i++) {             bener +=  * ;           }           apa[b] = bener;         } else if (dan > bintang) {           string ganti =   ;           dan = dan - bintang;           for (int i = 0; bener[i] !=   0 ; i++) {             if (bener[i] ==  * ) {               if (dan > 0)                 dan--;               else {                 ganti +=  * ;               }             } else               ganti += bener[i];           }           if (dan == 0)             apa[b] = ganti;           else             apa[b] =  errtype ;         }       } else {         cin >> a;         string tipe =   ;         int bintang = 0, dan = 0;         for (int i = 0; a[i] !=   0 ; i++) {           if (a[i] ==  * )             bintang++;           else if (a[i] ==  & )             dan++;           else             tipe += a[i];         }         string bener = apa[tipe];         if (bener ==  errtype  || bener ==   ) {           printf( errtype n );           continue;         }         if (bintang >= dan) {           for (int i = 0; i < bintang - dan; i++) {             bener +=  * ;           }           printf( %s n , bener.c_str());         } else if (dan > bintang) {           string ganti =   ;           dan = dan - bintang;           for (int i = 0; bener[i] !=   0 ; i++) {             if (bener[i] ==  * ) {               if (dan > 0)                 dan--;               else {                 ganti +=  * ;               }             } else               ganti += bener[i];           }           if (dan == 0)             printf( %s n , ganti.c_str());           else             printf( errtype n );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long pos = 0;     long long distance;     int n, flag = 1;     char dir[20];     cin >> n;     for (int j = 0; j < n; j++) {       cin >> distance >> dir;       if (pos == 0 && strcmp(dir,  South ) != 0) {         flag = 0;       } else if (pos == 20000 && strcmp(dir,  North ) != 0) {         flag = 0;       } else {         if (strcmp(dir,  South ) == 0) {           pos = pos + distance;           if (pos > 20000) flag = 0;         } else if (strcmp(dir,  North ) == 0) {           pos = pos - distance;           if (pos < 0) {             flag = 0;           }         }       }     }     if (pos) flag = 0;     if (flag)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize  Ofast    #pragma GCC optimize  unroll-loops    #pragma GCC target  sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native    using namespace std;   class Debugger {    public:     Debugger(const std::string& _separator =   -  )         : first(true), separator(_separator) {}     template <typename ObjectType>     Debugger& operator,(const ObjectType& v) {       if (!first)       std:         cerr << separator;       std::cerr << v;       first = false;       return *this;     }     ~Debugger() {     std:       cerr << endl;     }       private:     bool first;     std::string separator;   };   long long int n, k, d;   set<pair<long long int, long long int> > ans;   long long int s;   void dfs(long long int u, long long int dad, long long int d,            long long int rem) {     ans.insert({dad, u});     if (d) {       for (long long int i = 0; i < rem && s < n; i++) dfs(++s, u, d - 1, k - 1);     }   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> d >> k;     if (n <= d || d > 1 && k < 2) {       cout <<  NO ;       return 0;     }     for (s = 1; s <= d; s++) ans.insert({s, s + 1});     for (long long int i = 2; i <= d && s < n; i++) {       dfs(i, i - 1, min(i - 1, d + 1 - i), k - 2);     }     if (s < n) {       cout <<  NO ;       return 0;     }     cout <<  YES n ;     for (auto it : ans) cout << it.first <<     << it.second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long(n), (k);     scanf( %lld%lld , &(n), &(k));     ;     long long n2 = n;     vector<long long> vec;     while (n) {       vec.push_back(n);       if (n - 1 > 0) vec.push_back(n - 1);       if (n - 2 > 0) vec.push_back(n - 2);       if (n - 3 > 0) vec.push_back(n - 3);       n /= 2;     }     long long maxi = 1;     auto allok = [&](long long v) {       long long mi = v, ma = (v % 2) ? v : v + 1;       long long c = ma - mi + 1;       while (ma <= n2) {         mi *= 2;         ma = 2 * ma + 1;         if (mi < n2) c += min(ma, n2) - mi + 1;       }       return c >= k;     };     for (auto i : vec) {       if (allok(i)) maxi = max(maxi, i);     }     printf( %lld n , maxi);     return 0;   }