#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint16_t N, I, i, j; cin >> N >> I; vector s(N), a(N); for (i = 0; i != N; ++i) cin >> s[i] >> a[i]; vector dp(I + 1, 0); for (i = 0; i != N; ++i) { for (j = I; j >= s[i]; --j) if (dp[j] < dp[j - s[i]] + a[i]) dp[j] = dp[j - s[i]] + a[i]; } cout << dp[I] << '\n'; return 0; }