func_code_string: #include <bits/stdc++.h>   using namespace std;   int num(string s) {     if (s ==  00 ) return 0;     if (s ==  10 ) return 2;     if (s ==  11 ) return 3;     return 1;   }   void solve(int x) {     vector<int> v[4], vv[4];     int n;     cin >> n;     int ans = 0;     for (int i = 0; i < n; i++) {       string s;       int x;       cin >> s >> x;       v[num(s)].push_back(x);       vv[num(s)].push_back(x);     }     for (int i = 0; i < 4; i++) {       sort(vv[i].begin(), vv[i].end(), greater<int>());       sort(v[i].begin(), v[i].end(), greater<int>());       for (int j = 1; j < v[i].size(); j++) v[i][j] += v[i][j - 1];     }     int t1, t2;     int sz = v[3].size();     if (sz) ans += v[3][sz - 1];     t1 = sz;     t2 = sz;     int tot = sz;     sz = min(v[1].size(), v[2].size());     if (sz > 0) ans += v[1][sz - 1] + v[2][sz - 1];     int i = sz, j = sz, k = 0;     t1 += sz;     t2 += sz;     tot += sz + sz;     int mx = 2 * t1 - tot;     vector<int> fin;     while (i < v[1].size()) fin.push_back(vv[1][i++]);     while (j < v[2].size()) fin.push_back(vv[2][j++]);     while (k < v[0].size()) fin.push_back(vv[0][k++]);     sort(fin.begin(), fin.end(), greater<int>());     i = 0;     while (mx && i < fin.size()) {       mx--;       ans += fin[i++];     }     cout << ans;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     int T = t;     while (t--) {       solve(T - t);     }     return 0;   }   