func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, a, b, ans;   vector<long long> v[100005];   vector<long long> res;   long long cost(long long num) {     res.clear();     long long sum = 0;     long long need = num - v[0].size();     for (long long i = 1; i <= 100000; i++) {       for (long long j = 0; j < v[i].size(); j++) {         if (v[i].size() - j >= num) {           need--;           sum += v[i][j];         } else           res.push_back(v[i][j]);       }     }     sort(res.begin(), res.end());     for (long long i = 1; i <= need; i++) {       sum += res[i - 1];     }     return sum;   }   int main() {     scanf( %lld , &n);     for (long long i = 1; i <= n; i++) {       scanf( %lld%lld , &a, &b);       v[a].push_back(b);     }     for (long long i = 1; i <= 100000; i++) sort(v[i].begin(), v[i].end());     long long l = v[0].size(), r = n, m1, m2;     ans = min(cost(l), cost(r));     while (l + 2 < r) {       m1 = l + (r - l) / 3;       m2 = r - (r - l) / 3;       long long a1 = cost(m1);       long long a2 = cost(m2);       if (a1 > a2)         l = m1, ans = min(ans, a2);       else         r = m2, ans = min(ans, a1);     }     printf( %lld n , ans);     return 0;   }   