func_code_string: #include <bits/stdc++.h>   using namespace std;   struct om_nom {     int t;     int h;     int m;   } a[2005];   int n, x;   bool eaten[2005];   bool have_candy(int type) {     int flag = false;     for (int i = 0; i < n; ++i)       if (a[i].t == (bool)type && !eaten[i]) {         flag = true;         break;       }     return flag;   }   int solve(int cur, int H) {     int cnt = 0;     for (int i = 0; i < n; ++i) {       eaten[i] = false;     }     while (have_candy(cur)) {       int mm = -1, it = -1;       for (int i = 0; i < n; ++i)         if (a[i].t == cur && a[i].m > mm && a[i].h <= H && !eaten[i]) {           it = i;           mm = a[i].m;         }       if (it != -1) {         H += a[it].m;         cur ^= 1;         eaten[it] = true;       } else         break;       cnt++;     }     return cnt;   }   int main() {     cin >> n >> x;     for (int i = 0; i < n; ++i) {       cin >> a[i].t >> a[i].h >> a[i].m;     }     cout << max(solve(0, x), solve(1, x)) << endl;     return 0;   }   