n,V,c = map(int,input().split()) vw = [list(map(int,input().split())) for _ in range(n)] dp = [-1] * (V+1) dp[0] = 0 for v,w in vw: n_dp = [-1] * (V+1) for i in range(V+1): if dp[i] >= 0: if i + v <= V: n_dp[i+v] = max(n_dp[i+v],dp[i] + w+c) for i in range(V+1): if n_dp[i] >= 0: if i + v <= V: n_dp[i+v] = max(n_dp[i+v],n_dp[i] + w) for i in range(V+1): n_dp[i] = max(dp[i],n_dp[i]) # print(n_dp) dp = n_dp[::] print(max(dp))