func_code_string: #include <bits/stdc++.h>   using namespace std;   bool ex[100];   int att[100];   int de[100];   int jo[100];   int n, m, n1, n2;   int ae() {     int ina = 0;     int inb = 0;     pair<int, bool> mi[200];     for (int i = 0; i < n1; i++) mi[i].first = att[i], mi[i].second = 0;     for (int i = n1; i < n1 + m; i++) {       mi[i].first = jo[i - n1], mi[i].second = 1;     }     sort(mi, mi + m + n1);     int v = 0;     int y = 0;     for (int i = 0; i < n1 + m; i++) {       if (mi[i].second == 0)         v++;       else if (v) {         v--;         y++;       }     }     int v1 = 0;     int vt = 0;     for (int i = 0; i < y; i++) {       vt = jo[m - i - 1] - att[i];       if (vt > 0) v1 += vt;     }     return v1;   }   bool di() {     int in1 = 0;     int in2 = 0;     while (true) {       if (in2 == n2) return true;       if (in1 == m) return false;       while (jo[in1++] <= de[in2]) {         if (in1 == m) return false;       }       in1--;       ex[in1] = 1;       in1++, in2++;     }   }   bool di2() {     int in1 = 0;     int in2 = 0;     while (true) {       if (in2 == n1) return true;       if (in1 == m) return false;       while (ex[in1++] == 1)         ;       in1--;       if (in1 == m) return 0;       while (jo[in1++] < att[in2]) {         if (in1 == m) return false;       }       in1--;       in1++, in2++;     }   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       string s;       int t;       cin >> s >> t;       if (s[0] ==  A ) {         att[n1++] = t;       } else {         de[n2++] = t;       }     }     for (int i = 0; i < m; i++) cin >> jo[i];     sort(jo, jo + m);     sort(de, de + n2);     sort(att, att + n1);     int m1 = 0;     if (di() && di2()) {       for (int i = 0; i < m; i++)         if (!(ex[i] == 1)) m1 += jo[i];       for (int i = 0; i < n1; i++) m1 -= att[i];     }     cout << max(m1, ae());     return 0;   }   