func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n;     vector<int> one;     vector<int> two;     cin >> n;     for (int i = 0; i < n; i++) {       int t, w;       cin >> t >> w;       if (t == 1)         one.push_back(w);       else         two.push_back(w);     }     sort(one.begin(), one.end());     sort(two.begin(), two.end());     vector<int> pref_one = {0};     vector<int> pref_two = {0};     for (int i = 1; i <= one.size(); i++) {       int val = one[i - 1] + pref_one[i - 1];       pref_one.push_back(val);     }     for (int i = 1; i <= two.size(); i++) {       int val = two[i - 1] + pref_two[i - 1];       pref_two.push_back(val);     }     int res = 1000000;     for (int i = 0; i <= one.size(); i++) {       for (int j = 0; j <= two.size(); j++) {         bool possible = false;         int ans = i + 2 * j;         int w_one = pref_one[one.size() - i];         int w_two = pref_two[two.size() - j];         if (ans >= (w_one + w_two)) possible = true;         if (possible) res = min(res, ans);       }     }     cout << res << endl;   }   