Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import sys
sys.setrecursionlimit(10000)

input_lines = []
input_lines.append(raw_input())
N,T,S = [int(x) for x in input_lines[0].split(' ')]
data = []
for i in range(N):
	input_lines.append(raw_input())
	a,b = [int(x) for x in input_lines[i+1].split(' ')]
	data.append([a,b])
dp = [[0 for i in range(T+1)]for j in range(N+1)]
judge = 0
judge2 = 0
def rec(i,t):
	global judge
	global judge2
	if judge2 == 1 and t < T-S:
		judge =1
	if dp[i][t] != 0:
		return dp[i][t]
	if i == N:
		res = 0
	elif t < data[i][1] or (judge == 0 and t - data[i][1] < T-S and data[i][1] > T-S):
		res = rec(i+1,t)
	else:
		if judge == 0 and t - data[i][1] < T-S and data[i][1] <= T-S:
			judge2 = 1
			res = max(rec(i+1,t),rec(i+1,T-S-data[i][1])+data[i][0])
			judge = 0
		else:
			res = max(rec(i+1,t),rec(i+1,t-data[i][1])+data[i][0])
	dp[i][t] = res
	return res

print rec(0,T)

Fixed submission:
# coding: utf-8

input_lines = []
input_lines.append(raw_input())
N,T,S = [int(x) for x in input_lines[0].split(' ')]
data = []
for i in range(N):
	input_lines.append(raw_input())
	a,b = [int(x) for x in input_lines[i+1].split(' ')]
	data.append([a,b])
dp = [[0 for i in range(T+1)]for j in range(N+1)]
judge = 0

for i in range(N-1,-1,-1):
	for j in range(0,T+1):
		#もうこの店で遊べないorSをはじめてまたいで，かつS以降に配置不可能
		if j < data[i][1] or (j > T-S and j - data[i][1] < T-S and data[i][1] > T-S):
			dp[i][j] = dp[i+1][j]
		#Sをはじめてまたいで，かつS以降に配置可能
		elif j > T-S and j - data[i][1] < T-S and data[i][1] <= T-S:
			dp[i][j] = max(dp[i+1][j],dp[i+1][T-S-data[i][1]]+data[i][0])
		else:
			dp[i][j] = max(dp[i+1][j],dp[i+1][j-data[i][1]]+data[i][0])

print dp[0][T]

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import sys
sys.setrecursionlimit(10000)

input_lines = []
input_lines.append(raw_input())
N,T,S = [int(x) for x in input_lines[0].split(' ')]
data = []
for i in range(N):
	input_lines.append(raw_input())
	a,b = [int(x) for x in input_lines[i+1].split(' ')]
	data.append([a,b])
dp = [[0 for i in range(T+1)]for j in range(N+1)]
judge = 0
judge2 = 0
def rec(i,t):
	global judge
	global judge2
	if judge2 == 1 and t < T-S:
		judge =1
	if dp[i][t] != 0:
		return dp[i][t]
	if i == N:
		res = 0
	elif t < data[i][1] or (judge == 0 and t - data[i][1] < T-S and data[i][1] > T-S):
		res = rec(i+1,t)
	else:
		if judge == 0 and t - data[i][1] < T-S and data[i][1] <= T-S:
			judge2 = 1
			res = max(rec(i+1,t),rec(i+1,T-S-data[i][1])+data[i][0])
			judge = 0
		else:
			res = max(rec(i+1,t),rec(i+1,t-data[i][1])+data[i][0])
	dp[i][t] = res
	return res

print rec(0,T)

Fixed submission:
# coding: utf-8

input_lines = []
input_lines.append(raw_input())
N,T,S = [int(x) for x in input_lines[0].split(' ')]
data = []
for i in range(N):
	input_lines.append(raw_input())
	a,b = [int(x) for x in input_lines[i+1].split(' ')]
	data.append([a,b])
dp = [[0 for i in range(T+1)]for j in range(N+1)]
judge = 0

for i in range(N-1,-1,-1):
	for j in range(0,T+1):
		#もうこの店で遊べないorSをはじめてまたいで，かつS以降に配置不可能
		if j < data[i][1] or (j > T-S and j - data[i][1] < T-S and data[i][1] > T-S):
			dp[i][j] = dp[i+1][j]
		#Sをはじめてまたいで，かつS以降に配置可能
		elif j > T-S and j - data[i][1] < T-S and data[i][1] <= T-S:
			dp[i][j] = max(dp[i+1][j],dp[i+1][T-S-data[i][1]]+data[i][0])
		else:
			dp[i][j] = max(dp[i+1][j],dp[i+1][j-data[i][1]]+data[i][0])

print dp[0][T]