import sys input = lambda: sys.stdin.readline().rstrip() # ----------------------- # n, V, C = map(int, input().split()) vw = [list(map(int, input().split())) for _ in range(n)] dp = [[0]*(V+1) for _ in range(n+1)] dp[0][0] = 0 for i in range(n): v, w = vw[i] for j in range(V+1): dp[i+1][j] = max(dp[i+1][j], dp[i][j]) if j-v >= 0: dp[i+1][j] = max(dp[i+1][j], dp[i][j-v]+w+C) for j in range(V+1): if j-v >= 0: dp[i+1][j] = max(dp[i+1][j], dp[i+1][j-v]+w) print(max(dp[n]))