func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1 << 16;   int n, xa, xb, a[20], b[20], ca[N], cb[N], f[N][140], ans = 0x7fffffff;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     char c;     for (int i = 1; i <= n; i++) {       cin >> c >> a[i] >> b[i];       xa += a[i], xb += b[i];       for (int j = 0; j < (1 << n); j++)         if (j & (1 << i - 1)) {           if (c ==  R )             ca[j]++;           else             cb[j]++;         }     }     memset(f, -1, sizeof(f));     f[0][0] = 0;     for (int i = 0; i < (1 << n); i++)       for (int j = 0; j <= 130; j++)         if (f[i][j] != -1)           for (int k = 1; k <= n; k++)             if (!(i & (1 << k - 1))) {               int ti = i | (1 << (k - 1)), sa = min(a[k], ca[i]),                   sb = min(b[k], cb[i]);               f[ti][j + sa] = max(f[ti][j + sa], f[i][j] + sb);             }     for (int i = 0; i <= 130; i++)       if (f[(1 << n) - 1][i] != -1)         ans = min(ans, max(xa - i, xb - f[(1 << n) - 1][i]));     cout << ans + n;     return 0;   }   