Buggy python submission (verdict: Runtime Error):
import sys
N, T = map(int, sys.stdin.readline().split(" "))
roots = [tuple(map(int, sys.stdin.readline().split(" "))) for i in range(N)]

from operator import itemgetter
#roots = sorted(roots, key=lambda x:x[1])
roots = (sorted(roots, key=itemgetter(1, 0)))

def dfs(i, csum, tsum):
    if tsum + roots[i][1] <= T:
        return dfs(i+1, csum+roots[i][0], tsum+roots[i][1])
    else:
        return 100000000 if csum == 0 else csum

ans = 100000000
for ii in range(len(roots)):
  csum = dfs(ii, 0, 0)
  if ans > csum:
    ans = csum
  if csum == 100000000:
    is_do = False
    break

if ans == 100000000:
    print('TLE')
else:
    print(ans)

Fixed submission:
import sys
N, T = map(int, sys.stdin.readline().split(" "))
roots = [tuple(map(int, sys.stdin.readline().split(" "))) for i in range(N)]

from operator import itemgetter
#roots = sorted(roots, key=lambda x:x[1])
roots = (sorted(roots, key=itemgetter(1, 0)))

def dfs(i, csum, tsum):
    if tsum + roots[i][1] <= T:
        if i+1 == N:
          return csum + roots[i][0]
        else:
          return dfs(i+1, csum+roots[i][0], tsum+roots[i][1])
    else:
        return 100000000 if csum == 0 else csum

ans = 100000000
for ii in range(N):
  csum = dfs(ii, 0, 0)
  if ans > csum:
    ans = csum
  if csum == 100000000:
    is_do = False
    break

if ans == 100000000:
    print('TLE')
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split(" "))
roots = [tuple(map(int, input().split(" "))) for i in range(N)]
roots = sorted(roots, key=lambda x:x[1])

is_do = True
def dfs(i, csum, tsum):
    if tsum + roots[i][1] <= T:
        return dfs(i+1, csum+roots[i][0], tsum+roots[i][1])
    else:
        return 100000000 if csum == 0 else csum

ans = 100000000
for i in range(len(roots)):
  csum = dfs(i, 0, 0)
  if ans > csum:
    ans = csum
  if csum == 100000000:
    is_do = False

if ans == 100000000:
    print('TLE')
else:
    print(ans)

Fixed submission:
import sys
N, T = map(int, sys.stdin.readline().split(" "))
roots = [tuple(map(int, sys.stdin.readline().split(" "))) for i in range(N)]

from operator import itemgetter
#roots = sorted(roots, key=lambda x:x[1])
roots = (sorted(roots, key=itemgetter(1, 0)))

def dfs(i, csum, tsum):
    if tsum + roots[i][1] <= T:
        if i+1 == N:
          return csum + roots[i][0]
        else:
          return dfs(i+1, csum+roots[i][0], tsum+roots[i][1])
    else:
        return 100000000 if csum == 0 else csum

ans = 100000000
for ii in range(N):
  csum = dfs(ii, 0, 0)
  if ans > csum:
    ans = csum
  if csum == 100000000:
    is_do = False
    break

if ans == 100000000:
    print('TLE')
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split(" "))
roots = [tuple(map(int, input().split(" "))) for i in range(N)]
roots = sorted(roots, key=lambda x:x[1])

def dfs(i, csum, tsum):
    c, t = roots[i]

    if tsum + t <= T:
        return dfs(i+1, csum+c, tsum+t)
    else:
        return csum

import numpy as np
clist = np.array([dfs(i, 0, 0) for i in range(len(roots))])
nzclist = clist[np.nonzero(clist)]
if len(nzclist) == 0:
    print('TLE')
else:
    print(min(nzclist))

Fixed submission:
import sys
N, T = map(int, sys.stdin.readline().split(" "))
roots = [tuple(map(int, sys.stdin.readline().split(" "))) for i in range(N)]

from operator import itemgetter
#roots = sorted(roots, key=lambda x:x[1])
roots = (sorted(roots, key=itemgetter(1, 0)))

def dfs(i, csum, tsum):
    if tsum + roots[i][1] <= T:
        if i+1 == N:
          return csum + roots[i][0]
        else:
          return dfs(i+1, csum+roots[i][0], tsum+roots[i][1])
    else:
        return 100000000 if csum == 0 else csum

ans = 100000000
for ii in range(N):
  csum = dfs(ii, 0, 0)
  if ans > csum:
    ans = csum
  if csum == 100000000:
    is_do = False
    break

if ans == 100000000:
    print('TLE')
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split(" "))
roots = [tuple(map(int, input().split(" "))) for i in range(N)]
roots = sorted(roots, key=lambda x:x[1])

ans = 1000000000
for i in range(len(roots)):
  ii = i
  csum = 0
  tsum = 0
  
  while True:
    c, t = roots[ii]
    tsum += t

    if T >= tsum:
      ii += 1
      csum += c
    else:
      break
    
  if ans > csum and csum != 0:
      ans = csum
  else:
      tsum = 0
      break

print('TLE' if ans == 1000000000 else ans)

Fixed submission:
import sys
N, T = map(int, sys.stdin.readline().split(" "))
roots = [tuple(map(int, sys.stdin.readline().split(" "))) for i in range(N)]

from operator import itemgetter
#roots = sorted(roots, key=lambda x:x[1])
roots = (sorted(roots, key=itemgetter(1, 0)))

def dfs(i, csum, tsum):
    if tsum + roots[i][1] <= T:
        if i+1 == N:
          return csum + roots[i][0]
        else:
          return dfs(i+1, csum+roots[i][0], tsum+roots[i][1])
    else:
        return 100000000 if csum == 0 else csum

ans = 100000000
for ii in range(N):
  csum = dfs(ii, 0, 0)
  if ans > csum:
    ans = csum
  if csum == 100000000:
    is_do = False
    break

if ans == 100000000:
    print('TLE')
else:
    print(ans)