func_code_string: #include <bits/stdc++.h>   using namespace std;   char BUFFER[100000 + 5];   bool readn(int &n) { return scanf( %d , &n) == 1; }   bool readl(long long &n) { return scanf( %I64d , &n) == 1; }   bool readd(double &n) { return scanf( %lf , &n) == 1; }   bool reads(string &s) {     s =   ;     int n = scanf( %s , BUFFER);     if (n == 1) s = BUFFER;     return n == 1;   }   bool readln(string &s) {     char *valid = gets(BUFFER);     if (valid) s = BUFFER;     return ((bool)valid);   }   void Print(long long &n, bool printNewLine = true) {     printNewLine ? printf( %I64d n , n) : printf( %I64d , n);   }   const int maxn = 1e5 + 10;   int carry[maxn], f[maxn], d[maxn];   int anscnt = 0, ansfuel = 0;   int N, D, F;   vector<int> a, b;   void calc() {     int i, j, sum = 0;     for (i = 0; i < N; ++i)       if (d[i] >= D)         if (carry[i] > 0)           a.push_back(f[i]);         else           b.push_back(f[i]);     sort(a.begin(), a.end());     sort(b.begin(), b.end());     for (i = 0; i < ((int)b.size()); ++i) {       sum += b[i];       if (sum > F) break;       anscnt = i + 1;       ansfuel = sum;     }     if (0 == ((int)a.size()) || a[0] > F) return;     int C = 0;     for (i = 0; i < N; ++i) {       C += carry[i];       C = min(C, N);     }     sum = a[0];     i = 1;     j = 0;     while (1) {       if (sum > F) break;       int cnt = min(i + j + C, N);       if (cnt > anscnt || (cnt == anscnt && sum < ansfuel)) {         anscnt = cnt;         ansfuel = sum;       }       if (i == a.size() && j == b.size()) break;       if (i < a.size() && (j == b.size() || a[i] < b[j])) {         sum += a[i];         i++;       } else {         sum += b[j];         j++;       }     }   }   int main() {     int i;     cin >> N >> D >> F;     for (i = 0; i < N; ++i) cin >> carry[i] >> f[i] >> d[i];     calc();     cout << anscnt <<     << ansfuel << endl;     return 0;   }   