malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int L = 1e5 + 1;   long long sofar[L], out[L];   struct node {     long long l, r, q;   };   long long ans = 0, counter[3000002], k;   bool comp(node x, node y) { return x.r < y.r; }   void add(long long val) {     ans += counter[val ^ k];     counter[val]++;     return;   }   void remove(long long val) {     counter[val]--;     ans -= counter[val ^ k];     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long a, n, m, cur = 0, l, r;     cin >> n >> m >> k;     for (int i = 1; i < n + 1; ++i) {       cin >> a;       sofar[i] ^= sofar[i - 1];       sofar[i] ^= a;     }     std::vector<node> v[n / 316 + 5];     node temp;     for (int i = 0; i < m; ++i) {       cin >> l >> r;       l--, r++;       temp.l = l, temp.r = r, temp.q = i;       v[l / 316].push_back(temp);     }     for (int i = 0; i < n / 316 + 1; ++i) sort(v[i].begin(), v[i].end(), comp);     for (int i = 0; i < n / 316 + 3; ++i) {       l = r = i * 316;       ans = 0;       for (auto &x : v[i]) {         while (r < x.r) {           add(sofar[r]);           ++r;         }         while (l < x.l) {           remove(sofar[l]);           l++;         }         while (l > x.l) {           --l;           add(sofar[l]);         }         out[x.q] = ans;       }       for (int j = l; j < r; ++j) remove(sofar[j]);     }     for (int i = 0; i < m; ++i) cout << out[i] <<   n ;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);   #define endl   n    typedef long long LL;   const int maxn = 2e5 + 5;      int cnt, id, a[maxn], hea[maxn], siz[maxn], dfsid[maxn], sum[maxn];      map<int, int> exist, tol;      struct node{       int v, next;   }edge[maxn << 1];      inline void add(int u, int v){       edge[++cnt].v = v;       edge[cnt].next = hea[u];       hea[u] = cnt;   }      inline void dfs(int u, int fa){       siz[u] = 1;       dfsid[u] = ++id;       int pre = exist[a[u]]++;       for(int k = hea[u]; k; k = edge[k].next){           int v = edge[k].v;           if(v == fa) continue;           int x = exist[a[u]];           dfs(v, u);           siz[u] += siz[v];           if(x != exist[a[u]]){   // 子树内出现了父节点的值，删除子树外所有点               sum[1]++;               sum[dfsid[v]]--;               sum[dfsid[v] + siz[v]]++;           }       }       if(exist[a[u]] - pre != tol[a[u]]){ // 子树外存在父节点的值，删除子树内所有点           sum[dfsid[u]]++;           sum[dfsid[u] + siz[u]]--;       }   }      int main(){       IOS;       int n, u, v;       cin >> n;       for(int i = 1; i <= n; i++){           cin >> a[i];           tol[a[i]]++;       }       for(int i = 1; i < n; i++){           cin >> u >> v;           add(u, v);           add(v, u);       }       dfs(1, 1);       int ans = 0;       for(int i = 1; i <= n; i++){           sum[i] += sum[i - 1];           ans += sum[i] == 0;       }       cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int sq = sqrt(n);     if (n % sq == 0) {       cout << sq <<     << n / sq;     } else {       int i = 0;       while (++i) {         if (n % (sq - i) == 0) {           cout << sq - i <<     << n / (sq - i);           break;         } else if (n % (sq + i) == 0) {           cout << sq + i <<     << n / (sq + i);           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int p = 1e9 + 7;   long long binpow(long long a, long long b, long long mod) {     long long res = 1;     while (b > 0) {       if (b & 1) res = res * a % mod;       a = a * a % mod;       b >>= 1;     }     return res % mod;   }   const int dx[] = {1, -1, 0, 0};   const int dy[] = {0, 0, -1, 1};   const int inf = 1e9;   const int N = 1e5 + 9;   void solve() {     int n;     cin >> n;     vector<int> a(n);     for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));          i += 1 - 2 * ((0) > (n)))       cin >> a[i];     if (n == 1) {       cout << a[0] <<   n ;       return;     }     int dp[n][2];     dp[0][0] = a[0];     dp[0][1] = 1e9;     dp[1][0] = a[0] + a[1];     dp[1][1] = a[0];     for (__typeof(n) i = (2) - ((2) > (n)); i != (n) - ((2) > (n));          i += 1 - 2 * ((2) > (n))) {       dp[i][0] = min(dp[i - 1][1] + a[i], dp[i - 2][1] + a[i] + a[i - 1]);       dp[i][1] = min(dp[i - 1][0], dp[i - 2][0]);     }     cout << min(dp[n - 1][1], dp[n - 1][0]) <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 0x3f3f3f3f3f3f3f3f;   struct port {     int id;     int x, y;   };   void solve() {     int n, m, sx, sy, dx, dy;     cin >> n >> m >> sx >> sy >> dx >> dy;     vector<port> p;     for (int i = 0, x, y; i < m; ++i) {       cin >> x >> y;       p.push_back({i + 1, x, y});     }     vector<array<int, 2>> adj[m + 3];     for (auto &i : p) {       int wt = min(abs(i.x - sx), abs(i.y - sy));       adj[m + 1].push_back({i.id, wt});       adj[i.id].push_back({m + 1, wt});     }     for (auto &i : p) {       int wt = abs(i.x - dx) + abs(i.y - dy);       adj[m + 2].push_back({i.id, wt});       adj[i.id].push_back({m + 2, wt});     }     sort(begin(p), end(p), [&](port a, port b) { return a.x < b.x; });     for (int i = 1; i < m; ++i) {       int j = i - 1, wt = abs(p[i].x - p[j].x);       adj[p[i].id].push_back({p[j].id, wt});       adj[p[j].id].push_back({p[i].id, wt});     }     sort(begin(p), end(p), [&](port a, port b) { return a.y < b.y; });     for (int i = 1; i < m; ++i) {       int j = i - 1, wt = abs(p[i].y - p[j].y);       adj[p[i].id].push_back({p[j].id, wt});       adj[p[j].id].push_back({p[i].id, wt});     }     int wt = abs(dx - sx) + abs(dy - sy);     adj[m + 1].push_back({m + 2, wt});     adj[m + 2].push_back({m + 1, wt});     auto dijkstra = [&](int src, int des) {       vector<long long> dist(m + 3, inf);       priority_queue<array<long long, 2>, vector<array<long long, 2>>,                      greater<array<long long, 2>>>           pq;       dist[src] = 0;       pq.push({0, src});       while (!pq.empty()) {         long long curdist = pq.top()[0];         long long curnode = pq.top()[1];         pq.pop();         if (curdist > dist[curnode]) continue;         for (auto &[v, w] : adj[curnode]) {           if (dist[curnode] + w < dist[v]) {             dist[v] = dist[curnode] + w;             pq.push({dist[v], v});           }         }       }       return dist[des];     };     cout << dijkstra(m + 1, m + 2);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int tc;     tc = 1;     while (tc--) solve();   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  Yes  :  No );     exit(0);   }   void addmod(int &x, int y, int mod = 1000000007) {     assert(y >= 0);     x += y;     if (x >= mod) x -= mod;     assert(x >= 0 && x < mod);   }   void et() {     puts( -1 );     exit(0);   }   long long fastPow(long long x, long long y, int mod = 1000000007) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long gcd1(long long x, long long y) {     long long z = y;     while (x % y != 0) {       z = x % y;       x = y;       y = z;     }     return z;   }   int fac[105], inv[105];   void initfac(int n) {     fac[0] = inv[0] = 1;     for (int(i) = 1; (i) <= (int)(n); (i)++) {       fac[i] = (long long)fac[i - 1] * i % 1000000007;       inv[i] = fastPow(fac[i], 1000000007 - 2);     }   }   int C(int n, int m) {     if (n < m) return 0;     return (long long)fac[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;   }   int d[105];   long long dp[55][55][55], ways[55][55][55];   long long wk(int a, int b, int c) {     if (a < 0 || b < 0) return 0;     if (dp[a][b][c] != -1) return dp[a][b][c];     int ans = 0;     if (c) {       ans = (wk(a - 1, b, c - 1) * a + wk(a + 1, b - 1, c - 1) * b) % 1000000007;     } else if (a) {       ans = (wk(a - 2, b, 0) * (a - 1) + wk(a, b - 1, 0) * b) % 1000000007;     } else if (b > 2) {       for (long long z = 3, x = (b - 1) * (b - 2) / 2; z <= b;            x = x * (b - z++) % 1000000007) {         ans += x * wk(0, b - z, 0) % 1000000007;         ans %= 1000000007;       }     } else       ans = (b == 0);     return dp[a][b][c] = ans;     ;   }   int mdp[55][55];   int cal(int l, int r) {     if (mdp[l][r] != -1) return mdp[l][r];     if (r > n) return 0;     int ans = 0, c2 = 0, c3 = 0;     for (int i = l; i <= r; i++)       if (d[i] == 2)         c2++;       else         c3++;     if (r == n)       ans = wk(c2, c3, 0) % 1000000007;     else {       for (int x = 1; x <= n - r; x++) {         addmod(ans, wk(c2, c3, x) * cal(r + 1, r + x) % 1000000007);       }     }     return mdp[l][r] = ans;   }   void fmain(int tid) {     scanf( %d , &n);     for (int(i) = 1; (i) <= (int)(n); (i)++) scanf( %d , d + i);     initfac(55);     ways[0][0][0] = 1;     memset(dp, -1, sizeof dp);     memset(mdp, -1, sizeof mdp);     int ans = d[1] == 2 ? cal(2, 3) : cal(2, 4);     printf( %d n , ans);   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[5002][5002][2];   vector<vector<int> > adj(12345);   int subtree[5004], c[5003], d[5003], dp1[5003], dp2[5003];   int dfs(int u) {     int i, j, k, sumi = 1;     subtree[u] = 1;     for (i = 0; i < adj[u].size(); i++) {       dfs(adj[u][i]);       subtree[u] += subtree[adj[u][i]];     }     if (subtree[u] == 1) {       dp[u][1][0] = c[u];       dp[u][1][1] = c[u] - d[u];       dp[u][0][1] = 0;       dp[u][0][0] = 0;       return 0;     }     for (i = 0; i < subtree[u] + 2; i++) {       dp1[i] = (1000 * 1000 * 1000 + 5);       dp2[i] = (1000 * 1000 * 1000 + 5);       dp[u][i][0] = (1000 * 1000 * 1000 + 5);       dp[u][i][1] = (1000 * 1000 * 1000 + 5);     }     dp[u][1][1] = c[u] - d[u];     sumi = 1;     for (i = 0; i < adj[u].size(); i++) {       for (j = 0; j < sumi + 1; j++) {         for (k = 0; k < subtree[adj[u][i]] + 1; k++) {           dp1[j + k] = min(dp1[j + k], dp[u][j][1] + dp[adj[u][i]][k][1]);           dp1[j + k] = min(dp1[j + k], (1000 * 1000 * 1000 + 5));         }       }       sumi += subtree[adj[u][i]];       for (j = 0; j < sumi + 1; j++) {         dp[u][j][1] = min(dp[u][j][1], dp1[j]);         dp1[j] = (1000 * 1000 * 1000 + 5);       }     }     sumi = 1;     dp1[0] = 0;     for (i = 0; i < adj[u].size(); i++) {       for (j = 0; j < sumi + 1; j++) {         for (k = 0; k < subtree[adj[u][i]] + 1; k++) {           dp2[j + k] = min(dp2[j + k], dp1[j] + dp[adj[u][i]][k][0]);           dp2[j + k] = min(dp2[j + k], (1000 * 1000 * 1000 + 5));         }       }       sumi += subtree[adj[u][i]];       for (j = 0; j < sumi + 1; j++) {         dp1[j] = min(dp1[j], dp2[j]);         dp2[j] = (1000 * 1000 * 1000 + 5);       }     }     for (i = 0; i < subtree[u] + 1; i++) {       dp[u][i][1] = min(dp[u][i][1], dp1[i]);       dp1[i] = (1000 * 1000 * 1000 + 5);     }     dp[u][1][0] = c[u];     dp[u][0][0] = 0;     sumi = 1;     for (i = 0; i < adj[u].size(); i++) {       for (j = 0; j < sumi + 1; j++) {         for (k = 0; k < subtree[adj[u][i]] + 1; k++) {           dp1[j + k] = min(dp1[j + k], dp[u][j][0] + dp[adj[u][i]][k][0]);           dp1[j + k] = min(dp1[j + k], (1000 * 1000 * 1000 + 5));         }       }       sumi += subtree[adj[u][i]];       for (j = 0; j < sumi + 1; j++) {         dp[u][j][0] = min(dp[u][j][0], dp1[j]);         dp1[j] = (1000 * 1000 * 1000 + 5);       }     }     return 0;   }   int main() {     std::ios::sync_with_stdio(false);     int n, val;     int i, u;     cin >> n >> val;     cin >> c[0] >> d[0];     for (i = 1; i < n; i++) {       cin >> c[i] >> d[i];       cin >> u;       u--;       adj[u].push_back(i);     }     dfs(0);     for (i = n; i >= 0; i--) {       if (dp[0][i][1] <= val) {         cout << i << endl;         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   bool s[100005];   int main() {     int n;     cin >> n;     n *= 2;     int ans = 0, rst = 0;     ;     while (n--) {       int tmp;       cin >> tmp;       if (s[tmp])         ans -= 1;       else         s[tmp] = 1, ans++;       rst = max(rst, ans);     }     cout << rst << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     vector<bool> vt(100005);     vector<int> side(100005, 0b111);     set<int> G[100005];     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       G[a].insert(b);       G[b].insert(a);     }     bool first = true;     int g2 = 0;     for (int i = 1; i <= n; i++) {       if (G[1].find(i) != G[1].end()) {         if (first) {           g2 = i;           first = false;         }         side[i] &= 0b110;       } else {         side[i] &= 0b001;       }     }     for (int i = 1; i <= n; i++) {       if (G[g2].find(i) != G[g2].end()) {         side[i] &= 0b101;       } else {         side[i] &= 0b010;       }     }     for (int i = 1; i <= n; i++) {       if (side[i] != 1 && side[i] != 2 && side[i] != 4) {         puts( -1 );         return 0;       }     }     int ct1 = 0, ct2 = 0, ct3 = 0;     for (int i = 1; i <= n; i++) {       switch (side[i]) {         case 1:           ct1++;           break;         case 2:           ct2++;           break;         case 4:           ct3++;           break;       }       for (auto e : G[i])         if (side[i] == side[e]) {           puts( -1 );           return 0;         }     }     if (m != ct1 * ct2 + ct2 * ct3 + ct3 * ct1 || !ct1 || !ct2 || !ct3) {       puts( -1 );       return 0;     }     for (int i = 1; i <= n; i++) {       switch (side[i]) {         case 1:           printf( %d  , 1);           break;         case 2:           printf( %d  , 2);           break;         case 4:           printf( %d  , 3);           break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline int size(const T& c) {     return c.size();   }   using namespace std;   const int maxn = 100000 + 10;   struct student {     int a;     int b;     int cs;   } a[maxn];   int n, p, k, k2;   long long f[maxn];   long long sumgrey, sumplease, resgrey, resplease;   struct cmp {     bool operator()(int u, int v) {       return make_pair(make_pair(a[u].a, a[u].b), u) <              make_pair(make_pair(a[v].a, a[v].b), v);     }   };   set<int, cmp> s;   int vt;   bool mycmp1(student a, student b) {     if (a.b == b.b) {       return a.a < b.a;     }     return a.b < b.b;   }   bool mycmp2(student a, student b) {     if (a.b == b.b) {       return a.a > b.a;     }     return a.b < b.b;   }   void update(int sep) {     if (resgrey < sumgrey || (resgrey == sumgrey && resplease < sumplease)) {       resgrey = sumgrey;       resplease = sumplease;       vt = sep;     }   }   void process() {     for (int i = (1), _b = (n); i <= _b; i++) f[i] = f[i - 1] + a[i].b;     s.clear();     for (int i = (n), _a = (n - k + 1); i >= _a; i--) {       s.insert(i);       sumgrey += a[i].a;       sumplease = f[i - 1] - f[i - k2 - 1];     }     update(n - k + 1);     for (int i = (n - k), _a = (k2 + 1); i >= _a; i--) {       int u = *s.begin();       sumplease = f[i - 1] - f[i - k2 - 1];       if (a[i].a > a[u].a || (a[i].a == a[u].a && a[i].b > a[u].b)) {         s.erase(u);         sumgrey -= a[u].a;         s.insert(i);         sumgrey += a[i].a;       }       update(i);     }   }   void trace() {     s.clear();     for (int i = (n), _a = (n - k + 1); i >= _a; i--) s.insert(i);     for (int i = (n - k), _a = (vt); i >= _a; i--) {       int u = *s.begin();       if (a[i].a > a[u].a || (a[i].a == a[u].a && a[i].b > a[u].b)) {         s.erase(u);         s.insert(i);       }     }     set<int, cmp>::iterator it;     for (__typeof((s).begin()) it = (s).begin(); it != (s).end(); it++)       cout << a[*it].cs <<    ;     for (int i = (vt - k2), _b = (vt - 1); i <= _b; i++) cout << a[i].cs <<    ;   }   int main() {     cin >> n >> p >> k;     for (int i = (1), _b = (n); i <= _b; i++)       cin >> a[i].a >> a[i].b, a[i].cs = i;     k2 = p - k;     sort(a + 1, a + 1 + n, mycmp2);     process();     trace();     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   long long gcd(long long a, long long b) {     while (b > 0) {       long long p = a % b;       a = b;       b = p;     }     return a;   }   long long bexp(long long a, int b) {     long long res = 1;     while (b > 0) {       if (b & 1) res = res * a;       a = a * a;       b >>= 1;     }     return res;   }   long long bexpM(long long a, int b) {     long long res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % M;       a = (a * a) % M;       b >>= 1;     }     return res;   }   long long nCk(int n, int k) {     long long res = 1;     for (int i = k + 1; i < n + 1; i++) res = res * i;     long long p = 1;     for (int i = 2; i < n - k + 1; i++) p = p * i;     res = res / p;     return res;   }   long long nCkM(int n, int k) {     long long res = 1;     for (int i = k + 1; i < n + 1; i++) res = (res * i) % M;     long long p = 1;     for (int i = 2; i < n - k + 1; i++) p = (p * i) % M;     res = (res * bexpM(p, M - 2)) % M;     return res;   }   const int N = 2e5;   long long st[N][18];   long long q(int l, int s, int n) {     int i = 0;     while ((1 << (i + 1)) < s) i++;     return gcd(st[l][i], st[l - (1 << i) + s][i]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int u;     cin >> u;     for (int g = 0; g < u; g++) {       int n;       cin >> n;       long long a[n];       for (int i = 0; i < n; i++) {         cin >> a[i];       }       n--;       for (int i = 0; i < n; i++) {         st[i][0] = abs(a[i + 1] - a[i]);       }       for (int i = 1; i < log2(n); i++) {         for (int j = 0; j < n - (1 << (i - 1)); j++) {           st[j][i] = gcd(st[j][i - 1], st[j + (1 << (i - 1))][i - 1]);         }       }       int l = 1;       int r = n;       while (l < r) {         int m = (l + r + 1) / 2;         long long b[n - m + 1];         for (int i = 0; i < n - m + 1; i++) {           b[i] = q(i, m, n);         }         bool bo = 1;         for (int i = 0; i < n - m + 1; i++) {           if (b[i] != 1) bo = 0;         }         if (bo)           r = m - 1;         else           l = m;       }       bool bo = 1;       for (int i = 0; i < n; i++) {         if (st[i][0] > 1) bo = 0;       }       if (bo)         cout <<  1 n ;       else         cout << l + 1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1.1e5;   queue<int> Q[2];   vector<int> E[maxn];   int n, m, cnt, in[maxn], f[maxn];   signed main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) scanf( %d , f + i);     for (int i = 1, x, y; i <= m; ++i)       scanf( %d%d , &x, &y), ++in[x], E[y].push_back(x);     for (int i = 0; i < n; ++i)       if (!in[i]) Q[f[i]].push(i);     while (!(Q[1].empty() && Q[0].empty())) {       while (!Q[0].empty()) {         int u = Q[0].front();         Q[0].pop();         for (auto v : E[u])           if (!--in[v]) Q[f[v]].push(v);       }       if (!Q[1].empty()) ++cnt;       while (!Q[1].empty()) {         int u = Q[1].front();         Q[1].pop();         for (auto v : E[u])           if (!--in[v]) Q[f[v]].push(v);       }     }     printf( %d , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Seller {     long long first, second, diff;   } a[200005];   bool cmp(Seller p, Seller q) { return (p.diff > q.diff); }   int main() {     long long n, m, i, j, ans = 0;     cin >> n >> m;     for (i = 0; i < n; i++) cin >> a[i].first;     for (i = 0; i < n; i++) cin >> a[i].second;     for (i = 0; i < n; i++) {       a[i].diff = (a[i].second - a[i].first);     }     sort(a, a + n, cmp);     for (i = 0; i < m; i++) ans += a[i].first;     for (i = m; i < n; i++) ans += min(a[i].first, a[i].second);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, c, d;     scanf( %d %d %d %d %d , &n, &a, &b, &c, &d);     long long ans = 0;     for (int i = 1; i <= n; i++) {       int sum = a + b + i;       if (sum - a - c <= 0 || sum - a - c > n) continue;       if (sum - b - d <= 0 || sum - b - d > n) continue;       if (sum - c - d <= 0 || sum - c - d > n) continue;       ans++;     }     ans *= n;     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, uz[1005], kay;   char ar[1005][1005], k[1005];   int kontrol(int a, int say) {     for (int i = 1; i <= uz[a] - say + 1; i++) {       if (ar[a][i] == k[1]) {         int m = 1, j, k1;         for (j = i + 1, k1 = 2; j <= uz[a] && k1 <= say && m; j++, k1++)           if (ar[a][j] != k[k1]) m = 0;         if (m) {           return 0;         }       }     }     return 1;   }   int maxs = 0;   void oku() {     cin >> N;     for (int i = 1; i <= N; i++) {       scanf(  %s , ar[i] + 1);       uz[i] = strlen(ar[i] + 1);       maxs = max(maxs, uz[i]);     }     int o = 1, l;     k[o] =  a ;     k[o]--;     while (o <= maxs) {       l = 1;       if (k[o] !=  z )         k[o]++;       else {         int p1 = o;         while (p1) {           if (k[p1] !=  z ) {             k[p1]++;             break;           } else             p1--;         }         if (!p1) {           memset(k, 0, sizeof(k));           o++;           for (int i = 1; i <= o; i++) k[i] =  a ;         } else {           p1++;           while (p1 <= o) {             k[p1] =  a ;             p1++;           }         }       }       l = 1;       for (int i = 1; i <= N && l; i++) l = kontrol(i, o);       if (l) {         printf( %s n , k + 1);         return;       }     }   }   int main() {     oku();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char ch[100001];   int N, n, m;   long long a[1 << 20], b[1 << 20];   int g[21][100001];   void FWT(long long p[], int flag) {     int temp = N;     for (int i = 2; i <= temp; i *= 2) {       int t = i / 2;       for (int j = 0; j < temp; j += i) {         for (int k = j; k < j + t; k++) {           long long x = p[k];           long long y = p[k + t];           p[k] = x + y;           p[k + t] = x - y;           if (flag == -1) {             p[k] /= 2;             p[k + t] /= 2;           }         }       }     }   }   int main() {     cin >> n >> m;     N = 1 << n;     for (int i = 1; i <= n; i++) {       scanf( %s , ch + 1);       for (int j = 1; j <= m; j++) {         g[i][j] = ch[j] -  0 ;       }     }     for (int i = 1; i <= m; i++) {       int x = 0;       for (int j = 1; j <= n; j++) {         x = (x * 2) | g[j][i];       }       a[x]++;     }     for (int i = 0; i < N; ++i) b[i] = b[i >> 1] + (i & 1);     for (int i = 0; i < N; ++i) b[i] = min(b[i], n - b[i]);     FWT(a, 1);     FWT(b, 1);     for (int i = 0; i < N; ++i) a[i] *= b[i];     FWT(a, -1);     long long ans = n * m;     for (int i = 0; i < N; ++i) ans = min(ans, a[i]);     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<pair<long long int, long long int> > v;     long long int n, x, c = 0;     cin >> n;     for (int i = 0; i < n; i++) {       long long int a, b;       cin >> a >> b;       v.push_back(make_pair(a, b));     }     sort(v.begin(), v.end());     long long int i = 0;     x = v[0].second;     while (i < n) {       if (v[i].first <= x) i++;       if (v[i].second < x) x = v[i].second;       if (v[i].first > x || i >= n) {         c++;         x = v[i].second;       }     }     cout << c;   }