func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   long long ans, dp[N];   int ed, n, m;   struct node {     int w, c;     double val;     node(int a = 0, int b = 0) : w(a), c(b) {}     bool operator<(const node &b) const { return val > b.val; }   } a[N], tmp[N];   long long DP() {     for (int i = 1; i <= ed; i++) {       for (int j = m; j >= tmp[i].w; j--) {         dp[j] = max(dp[j], dp[j - tmp[i].w] + tmp[i].c);       }     }     return dp[m];   }   int main() {     scanf( %d%d , &n, &m);     ans = 0;     for (int i = 1; i <= n; i++)       scanf( %d%d , &a[i].w, &a[i].c), a[i].val = 1.0 * a[i].c / a[i].w;     sort(a + 1, a + 1 + n);     int tp[4];     memset(tp, -1, sizeof(tp));     for (int i = 1; i <= n; i++) {       if (m < 30) {         ed = 0;         while (i <= n) tmp[++ed] = a[i], i++;         for (int ii = 1; ii <= 3; ii++)           if (~tp[ii]) tmp[++ed] = node(ii, tp[ii]), m += ii, ans -= tp[ii];         ans += DP();         break;       }       ans += a[i].c;       m -= a[i].w;       tp[a[i].w] = a[i].c;     }     printf( %lld n , ans);     return 0;   }   