#include using namespace std; using ll = long long; using vll = vector; using vvll =vector; #define all(A) A.begin(),A.end() #define rep(i, n) for (ll i = 0; i < (ll) (n); i++) bool chmax(ll& p, ll q) { if (p < q) { p = q; return 1; } else { return 0; } } bool chmin(ll& p, ll q) { if (p > q) { p = q; return 1; } else { return 0; } } int main() { ll N,V,C;cin>>N>>V>>C; vll A(N),B(N); rep(i,N)cin>>A[i]>>B[i]; vvll DP(N+1,vll(V+1,-1e18)); DP[0][0]=0; rep(i,N){ rep(v,V+1){ chmax(DP[i+1][v],DP[i][v]); if(v+A[i]<=V){ chmax(DP[i+1][v+A[i]],DP[i][v]+B[i]+C); } } } vvll DP2(N+1,vll(V+1,-1e18)); DP2[0]=DP[N]; rep(i,N){ rep(v,V+1){ chmax(DP2[i+1][v],DP2[i][v]); if(v+A[i]<=V){ chmax(DP2[i+1][v+A[i]],DP2[i][v]+B[i]); chmax(DP2[i+1][v+A[i]],DP2[i+1][v]+B[i]); } } } ll an=0; rep(v,V+1)chmax(an,DP2[N][v]); cout<