malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   signed main() {     cin.tie(0)->sync_with_stdio(0);     long long n, m;     cin >> n >> m;     vector<long long> pw(n + 1);     pw[0] = 1;     for (long long i = 1; i <= n; i++) pw[i] = 2 * pw[i - 1] % MOD;     long long _ = n;     vector<long long> basis;     for (long long i = 0; i < n; i++) {       long long a;       cin >> a;       for (auto x : basis) a = min(a, a ^ x);       if (a) {         long long id = 0;         while (id < (long long)basis.size() && basis[id] > a) ++id;         basis.insert(basis.begin() + id, a);       }     }     n = basis.size();     vector<long long> ans(2 * m + 1, 0);     if (n <= 20) {       for (long long mask = 0; mask < (1ll << n); mask++) {         long long val = 0;         for (long long i = 0; i < n; i++)           if (mask & (1ll << i)) val ^= basis[i];         ans[__builtin_popcountll(val)]++;       }     } else {       vector<bool> good(m);       for (auto x : basis)         for (long long i = m - 1; i >= 0; i--)           if (x & (1ll << i)) {             good[i] = 1;             break;           }       for (long long i = 0; i < n; i++)         for (long long j = i + 1; j < n; j++)           basis[i] = min(basis[i], basis[i] ^ basis[j]);       vector<long long> stuff(n, 0);       for (long long i = 0; i < n; i++) {         long long cnt = 0;         for (long long j = 0; j < m; j++)           if (!good[j]) {             if (basis[i] & (1ll << j)) stuff[i] += (1ll << cnt);             cnt++;           }       }       vector<vector<vector<long long>>> dp(           n, vector<vector<long long>>(n + 1,                                        vector<long long>((1ll << (m - n)), 0)));       dp[0][1][stuff[0]] = dp[0][0][0] = 1;       for (long long i = 1; i < n; i++)         for (long long j = 0; j <= n; j++)           for (long long k = 0; k < (1ll << (m - n)); k++) {             dp[i][j][k] = dp[i - 1][j][k];             if (j) dp[i][j][k] += dp[i - 1][j - 1][k ^ stuff[i]];           }       for (long long i = 0; i <= n; i++)         for (long long j = 0; j < (1ll << (m - n)); j++)           ans[i + __builtin_popcount(j)] += dp[n - 1][i][j];     }     for (long long i = 0; i <= m; i++)       cout << (ans[i] % MOD) * pw[_ - n] % MOD <<    ;     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     scanf( %d , &t);     while (t--) {       int N;       scanf( %d , &N);       vector<int> a(N + 1);       vector<int> b(N + 1);       int sum = 0;       for (int i = 1; i <= N; ++i) {         scanf( %d , &a[i]);         sum += a[i];         b[i] = a[i];       }       if (sum % N != 0) {         printf( -1 n );         continue;       }       vector<vector<int>> ans;       for (int i = 2; i <= N; ++i) {         if (a[i] % i == 0) {           b[i] -= a[i];           b[1] += a[i];           ans.push_back({i, 1, a[i] / i});         } else {           int m = i - a[i] % i;           b[1] -= m;           b[i] += m;           ans.push_back({1, i, m});           ans.push_back({i, 1, (a[i] + m) / i});           b[i] -= (a[i] + m);           b[1] += (a[i] + m);         }       }       for (int i = 2; i <= N; ++i) {         b[1] -= sum / N;         b[i] += sum / N;         ans.push_back({1, i, sum / N});       }       printf( %d n , (int)ans.size());       for (vector<int>& v : ans) {         printf( %d %d %d n , v[0], v[1], v[2]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int a[200000];   int b[200000];   int c[200001];   int t[200001];   vector<int> x;   vector<int> ans;   int add(int r, int cr, int d) {     if (c[r] == t[r]) cr--;     t[r] += d;     if (c[r] == t[r]) cr++;     return cr;   }   int main() {     int n, m, p, i, j;     scanf( %d %d %d , &n, &m, &p);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     for (i = 0; i < m; i++) {       scanf( %d , &b[i]);       x.push_back(b[i]);     }     x.push_back(1000000001);     sort(x.begin(), x.end());     x.erase(unique(x.begin(), x.end()), x.end());     int k = x.size();     for (i = 0; i < n; i++) {       int pos = lower_bound(x.begin(), x.end(), a[i]) - x.begin();       if (a[i] == x[pos])         a[i] = pos;       else         a[i] = k - 1;     }     for (i = 0; i < k; i++) {       c[i] = 0;       t[i] = 0;     }     for (i = 0; i < m; i++) {       int pos = lower_bound(x.begin(), x.end(), b[i]) - x.begin();       c[pos]++;     }     int cr = 1;     long long d = (long long)p * (m - 1);     for (i = 0; i < p; i++) {       if (i + d >= n) continue;       for (j = 0; j < m; j++) cr = add(a[i + p * j], cr, 1);       if (cr == k) ans.push_back(i);       j = i + p * m;       while (j < n) {         cr = add(a[j], cr, 1);         cr = add(a[j - p * m], cr, -1);         if (cr == k) ans.push_back(j - p * (m - 1));         j += p;       }       int l = j - p;       for (j = 0; j < m; j++) cr = add(a[l - p * j], cr, -1);     }     sort(ans.begin(), ans.end());     printf( %d n , ans.size());     for (i = 0; i < ans.size(); i++) printf( %d  , ans[i] + 1);     puts(  );     return 0;   }
#include <bits/stdc++.h>   class Counter {    public:     Counter(std::vector<size_t> perm1, std::vector<size_t> perm2)         : size_(perm1.size()) {       std::vector<size_t> inv2(size_, 0);       for (size_t i = 0; i < size_; ++i) {         inv2[perm2[i]] = i;       }       auto& points = perm1;       for (size_t x = 0; x < size_; ++x) {         points[x] = inv2[perm1[x]];       }       size_t nextPowOfTwo = 1;       while (nextPowOfTwo < size_) nextPowOfTwo <<= 1;       segTree_.resize(2 * nextPowOfTwo - 1);       build(points, 0, 0, size_ - 1);     }     int count(size_t minX, size_t maxX, size_t minY, size_t maxY) {       return countAux(0, 0, size_ - 1, minX, maxX, minY, maxY);     }       private:     void build(const std::vector<size_t>& points, int vertex, int from, int to) {       if (from == to) {         segTree_[vertex].push_back(points[from]);       } else {         int middle = from + (to + 1 - from) / 2;         build(points, 2 * vertex + 1, from, middle - 1);         build(points, 2 * vertex + 2, middle, to);         const auto& left = segTree_[2 * vertex + 1];         const auto& right = segTree_[2 * vertex + 2];         segTree_[vertex].reserve(left.size() + right.size());         std::merge(left.begin(), left.end(), right.begin(), right.end(),                    std::back_inserter(segTree_[vertex]));       }     }     int countAux(int vertex, int from, int to, int minX, int maxX, int minY,                  int maxY) {       if (maxX < minX) {         return 0;       }       if (from == minX && to == maxX) {         const auto& range = segTree_[vertex];         auto it1 = std::lower_bound(range.begin(), range.end(), minY);         auto it2 = std::lower_bound(range.begin(), range.end(), maxY + 1);         return it2 - it1;       }       int middle = from + (to + 1 - from) / 2;       int countLeft = countAux(2 * vertex + 1, from, middle - 1, minX,                                std::min(maxX, middle - 1), minY, maxY);       int countRight = countAux(2 * vertex + 2, middle, to,                                 std::max(minX, middle), maxX, minY, maxY);       return countLeft + countRight;     }       private:     size_t size_;     std::vector<std::vector<int>> segTree_;   };   int main() {     size_t size;     ::scanf( %lu , &size);     auto readPerm = [](size_t size) {       std::vector<size_t> perm;       perm.reserve(size);       for (size_t i = 0; i < size; ++i) {         size_t elem;         ::scanf( %lu , &elem);         --elem;         perm.push_back(elem);       }       return perm;     };     auto perm1 = readPerm(size);     auto perm2 = readPerm(size);     Counter counter(std::move(perm1), std::move(perm2));     size_t nQueries;     ::scanf( %lu , &nQueries);     size_t x = 0;     auto f = [&](size_t z) { return (z + x - 1) % size; };     for (size_t i = 0; i < nQueries; ++i) {       size_t a, b, c, d;       ::scanf( %lu %lu %lu %lu , &a, &b, &c, &d);       size_t count = counter.count(std::min(f(a), f(b)), std::max(f(a), f(b)),                                    std::min(f(c), f(d)), std::max(f(c), f(d)));       std::cout << count <<   n ;       x = count + 1;     }   }
#include <bits/stdc++.h>   const long long N = 3000006;   using namespace std;   const long long MOD = 1000000007LL;   template <typename T>   T gcd(T a, T b) {     if (a == 0) return b;     return gcd(b % a, a);   }   template <typename T>   T power(T x, T y, long long m = MOD) {     T ans = 1;     while (y > 0) {       if (y & 1LL) ans = (ans * x) % m;       y >>= 1LL;       x = (x * x) % m;     }     return ans % m;   }   long long prime[N];   long long a[N], f[N];   int32_t main() {     memset(prime, 1, sizeof(prime));     prime[1] = 0;     for (long long i = 2; i < N; i++) {       if (!prime[i]) continue;       for (long long j = i * i; j < N; j += i) prime[j] = 0;     }     long long n;     cin >> n;     for (long long(i) = (0); i < (n); i++) {       cin >> a[i];       ++f[a[i]];     }     long long maxi = 0;     if (n == 1) {       cout <<  1  <<   n ;       cout << a[0];       return 0;     }     for (long long(i) = (0); i < (n); i++) {       if (a[i] == 1) continue;       if (prime[a[i] + 1] && f[1]) {         cout << f[1] + 1 <<   n ;         for (long long(i) = (0); i < (f[1]); i++) cout <<  1  ;         cout << a[i];         return 0;       }     }     if (f[1] >= 2) {       cout << f[1] <<   n ;       for (long long(i) = (0); i < (f[1]); i++) cout <<  1  ;       return 0;     }     for (long long(i) = (0); i < (n - 1); i++) {       for (long long(j) = (i + 1); j < (n); j++) {         if (prime[a[i] + a[j]]) {           cout <<  2  <<   n ;           cout << a[i] <<     << a[j];           return 0;         }       }     }     cout <<  1  <<   n ;     cout << a[0];   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 9;   char s[MAXN];   map<char, char> mp;   int main(int argc, char const *argv[]) {     int n, m;     scanf( %d%d , &n, &m);     scanf( %s , s);     int present = 0;     for (int i = 0; i < n; i++) {       present |= (1 << (s[i] -  a ));     }     for (char c =  a ; c <=  z ; c++)       if (present & (1 << (c -  a ))) {         mp[c] = c;       }     char one, two;     for (int i = 0; i < m; i++) {       scanf(  %c %c , &one, &two);       if (one == two) {         continue;       }       for (auto &it : mp) {         if (it.second == one)           it.second = two;         else if (it.second == two)           it.second = one;       }     }     for (int i = 0; i < n; i++)       if (mp.count(s[i])) {         s[i] = mp[s[i]];       }     puts(s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = (int)1e6 + 17;   const int MOD = (int)1e9 + 7;   const long long oo = (long long)1e18 + 7;   const int INF = (int)999999999;   const int N = (int)1e5 + 17;   const int di[4] = {-1, 0, 1, 0};   const int dj[4] = {0, 1, 0, -1};   inline long long IN() {     long long x = 0, ch = getchar(), f = 1;     while (!isdigit(ch) && (ch !=  - ) && (ch != EOF)) ch = getchar();     if (ch ==  - ) {       f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline void OUT(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10)       OUT(x / 10), putchar(x % 10 +  0 );     else       putchar(x +  0 );   }   double d, h, v, e, ans;   int main() {     cin >> d >> h >> v >> e;     ans = e - ((4 * v) /                (3.14159265358979323846264338327950288419716939937510 * d * d));     h = -h;     if (ans > -1e4 && ans < 0)       cout <<  YES  << endl << fixed << setprecision(10) << (h / ans);     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, x = -1, m, j = 0;     cin >> n;     cin >> k;     if (k == 2) {       x = 1;     }     if (k == 1) {       x = 0;     }     if (k == 0) {       j++;     }     for (int i = 1; i < n; i++) {       cin >> k;       if (k == 0) {         j++;         x = -1;       } else {         if (x == -1 and k == 3) {         } else {           if (k == 3) {             x = ((x - 1) % 2 + 2) % 2;           } else {             if (k - 1 == x) {               j++;               x = -1;             } else {               x = k - 1;             }           }         }       }     }     cout << j;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target(         avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   long long MOD = 1e9 + 7;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),         cout << fixed << setprecision(20);     long long t;     cin >> t;     while (t--) {       long long n, p;       cin >> n >> p;       vector<pair<long long, long long> > ans;       for (int i = 0; i < 2 * n + p; i++) {         ans.push_back({i % n, (i + i / n + 1) % n});       }       for (auto i : ans) {         cout << i.first + 1 <<     << i.second + 1 <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   struct scroll {     int pow;     int dmg;     int loc;     bool operator<(const scroll& a) const {       if (dmg > a.dmg)         return true;       else if (dmg == a.dmg && pow < a.pow)         return true;       else         return false;     }   };   struct used_scrollr {     int num;     int time;     bool operator<(const used_scrollr& a) const { return time < a.time; }   };   int main() {     int N, max, reg;     scanf( %d%d%d , &N, &max, &reg);     scroll ary[N];     bool used_scroll[N];     int used_time[N];     for (int i = 0; i < N; ++i) {       int x, y;       scanf( %d%d , &x, &y);       ary[i] = (scroll){x, y, i + 1};       used_scroll[i] = false;     }     sort(ary, ary + N);     int time = 0;     int used_scrolls = 0;     int current_hp = max;     int drain = 0;     while (true) {       current_hp -= drain;       if (current_hp + reg < max)         current_hp += reg;       else         current_hp = max;       if (current_hp <= 0) {         time++;         break;       }       bool used_a_scroll = false;       for (int i = 0; i < N; ++i) {         if (used_scroll[i] == false &&             (((current_hp * 100) / max) +                  ((current_hp * 100) % max == 0 ? 0 : 1) <=              ary[i].pow)) {           used_time[i] = time;           drain += ary[i].dmg;           used_scroll[i] = true;           used_scrolls++;           used_a_scroll = true;           break;         }       }       if ((reg - drain) >= 0 && used_a_scroll == false) break;       time++;     }     if (current_hp <= 0) {       printf( YES n );       printf( %d %d n , time - 1, used_scrolls);       used_scrollr ary2[used_scrolls];       int cnt = 0;       for (int i = 0; i < N; ++i)         if (used_scroll[i])           ary2[cnt++] = (used_scrollr){ary[i].loc, used_time[i]};       sort(ary2, ary2 + used_scrolls);       for (int i = 0; i < used_scrolls; ++i)         printf( %d %d n , ary2[i].time, ary2[i].num);     } else {       printf( NO n );     }   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 100000;   const long long oops = 1LL << 60;   class Ball {    public:     long long value, color;   } arr[MAXN + 5];   long long colorBest[MAXN + 5];   long long n;   void addToTopTwo(vector<pair<long long, int> >& toptwo, long long best,                    long long color) {     if (toptwo.size() != 2)       toptwo.push_back(make_pair(best, color));     else {       long long c, c2;       bool khalas = 0;       for (c = 0; c < 2; c++)         if (toptwo[c].second == color) {           toptwo[c].first = max(toptwo[c].first, best);           khalas = 1;         }       if (!khalas) {         if (toptwo[0].first > toptwo[1].first) {           if (toptwo[1].first < best) toptwo[1] = make_pair(best, color);         } else {           if (toptwo[0].first < best) toptwo[0] = make_pair(best, color);         }       }     }     return;   }   int main() {     long long c, c2;     long long qs;     scanf( %I64d%I64d , &n, &qs);     for (c = 0; c < n; c++) scanf( %I64d , &arr[c].value);     for (c = 0; c < n; c++) scanf( %I64d , &arr[c].color);     for (long long loops = 0; loops < qs; loops++) {       for (c = 0; c <= n; c++) {         colorBest[c] = -oops;       }       long long a, b;       scanf( %I64d%I64d , &a, &b);       long long ret = -oops;       vector<pair<long long, int> > toptwo;       for (c = 0; c < n; c++) {         long long best = b * (long long)arr[c].value;         if (colorBest[arr[c].color] != -oops)           best = max(best, colorBest[arr[c].color] + a * (long long)arr[c].value);         for (c2 = 0; c2 < toptwo.size(); c2++)           if (toptwo[c2].second != arr[c].color)             best = max(best, toptwo[c2].first + b * (long long)arr[c].value);         colorBest[arr[c].color] = max(colorBest[arr[c].color], best);         addToTopTwo(toptwo, best, arr[c].color);         ret = max(ret, best);       }       printf( %I64d n , max(ret, 0LL));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void adskiy_razgon() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   const int mxN = 1e+9 + 7;   const long long INF = 1e+18 + 7;   long long nod(long long a, long long b) {     if (b > a) {       swap(a, b);     }     while (b > 0) {       a %= b;       swap(a, b);     }     return a;   }   long long nok(long long a, long long b) { return a * b / nod(a, b); }   void sp(long long a, double b) { cout << fixed << setprecision(a) << b; }   long long binpow(long long a, long long n) {     if (n == 0) {       return 1;     }     if (n % 2 == 1) {       return binpow(a, n - 1) * a;     } else {       long long b = binpow(a, n / 2);       return b * b;     }   }   void solve() {     int n, m, t;     cin >> n >> m >> t;     cout << ((n - m) * t + m - 1) / m;   }   int main() {     adskiy_razgon();     long long t = 1;     for (int i = 1; i <= t; ++i) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   class SegmentTree {    private:     vector<ll> aint;     vector<ll> lazy;       public:     SegmentTree(int n) {       aint.resize(1 + 4 * n);       lazy.resize(1 + 4 * n);     }     void cleannode(int node, int from, int to) {       int mid = (from + to) / 2;       if (from < to) {         lazy[node * 2] += lazy[node];         lazy[node * 2 + 1] += lazy[node];       }       aint[node] = aint[node] + lazy[node];       lazy[node] = 0;     }     void computenode(int node, int from, int to) {       if (from < to) {         int mid = (from + to) / 2;         aint[node] = max(aint[node * 2], aint[node * 2 + 1]);       }     }     void update(int node, int from, int to, int x, int y, ll val) {       cleannode(node, from, to);       if (from == x && to == y) {         lazy[node] += val;         cleannode(node, from, to);       } else {         int mid = (from + to) / 2;         cleannode(node * 2, from, mid);         cleannode(node * 2 + 1, mid + 1, to);         if (x <= mid)           update(node * 2, from, mid, x, (((mid) < (y)) ? (mid) : (y)), val);         if (mid + 1 <= y)           update(node * 2 + 1, mid + 1, to, (((mid + 1) < (x)) ? (x) : (mid + 1)),                  y, val);         computenode(node, from, to);       }     }     ll query(int node, int from, int to, int x, int y) {       cleannode(node, from, to);       if (from == x && to == y)         return aint[node];       else {         int mid = (from + to) / 2;         if (x <= mid && y <= mid)           return query(node * 2, from, mid, x, y);         else if (mid + 1 <= x && mid + 1 <= y)           return query(node * 2 + 1, mid + 1, to, x, y);         else           return max(query(node * 2, from, mid, x, mid),                      query(node * 2 + 1, mid + 1, to, mid + 1, y));       }     }   };   int const nmax = 200000;   int v[1 + nmax];   vector<pair<int, int>> g[1 + nmax];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> v[i];     for (int i = 1; i <= m; i++) {       int x, y, cost;       cin >> x >> y >> cost;       g[y].push_back({x, cost});     }     SegmentTree aint(n);     for (int i = 1; i <= n; i++) {       ll result = aint.query(1, 0, n, 0, i - 1);       aint.update(1, 0, n, i, i, result);       aint.update(1, 0, n, 0, i - 1, -v[i]);       for (int h = 0; h < g[i].size(); h++) {         int x = g[i][h].first, cost = g[i][h].second;         aint.update(1, 0, n, 0, x - 1, cost);       }     }     cout << aint.query(1, 0, n, 0, n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 333;   int main() {     int n, a1, a2, a3, b1, b2, b3;     cin >> n >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;     int c1 = b1, c2 = b2, c3 = b3;     while (c1 + c2 + c3 > n) {       if (c3 > a3)         c3--;       else if (c2 > a2)         c2--;       else if (c1 > a1)         c1--;     }     cout << c1 <<     << c2 <<     << c3 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, i;     cin >> n >> k;     vector<pair<long long, long long>> v;     vector<long long> inp, p;     vector<long long>::iterator it;     map<long long, long long> m;     for (i = 0; i < n; i++) {       long long x;       cin >> x;       v.push_back(make_pair(x, 0));       inp.push_back(x);     }     for (i = 0; i < n; i++) cin >> v[i].second;     sort(v.begin(), v.end());     int t = 0, u = 0;     long long sum = 0;     for (i = 0; i < n; i++) {       if (t < k) {         for (it = p.begin(); it != p.end(); it++) {           if (v[i].second >= *it) {             p.insert(it, v[i].second);             t++;             break;           }         }         if (it == p.end()) {           p.push_back(v[i].second);           t++;         }         sum += v[i].second;         m[v[i].first] = sum;       } else {         if (u == 1) {           for (it = p.begin(); it != p.end(); it++) {             if (v[i - 1].second >= *it) {               p.insert(it, v[i - 1].second);               sum += v[i - 1].second;               sum -= p.back();               p.pop_back();               break;             }           }         }         m[v[i].first] = sum + v[i].second;         if (u == 0) u = 1;       }     }     for (i = 0; i < n; i++) {       cout << m[inp[i]] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> pref_sum_a;   vector<long long> pref_sum_b;   signed main() {     long long n;     cin >> n;     if (n == 2) {       cout << 3 << endl;       cout << 2 <<     << 1 <<     << 2 << endl;     }     if (n == 3) {       cout << 4 << endl;       cout << 2 <<     << 1 <<     << 3 <<     << 2 << endl;     }     if (n == 4) {       cout << 6 << endl;       cout << 1 <<     << 3 <<     << 2 <<     << 4 <<     << 1 <<     << 3            << endl;     }     if (n > 4) {       cout << n + n / 2 << endl;       for (long long t = 2; t <= n; t += 2) {         cout << t <<    ;       }       for (long long g = 1; g <= n; g += 2) {         cout << g <<    ;       }       for (long long t = 2; t <= n; t += 2) {         cout << t <<    ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int64_t exp(int64_t a, int64_t b) {     if (b == 0) return 1;     int64_t c = exp(a, b / 2);     c = c * c;     if (b % 2 == 1) c = c * a;     return c;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int64_t ans = 0;     for (int i = 0; i < n; i++) {       int64_t k, a;       cin >> k >> a;       if (a == 1) {         ans = max(ans, k + 1);         continue;       }       int64_t x = 0;       for (int64_t b = 16; b >= 1; b /= 2) {         while (exp(4, b + x) < a) x += b;       }       ans = max(ans, k + x + 1);     }     cout << ans;   }