func_code_string: #include <bits/stdc++.h>   using namespace std;   struct candy {     candy(int t, int h, int m) {       this->type = t;       this->height = h;       this->mass = m;     }     int type;     int height;     int mass;     bool operator<(const candy &c) const { return this->mass < c.mass; }     bool operator>(const candy &c) const { return this->height < c.height; }   };   int amount(int first, vector<candy> &all_candies, int x) {     priority_queue<candy> candies0, candies1;     int all_candies_index = 0;     int max_height = x;     int last_taken = 1 - first;     int amount_taken = 0;     while (true) {       while (all_candies_index < all_candies.size()) {         if (all_candies[all_candies_index].height > max_height) {           break;         }         if (all_candies[all_candies_index].type == 0) {           candies0.push(all_candies[all_candies_index]);         } else {           candies1.push(all_candies[all_candies_index]);         }         all_candies_index++;       }       if (last_taken) {         if (candies0.empty()) {           break;         }         amount_taken++;         max_height += candies0.top().mass;         candies0.pop();         last_taken = 0;       } else {         if (candies1.empty()) {           break;         }         amount_taken++;         max_height += candies1.top().mass;         candies1.pop();         last_taken = 1;       }     }     return amount_taken;   }   int main() {     int n, x;     scanf( %d%d , &n, &x);     vector<candy> all_candies;     for (int i = 0; i < n; ++i) {       int t, h, m;       scanf( %d%d%d , &t, &h, &m);       all_candies.push_back(candy(t, h, m));     }     sort(all_candies.begin(), all_candies.end(), std::greater<candy>());     printf( %d n , max(amount(0, all_candies, x), amount(1, all_candies, x)));     return 0;   }   