func_code_string: #include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   void PLAY() {     cout << fixed << setprecision(10);     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int num_cost[100005];   int mp[205][100005];   int freq_cum[100005];   int freq[100005];   int main() {     PLAY();     int n;     cin >> n;     vector<int> v(n);     set<int> st;     for (int i = 0; i < n; i++) {       cin >> v[i];       freq_cum[v[i]]++;       freq[v[i]]++;       st.insert(v[i]);     }     for (int i = 0; i < n; i++) {       int d;       cin >> d;       num_cost[v[i]] += d;       mp[d][v[i]]++;     }     vector<int> srtd(st.begin(), st.end());     sort(srtd.rbegin(), srtd.rend());     for (int i = 1; i < 100005; i++) {       num_cost[i] += num_cost[i - 1];       freq_cum[i] += freq_cum[i - 1];     }     for (int i = 1; i <= 200; i++)       for (int j = 1; j < 100005; j++) mp[i][j] += mp[i][j - 1];     int res = INT_MAX;     for (int i = 0; i < (int)srtd.size(); i++) {       int num = srtd[i];       int cur_cost = num_cost[srtd[0]] - num_cost[srtd[i]];       int removed = freq_cum[srtd[0]] - freq_cum[num];       int rem = n - removed;       int remove = max(0, rem - (freq[num] * 2 - 1));       for (int cost = 1; cost <= 200 && remove; cost++) {         int avilable = mp[cost][num - 1] - mp[cost][0];         int cnt = min(remove, avilable);         cur_cost += cnt * cost;         remove -= cnt;       }       res = min(res, cur_cost);     }     cout << res << endl;     return 0;   }   