malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include<bits/stdc++.h>   using namespace std;      namespace program {    const int N = 100005;        struct edge {     int to, nxt;     edge() {}     edge(int to_, int nxt_): to(to_), nxt(nxt_) {}    } e[N << 1];    int hd[N], cnt, fir[N], end[N];    vector<pair<int, int> > del, ins;        void adde(int u, int v) {     e[++cnt] = edge(v, hd[u]); hd[u] = cnt;     e[++cnt] = edge(u, hd[v]); hd[v] = cnt;    }    bool dfs(int u, int fa) {     vector<int> son1, son2;     for(int i = hd[u]; i; i = e[i].nxt) {      int v = e[i].to;      if(v == fa) continue;      if(dfs(v, u)) {       son1.push_back(v);      }      else {       son2.push_back(v);      }     }     if(!son1.size()) {      end[u] = u;     }     else if(son1.size() == 1) {      end[u] = end[son1[0]];     }     else {      end[u] = end[son1[0]];      fir[u] = end[son1[1]];      if(fa) del.push_back(make_pair(fa, u));      for(int i = 2; i < son1.size(); ++i) {       del.push_back(make_pair(u, son1[i]));       ins.push_back(make_pair(end[u], son1[i]));       end[u] = end[son1[i]];      }     }     for(int i = 0; i < son2.size(); ++i) {      ins.push_back(make_pair(end[u], fir[son2[i]]));      end[u] = end[son2[i]];     }     return son1.size() <= 1;    }    int main() {     int T;     scanf( %d , &T);     while(T--) {      int n;      scanf( %d , &n);      cnt = 0;      memset(hd + 1, 0, sizeof(int) * n);      for(int i = 1; i < n; ++i) {       int u, v;       scanf( %d%d , &u, &v);       adde(u, v);      }      del.clear();      ins.clear();      dfs(1, 0);      printf( %d n , del.size());      for(int i = 0; i < del.size(); ++i) {       printf( %d %d %d %d n , del[i].first, del[i].second, ins[i].first, ins[i].second);      }     }     return 0;    }   }   int main() {    return program::main();   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 10;   double power(double x, int n) {     if (n <= 1) return n ? x : 1;     double t = power(x, n / 2);     if (n % 2)       return t * t * x;     else       return t * t;   }   double p[maxn];   int main() {     int m, n;     scanf( %d%d , &m, &n);     for (int i = 1; i <= m; i++) p[i] = power(i * 1.0 / m, n);     for (int i = m; i >= 1; i--) p[i] -= p[i - 1];     double ans = 0;     for (int i = 1; i <= m; i++) ans += i * p[i];     printf( %.15f n , ans);   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> dir[4];   int ans = 0;   int n, m;   char maz[55][55];   char op[105];   void bfs() {     int x, y;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (maz[i][j] ==  S ) {           x = i, y = j;         }       }     }     for (int i = 0; op[i]; ++i) {       int t = op[i] -  0 ;       x += dir[t].first;       y += dir[t].second;       if (x < 1 || y < 1 || x > n || y > m || maz[x][y] ==  # ) return;       if (maz[x][y] ==  E ) {         ans++;         return;       }     }   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       scanf( %s , maz[i] + 1);     }     scanf( %s , op);     dir[0] = pair<int, int>(0, 1);     dir[1] = pair<int, int>(0, -1);     dir[2] = pair<int, int>(1, 0);     dir[3] = pair<int, int>(-1, 0);     sort(dir, dir + 4);     do {       bfs();     } while (next_permutation(dir, dir + 4));     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = acos(-1);   const int n_ = 1e5 + 5;   int n;   long long a[n_], b[n_], dp[n_];   vector<int> st;   vector<long double> p;   long double getIntersect(int i, int j) {     return (dp[j] - dp[i]) / (long double)(b[i] - b[j]);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %lld , a + i);     for (int i = 0; i < n; i++) scanf( %lld , b + i);     dp[0] = b[0];     st.push_back(0);     p.push_back(2e9);     int id;     for (int i = 1; i < n; i++) {       id = lower_bound(p.begin(), p.end(), (long double)a[i] - 1) - p.begin();       dp[i] = dp[st[id]] + b[st[id]] * (a[i] - 1) + b[i];       while (st.size() > 1 && getIntersect(st[st.size() - 2], st.back()) >                                   getIntersect(st.back(), i)) {         st.pop_back();         p.pop_back();       }       p.back() = getIntersect(st.back(), i);       p.push_back(2e9);       st.push_back(i);     }     printf( %lld , dp[n - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n, m, flag = 0;     cin >> n >> m;     long long int a[n][m], b[n][m];     for (long long int(i) = 0; (i) < (n); ++(i)) {       for (long long int(j) = 0; (j) < (m); ++(j)) {         cin >> a[i][j];       }     }     for (long long int(i) = 0; (i) < (n); ++(i)) {       for (long long int(j) = 0; (j) < (m); ++(j)) {         cin >> b[i][j];       }     }     for (long long int(i) = 0; (i) < (n); ++(i)) {       for (long long int(j) = 0; (j) < (m); ++(j)) {         if (a[i][j] > b[i][j]) swap(a[i][j], b[i][j]);       }     }     for (long long int(i) = 0; (i) < (n); ++(i)) {       for (long long int(j) = 0; (j) < (m - 1); ++(j)) {         if (a[i][j] >= a[i][j + 1]) {           flag = 1;         }       }     }     for (long long int(j) = 0; (j) < (m); ++(j)) {       for (long long int(i) = 0; (i) < (n - 1); ++(i)) {         if (a[i][j] >= a[i + 1][j]) {           flag = 1;         }       }     }     for (long long int(i) = 0; (i) < (n); ++(i)) {       for (long long int(j) = 0; (j) < (m - 1); ++(j)) {         if (b[i][j] >= b[i][j + 1]) {           flag = 1;         }       }     }     for (long long int(j) = 0; (j) < (m); ++(j)) {       for (long long int(i) = 0; (i) < (n - 1); ++(i)) {         if (b[i][j] >= b[i + 1][j]) {           flag = 1;         }       }     }     if (flag == 0)       cout <<  Possible ;     else       cout <<  Impossible ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[100500];   char c[200100];   int l[100100][26], r[100100][26];   int last[26];   int main() {     long long res;     int tmp;     int n, k, ll, l1, i, j;     cin >> n >> k;     scanf( %s , s);     ll = strlen(s);     memset(last, -1, sizeof(last));     for (i = 0; i < ll; i++) {       last[s[i] -  a ] = i;       for (j = 0; j < 26; j++) l[i][j] = last[j];     }     memset(last, -1, sizeof(last));     for (i = ll - 1; i >= 0; i--) {       last[s[i] -  a ] = i;       for (j = 0; j < 26; j++) r[i][j] = last[j];     }     for (int cnt = 0; cnt < n; cnt++) {       scanf( %s , c);       l1 = strlen(c);       res = 0;       for (j = 0; j < l1; j++) {         tmp = 100500;         if (l[min(j, ll - 1)][c[j] -  a ] != -1)           tmp = abs(j - l[min(j, ll - 1)][c[j] -  a ]);         if (r[min(j, ll - 1)][c[j] -  a ] != -1)           tmp = min(tmp, abs(r[min(j, ll - 1)][c[j] -  a ] - j));         if (tmp == 100500) tmp = l1;         res += tmp;       }       cout << res << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2020;   int Arr[N][N];   int Pre[N][N];   int Add[N][N];   bool Col[N];   bool Row[N];   int getSum(int x1, int y1, int x2, int y2) {     return Pre[x2][y2] - Pre[x1 - 1][y2] - Pre[x2][y1 - 1] + Pre[x1 - 1][y1 - 1];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int k;     cin >> k;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         char ch;         cin >> ch;         Arr[i][j] = (ch ==  B );       }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         Pre[i][j] = Pre[i - 1][j] + Pre[i][j - 1] - Pre[i - 1][j - 1] + Arr[i][j];     int Total = 0;     for (int i = 1; i <= n; i++) {       if (!getSum(i, 1, i, n)) Row[i] = true, Total++;       if (!getSum(1, i, n, i)) Col[i] = true, Total++;     }     for (int x = 1; x + k - 1 <= n; x++) {       int Cur = Total;       for (int i = 1; i < k; i++)         if (!Col[i])           Cur += (getSum(1, i, n, i) - getSum(x, i, x + k - 1, i) == 0);       for (int y = 1; y + k - 1 <= n; y++) {         if (!Col[y + k - 1])           Cur += (getSum(1, y + k - 1, n, y + k - 1) -                       getSum(x, y + k - 1, x + k - 1, y + k - 1) ==                   0);         Add[x][y] += Cur;         if (!Col[y])           Cur -= (getSum(1, y, n, y) - getSum(x, y, x + k - 1, y) == 0);       }     }     for (int x = 1; x + k - 1 <= n; x++) {       int Cur = 0;       for (int i = 1; i < k; i++)         if (!Row[i])           Cur += (getSum(i, 1, i, n) - getSum(i, x, i, x + k - 1) == 0);       for (int y = 1; y + k - 1 <= n; y++) {         if (!Row[y + k - 1])           Cur += (getSum(y + k - 1, 1, y + k - 1, n) -                       getSum(y + k - 1, x, y + k - 1, x + k - 1) ==                   0);         Add[y][x] += Cur;         if (!Row[y])           Cur -= (getSum(y, 1, y, n) - getSum(y, x, y, x + k - 1) == 0);       }     }     int Ans = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) Ans = max(Ans, Add[i][j]);     cout << Ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int X = 100;   char s[X][1000], a[15];   int main() {     int i = 0, j = 0, c = 0, x;     memset(s,  . , sizeof(s));     for (x = 0; x < X; x++) s[x][999] = 0;     scanf( %s , a);     for (x = 0; a[x]; x++) {       for (;;) {         if (c == a[x]) {           s[++i][0] =  X , j = 0;           break;         } else if (j)           s[i][j] =  X , j += 2, c = (c + 255) % 256;         else           i += 2, s[i][j] =  X , j += 2, c = (c + 255) % 256;       }     }     for (x = 0; x < X; x++) puts(s[x]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin.clear();     fflush(stdin);     int n;     cin >> n;     while (n--) {       string s;       cin >> s;       int year = stoi(s.substr(4, s.size() - 4)), p = 1, x = 1989;       for (int i = 0; i < s.size() - 5; i++) {         p *= 10;         x += p;       }       p *= 10;       while (year < x) {         year += p;       }       cout << year << endl;     }     return 0;   }
#include <bits/stdc++.h>   char s[1000010];   int max_pos_by_allowed_and_len[1 << 20][21];   constexpr int full = (1 << 20) - 1;   template <typename T>   void mx(T& x, T y) {     x = (x > y ? x : y);   }   void update(const int* __restrict__ a, int* __restrict__ b) {     for (int i = 0; i < 21; i += 7) {       mx(b[i + 0], a[i + 0]);       mx(b[i + 1], a[i + 1]);       mx(b[i + 2], a[i + 2]);       mx(b[i + 3], a[i + 3]);       mx(b[i + 4], a[i + 4]);       mx(b[i + 5], a[i + 5]);       mx(b[i + 6], a[i + 6]);     }   }   int main() {     scanf( %s , s);     int n = strlen(s);     for (int i = 0; i < n; ++i) s[i] -=  a ;     for (int i = 1; i <= n; ++i) {       int used = 0;       for (int j = i; j > 0; --j) {         if ((used >> s[j - 1]) & 1) break;         used |= (1 << s[j - 1]);         max_pos_by_allowed_and_len[full ^ used][i - j + 1] = i;       }     }     for (int mask = full; mask > 0; --mask) {       for (int bit = 0; bit < 20; ++bit) {         int updated = mask ^ (1 << bit);         if (updated > mask) continue;         update(&max_pos_by_allowed_and_len[mask][0],                &max_pos_by_allowed_and_len[updated][0]);       }     }     int ans = 1;     for (int i = 1; i <= n; ++i) {       int used = 0;       for (int j = i; j > 0; --j) {         if ((used >> s[j - 1]) & 1) break;         used |= (1 << s[j - 1]);         for (int other_len = 20; other_len >= 0; --other_len) {           if (max_pos_by_allowed_and_len[used][other_len] > i) {             mx(ans, i - j + 1 + other_len);             break;           }         }       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x1 = 0, y1 = 0, x2 = 0, y2 = 0;     int n = 0;     cin >> x1 >> y1 >> x2 >> y2 >> n;     int count = 0;     for (int i = 0; i < n; ++i) {       int a = 0, b = 0, c = 0;       cin >> a >> b >> c;       int d1 = (a * 1LL * x1 + b * 1LL * y1 + c < 0 ? -1 : 1);       int d2 = (a * 1LL * x2 + b * 1LL * y2 + c < 0 ? -1 : 1);       if ((d1 * 1LL * d2) < 0) ++count;     }     cout << count;     return 0;   }
#include <bits/stdc++.h>      using namespace std;      #define fr first   #define sc second   #define pb push_back      const int INF = 1e9 + 1;   const int mod = 1e9+9;   const int base = 1e9;      int main() {       //freopen( input.txt ,  r , stdin);       ios_base::sync_with_stdio(false);       cin.tie(0); cout.tie(0);       int t;       cin>>t;       while(t--) {           int n, m;           cin>>n>>m;           vector<int> k(n), c(m);           for(int i = 0; i < n; i++) {               cin>>k[i];           }           sort(k.rbegin(), k.rend());           for(int i = 0; i < m; i++) {               cin>>c[i];           }           int64_t ans = 0;           int i = 0;           for(auto p : k) {               if(i < p) {                   ans += c[i];                   i++;               } else {                   ans += c[p-1];               }           }           cout<<ans<<  n ;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, K;   bool good[1050];   int main() {     scanf( %d , &N);     for (int i = 2; i <= N; i++) {       bool isp = true;       for (int j = 2; j < i; j++)         if (i % j == 0) {           isp = false;           int x = i;           while (x % j == 0) x /= j;           if (x == 1) good[i] = true;           break;         }       if (isp) good[i] = true;       if (good[i]) ++K;     }     printf( %d n , K);     for (int i = 2; i <= N; i++)       if (good[i]) printf( %d  , i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long a, b;     cin >> a >> b;     if ((a + b) % 3 != 0) {       cout <<  NO  << endl;       return;     }     long long mi = min(a, b);     long long mx = max(a, b);     long long d = mx - mi;     if (mx > 2 * mi) {       cout <<  NO  << endl;     } else {       cout <<  YES  << endl;     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   string t[100000];   char mm[100000];   int check[26];   int ans() {     int m = 0, c = 0;     for (int i = 0; i < 26; ++i) m = max(m, check[i]);     for (int i = 0; i < 26; ++i) {       if (check[i] == m) ++c;       if (c > 1) return 0;     }     return 1;   }   int main() {     int n, shock = 0, c = 0;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> mm[i] >> t[i];       if (mm[i] ==  !  or mm[i] ==  ? ) ++shock;     }     for (int i = 0; i < n - 1; ++i) {       if (mm[i] ==  . ) {         for (int j = 0; j < t[i].size(); ++j) check[t[i][j] -  a ] = -1;       }       if (mm[i] ==  ! ) {         ++c;         set<char> s;         for (int j = 0; j < t[i].size(); ++j) {           if (check[t[i][j] -  a ] != -1) {             if (s.find(t[i][j] -  a ) == s.end()) {               s.insert(t[i][j] -  a );               ++check[t[i][j] -  a ];             }           }         }       }       if (mm[i] ==  ? ) {         ++c;         check[t[i][0] -  a ] = -1;       }       if (ans()) {         cout << shock - c - 1;         return 0;       }     }     cout <<  0 ;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1E7;   int a[2][200], u, v, c[200], n;   bool check() {     for (int i = 0; i <= n; i++)       if (c[i] > 1 || c[i] < -1) return 0;     return 1;   }   void dfs(int x) {     if (x > n) {       cout << n << endl;       for (int i = 0; i <= n; i++) printf( %d  , a[u][i]);       printf(  n%d n , n - 1);       for (int i = 0; i < n; i++) printf( %d  , a[v][i]);       return;     }     for (int i = 1; i <= x; i++) c[i] = a[u][i - 1];     c[0] = 0;     for (int i = 0; i < x; i++) c[i] += a[v][i];     if (!check()) {       for (int i = 1; i <= x; i++) c[i] = a[u][i - 1];       c[0] = 0;       for (int i = 0; i < x; i++) c[i] -= a[v][i];     }     for (int i = 0; i <= x; i++) a[v][i] = c[i];     swap(u, v);     dfs(x + 1);   }   int main() {     cin >> n;     u = 0;     v = 1;     a[0][0] = 1;     dfs(1);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, arr[100], k;     set<int> todo;     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> arr[i];       k += arr[i];       for (long long x = 1; x * x <= arr[i]; x++) {         todo.insert(x);         todo.insert(arr[i] / x);         todo.insert(arr[i] / x + 1);       }     }     long long best = 1;     auto nxtIt = todo.begin();     for (int i : todo) {       nxtIt++;       long long nxtVal = (nxtIt == todo.end()) ? 1LL << 55 : *nxtIt;       long long sum = 0;       for (int j = 0; j < n; j++) sum += (arr[j] + i - 1) / i;       if (sum * i <= k) best = max(best, min(nxtVal - 1, k / sum));     }     cout << best;   }
#include <bits/stdc++.h>   using namespace std;   string s[100001];   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> s[i];     }     long double x = 0;     long long ans = 0;     for (int i = n; i >= 1; i--) {       if (s[i] ==  halfplus ) {         x += 0.5;       }       ans += x * m;       x *= 2;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-8;   const int INF = 1E9;   const int MAXN = 11111;   int n, maxc;   int l[MAXN], r[MAXN], b[MAXN];   int _less[MAXN];   int id[MAXN], mx;   double ans, dp[11][MAXN], sum[11][MAXN];   double p[11];   int main() {     cin >> n;     for (int i = 0; i < (int)(n); i++) {       cin >> l[i] >> r[i];       p[i] = 1.0 / (r[i] - l[i] + 1);     }     for (int i = 0; i < (int)(n); i++) id[i] = i;     ans = 0;     while (true) {       maxc = 1 << (n - 1);       for (int mask = 0; mask < (int)(maxc); mask++) {         for (int i = 0; i < (int)(n - 1); i++) _less[i] = (mask >> i) & 1;         bool ok = 1;         for (int i = 0; i < (int)(n - 1); i++)           if (_less[i] == 1 && id[i] > id[i + 1]) {             ok = 0;             break;           }         if (!ok) continue;         memset(dp, 0, sizeof(dp));         for (int i = l[id[n - 2]]; i <= r[id[n - 2]]; i++) {           dp[n - 2][i] = 1.0 * i;           if (_less[n - 2])             dp[n - 2][i] *= (l[id[n - 1]] <= i && i <= r[id[n - 1]] ? 1 : 0);           else             dp[n - 2][i] *= (i + 1 <= r[id[n - 1]]                                  ? (r[id[n - 1]] - max(l[id[n - 1]], i + 1) + 1)                                  : 0);         }         mx = r[id[n - 2]];         sum[n - 2][MAXN - 1] = dp[n - 2][MAXN - 1];         for (int i = (int)(MAXN - 1) - 1; i >= 0; i--)           sum[n - 2][i] = sum[n - 2][i + 1] + dp[n - 2][i];         for (int i = n - 3; i >= 0; i--) {           for (int j = l[id[i]]; j <= r[id[i]]; j++) {             if (_less[i])               dp[i][j] = dp[i + 1][j];             else {               dp[i][j] = sum[i + 1][j + 1];             }           }           sum[i][MAXN - 1] = dp[i][MAXN - 1];           for (int j = (int)(MAXN - 1) - 1; j >= 0; j--)             sum[i][j] = sum[i][j + 1] + dp[i][j];         }         ans += sum[0][0];       }       if (!next_permutation(id, id + n)) break;     }     cout.precision(40);     for (int i = 0; i < (int)(n); i++) ans *= p[i];     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long n;     cin >> n;     long long a[n];     long long sum = 0;     for (long long i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     long long req = ceil(4.5 * n) - sum;     vector<long long> b(n);     for (long long i = 0; i < n; i++) {       b[i] = 5 - a[i];     }     bool check = 0;     sort(b.begin(), b.end(), greater<long long>());     long long ans = 0;     for (long long i = 0; i < n; i++) {       if (req <= 0) {         cout << ans;         check = 1;         break;       }       req -= b[i];       ans++;     }     if (!check) cout << n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 4e5 + 47, mod = 1e9 + 7, inf = 1e9 + 7;   long long n, m;   vector<long long> val;   void read() {     cin >> n;     val.resize(n);     for (long long i = 0; i < n; ++i) cin >> val[i];   }   vector<long long> fenw(MAXN, 0);   void update(long long pos) {     for (; pos < MAXN; pos = (pos | (pos + 1))) fenw[pos]++;   }   long long get_sum(long long l) {     long long res = 0;     for (; l >= 0; l = (l & (l + 1)) - 1) res += fenw[l];     return res;   }   bool comp(pair<long long, long long> &a, pair<long long, long long> &b) {     if (a.first < b.first) return false;     if (a.first > b.first) return true;     return a.second <= b.second;   }   void solve() {     cin >> m;     vector<vector<pair<long long, long long> > > quer(n + 1);     for (long long i = 0; i < m; ++i) {       long long x, y;       cin >> x >> y;       quer[x - 1].push_back({y, i});     }     vector<pair<long long, long long> > suck(n);     for (long long i = 0; i < n; ++i) suck[i] = {val[i], i};     sort(suck.begin(), suck.end(), comp);     vector<long long> ans(m, 0);     for (long long len = 0; len < n; ++len) {       update(suck[len].second);       for (pair<long long, long long> p : quer[len]) {         long long k = p.first;         long long l = 0, r = n;         while (l < r) {           long long mid = l + (r - l) / 2;           if (get_sum(mid) < k)             l = mid + 1;           else             r = mid;         }         ans[p.second] = val[l];       }     }     for (long long i = 0; i < m; ++i) cout << ans[i] <<    ;     cout << endl;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long t = 1;     while (t--) {       read();       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int v, w;     node() {}     node(int V, int W) {       v = V;       w = W;     }   };   vector<node> G[105];   int n, m;   int dp[105][105][30];   int dfs(int first, int second, int s) {     if (dp[first][second][s] != -1) return dp[first][second][s];     for (int i = 0; i < G[first].size(); i++) {       int v = G[first][i].v;       int w = G[first][i].w;       if (w < s) continue;       if (dfs(second, v, w) == 0) return dp[first][second][s] = 1;     }     return dp[first][second][s] = 0;   }   int main() {     while (~scanf( %d %d , &n, &m)) {       memset(dp, -1, sizeof(dp));       for (int i = 1; i <= n; i++) G[i].clear();       for (int i = 1; i <= m; i++) {         int u, v;         char s;         scanf( %d %d %c , &u, &v, &s);         G[u].push_back(node(v, s -  a ));       }       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++)           if (dfs(i, j, 0))             printf( A );           else             printf( B );         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, i, c = 0, b;     cin >> n;     char name[15];     for (i = 0; i < n; i++) {       cin >> name;       cin >> b >> a;       if (b >= 2400 && a > b) c = 1;     }     if (c == 1)       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   void print(long long a[], int n) {     cout << endl;     for (int i = 0; i < n; i++) cout << a[i] <<    ;     cout << endl;   }   const int N = 1111;   int db[2][N];   int main() {     int n, k, x;     scanf( %d%d%d , &n, &k, &x);     int minn = 1 << 30;     int maxx = -minn;     for (int i = 0; i < n; i++) {       int r;       scanf( %d , &r);       db[0][r]++;     }     int b = 0;     int p = 1;     for (int i = 0; i < k; i++) {       for (int j = 0; j < N; j++) db[p][j] = 0;       int c = 0;       for (int j = 0; j < N; j++) {         if (db[b][j]) {           int t = db[b][j];           if (c % 2 == 0) {             db[p][j] += t / 2;             db[p][j ^ x] += (t + 1) / 2;           } else {             db[p][j] += (t + 1) / 2;             db[p][j ^ x] += t / 2;           }           c += t;         }       }       swap(b, p);     }     for (int i = 0; i < N; i++) {       if (db[b][i]) {         minn = min(minn, i);         maxx = max(maxx, i);       }     }     cout << maxx <<     << minn << endl;     return 0;   }