func_code_string: #include <bits/stdc++.h>   using namespace std;   int Szukaj(vector<int>& moje, vector<bool>& jest, int x) {     int nr = -1;     for (int i = 0; i < moje.size(); ++i) {       if (moje[i] >= x && jest[i]) {         if (nr == -1)           nr = i;         else {           if (moje[i] < moje[nr]) nr = i;         }       }     }     return nr;   }   int main() {     ios_base::sync_with_stdio(0);     int n, m;     cin >> n >> m;     vector<int> atk, def;     for (int i = 0; i < n; ++i) {       string op;       int s;       cin >> op >> s;       if (op ==  ATK )         atk.push_back(s);       else         def.push_back(s);     }     vector<int> moje(m);     for (int i = 0; i < m; ++i) cin >> moje[i];     int odp = 0;     sort(atk.begin(), atk.end());     sort(moje.begin(), moje.end());     reverse(moje.begin(), moje.end());     for (int i = 1; i <= min(atk.size(), moje.size()); ++i) {       vector<int> a, b;       for (int j = 0; j < i; ++j) a.push_back(moje[j]);       for (int j = i - 1; j >= 0; --j) b.push_back(atk[j]);       int s = 0;       bool ok = true;       for (int j = 0; j < i; ++j) {         if (a[j] >= b[j])           s += a[j] - b[j];         else           ok = false;       }       if (ok) odp = max(odp, s);     }     bool ok = true;     int s = 0;     vector<bool> jest(moje.size(), true);     sort(def.begin(), def.end());     for (int i = 0; i < def.size(); ++i) {       int nr = Szukaj(moje, jest, def[i] + 1);       if (nr != -1)         jest[nr] = false;       else         ok = false;     }     for (int i = 0; i < atk.size(); ++i) {       int nr = Szukaj(moje, jest, atk[i]);       if (nr != -1) {         jest[nr] = false;         s += moje[nr] - atk[i];       } else         ok = false;     }     for (int i = 0; i < moje.size(); ++i)       if (jest[i]) s += moje[i];     if (ok) odp = max(odp, s);     cout << odp;     return 0;   }   