func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long maxn = 100000 + 5;   const long long inf = 9e17;   long long ans = inf, l, r, mid1, mid2;   vector<long long> g[maxn], v;   long long n, m;   inline long long cost(long long mid) {     long long cnt = mid - g[0].size(), tmp = 0;     v.clear();     for (int i = 1; i <= m; i++) {       for (int j = 0; j < g[i].size(); j++) {         if (g[i].size() - j >= mid) {           --cnt;           tmp += g[i][j];         } else           v.push_back(g[i][j]);       }     }     sort(v.begin(), v.end());     for (int i = 0; i < cnt; i++) tmp += v[i];     return tmp;   }   int main() {     long long a, b;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a >> b;       m = max(m, a);       g[a].push_back(b);     }     for (int i = 0; i <= m; i++) sort(g[i].begin(), g[i].end());     l = g[0].size(), r = n;     while (l < r) {       mid1 = (l + l + r) / 3;       mid2 = (l + r + r) / 3;       if (cost(mid1) > cost(mid2)) {         if (l == mid1)           break;         else           l = mid1;       } else {         if (r == mid2)           break;         else           r = mid2;       }     }     ans = inf;     for (int i = l; i <= r; i++) ans = min(ans, cost(i));     cout << ans <<   n ;     return 0;   }   