malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxp = 22;   const long double EPS = 1e-18;   const long long INF = 2e18;   const int MOD = 1e9 + 7;   const int N = 2e5 + 1;   string s, t =  hard ;   long long dp[N][4];   long long arr[N];   int n;   long long solve(int x, int idx) {     if (idx == 4) return INF;     if (x == n) return 0;     if (dp[x][idx] != -1) return dp[x][idx];     int nxt = idx;     if (s[x] == t[idx]) nxt++;     return dp[x][idx] = min(solve(x + 1, idx) + arr[x], solve(x + 1, nxt));   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> s;     int i, j;     for (i = 0; i < n; i++) cin >> arr[i];     for (i = 0; i < n; i++)       for (j = 0; j < 4; j++) dp[i][j] = -1;     cout << solve(0, 0) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4e5 + 10;   int mod = 1e9 + 7;   int qpow(int a, int b) {     int ans = 1;     for (; b >= 1; b >>= 1, a = (long long)a * a % mod)       if (b & 1) ans = (long long)ans * a % mod;     return ans;   }   long long ans[32];   int main() {     int t;     scanf( %d , &t);     while (t--) {       int d, m, c;       scanf( %d%d , &d, &mod);       fill(ans, ans + 30, 0);       for (c = 0; (1 << (c + 1)) <= d; c++)         ;       for (int i = 0; i < c; i++) ans[i] = (1ll << i) % mod;       ans[c] = (d - (1ll << c) + 1) % mod;       long long res = 1;       for (int i = 0; i <= c; i++) res = res * (ans[i] + 1ll) % mod;       res = (res + mod - 1) % mod;       printf( %lld n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long r, g, b;     cin >> r >> g >> b;     long long ans = min(r, min(g, b));     long long mini = ans;     if (r <= 3 && g <= 3 && b <= 3) {       cout << ans << endl;       return 0;     }     long long count = 0;     r = r - ans;     g = g - ans;     b = b - ans;     if (r % 3 == 2) {       ++count;     }     if (g % 3 == 2) {       ++count;     }     if (b % 3 == 2) {       ++count;     }     ans += (r / 3) + (g / 3) + (b / 3);     if (count == 2 && mini != 0) {       ++ans;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int const M = 4e5 + 20;   int a[M], ans[M], l[M], r[M], ty[M], cnt[M], sv[M];   vector<pair<int, int> > qu[M];   int main() {     int n, q;     cin >> n >> q;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= q; i++) {       int ind, nu;       cin >> ind >> nu;       qu[ind].push_back(make_pair(nu, i));       sv[i] = ind;     }     vector<int> lis;     for (int i = 1; i <= n; i++) {       qu[i].push_back(make_pair(a[i], 0));       for (int j = 0; j < qu[i].size(); j++) {         int now = qu[i][j].first;         if (lis.size() == 0 || now > lis.back()) {           ans[qu[i][j].second] = (int)lis.size() + 1;         } else {           int ind = lower_bound(lis.begin(), lis.end(), now) - lis.begin();           ans[qu[i][j].second] = ind + 1;         }         if (j == (int)qu[i].size() - 1) {           l[i] = ans[0];           if (ans[0] == (int)lis.size() + 1)             lis.push_back(a[i]);           else             lis[ans[0] - 1] = a[i];         }       }     }     int best = lis.size();     lis.clear();     for (int i = n; i >= 1; i--) {       for (int j = 0; j < qu[i].size(); j++) {         int now = qu[i][j].first;         now = -now;         if (lis.size() == 0 || now > lis.back()) {           ans[qu[i][j].second] += (int)lis.size();           if (j == (int)qu[i].size() - 1) {             r[i] = (int)lis.size() + 1;             lis.push_back(now);           }         } else {           int ind = lower_bound(lis.begin(), lis.end(), now) - lis.begin();           ans[qu[i][j].second] += ind;           if (j == (int)qu[i].size() - 1) {             r[i] = ind + 1;             lis[ind] = now;           }         }       }     }     for (int i = 1; i <= n; i++) {       if (l[i] + r[i] != best + 1) {         ty[i] = 3;       } else         cnt[l[i]]++;     }     for (int i = 1; i <= n; i++) {       if (ty[i] != 3 && cnt[l[i]] > 1)         ty[i] = 2;       else if (ty[i] != 3)         ty[i] = 1;     }     for (int i = 1; i <= q; i++) {       int tmp = ans[i];       if (ty[sv[i]] == 1)         tmp = max(tmp, best - 1);       else         tmp = max(tmp, best);       cout << tmp <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int v[4005], d[14005];   long long int p[4005];   bool done[4005];   vector<int> vec;   int main() {     int n, val, ans = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> v[i] >> d[i] >> p[i];     }     for (int i = 0; i < n; i++) {       if (done[i]) continue;       vec.push_back(i + 1);       ans++;       val = 0;       for (int j = i + 1; j < n; j++) {         if (!done[j]) {           if (val == v[i]) break;           p[j] -= v[i] - val;           val++;         }       }       long long int val = 0;       for (int j = i + 1; j < n; j++) {         if (done[j] == 1) continue;         p[j] -= val;         if (p[j] < 0) {           val += d[j];           done[j] = 1;         }       }     }     sort(vec.begin(), vec.end());     cout << ans << endl;     for (int i = 0; i < vec.size(); i++) cout << vec[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   long long cnt[200010];   void f(long long x) {     while (x) {       cnt[x]++;       x /= 2;     }     cnt[0]++;   }   long long count(long long x, long long y) {     long long sol = INT32_MAX, cnt = 0;     while (x != y) {       if (!x) break;       ++cnt;       x /= 2;     }     if (!x && y) return sol;     return cnt;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cerr.tie(nullptr);     long long n, k;     cin >> n >> k;     vector<long long> a(n);     long long maxi = 0;     for (auto& i : a) {       cin >> i;       f(i);       maxi = max(maxi, i);     }     long long sol = INT32_MAX;     for (long long i = 0; i <= maxi; ++i) {       if (cnt[i] < k) continue;       long long res = 0;       vector<long long> t;       for (long long j = 0; j < n; ++j) {         t.push_back(count(a[j], i));       }       sort(t.begin(), t.end());       for (long long j = 0; j < k; ++j) res += t[j];       sol = min(sol, res);     }     cout << sol <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   struct comp {     bool operator()(const vector<int>& lhs, const vector<int>& rhs) const {       return lhs.size() > rhs.size();     }   };   struct comps {     bool operator()(const string& lhs, const string& rhs) const {       return lhs > rhs;     }   };   bool ff(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }   double dis(double x1, double y1, double x2, double y2) {     return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));   }   int gcd(long long unsigned int a, long long unsigned int b) {     return (b == 0) ? a : gcd(b, a % b);   }   int comb(int a, int b) {     if (a == 0) return 1;     if (a < b) return 1;     if (a == b) return 1;     if (b == 1) return a;     if (b == 0) return 1;     long long unsigned int aa = 1, bb = 1;     for (int i = b; i > 0; i--, a--) {       aa *= a;       bb *= i;       int gc = gcd(aa, bb);       if (gc > 1) {         aa /= gc;         bb /= gc;       }     }     return aa % 1000000007;   }   bool isprime(long long unsigned int n) {     for (int i = 2; i <= sqrt(n); i++)       if (n % i == 0) return false;     return true;   }   bool f(pair<int, int> p1, pair<int, int> p2) {     if (p1.first < p2.first)       return true;     else if ((p1.first == p2.first) && (p1.second > p2.second))       return true;     else       return false;   }   int t[100005];   int x[100005];   int v[100005];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) cin >> t[i] >> x[i];     int i = 0;     int nn = n;     int kalkis = 0;     int delay = 0;     while (n > 0) {       int p = (n >= m) ? m : n;       n -= p;       kalkis =           (t[i + p - 1] > (kalkis + delay)) ? t[i + p - 1] : (kalkis + delay);       map<int, int> mapp;       map<int, vector<int> > duranlar;       for (int j = i; j < i + p; j++) {         mapp[x[j]]++;         duranlar[x[j]].push_back(j);       }       map<int, int>::iterator it;       delay = 0;       for (it = mapp.begin(); it != mapp.end(); it++) {         for (int k = 0; k < duranlar[it->first].size(); k++) {           v[duranlar[it->first][k]] = kalkis + delay + (it->first);         }         delay += 1 + (it->second) / 2;       }       it--;       delay += 2 * (it->first);       i += p;     }     for (int i = 0; i < nn; i++) cout << v[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> edge[20];   int n, t;   string a, b;   bitset<20> used;   void DFS(int h) {     used[h] = true;     for (auto &i : edge[h])       if (!used[i]) DFS(i);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> t;     while (t--) {       cin >> n;       cin >> a >> b;       for (auto &i : edge) i.clear();       bool check = false;       for (int i = 0; i <= n - 1; i++) {         if (a[i] == b[i]) continue;         if (a[i] > b[i]) {           check = true;           break;         }         edge[a[i] -  a ].push_back(b[i] -  a );         edge[b[i] -  a ].push_back(a[i] -  a );       }       if (check) {         cout << -1 <<   n ;         continue;       }       used.reset();       int ans = 20;       for (int i = 0; i <= 19; i++) {         if (!used[i]) {           DFS(i);           ans--;         }       }       cout << ans <<   n ;     }     return 0;   }
#include<bits/stdc++.h>   #define rep(i,st,en) for(int i=st;i<=en;i++)      using namespace std;   typedef long long ll;   int t,x,y,i,n;      int main()   {    scanf( %d ,&t);    while(t--)    {     scanf( %d ,&n);     rep(i,1,n)scanf( %d ,&x);     printf( %d n ,3*n);     rep(i,1,n/2)     {      x=2*i-1;      y=2*i;      printf( 2 %d %d n ,x,y);      printf( 2 %d %d n ,x,y);      printf( 1 %d %d n ,x,y);      printf( 2 %d %d n ,x,y);      printf( 2 %d %d n ,x,y);      printf( 1 %d %d n ,x,y);     }     //TODO    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10;   int n, sz;   vector<int> vec[MAXN];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     cout << n - 1 <<   n ;     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--, b--;       vec[a].push_back(sz);       vec[b].push_back(sz++);       cout << 2 <<     << a + 1 <<     << b + 1 <<   n ;     }     for (int i = 0; i < n; i++)       for (int j = 1; j < vec[i].size(); j++)         cout << vec[i][j - 1] + 1 <<     << vec[i][j] + 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<char> a;     char x;     for (int i = 0; i < n; i++) {       cin >> x;       a.push_back(x);     }     for (int i = 0; i < a.size(); i++) {       if (a[i] ==  U  && a[i + 1] ==  R ) {         a.erase(a.begin() + i);         a[i] =  D ;       }       if (a[i] ==  R  && a[i + 1] ==  U ) {         {           a.erase(a.begin() + i);           a[i] =  D ;         }       }     }     cout << a.size();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long p[1100000], r[1100000], cnt;   int main() {     long long n, bac;     cin >> n;     if (n == 1) {       printf( 1 n );       return 0;     }     bac = n;     long long i;     for (i = 2; i * i <= n; i++) {       if (bac % i == 0) {         cnt++;         p[cnt] = i;         while (bac % i == 0) {           bac /= i;           r[cnt]++;         }       }     }     if (bac != 1) {       cnt++;       p[cnt] = bac;     }     if (cnt == 1)       cout << p[1] << endl;     else       printf( 1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     vector<int> r(7, 0);     string den;     for (int i = 0; i < n; i++) {       cin >> den;       for (int j = 0; den[j] !=   0 ; j++) {         r[j] += den[j] ==  1 ;       }     }     int m = 0;     for (int i = 0; i < 7; i++) {       m = max(m, r[i]);     }     printf( %d n , m);     getchar();     getchar();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, res = 0, j, mid, a[6] = {}, b[6] = {};     cin >> n;     for (i = 0; i < n; i++) {       cin >> j;       a[j]++;     }     for (i = 0; i < n; i++) {       cin >> j;       b[j]++;     }     for (i = 1; i < 6; i++) {       mid = a[i] + b[i];       if (mid % 2) {         cout << -1 << endl;         return 0;       }       res += abs(a[i] - mid / 2);     }     cout << res / 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INFint = 2147483647;   const long long INF = 9223372036854775807ll;   const long long MOD = 1000000007ll;   const long double EPS = 1e-9;   int p[1000];   int a[1000];   int b[1000];   int cnt;   void dfs(int v) {     p[v] = 1;     for (int i = 1; i <= cnt; i++) {       if (!p[i]) {         if ((a[v] > a[i] && a[v] < b[i]) || (b[v] > a[i] && b[v] < b[i])) dfs(i);       }     }   }   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int t, x, y;       cin >> t >> x >> y;       if (t == 1) {         cnt++;         a[cnt] = x;         b[cnt] = y;       } else {         memset(p, 0, sizeof(p));         dfs(x);         if (p[y]) {           cout <<  YES  << endl;         } else           cout <<  NO  << endl;       }     }     fprintf(stderr,   nTIME = %lf n , 1.0 * clock() / CLOCKS_PER_SEC);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dp[100002];   int main() {     double res = 0, prob = 0;     int n;     cin >> n;     dp[0] = 0;     for (int i = 0; i < n; i++) {       double p;       cin >> p;       dp[i] = dp[i - 1] * p;       res = res + p + dp[i] * 2.0;       dp[i] += p;     }     printf( %.7lf n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<int> a(n), b(n), c(n);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     int ans = INT_MAX;     sort(a.begin(), a.end());     sort(b.begin(), b.end());     for (int i = 0; i < n; i++) {       int x = (b[i] - a[0] + m) % m;       for (int j = 0; j < n; j++) c[j] = (a[j] + x) % m;       sort(c.begin(), c.end());       if (c == b) ans = min(ans, x);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fll;   using namespace std;   const double eps = 1e-6;   const long long mod = 1e9 + 7;   const int maxn = 1e5 + 100;   const int maxe = 1e6 + 100;   struct node {     int to;     int next;   };   bool dp[maxn][2], cir;   vector<int> V[maxn];   int vis[maxn][2];   int Next[maxn][2], n, m;   inline bool dfs(int x, int s) {     if (!V[x].size()) return s == 1;     if (vis[x][s] == 2) return dp[x][s];     vis[x][s] = 1;     bool t = 0;     for (int i = 0; i < V[x].size(); i++) {       int v = V[x][i];       if (vis[v][s ^ 1] == 1) {         cir = 1;         continue;       }       if (dfs(v, s ^ 1)) {         t = 1;         Next[x][s] = v;       }     }     vis[x][s] = 2;     return dp[x][s] = t;   }   inline void print(int x, int s) {     printf( %d  , x);     if (Next[x][s]) {       print(Next[x][s], s ^ 1);     }   }   void Solve() {     cin >> n >> m;     int xx, v;     for (int i = 1; i <= n; i++) {       cin >> xx;       for (int j = 0; j < xx; j++) {         cin >> v;         V[i].push_back(v);       }     }     int st;     cin >> st;     if (dfs(st, 0)) {       puts( Win );       print(st, 0);     } else if (cir)       puts( Draw );     else       puts( Lose );   }   int main() {     int Case = 1, cases;     while (Case--) {       Solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using db = long double;   using pll = pair<long long, long long>;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t, i, x, j, y, z, k, n;     long long tt;     cin >> tt;     for (long long _tt = 0; _tt < tt; _tt++) {       cin >> n;       z = 0;       while (n != 1) {         if (n % 6 == 0)           n /= 6;         else if ((n * 2) % 6 == 0)           n *= 2;         else {           z = -1;           break;         }         z++;       }       cout << z <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;   inline 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 * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   const int maxn = 1e5 + 10;   const int mod = 1e9 + 7;   string s;   int len, match[1005];   long long dp[1000][1000][3][3];   void get_match() {     stack<int> sta;     for (int i = 0; i < len; i++) {       if (s[i] ==  ( )         sta.push(i);       else {         int t = sta.top();         sta.pop();         match[i] = t;         match[t] = i;       }     }   }   void dfs(int l, int r) {     if (l + 1 == r) {       dp[l][r][0][1] = 1;       dp[l][r][1][0] = 1;       dp[l][r][0][2] = 1;       dp[l][r][2][0] = 1;       return;     }     if (match[l] == r) {       dfs(l + 1, r - 1);       for (int i = 0; i < 3; i++)         for (int j = 0; j < 3; j++) {           if (j != 1)             dp[l][r][0][1] = (dp[l][r][0][1] + dp[l + 1][r - 1][i][j]) % mod;           if (i != 1)             dp[l][r][1][0] = (dp[l][r][1][0] + dp[l + 1][r - 1][i][j]) % mod;           if (j != 2)             dp[l][r][0][2] = (dp[l][r][0][2] + dp[l + 1][r - 1][i][j]) % mod;           if (i != 2)             dp[l][r][2][0] = (dp[l][r][2][0] + dp[l + 1][r - 1][i][j]) % mod;         }       return;     } else {       int k = match[l];       dfs(l, k);       dfs(k + 1, r);       for (int i = 0; i < 3; i++)         for (int j = 0; j < 3; j++)           for (int x = 0; x < 3; x++)             for (int y = 0; y < 3; y++) {               if ((x == 1 && y == 1) || (x == 2 && y == 2)) continue;               dp[l][r][i][j] =                   (dp[l][r][i][j] + dp[l][k][i][x] * dp[k + 1][r][y][j]) % mod;             }       return;     }   }   int main() {     memset(dp, 0, sizeof(dp));     cin >> s;     len = s.size();     get_match();     dfs(0, len - 1);     long long ans = 0;     for (int i = 0; i < 3; i++)       for (int j = 0; j < 3; j++) ans = (ans + dp[0][len - 1][i][j]) % mod;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[5050][505];   pair<long long, long long> pre[5050][505];   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long d, s;     cin >> d >> s;     queue<pair<long long, long long>> q;     for (long long i = 1; i < 10; i++) {       dp[i][i % d] = 1;       q.push({i, i % d});     }     while (q.size()) {       pair<long long, long long> curr = q.front();       q.pop();       long long sum = curr.first;       long long div = curr.second;       for (long long i = 0; i <= 9; i++) {         long long curr_sum = sum + i;         long long curr_div = (div * 10 + i) % d;         if (curr_sum <= s and !dp[curr_sum][curr_div]) {           dp[curr_sum][curr_div] = dp[sum][div] + 1;           q.push({curr_sum, curr_div});           pre[curr_sum][curr_div] = {sum, div};         }       }     }     if (!dp[s][0]) {       cout << -1;     } else {       vector<long long> ans;       long long sum = s, div = 0;       while (true) {         if (dp[sum][div] == 1) {           ans.push_back(sum);           break;         } else {           pair<long long, long long> curr = pre[sum][div];           ans.push_back(sum - curr.first);           sum = curr.first;           div = curr.second;         }       }       reverse(ans.begin(), ans.end());       for (auto x : ans) {         cout << x;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, a, am, duong, zero;   unsigned long long t;   int main() {     scanf( %d n , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a);       if (a < 0)         am++;       else if (a > 0)         duong++;       else         zero++;       t += abs(abs(a) - 1);     }     if (am % 2 == 1) {       if (zero == 0) t += 2;     }     printf( %llu , t);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int sum = 0, a;     for (int i = 0; i < n; i++) {       cin >> a;       sum += a;     }     int m;     cin >> m;     vector<char> good(1e5 + 1, false);     int l, r;     for (int i = 0; i < m; i++) {       cin >> l >> r;       for (int j = l; j <= r; j++) {         good[j] = true;       }     }     for (int i = sum; i <= 1e5; i++) {       if (good[i]) {         cout << i << endl;         return 0;       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a;     cin >> a;     int i, flag = 0;     for (i = 1; i < a.size(); i++) {       if (a[i] ==  1 ) {         flag = 1;         break;       }     }     i = (a.size()) / 2;     if (flag == 1 && a.size() % 2 == 1) i++;     cout << i;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T sqr(T x) {     return x * x;   }   template <typename T>   T abs(T x) {     return x < 0 ? -x : x;   }   template <typename T>   T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   const int MAXN = 8009;   const int MAXX = (int)1e+6 + 7;   struct triple {     int x, l, r;     triple(int x = 0, int l = 0, int r = 0) : x(x), l(l), r(r) {}   };   int s[MAXN];   vector<triple> v[MAXN];   int lg[MAXX];   int upd[MAXX], cnt;   int n, m;   int cpwr[MAXX];   int count_power(int l, int r) { return lg[r] - lg[l - 1]; }   int main(int argc, char **argv) {     ios_base::sync_with_stdio(false);     lg[0] = -1;     lg[1] = 0;     for (int i = 2; i < MAXX; ++i) {       lg[i] = lg[i >> 1] + 1;     }     cin >> n >> m;     s[1] = 1;     for (int i = 2; i <= n; ++i) {       s[i] = s[i - 1] + lg[s[i - 1]] + 1;     }     while (m--) {       int t;       cin >> t;       if (t == 1) {         int l, r, x;         cin >> t >> l >> r >> x;         v[t].push_back(triple(x, l, r));       } else {         int l, r, ans = 0;         cin >> t >> l;         r = l;         ++cnt;         for (; t <= n; ++t) {           for (size_t i = 0; i < v[t].size(); ++i) {             if (l <= v[t][i].r && v[t][i].l <= r && upd[v[t][i].x] != cnt) {               upd[v[t][i].x] = cnt;               ++ans;             }           }           int len = r - l + 1;           int k = count_power(l, r);           l += count_power(1, l - 1);           r = l + len - 1 + k;         }         cout << ans <<   n ;       }     }     return 0;   }