func_code_string: #include <bits/stdc++.h>   using namespace std;   struct item {     string n, c;     int a, s;   };   item make(string n, string c, int a, int s) {     item z;     z.a = a;     z.c = c;     z.n = n;     z.s = s;     return z;   }   struct rez {     string n, t, h;     int b;   };   bool f2(rez a, rez b) { return a.b > b.b; }   struct equip {     string n;     vector<string> r;     int s;   };   int n, k, s, ya[3], yb[3];   item a[3][100];   rez b[3][1000];   equip z[3];   int sum(int h, int l) {     int sss = 0;     for (int i = 0; i < l; i++) sss += b[h][i].b;     return sss;   }   int main() {     string name, clas;     int atk, def, rz, siz;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> name >> clas >> atk >> def >> rz >> siz;       if (clas ==  weapon ) {         a[0][ya[0]] = make(name, clas, atk, siz);         ya[0]++;       }       if (clas ==  armor ) {         a[1][ya[1]] = make(name, clas, def, siz);         ya[1]++;       }       if (clas ==  orb ) {         a[2][ya[2]] = make(name, clas, rz, siz);         ya[2]++;       }       s += siz;     }     cin >> k;     rez y;     for (int i = 0; i < k; i++) {       cin >> y.n >> y.t >> y.b >> y.h;       if (y.t ==  gladiator ) {         b[0][yb[0]] = y;         yb[0]++;       }       if (y.t ==  sentry ) {         b[1][yb[1]] = y;         yb[1]++;       }       if (y.t ==  physician ) {         b[2][yb[2]] = y;         yb[2]++;       }     }     for (int h = 0; h < 3; h++) sort(b[h], b[h] + yb[h], f2);     if (s == k) {       for (int h = 0; h < 3; h++) {         int mx = -1, m;         for (int i = 0; i < ya[h]; i++) {           int ss = 0;           for (int j = 0; j < yb[h]; j++)             if (b[h][j].h == a[h][i].n) ss += b[h][j].b;           if (ss + a[h][i].a > mx) {             mx = ss + a[h][i].a;             m = i;           }         }         z[h].n = a[h][m].n;         for (int i = 0; i < 3; i++)           for (int j = 0; j < yb[i]; j++)             if (b[i][j].h == z[h].n) z[h].r.push_back(b[i][j].n);       }     } else {       int m[3];       for (int h = 0; h < 3; h++) {         int mx = -1, mm, l;         for (int i = 0; i < ya[h]; i++) {           int sm = sum(h, min(a[h][i].s, yb[h]));           if (a[h][i].a + sm > mx) {             mx = a[h][i].a + sm;             mm = i;             l = min(a[h][i].s, yb[h]);           }         }         z[h].n = a[h][mm].n;         z[h].s = a[h][mm].s;         for (int i = 0; i < l; i++) z[h].r.push_back(b[h][i].n);         m[h] = l;       }       for (int h = 0; h < 3; h++)         for (int i = 0; i < 3; i++)           while (m[i] < yb[i] && z[h].r.size() < z[h].s) {             z[h].r.push_back(b[i][m[i]].n);             m[i]++;           }     }     for (int i = 0; i < 3; i++) {       cout << z[i].n <<     << z[i].r.size();       for (int j = 0; j < z[i].r.size(); j++) cout <<     << z[i].r[j];       cout << endl;     }     return 0;   }   