func_code_string: #include <bits/stdc++.h>   using namespace std;   int N, A, ni, ai;   string si;   vector<int> hero;   vector<string> moves;   vector<int> player;   bool used[22][(int)(1 << 20)];   int dp[22][(int)(1 << 20)];   int BAD = 99999999;   int memo(int a, int b) {     if (used[a][b]) return dp[a][b];     if (a == A) return 0;     int res = -BAD;     for (int i = 0; i < A; ++i) {       if ((b & (1 << i)) > 0) continue;       int add = hero[i];       if (moves[a] ==  p ) {         if (player[a] % 2 == 0) {           add *= -1;           if (res == -BAD)             res = add + memo(a + 1, b + (1 << i));           else             res = min(res, add + memo(a + 1, b + (1 << i)));         } else {           if (res == -BAD)             res = add + memo(a + 1, b + (1 << i));           else             res = max(res, add + memo(a + 1, b + (1 << i)));         }       } else {         if (player[a] % 2 == 0) {           if (res == -BAD)             res = memo(a + 1, b + (1 << i));           else             res = min(res, memo(a + 1, b + (1 << i)));         } else {           if (res == -BAD)             res = memo(a + 1, b + (1 << i));           else             res = max(res, memo(a + 1, b + (1 << i)));         }       }     }     used[a][b] = true;     dp[a][b] = res;     return dp[a][b];   }   void solve() { cout << memo(0, 0) << endl; }   int main() {     cin >> N;     for (int i = 0; i < N; ++i) {       cin >> ni;       hero.push_back(ni);     }     sort(hero.begin(), hero.end());     reverse(hero.begin(), hero.end());     cin >> A;     for (int i = 0; i < A; ++i) {       cin >> si;       cin >> ai;       moves.push_back(si);       player.push_back(ai);     }     solve();   }   