func_code_string: #include <bits/stdc++.h>   using namespace std;   priority_queue<pair<int, int> > a;   priority_queue<pair<int, int> > b;   vector<pair<int, int> > A;   vector<pair<int, int> > B;   int main() {     int n, x;     scanf( %d%d , &n, &x);     int x0 = x;     for (int i = 0; i < n; i++) {       int t;       int h, m;       scanf( %d%d%d , &t, &h, &m);       if (t == 0)         A.push_back(pair<int, int>(h, m));       else         B.push_back(pair<int, int>(h, m));     }     int pa = 0, push_back = 0;     sort(A.begin(), A.end());     sort(B.begin(), B.end());     int ans = 0;     while (pa < A.size() && A[pa].first <= x)       a.push(pair<int, int>(A[pa].second, A[pa].first)), pa++;     while (push_back < B.size() && B[push_back].first <= x)       b.push(pair<int, int>(B[push_back].second, B[push_back].first)),           push_back++;     int nn = 0;     int cur = 0;     while (nn < 2) {       pair<int, int> k;       if (cur == 0) {         if (a.size() == 0) {           nn++;           continue;         }         k = a.top();         a.pop();       }       if (cur == 1) {         if (b.size() == 0) {           nn++;           continue;         }         k = b.top();         b.pop();       }       x += k.first;       ans++;       while (pa < A.size() && A[pa].first <= x)         a.push(pair<int, int>(A[pa].second, A[pa].first)), pa++;       while (push_back < B.size() && B[push_back].first <= x)         b.push(pair<int, int>(B[push_back].second, B[push_back].first)),             push_back++;       cur ^= 1;       nn = 0;     }     int ans2 = 0;     cur = 1;     nn = 0;     while (a.size()) a.pop();     while (b.size()) b.pop();     pa = push_back = 0;     x = x0;     while (pa < A.size() && A[pa].first <= x)       a.push(pair<int, int>(A[pa].second, A[pa].first)), pa++;     while (push_back < B.size() && B[push_back].first <= x)       b.push(pair<int, int>(B[push_back].second, B[push_back].first)),           push_back++;     while (nn < 2) {       pair<int, int> k;       if (cur == 0) {         if (a.size() == 0) {           nn++;           continue;         }         k = a.top();         a.pop();       }       if (cur == 1) {         if (b.size() == 0) {           nn++;           continue;         }         k = b.top();         b.pop();       }       x += k.first;       ans2++;       while (pa < A.size() && A[pa].first <= x)         a.push(pair<int, int>(A[pa].second, A[pa].first)), pa++;       while (push_back < B.size() && B[push_back].first <= x)         b.push(pair<int, int>(B[push_back].second, B[push_back].first)),             push_back++;       cur ^= 1;       nn = 0;     }     printf( %d n , max(ans, ans2));   }   