malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const long long MOD = 998244353;   const int N = 6000;   std::vector<long long> fact(N), revfact(N);   long long Pow(long long a, long long b) {     long long rt = 1;     while (b) {       if (b & 1) rt = (rt * a) % MOD;       a = (a * a) % MOD;       b /= 2;     }     return rt;   }   long long C(int n, int k) {     return (((fact[n] * revfact[k]) % MOD) * revfact[n - k]) % MOD;   }   int main() {     const int n = 3;     std::vector<int> a(n);     for (int i = 0; i < n; i++) std::cin >> a[i];     fact[0] = 1;     for (int i = 1; i < N; i++) {       fact[i] = (fact[i - 1] * 1LL * i) % MOD;     }     for (int i = 0; i < N; i++) {       revfact[i] = Pow(fact[i], MOD - 2);       assert((fact[i] * revfact[i]) % MOD == 1);     }     long long ans = 1;     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         long long cur = 0;         for (int k = 0; k <= std::min(a[i], a[j]); k++) {           cur = (cur + (C(a[i], k) * C(a[j], k) % MOD) * fact[k]) % MOD;         }         ans = (ans * cur) % MOD;       }     }     std::cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, k;     cin >> n >> k;     vector<int> g[n + 1];     for (int i = 0; i < n - 1; ++i) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     vector<vector<int>> dp(n + 1, vector<int>(k + 1));     int ans = 0;     function<void(int, int)> dfs;     dfs = [&](int u, int pre) {       dp[u][0] = 1;       for (auto v : g[u]) {         if (v != pre) {           dfs(v, u);           for (int j = 0; j < k; ++j) {             ans += dp[v][j] * dp[u][k - 1 - j];           }           for (int j = 1; j <= k; ++j) {             dp[u][j] += dp[v][j - 1];           }         }       }     };     dfs(1, 0);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool uin(T &a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <class T>   bool uax(T &a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   int main() {     ios::sync_with_stdio(false);     cout.precision(10);     cout << fixed;     int N, X, Y;     cin >> N >> X >> Y;     for (int i = 0; i < (int)(N); ++i) {       int A;       cin >> A;       long long l = 0, r = 1e18;       while (r - l > 1) {         long long m = (l + r) / 2;         long long hits = m / X + m / Y;         if (hits >= A)           r = m;         else           l = m;       }       if (r % Y == 0 && r % X == 0)         cout <<  Both n ;       else if (r % X)         cout <<  Vanya n ;       else if (r % Y)         cout <<  Vova n ;     }     return 0;   }
#include <bits/stdc++.h>   const long long mod = 1e9 + 7;   using namespace std;   vector<int> par, rnk;   void make_set(int n) {     par[n] = n;     rnk[n] = 0;   }   int find_set(int a) {     if (par[a] == a) return a;     return par[a] = find_set(par[a]);   }   void union_set(int a, int b) {     a = find_set(a);     b = find_set(b);     if (a == b) return;     if (rnk[a] > rnk[b]) {       par[b] = a;     } else if (rnk[a] < rnk[b]) {       par[a] = b;     } else {       par[b] = a;       rnk[a]++;     }   }   void solve() {     int n, a, b;     cin >> n >> a >> b;     par.assign(n, 0);     rnk.assign(n, 0);     if (a != 1 && b != 1) {       cout <<  NO n ;       return;     }     if (a == 1 && b == 1) {       if (n == 2 || n == 3) {         cout <<  NO n ;         return;       }       cout <<  YES n ;       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           if (abs(i - j) == 1)             cout <<  1 ;           else             cout <<  0 ;         }         cout << endl;       }       return;     }     for (int i = 0; i < n; i++) make_set(i);     for (int i = 0; i < n - (max(a, b)); i++) {       union_set(i, i + 1);     }     int flag = 0;     if (a > 1) flag = 1;     cout <<  YES n ;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i == j)           cout <<  0 ;         else if (flag) {           if (find_set(i) == find_set(j))             cout <<  1 ;           else             cout <<  0 ;         } else {           if (find_set(i) != find_set(j))             cout <<  1 ;           else             cout <<  0 ;         }       }       cout << endl;     }   }   int main() {     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int i, a[n];       map<int, pair<int, int> > m;       for (i = 0; i < n; i++) {         cin >> a[i];       }       int vis[n + 1];       memset(vis, -1, sizeof(vis));       for (i = 0; i < n; i++) {         if (m.find(a[i]) == m.end()) {           pair<int, int> p;           p.first = i;           p.second = i + 1;           m[a[i]] = p;         } else {           pair<int, int> p = m[a[i]];           p.second = max(p.second, i - p.first);           p.first = i;           m[a[i]] = p;         }       }       map<int, pair<int, int> >::iterator it;       for (it = m.begin(); it != m.end(); it++) {         pair<int, int> p = it->second;         int i = p.first;         int x = max(p.second, n - i);         if (vis[x] == -1)           vis[x] = it->first;         else           vis[x] = min(vis[x], it->first);       }       for (i = 1; i <= n; i++) {         if (vis[i] == -1)           cout << vis[i] <<    ;         else {           int temp = vis[i];           while (i + 1 <= n && (vis[i + 1] == -1 || vis[i + 1] >= temp)) {             cout << temp <<    ;             i++;           }           cout << temp <<    ;         }       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[300001];   long long an[300001], dp[300001];   struct data {     int x, y, No;     void scan() { scanf( %d%d , &x, &y); }     bool operator<(data b) const {       if (y < b.y) return 0;       if (y > b.y) return 1;       int r1 = x % y, r2 = b.x % y;       if (r1 < r2) return 0;       if (r1 > r2) return 1;       return No < b.No;     }   } d[300001];   int main() {     int n, i, j, k, mi, p;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     scanf( %d , &p);     for (i = 0; i < p; i++) d[i].scan(), d[i].No = i;     sort(d, d + p);     for (i = 0; i < p; i += j) {       int tmp = d[i].x % d[i].y;       mi = n;       for (j = 0; i + j < p; j++) {         if (d[i].y != d[i + j].y || d[i + j].x % d[i].y != tmp) break;         mi = min(mi, d[i + j].x);       }       k = d[i].x + (n - d[i].x) / d[i].y * d[i].y;       dp[k] = a[k];       for (k -= d[i].y; k >= mi; k -= d[i].y) dp[k] = a[k] + dp[k + d[i].y];       for (k = 0; k < j; k++) an[d[i + k].No] = dp[d[i + k].x];     }     for (i = 0; i < p; i++) printf( %I64d n , an[i]);   }
#include <bits/stdc++.h>   using namespace std;   int a[100000], b, c, n, m, x, y, z, s;   int main() {     cin >> a[0] >> a[1] >> n;     if (n <= 1)       cout << a[n];     else {       for (int i = 2; i <= n; i++) {         a[i] = a[i - 1] + a[i - 2];       }       cout << a[n];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cnt[105];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     long long a[n];     for (long long i = 0; i < n; i++) cin >> a[i];     long long ans = 0;     while (m--) {       long long l, r;       cin >> l >> r;       l--;       r--;       long long sm = 0;       for (long long i = l; i <= r; i++) sm += a[i];       if (sm > 0) ans += sm;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T in() {     char ch;     T n = 0;     bool ng = false;     while (1) {       ch = getchar();       if (ch ==  - ) {         ng = true;         ch = getchar();         break;       }       if (ch >=  0  && ch <=  9 ) break;     }     while (1) {       n = n * 10 + (ch -  0 );       ch = getchar();       if (ch <  0  || ch >  9 ) break;     }     return (ng ? -n : n);   }   template <typename T>   inline T POW(T B, T P) {     if (P == 0) return 1;     if (P & 1)       return B * POW(B, P - 1);     else       return (POW(B, P / 2) * POW(B, P / 2));   }   template <typename T>   inline T Gcd(T a, T b) {     if (a < 0) return Gcd(-a, b);     if (b < 0) return Gcd(a, -b);     return (b == 0) ? a : Gcd(b, a % b);   }   template <typename T>   inline T Lcm(T a, T b) {     if (a < 0) return Lcm(-a, b);     if (b < 0) return Lcm(a, -b);     return a * (b / Gcd(a, b));   }   long long Bigmod(long long base, long long power, long long MOD) {     long long ret = 1;     while (power) {       if (power & 1) ret = (ret * base) % MOD;       base = (base * base) % MOD;       power >>= 1;     }     return ret;   }   bool isVowel(char ch) {     ch = toupper(ch);     if (ch ==  A  || ch ==  U  || ch ==  I  || ch ==  O  || ch ==  E )       return true;     return false;   }   template <typename T>   long long int isLeft(T a, T b, T c) {     return (a.x - b.x) * (b.y - c.y) - (b.x - c.x) * (a.y - b.y);   }   long long ModInverse(long long number, long long MOD) {     return Bigmod(number, MOD - 2, MOD);   }   bool isConst(char ch) {     if (isalpha(ch) && !isVowel(ch)) return true;     return false;   }   int toInt(string s) {     int sm;     stringstream second(s);     second >> sm;     return sm;   }   int n;   double a[19][19];   double dp[19][(1 << 18) + 10];   int vs[19][(1 << 18) + 10];   int lm;   double Solve(int w, int m) {     if (m == lm) {       if (w == 0) return 1.0;       return 0.0;     }     double &res = dp[w][m];     if (vs[w][m]) return res;     vs[w][m] = 1;     res = 0.0;     for (int i = 0; i < n; i++) {       if ((m & (1 << i)) == 0) {         double aa = a[w][i] * Solve(w, (m | (1 << i)));         aa += a[i][w] * Solve(i, (m | (1 << i)));         res = max(res, aa);       }     }     return res;   }   int main() {     cin >> n;     lm = (1 << n) - 1;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) cin >> a[i][j];     if (n == 1) {       printf( 1.00 n );       return 0;     } else if (n == 2) {       printf( %.10lf n , a[0][1]);       return 0;     }     double ans = 0.0;     for (int j = 0; j < n; j++) {       for (int i = j + 1; i < n; i++) {         double aa = a[j][i] * Solve(j, (1 << j) | (1 << i));         aa += a[i][j] * Solve(i, (1 << i) | (1 << j));         ans = max(aa, ans);       }     }     printf( %.10lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> e[100005];   int used[100005];   void bfs(int x) {     queue<int> q;     while (!q.empty()) q.pop();     q.push(x);     used[x] = 1;     while (!q.empty()) {       int p = q.front();       q.pop();       for (int i = 0; i < e[p].size(); i++) {         if (e[p][i]) {           if (!used[e[p][i]]) {             if (used[p] == 1)               used[e[p][i]] = 2;             else               used[e[p][i]] = 1;             q.push(e[p][i]);           }         }       }     }   }   int main() {     int n, x, y;     while (~scanf( %d , &n)) {       for (int i = 0; i < n - 1; i++) {         scanf( %d%d , &x, &y);         e[x].push_back(y);         e[y].push_back(x);       }       memset(used, 0, sizeof(used));       bfs(1);       long long ans1 = 0, ans2 = 0;       for (int i = 1; i <= n; i++) {         if (used[i] == 1)           ans1++;         else           ans2++;       }       printf( %I64d n , ans2 * ans1 - (n - 1));     }     return 0;   }
#include <bits/stdc++.h>   int main() {     char a[8][8];     char x, y;     int i, j, b = 0;     for (i = 0; i < 8; i++)       for (j = 0; j < 8; j++) a[i][j] = 1;     scanf( %c%c , &x, &y);     x -=  a ;     y -=  1 ;     a[x][y] = 0;     for (i = 0; i < 8; i++) {       a[x][i] = 0;       a[i][y] = 0;     }     if (x >= 2 && y >= 1) a[x - 2][y - 1] = 0;     if (x >= 1 && y >= 2) a[x - 1][y - 2] = 0;     if (x >= 2 && y <= 6) a[x - 2][y + 1] = 0;     if (x >= 1 && y <= 5) a[x - 1][y + 2] = 0;     if (x <= 5 && y >= 1) a[x + 2][y - 1] = 0;     if (x <= 6 && y >= 2) a[x + 1][y - 2] = 0;     if (x <= 5 && y <= 6) a[x + 2][y + 1] = 0;     if (x <= 6 && y <= 5) a[x + 1][y + 2] = 0;     while (1) {       scanf( %c , &x);       if (x ==   n ) break;     }     scanf( %c%c , &x, &y);     x -=  a ;     y -=  1 ;     a[x][y] = 0;     if (x >= 2 && y >= 1) a[x - 2][y - 1] = 0;     if (x >= 1 && y >= 2) a[x - 1][y - 2] = 0;     if (x >= 2 && y <= 6) a[x - 2][y + 1] = 0;     if (x >= 1 && y <= 5) a[x - 1][y + 2] = 0;     if (x <= 5 && y >= 1) a[x + 2][y - 1] = 0;     if (x <= 6 && y >= 2) a[x + 1][y - 2] = 0;     if (x <= 5 && y <= 6) a[x + 2][y + 1] = 0;     if (x <= 6 && y <= 5) a[x + 1][y + 2] = 0;     for (i = 0; i < 8; i++)       for (j = 0; j < 8; j++) b += a[i][j];     printf( %d , b);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     int a, b, c, d;     cin >> a >> b >> c >> d;     if (a + b <= max(c, d))       cout <<  Polycarp ;     else if (a <= c && b <= d)       cout <<  Polycarp ;     else       cout <<  Vasiliy ;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n;     int a[105];     scanf( %d , &n);     int B, C;     B = 0;     C = 0;     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       if (a[i] < 0)         C += a[i];       else         B += a[i];     }     printf( %d n , B - C);   }
#include <bits/stdc++.h>   using namespace std;   long long n, r, l[210000], t[210000], ans, a[110000], b, x, y, c;   int main() {     scanf( %I64d%I64d , &n, &r);     for (int i = 1; i <= n; i++) scanf( %I64d , &l[i]);     for (int i = 1; i <= n; i++) scanf( %I64d , &t[i]);     for (int i = 1; i <= n; i++)       if (t[i] < l[i]) {         printf( -1 n );         return 0;       }     b = 0;     c = 0;     for (int i = 1; i <= n; i++) {       if (l[i] <= b) {         b -= l[i];         c += l[i];       } else {         l[i] -= b;         t[i] -= b;         c += b;         b = 0;         x = 2 * l[i] - t[i];         if (x > 0) {           y = (x - 1) / r + 1;           if (ans + y <= 100000) {             for (int j = 1; j <= y; j++) a[++ans] = c + t[i] - x + r * (j - 1);           } else             ans += y;           b = (r - x % r) % r;           c += t[i];         } else           c += 2 * l[i];       }     }     printf( %I64d n , ans);     if (ans <= 100000) {       for (int i = 1; i < ans; i++) printf( %I64d  , a[i]);       if (ans) printf( %I64d , a[ans]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int s[1005];   int main() {     int n, m, h;     scanf( %d%d%d , &n, &m, &h);     int sum = 0;     for (int i = 1; i <= m; i++) {       scanf( %d , &s[i]);       sum += s[i];     }     if (sum < n) {       printf( -1 n );       return 0;     }     long double ans = 1;     long double down = sum - 1;     long double up = sum - s[h];     for (int i = 1; i <= n - 1; i++) {       ans = ans * up / down;       up--, down--;     }     printf( %.20Lf n , 1 - ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     vector<long long> h(n + 5);     vector<long long> deg(n + 5, 0), a(n + 5, 0);     for (long long i = 1; i <= n; i++) cin >> h[i];     for (long long i = 1; i <= n; i++) cin >> a[i], deg[a[i]]++;     long long c = -1;     long long maxi = 0;     for (long long i = 1; i <= n; i++) {       if (h[i] == 1) {         long long x = a[i];         long long cnt = 1;         while (x > 0 && deg[x] == 1) cnt++, x = a[x];         if (cnt > maxi) {           maxi = cnt;           c = i;         }       }     }     vector<long long> temp;     temp.push_back(c);     c = a[c];     while (c > 0 && deg[c] == 1) temp.push_back(c), c = a[c];     long long l = (long long)temp.size();     cout << l <<   n ;     for (long long i = l - 1; i >= 0; i--) cout << temp[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const int mxs = 2e5 + 7;   int n;   int a[mxs];   int l[mxs];   int r[mxs];   int ans[mxs];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = n; i; i--) {       l[i] = i;       while (a[i] <= a[l[i] + 1]) l[i] = l[l[i] + 1];     }     for (int i = 1; i <= n; i++) {       r[i] = i;       while (a[i] <= a[r[i] - 1]) r[i] = r[r[i] - 1];     }     for (int i = 1; i <= n; i++) {       int res = l[i] - r[i] + 1;       ans[res] = max(ans[res], a[i]);     }     for (int i = n; i; i--) ans[i] = max(ans[i], ans[i + 1]);     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:64000000 )   const int maxn = 200200;   const int inf = 1000000007;   const int mod = 1000000007;   const int dx[4] = {1, -1, 0, 0};   const int dy[4] = {0, 0, 1, -1};   double pr[maxn];   double pw(double x, int k) {     if (k == 1) return x;     double ans = pw(x, k / 2);     ans = ans * ans;     if (k % 2 == 1) ans = ans * x;     return ans;   }   int main() {     int n, m;     while (scanf( %d%d , &n, &m) == 2) {       pr[n + 1] = 0;       double ans = 0;       for (int i = n; i >= 1; i--) {         pr[i] = 1 - pw((double)(i - 1) / n, m);         ans += i * (pr[i] - pr[i + 1]);       }       printf( %.10lf n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> nums;   int mod[100];   char in[1000010];   int cnt[100];   int main() {     int i, j, k;     nums.push_back(1);     nums.push_back(6);     nums.push_back(8);     nums.push_back(9);     sort(nums.begin(), nums.end());     do {       int sum = 0;       for (i = 0; i < 4; i++) {         sum *= 10;         sum += nums[i];       }       mod[sum % 7] = sum;     } while (next_permutation(nums.begin(), nums.end()));     int ok = 1;     int n;     scanf( %s , in);     n = strlen(in);     for (i = 0; i < n; i++) {       cnt[in[i] -  0 ]++;     }     for (i = 0; i < 4; i++) {       cnt[nums[i]]--;     }     int now = 0;     for (i = 9; i >= 1; i--) {       while (cnt[i]--) {         now *= 10;         now += i;         now %= 7;         printf( %d , i);       }     }     now *= 10000;     now %= 7;     printf( %d , mod[(7 - now) % 7]);     while (cnt[i]--) {       printf( %d , i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5;   const long long mod = 998244353;   long long a[N];   long long n, m, k;   long long pw(long long n, long long k) {     if (!k) return 1;     long long res = pw(n, k >> 1);     res = res * res % mod;     if (k & 1) return res * n % mod;     return res;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m >> k;     for (long long i = 1; i <= m; i++) {       cin >> a[i];     }     long long ans = 1;     for (long long i = 1; i <= m; i++) {       long long num = a[i] - a[i - 1];       (ans *= pw(k, 2 * num) + pw(k, num)) %= mod;       if (ans < 0) ans += mod;     }     (ans *= pw(k, n - 2 * a[m])) %= mod;     (ans *= pw(pw(2, m), mod - 2)) %= mod;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) {       long long a, b;       cin >> a >> b;       long long c = a ^ b;       a = a & c;       b = b & c;       cout << a + b <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> a;   int n, j;   string s;   map<long long, int> f;   long long h(string s) {     long long res = 0;     for (int i = 0; i < s.length(); i++) res = res * 28 + (s[i] -  a ) + 1;     return res;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       cin >> s;       a.push_back(s);     }     long long j;     for (int i = n - 1; i >= 0; i--) {       j = h(a[i]);       f[j]++;       if (f[j] == 1) cout << a[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b) {       return a;     } else {       return b;     }   }   long long min(long long a, long long b) {     if (a < b) {       return a;     } else {       return b;     }   }   vector<string> split(const string& s, char c) {     vector<string> v;     stringstream ss(s);     string x;     while (getline(ss, x, c)) v.emplace_back(x);     return move(v);   }   void err(vector<string>::iterator it) {}   template <typename T, typename... Args>   void err(vector<string>::iterator it, T a, Args... args) {     cerr << it->substr((*it)[0] ==    , it->length()) <<   =   << a <<  ,  ;     err(++it, args...);   }   template <typename T>   struct number_iterator : std::iterator<random_access_iterator_tag, T> {     T v;     number_iterator(T _v) : v(_v) {}     operator T&() { return v; }     T operator*() const { return v; }   };   template <typename T>   struct number_range {     T b, e;     number_range(T b, T e) : b(b), e(e) {}     number_iterator<T> begin() { return b; }     number_iterator<T> end() { return e; }   };   template <typename T>   number_range<T> range(T e) {     return number_range<T>(1, e + 1);   }   template <typename T>   number_range<T> range(T b, T e) {     return number_range<T>(b, e + 1);   }   long long c(long long len, long long b) {     long long base = 1, tot = 0;     for (int i = (1); i <= (len); i++) {       if (i != b) tot += base;       base *= 2;     }     return tot;   }   long long f(long long d) {     if (d <= 1) return 0;     long long res = 0;     for (int i = (1); i <= (60); i++) {       for (int j = (1); j <= (i - 1); j++) {         if (c(i, j) <= d) res++;       }     }     return res;   }   int main() {     long long a, b;     cin >> a >> b;     long long ff = f(b) - f(a - 1);     cout << ff << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct ilter {     int job;     long long ti;     bool operator<(const ilter &a) const { return a.ti > ti; }   } T[100001];   int s, c;   long long TIME;   int main() {     map<int, int> M2;     int n, k;     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> T[i].job;       M2[T[i].job]++;     }     for (int i = 0; i < n; i++) {       cin >> T[i].ti;       ;     }     s = k - M2.size();     if (s == 0)       return cout << 0, 0;     else {       sort(T, T + n);       for (int i = 0; i < n; i++) {         if (M2[T[i].job] > 1) {           TIME += T[i].ti;           M2[T[i].job]--;           c++;         }         if (c == s) break;       }       cout << TIME;     }     return 0;   }
#include <bits/stdc++.h>   const double EPS = 1e-9;   const int MAX_REPS = 2000;   double bx, by, h, r;   void solve(double x, double& y1, double& y2, double& y3) {     double A1, A2, B1, B2, C1, C2, dy1, dy2, dx, dy;     dx = -(x - bx);     dy = ((h - r) - by);     A1 = -dy;     B1 = dx;     C1 = A1 * x + B1 * (h - r);     y1 = C1 / B1;     A2 = -B1;     B2 = A1;     C2 = B2 * y1;     dy1 = ((C1 - A1) / B1) - (C1 / B1);     dy2 = ((C2 - A2) / B2) - (C2 / B2);     assert(dy1 > 0);     assert(dy2 < 0);     A1 = dy1 - dy2;     B1 = sqrt(1 + dy2 * dy2);     y2 = y1 + A1 / B1 * (B1 + r) - A1;     y3 = y1 + A1 / B1 * (B1 - r) - A1;   }   int main(void) {     int i;     double yl, yh, frl, tol, frh, toh, mi, bc, bh, bl;     std::cin >> yl >> yh >> h >> bx >> by >> r;     frh = 0;     toh = bx - r / 2;     for (i = 0; i < MAX_REPS && fabs(frh - toh) >= EPS; ++i) {       mi = (frh + toh) / 2;       solve(mi, bc, bh, bl);       if (bh >= yh) {         frh = mi;       } else {         toh = mi;       }     }     frl = 0;     tol = bx - r / 2;     for (i = 0; i < MAX_REPS && fabs(frl - tol) >= EPS; ++i) {       mi = (frl + tol) / 2;       solve(mi, bc, bh, bl);       if (bc - r <= yl) {         tol = mi;       } else {         frl = mi;       }     }     mi = (frl + frh) / 2;     solve(mi, bc, bh, bl);     if (bc - r < yl || bh > yh) {       std::cout <<  -1  << std::endl;     } else {       std::cout << (frl + frh) / 2 << std::endl;     }     return 0;   }