malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m, cl, ce, v;     cin >> n >> m >> cl >> ce >> v;     vector<long long> data_l(cl), data_e(ce);     for (long long i = 0; i < cl; i++) {       long long k;       cin >> k;       data_l[i] = k - 1;     }     for (long long i = 0; i < ce; i++) {       long long k;       cin >> k;       data_e[i] = k - 1;     }     sort((data_l).begin(), (data_l).end());     sort((data_e).begin(), (data_e).end());     vector<long long> r_data_l = data_l;     vector<long long> r_data_e = data_e;     for (long long i = 0; i < r_data_l.size(); i++) r_data_l[i] *= -1;     for (long long i = 0; i < r_data_e.size(); i++) r_data_e[i] *= -1;     sort((r_data_l).begin(), (r_data_l).end());     sort((r_data_e).begin(), (r_data_e).end());     long long q;     cin >> q;     vector<long long> ans(q);     for (long long i = 0; i < q; i++) {       long long x1, y1, x2, y2;       cin >> x1 >> y1 >> x2 >> y2;       x1--;       y1--;       x2--;       y2--;       swap(x1, y1);       swap(x2, y2);       if (y1 == y2) {         ans[i] = abs(x2 - x1);         continue;       }       long long lift_time = (abs(y2 - y1) - 1) / v + 1;       long long left_l = -1, right_l = -1, left_e = -1, right_e = -1;       vector<long long>::iterator it =           lower_bound((r_data_l).begin(), (r_data_l).end(), -x1);       if (it != r_data_l.end()) left_l = -(*it);       it = lower_bound((data_l).begin(), (data_l).end(), x1);       if (it != data_l.end()) right_l = *it;       it = lower_bound((r_data_e).begin(), (r_data_e).end(), -x1);       if (it != r_data_e.end()) left_e = -(*it);       it = lower_bound((data_e).begin(), (data_e).end(), x1);       if (it != data_e.end()) right_e = *it;       long long ans1 =           (left_l == -1 ? INF                         : abs(left_l - x1) + abs(left_l - x2) + abs(y1 - y2));       long long ans2 =           (right_l == -1 ? INF                          : abs(right_l - x1) + abs(right_l - x2) + abs(y1 - y2));       long long ans3 =           (left_e == -1 ? INF : abs(left_e - x1) + abs(left_e - x2) + lift_time);       long long ans4 =           (right_e == -1 ? INF                          : abs(right_e - x1) + abs(right_e - x2) + lift_time);       ans[i] = min(min(ans1, ans2), min(ans3, ans4));     }     for (long long i = 0; i < q; i++) cout << ans[i] << endl;     return 0;   }
#include <bits/stdc++.h>   int m, n, W, i, j, k, a[555555], b[555555], c[555555];   long long w[555555], rs;   double rq;   void solve(int l, int r, long long x) {     if (l == r) {       rs += (x * c[b[l]]) / w[b[l]];       rq += double((x * c[b[l]]) % w[b[l]]) / w[b[l]];       return;     }     int i = l, j = r, k, h = b[(l + r) >> 1];     long long e, f;     while (i <= j) {       while (c[b[i]] * w[h] < c[h] * w[b[i]]) i++;       while (c[b[j]] * w[h] > c[h] * w[b[j]]) j--;       if (i <= j) {         k = b[i];         b[i++] = b[j];         b[j--] = k;       }     }     for (f = e = 0, k = l; k < i; k++) {       f += w[b[k]];       e += c[b[k]];       if (f >= x) break;     }     if (k == i) {       rs += e;       solve(i, r, x - f);     } else if (k > j) {       f -= w[b[k]];       e -= c[b[k]];       rs += e + ((x - f) * c[b[k]]) / w[b[k]];       rq += double(((x - f) * c[b[k]]) % w[b[k]]) / w[b[k]];     } else       solve(l, j, x);   }   int main() {     srand(time(0));     scanf( %d%d%d , &m, &n, &W);     for (i = 0; i < n; i++) {       scanf( %I64d , &w[i]);       b[i] = i;     }     for (i = 0; i < n; i++) scanf( %d , &c[i]);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     for (j = 0; j < m; j++) {       if (j)         for (i = 0; i < n; i++) c[i] -= a[i];       solve(0, n - 1, W);     }     rs += int(rq);     rq -= int(rq);     rq += rs % 10;     rs /= 10;     if (rs != 0) printf( %I64d , rs);     printf( %.11lf n , rq);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, ai;     cin >> n;     map<pair<long long int, long long int>, int> mp;     vector<long long int> c;     for (long long int i = 0; i < n; i++) {       cin >> ai;       c.push_back(ai);       mp[{ai, i}]++;     }     for (long long int i = 0; i < n; i++) {       cin >> ai;       c.push_back(ai);       mp[{ai, i}]++;     }     cin >> m;     long long int d2 = 0;     for (auto c : mp) {       if (c.second == 2) d2++;     }     sort(c.begin(), c.end());     long long int ans = 1;     for (long long int i = 0; i < 2 * n;) {       long long int j = i + 1;       while (j < 2 * n && c[j] == c[i]) j++;       for (long long int k = 1; k <= j - i; k++) {         long long int p = k;         while (p % 2 == 0 && d2) {           d2--;           p /= 2;         }         (ans *= p) %= m;       }       i = j;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 105;   map<string, int> H1[maxn], H2[maxn];   vector<char> ans;   char getA(string a, string b) {     int c[30];     for (int i = 0; i < 26; i++) c[i] = 0;     for (int i = 0; i < a.size(); i++) c[a[i] -  a ]++;     for (int i = 0; i < b.size(); i++) c[b[i] -  a ]--;     for (int i = 0; i < 26; i++) {       if (c[i] > 0) return i +  a ;     }   }   int main() {     int n;     cin >> n;     if (n == 1) {       cout <<  ? 1 1  << endl;       string sss;       cin >> sss;       cout <<  !   << sss << endl;     } else {       cout <<  ? 1   << n << endl;       for (int i = 0; i < n * (n + 1) / 2; i++) {         string s;         cin >> s;         sort(s.begin(), s.end());         H1[s.size()][s]++;       }       cout <<  ? 2   << n << endl;       for (int i = 0; i < n * (n - 1) / 2; i++) {         string s;         cin >> s;         sort(s.begin(), s.end());         H2[s.size()][s]++;       }       for (int i = 1; i <= n; i++) {         for (auto p : H2[i]) {           H1[i][p.first] -= H2[i][p.first];         }         for (auto p : H1[i]) {           if (p.second > 0) {             string new1 =   ;             for (int j = 0; j < ans.size(); j++) new1 += ans[j];             ans.push_back(getA(p.first, new1));           }         }       }       string new1 =   ;       for (int j = 0; j < ans.size(); j++) new1 += ans[j];       cout <<  !   << new1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   void __print(unsigned x) { cerr << x; }   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   void __print(char x) { cerr <<      << x <<     ; }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   int n, x;   vector<int> visited;   vector<int> g[20000];   void dfs(int u, int deep) {     visited[u] = deep;     for (int v : g[u]) {       if (!visited[v]) {         dfs(v, deep + 1);       }     }   }   void solve() {     cin >> n >> x;     x--;     for (int i = 0; i < n; i += 1) g[i].clear();     visited.clear();     visited.resize(n);     int e = n - 1;     while (e--) {       int u, v;       cin >> u >> v;       u--;       v--;       g[u].emplace_back(v);       g[v].emplace_back(u);     };     if (g[x].size() <= 1) {       cout <<  Ayush n ;       return;     }     int ans = 0;     dfs(x, 1);     for (int &x : visited) x--;     vector<int> dis = visited;     sort(dis.begin(), dis.end());     ans = dis[n - 1] + dis[n - 2];     int t = n - ans - 1;     if (ans & 1) {       if (t & 1) {         cout <<  Ashish n ;       } else         cout <<  Ayush n ;     } else {       if (t & 1)         cout <<  Ayush n ;       else         cout <<  Ashish n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int tc;     cin >> tc;     while (tc--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename S>   inline T smax(T &a, const S &b) {     return a < b ? a = b : a;   }   int n, s, m, k, a[int(1500 + 20)], l[int(1500 + 20)], r[int(1500 + 20)],       id[int(1500 + 20)];   int psum[int(1500 + 20)], dp[int(1500 + 20)][int(1500 + 20)],       pos[int(1500 + 20)];   inline bool check(int val) {     for (int i = 1; i <= n; i++) {       psum[i] = psum[i - 1] + ((a[i] <= val) ? 1 : 0);       for (int j = 1; j <= m; j++) {         dp[i][j] = dp[i - 1][j];         if (!~pos[i]) continue;         int L = l[pos[i]];         smax(dp[i][j], dp[L - 1][j - 1] + psum[i] - psum[L - 1]);         L = r[id[pos[i]]];         smax(dp[i][j], dp[L][j - 1] + psum[i] - psum[L]);       }     }     return dp[n][m] >= k;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout.tie(0);     cin >> n >> s >> m >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 0; i < s; i++) cin >> l[i] >> r[i];     memset(id, -1, sizeof(id));     memset(pos, -1, sizeof(pos));     for (int i = 0; i < s; i++) {       if (!~pos[r[i]] || l[pos[r[i]]] > l[i]) pos[r[i]] = i;       for (int j = 0; j < s; j++)         if (r[j] <= r[i] && r[j] >= l[i])           if (!~id[i] || l[id[i]] > l[j]) id[i] = j;     }     int lo = 0, hi = 1e9 + 2;     while (lo != hi - 1) {       int mid = (long long)lo + hi >> 1;       if (check(mid))         hi = mid;       else         lo = mid;     }     if (!check(hi)) hi = -1;     cout << hi << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char ch[60][60];   int x[4] = {-1, 1, 0, 0};   int y[4] = {0, 0, -1, 1};   bool mark[60][60];   void del(int a, int b) {     for (int i = 0; i < 4; i++)       if (mark[a + x[i]][b + y[i]]) {         mark[a + x[i]][b + y[i]] = 0;         del(a + x[i], b + y[i]);       }   }   bool dfs(int a, int b, int n, int m) {     for (int i = 0; i <= n + 1; i++)       for (int j = 0; j <= m + 1; j++)         if (ch[i][j] ==  # )           mark[i][j] = 1;         else           mark[i][j] = 0;     mark[a][b] = 0;     int s = 0;     for (int i = 0; i < 4; i++)       if (mark[a + x[i]][b + y[i]]) {         s++;         if (s > 1) return 1;         mark[a + x[i]][b + y[i]] = 0;         del(a + x[i], b + y[i]);       }     return 0;   }   int main() {     int n, m;     while (scanf( %d %d , &n, &m) != EOF) {       gets(ch[0]);       for (int i = 0; i <= n + 1; i++)         for (int j = 0; j <= m + 1; j++) ch[i][j] =  . ;       for (int i = 1; i <= n; i++) gets(ch[i] + 1);       int s = 0;       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++)           if (ch[i][j] ==  # ) s++;       if (s < 3)         printf( -1 n );       else {         s = 2;         for (int i = 1; i <= n; i++) {           for (int j = 1; j <= m; j++)             if (ch[i][j] ==  # ) {               if (dfs(i, j, n, m)) {                 s = 1;                 break;               }             }           if (s < 2) break;         }         printf( %d n , s);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 400005;   const long long MOD = 998244353;   const long long g = 3;   int n, N;   int rev[MAXN];   long long m, Inv;   long long f[MAXN];   long long A[MAXN];   long long B[MAXN];   long long fac[MAXN];   long long inv[MAXN];   long long wn[2][MAXN];   long long power(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) (res *= a) %= MOD;       (a *= a) %= MOD;       b >>= 1;     }     return res;   }   void init(int l) {     N = 1;     while (N < l) N <<= 1;     int half = N >> 1;     Inv = power(N, MOD - 2);     for (int i = 1; i < N; i++) rev[i] = (rev[i >> 1] >> 1) + (i & 1) * half;     for (int i = 0; i < half; i++) {       wn[0][i + half] = power(g, (MOD - 1) * i / N);       wn[1][i + half] = power((MOD + 1) / g, (MOD - 1) * i / N);     }     for (int i = half - 1; i >= 0; i--) {       wn[0][i] = wn[0][i << 1];       wn[1][i] = wn[1][i << 1];     }     fac[0] = 1;     for (int i = 1; i <= l; i++) fac[i] = fac[i - 1] * i % MOD;     inv[l] = power(fac[l], MOD - 2);     for (int i = l; i >= 1; i--) inv[i - 1] = inv[i] * i % MOD;   }   void NTT(long long *v, bool inv) {     for (int i = 0; i < N; i++)       if (i < rev[i]) swap(v[i], v[rev[i]]);     for (int i = 1; i < N; i <<= 1)       for (int j = 0; j < N; j += i << 1) {         long long *l = v + j, *r = v + j + i, *w = wn[inv] + i, A;         for (int k = 0; k < i; k++, l++, r++, w++) {           A = *r * *w;           *r = (*l - A) % MOD;           *l = (*l + A) % MOD;         }       }     if (inv) {       for (int i = 0; i < N; i++) (v[i] *= Inv) %= MOD;     }   }   int main() {     scanf( %d%lld , &n, &m);     init(n << 1 | 1);     for (int i = 0; i <= n; i++) scanf( %lld , &f[i]);     for (int i = 0; i <= n; i++) A[i] = inv[i];     for (int i = 0; i <= n; i++) B[i] = fac[n - i] * f[n - i] % MOD;     NTT(A, 0);     NTT(B, 0);     for (int i = 0; i < N; i++) f[i] = A[i] * B[i] % MOD;     NTT(f, 1);     reverse(f, f + n + 1);     for (int i = 0; i <= n; i++)       f[i] = f[i] * inv[i] % MOD * power(fac[i] * inv[i + 1] % MOD, m) % MOD;     memset(A, 0, sizeof(A));     memset(B, 0, sizeof(B));     for (int i = 0; i <= n; i++) A[i] = (i % 2 ? -inv[i] : inv[i]);     for (int i = 0; i <= n; i++) B[i] = fac[n - i] * f[n - i] % MOD;     NTT(A, 0);     NTT(B, 0);     for (int i = 0; i < N; i++) f[i] = A[i] * B[i] % MOD;     NTT(f, 1);     reverse(f, f + n + 1);     for (int i = 0; i <= n; i++) f[i] = f[i] * inv[i] % MOD;     for (int i = 0; i <= n; i++) printf( %lld  , (f[i] + MOD) % MOD);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   inline int Get() {     char ch;     while ((ch = getchar()) <  0  || ch >  9 )       ;     int Num = ch -  0 ;     while ((ch = getchar()) >=  0  && ch <=  9 )       Num = (Num << 3) + (Num << 1) + ch -  0 ;     return Num;   }   const int N = 1e3 + 5;   const int M = 1600;   int n, m, gA[N], gB[N], tA[N], tB[N], id[N];   long double prob[N];   std ::pair<long double, long double> dp[N][M];   inline bool cmp(const int &a, const int &b) {     return (1 - prob[b]) * prob[a] * tB[a] < (1 - prob[a]) * prob[b] * tB[b];   }   int main() {     n = Get(), m = Get();     for (int i = 1; i <= n; ++i) {       gA[i] = Get(), gB[i] = Get(), tA[i] = Get(), tB[i] = Get();       double res;       scanf( %lf , &res);       prob[i] = res;     }     for (int i = 1; i <= n; ++i) id[i] = i;     std ::sort(id + 1, id + n + 1, cmp);     for (int i = 1, k; k = id[i], i <= n; ++i)       for (int j = m; j >= 0; --j) {         std ::pair<long double, long double> nxt;         dp[i][j] = dp[i - 1][j];         if (j >= tA[k]) {           nxt = std ::make_pair(dp[i - 1][j - tA[k]].first + gA[k],                                 dp[i - 1][j - tA[k]].second - tA[k]);           dp[i][j] = std ::max(dp[i][j], nxt);         }         if (j >= tA[k] + tB[k]) {           nxt.first =               dp[i - 1][j - tA[k] - tB[k]].first + gA[k] + (1 - prob[k]) * gB[k];           nxt.second = prob[k] * dp[i - 1][j - tA[k] - tB[k]].second -                        (1 - prob[k]) * (j - tA[k]) - tA[k];           dp[i][j] = std ::max(dp[i][j], nxt);         }       }     std ::pair<long double, long double> ans = std ::make_pair(0, 0);     for (int j = 0; j <= m; ++j) ans = std ::max(ans, dp[n][j]);     printf( %.10lf %.10lf n , (double)ans.first, -(double)ans.second);   }
#include <bits/stdc++.h>   using namespace std;   string m[10];   bool win(int i, int j, int x, int y) {     int X = 0;     int O = 0;     int D = 0;     for (int c = 0; c < 5 && i >= 0 && i < 10 && j >= 0 && j < 10;          i += x, j += y, c++) {       if (m[i][j] ==  X ) {         X++;       } else if (m[i][j] ==  O ) {         O++;       } else {         D++;       }     }     return X == 4 && D == 1;   }   int main() {     ios_base::sync_with_stdio(0);     for (int i = 0; i < 10; i++) {       cin >> m[i];     }     for (int i = 0; i < 10; i++) {       for (int j = 0; j < 10; j++) {         if (m[i][j] ==  X ) {           for (int kx = -1; kx < 2; kx++) {             for (int ky = -1; ky < 2; ky++) {               if (kx == 0 && ky == 0) continue;               if (win(i, j, kx, ky)) {                 cout <<  YES ;                 return 0;               }             }           }         }       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   bool chkmax(T &x, T y) {     return x < y ? x = y, true : false;   }   template <typename T>   bool chkmin(T &x, T y) {     return x > y ? x = y, true : false;   }   int readint() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   long long n, p;   int main() {     n = readint();     p = readint();     for (long long i = 1;; i++) {       n -= p;       if (n <= 0) return printf( -1 n ), 0;       if (n < i) continue;       if (__builtin_popcountll(n) <= i) return printf( %lld n , i), 0;     }     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long x, y, cx[120], cy[120], n, i, l = 0;     string s;     cin >> x >> y;     getline(cin, s);     getline(cin, s);     n = s.size();     cx[0] = cy[0] = 0;     if (x == 0 && y == 0) l = 1;     for (i = 0; i < n; i++) {       cx[i + 1] = cx[i];       cy[i + 1] = cy[i];       if (s[i] ==  R ) cx[i + 1]++;       if (s[i] ==  U ) cy[i + 1]++;       if (s[i] ==  D ) cy[i + 1]--;       if (s[i] ==  L ) cx[i + 1]--;       if (x == cx[i] && cy[i] == y) l = 1;     }     for (i = 0; i <= n; i++) {       if (cx[n] == 0 && cy[n] == 0) break;       if (cx[n] == 0 && (y - cy[i]) % cy[n] == 0 && (y - cy[i]) / cy[n] > 0 &&           cx[i] == x)         l = 1;       if (cx[n] != 0)         if ((x - cx[i]) % cx[n] == 0 &&             cy[n] * ((x - cx[i]) / cx[n]) + cy[i] == y &&             ((x - cx[i]) / cx[n]) > 0)           l = 1;     }     if (l == 1)       cout <<  Yes n ;     else       cout <<  No n ;   }
#include <bits/stdc++.h>   using namespace std;   using lint = long long;   const int inf = 1000000007;   const int MOD = 1000000007;   void solve() {     int n, k;     cin >> n >> k;     vector<set<int>> edge(n);     for (int i = 0; i < n - 1; ++i) {       int a, b;       cin >> a >> b;       --a;       --b;       edge[a].insert(b);       edge[b].insert(a);     }     if (k == 1) {       cout << n - 1 <<   n ;       return;     }     int res = 0;     vector<queue<int>> child(n);     for (int i = 0; i < n; ++i) {       if (edge[i].size() == 1) {         child[*edge[i].begin()].push(i);       }     }     queue<int> que;     for (int i = 0; i < n; ++i) {       if (child[i].size() >= k) que.push(i);     }     while (!que.empty()) {       int x = que.front();       que.pop();       if (child[x].size() < k) continue;       res += 1;       for (int i = 0; i < k; ++i) {         int buf = child[x].front();         child[x].pop();         edge[x].erase(buf);       }       if (child[x].size() >= k) que.push(x);       if (edge[x].size() == 1) {         int par = *edge[x].begin();         child[par].push(x);         if (child[par].size() >= k) que.push(par);       }     }     cout << res <<   n ;   }   signed main() {     cin.tie(0);     ios::sync_with_stdio(false);     int t;     cin >> t;     for (int i = 0; i < t; ++i) solve();     return 0;   }
#include <bits/stdc++.h>   int x, n, m, a[2010], f[2010], min, c, i, j, k;   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);       if (a[i] <= m) f[a[i]]++;     }     c = 0;     x = n / m;     for (i = 1; i <= n; i++) {       if (a[i] > m) {         k = 1;         for (j = 2; j <= m; j++)           if (f[j] < f[k]) k = j;         if (f[k] == n / m) break;         c++;         f[k]++;         a[i] = k;       } else if (f[a[i]] > x) {         k = 1;         for (j = 2; j <= m; j++)           if (f[j] < f[k]) k = j;         if (f[k] == n / m) break;         f[a[i]]--;         c++;         f[k]++;         a[i] = k;       }     }     k = 1;     for (j = 2; j <= m; j++)       if (f[j] < f[k]) k = j;     printf( %d %d n , f[k], c);     for (i = 1; i <= n; i++) printf( %d  , a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[20], b[20];   char s[110000];   int main() {     int n, i, j;     scanf( %s , s);     for (i = 0; s[i]; i++) {       if (s[i] ==  5 )         a[2]++;       else if (s[i] ==  9 )         a[6]++;       else         a[s[i] -  0 ]++;     }     scanf( %s , s);     for (i = 0; s[i]; i++) {       if (s[i] ==  5 )         b[2]++;       else if (s[i] ==  9 )         b[6]++;       else         b[s[i] -  0 ]++;     }     int ans = 210000;     for (i = 0; i <= 9; i++)       if (i - 9 && i - 5) {         if (a[i]) ans = min(ans, b[i] / a[i]);       }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, N, Left, Right;   long long seg[2000001], vs[2000001];   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     char grid[n + 1][m + 1];     vs[0] = 0;     set<pair<long long, long long>> d;     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= m; j++) {         cin >> grid[i][j];       }     }     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= m; j++) {         if (i > 1 && j > 1) {           if (grid[i - 1][j] ==  X  && grid[i][j - 1] ==  X ) {             vs[j]++;           }         }       }     }     for (long long i = 1; i <= m; i++) vs[i] += vs[i - 1];     long long q;     cin >> q;     while (q--) {       cin >> Left >> Right;       if (vs[Right] - vs[Left])         cout <<  NO ;       else         cout <<  YES ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n, m, k, kk, x, y;     cin >> n >> m >> k;     kk = k;     long long int a[m];     for (long long int i = 0; i < m; i++) a[i] = 9999999999;     for (long long int i = 0; i < n; i++) {       cin >> x >> y;       a[x - 1] = min(a[x - 1], y);     }     for (long long int i = 0; i < m; i++) {       if (a[i] >= kk)         kk = 0;       else         kk -= a[i];       if (kk == 0) break;     }     cout << k - kk;     return;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t = 1;     while (t--) solve();     cerr <<   n           <<  Time elapsed :  << clock() * 1000.0 / CLOCKS_PER_SEC <<   ms n ;   }