malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct node {     long double x, y;     node(long double X = 0.0, long double Y = 0.0) { x = X, y = Y; }   } que[200005];   int n, k;   int t[200005], head, tail;   long double s[200005], a[200005], b[200005], f[2][200005];   long double K(node, node);   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; ++i) {       scanf( %d , t + i);       s[i] = s[i - 1] + t[i];       a[i] = a[i - 1] + s[i] / t[i];       b[i] = b[i - 1] + 1.0 / t[i];     }     int now = 1, lst = 0;     for (int i = 1; i <= n; ++i) f[now][i] = 9999999999999999;     for (int p = 1; p <= k; ++p) {       swap(now, lst);       head = tail = 0;       que[tail++] = node(0, 0);       for (int i = 1; i <= n; ++i) {         while (head + 1 < tail)           if (K(que[head], que[head + 1]) < b[i])             ++head;           else             break;         f[now][i] = que[head].y - que[head].x * b[i] + a[i];         node tmp(s[i], f[lst][i] - a[i] + s[i] * b[i]);         while (head < tail - 1)           if (K(que[tail - 1], que[tail - 2]) > K(que[tail - 2], tmp))             --tail;           else             break;         que[tail++] = tmp;       }     }     printf( %.10lf , (double)f[now][n]);     return 0;   }   long double K(node x, node y) { return (x.y - y.y) / (x.x - y.x); }
#include <bits/stdc++.h>   using namespace std;   const int fx[] = {+1, -1, +0, +0}, fy[] = {+0, +0, +1, -1};   const long long mod = 1e9 + 7, INF = 1e18, mx = 1e6;   int Case = 1, cas = 0;   long long n, A[mx], Sum;   int main() {     ios_base ::sync_with_stdio(0), cin.tie(0);     ;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> A[i];       Sum += A[i];     }     if (Sum % 3)       cout << 0 << endl;     else {       long long Ans = 0, taken = 0, milse = 0;       long long target = Sum / 3;       for (int i = 1; i < n; i++) {         taken += A[i];         if (taken == target + target) Ans += milse;         if (taken == target) milse++;       }       cout << Ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, t, ma, sum = 0;     std::string s[1000];     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < k; i++) {       cin >> t;       ma = 1;       map<char, int> m;       for (int j = 0; j < n; j++) m[s[j][i]]++;       for (map<char, int>::iterator it = m.begin(); it != m.end(); it++)         ma = max(ma, it->second);       sum += ma * t;     }     cout << sum;   }
#include <bits/stdc++.h>   #pragma optimise GCC(-O2)   using namespace std;   mt19937_64 rang(       chrono::high_resolution_clock::now().time_since_epoch().count());   int rng(int lim) {     uniform_int_distribution<int> uid(0, lim - 1);     return uid(rang);   }   long long INF = LLONG_MAX;   const long long M = 1000000007;   long long powm(long long, long long);   long long foo(long long a) {     long long ct = 1;     long long tp = a;     while (tp > 0) {       tp -= ct;       ct++;     }     return ct;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     string s;     cin >> s;     long long hr = 0;     long long mn = 0;     hr += 10 * (s[0] -  0 );     hr += (s[1] -  0 );     mn += 10 * (s[3] -  0 );     mn += (s[4] -  0 );     long long a;     cin >> a;     mn += a;     long long ex = mn / 60;     mn = mn % 60;     hr += ex;     hr %= 24;     if (hr > 9 && mn > 9) cout << hr <<  :  << mn;     if (hr > 9 && mn <= 9) cout << hr <<  :  <<  0  << mn;     if (hr <= 9 && mn > 9) cout <<  0  << hr <<  :  << mn;     if (hr <= 9 && mn <= 9) cout <<  0  << hr <<  :  <<  0  << mn;   }   long long powm(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % M;       a = (a * a) % M;       b >>= 1;     }     return res;   }
#include <bits/stdc++.h>   using namespace std;   using int64 = long long;   using ld = double;   const int MAXN = 1e5 + 1;   vector<int> G[MAXN], comp[MAXN], suf_freq[MAXN];   vector<int64> suf_sum[MAXN];   int comp_cnt, comp_ind[MAXN], p[MAXN], dp1[MAXN], dp2[MAXN], dp[MAXN],       diameter[MAXN];   void max_self(int &a, int b) { a = max(a, b); }   void dfs1(int u) {     comp_ind[u] = comp_cnt;     comp[comp_cnt].emplace_back(u);     for (int v : G[u])       if (!comp_ind[v]) {         p[v] = u;         dfs1(v);         if (dp1[u] <= dp1[v] + 1) {           dp2[u] = dp1[u];           dp1[u] = dp1[v] + 1;         } else           max_self(dp2[u], dp1[v] + 1);       }   }   void dfs2(int u, int dist) {     dp[u] = max(dp1[u], dist);     max_self(diameter[comp_cnt], dp[u]);     for (int v : G[u])       if (v != p[u]) {         if (dp1[u] == dp1[v] + 1)           dfs2(v, max(dp2[u], dist) + 1);         else           dfs2(v, max(dp1[u], dist) + 1);       }   }   ld solve(int x, int y) {     if (x == y) return -1;     if (comp[x].size() > comp[y].size()) swap(x, y);     int D = max(diameter[x], diameter[y]);     ld sum = 0;     for (int d = 0; d <= diameter[x]; ++d) {       int64 freq = suf_freq[x][d];       if (d < diameter[x]) freq -= suf_freq[x][d + 1];       if (freq == 0) continue;       int suf = max(0, min(D - d - 1, diameter[y]));       sum += freq * suf_sum[y][suf];       sum += freq * suf_freq[y][suf] * (d + 1);       int rest = comp[y].size() - suf_freq[y][suf];       sum += freq * rest * D;     }     return sum / ((ld)comp[x].size() * comp[y].size());   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int N, M, Q;     cin >> N >> M >> Q;     for (int i = 0; i < M; ++i) {       int u, v;       cin >> u >> v;       G[u].emplace_back(v);       G[v].emplace_back(u);     }     for (int u = 1; u <= N; ++u)       if (!comp_ind[u]) {         ++comp_cnt;         dfs1(u);         dfs2(u, 0);         suf_sum[comp_cnt] = vector<int64>(diameter[comp_cnt] + 1);         suf_freq[comp_cnt] = vector<int>(diameter[comp_cnt] + 1);         for (int v : comp[comp_cnt]) {           suf_sum[comp_cnt][dp[v]] += dp[v];           ++suf_freq[comp_cnt][dp[v]];         }         for (int d = diameter[comp_cnt] - 1; d >= 0; --d) {           suf_sum[comp_cnt][d] += suf_sum[comp_cnt][d + 1];           suf_freq[comp_cnt][d] += suf_freq[comp_cnt][d + 1];         }       }     map<pair<int, int>, ld> sol;     cout << fixed << setprecision(8);     for (int q = 0; q < Q; ++q) {       int u, v;       cin >> u >> v;       u = comp_ind[u], v = comp_ind[v];       pair<int, int> p{u, v};       auto it = sol.find(p);       if (it != sol.end())         cout << it->second <<   n ;       else {         ld ans = solve(u, v);         sol[p] = sol[make_pair(v, u)] = ans;         cout << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void read(T& x) {     bool fu = 0;     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     if (c ==  - ) fu = 1, c = getchar();     for (x = 0; c > 32; c = getchar()) x = x * 10 + c -  0 ;     if (fu) x = -x;   };   template <class T>   inline void read(T& x, T& y) {     read(x);     read(y);   }   template <class T>   inline void read(T& x, T& y, T& z) {     read(x);     read(y);     read(z);   }   inline char getc() {     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     return c;   }   const int D = 360360;   long long A, B, C;   int n, i, j, k, l, p;   int f[761000];   int dp(long long A, long long B) {     int i, j;     memset(f, 127, sizeof(f));     f[B - A] = 0;     for (i = B - A; i >= 1; i--) {       long long x = A + i;       f[i - 1] = min(f[i - 1], f[i] + 1);       for (j = 2; j <= k; j++)         if (x - (x % j) >= A)           f[x - (x % j) - A] = min(f[x - (x % j) - A], f[i] + 1);     }     return f[0];   }   int main() {     cin >> B >> A >> k;     long long t1 = (A - 1) / D, t2 = (B - 1) / D, ans, ci = dp(0, D);     if (t1 == t2)       ans = dp(A, B);     else       ans = dp(A, (t1 + 1) * D) + dp(t2 * D, B) + ci * (t2 - t1 - 1);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, x = 0, y = 0, p = 0, q = 0;       cin >> n;       bool ans = true;       for (int i = 1; i <= n; i++) {         cin >> p >> q;         if (p < x || q < y)           ans = false;         else if (q - y > p - x)           ans = false;         x = p;         y = q;       }       if (ans == true)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long int modInverse(long long int n, long long int p) {     return power(n, p - 2, p);   }   struct point {     long long int x, y;   };   void bfs(long long int node, vector<long long int> adj[], vector<bool> &visit,            vector<long long int> &dis) {     queue<long long int> q;     visit[node] = true;     dis[node] = 0;     q.push(node);     while (!q.empty()) {       long long int s = q.front();       q.pop();       for (auto u : adj[s]) {         if (visit[u]) continue;         visit[u] = true;         dis[u] = dis[s] + 1;         q.push(u);       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int tests;     cin >> tests;     for (long long int gg = 0; gg < tests; gg++) {       long long int n, a, b, da, db;       cin >> n >> a >> b >> da >> db;       vector<long long int> adj[n + 1];       for (long long int i = 0; i < n - 1; i++) {         long long int x, y;         cin >> x >> y;         adj[x].push_back(y);         adj[y].push_back(x);       }       vector<bool> visit(n + 1, false);       vector<long long int> dis(n + 1, 0);       bfs(a, adj, visit, dis);       if (dis[b] <= da) {         cout <<  Alice n ;         continue;       }       if (db > 2 * da) {         long long int m1 = *max_element(dis.begin(), dis.end()), node1 = 0;         for (long long int i = 1; i < n + 1; i++) {           if (dis[i] == m1) {             node1 = i;             break;           }         }         visit.assign(n + 1, false);         dis.assign(n + 1, 0);         bfs(node1, adj, visit, dis);         long long int dia = *max_element(dis.begin(), dis.end());         if (dia > 2 * da) {           cout <<  Bob n ;         } else {           cout <<  Alice n ;         }       } else {         cout <<  Alice n ;       }     }   }
#include <bits/stdc++.h>   const int SIZE_N = (1000 + 10);   const int SIZE_M = (SIZE_N);   const int SIZE_K = (500000 + 10);   int n, m, k;   int mat[SIZE_N][SIZE_M];   int mx[SIZE_M], my[SIZE_N];   int main(void) {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) scanf( %d , &mat[i][j]);     for (int i = 1; i <= n; ++i) my[i] = i;     for (int i = 1; i <= m; ++i) mx[i] = i;     for (; k > 0; --k) {       char typ[10];       int a, b;       scanf( %s , typ);       scanf( %d%d , &a, &b);       if (typ[0] ==  c ) {         std::swap(mx[a], mx[b]);       } else if (typ[0] ==  r ) {         std::swap(my[a], my[b]);       } else if (typ[0] ==  g ) {         printf( %d n , mat[my[a]][mx[b]]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   vector<int> adj[100005];   vector<int>::iterator it;   int con[100005];   bool visited[100005];   int bfs(int root) {     int j, i, u, v, mn = 10000000, temp;     queue<int> Q;     Q.push(root);     visited[root] = true;     while (!Q.empty()) {       u = Q.front();       Q.pop();       for (i = 0; i < adj[u].size(); i++) {         v = adj[u][i];         if (!visited[v]) {           Q.push(v);           visited[v] = true;         } else {           for (j = 0; j < adj[u].size(); j++) {             if (adj[u][j] != v) {               it = lower_bound(adj[v].begin(), adj[v].end(), adj[u][j]);               if (it != adj[v].end() && ((*it) == adj[u][j])) {                 temp = con[u] + con[v] + con[adj[u][j]] - 6;                 if (temp < mn) mn = temp;               }             }           }         }       }     }     return mn;   }   int main() {     int j, t, i, t1, t2, n, m, ans;     t = 1;     while (t--) {       scanf( %d , &n);       scanf( %d , &m);       memset(visited, 0, sizeof(visited));       for (i = 0; i < m; i++) {         scanf( %d%d , &t1, &t2);         adj[t1].push_back(t2);         adj[t2].push_back(t1);       }       for (i = 1; i <= n; i++) {         sort(adj[i].begin(), adj[i].end());       }       for (i = 1; i <= n; i++) {         con[i] = adj[i].size();       }       ans = 10000000;       for (i = 1; i <= n; i++) {         if (!visited[i]) {           t1 = bfs(i);           if (t1 < ans) ans = t1;         }       }       if (ans == 10000000)         printf( -1 n );       else         printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int BIT[100005];   int v[100005], n, i, mayor, lol, cosaMenor = 1000005;   int contMayor, numMenor;   bool record[100005];   int buenos;   void add(int pos) {     while (pos > 0) {       BIT[pos]++;       pos -= pos & (-pos);     }   }   int query(int pos) {     int sum = 0;     while (pos <= n) {       sum += BIT[pos];       pos += pos & (-pos);     }     return sum;   }   int cont[100005];   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &v[i]);     for (i = 1; i <= n; i++) {       if (query(v[i]) == 1)         cont[mayor]++;       else {         if (query(v[i]) > 1) {           cosaMenor = min(cosaMenor, v[i]);         } else {           record[v[i]] = true;           buenos++;         }       }       add(v[i]);       mayor = max(mayor, v[i]);     }     for (i = 1; i <= n; i++) {       if (buenos + cont[i] - (record[i] ? 1 : 0) > contMayor) {         contMayor = buenos + cont[i] - (record[i] ? 1 : 0);         numMenor = i;       } else {         if (buenos + cont[i] - (record[i] ? 1 : 0) == contMayor)           numMenor = min(numMenor, i);       }     }     if (contMayor == 0)       printf( %d , cosaMenor > n ? 1 : cosaMenor);     else       printf( %d , numMenor);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int f[10];     for (int i = 0; i < 10; i++) {       f[i] = 0;     }     for (int i = 0; i < 6; i++) {       int tem;       cin >> tem;       f[tem]++;     }     int leg;     int flag = 0;     for (int i = 0; i < 10; i++) {       if (f[i] >= 4) {         flag = 1;         f[i] = f[i] - 4;         break;       }     }     if (flag == 0) {       cout <<  Alien n ;       return 0;     }     int h = 0, b = 0;     for (int i = 0; i < 10; i++) {       if (f[i] != 0) {         h = i;         f[i] = f[i] - 1;       }     }     for (int i = 0; i < 10; i++) {       if (f[i] != 0) {         b = i;       }     }     if (h == b) {       cout <<  Elephant n ;     } else {       cout <<  Bear n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T sqr(T a) {     return a * a;   };   template <typename T>   void dprint(T begin, T end) {     for (auto i = begin; i != end; i++) cerr << (*i) <<    ;     cerr <<   n ;   };   const int maxn = 500 + 5;   int n, step[maxn * 2];   string ans;   pair<int, int> loc[maxn * 2];   bool query(int r1, int c1, int r2, int c2) {     cout <<  ?   << r1 <<     << c1 <<     << r2 <<     << c2 << endl;     cout.flush();     cin >> ans;     return ans ==  YES ;   }   int main() {     scanf( %d , &n);     loc[0] = pair<int, int>(1, 1);     for (int i = 0; i < n - 1; i++) {       if (query(loc[i].first + 1, loc[i].second, n, n)) {         loc[i + 1] = pair<int, int>(loc[i].first + 1, loc[i].second);         step[i] = 0;         continue;       }       if (query(loc[i].first, loc[i].second + 1, n, n)) {         loc[i + 1] = pair<int, int>(loc[i].first, loc[i].second + 1);         step[i] = 1;         continue;       }     }     loc[2 * n - 2] = pair<int, int>(n, n);     for (int i = 2 * n - 2; i > n; i--) {       if (query(loc[i - n].first, loc[i - n].second, loc[i].first,                 loc[i].second - 1)) {         loc[i - 1] = pair<int, int>(loc[i].first, loc[i].second - 1);         step[i - 1] = 1;         continue;       }       if (query(loc[i - n].first, loc[i - n].second, loc[i].first - 1,                 loc[i].second)) {         loc[i - 1] = pair<int, int>(loc[i].first - 1, loc[i].second);         step[i - 1] = 0;         continue;       }     }     if (loc[n].first == loc[n - 1].first + 1)       step[n - 1] = 0;     else       step[n - 1] = 1;     cout <<  !  ;     for (int i = 0; i < 2 * n - 2; i++)       if (step[i] == 0)         cout <<  D ;       else         cout <<  R ;     cout << endl;     cout.flush();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, t, u, v;     vector<long long> b;     vector<pair<long long, long long> > a;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d%d , &x, &t);       a.push_back(make_pair(x, t));     }     scanf( %d , &v);     a.push_back(make_pair(0, 0));     for (int i = 0; i < a.size(); ++i)       a[i] = make_pair(a[i].first + v * a[i].second,                        -(a[i].first - v * a[i].second));     sort(a.rbegin(), a.rend());     u = v = 0;     for (int i = 0; i < a.size(); ++i) {       x = -a[i].second;       t = upper_bound(b.begin(), b.end(), x) - b.begin();       if (t == b.size())         b.push_back(x);       else         b[t] = x;       if (a[i] == make_pair(0ll, 0ll))         u = max(u, t);       else         v = max(v, t + 1);     }     printf( %d %d n , u, v);     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 1000000;   int N;   long long Ans;   std::vector<int> G[MAXN + 5];   long long Val[MAXN + 5];   int Size[MAXN + 5];   int Fa[MAXN + 5], Dep[MAXN + 5];   void Dfs(int u, int fa, int dep) {     Size[u] = 1;     Fa[u] = fa;     Dep[u] = dep;     for (int i = 0; i < int(G[u].size()); i++) {       int v = G[u][i];       if (v != fa) {         Dfs(v, u, dep + 1);         Size[u] += Size[v];         Val[u] += (long long)Size[v] * Size[v];       }     }     Val[u] += (long long)(N - Size[u]) * (N - Size[u]);     Ans -= Val[u];   }   int Pa[MAXN + 5], Num[MAXN + 5];   int Find(int u) { return Pa[u] == u ? u : Pa[u] = Find(Pa[u]); }   long long In1(int u) {     return (long long)(N - Num[u]) * (N - Num[u]) * Num[u] - Val[u] * Num[u];   }   long long In2(int u) {     return (long long)Num[u] * (Num[u] - 1) * 2 * (N - Num[u]);   }   long long In3(int u) {     return std::max((long long)Num[u] * (Num[u] - 1) * (Num[u] - 2), 0ll);   }   void Merge(int u, int v) {     Ans -= In1(u) + In2(u) + In3(u);     Ans -= In1(v) + In2(v) + In3(v);     Pa[v] = u, Num[u] += Num[v];     Val[u] += Val[v] - (long long)Size[v] * Size[v] -               (long long)(N - Size[v]) * (N - Size[v]);     Ans += In1(u) + In2(u) + In3(u);   }   int main() {     scanf( %d , &N);     for (int i = 1; i < N; i++) {       int u, v;       scanf( %d%d , &u, &v);       G[u].push_back(v), G[v].push_back(u);     }     Ans = (long long)N * (N - 1) * (N - 1);     Dfs(1, 0, 0);     printf( %lld n , Ans);     for (int i = 1; i <= N; i++) Pa[i] = i, Num[i] = 1;     int Q;     scanf( %d , &Q);     while (Q--) {       int u, v;       scanf( %d%d , &u, &v);       u = Find(u), v = Find(v);       while (u != v) {         if (Dep[u] < Dep[v]) std::swap(u, v);         int anc = Find(Fa[u]);         Merge(anc, u), u = anc;       }       printf( %lld n , Ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mo = 998244353;   const double PI = acos(-1.0);   template <typename _T>   _T Fabs(_T x) {     return x < 0 ? -x : x;   }   template <typename _T>   void read(_T &x) {     _T f = 1;     x = 0;     char s = getchar();     while (s >  9  || s <  0 ) {       if (s ==  - ) f = -1;       s = getchar();     }     while ( 0  <= s && s <=  9 ) {       x = (x << 3) + (x << 1) + (s ^ 48);       s = getchar();     }     x *= f;   }   int n, b[400005 * 2], totx, d[400005 * 2], toty, ans;   bool vis[400005];   set<int> st[400005 << 2];   int maxx[400005 << 2], minn[400005 << 2];   struct ming {     int ax, ay, bx, by;   } s[400005];   struct node {     int l, r, val;   };   vector<node> vec[400005];   void updata(int rt, bool fg) {     if (fg)       maxx[rt] = minn[rt] = 0;     else       maxx[rt] = max(maxx[rt << 1], maxx[rt << 1 | 1]),       minn[rt] = min(minn[rt << 1], minn[rt << 1 | 1]);     if (!st[rt].empty()) {       int t = *st[rt].rbegin();       if (vis[t])         minn[rt] = max(minn[rt], t);       else         maxx[rt] = max(maxx[rt], t);     }     if (minn[rt] > maxx[rt]) maxx[rt] = 0;   }   void insert(int rt, int l, int r, int al, int ar, int aw) {     if (al <= l && r <= ar) {       if (aw > 0)         st[rt].insert(aw);       else         st[rt].erase(-aw);       updata(rt, l == r);       return;     }     int mid = l + r >> 1;     if (al <= mid) insert(rt << 1, l, mid, al, ar, aw);     if (ar > mid) insert(rt << 1 | 1, mid + 1, r, al, ar, aw);     updata(rt, 0);   }   signed main() {     read(n);     for (int i = 1; i <= n; i++)       read(s[i].ax), read(s[i].ay), read(s[i].bx), read(s[i].by);     for (int i = 1; i <= n; i++) b[++totx] = s[i].ax, b[++totx] = s[i].bx;     sort(b + 1, b + totx + 1);     totx = unique(b + 1, b + totx + 1) - b - 1;     for (int i = 1; i <= n; i++)       s[i].ax = lower_bound(b + 1, b + totx + 1, s[i].ax) - b,       s[i].bx = lower_bound(b + 1, b + totx + 1, s[i].bx) - b;     for (int i = 1; i <= n; i++) d[++toty] = s[i].ay, d[++toty] = s[i].by;     sort(d + 1, d + toty + 1);     toty = unique(d + 1, d + toty + 1) - d - 1;     for (int i = 1; i <= n; i++)       s[i].ay = lower_bound(d + 1, d + toty + 1, s[i].ay) - d,       s[i].by = lower_bound(d + 1, d + toty + 1, s[i].by) - d - 1;     for (int i = 1; i <= n; i++)       vec[s[i].ax].push_back((node){s[i].ay, s[i].by, i}),           vec[s[i].bx].push_back((node){s[i].ay, s[i].by, -i});     for (int i = 1; i <= totx; i++) {       int siz = vec[i].size();       for (int j = 0; j < siz; j++)         insert(1, 1, toty, vec[i][j].l, vec[i][j].r, vec[i][j].val);       while (maxx[1])         vis[maxx[1]] = 1, insert(1, 1, toty, s[maxx[1]].ay, s[maxx[1]].by, 0),         ans++;     }     printf( %d n , ans + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T abs(T x) {     return x > 0 ? x : -x;   }   int n, m;   int a[1 << 20];   int t[1 << 20];   void upd(int v, int val) {     v += 1 << n;     t[v] = val;     v /= 2;     bool cur = 0;     while (v > 0) {       if (cur == 0)         t[v] = t[2 * v] | t[2 * v + 1];       else         t[v] = t[2 * v] ^ t[2 * v + 1];       v /= 2;       cur ^= 1;     }   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < 1 << n; ++i) scanf( %d , &a[i]);     memset((t), (0), sizeof(t));     bool cur = 1;     for (int h = 1 << n; h > 0; h /= 2) {       for (int v = h; v < 2 * h; ++v)         if (h == 1 << n)           t[v] = a[v - h];         else           t[v] = cur == 0 ? t[2 * v] | t[2 * v + 1] : t[2 * v] ^ t[2 * v + 1];       cur ^= 1;     }     while (m--) {       int p, b;       scanf( %d %d , &p, &b);       upd(p - 1, b);       printf( %d n , t[1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[200];   map<int, int> Map;   int cnt[20];   int main() {     for (int i = 0; i <= 11; i++) Map[1 << i] = i;     int _;     for (scanf( %d , &_); _; _--) {       scanf( %d , &n);       for (int i = 0; i < 12; i++) cnt[i] = 0;       for (int i = 1; i <= n; i++) {         scanf( %d , &a[i]);         if (a[i] > 2048) continue;         cnt[Map[a[i]]]++;       }       for (int i = 0; i <= 10; i++) {         cnt[i + 1] += cnt[i] / 2;       }       if (cnt[11])         puts( YES );       else         puts( NO );     }     return 0;   }