malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n;   double dp[(1 << 20)];   double a[20][20];   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> a[i][j];       }     }     dp[(1 << n) - 1] = 1.0;     for (int st = (1 << n) - 1; st >= 0; st--) {       for (int i = 0; i < n; i++) {         if (st & (1 << i)) {           for (int j = 0; j < n; j++) {             if ((st & (1 << j)) && (i != j)) {               int q = __builtin_popcount(st);               dp[st ^ (1 << j)] += dp[st] * a[i][j] * (1.0 / (q * (q - 1) / 2));             }           }         }       }     }     for (int i = 1; i < (1 << n); i = (i << 1)) {       printf( %.6f  , dp[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   int pr[] = {2, 3, 5, 7, 11, 13, 17, 19};   int big[50000005];   int c[10];   int ans[10100];   int main() {     int k;     scanf( %d , &k);     big[1] = 0;     for (int i = 0; i < 7; i++) big[pr[i]] = i + 1;     for (int i = 2; i <= 2 * k * k; i++) {       if (big[i] == 0) continue;       for (int j = 0; j < 7; j++) {         if (i * pr[j] <= 2 * k * k) {           big[i * pr[j]] = max(big[i], j + 1);         }       }       for (int j = big[i] - 1; j < 7; j++) c[j]++;     }     for (int j = 0; j < 7; j++)       if (c[j] >= k) {         int sz = 0;         for (int i = 2 * k * k; i >= 0; i--)           if (big[i] != 0 && big[i] - 1 <= j &&               big[i / pr[big[i] - 1]] - 1 < big[i] - 1) {             ans[sz++] = i;             if (sz == k) break;           }         if (sz < k) continue;         for (int i = sz - 1; i >= 0; i--) printf( %d  , ans[i]);         printf(  n );         return 0;       }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e7 + 5;   int s[maxn];   int a[maxn];   int main() {     int n;     scanf( %d , &n);     long long ans = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &s[i]);     }     sort(s + 1, s + n + 1);     for (int i = 1; i <= n / 2; i++) {       a[i] = s[i] + s[n + 1 - i];       ans += a[i] * a[i];     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const long double EPS = 1e-9;   long long Power(long long a, long long b) {     if (b == 0) return 1;     long long p = Power(a, b / 2);     p = (p * p);     if (b & 1) {       p = (p * a);     }     return p;   }   long long Gcd(long long a, long long b) {     if (b == 0) return a;     if (a < b) return Gcd(b, a);     return Gcd(b, a % b);   }   void Solve() {     int n, m;     long long l;     cin >> n >> m >> l;     vector<long long> arr(n), seg(n, -1);     for (int i = 0; i < n; i++) cin >> arr[i];     int curr = 0, prev = -1;     for (int i = 0; i < n; i++) {       if (arr[i] > l) {         seg[i] = 0;         if (prev == -1) {           curr++;         }         prev = 0;       } else {         prev = -1;         seg[i] = -1;       }     }     while (m--) {       int t;       cin >> t;       if (t == 0) {         cout << curr <<   n ;       } else {         int p;         long long d;         cin >> p >> d;         p--;         arr[p] += d;         if (seg[p] == -1 && arr[p] > l) {           seg[p] = 0;           if (p == 0) {             if (p + 1 < n && seg[p + 1] == -1) {               curr++;             } else if (n == 1) {               curr++;             }           } else if (p == n - 1) {             if (p - 1 >= 0 && seg[p - 1] == -1) {               curr++;             } else if (n == 1) {               curr++;             }           } else {             if (seg[p - 1] == 0 && seg[p + 1] == 0) {               curr--;             } else if (seg[p - 1] == -1 && seg[p + 1] == -1) {               curr++;             }           }         }       }     }   }   int main() {     int t = 1;     while (t--) {       Solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e4 + 5;   char s[N];   int dp[10][N];   int ans[N];   int len;   int dfs(int num, int idx) {     if (~dp[num][idx]) return dp[num][idx];     if (idx == len)       return 1;     else if (idx > len)       return 0;     int &ret = dp[num][idx];     ret = dfs(num ^ 1, idx + num);     bool flag = false;     for (int i = idx; i < idx + num; ++i) {       if (s[i] != s[i + num]) {         flag = true;         break;       }     }     if (flag) {       ret = max(ret, dfs(num, idx + num));     }     return ret;   }   const int B = 333;   int cal(char a, char b, char c) { return a * B * B + b * B + c; }   int cal(char a, char b) { return a * B * B + b * B; }   void prt(int x) {     printf( %c , x / (B * B));     printf( %c , x % (B * B) / B);     if (x % B) {       printf( %c , x % B);     }     puts(  );   }   int main() {     while (~scanf( %s , s)) {       memset(dp, -1, sizeof(dp));       int cnt = 0;       len = strlen(s);       for (int i = len - 2; i >= 5; --i) {         if (dfs(2, i) == 1) {           ans[cnt++] = (cal(s[i], s[i + 1]));         }         if (dfs(3, i) == 1) {           ans[cnt++] = (cal(s[i], s[i + 1], s[i + 2]));         }       }       sort(ans, ans + cnt);       cnt = unique(ans, ans + cnt) - ans;       printf( %d n , cnt);       for (int i = 0; i < cnt; ++i) {         prt(ans[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long jc[210000], ny[210000];   char s[210000];   int n, f[210000], g[210000], ans;   int C(int n, int m) {     if (m > n) return 0;     return jc[n] * ny[m] % 1000000007 * ny[n - m] % 1000000007;   }   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     for (int i = 1; i <= n; i++) {       f[i] = f[i - 1];       if (s[i] ==  ( ) f[i]++;     }     for (int i = n; i >= 1; i--) {       g[i] = g[i + 1];       if (s[i] ==  ) ) g[i]++;     }     jc[0] = jc[1] = ny[0] = ny[1] = 1;     for (int i = 2; i <= n; i++)       jc[i] = jc[i - 1] * i % 1000000007,       ny[i] = (long long)(-1000000007 / i) * ny[1000000007 % i] % 1000000007;     for (int i = 2; i <= n; i++) ny[i] = ny[i] * ny[i - 1] % 1000000007;     for (int i = 1; i <= n; i++)       if (s[i] ==  ( ) ans = (ans + C(f[i] + g[i] - 1, f[i])) % 1000000007;     ans = (ans + 1000000007) % 1000000007;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int mod = 1e9 + 7;   const int N = 100 + 10;   inline int add(int x, int y) {     x += y;     if (x >= mod) x -= mod;     return x;   }   inline int mul(int x, int y) {     x = (1LL * x * y) % mod;     return x;   }   vector<pair<int, int> > G[N];   int dp[N][N][30][2];   int f(int i, int j, int last, int turn) {     int &ret = dp[i][j][last][turn];     if (~ret) return ret;     ret = 0;     if (turn == 1) {       for (auto it : G[i]) {         int nxt = it.first;         int ed = it.second;         if (ed >= last) {           int x = f(nxt, j, ed, 0);           if (x == 0) return ret = 1;         }       }     } else {       for (auto it : G[j]) {         int nxt = it.first;         int ed = it.second;         if (ed >= last) {           int x = f(i, nxt, ed, 1);           if (x == 0) return ret = 1;         }       }     }     return ret;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     memset(dp, -1, sizeof(dp));     int n, m;     cin >> n >> m;     for (int i = 0; i <= m - 1; ++i) {       int u, v;       cin >> u >> v;       char c;       cin >> c;       int x = c -  a ;       G[u].push_back({v, x});     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         int curr = f(i, j, 0, 1);         if (curr == 0)           cout <<  B ;         else           cout <<  A ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<long long, pair<long long, long long> > stree[4000005];   char sa[1000005];   void build(long long node, long long start, long long end) {     if (start == end) {       stree[node].first = 0;       stree[node].second.first = 0;       stree[node].second.second = 0;       if (sa[start] ==  ( )         stree[node].second.first = 1;       else if (sa[start] ==  ) )         stree[node].second.second = 1;     } else {       long long mid = (start + end) / 2;       build(2 * node, start, mid);       build(2 * node + 1, mid + 1, end);       long long com =           min(stree[2 * node].second.first, stree[2 * node + 1].second.second);       long long left =           stree[2 * node].second.first + stree[2 * node + 1].second.first - com;       long long right =           stree[2 * node].second.second + stree[2 * node + 1].second.second - com;       stree[node].first = stree[2 * node].first + stree[2 * node + 1].first + com;       stree[node].second.first = left;       stree[node].second.second = right;     }   }   pair<long long, pair<long long, long long> > query(long long node,                                                      long long start,                                                      long long end, long long l,                                                      long long r) {     if (l > end || start > r) return make_pair(0, make_pair(0, 0));     if (l <= start && r >= end) return stree[node];     long long mid = (start + end) / 2;     pair<long long, pair<long long, long long> > p1 =         query(2 * node, start, mid, l, r);     pair<long long, pair<long long, long long> > p2 =         query(2 * node + 1, mid + 1, end, l, r);     long long a = min(p1.second.first, p2.second.second);     long long b = p1.second.first + p2.second.first - a;     long long c = p1.second.second + p2.second.second - a;     return make_pair(p1.first + p2.first + a, make_pair(b, c));   }   int main() {     string str;     cin >> str;     long long n, q;     n = str.length();     cin >> q;     for (long long i = 1; i <= n; i++) sa[i] = str[i - 1];     build(1, 1, n);     while (q-- != 0) {       long long x, y;       cin >> x >> y;       long long ans = 2 * query(1, 1, n, x, y).first;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t, ss, tt;     int bc;     vector<int> res;     cin >> bc >> s >> t;     ss = s;     tt = t;     sort(ss.begin(), ss.end());     sort(tt.begin(), tt.end());     if (ss != tt) {       cout << -1;       return 0;     }     if (!is_permutation(s.begin(), s.end(), t.begin())) return cout << -1, 0;     for (int i = 0; i < t.size(); ++i) {       for (int j = i; j < s.size(); ++j)         if (t[t.size() - i - 1] == s[j]) {           res.insert(res.end(), {(int)s.size(), j, 1});           reverse(s.begin() + j, s.end());           rotate(s.begin(), s.begin() + s.size() - 1, s.end());           break;         }     }     cout << res.size() <<   n ;     for (int i = 0; i < res.size(); i++) {       cout << res[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   typename T::value_type arr_sum(const T& v, int n) {     typename T::value_type sum = 0;     for (int i = 0; i < n; ++i) sum += v[i];     return sum;   }   struct Sync_stdio {     Sync_stdio() {       cin.tie(NULL);       ios_base::sync_with_stdio(false);     }   } _sync_stdio;   int n, m;   vector<string> w(n);   void print_square(int x1, int x2, int y1, int y2) {     for (int i = x1; i < x2 + 1; ++i) {       if (w[i][y1] !=  w ) {         w[i][y1] =  + ;       }       if (w[i][y2] !=  w ) {         w[i][y2] =  + ;       }     }     for (int i = y1; i < y2 + 1; ++i) {       if (w[x1][i] !=  w ) {         w[x1][i] =  + ;       }       if (w[x2][i] !=  w ) {         w[x2][i] =  + ;       }     }     for (auto i : w) {       cout << i <<   n ;     }     exit(0);   }   void check1(vector<pair<int, int> >& v) {     int max1 = -1, min1 = 100001;     int max2 = -1, min2 = 100001;     for (int i = 0; i < v.size(); ++i) {       max1 = max(max1, v[i].first);       min1 = min(min1, v[i].first);       max2 = max(max2, v[i].second);       min2 = min(min2, v[i].second);     }     int left = 0, up = 0, right = 0, down = 0;     for (int i = 0; i < v.size(); ++i) {       if (v[i].first == min1 && min2 < v[i].second && v[i].second < max2) {         up = 1;       }       if (v[i].first == max1 && min2 < v[i].second && v[i].second < max2) {         down = 1;       }       if (v[i].second == min2 && min1 < v[i].first && v[i].first < max1) {         left = 1;       }       if (v[i].second == max2 && min1 < v[i].first && v[i].first < max1) {         right = 1;       }       if (min1 < v[i].first && v[i].first < max1 && min2 < v[i].second &&           v[i].second < max2) {         cout << -1;         exit(0);       }     }     if (max1 == min1) {       up = 0;       down = 0;     }     if (min2 == max2) {       left = 0;       right = 0;     }     if (max1 - min1 == max2 - min2) {       print_square(min1, max1, min2, max2);     }     if (up && down && left && right) {       cout << -1;       exit(0);     }     int diff = (max1 - min1) - (max2 - min2);     if (diff > 0) {       if (!left && max2 + (min1 - max1) >= 0) {         print_square(min1, max1, max2 + (min1 - max1), max2);       }       if (!right && min2 + (max1 - min1) < m) {         print_square(min1, max1, min2, min2 + (max1 - min1));       }       if (!left && !right && max1 - min1 < m) {         print_square(min1, max1, 0, max1 - min1);       }     }     if (diff < 0) {       if (!up && max1 + (min2 - max2) >= 0) {         print_square(max1 + (min2 - max2), max1, min2, max2);       }       if (!down && min1 + (max2 - min2) < n) {         print_square(min1, min1 + (max2 - min2), min2, max2);       }       if (!up && !down && max2 - min2 < n) {         print_square(0, max2 - min2, min2, max2);       }     }     cout << -1;     exit(0);   }   int main() {     cin >> n >> m;     vector<pair<int, int> > v;     for (int i = 0; i < n; ++i) {       string t;       cin >> t;       w.push_back(t);       for (int j = 0; j < m; ++j) {         if (t[j] ==  w ) {           v.push_back({i, j});         }       }     }     check1(v);   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int q;     cin >> q;     while (q--) {       ll a, b, m;       cin >> a >> b >> m;       if (a == b) {         cout << 1 <<     << a <<   n ;         continue;       }       bool f = false;       for (int k = 1; k <= 49 && (1ll << (k - 1)) <= b / a; k++) {         ll t = (1ll << (k - 1)) * a;         ll b_tmp = b - t;         vector<ll> rs(k + 1);         rs[0] = a;         for (int cur = 1; cur <= k; cur++) {           ll pw = (cur == k) ? 1 : (1ll << (k - cur - 1));           rs[cur] = 1;           b_tmp -= pw * rs[cur];         }         if (b_tmp < 0) {           continue;         }         for (int cur = 1; cur <= k; cur++) {           ll pw = (cur == k) ? 1 : (1ll << (k - cur - 1));           ll now = min(m - 1, b_tmp / pw);           b_tmp -= pw * now;           rs[cur] += now;         }         if (b_tmp == 0) {           f = true;           cout << k + 1 <<    ;           vector<ll> ans;           for (int i = 0; i <= k; i++) {             ll cur = rs[i];             for (int j = i - 1; j >= 0; j--) {               cur += ans[j];             }             ans.push_back(cur);             cout << cur <<    ;           }           cout <<   n ;           break;         }       }       if (!f) cout << -1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool check(string s) {     string t = s;     reverse(t.begin(), t.end());     return (s == t);   }   int main() {     string s;     cin >> s;     int l = 0, r = ((int)s.length()) - 1;     set<char> all;     while (l < r) {       all.insert(s[l]);       all.insert(s[r]);       l++;       r--;     }     if (all.size() <= 1) {       cout <<  Impossible  << endl;       return 0;     }     for (int i = 0; i < ((int)s.length()) - 1; i++) {       string fi =   , se =   ;       for (int j = 0; j <= i; j++) fi += s[j];       for (int j = i + 1; j < (int)s.length(); j++) se += s[j];       if (check(se + fi) && (se + fi != s)) {         cout << 1 << endl;         return 0;       }     }     cout << 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T MAX(T a, T b) {     if (a > b) return a;     return b;   }   template <class T>   inline T MIN(T a, T b) {     if (a < b) return a;     return b;   }   template <class T>   inline T ABS(T x) {     if (x < 0) return -x;     return x;   }   inline void OPEN(const string &s) {     freopen((s +  .in ).c_str(),  r , stdin);     freopen((s +  .out ).c_str(),  w , stdout);   }   const static int inf = 1000000000;   int n, m, x, y, z, p;   int a, b;   vector<pair<int, int> > cek;   void rotate90(int &a, int &b, int &r, int &c) {     int tempa = a;     int tempb = b;     a = tempb;     b = r - tempa + 1;     swap(r, c);   }   void flipH(int &a, int &b, int &r, int &c) { b = c - b + 1; }   void rotate(int &a, int &b, int &r, int &c) {     int tempa = a;     int tempb = b;     a = c - tempb + 1;     b = tempa;     swap(r, c);   }   int main() {     scanf( %d%d%d%d%d%d , &n, &m, &x, &y, &z, &p);     for (int(i) = (0); (i) < (p); ++(i)) {       scanf( %d%d , &a, &b);       cek.push_back(make_pair(a, b));     }     x %= 4;     z %= 4;     y %= 2;     for (int(i) = (0); (i) < (cek.size()); ++(i)) {       a = cek[i].first;       b = cek[i].second;       int r = n, c = m;       for (int(j) = (0); (j) < (x); ++(j)) rotate90(a, b, r, c);       for (int(j) = (0); (j) < (y); ++(j)) flipH(a, b, r, c);       for (int(j) = (0); (j) < (z); ++(j)) rotate(a, b, r, c);       printf( %d %d n , a, b);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[] = {0, -1, 0, 1, -1, -1, 1, 1};   const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};   int n, pre = 0;   int a[1005], b[1005], p[1005];   vector<int> num;   bool vis[1005];   bool valid() {     int na = 0;     set<int> st;     for (int j = 0; j < n; ++j) {       if (a[j] == p[j]) ++na;       st.insert(p[j]);     }     return ((st.size()) == n && na == n - 1);   }   int main() {     int v;     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     for (int i = 0; i < n; ++i) {       scanf( %d , &b[i]);       p[i] = b[i];       if (vis[p[i]]) v = p[i];       vis[p[i]] = 1;     }     vis[v] = 0;     for (int i = 0; i < n; ++i)       if (b[i] == v) num.push_back(i);     int tmp1 = p[num[0]], tmp2 = p[num[1]];     for (int j = 1; j <= n; ++j) {       if (!vis[j]) {         vis[j] = 1;         p[num[0]] = j;         for (int k = 1; k <= n; ++k) {           if (!vis[k]) {             vis[k] = 1;             p[num[1]] = k;             break;           }         }         if (valid())           break;         else {           vis[p[num[0]]] = vis[p[num[1]]] = 0;           p[num[0]] = tmp1;           p[num[1]] = tmp2;         }       }     }     for (int i = 0; i < n; ++i) printf( %d  , p[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     if (n % 2 == 0) {       for (int i = 0; i < n - 2; i++) {         cout << s[i];         if (i % 2) {           cout <<  - ;         }       }       cout << s[n - 2] << s[n - 1];     }     if (n % 2) {       for (int i = 0; i < n - 3; i++) {         cout << s[i];         if (i % 2) {           cout <<  - ;         }       }       cout << s[n - 3] << s[n - 2] << s[n - 1];     }   }
#include <bits/stdc++.h>   int C[100005], D[505][505], L[100005], R[100005], Par[100005];   int N, K, M;   using namespace std;   int find(int n) {     if (Par[n] == n)       return n;     else       return Par[n] = find(Par[n]);   }   void join(int a, int b) { Par[find(a)] = find(b); }   int main() {     cin >> N >> M >> K;     for (int i = 1; i <= K; i++) {       int x;       cin >> x;       L[i] = R[i - 1] + 1;       R[i] = L[i] + x - 1;       for (int p = L[i]; p <= R[i]; p++) C[p] = i;     }     for (int i = 1; i <= N; i++) Par[i] = i;     for (int i = 1; i <= K; i++) {       for (int j = 1; j <= K; j++) D[i][j] = 1000000005;       D[i][i] = 0;     }     while (M--) {       int a, b, d;       cin >> a >> b >> d;       if (d == 0) join(a, b);       D[C[a]][C[b]] = min(D[C[a]][C[b]], d);       D[C[b]][C[a]] = min(D[C[b]][C[a]], d);     }     for (int i = 1; i <= K; i++)       for (int p = L[i]; p <= R[i]; p++)         if (find(p) != find(L[i])) {           cout <<  No ;           return 0;         }     for (int k = 1; k <= K; k++)       for (int i = 1; i <= K; i++)         for (int j = 1; j <= K; j++) D[i][j] = min(D[i][j], D[i][k] + D[k][j]);     cout <<  Yes n ;     for (int i = 1; i <= K; i++) {       for (int j = 1; j <= K; j++) {         if (D[i][j] < 1000000005)           cout << D[i][j] <<    ;         else           cout <<  -1  ;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> g[100001], vc;   int judge(int x) {     vc.clear();     int need = x - g[0].size(), ans = 0;     for (int i = 1; i < 100001; i++) {       for (int j = 0; j < g[i].size(); j++) {         if (g[i].size() - j >= x) {           need--;           ans += g[i][j];         } else           vc.push_back(g[i][j]);       }     }     sort(vc.begin(), vc.end());     for (int i = 0; i < need; i++) ans += vc[i];     return ans;   }   int main() {     scanf( %d , &n);     int a, b;     for (int i = 0; i < n; i++) {       scanf( %d%d , &a, &b);       g[a].push_back(b);     }     for (int i = 1; i < 100001; i++) {       sort(g[i].begin(), g[i].end());     }     int l = g[0].size(), r = n;     while (l < r) {       int mid = (l + l + r) / 3, mmid = (l + r + r) / 3;       if (judge(mid) > judge(mmid)) {         if (l == mid)           break;         else           l = mid;       } else {         if (r == mmid)           break;         else           r = mmid;       }     }     int ans = 0x3f3f3f3f;     for (int i = l; i <= r; i++) ans = min(ans, judge(i));     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, y, z;     int sum1 = 0, sum2 = 0, sum3 = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x >> y >> z;       sum1 += x;       sum2 += y;       sum3 += z;     }     if ((sum1 == 0) && (sum2 == 0) && (sum3 == 0)) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, j, n;   void solve() {     int n;     long long l;     cin >> n >> l;     long long a[n];     for (i = 0; i < n; i++) cin >> a[i];     ;     sort(a, a + n);     long long m = 2 * max(a[0], l - a[n - 1]);     for (i = 0; i < n - 1; i++) {       m = max(m, a[i + 1] - a[i]);     }     long double d = 1.0 * m / 2;     cout << setprecision(9) << d;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   const int maxd = 205;   struct Node {     int l, d;   } leg[maxn];   bool operator<(const Node &a, const Node &b) { return a.l > b.l; }   int n, tot[maxd], td = 0, md = 0;   int Solve(int st, int ed) {     int cnt = ed - st;     int res = td;     for (int i = md; i >= 0 && cnt > 0; i--) {       res -= min(cnt, tot[i]) * i;       cnt -= min(cnt, tot[i]);     }     return res;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> leg[i].l;     for (int i = 0; i < n; i++) cin >> leg[i].d;     for (int i = 0; i < n; i++) md = max(md, leg[i].d);     sort(leg, leg + n);     for (int i = 0; i < n; i++) {       tot[leg[i].d]++;       td += leg[i].d;     }     int p = 0;     int res = INT_MAX, tot_d = 0;     while (p < n) {       int p1 = p + 1;       while (p1 < n && leg[p1].l == leg[p].l) p1++;       p1--;       for (int i = p; i <= p1; i++) {         tot[leg[i].d]--;         td -= leg[i].d;       }       int tmp = tot_d + Solve(p, p1);       res = min(tmp, res);       for (int i = p; i <= p1; i++) tot_d += leg[i].d;       p = p1 + 1;     }     cout << res << endl;     return 0;   }