#include using namespace std; constexpr std::int32_t INF = 1 << 30; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N, V, C; cin >> N >> V >> C; vector A(N), B(N); for (int i = 0; i < N; i++) { cin >> A[i] >> B[i]; } vector dp(V + 1, -INF); dp[0] = 0; for (int i = 0; i < N; i++) { for (int j = V; j-- > 0;) { if (j + A[i] > V) continue; dp[j + A[i]] = max(dp[j + A[i]], dp[j] + B[i] + C); } for (int j = 0; j + A[i] <= V; j++) { dp[j + A[i]] = max(dp[j + A[i]], dp[j] + B[i]); } } cout << *ranges::max_element(dp) << '\n'; return 0; }