func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1 << 16;   map<pair<int, int>, int> dp[maxn];   int n, c[20], r[20], b[20], ed, rrr, bbb, ans = 0x3f3f3f3f;   int main() {     cin >> n;     getchar();     for (int i = 1; i <= n; i++) {       char ch;       cin >> ch >> r[i] >> b[i];       if (ch ==  R ) c[i] = 1;     }     ed = (1 << n) - 1;     dp[0][pair<int, int>(0, 0)] = 0;     for (int i = 0; i <= ed; i++) {       int rr = 0, bb = 0;       for (int t = 0; t < n; t++)         if (i & (1 << t)) ++(c[t + 1] ? rr : bb);       for (int j = 0; j < n; j++) {         if (i & (1 << j)) continue;         for (auto it : dp[i]) {           int next = i | (1 << j), need = 0;           if (it.first.first < max(r[j + 1] - rr, 0))             need = max(need, r[j + 1] - rr - it.first.first);           if (it.first.second < max(b[j + 1] - bb, 0))             need = max(need, b[j + 1] - bb - it.first.second);           int rmr = it.first.first + need - max(r[j + 1] - rr, 0),               rmb = it.first.second + need - max(b[j + 1] - bb, 0);           if (!dp[next].count(pair<int, int>(rmr, rmb)))             dp[next][pair<int, int>(rmr, rmb)] = 0x3f3f3f3f;           dp[next][pair<int, int>(rmr, rmb)] =               min(dp[next][pair<int, int>(rmr, rmb)], it.second + need);         }       }     }     for (auto it : dp[ed]) ans = min(ans, it.second);     cout << ans + n << endl;     return 0;   }   