func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAX = 18;   string color[MAX];   int r[MAX], b[MAX];   map<pair<int, int>, int> dp[1 << MAX];   int n;   int func() {     dp[0][make_pair(0, 0)] = 0;     int ans = INT_MAX;     for (int mask = 0; mask < (1 << n); mask++) {       int R = 0, B = 0;       for (int j = 0; j < n; j++)         if (mask & (1 << j)) color[j] ==  R  ? R++ : B++;       for (int i = 0; i < n; i++)         if (!(mask & (1 << i)))           for (auto j : dp[mask]) {             pair<int, int> token = j.first;             int turns = j.second;             pair<int, int> need;             need.first = max(0, r[i] - R);             need.second = max(0, b[i] - B);             int diff = max(max(need.first - token.first, 0),                            max(need.second - token.second, 0));             turns += diff;             need.first = token.first - need.first + diff;             need.second = token.second - need.second + diff;             if (dp[mask | (1 << i)].find(need) == dp[mask | (1 << i)].end())               dp[mask | (1 << i)][need] = INT_MAX;             dp[mask | (1 << i)][need] = min(dp[mask | (1 << i)][need], turns);           }     }     for (auto j : dp[(1 << n) - 1]) ans = min(ans, j.second);     return ans + n;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) cin >> color[i] >> r[i] >> b[i];     cout << func() << endl;     return 0;   }   