malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void c_p_c() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   bool isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i += 6) {       if (n % i == 0 || n % (i + 2) == 0) return false;     }     return true;   }   vector<bool> Sieve(long long n) {     bool prime[n + 1];     memset(prime, true, sizeof(prime));     for (long long i = 2; i * i <= n; i++) {       if (prime[i]) {         for (long long j = i * i; j <= n; j += i) {           prime[j] = false;         }       }     }     vector<bool> primes(n + 1);     primes[0] = false;     primes[1] = false;     for (long long i = 2; i <= n; i++) {       if (prime[i]) primes[i] = true;     }     return primes;   }   set<long long> primeFactors(long long n) {     set<long long> factors;     while (n % 2 == 0) {       n /= 2;       factors.insert(2);     }     for (long long i = 3; i <= sqrt(n); i += 2) {       while (n % i == 0) {         factors.insert(i);         n /= i;       }     }     if (n > 2) factors.insert(n);     return factors;   }   bool cmp(string a, string b) { return a.length() < b.length(); }   int32_t main() {     c_p_c();     long long n, k;     cin >> n >> k;     for (long long i = n; i >= n - k + 1; i--) cout << i <<    ;     for (long long i = 1; i <= n - k; i++) cout << i <<    ;     cout <<   n ;   }
#include <bits/stdc++.h>   int main() {     char s[105];     int i, n, j;     scanf( %d , &n);     getchar();     for (i = 0; i < n; i++) {       scanf( %c , &s[i]);     }     for (i = 0; i < n; i++) {       if (s[i] ==  o  && s[i + 1] ==  g  && s[i + 2] ==  o ) {         printf( *** );         for (j = i + 3; j < n; j += 2) {           if (s[j] ==  g  && s[j + 1] ==  o ) {             continue;           } else {             break;           }         }         i = j - 1;       } else         printf( %c , s[i]);     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long K;   vector<int> E[200000 + 5];   void addEdge(int u, int v) {     E[u].push_back(v);     E[v].push_back(u);   }   int sz[200000 + 5], deep[200000 + 5], fa[200000 + 5];   int msz[200000 + 5], root;   void dfs1(int x, int f) {     sz[x] = 1;     msz[x] = 0;     for (int y : E[x]) {       if (y != f) {         dfs1(y, x);         sz[x] += sz[y];         msz[x] = max(msz[x], sz[y]);       }     }     msz[x] = max(msz[x], n - sz[x]);     if (root == 0 || msz[x] < msz[root]) root = x;   }   set<pair<int, int> > S[200000 + 5];   long long minans = 0, maxans = 0;   int sons[200000 + 5];   void dfs2(int x, int f, int rt) {     sz[x] = 1;     fa[x] = f;     deep[x] = deep[f] + 1;     for (int y : E[x]) {       if (y != f) {         sons[x]++;         dfs2(y, x, rt);         sz[x] += sz[y];       }     }     if (sz[x] > 1) S[rt].insert(make_pair(deep[x], x));     minans += sz[x] % 2;     maxans += sz[x];   }   bool vis[200000 + 5];   int getSon(int x) {     for (int t : E[x]) {       if (t != fa[x] && !vis[t]) {         vis[t] = 1;         return t;       }     }     return x;   }   void del(int x, int rt) {     vis[x] = 1;     sons[fa[x]]--;     if (sons[fa[x]] == 0) S[rt].erase(make_pair(deep[fa[x]], fa[x]));   }   priority_queue<pair<int, int> > q;   vector<int> ans;   void dfs3(int x) {     if (!vis[x]) ans.push_back(x);     for (int y : E[x])       if (y != fa[x]) dfs3(y);   }   int main() {     scanf( %d %lld , &n, &K);     for (int i = 1, u, v; i < n; i++) {       scanf( %d %d , &u, &v);       addEdge(u, v);     }     dfs1(1, 0);     for (int y : E[root]) {       dfs2(y, root, y);       q.push(make_pair(sz[y], y));     }     if (K >= minans && K <= maxans && (maxans - K) % 2 == 0) {       puts( YES );       K = (maxans - K) / 2;       while (K) {         int rt = q.top().second;         q.pop();         int lc = S[rt].rbegin()->second;         int d = deep[lc];         if (K >= d) {           K -= d;           int u = getSon(lc), v = getSon(lc);           del(u, rt);           del(v, rt);           printf( %d %d n , u, v);         } else {           int u = S[rt].lower_bound(make_pair(K, 0))->second;           int v = getSon(u);           del(u, rt);           del(v, rt);           printf( %d %d n , u, v);           break;         }         sz[rt] -= 2;         if (sz[rt] > 1) q.push(make_pair(sz[rt], rt));       }       dfs3(root);       for (int i = 0; i < (int)ans.size() / 2; i++)         printf( %d %d n , ans[i], ans[i + (int)ans.size() / 2]);     } else       puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200000 + 5, inf = 2e9;   const long double EPS = 1e-9L;   vector<pair<int, int> > pairs[26];   vector<int> mn[26];   int leftSub[N], rightSub[N];   void computeSub(string& a, string& b, int ans[]) {     for (int i = 0; i < (int)(a).size(); ++i) {       int prv = 0;       if (i != 0) prv = ans[i - 1];       if (prv == (int)(b).size() || a[i] != b[prv])         ans[i] = ans[i - 1];       else         ans[i] = 1 + ans[i - 1];     }   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s, t;     cin >> s >> t;     for (int i = 0; i < (int)(t).size(); ++i) {       int l = i, r = (int)(t).size() - 1 - i;       pairs[t[i] -  a ].push_back({l, r});     }     for (int c = 0; c < 26; ++c) {       sort(pairs[c].begin(), pairs[c].end());       for (int i = 0; i < (int)(pairs[c]).size(); ++i) {         if (i == 0)           mn[c].push_back(pairs[c][i].second);         else           mn[c].push_back(min(pairs[c][i].second, mn[c][i - 1]));       }     }     computeSub(s, t, leftSub);     reverse(s.begin(), s.end()), reverse(t.begin(), t.end());     computeSub(s, t, rightSub);     reverse(s.begin(), s.end()), reverse(rightSub, rightSub + (int)(s).size());     for (int i = 0; i < (int)(s).size(); ++i) {       int a = 0, b = 0;       if (i != 0) a = leftSub[i - 1];       if (i != (int)(s).size() - 1) b = rightSub[i + 1];       pair<int, int> p = {a, inf};       if (pairs[s[i] -  a ].empty() || pairs[s[i] -  a ][0] > p) {         cout <<  No n ;         return 0;       }       int ind =           upper_bound(pairs[s[i] -  a ].begin(), pairs[s[i] -  a ].end(), p) -           begin(pairs[s[i] -  a ]);       if (mn[s[i] -  a ][ind - 1] > b) {         cout <<  No n ;         return 0;       }     }     cout <<  Yes n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int T, n, k;   long long ans, p;   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d%d , &n, &k);       ans = 0;       p = 1;       for (int i = 0; i <= 31; i++) {         if (((long long)(1 << i) & k) != 0) ans = (ans + p) % MOD;         p = p * n % MOD;       }       printf( %lld n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   template <typename T>   inline T lowbit(T x) {     return x & -x;   }   const int N = 2e5 + 10;   int n, m;   int q;   int res;   int les[N], more[N];   bool vis[N];   void solve() {     cin >> n >> m;     while (m--) {       int u, v;       scanf( %d%d , &u, &v);       if (u > v)         les[u]++, more[v]++;       else         les[v]++, more[u]++;     }     for (int i = 1; i <= n; ++i) {       if (!more[i]) res++, vis[i] = 1;     }     cin >> q;     while (q--) {       int x;       scanf( %d , &x);       int a, b;       if (x == 1) {         scanf( %d%d , &a, &b);         if (a > b)           les[a]++, more[b]++;         else           les[b]++, more[a]++;         if (vis[a] && more[a]) vis[a] = 0, res--;         if (vis[b] && more[b]) vis[b] = 0, res--;       }       if (x == 2) {         scanf( %d%d , &a, &b);         if (a > b)           les[a]--, more[b]--;         else           les[b]--, more[a]--;         if (!vis[a] && !more[a]) res++, vis[a] = 1;         if (!vis[b] && !more[b]) res++, vis[b] = 1;       }       if (x == 3) {         cout << res << endl;       }     }   }   signed main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int nmax = 100005;   const long long inf = 1e9;   const double eps = 1e-6;   long long dp[1005][1005];   long long gp[1005][1005];   long long a[1005][1005];   long long rdp[1005][1005];   long long rgp[1005][1005];   int main() {     ios_base::sync_with_stdio(0);     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         cin >> a[i][j];       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];       }     }     for (int i = n; i; --i) {       for (int j = m; j; --j) {         rdp[i][j] = max(rdp[i][j + 1], rdp[i + 1][j]) + a[i][j];       }     }     for (int i = n; i; --i) {       for (int j = 1; j <= m; ++j) {         gp[i][j] = max(gp[i + 1][j], gp[i][j - 1]) + a[i][j];       }     }     for (int i = 1; i <= n; ++i) {       for (int j = m; j; --j) {         rgp[i][j] = max(rgp[i - 1][j], rgp[i][j + 1]) + a[i][j];       }     }     long long ans = 0;     for (int i = 2; i < n; ++i) {       for (int j = 2; j < m; ++j) {         ans =             max(ans, dp[i][j - 1] + rdp[i][j + 1] + gp[i + 1][j] + rgp[i - 1][j]);         ans =             max(ans, dp[i - 1][j] + rdp[i + 1][j] + gp[i][j - 1] + rgp[i][j + 1]);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e5 + 5;   template <typename T>   void chkmax(T& x, T y) {     if (y > x) x = y;   }   template <typename T>   void chkmin(T& x, T y) {     if (y < x) x = y;   }   int N, c[MAXN];   long long ans;   int main() {     scanf( %d , &N);     for (int i = 1; i <= N; ++i) scanf( %d , &c[i]);     for (int i = 1; i <= N; i += 2) {       long long minv = 0, sum = 0;       for (int j = i + 1; j <= N; ++j) {         long long l = -sum - c[i], r = -sum - max(1ll, -minv);         if (j % 2 == 1)           chkmax(l, 1ll), chkmin(r, (long long)c[j]);         else           chkmax(l, (long long)-c[j]), chkmin(r, -1ll);         ans += max(0ll, r - l + 1);         sum += j % 2 == 1 ? c[j] : -c[j];         chkmin(minv, sum);       }     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   char s1[N], s2[N], s[N];   int n, lst, nod, len[N], fail[N], diff[N], anc[N], ch[N][26];   int f[N], pos[N], pre[N];   void init() {     fail[0] = fail[1] = nod = 1;     len[1] = -1;   }   void extend(int c, int i) {     int p = lst;     while (s[i - len[p] - 1] != s[i]) p = fail[p];     if (!ch[p][c]) {       int x = ++nod, k = fail[p];       while (s[i - len[k] - 1] != s[i]) k = fail[k];       fail[x] = ch[k][c];       ch[p][c] = x;       len[x] = len[p] + 2;       diff[x] = len[x] - len[fail[x]];       anc[x] = (diff[x] == diff[fail[x]]) ? anc[fail[x]] : fail[x];     }     lst = ch[p][c];   }   int main() {     scanf( %s%s , s1 + 1, s2 + 1);     n = strlen(s1 + 1);     init();     for (int i = 1; i <= n * 2; i++) s[i] = (i & 1) ? s1[(i + 1) / 2] : s2[i / 2];     for (int i = 1; i <= n * 2; i++) f[i] = 1e9;     for (int i = 1; i <= n * 2; i++) {       extend(s[i] -  a , i);       for (int k = lst; k; k = anc[k]) {         pos[k] = i - len[anc[k]] - diff[k];         if (anc[k] != fail[k] && f[pos[fail[k]]] < f[pos[k]])           pos[k] = pos[fail[k]];         if (!(i & 1) && f[i] > f[pos[k]] + 1)           f[i] = f[pos[k]] + 1, pre[i] = pos[k];       }       if (!(i & 1) && s[i] == s[i - 1] && f[i - 2] <= f[i])         f[i] = f[i - 2], pre[i] = i - 2;     }     if (f[n * 2] >= 1e9) return puts( -1 ), 0;     printf( %d n , f[n * 2]);     for (int i = n * 2; i; i = pre[i])       if (i - pre[i] > 2) printf( %d %d n , pre[i] / 2 + 1, i >> 1);   }
#include <bits/stdc++.h>   using namespace std;   int grid[33][33];   int main() {     int test;     scanf( %d , &test);     for (int _T = 1; _T <= test; _T++) {       int n, m;       cin >> n >> m;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           cin >> grid[i][j];         }       }       int ans = 0;       for (int dist = 0; dist < (n + m - 1) / 2; dist++) {         int cnt1 = 0, cnt2 = 0;         for (int i = 0; i < n; i++) {           for (int j = 0; j < m; j++) {             if (i + j == dist) {               cnt1 += (grid[i][j] == 0);               cnt2 += (grid[i][j] == 1);             }           }         }         for (int i = 0; i < n; i++) {           for (int j = 0; j < m; j++) {             if ((n - 1 - i) + (m - 1 - j) == dist) {               cnt1 += (grid[i][j] == 0);               cnt2 += (grid[i][j] == 1);             }           }         }         ans += min(cnt1, cnt2);       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, ave1, ave2, ans1, ans2;   int a[567890], sum;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), sum += a[i];     sort(a + 1, a + n + 1);     int ave1 = sum / n;     if (ave1 * n == sum)       ave2 = ave1;     else       ave2 = ave1 + 1;     for (int i = 1; i <= n; i++) {       if (a[i] < ave1) ans1 += (ave1 - a[i]);       if (a[i] > ave2) ans2 += (a[i] - ave2);     }     printf( %d , ans1 > ans2 ? ans1 : ans2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int GCD(int a, int b) {     if (b == 0) return a;     return (a % b == 0 ? b : GCD(b, a % b));   }   long long int POW(long long int base, long long int exp) {     long long int val;     val = 1;     while (exp > 0) {       if (exp % 2 == 1) {         val = (val * base) % 1000000007;       }       base = (base * base) % 1000000007;       exp = exp / 2;     }     return val;   }   vector<int> fib;   vector<int> ans;   int main() {     int s, k, i, n;     long long till;     scanf( %d%d , &s, &k);     fib.push_back(1);     till = 1;     for (i = 1; fib[i - 1] <= s; i++) {       fib.push_back(till);       if (i >= k) {         till = till + fib[i] - fib[i - k];       } else {         till = till + fib[i];       }     }     n = fib.size();     ans.push_back(0);     for (i = n - 1; i >= 1; i--) {       if (s >= fib[i]) {         s = s - fib[i];         ans.push_back(fib[i]);       }     }     n = ans.size();     printf( %d n , n);     for (i = 0; i < n; i++) {       printf( %d  , ans[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, m;     scanf( %d %d , &n, &m);     int c[n], a[m];     int i;     for (i = 0; i < n; i++) {       scanf( %d , &c[i]);     }     for (i = 0; i < m; i++) {       scanf( %d , &a[i]);     }     int j = 0, count = 0;     int t = 0;     for (i = 0; i < m;) {       if (j >= n) break;       for (j = t; j < n; j++) {         if (i >= m) {           break;         }         if (a[i] >= c[j]) {           i = i + 1;           t = j + 1;           count = count + 1;         }       }     }     printf( %d n , count);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   int c[maxn], ans[maxn];   int k, n, maxb, t;   int b[maxn];   void update(int x, int d) {     for (; x <= maxb; x += x & -x) {       if (d > c[x]) c[x] = d;     }   }   int get(int x) {     int ans = 0;     for (; x > 0; x -= x & -x)       if (c[x] > ans) ans = c[x];     return ans;   }   void solve() {     if (t >= maxb) {       sort(b, b + n);       cout << unique(b, b + n) - b << endl;     } else {       int x;       memset(c, 0, sizeof(c));       memset(ans, 0, sizeof(ans));       for (int i = 0; i < t; i++) {         for (int j = 0; j < n; j++) {           x = get(b[j] - 1) + 1;           if (x > ans[j]) {             ans[j] = x;             update(b[j], x);           }         }       }       cout << *max_element(ans, ans + n) << endl;     }   }   int main() {     cin >> k >> n >> maxb >> t;     for (int i = 0; i < k; i++) {       for (int j = 0; j < n; j++) scanf( %d , b + j);       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 10;   int e[maxn], ne[maxn], h[maxn], idx = 0;   int sz[maxn];   int ans = 0;   void add(int a, int b) {     e[idx] = b, ne[idx] = h[a];     h[a] = idx++;   }   void dfs(int now, int fa) {     sz[now] = 1;     for (int i = h[now]; i != -1; i = ne[i]) {       int j = e[i];       if (j == fa) continue;       dfs(j, now);       sz[now]++;     }   }   int dfs2(int now, int fa) {     int d1 = 0, d2 = 0;     for (int i = h[now]; i != -1; i = ne[i]) {       int j = e[i];       if (j == fa) continue;       int d = dfs2(j, now);       if (d > d1)         d2 = d1, d1 = d;       else if (d > d2)         d2 = d;     }     if (d1 >= 1 && d2 >= 1) {       if (now != 1)         ans = max(ans, d1 + d2 + sz[now] - 1);       else         ans = max(ans, d1 + d2 + sz[now] - 2);     } else if (d2 == 0 && d1 >= 1) {       if (now != 1)         ans = max(ans, d1 + sz[now]);       else         ans = max(ans, d1 + sz[now] - 1);     }     return (d1 == 0 ? 1 : d1 + sz[now] - 1);   }   int main() {     int t;     scanf( %d , &t);     memset(h, -1, sizeof h);     while (t--) {       int n;       scanf( %d , &n);       idx = 0;       ans = 0;       for (int i = 1; i <= n - 1; i++) {         int a, b;         scanf( %d%d , &a, &b);         add(a, b);         add(b, a);       }       dfs(1, -1);       dfs2(1, -1);       cout << ans << endl;       for (int i = 1; i <= n; i++) h[i] = -1, sz[i] = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int sum = 0, mx = 0;     node *left = nullptr, *right = nullptr;     node *getLeft() {       if (left == nullptr) left = new node;       return left;     }     node *getRight() {       if (right == nullptr) right = new node;       return right;     }     void setValue(int k, int v, int a = 0, int b = 1 << 30) {       if (b == a + 1)         mx = sum = v;       else if (k < (a + b) / 2) {         getLeft()->setValue(k, v, a, (a + b) / 2);         mx = ::max(mx, left->mx + sum);       } else {         getRight()->setValue(k, v, (a + b) / 2, b);         mx = ::max(mx, right->mx + sum);       }     }     void insert(int pa, int pb, int a = 0, int b = 1 << 30) {       if (a >= pb || b <= pa) return;       if (a >= pa && b <= pb) {         sum++;         mx++;       } else {         mx = 0;         if (left) {           left->insert(pa, pb, a, (a + b) / 2);           mx = ::max(mx, left->mx);         }         if (right) {           right->insert(pa, pb, (a + b) / 2, b);           mx = ::max(mx, right->mx);         }         mx += sum;       }     }     int max(int pa, int pb, int a = 0, int b = 1 << 30) {       if (a >= pb || b <= pa) return 0;       if (a >= pa && b <= pb) return mx;       int ans = 0;       if (left) ans = ::max(ans, left->max(pa, pb, a, (a + b) / 2));       if (right) ans = ::max(ans, right->max(pa, pb, (a + b) / 2, b));       return ans + sum;     }   };   int main() {     int n, r, h, t;     node *tree = new node;     priority_queue<pair<int, int> > pq;     scanf( %d %d , &n, &r);     for (int i = 0; i < n; i++) {       scanf( %d %d , &h, &t);       if (t < 0) continue;       h = max(h, 0);       pq.push(make_pair(-t, -h));       pq.push(make_pair(-h, 2));       pq.push(make_pair(-(t + 1), 2));     }     int prev = -1;     while (!pq.empty()) {       int a = -pq.top().second, b = -pq.top().first;       pq.pop();       if (a < 0) {         if (b == prev) continue;         int v = tree->max(0, b - r + 1);         if (a == -2 || v > tree->max(prev, prev + 1)) {           tree->setValue(b, v);           prev = b;           if (b + r <= 1000000000) pq.push(make_pair(-(b + r), 1));         }       } else         tree->insert(a, b + 1);       if (tree->mx > n) puts( wtf );     }     printf( %d n , tree->mx);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   const double eps = 0.01;   void solution() {     int n;     cin >> n;     vector<int> h(n + 1);     map<pair<int, int>, int> data;     map<pair<int, int>, int>::iterator iter;     for (int i = 1; i <= n; i++) {       cin >> h[i];       data[make_pair(h[i], i)]++;     }     vector<pair<int, int> > coll;     int place = 0;     for (iter = data.begin(); iter != data.end(); iter++) {       for (int j = 0; j < iter->second; j++) {         place++;         coll.push_back(make_pair(place, iter->first.second));       }     }     for (int i = 0; i < n; i++) {       if (coll[i].first > coll[i].second) {         swap(coll[i].first, coll[i].second);       }     }     sort(coll.begin(), coll.end());     int L = coll[0].first;     int R = coll[0].second;     int answer = 0;     for (int i = 1; i < n; i++) {       int l2 = coll[i].first;       int r2 = coll[i].second;       if (l2 <= R) {         R = max(R, r2);       } else {         L = l2;         R = r2;         answer++;       }     }     cout << answer + 1 <<   n ;   }   void include_file() {     freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);   }   int main() {     solution();     return 0;   }
#include <bits/stdc++.h>   int grid[1001][1001];   int start[100000];   int main(void) {     int n, m, k;     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         scanf( %d , &grid[i][j]);       }     }     for (int i = 0; i < k; i++) {       scanf( %d , &start[i]);     }     for (int i = 0; i < k; i++) {       int r = 1;       int c = start[i];       while (r <= n) {         int rr, cc;         switch (grid[r][c]) {           case 1:             rr = r;             cc = c + 1;             break;           case 2:             rr = r + 1;             cc = c;             break;           case 3:             rr = r;             cc = c - 1;             break;         }         grid[r][c] = 2;         r = rr;         c = cc;       }       printf( %d  , c);     }   }
#include <bits/stdc++.h>   using namespace std;   static const double EPS = 1e-10;   const int MODULO = 1000000007;   typedef struct {     int i, m, v;   } P;   vector<P> mv;   bool mLt(const P& x, const P& y) {     return (x.m != y.m) ? less<int>()(x.m, y.m) : less<int>()(x.v, y.v);   }   int n, k, h;   bool C(double t) {     int i = 1;     for (__typeof__((mv).begin()) it = (mv).begin(); it != (mv).end(); ++it) {       if ((double)i * h <= (*it).v * t) i++;       if (i > k) break;     }     return i > k;   }   int main() {     cin >> n >> k >> h;     mv.resize(n);     for (int i = 0; i < n; i++) mv[i].i = i + 1;     for (int i = 0; i < n; i++) cin >> mv[i].m;     for (int i = 0; i < n; i++) cin >> mv[i].v;     sort(mv.begin(), mv.end(), mLt);     double l = 0, r = 1e10;     double t;     for (int i = 0; i < 100; i++) {       t = (l + r) / 2;       if (C(t))         r = t;       else         l = t;     }     int cnt = 1;     for (__typeof__((mv).begin()) it = (mv).begin(); it != (mv).end(); ++it) {       if ((double)cnt * h <= (*it).v * t * (1 + EPS)) {         printf( %d  , (*it).i);         cnt++;       }       if (cnt > k) break;     }     puts(  n );     return 0;   }