malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   string s[100];   long long C[51][3000][2];   int Count[2000100];   double DP[2000100];   int l;   double get(int mask) {     int left = Count[mask];     if (left == 0) return 0;     if (DP[mask] >= 0) return DP[mask];     double res = 0;     int cnt = 0;     for (int i = 0; i < l; i++)       if ((mask & (1 << i)) == 0) {         res += left + Count[mask | (1 << i)] * get(mask | (1 << i));         cnt++;       }     return DP[mask] = res / cnt / left;   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> s[i];     l = s[0].size();     int h1 = l / 2;     int h2 = l - l / 2;     for (int j = 0; j < n; j++)       for (int i = 0; i < (1 << h1); i++) {         long long c = 0;         for (int k = 0; k < n; k++) {           if (k != j) {             int common = 0;             for (int m = 0; m < h1; m++)               if (s[j][m] == s[k][m]) common |= 1 << m;             if ((i & common) == i) c |= 1ll << k;           }         }         C[j][i][0] = c;       }     for (int j = 0; j < n; j++)       for (int i = 0; i < (1 << h2); i++) {         long long c = 0;         for (int k = 0; k < n; k++) {           if (j != k) {             int common = 0;             for (int m = 0; m < h2; m++)               if (s[j][m + h1] == s[k][m + h1]) common |= 1 << m;             if ((i & common) == i) c |= 1ll << k;           }         }         C[j][i][1] = c;       }     int mask = (1 << h1) - 1;     for (int i = 0; i < (1 << l); i++) {       int cnt = 0;       for (int j = 0; j < n; j++) {         long long common = C[j][mask & i][0] & C[j][i >> h1][1];         if (common != 0) cnt++;       }       Count[i] = cnt;     }     for (int i = 0; i < (1 << l); i++) DP[i] = -1.0;     printf( %.15llf n , get(0));   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long m = 200, ans = 0;     while (n--) {       long long a, p;       cin >> a >> p;       m = min(m, p);       ans += m * a;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   typedef struct mk {     int v;     struct mk *next;   } roy;   roy *add(roy *head, int v) {     roy *t = (roy *)malloc(sizeof(roy));     t->v = v;     t->next = NULL;     if (head == NULL) return t;     t->next = head;     return t;   }   long long n, a[300010], s[300030], u, v, count;   roy *gp[300030];   void dfs(int x, int p) {     s[x] += a[x];     roy *t = gp[x];     while (t != NULL) {       int y = t->v;       if (y != p) {         dfs(y, x);         if (s[y] > 0) s[x] += s[y];       }       t = t->next;     }   }   void go(int x, int p, long long total) {     s[x] += a[x];     roy *t = gp[x];     while (t != NULL) {       int y = t->v;       if (y != p) {         go(y, x, total);         if (s[y] > 0) s[x] += s[y];       }       t = t->next;     }     if (s[x] == total) s[x] = 0, count++;   }   int main() {     for (int i = 0; i < 300030; i++) gp[i] = NULL;     scanf( %lld , &n);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (int i = 1; i < n; i++) {       scanf( %lld%lld , &u, &v);       gp[u] = add(gp[u], v);       gp[v] = add(gp[v], u);     }     dfs(1, -1);     long long mx = -1e18;     for (int i = 1; i <= n; i++) {       mx = (mx < s[i]) ? s[i] : mx;       s[i] = 0;     }     go(1, -1, mx);     printf( %lld %lld n , mx * count, count);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int s = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       s = (s << 3) + (s << 1) + ch -  0 , ch = getchar();     return s * f;   }   const int N = 1e5 + 5, M = 320;   int n, m, fa[N], top[N], t[N], sz[N], son[N];   struct Edge {     int to, next;   } e[N];   int head[N], ecnt, id[N], pos[N], L[M], R[M];   inline void adde(int u, int v) {     e[++ecnt].next = head[u];     e[ecnt].to = v;     head[u] = ecnt;   }   void dfs1(int u) {     sz[u] = 1;     for (int i = head[u], v; i; i = e[i].next) {       v = e[i].to;       dfs1(v);       sz[u] += sz[v];       if (sz[son[u]] < sz[v]) son[u] = v;     }   }   int inde, p[N], cnt[M][N], ans, tag[M], blk, blksz;   void dfs2(int u, int fr) {     id[u] = ++inde;     p[inde] = u;     top[u] = fr;     ++cnt[pos[inde]][t[u]];     if (son[u]) dfs2(son[u], fr);     for (int i = head[u], v; i; i = e[i].next) {       v = e[i].to;       if (v != son[u]) dfs2(v, v);     }   }   bool black[N];   inline void modify_blk(int x, int l, int r, int val) {     if (l <= L[x] && R[x] <= r) {       if (val > 0) {         ++tag[x];         ans += cnt[x][tag[x]];       } else {         ans -= cnt[x][tag[x]];         --tag[x];       }     } else {       for (int i = max(l, L[x]), u; i <= min(r, R[x]); ++i) {         u = p[i];         if (black[u]) {           if (val > 0)             --t[u];           else             ++t[u];           continue;         }         if (val > 0) {           --cnt[x][t[u]];           ++cnt[x][--t[u]];           if (t[u] == tag[x]) ++ans;         } else {           --cnt[x][t[u]];           if (t[u] == tag[x]) --ans;           ++cnt[x][++t[u]];         }       }     }   }   inline void modify_node(int u, int val) {     if (black[u] && !val) {       ++cnt[pos[id[u]]][t[u]];       if (t[u] <= tag[pos[id[u]]]) ++ans;     } else if (!black[u] && val) {       --cnt[pos[id[u]]][t[u]];       if (t[u] <= tag[pos[id[u]]]) --ans;     }     black[u] = val;   }   inline void modify(int x, int val) {     if (black[x] == val) return;     modify_node(x, val);     int u = fa[x], l, r;     while (u) {       l = id[top[u]];       r = id[u];       if (pos[l] == pos[r]) {         modify_blk(pos[l], l, r, black[x]);       } else {         modify_blk(pos[l], l, r, black[x]);         modify_blk(pos[r], l, r, black[x]);         for (int i = pos[l] + 1; i < pos[r]; ++i) modify_blk(i, l, r, black[x]);       }       u = fa[top[u]];     }   }   int main() {     n = read();     m = read();     for (int i = 2; i <= n; ++i) fa[i] = read(), adde(fa[i], i);     for (int i = 1; i <= n; ++i) t[i] = read() + 1;     blksz = min(N / (M - 2), int(sqrt(n)));     blk = (n - 1) / blksz + 1;     for (int i = 1; i <= n; ++i) pos[i] = (i - 1) / blksz + 1;     for (int i = 1; i <= blk; ++i) L[i] = (i - 1) * blksz + 1, R[i] = i * blksz;     R[blk] = n;     dfs1(1);     dfs2(1, 0);     while (m--) {       int node = read(), val = 1;       if (node < 0) node = -node, val = 0;       modify(node, val);       printf( %d  , ans);     }     return 0;   }
#include <bits/stdc++.h>   const int inf = (int)1e9;   const int mod = 1e9 + 7;   using namespace std;   long long a[1011][1011];   int n, m;   int id[1000011];   long long k;   int d[1000011];   int c[1011][1011];   int now = 0;   vector<pair<long long, pair<int, int> > > b;   bool cmp(pair<long long, pair<int, int> > a,            pair<long long, pair<int, int> > b) {     return a.first > b.first;   }   int get(int x) {     if (d[x] == x) {       return x;     }     return get(d[x]);   }   void unite(int x, int y) {     x = get(x);     y = get(y);     if (x == y) {       return;     }     if (id[x] <= id[y]) {       d[x] = y;       id[y] += id[x];     } else {       d[y] = x;       id[x] += id[y];     }   }   void rec(int x, int y, int cnt, int mn) {     if (now >= cnt) {       return;     }     now++;     c[x][y] = mn;     if (a[x - 1][y] >= mn && c[x - 1][y] == 0) {       rec(x - 1, y, cnt, mn);     }     if (a[x + 1][y] >= mn && c[x + 1][y] == 0) {       rec(x + 1, y, cnt, mn);     }     if (a[x][y + 1] >= mn && c[x][y + 1] == 0) {       rec(x, y + 1, cnt, mn);     }     if (a[x][y - 1] >= mn && c[x][y - 1] == 0) {       rec(x, y - 1, cnt, mn);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> a[i][j];         b.push_back(make_pair(a[i][j], make_pair(i, j)));         d[(i - 1) * m + j] = (i - 1) * m + j;         id[(i - 1) * m + j] = 1;       }     }     sort(b.begin(), b.end(), &cmp);     for (int x = 0; x < b.size(); x++) {       int i = b[x].second.first, j = b[x].second.second;       if (a[i - 1][j] >= a[i][j]) {         unite((i - 1) * m + j, (i - 2) * m + j);       }       if (a[i + 1][j] >= a[i][j]) {         unite((i - 1) * m + j, (i)*m + j);       }       if (a[i][j + 1] >= a[i][j]) {         unite((i - 1) * m + j, (i - 1) * m + j + 1);       }       if (a[i][j - 1] >= a[i][j]) {         unite((i - 1) * m + j, (i - 1) * m + j - 1);       }       if (k % a[i][j] == 0) {         if (id[get((i - 1) * m + j)] >= k / a[i][j]) {           cout <<  YES  << endl;           rec(i, j, k / a[i][j], a[i][j]);           for (int k = 1; k <= n; k++) {             for (int l = 1; l <= m; l++) {               cout << c[k][l] <<    ;             }             cout << endl;           }           return 0;         }       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct number {     deque<int> q;     map<int, int> db;     int curr = 0;   };   struct pii {     int x, y, id;   };   const int S = 300;   bool sortFunc(pii a, pii b) {     if (a.x / S == b.x / S) return ((a.x / S) & 1 ? a.y > b.y : a.y < b.y);     return a.x < b.x;   }   vector<number> t(1e5 + 1);   void inc(map<int, int>& db, int num, int& curr) {     if (db.count(num) == 0) db[num] == 0;     if (++db[num] == 1) curr++;   }   void dec(map<int, int>& db, int num, int& curr) {     if (--db[num] == 0) curr--;   }   int curr = 0, nums = 0;   void add(int poz, int num) {     if (t[num].curr <= 1 && t[num].q.size() > 0) curr--;     if (t[num].q.empty())       t[num].q.push_front(poz);     else if (poz < t[num].q.front()) {       inc(t[num].db, t[num].q.front() - poz, t[num].curr);       t[num].q.push_front(poz);     } else {       inc(t[num].db, poz - t[num].q.back(), t[num].curr);       t[num].q.push_back(poz);     }     if (t[num].curr <= 1) curr++;     if (t[num].q.size() == 1) nums++;   }   void remove(int poz, int num) {     if (t[num].curr <= 1) curr--;     if (t[num].q.size() == 1)       t[num].q.pop_front();     else if (poz == t[num].q.front()) {       t[num].q.pop_front();       dec(t[num].db, t[num].q.front() - poz, t[num].curr);     } else {       t[num].q.pop_back();       dec(t[num].db, poz - t[num].q.back(), t[num].curr);     }     if (t[num].curr <= 1 && t[num].q.size() > 0) curr++;     if (t[num].q.size() == 0) nums--;   }   int main() {     int n;     cin >> n;     vector<int> sor(n);     for (int& a : sor) cin >> a;     int q;     cin >> q;     vector<pii> v(q);     for (int i = 0; i < q; i++)       cin >> v[i].x >> v[i].y, v[i].id = i, v[i].x--, v[i].y--;     sort(v.begin(), v.end(), sortFunc);     int l = 0, r = -1;     vector<int> ans(q);     for (pii& a : v) {       while (a.x < l) add(l - 1, sor[l - 1]), l--;       while (r < a.y) add(r + 1, sor[r + 1]), r++;       while (l < a.x) remove(l, sor[l]), l++;       while (a.y < r) remove(r, sor[r]), r--;       ans[a.id] = (curr > 0 ? nums : nums + 1);     }     for (int& a : ans) cout << a <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int MAX = 200005;   long long modexp(long long x, long long n) {     if (n == 0) return 1LL;     if (n % 2 == 0) {       long long y = modexp(x, n / 2) % mod;       return (y * y) % mod;     }     return (x * modexp(x, n - 1) % mod) % mod;   }   long long powr(long long x, long long n) {     long long ans = 1;     for (int i = 1; i <= n; i++) ans = ans * x;     return ans;   }   int main() {     int n;     scanf( %d , &n);     int a[n];     int dp[n];     pair<int, int> aux[n];     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       dp[i] = mod;       aux[i] = make_pair(a[i], i);     }     sort(aux, aux + n);     sort(a, a + n);     dp[2] = a[2] - a[0];     dp[3] = a[3] - a[0];     dp[4] = a[4] - a[0];     int idx[n];     for (int i = 0; i < 5; i++) idx[i] = 0;     for (int i = 5; i < n; i++) {       vector<pair<int, int> > p;       if (i - 2 >= 3) p.push_back(make_pair(dp[i - 3] + a[i] - a[i - 2], i - 2));       if (i - 3 >= 3) p.push_back(make_pair(dp[i - 4] + a[i] - a[i - 3], i - 3));       if (i - 4 >= 3) p.push_back(make_pair(dp[i - 5] + a[i] - a[i - 4], i - 4));       sort(p.begin(), p.end());       dp[i] = p[0].first;       idx[i] = p[0].second;     }     int color[n];     int team = 0;     for (int i = n - 1; i > 0; i--) {       team++;       int x = idx[i];       for (int j = x; j <= i; j++) {         color[j] = team;       }       i = x;     }     printf( %d %d n , dp[n - 1], team);     int ans[n];     for (int i = 0; i < n; i++) {       ans[aux[i].second] = color[i];     }     for (int i = 0; i < n; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   char dir[] = { R ,  L ,  D ,  U };   const int MOD = 1e9 + 7;   const long long INF = 1e9;   void setIO(string filename) {     if (fopen((filename +  .in ).c_str(),  r )) {       freopen((filename +  .in ).c_str(),  r , stdin);       freopen((filename +  .out ).c_str(),  w , stdout);     }   }   void solve() {     int n;     cin >> n;     vector<pair<long long, long long> > a(n);     for (auto &i : a) cin >> i.first >> i.second;     sort((a).begin(), (a).end());     for (int i = 0; i < n - 1; i++) {       pair<long long, long long> curr = a[i];       if (a[i + 1].first - a[i].first >= 30)         continue;       else {         while (curr.first < a[i + 1].first) {           curr.second = (curr.second + 4 - 1) / 4;           curr.first++;         }         a[i + 1].second += max(0ll, curr.second - a[i + 1].second);       }     }     long long ans = a.back().first;     while (a.back().second > 1) {       ;       a.back().second = (a.back().second + 4 - 1) / 4;       ans++;     }     cout << max(1ll, ans + (a.back().first == ans)) <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t = 1;     for (int i = 1; i <= t; i++) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int flag = 0;     for (int i = 0; i < n - 1; i++) {       if (s[i] > s[i + 1]) {         flag = 1;         cout <<  YES  << endl;         cout << i + 1 <<     << i + 2;         break;         return 0;       }     }     if (flag == 0) {       cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   using pil = pair<int, ll>;   using pli = pair<ll, int>;   using pll = pair<ll, ll>;   const int inf = (1 << 30) - 1;   const ll INF = (1LL << 60) - 1;   const double pi = acos(-1.0);   const double EPS = 1e-10;   template <typename T>   bool chmax(T &x, const T &y) {     if (x < y) {       x = y;       return true;     }     return false;   }   template <typename T>   bool chmin(T &x, const T &y) {     if (x > y) {       x = y;       return true;     }     return false;   }   template <typename T>   void in(T &x) {     cin >> x;   }   template <typename T>   void out(T x) {     cout << x <<   n ;   }   template <typename T>   void out2(T x) {     cout << x <<    ;   }   template <typename T, typename U>   void in(pair<T, U> &p) {     cin >> p.first >> p.second;   }   template <typename T, typename U>   void out(pair<T, U> p) {     cout << p.first <<     << p.second <<   n ;   }   using vi = vector<int>;   using vll = vector<ll>;   template <typename T>   void in(vector<T> &a) {     for (int i = 0; i < (int)a.size(); i++) cin >> a[i];   }   template <typename T>   void out(const vector<T> &a) {     for (auto &e : a) cout << e <<   n ;   }   template <typename T>   void out2(const vector<T> &a) {     for (auto &e : a) cout << e <<    ;     cout <<   n ;   }   template <typename T>   void unique(vector<T> &a) {     sort(a.begin(), a.end()), a.erase(unique(a.begin(), a.end()), a.end());   }   vector<int> iota(int n) {     vector<int> ret(n);     iota(ret.begin(), ret.end(), 0);     return ret;   }   template <typename T>   vector<int> iota(const vector<T> &a, bool greater = false) {     vector<int> ret = iota((int)a.size());     sort(ret.begin(), ret.end(),          [&](int i, int j) { return (a[i] < a[j]) ^ greater; });     return ret;   }   struct io_setup {     io_setup() {       ios_base::sync_with_stdio(false);       cin.tie(NULL);       cout << fixed << setprecision(15);     }   } io_setup;   const int MOD = 1000000007;   int main() {     int T;     in(T);     int ord[] = {0, 2, 3, 1};     while (T--) {       ll N;       in(N);       ll x = 1;       while (x * 4 <= N) x *= 4;       ll y = (N - x) / 3;       ll p, q, r;       p = x + y, q = x * 2;       while (y) {         x /= 4;         q += x * ord[y / x];         y %= x;       }       r = p ^ q;       if (N % 3 == 1) out(p);       if (N % 3 == 2) out(q);       if (N % 3 == 0) out(r);     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ll N, M;     cin >> N >> M;     if (N > M) swap(N, M);     ll rem = 0;     if (N == 1) {       rem = min(M % 6, 6 - M % 6);     } else {       if (N % 2 == 1 && M % 2 == 1) {         rem = 1;       } else {         if (M == 2) {           rem = 4;         } else if (M == 3 || M == 7) {           rem = 2;         } else {           rem = 0;         }       }     }     cout << N * M - rem << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 100005;   const int MOD = 1000000007;   unordered_map<int, bool> sp;   vector<int> g[MAX];   struct node {     int u, v;     int cost;     node(int _u, int _v, int _cost) {       u = _u;       v = _v;       cost = _cost;     }   };   bool mst_sort(node &a, node &b) { return a.cost < b.cost; }   bool ans_sort(node &a, node &b) { return a.cost > b.cost; }   vector<node> e;   int par[MAX];   int findpar(int r) {     if (par[r] == r) return r;     par[r] = findpar(par[r]);     return par[r];   }   vector<node> tree;   void mst(int n) {     for (int i = 0; i < n; i++) par[i] = i;     sort(e.begin(), e.end(), mst_sort);     int c = 0;     for (int i = 0; i < e.size(); i++) {       int u = findpar(e[i].u);       int v = findpar(e[i].v);       if (u != v) {         par[u] = v;         tree.push_back(e[i]);         g[e[i].u].push_back(e[i].v);         g[e[i].v].push_back(e[i].u);         c++;         if (c == n - 1) break;       }     }     return;   }   int can[MAX];   map<pair<int, int>, bool> vis;   bool dfs(int n, int par) {     if (sp[n]) return can[n] = true;     if (vis[pair<int, int>(n, par)]) return can[n] = false;     if (can[n] != -1) return can[n];     bool ret = false;     for (int i : g[n]) {       if (i != par) ret |= dfs(i, n);       if (ret) return can[n] = ret;     }     return can[n] = ret;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ;     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < k; i++) {       int temp;       cin >> temp;       sp[temp] = true;     }     while (m--) {       int u, v, cost;       cin >> u >> v >> cost;       e.push_back(node(u, v, cost));     }     mst(n);     sort(tree.begin(), tree.end(), ans_sort);     int ans = 0;     memset(can, -1, sizeof can);     for (int i = 0; i < tree.size(); i++) {       node p = tree[i];       if (sp[p.u] && sp[p.v]) {         ans = p.cost;         break;       }       if (sp[p.u]) {         can[p.v] = -1;         if (dfs(p.v, p.u)) {           ans = p.cost;           break;         }       } else if (sp[p.v]) {         can[p.u] = -1;         if (dfs(p.u, p.v)) {           ans = p.cost;           break;         }       } else {         can[p.u] = can[p.v] = -1;         if (dfs(p.u, p.v) && dfs(p.v, p.u)) {           ans = p.cost;           break;         }       }       vis[pair<int, int>(p.u, p.v)] = true;     }     for (int i = 0; i < k; i++) cout << ans <<    ;     cout <<   n ;   }
#include <bits/stdc++.h>   const long long M = 1000005;   const long long mod = 1e9 + 7;   using namespace std;   long long n, m, a, b, fac[M], Ans;   inline long long Fpw(long long Base, long long k) {     long long temp = 1;     while (k) {       if (k & 1) temp = (1LL * temp * Base) % mod;       Base = (1LL * Base * Base) % mod;       k >>= 1;     }     return temp;   }   inline long long Inv(long long a) { return Fpw(a, mod - 2); }   inline long long C(long long n, long long m) {     if (n < 0 || m < 0 || n < m) return 0;     return fac[n] * Inv(fac[m]) % mod * Inv(fac[n - m]) % mod;   }   int main() {     scanf( %lld%lld , &n, &m);     fac[0] = 1;     for (long long i = 1; i <= 1000000; i++)       fac[i] = (1LL * fac[i - 1] * i) % mod;     for (long long i = 2; i <= n; i++) {       long long temp = C(n - 2, i - 2) * fac[i - 2] % mod;       temp = temp * C(m - 1, i - 2) % mod;       if (n - i - 1 >= 0) temp = temp * i % mod * Fpw(n, n - i - 1) % mod;       temp = temp * Fpw(m, n - i) % mod;       Ans = (Ans + temp) % mod;     }     printf( %lld n , Ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   enum { MAXPOS = 110500, MAXBYTE = 20, MAXN = 7070 };   int q_level[MAXN], q_left[MAXN], q_right[MAXN], q_value[MAXN];   int jump_up[MAXBYTE][MAXPOS], jump_low[MAXBYTE][MAXPOS];   int high[MAXPOS];   void init() {     for (int i = 0; (1 << i) < MAXPOS; i++) high[1 << i] = 1;     for (int i = 2; i < MAXPOS; i++) {       high[i] += high[i - 1];     }     for (int i = 1; i < MAXPOS; i++) {       jump_up[0][i] = i + high[i];       jump_low[0][i] = i + high[i] - !(i & (i - 1));     }     for (int i = 1; i < MAXBYTE; i++) {       for (int j = 1; j < MAXPOS; j++) {         if (jump_up[i - 1][j] < MAXPOS) {           jump_up[i][j] = jump_up[i - 1][jump_up[i - 1][j]];         }         if (jump_low[i - 1][j] < MAXPOS) {           jump_low[i][j] = jump_low[i - 1][jump_low[i - 1][j]];         }       }     }   }   inline int get_left(int start, int jumps) {     if (jumps == 0) return start;     for (int i = MAXBYTE - 1; i >= 0; i--) {       if (jumps >= (1 << i)) {         jumps -= (1 << i);         start = jump_low[i][start];       }     }     return start;   }   inline int get_right(int start, int jumps) {     if (jumps == 0) return start;     for (int i = MAXBYTE - 1; i >= 0; i--) {       if (jumps >= (1 << i)) {         jumps -= (1 << i);         start = jump_up[i][start];       }     }     return start;   }   int main() {     init();     int n, m;     scanf( %d %d , &n, &m);     int q_cnt = 0;     for (int i = 0; i < m; i++) {       int type;       scanf( %d , &type);       if (type == 1) {         scanf( %d %d %d %d , &q_level[q_cnt], &q_left[q_cnt], &q_right[q_cnt],               &q_value[q_cnt]);         q_cnt++;       } else {         int level, position;         scanf( %d %d , &level, &position);         set<int> subtree;         for (int j = 0; j < q_cnt; j++) {           if (q_level[j] < level) continue;           int left = get_left(position, q_level[j] - level);           int right = get_right(position, q_level[j] - level);           if (max(left, q_left[j]) <= min(right, q_right[j]))             subtree.insert(q_value[j]);         }         printf( %d n , (int)subtree.size());       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[107];   stack<int> Q[100];   int cmp(int a, int b) { return a > b; }   int main() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     sort(a + 1, a + 1 + n, cmp);     int ans = 0;     int tmp = -1;     int flag = 1;     for (int i = 1; i <= n; i++) {       if (a[i] != k) {         flag = 0;         break;       }     }     if (flag) {       printf( 0 n );       return 0;     }     while (1) {       tmp = -1;       ans++;       for (int i = 1; i <= n; i++) {         if (a[i] == k)           continue;         else if (tmp == a[i])           continue;         else {           tmp = a[i];           a[i]++;         }       }       int flag = 1;       for (int i = 1; i <= n; i++) {         if (a[i] != k) {           flag = 0;           break;         }       }       if (flag) break;     }     printf( %d , ans);     return 0;   }