func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   const int maxn = 16;   char tp[maxn];   int r[maxn], b[maxn];   int dp[1 << maxn][2][16 * 16 * 1];   int inf = (int)(1e9);   int go(int msk, int R, int B, int x, int y) {     x = min(x, n * n);     y = min(y, n * n);     if (msk == (1 << n) - 1) return 0;     int &res = dp[msk][y == 0][max(x, y)];     if (res != -1) return res;     res = inf;     for (int i = 0; i < n; i++) {       if (msk & (1 << i)) continue;       int costr = max(0, r[i] - R);       int costb = max(0, b[i] - B);       int needr = max(0, costr - x);       int needb = max(0, costb - y);       int t = max(needr, needb);       res = min(res, t + go(msk | (1 << i), R + (tp[i] ==  R ),                             B + (tp[i] ==  B ), x + t - costr, y + t - costb));     }     return res;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> tp[i] >> r[i] >> b[i];     }     int needr = 0, needb = 0;     for (int i = 0; i < n; i++) {       needr += max(0, r[i] - n);       needb += max(0, b[i] - n);       r[i] = min(r[i], n);       b[i] = min(b[i], n);     }     int t = max(needr, needb);     memset(dp, -1, sizeof(dp));     cout << n + t + go(0, 0, 0, t - needr, t - needb) << endl;     return 0;   }   