import sys input = sys.stdin.readline from collections import * N, V, C = map(int, input().split()) vw = [tuple(map(int, input().split())) for _ in range(N)] dp1 = [0]*(V+1) for i in range(N): v, w = vw[i] for j in range(V, -1, -1): if j-v>=0: dp1[j] = max(dp1[j], dp1[j-v]+w+C) dp2 = [0]*(V+1) for i in range(V+1): for v, w in vw: if i+v<=V: dp2[i+v] = max(dp2[i+v], dp2[i]+w) ans = 0 for i in range(V+1): ans = max(ans, dp1[i]+dp2[V-i]) print(ans)