malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int M = 1000005;   int read() {     int x = 0, f = 1;     char c;     while ((c = getchar()) <  0  || c >  9 ) {       if (c ==  - ) f = -1;     }     while (c >=  0  && c <=  9 ) {       x = (x << 3) + (x << 1) + (c ^ 48);       c = getchar();     }     return x * f;   }   int n, m, ans, c1, c2;   char s[M];   int dx[8] = {-1, 1, 0, 0, 1, -1, 1, -1}, dy[8] = {0, 0, -1, 1, 1, -1, -1, 1};   vector<int> f[M], a[M];   struct node {     int x, y, d;   };   bool check(int x) {     queue<node> q;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         f[i][j] = 0;         if (i - x >= 1 && j - x >= 1 && i + x <= n && j + x <= m) {           int t = a[i + x][j + x] + a[i - x - 1][j - x - 1] -                   a[i - x - 1][j + x] - a[i + x][j - x - 1];           if (t == (2 * x + 1) * (2 * x + 1)) {             f[i][j] = 1;             q.push(node{i, j, 0});           }         }       }     c2 = 0;     while (!q.empty()) {       node t = q.front();       c2++;       q.pop();       if (t.d == x) continue;       for (int i = 0; i < 8; i++) {         int tx = t.x + dx[i], ty = t.y + dy[i];         if (tx >= 1 && tx <= n && ty >= 1 && ty <= m && !f[tx][ty]) {           f[tx][ty] = 1;           q.push(node{tx, ty, t.d + 1});         }       }     }     return c1 == c2;   }   void dich(int l, int r) {     if (l > r) return;     int mid = (l + r) >> 1;     if (check(mid)) {       ans = mid;       dich(mid + 1, r);     } else       dich(l, mid - 1);   }   signed main() {     n = read();     m = read();     for (int i = 0; i <= n; i++)       for (int j = 0; j <= m; j++) {         f[i].push_back(0);         a[i].push_back(0);       }     for (int i = 1; i <= n; i++) {       scanf( %s , s + 1);       for (int j = 1; j <= m; j++) {         if (s[j] ==  X ) c1++;         a[i][j] = (s[j] ==  X  ? 1 : 0);       }     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];     dich(0, max(n, m));     printf( %d n , ans);     for (int i = 1; i <= n; i++, puts(  ))       for (int j = 1, x = ans; j <= m; j++)         if (i - x >= 1 && j - x >= 1 && i + x <= n && j + x <= m) {           int t = a[i + x][j + x] + a[i - x - 1][j - x - 1] -                   a[i - x - 1][j + x] - a[i + x][j - x - 1];           if (t == (2 * x + 1) * (2 * x + 1))             printf( X );           else             printf( . );         } else           printf( . );   }
#include <bits/stdc++.h>   using namespace std;   struct trip {     int a, b, c;   };   const int MAXINT = 2 * 1e5 + 1;   int n, c, stairs[MAXINT], elevator[MAXINT], dp[MAXINT][2];   void solve(int pos) {     if (pos < n) {       dp[pos][0] = min(dp[pos - 1][1], dp[pos - 1][0]) + stairs[pos - 1];       dp[pos][1] = min(dp[pos - 1][1], dp[pos - 1][0] + c) + elevator[pos - 1];       solve(pos + 1);     }   }   int main() {     cin >> n >> c;     for (int i = 0; i < n - 1; i++) cin >> stairs[i];     for (int i = 0; i < n - 1; i++) cin >> elevator[i];     for (int i = 0; i < n; i++)       for (int j = 0; j < 2; j++) dp[i][j] = 0x3f3f3f3f;     dp[0][0] = 0, dp[0][1] = c;     solve(1);     for (int i = 0; i < n; i++) cout << min(dp[i][0], dp[i][1]) <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 110000;   int x[N], y[N];   vector<int> vec[2];   int main() {     int n;     scanf( %d , &n);     auto prv = [&n](int x) { return (x - 1 + n) % n; };     auto nxt = [&n](int x) { return (x + 1) % n; };     for (int i = 0; i < n; i++) scanf( %d%d , &x[i], &y[i]);     for (int T = 0; T < 2; T++) {       if (T)         for (int i = 0; i < n; i++) swap(x[i], y[i]);       int id, miy = 1e8;       for (int i = 0; i < n; i++)         if (miy > y[i]) miy = y[i], id = i;       int lid = id, rid = id;       while (y[prv(lid)] == miy) lid = prv(lid);       while (y[nxt(rid)] == miy) rid = nxt(rid);       vec[T].push_back(abs(x[lid] - x[rid]) + 1);       int now_y = miy;       while (1) {         ++now_y;         if (y[prv(lid)] == now_y) lid = prv(lid);         if (y[nxt(rid)] == now_y) rid = nxt(rid);         if (y[prv(lid)] <= y[lid]) {           vec[T].push_back(abs(x[lid] - x[rid]) + 1);           break;         }         double lx = (1.0 * x[lid] * (y[prv(lid)] - now_y) +                      1.0 * x[prv(lid)] * (now_y - y[lid])) /                     (y[prv(lid)] - y[lid]);         double rx = (1.0 * x[rid] * (y[nxt(rid)] - now_y) +                      1.0 * x[nxt(rid)] * (now_y - y[rid])) /                     (y[nxt(rid)] - y[rid]);         if (lx > rx) swap(lx, rx);         vec[T].push_back(floor(rx) - ceil(lx) + 1);       }     }     long long all = 0;     for (auto &t : vec[0]) all += t;     double ans = 0;     for (int T = 0; T < 2; T++) {       double sum0 = 0, sum1 = 0, sum2 = 0;       int k = 0;       for (auto &t : vec[T]) {         sum0 += t;         sum1 += 1.0 * k * t;         sum2 += 1.0 * k * k * t;         ++k;       }       ans += 2 * sum2 * sum0 - 2 * sum1 * sum1;     }     printf( %.10lf n , ans / all / (all - 1) / 2);   }
#include <bits/stdc++.h>   using namespace std;   int n, m, mn = 2e9, cnt, num, s[2505][2505];   bool v[2505];   char a[2505][2505];   int main() {     int i, j, r, c, tr, tc, sz;     cin >> n >> m;     for (i = 1; i <= n; i++) {       scanf( %s , &a[i][1]);     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j] -  0 ;       }     }     sz = max(n, m);     for (i = 2; i <= sz; i++) {       cnt = 0;       for (r = 1; r <= n; r += i) {         for (c = 1; c <= m; c += i) {           tr = min(r + i - 1, n);           tc = min(c + i - 1, m);           num = s[tr][tc] - s[r - 1][tc] - s[tr][c - 1] + s[r - 1][c - 1];           cnt += min(num, i * i - num);         }       }       mn = min(mn, cnt);     }     cout << mn;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> inp;   long long lim;   long long dp[25][2][2][5];   long long DP(long long pos, long long isSmall, long long isStart,                long long val) {     if (val > 3) return 0;     if (pos == lim) {       return 1;     }     if (dp[pos][isSmall][isStart][val] != -1)       return dp[pos][isSmall][isStart][val];     long long ses = isSmall ? 9 : inp[pos];     long long ret = 0;     if (!isStart) {       for (int i = 0; i <= ses; i++) {         ret += DP(pos + 1, isSmall | i < inp[pos], 0, (i != 0) + val);       }     } else {       for (int i = 1; i <= ses; i++) {         ret += DP(pos + 1, isSmall | i < inp[pos], 0, (i != 0) + val);       }       ret += DP(pos + 1, 1, 1, 0);     }     return dp[pos][isSmall][isStart][val] = ret;   }   long long cal(long long x) {     inp.clear();     while (x) {       inp.push_back(x % 10);       x = x / 10;     }     reverse(inp.begin(), inp.end());     lim = inp.size();     memset(dp, -1, sizeof(dp));     return DP(0, 0, 1, 0);   }   int main() {     long long T;     cin >> T;     while (T--) {       long long x, y;       cin >> x >> y;       cout << cal(y) - cal(x - 1) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   long long solve(long long l, long long r, long long x) {     long long res = 0;     for (int i = 1; i <= 62; i++) {       long long p = (1LL << i) - 1;       long long val = (x ^ p);       if (l <= p && p <= r) {         res = max(res, val);       }       if (l <= val && val <= r) {         res = max(res, p);       }     }     return res;   }   int main() {     long long l, r;     cin >> l >> r;     if (l == r) {       cout << 0;     } else if (r - l <= 1000) {       long long m = 0;       for (long long i = l; i <= r; i++) {         for (long long j = l; j <= r; j++) {           m = max(m, i ^ j);         }       }       cout << m;     } else {       long long a = solve(l, r, l);       long long b = solve(l, r, r);       cout << max(a, b);     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   inline bool check(vector<long long>& prev, long long x) {     long long sz = prev.size();     for (long long i = 0; i < sz; i += x) {       long long j = min(i + x - 1, sz - 1);       if (prev[j] - i > k) return false;     }     return true;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> k;     vector<long long> a(n);     for (long long i = 0; i < n; i++) cin >> a[i];     sort(a.begin(), a.end());     long long sz = a.back() + 10;     vector<long long> cnt(sz, 0);     for (long long i : a) cnt[i]++;     vector<long long> prev(sz, 0);     for (long long i = 1; i < sz; i++) {       if (cnt[i] > 0)         prev[i] = i;       else         prev[i] = prev[i - 1];     }     long long hi = a.front();     for (long long i = hi; i >= 1; i--) {       if (check(prev, i)) {         cout << i << endl;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char Start;   int n, m;   char S[400005], T[400005];   int fa[400005], tr[400005][26], len[400005], rt[400005], pos[400005], tot, last;   vector<int> G[400005];   void ins(int c, bool debug = 0) {     if (tr[last][c]) {       int p = last, q = tr[last][c];       if (len[q] != len[p] + 1) {         int v = ++tot;         memcpy(tr[v], tr[q], sizeof tr[q]);         fa[v] = fa[q], len[v] = len[p] + 1;         for (; ~p && tr[p][c] == q; p = fa[p]) tr[p][c] = v;         fa[q] = v;       }     } else {       int u = ++tot, p = last, q;       len[u] = len[p] + 1;       for (; ~p && !tr[p][c]; p = fa[p]) tr[p][c] = u;       if (p == -1)         fa[u] = 0;       else if (len[q = tr[p][c]] == len[p] + 1)         fa[u] = q;       else {         int v = ++tot;         memcpy(tr[v], tr[q], sizeof tr[q]);         fa[v] = fa[q], len[v] = len[p] + 1;         for (; ~p && tr[p][c] == q; p = fa[p]) tr[p][c] = v;         fa[q] = fa[u] = v;       }     }   }   int lc[400005 * 30], rc[400005 * 30], mx[400005 * 30], mxp[400005 * 30];   void upd(int u) {     if (mx[lc[u]] >= mx[rc[u]])       mx[u] = mx[lc[u]], mxp[u] = mxp[lc[u]];     else       mx[u] = mx[rc[u]], mxp[u] = mxp[rc[u]];   }   void ins(int &u, int l, int r, int p) {     if (!u) u = ++tot, mxp[u] = l;     if (l == r) return (void)(mx[u]++);     int m = l + r >> 1;     p <= m ? ins(lc[u], l, m, p) : ins(rc[u], m + 1, r, p);     upd(u);   }   void merge(int &u, int l, int r) {     if (!l || !r) return (void)(u = l + r);     u = ++tot;     if (lc[l] || rc[l]) {       merge(lc[u], lc[l], lc[r]), merge(rc[u], rc[l], rc[r]);       upd(u);     } else {       mx[u] = mx[l] + mx[r], mxp[u] = mxp[l];     }   }   pair<int, int> qry(int u, int l, int r, int ql, int qr) {     if (ql > r || l > qr || !u || ql > qr) return make_pair(0, 0x3f3f3f3f);     if (ql <= l && r <= qr) return make_pair(mx[u], mxp[u]);     int m = l + r >> 1;     pair<int, int> r1 = qry(lc[u], l, m, ql, qr),                    r2 = qry(rc[u], m + 1, r, ql, qr);     if (r1.first >= r2.first)       return r1;     else       return r2;   }   int f[400005], g[400005], ps[400005];   void dfs(int u) {     for (int v : G[u]) {       dfs(v), merge(rt[u], rt[u], rt[v]);       if (!ps[u]) ps[u] = ps[v];     }   }   int ans;   void dfs2(int u) {     ans = max(ans, f[u]);     for (int v : G[u]) {       if (!u || qry(rt[g[u]], 1, n, ps[v] - len[v] + len[g[u]], ps[v] - 1).first)         f[v] = f[u] + 1, g[v] = v;       else         f[v] = f[u], g[v] = g[u];       dfs2(v);     }   }   char End;   int main() {     scanf( %d , &n);     scanf( %s , S + 1);     fa[0] = -1;     for (int i = (1), LIM = (n); i <= LIM; i++)       ins(S[i] -  a ), last = tr[last][S[i] -  a ], ps[last] = i;     for (int i = (1), LIM = (tot); i <= LIM; i++) {       G[fa[i]].push_back(i);       if (ps[i]) ins(rt[i], 1, n, ps[i]);     }     dfs(0);     dfs2(0);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000000 + 7;   int main() {     ios::sync_with_stdio(0);     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     long long n;     cin >> n;     if (n < 3) {       cout << -1;       return 0;     }     for (int i = n; i >= 1; i--) {       cout << i <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool prime(int n) {     if (n % 2 == 0) return false;     for (int i = 3; i * i <= n; i += 2)       if (n % i == 0) return false;     return true;   }   int r(int n) {     int div = 1;     int ans = 0;     while (div <= n) {       ans *= 10;       ans += ((n / div) % 10);       div *= 10;     }     return ans;   }   int main() {     int n;     cin >> n;     int cont = 0;     int i = 11;     while (cont < n) {       if (prime(i)) {         int x = r(i);         if (x != i && prime(x)) {           cont++;           if (cont == n) cout << i <<   n ;         }       }       i++;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   long long add(long long x, long long y, long long CMOD = MOD) {     return (x + y + CMOD + CMOD) % CMOD;   }   long long mult(long long x, long long y, long long CMOD = MOD) {     return add(x, 0) * add(y, 0) % CMOD;   }   long long fast_expo(long long x, long long y, long long CMOD = MOD) {     if (x == 0) return 0;     if (y == 0) return 1;     long long ans = fast_expo(x, y / 2, CMOD);     ans = mult(ans, ans, CMOD);     if (y & 1) ans = mult(ans, x, CMOD);     return ans;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   long long gen(long long x, long long y) {     if (x == y) return x;     return x + rng() % (y - x + 1);   }   const int TAM = 2e5 + 100;   const long long INF = LLONG_MAX / 4;   long long fact[TAM];   long long ifact[TAM];   long long n, m;   void pre() {     fact[0] = 1;     for (int i = 1; i < TAM; i++) fact[i] = mult(fact[i - 1], i);     for (int i = 0; i < TAM; i++) ifact[i] = fast_expo(fact[i], MOD - 2);   }   long long comb(long long x, long long y) {     return mult(fact[x], mult(ifact[y], ifact[x - y]));   }   int main() {     pre();     cin >> n >> m;     if (n == 2) {       puts( 0 );       return 0;     }     long long ans = 0;     for (long long x = n - 1; x <= m; x++) {       long long factor = mult(comb(x - 2, n - 3), fast_expo(2, n - 3));       ans = add(ans, mult(x - 1, factor));     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sign(long long x) { return x < 0 ? -1 : x > 0 ? 1 : 0; }   struct point {     long long x, y;     point(long long a = 0, long long b = 0) : x(a), y(b) {}     point operator-(point q) { return point(x - q.x, y - q.y); }     long long operator%(point q) { return x * q.y - y * q.x; }   };   point T[1001];   long long piso(long long A, long long B) {     if (B < 0) A = -A, B = -B;     if (A >= 0)       return A / B;     else       return -((-A + B - 1) / B);   }   long long techo(long long A, long long B) {     if (B < 0) A = -A, B = -B;     if (A >= 0)       return (A + B - 1) / B;     else       return A / B;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %lld %lld , &T[i].x, &T[i].y);     if (T[2].y > T[0].y) {       for (int i = 0; i < n; i++) T[i].y = -T[i].y;       swap(T[0], T[1]);       reverse(T + 2, T + n);     }     T[n] = T[0];     long long y = T[0].y;     bool sirve = true;     long long le = T[0].x, ri = T[1].x;     for (int i = 2; i < n; i++) {       long long der = T[1].x;       long long izq = T[0].x;       for (int j = 2; j < i; j++)         if (abs(y - T[j].y) < abs(y - T[i].y)) {           long long A = T[j].y - T[i].y;           long long B = T[i].x - T[j].x;           long long C = T[i].x * A + T[i].y * B;           der = min(der, piso(C - B * y, A));         }       if (i - 1 > 1)         if (T[i].y == T[i - 1].y && T[i - 2].y > T[i].y &&             sign((T[i] - T[i - 1]) % (T[i] - T[i - 2])) <= 0)           sirve = false;       for (int j = i + 1; j < n; j++)         if (abs(y - T[j].y) < abs(y - T[i].y)) {           long long A = T[j].y - T[i].y;           long long B = T[i].x - T[j].x;           long long C = T[i].x * A + T[i].y * B;           izq = max(izq, techo(C - B * y, A));         }       if (i + 1 < n)         if (T[i].y == T[i + 1].y && T[i + 2].y > T[i].y &&             sign((T[i] - T[i + 1]) % (T[i] - T[i + 2])) >= 0)           sirve = false;       if (der < izq)         sirve = false;       else if (ri < izq || der < le)         sirve = false;       else {         le = max(izq, le);         ri = min(der, ri);       }     }     int res = ri - le + 1;     if (!sirve) res = 0;     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long oo = 1e18;   const long long MOD = 998244353;   const long long MAXN = 2e5 + 100;   long long qpow(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % MOD;       a = a * a % MOD;       b /= 2;     }     return res;   }   long long inv(long long x) { return qpow(x, MOD - 2); }   long long fact[MAXN];   long long C(long long n, long long k) {     return fact[n] * inv(fact[k] * fact[n - k] % MOD) % MOD;   }   long long N, K;   long long arr[MAXN];   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     fact[0] = 1;     for (long long i = 1; i < MAXN; i++) fact[i] = fact[i - 1] * i % MOD;     cin >> N >> K;     long long cont = 0;     for (long long i = 0; i < N; i++) {       cin >> arr[i];     }     for (long long i = 0; i < N; i++) {       if (arr[i] != arr[(i + 1) % N]) {         cont++;       }     }     long long res = 0;     for (long long i = 1; i <= cont; i++) {       long long tp = qpow(2, i);       if (i % 2 == 0) tp = (tp + MOD - C(i, i / 2)) % MOD;       tp = tp * inv(2) % MOD;       tp = tp * qpow(K - 2, cont - i) % MOD;       tp = tp * C(cont, i) % MOD;       res = (res + tp) % MOD;     }     res = res * qpow(K, N - cont) % MOD;     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int str[26][1505];   int ans[26][1505];   int main(int argc, char *argv[]) {     int n;     scanf( %d , &n);     getchar();     char c;     for (int i = 0; i < n; i++) {       c = getchar();       str[c -  a ][i]++;     }     for (int i = 0; i < 26; i++) {       for (int j = 1; j < n; j++) {         str[i][j] = str[i][j - 1] + str[i][j];       }     }     int total, m;     for (int i = 0; i < 26; i++) {       for (int j = 0; j < n; j++) {         for (int k = j; k < n; k++) {           if (j == 0) {             total = str[i][k];           } else {             total = str[i][k] - str[i][j - 1];           }           m = k - j + 1 - total;           if (ans[i][m] < k - j + 1) {             ans[i][m] = k - j + 1;           }         }       }     }     for (int i = 0; i < 26; i++) {       for (int j = 1; j <= n; j++) {         ans[i][j] = ans[i][j] < ans[i][j - 1] ? ans[i][j - 1] : ans[i][j];       }     }     int q;     scanf( %d , &q);     int num;     while ((q--) > 0) {       scanf( %d %c , &num, &c);       printf( %d n , ans[c -  a ][num]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long l[200010];   int n;   long long teste(long long x) {     if (x <= 1) return n;     long long res = 0;     for (int i = 0; i < n; i++) {       if (l[i] < x)         res += x - (l[i] % x);       else         res += min(l[i] % x, x - (l[i] % x));     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < n; i++) cin >> l[i];     long long res = n;     for (int i = 0; i < 20; i++) {       int p = rand() * rand() % n;       long long t = l[p];       vector<long long> factors;       for (int j = 2; j <= sqrt(t); j++) {         while (t % j == 0) {           t /= j;           factors.push_back(j);         }       }       if (t > 1) factors.push_back(t);       t = l[p] - 1;       for (int j = 2; j <= sqrt(t); j++) {         while (t % j == 0) {           t /= j;           factors.push_back(j);         }       }       if (t > 1) factors.push_back(t);       t = l[p] + 1;       for (int j = 2; j <= sqrt(t); j++) {         while (t % j == 0) {           t /= j;           factors.push_back(j);         }       }       if (t > 1) factors.push_back(t);       sort(factors.begin(), factors.end());       for (int j = 0; j < (int)factors.size(); j++) {         if (j and factors[j] == factors[j - 1]) continue;         res = min(res, teste(factors[j]));       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s, t;     cin >> s >> t;     vector<int> f1(26);     vector<int> f2(26);     for (int i = 0; i < n; i++) {       f1[s[i] - 97]++;       f2[t[i] - 97]++;     }     int f = 0;     for (int i = 0; i < 26; i++) {       if (f1[i] != f2[i]) {         f = 1;         break;       }     }     if (f == 1)       cout <<  -1  << endl;     else {       int cou = 0;       vector<int> v;       for (int i = 0; i < n; i++) {         if (s[i] == t[i]) continue;         int c = 0;         for (int j = i + 1; j < n; j++) {           if (t[i] == s[j]) {             c++;             break;           }           c++;         }         char x = s[i];         s[i] = s[i + c];         s[i + c] = x;         for (int k = 1; k < c; k++) {           v.push_back(i + k);         }         v.push_back(i + c);         for (int k = 1; k < c; k++) {           v.push_back(i + c - k);         }         cou = cou + 2 * c - 1;       }       cout << cou << endl;       for (int i = 0; i < cou; i++) cout << v[i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Lem {     int m, v, id;     bool operator<(Lem b) const { return m < b.m || (m == b.m && v < b.v); }   };   int n, k, h;   Lem a[(100000 + 10)];   bool can(double t) {     int j = k;     for (int i(n - 1), _l(0); i >= _l; --i) {       if (j > 0 && (double)j * h / a[i].v - t <= -1e-10) j--;     }     return j == 0;   }   void putAns(double t) {     int ans[(100000 + 10)];     int j = k;     for (int i(n - 1), _l(0); i >= _l; --i) {       if (j > 0 && (double)j * h / a[i].v - t <= -1e-10) ans[--j] = a[i].id;     }     for (int i(0), _n(k - 1); i < _n; ++i) printf( %d  , ans[i]);     printf( %d n , (ans[k - 1]));   }   int main() {     scanf( %d , &(n)), scanf( %d , &(k)), scanf( %d , &(h));     for (int i(0), _n(n); i < _n; ++i) scanf( %d , &(a[i].m)), a[i].id = i + 1;     for (int i(0), _n(n); i < _n; ++i) scanf( %d , &(a[i].v));     sort(a, a + n);     double l = 1e-10, r = 1e10;     int cnt = 100;     while (cnt--) {       double mid = (l + r) / 2.0;       if (can(mid))         r = mid;       else         l = mid;     }     putAns(r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     if (s.size() >= 1 && s.size() <= 100) {       int i, j, k = 0, m = 0;       for (i = 0; i < s.size(); i++) {         if (s[i] >=  a  && s[i] <=  z ) k++;         if (s[i] >=  A  && s[i] <=  Z ) m++;       }       if (k >= m) {         for (j = 0; j < s.size(); j++) {           if (s[j] >=  A  && s[j] <=  Z ) s[j] = s[j] + 32;           cout << s[j];         }       }       if (k < m) {         for (j = 0; j < s.size(); j++) {           if (s[j] >=  a  && s[j] <=  z ) s[j] = s[j] - 32;           cout << s[j];         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = (long long)1000 * 1000 * 1000 + 9;   const int maxn = 1000 * 100 + 1;   int n, m, r[maxn], parent[maxn];   long long javab = 1;   int par(int x) {     if (x == parent[x]) return x;     return parent[x] = par(parent[x]);   }   bool merge(int x, int y) {     x = par(x);     y = par(y);     if (x == y) return true;     if (r[x] < r[y]) swap(x, y);     parent[y] = x;     r[x] += r[y];     return false;   }   int main() {     ios::sync_with_stdio(false);     int x, y;     cin >> n >> m;     for (int i = 0; i < n; i++) {       parent[i] = i;       r[i] = 1;     }     for (int i = 0; i < m; i++) {       cin >> x >> y;       x--;       y--;       if (merge(x, y) == true) {         javab *= 2;         javab %= mod;       }       cout << javab - 1 << endl;     }     return 0;   }