def solve():

    N, T, S = list(map(int, input().split()))

    a = [tuple(map(int, input().split())) for _ in [0]*N]

    dp = [float("-inf")]*(T+1)

    dp[0] = 0



    for fun, mise_time in a:

        for prev_time in range(T-mise_time, -1, -1):

            from_fun, to_fun = dp[prev_time], dp[prev_time+mise_time]

            new_time = prev_time + mise_time

            new_fun = fun + from_fun

            if prev_time < S < new_time:

                new_time = S + mise_time

                if new_time > T:

                    continue

                to_fun = dp[new_time]

            if new_fun > to_fun:

                dp[new_time] = new_fun



    print((max(dp)))





if __name__ == "__main__":

    solve()
def solve():

    N, T, S = list(map(int, input().split()))

    a = [tuple(map(int, input().split())) for _ in [0]*N]

    dp = [float("-inf")]*(T+1)

    dp[0] = 0



    for fun, mise_time in a:

        for prev_time, to_fun in zip(list(range(T-mise_time, -1, -1)), dp[::-1]):

            new_time = prev_time + mise_time

            new_fun = fun + dp[prev_time]

            if prev_time < S < new_time:

                new_time = S + mise_time

                if new_time > T:

                    continue

                to_fun = dp[new_time]

            if new_fun > to_fun:

                dp[new_time] = new_fun



    print((max(dp)))





if __name__ == "__main__":

    solve()
def solve():
    N, T, S = list(map(int, input().split()))
    a = [tuple(map(int, input().split())) for _ in [0] * N]
    dp = [float("-inf")] * (T + 1)
    dp[0] = 0
    for fun, mise_time in a:
        for prev_time in range(T - mise_time, -1, -1):
            from_fun, to_fun = dp[prev_time], dp[prev_time + mise_time]
            new_time = prev_time + mise_time
            new_fun = fun + from_fun
            if prev_time < S < new_time:
                new_time = S + mise_time
                if new_time > T:
                    continue
                to_fun = dp[new_time]
            if new_fun > to_fun:
                dp[new_time] = new_fun
    print((max(dp)))


if __name__ == "__main__":
    solve()

def solve():
    N, T, S = list(map(int, input().split()))
    a = [tuple(map(int, input().split())) for _ in [0] * N]
    dp = [float("-inf")] * (T + 1)
    dp[0] = 0
    for fun, mise_time in a:
        for prev_time, to_fun in zip(list(range(T - mise_time, -1, -1)), dp[::-1]):
            new_time = prev_time + mise_time
            new_fun = fun + dp[prev_time]
            if prev_time < S < new_time:
                new_time = S + mise_time
                if new_time > T:
                    continue
                to_fun = dp[new_time]
            if new_fun > to_fun:
                dp[new_time] = new_fun
    print((max(dp)))


if __name__ == "__main__":
    solve()

-        for prev_time in range(T - mise_time, -1, -1): -            from_fun, to_fun = dp[prev_time], dp[prev_time + mise_time] +        for prev_time, to_fun in zip(list(range(T - mise_time, -1, -1)), dp[::-1]): -            new_fun = fun + from_fun +            new_fun = fun + dp[prev_time]