func_code_string: #include <bits/stdc++.h>   using namespace std;   int p1[400010], p2[400010], p3[400010], p0[400010];   int cnt1, cnt2, cnt3, cnt0;   inline bool cmp(const int a, const int b) { return a > b; }   int main() {     int n;     cin >> n;     for (int i = 1, a, b, va; i <= n; i++) {       scanf( %1d%1d %d , &a, &b, &va);       if (a + b == 0)         p0[++cnt0] = va;       else if (a + b == 2)         p3[++cnt3] = va;       else if (a == 1)         p1[++cnt1] = va;       else         p2[++cnt2] = va;     }     sort(p1 + 1, p1 + 1 + cnt1, cmp);     sort(p2 + 1, p2 + 1 + cnt2, cmp);     long long ans = 0;     int fl = 0;     if (cnt2 < cnt1) swap(cnt2, cnt1), fl = 1;     for (int i = 1; i <= cnt1; i++) {       ans += p2[i] + p1[i];     }     if (fl)       for (int i = cnt1 + 1; i <= cnt2; i++) p0[++cnt0] = p1[i];     else       for (int i = cnt1 + 1; i <= cnt2; i++) p0[++cnt0] = p2[i];     sort(p0 + 1, p0 + 1 + cnt0, cmp);     for (int i = 1; i <= cnt3; i++) {       ans += p0[i] + p3[i];     }     cout << ans;     return 0;   }   