malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   set<pair<int, int> > vis;   int mx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};   int my[8] = {-1, 1, -2, 2, -2, 2, -1, 1};   int main() {     long long K;     int N;     cin >> K >> N;     for (int i = 0; i < N; i++) {       int x, y;       cin >> x >> y;       vis.insert(pair<int, int>(x, y));     }     int i = 0;     vector<pair<int, int> > cur;     cur.push_back(pair<int, int>(0, 0));     vis.insert(pair<int, int>(0, 0));     int pinc, ppinc;     for (i = 0; i < 100 && i < K; i++) {       vector<pair<int, int> > nxt;       for (int j = 0; j < cur.size(); j++) {         int cx = cur[j].first, cy = cur[j].second;         for (int m = 0; m < 8; m++) {           int nx = cx + mx[m], ny = cy + my[m];           pair<int, int> t(nx, ny);           if (!vis.count(t)) {             vis.insert(t);             nxt.push_back(t);           }         }       }       cur = nxt;       ppinc = pinc;       pinc = nxt.size();     }     const int md = 1000000007;     long long num = (K - i);     long long dif = pinc - ppinc;     num %= md;     dif %= md;     long long a = pinc + num * dif + pinc + dif;     if (a % 2 == 0) {       a /= 2;     } else {       num /= 2;     }     a %= md;     num %= md;     cout << (vis.size() - N + a * num) % md;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   int main() {     fast();     long long n;     cin >> n;     if (n % 4 == 1)       cout <<  0  <<     <<  A  << endl;     else if (n % 4 == 0)       cout <<  1  <<     <<  A  << endl;     else if (n % 4 == 2)       cout <<  1  <<     <<  B  << endl;     else if (n % 4 == 3)       cout <<  2  <<     <<  A  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n;   long long qpow(long long a, long long b) {     long long x = 1, base = a;     while (b) {       if (b & 1) {         x = (x * base) % 1000000007;       }       base = (base * base) % 1000000007;       b >>= 1;     }     return x % 1000000007;   }   int main() {     ios::sync_with_stdio(0);     cin >> n;     long long ans = (qpow(4, ((1ll << n) - 2)) * 6) % 1000000007;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool check(int a, int b, int frst, int s) {     return a * frst / (double)s >= (double)b;   }   int main() {     int n, a, b, *arr;     cin >> n >> a >> b;     arr = new int[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     sort(arr + 1, arr + n);     for (int i = 1; i < n; i++) {       arr[i] = arr[i] + arr[i - 1];     }     int l = 0, r = n - 1, ans;     while (l <= r) {       int mid = (l + r) / 2;       bool now = check(a, b, arr[0], arr[mid]);       bool nx = check(a, b, arr[0], arr[mid + 1]);       if (mid == n - 1 || (now && !nx)) {         ans = mid;         break;       } else if (now && nx) {         l = mid + 1;       } else {         r = mid - 1;       }     }     cout << n - (ans + 1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 100020;   int n, q;   int a[Maxn];   int pre[Maxn], fin[Maxn], rel[Maxn];   int tree[Maxn << 2];   vector<int> V;   int getid(int x) { return lower_bound(V.begin(), V.end(), x) - V.begin() + 1; }   void add(int tar, int w, int l, int r, int x) {     if (l == r) {       tree[x] = max(tree[x], w);       return;     }     int mid = (l + r) >> 1;     if (tar <= mid)       add(tar, w, l, mid, x << 1);     else       add(tar, w, mid + 1, r, x << 1 | 1);     tree[x] = max(tree[x << 1], tree[x << 1 | 1]);   }   int query(int L, int R, int l, int r, int x) {     if (L <= l && R >= r) return tree[x];     int mid = (l + r) >> 1;     int ret = 0;     if (L <= mid) ret = max(ret, query(L, R, l, mid, x << 1));     if (R > mid) ret = max(ret, query(L, R, mid + 1, r, x << 1 | 1));     return ret;   }   void cal(int *a, int *b, int flag = 0) {     memset(tree, 0, sizeof(tree));     for (int i = 1; i <= n; i++) {       if (flag)         b[i] = query(a[i], V.size(), 1, V.size(), 1);       else {         b[i] = query(a[i] + 1, V.size(), 1, V.size(), 1);       }       add(a[i], i, 1, V.size(), 1);     }   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i < n; i++) a[i] = abs(a[i + 1] - a[i]);     n--;     for (int i = 1; i <= n; i++) V.push_back(a[i]);     sort(V.begin(), V.end());     V.erase(unique(V.begin(), V.end()), V.end());     for (int i = 1; i <= n; i++) a[i] = getid(a[i]);     cal(a, pre);     reverse(a + 1, a + n + 1);     cal(a, fin, 1);     reverse(a + 1, a + n + 1);     for (int i = 1; i <= n; i++) rel[i] = n + 1 - fin[n + 1 - i];     for (int i = 1; i <= q; i++) {       int l, r;       scanf( %d%d , &l, &r);       r--;       long long ans = 0;       for (int j = l; j <= r; j++) {         long long L = j - max(l - 1, pre[j]);         long long R = min(r + 1, rel[j]) - j;         ans += L * R * V[a[j] - 1];       }       printf( %lld n , ans);     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   const int INF = 0x3f3f3f3f;   template <typename X>   inline bool minimize(X& p, X q) {     if (p <= q) return 0;     p = q;     return 1;   }   template <typename X>   inline bool maximize(X& p, X q) {     if (p >= q) return 0;     p = q;     return 1;   }   char str[100];   bool v[10000005];   int a[5005];   int n, kk;   void doit() {     memset(v, 0, sizeof(v));     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       v[a[i]] = 1;     }     int q, x, tmp, left, xx;     scanf( %d , &q);     for (int ii = 1; ii <= q; ii++) {       scanf( %d , &xx);       int ans = 50;       for (int i = 1; i <= n; i++)         for (int j = 0; j <= kk; j++) {           x = xx;           tmp = a[i] * j;           if (x < tmp) continue;           if (x == tmp) {             ans = min(ans, j);             continue;           }           x -= tmp;           left = kk - j;           for (int k = 1; k <= left; k++)             if (x % k == 0) {               if (x / k >= 10000005) continue;               if (v[x / k]) {                 ans = min(ans, j + k);                 break;               }             }         }       if (ans != 50)         printf( %d n , ans);       else         printf( %d n , -1);     }   }   int main() {     while (scanf( %d%d , &n, &kk) != EOF) doit();   }
#include <bits/stdc++.h>   using namespace std;   int i, dp[100000], t;   string s;   int main() {     cin >> s;     for (i = 0; i < s.size(); i++)       if (s[i] >=  a ) {         dp[i] = dp[i - 1];         t++;       } else         dp[i] = min(dp[i - 1] + 1, t);     cout << dp[s.size() - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int nbPairs[5001][5001];   const int MOD = 1e9 + 7;   int main() {     char s[5001], t[5001];     scanf( %s%s , &s, &t);     int ss = strlen(s), st = strlen(t);     for (int is = ss - 1; is >= 0; is--)       for (int it = st - 1; it >= 0; it--) {         if (s[is] == t[it]) nbPairs[is][it] += 1 + nbPairs[is + 1][it + 1];         nbPairs[is][it] += nbPairs[is][it + 1];         nbPairs[is][it] %= MOD;       }     int a = 0;     for (int i = 0; i < ss; i++) {       a += nbPairs[i][0];       a %= MOD;     }     printf( %d n , a);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2000005;   char str[MAXN];   struct Palindromic_Tree {     vector<pair<int, int>> next[MAXN];     int fail[MAXN];     int cnt[MAXN];     int num[MAXN];     int len[MAXN];     int S[MAXN];     int last;     int n;     int p;     int newnode(int l) {       next[p].clear();       cnt[p] = 0;       num[p] = 0;       len[p] = l;       return p++;     }     void init() {       p = 0;       next[0].clear();       next[1].clear();       newnode(0);       newnode(-1);       last = 0;       n = 0;       S[n] = -1;       fail[0] = 1;     }     int get_fail(int x) {       while (S[n - len[x] - 1] != S[n]) x = fail[x];       return x;     }     int find(int cur, int c) {       for (int i = 0; i < next[cur].size(); i++) {         if (next[cur][i].first == c) return next[cur][i].second;       }       return 0;     }     int add(int c) {       c -=  a ;       S[++n] = c;       int cur = get_fail(last);       int k = find(cur, c);       if (k == 0) {         int now = newnode(len[cur] + 2);         fail[now] = find(get_fail(fail[cur]), c);         next[cur].push_back(make_pair(c, now));         num[now] = num[fail[now]] + 1;       }       last = find(cur, c);       cnt[last]++;       return num[last];     }     void count() {       for (int i = p - 1; i >= 0; --i) cnt[fail[i]] += cnt[i];     }   } tree;   long long head[MAXN], tail[MAXN];   int main() {     int n;     while (~scanf( %d , &n)) {       memset(head, 0, sizeof(head));       memset(tail, 0, sizeof(tail));       scanf( %s , str + 1);       tree.init();       for (int i = 1; i <= n; i++) {         tail[i] = tree.add(str[i]);       }       tree.init();       for (int i = n; i >= 1; i--) {         head[i] = ((head[i + 1] + tree.add(str[i])) % 51123987) % 51123987;       }       long long ans = head[1] * (head[1] - 1) / 2 % 51123987;       for (int i = 2; i <= n; i++)         ans = (ans - tail[i - 1] * head[i] % 51123987) % 51123987;       ans = (ans + 51123987) % 51123987;       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   int q[1000001] = {0}, p[1000001] = {0};   int main() {     int n, i, a, b, j;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d%d , &a, &b);       q[a] = b;       ++p[a];       --p[b];     }     i = 0;     while (p[++i] != 1)       ;     j = q[0];     while (j && i) {       printf( %d %d  , i, j);       i = q[i];       j = q[j];     }     if (i) printf( %d , i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000 + 10, M = 2000 + 10;   int n, m, s, t;   int h[N], ecnt, nxt[M], v[M];   bool mp[N][N];   int dis[2][N], ans;   void _add(int x, int y) {     nxt[++ecnt] = h[x];     v[ecnt] = y;     h[x] = ecnt;     mp[x][y] = 1;   }   queue<int> que;   void dijkstra(int s, int *dis) {     for (int i = 1; i <= n; ++i) dis[i] = -1;     que.push(s);     dis[s] = 0;     while (!que.empty()) {       int u = que.front();       que.pop();       for (int i = h[u]; i; i = nxt[i])         if (dis[v[i]] == -1) {           dis[v[i]] = dis[u] + 1;           que.push(v[i]);         }     }   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m >> s >> t;     ecnt = 1;     for (int i = 1; i <= m; ++i) {       int x, y;       cin >> x >> y;       _add(x, y);       _add(y, x);     }     dijkstra(s, dis[0]);     dijkstra(t, dis[1]);     for (int i = 1; i <= n; ++i)       for (int j = i + 1; j <= n; ++j)         if (!mp[i][j]) {           ans += min(dis[0][i] + dis[1][j] + 1, dis[1][i] + dis[0][j] + 1) >=                  dis[0][t];         }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int n, arr[100];   bool vis[100];   int Cycle(int st) {     int l = 1;     int node = arr[st];     vis[st] = true;     while (node != st) {       if (vis[node]) return -1;       l++;       vis[node] = true;       node = arr[node];     }     return l;   }   long long GCD(long long a, long long b) {     int max = (a > b) ? a : b, min = (a < b) ? a : b;     while (min != 0) {       int temp = max % min;       max = min;       min = temp;     }     return max;   }   long long LCM(long long a, long long b) { return a * b / GCD(a, b); }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , arr + i);       arr[i]--;     }     long long res = 1;     for (int i = 0; i < n; i++) {       if (!vis[i]) {         long long l = Cycle(i);         if (l == -1) {           printf( -1 n );           return 0;         }         if (l % 2 == 0) l /= 2;         res = LCM(res, l);       }     }     printf( %lld n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, l, r, sum, sk;   int a[1010];   int main() {     while (scanf( %d%d%d%d%d%d , &n, &k, &l, &r, &sum, &sk) != EOF) {       if (n != k) {         int s1, s2;         s1 = sum - sk;         s2 = sk;         int tmp1, tmp2;         tmp1 = s1 / (n - k);         tmp2 = s1 - tmp1 * (n - k);         for (int i = 0; i < n - k; i++) {           a[i] = tmp1;         }         for (int i = 0; i < tmp2; i++) {           a[i]++;         }         tmp1 = s2 / k;         tmp2 = s2 - tmp1 * k;         for (int i = n - k; i < n; i++) {           a[i] = tmp1;         }         for (int i = n - k; i < n - k + tmp2; i++) {           a[i]++;         }         for (int i = 0; i < n; i++) {           if (i == 0) {             printf( %d , a[i]);           } else {             printf(  %d , a[i]);           }         }         printf(  n );       } else {         int tmp1 = sum / n;         int tmp2 = sum - n * tmp1;         for (int i = 0; i < n; i++) {           a[i] = tmp1;         }         for (int i = 0; i < tmp2; i++) {           a[i]++;         }         for (int i = 0; i < n; i++) {           if (i == 0) {             printf( %d , a[i]);           } else {             printf(  %d , a[i]);           }         }         printf(  n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, k;     scanf( %d , &t);     while (t--) {       scanf( %d %d , &n, &k);       if (n == k || n == 1 || n == 2) {         cout <<  Alice n ;         continue;       }       if (k % 3) {         if (!(n % 3)) {           cout <<  Bob n ;           continue;         }         cout <<  Alice n ;         continue;       }       if ((n % (k + 1)) % 3 == 0 && n % (k + 1) != k) {         cout <<  Bob n ;         continue;       }       cout <<  Alice n ;       continue;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fun(string x) {     if (x.size() > 7) return 1000005;     int n = 0;     for (int i = 0; i < x.size(); i++) {       n *= 10;       n += (x[i] -  0 );     }     return n;   }   bool f(string s) {     if (s.size() > 1 && s[0] ==  0  || s.size() > 7)       return false;     else       return true;   }   int main() {     string s;     cin >> s;     int n = s.size();     int a1, a2, a3, mx = 0;     bool d = false;     for (int i = 1; i < s.size() - 1; i++) {       for (int j = i + 1; j < s.size(); j++) {         if (f(s.substr(0, i)) && f(s.substr(i, j - i)) &&             f(s.substr(j, s.size() - j))) {           if (fun(s.substr(0, i)) <= 1000000 &&               fun(s.substr(i, j - i)) <= 1000000 &&               fun(s.substr(j, s.size() - j)) <= 1000000) {             a1 = fun(s.substr(0, i));             a2 = fun(s.substr(i, j - i));             a3 = fun(s.substr(j, s.size() - j));             mx = max((a1 + a2 + a3), mx);             d = true;           }         }       }     }     if (d)       cout << mx <<   n ;     else       cout <<  -1 n ;   }
#include <bits/stdc++.h>   using namespace std;   const int S = 100009;   vector<int> in[S];   vector<int> out[S];   bool viz[S];   int moa[S];   vector<int> topol;   vector<int> rang[S];   void dfs(int a) {     if (viz[a]) return;     viz[a] = 1;     for (auto u : out[a]) dfs(u);     topol.push_back(a);   }   void sfd(int a, int c) {     if (moa[a] != -1) return;     moa[a] = c;     for (auto u : in[a]) sfd(u, c);   }   int main() {     memset(moa, -1, sizeof moa);     int n, v;     cin >> n;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         scanf( %i , &v);         if (v != 0) {           in[i].push_back(j);           out[j].push_back(i);         }       }     }     for (int i = 1; i <= n; i++) dfs(i);     int r = 0, u;     for (int i = n - 1; i > -1; i--) {       u = topol[i];       if (moa[u] == -1) {         sfd(u, r);         r++;       }     }     for (int i = 1; i <= n; i++) {       if (moa[i] != moa[1]) {         printf( NO );         return 0;       }     }     printf( YES );   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vi = vector<int>;   using pii = array<ll, 3>;   vector<vector<pii>> adj;   vi sz, parent;   int fill(int cur, int par = -1) {     parent[cur] = par;     for (auto [v, _, __] : adj[cur])       if (v != par) sz[cur] += fill(v, cur);     sz[cur] = max(1, sz[cur]);     return sz[cur];   }   int main(int argc, char* argv[]) {     std::ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.precision(10);     int t;     cin >> t;     while (t--) {       ll n, s;       cin >> n >> s;       adj.assign(n, {});       sz.assign(n, 0);       parent.assign(n, -1);       for (int i = (0); i < (n - 1); ++i) {         ll u, v, w, c;         cin >> u >> v >> w >> c;         u--, v--;         adj[u].push_back({v, w, c});         adj[v].push_back({u, w, c});       }       fill(0);       priority_queue<array<ll, 3>> prePQ[2];       ll start_sum = 0;       for (int u = (0); u < (n); ++u)         for (auto [v, w, c] : adj[u]) {           if (parent[v] == u) {             start_sum += w * sz[v];             if (c == 1) {               prePQ[0].push({sz[v] * (w - w / 2), w, sz[v]});               prePQ[0].push({sz[v] * (w / 2 - w / 4), w / 2, sz[v]});             } else {               prePQ[1].push({sz[v] * (w - w / 2), w, sz[v]});             }           }         }       ll mi = 1e18;       for (int p = (0); p < (2); ++p) {         ll steps = 0, cur_sum = start_sum;         priority_queue<array<ll, 3>> pqOne = prePQ[0], pqTwo = prePQ[1];         if (p && pqOne.size()) {           steps++;           auto [g, w, s] = pqOne.top();           w /= 4;           cur_sum -= g;           pqOne.pop();           pqOne.push({s * (w - w / 2), w, s});         }         while (cur_sum > s) {           if (pqOne.empty()) {             steps += 2;             auto [g, w, s] = pqTwo.top();             w /= 2;             cur_sum -= g;             pqTwo.pop();             pqTwo.push({s * (w - w / 2), w, s});           } else if (pqTwo.empty()) {             steps += 1;             auto [g, w, s] = pqOne.top();             w /= 4;             cur_sum -= g;             pqOne.pop();             pqOne.push({s * (w - w / 2), w, s});           } else {             steps += 2;             auto [g11, w11, s11] = pqOne.top();             pqOne.pop();             auto [g12, w12, s12] = pqOne.top();             pqOne.pop();             auto [g2, w2, s2] = pqTwo.top();             pqTwo.pop();             if (g11 + g12 > g2) {               pqTwo.push({g2, w2, s2});               cur_sum -= g11 + g12;               w11 /= 4;               w12 /= 4;               pqOne.push({s11 * (w11 - w11 / 2), w11, s11});               pqOne.push({s12 * (w12 - w12 / 2), w12, s12});             } else {               pqOne.push({g11, w11, s11});               pqOne.push({g12, w12, s12});               cur_sum -= g2;               w2 /= 2;               pqTwo.push({s2 * (w2 - w2 / 2), w2, s2});             }           }         }         mi = min(mi, steps);       }       cout << mi <<   n ;     }     cout.flush();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2 * 100100;   int a[maxn], logTable[maxn], rmq[50][maxn];   int minPos(int i, int j) {     int k = logTable[j - i];     int x = rmq[k][i];     int y = rmq[k][j - (1 << k) + 1];     return a[x] <= a[y] ? a[x] : a[y];   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 2; i <= n; i++) logTable[i] = logTable[i >> 1] + 1;     for (int i = 0; i < n; ++i) rmq[0][i] = i;     for (int k = 1; (1 << k) < n; ++k) {       for (int i = 0; i + (1 << k) <= n; i++) {         int x = rmq[k - 1][i];         int y = rmq[k - 1][i + (1 << (k - 1))];         rmq[k][i] = a[x] <= a[y] ? x : y;       }     }     set<pair<int, int> > s;     for (int i = 0; i < n; i++) {       int curr, curl;       int l = i, r = n;       while (r - l > 1) {         int mid = (r + l) / 2;         int curmin = minPos(i, mid);         if (curmin == a[i])           l = mid;         else           r = mid;       }       curr = l;       l = -1, r = i;       while (r - l > 1) {         int mid = (r + l) / 2;         int curmin = minPos(mid, i);         if (curmin == a[i])           r = mid;         else           l = mid;       }       curl = r;       s.insert(make_pair(-a[i], curr - curl + 1));     }     for (int i = 1; i <= n; i++) {       while ((int)(s).size() && s.begin()->second < i) s.erase(s.begin());       printf( %d  , -s.begin()->first);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, t;     cin >> n >> m;     string s[100 + 10];     for (int i = 0; i < n; i++) {       cin >> s[i];     }     for (int i = 0; i < n; i++) {       t = s[i][0];       for (int j = 0; j < m; j++) {         if (s[i][j] != t) {           cout <<  NO  << endl;           return 0;         }       }     }     for (int i = 1; i < n - 1; i++) {       if (s[i] == s[i - 1] || s[i] == s[i + 1]) {         cout <<  NO  << endl;         return 0;       }     }     cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 100 * 1000 + 5;   int Q;   map<int, int> POS;   struct range {     int s, e;     long long siz;     long long mod[5];     range(int s = -1, int e = -1) : s(s), e(e) {       memset(mod, 0, sizeof mod);       siz = 0;     }   } t[1 << 18];   inline void build(int x) {     if (t[x].e <= t[x].s) return;     int mid = (t[x].s + t[x].e) / 2;     int l = (x << 1);     int r = l + 1;     t[l] = range(t[x].s, mid);     t[r] = range(mid + 1, t[x].e);     build(l);     build(r);   }   inline void add(int root, int pos, int val) {     range &now = t[root];     now.siz++;     if (now.s == now.e) {       now.mod[1] = val;       return;     }     int l = (root << 1), r = (root << 1) + 1;     if (pos <= t[l].e)       add(l, pos, val);     else       add(r, pos, val);     for (int i = 0; i < 5; i++) {       int tmp = (i - t[l].siz) % 5;       tmp = (tmp + 5) % 5;       now.mod[i] = t[l].mod[i] + t[r].mod[tmp];     }   }   inline void del(int root, int pos, int val) {     range &now = t[root];     now.siz--;     if (now.s == now.e) {       now.mod[1] = 0;       return;     }     int l = (root << 1), r = (root << 1) + 1;     if (pos <= t[l].e)       del(l, pos, val);     else       del(r, pos, val);     for (int i = 0; i < 5; i++) {       int tmp = (i - t[l].siz) % 5;       tmp = (tmp + 5) % 5;       now.mod[i] = t[l].mod[i] + t[r].mod[tmp];     }   }   int main() {     scanf( %d , &Q);     vector<pair<int, int> > qq;     vector<int> num;     for (int i = 1; i <= Q; i++) {       char test[5];       scanf( %s , test);       if (test[0] ==  a ) {         int tmp;         scanf( %d , &tmp);         qq.push_back(pair<int, int>(0, tmp));         num.push_back(tmp);       } else if (test[0] ==  d ) {         int tmp;         scanf( %d , &tmp);         qq.push_back(pair<int, int>(1, tmp));       } else         qq.push_back(pair<int, int>(2, -1));     }     sort(num.begin(), num.end());     int uni = 0;     for (int i = 0; i < (int)num.size(); i++) {       if (POS[num[i]] == 0) POS[num[i]] = ++uni;     }     t[1] = range(1, uni);     build(1);     for (int i = 0; i < (int)qq.size(); i++) {       if (qq[i].first == 0)         add(1, POS[qq[i].second], qq[i].second);       else if (qq[i].first == 1)         del(1, POS[qq[i].second], qq[i].second);       else         printf( %I64d n , t[1].mod[3]);     }     return 0;   }
#include<bits/stdc++.h>   using  namespace std;   int main(){        int T;        cin>>T;        while(T--){            long long int N;            cin>>N;            int sum1=0,i=1,count=0;            while(true){                sum1+=i;count++;                if(sum1>=N){break;}                i+=2;             }            cout<<count<<  n ;        }        return 0;    }