func_code_string: #include <bits/stdc++.h>   using namespace std;   char c[16];   int r[16], b[16], n;   int memo[1 << 16][16 * 16 + 5][2];   int roll(int mask, int other, int which) {     other = min(other, n * n);     if (mask == ((1 << n) - 1)) {       return 0;     }     int &ans = memo[mask][other][which];     if (~ans) {       return ans;     }     ans = (int)2e9;     int rr = 0, bb = 0;     if (which == 0) {       bb = other;     } else {       rr = other;     }     int R = 0, B = 0;     for (int i = int(0); i < int(n); i++) {       if (mask & (1 << i)) {         R += c[i] ==  R ;         B += c[i] ==  B ;       }     }     for (int i = int(0); i < int(n); i++) {       if (!(mask & (1 << i))) {         int nred = max(0, (r[i] - R) - rr);         int nblue = max(0, (b[i] - B) - bb);         int need = max(nred, nblue);         int nextred = rr + need - max(0, r[i] - R);         int nextblue = bb + need - max(0, b[i] - B);         if (nextred == 0) {           ans = min(ans, roll(mask | (1 << i), nextblue, 0) + need);         }         if (nextblue == 0) {           ans = min(ans, roll(mask | (1 << i), nextred, 1) + need);         }       }     }     return ans;   }   int main() {     scanf( %d%*c , &n);     int nr = 0, nb = 0;     for (int i = int(0); i < int(n); i++) {       scanf( %c %d %d%*c , c + i, r + i, b + i);       nr += max(0, r[i] - n);       nb += max(0, b[i] - n);       r[i] = min(r[i], n);       b[i] = min(b[i], n);     }     memset(memo, -1, sizeof memo);     int ans = 0;     if (nr < nb) {       ans = roll(0, nb - nr, 1);     } else {       ans = roll(0, nr - nb, 0);     }     printf( %d n , ans + max(nr, nb) + n);     return 0;   }   