Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03032 (python)

Fixed submission:
#D問題
N, M=map(int, input().split())
V = input().split()
V_i = [int(i) for i in V]

ans = 0
for i in range(M+1):
    for j in range(M+1-i):
        if i+j >N:
            break;
        num = 0
        dump_num = []
        for k in range(i):
            num += V_i[k]
            dump_num.append(V_i[k])
        for k in range(N-1,N-j-1,-1):
            num+=V_i[k]
            dump_num.append(V_i[k])
        dump_num.sort()
        for k in range(M-i-j):
            if k >= len(dump_num):
                break;
            if dump_num[k] >= 0:
                break;
            num -= dump_num[k]
        
        if num >= ans:
            ans = num
print(ans)

Buggy submission (verdict: Runtime Error):
#D問題
N, M=map(int, input().split())
V = input().split()
V_i = [int(i) for i in V]

ans = 0
for i in range(M):
    for j in range(M-i):
        if i+j >N:
            break;
        num = 0
        dump_num = []
        for k in range(i):
            num += V_i[k]
            dump_num.append(V_i[k])
        for k in range(N-1,N-j-1,-1):
            num+=V_i[k]
            dump_num.append(V_i[k])
        dump_num.sort()
        for k in range(M-i-j):
            if k > len(dump_num):
                break;
            if dump_num[k] >= 1:
                break;
            num -=dump_num[k]
        
        if num > ans:
            ans = num
print(ans)

Buggy submission (verdict: Runtime Error):
#D問題
N, M=map(int, input().split())
V = input().split()
V_i = [int(i) for i in V]

ans = 0
for i in range(M):
    for j in range(M-i):
        if i+j >M:
            break;
        num = 0
        dump_num = []
        for k in range(i):
            num += V_i[k]
            dump_num.append(V_i[k])
        for k in range(N-1,N-j-1,-1):
            num+=V_i[k]
            dump_num.append(V_i[k])
        dump_num.sort()
        for k in range(M-i-j):
            if k >= len(dump_num):
                break;
            if dump_num[k] >= 1:
                break;
            num -=dump_num[k]
        if num > ans:
            ans = num
print(ans)
Problem p03086 (python)

Fixed submission:
N = input()
answer_list = []
answer = 0

for i in range(len(N)):
  if N[i] == "A" or N[i] == "T" or N[i] == "C" or N[i] == "G":
    answer += 1
  else:
    answer_list.append(answer)
    answer = 0
  if i+1 == len(N):
    answer_list.append(answer)
print(max(answer_list))

Buggy submission (verdict: Runtime Error):
N = input()
answer_list = []
answer = 0

for i in range(len(N)):
    if N[i] == "A" or N[i] == "T" or N[i] == "C" or N[i] == "G":
        answer += 1
    else:
        answer_list.append(answer)
        answer = 0
print(max(answer_list))
Problem p03361 (python)

Fixed submission:
H, W = map(int,input().split())
map = [input() for i in range(H)]

def drow(i,j, map = map):
  if j > 0 and map[i][j-1] == "#":
    return "Yes"
  if j < W-1 and map[i][j+1] == "#":
    return "Yes"
  if i > 0 and map[i-1][j] == "#":
    return "Yes"
  if i < H -1 and map[i+1][j] == "#":
    return "Yes"
  return "No"

ans = "Yes"
for i in range(H):
  for j in range(W):
    if map[i][j] == "#":
      ans = drow(i,j)
      if ans == "No":
        print(ans)
        exit()
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
map = [input() for i in range(H)]

def drow(i,j, map = map):
  if j > 0 and map[i][j-1] == "#":
    return "Yes"
  if j < W-1 and map[i][j+1] == "#":
    return "Yes"
  if i > 0 and map[i-1][j] == "#":
    return "Yes"
  if i < H -1 and map[i+1][j] == "#":
    return "Yes"
  return "No"


for i in range(H):
  for j in range(W):
    if map[i][j] == "#":
      ans = drow(i,j)
      if ans == "No":
        break
if H == 1 and W == 1:
  ans = "No"
  if map[0][0] == "#":
    ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
map = [input() for i in range(H)]

def drow(i,j, map = map):
  if j > 0 and map[i][j-1] == ".":
    return "No"
  if j < W-1 and map[i][j+1] == ".":
    return "No"
  if i > 0 and map[i-1][j] == ".":
    return "No"
  if i < H -1 and map[i+1][j] == ".":
    return "No"
  return "Yes"

for i in range(H):
  for j in range(W):
    if map[i][j] == "#":
      ans = drow(i,j)
      if ans == "No":
        break
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
map = [input() for i in range(H)]

def drow(i,j, map = map):
  if j > 0 and map[i][j-1] == "#":
    return "Yes"
  if j < W-1 and map[i][j+1] == "#":
    return "Yes"
  if i > 0 and map[i-1][j] == "#":
    return "Yes"
  if i < H -1 and map[i+1][j] == "#":
    return "Yes"
  return "No"

if H == 1 and W==1:
  if map[0][0] =="#":
    ans = "Yes"
  else:
    ans = "No"

for i in range(H):
  for j in range(W):
    if map[i][j] == "#":
      ans = drow(i,j)
      if ans == "No":
        break
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
map = [input() for i in range(H)]

def drow(i,j, map = map):
  if j > 0 and map[i][j-1] == "#":
    return "YES"
  if j < W-1 and map[i][j+1] == "#":
    return "YES"
  if i > 0 and map[i-1][j] == "#":
    return "YES"
  if i < H -1 and map[i+1][j] == "#":
    return "YES"
  return "NO"
    

for i in range(H):
  for j in range(W):
    if map[i][j] == "#":
      ans = drow(i,j)
      if ans == "NO":
        break
print(ans)
Problem p03999 (python)

Fixed submission:
S =input()
ans_list = []
if len(S) == 1:
    print(int(S))
else:
    for i in range(2**(len(S)-1)):
        comb = bin(i)[2:].zfill(len(S)-1)
        num_list = []
        num = S[0]
        for i in range(len(comb)):
            if comb[i] == "1":
                num_list.append(int(num))
                num = S[i+1]
            else:
                num += S[i+1]
        num_list.append(int(num))
        ans_list.append(sum(num_list))
    print(sum(ans_list))

Buggy submission (verdict: Runtime Error):
S =input()
ans_list = []
for i in range(2**(len(S)-1)):
    comb = bin(i)[2:].zfill(len(S)-1)
    num_list = []
    num = S[0]
    for i in range(len(comb)):
        if comb[i] == "1":
            num_list.append(int(num))
            num = S[i+1]
        else:
            num += S[i+1]
    num_list.append(int(num))
    ans_list.append(sum(num_list))
print(sum(ans_list))
Problem p02801 (python)

Fixed submission:
print(chr(ord(input()) + 1))

Buggy submission (verdict: Runtime Error):
    print(chr(ord(input()) + 1))
Problem p03110 (python)

Fixed submission:
n = int(input())
 
sum = 0
for i in range(n):
  v,t = input().split()
  v = float(v)
  if t == 'BTC':
    sum+=v*380000
  else:
    sum+=v
    
print(sum)

Buggy submission (verdict: Runtime Error):
n = int(input())

sum = 0
for i in range(n):
  v,t = input().split()
  v = int(v)
  if t = 'BTC':
    sum+=v*38000
  else:
    sum+=v

print(sum)
Problem p03162 (python)

Fixed submission:
def retMax(a,b):
  if a>=b:
    return a
  else:
    return b

n = int(input())
r = []
dpList = [ [0] * 3 for x in range(n)]

for i in range(n):
  r.append(list(map(int,input().split())))

dpList[0][0] = r[0][0]  
dpList[0][1] = r[0][1]  
dpList[0][2] = r[0][2]  

for s in range(1,n):
  #b->a,c->aの最大値
  dpList[s][0] = retMax(dpList[s-1][1]+r[s][0],dpList[s-1][2]+r[s][0])
  #a->b,c->bの最大値
  dpList[s][1] = retMax(dpList[s-1][0]+r[s][1],dpList[s-1][2]+r[s][1])
  #a->c,b->cの最大値
  dpList[s][2] = retMax(dpList[s-1][0]+r[s][2],dpList[s-1][1]+r[s][2])

print(max(dpList[n-1]))

Buggy submission (verdict: Runtime Error):
def retMax(a,b):
  if a>=b:
    return a
  else:
    return b

n = int(input())
r = []
dpList = [ [0] * 3 for x in range(n)]

for i in range(n):
  r.append(list(map(int,input().split())))

dpList[0][0] = r[0][0]  
dpList[0][1] = r[0][1]  
dpList[0][2] = r[0][2]  

for s in range(1,n):
  #b->a,c->aの最大値
  dpList[s][0] = retMax(dpList[s-1][1]+r[s][0],dpList[s-1][2]+r[s][0])
  #a->b,c->bの最大値
  dpList[s][1] = retMax(dpList[s-1][0]+r[s][1],dpList[s-1][2]+r[s][1])
  #a->c,b->cの最大値
  dpList[s][2] = retMax(dpList[s-1][0]+r[s][2],dpList[s-1][1]+r[s][2])

print(max(dpList[s]))
Problem p03424 (python)

Fixed submission:
import sys
n = int(input())
cl = input().split()
for c in cl:
  if c=='Y':
    print('Four')
    sys.exit()
else:
  print('Three')

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())

for i in range(n):
  c =input()
  if c=='Y':
    print('Four')
    sys.exit()
else:
  print('Three')
Problem p03434 (python)

Fixed submission:
n = int(input())
cardList = map(int,input().split())
cl = list(cardList)
cl.sort(reverse=True)
alice = 0
bob = 0
turn = True
for c in cl:  
  if turn:
    alice+= c
    turn = False
  else:
    bob +=c
    turn =True
    
print(alice-bob)

Buggy submission (verdict: Runtime Error):
n = int(input())
cardList = [int(input()) for i in range(n)]

cardList = cardList.sort(reverse=True)

alice = 0
bob = 0
turn = True
for c in cardList:  
  if turn:
    alice+= c
    turn = False
  else:
    bob +=c
    turn =True
    
print(alice-bob)
Problem p03597 (python)

Fixed submission:
a = int(input())
b=int(input())
print(a*a - b)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
b = list(map(int, input().split())) 

sum = 0
for ball in b:
  sum += ball - 0 if (ball - 0) < k - ball else k - ball
  
  print(sum*2)

Buggy submission (verdict: Runtime Error):
a = int(input())
b=int(input())
return a*a - b
Problem p03609 (python)

Fixed submission:
a,b = map(int,input().split())
print (a -b if a-b >0 else 0)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split)
print (a -b if a-b <0 else 0)
Problem p03795 (python)

Fixed submission:
n = int(input())
print(n*800-(n//15*200))

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest
import math

def resolve():
    s,c= map(int,input().split())

    if s>=c/2:
        print(str(math.floor(c/2)))
    else:
        zanc = c - (s * 2)
        print(str(s + math.floor(zanc/4)))
        
resolve()
Problem p03797 (python)

Fixed submission:
import sys
from io import StringIO
import unittest
import math

def resolve():
    s,c= map(int,input().split())

    if s>=c/2:
        print(str(math.floor(c/2)))
    else:
        zanc = c - (s * 2)
        print(str(s + math.floor(zanc/4)))
        
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    s,c= map(int,input().split())

    if s>=c/2:
        print(str(math.floor(c/2)))
    else:
        zanc = c - (s * 2)
        print(str(s + math.floor(zanc/4)))
        
resolve()
Problem p03852 (python)

Fixed submission:
s = input()
 
if s == 'a' or s == 'i' or s == 'u' or s == 'e' or s == 'o' :
  print('vowel')
else:
  print('consonant')

Buggy submission (verdict: Runtime Error):
s = input()

if s == 'a' or s == 'i' s == 'u' s == 'e' s == 'o' :
  print('vowel')
else:
  print('consonant')
Problem p03943 (python)

Fixed submission:
a,b,c = map(int,input().split())
 
if a == b+c or b == a+c or c == a+b :
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c = map(input().split())
 
if a == b+c or b == a+c or c == a+b :
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c = map(input().split())

if a = b+c or b = a+c or c = a+b :
  print("Yes")
else:
  print("No")
Problem p02761 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    if(pow(10,N-1)==1):x=0
    else:x=pow(10,N-1)
    for i in range(x,pow(10,N)):    
        f=True
        for j in range(M):
            if not(str(i)[s[j]-1]==str(c[j])):f=False
            if(not f):break
        if(f):
            print(i)
            return
    print(-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    for i in range(pow(10,N-1)-1,pow(10,N)):
        f=True
        for j in range(M):
            if not(str(i)[s[j]-1]==str(c[j])):f=False
            if(not f):break
        if(f):
            print(i)
            return
    print(-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()
Problem p02765 (python)

Fixed submission:
n,r=map(int,input().split())

ans=0
if n<10:
  ans=r+100*(10-n)
else:
  ans=r
print(ans)

Buggy submission (verdict: Runtime Error):
n,r=int(input())
ans=0
if n<10:
  ans=r+r*(10-n)
else:
  ans=r
ptinr(ans)
Problem p02780 (python)

Fixed submission:
from itertools import accumulate

N,K=map(int,input().split())
p = list(map(int,input().split()))

pp=[0]*N
for i in range(N):
  pp[i]=(p[i]+1)/2

sum=0
temp=0
for i in range(0,K):
  temp+=pp[i]
sum=temp
for i in range(0,N-K):
  temp=temp-pp[i]+pp[i+K]
  sum=max(sum,temp)
print(sum)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=[int(input()) for _ in range(N)]

pp=[0]*N
for i in range(N):
    pp[i]=(p[i]+1)/2
sum=0
for i in range(0,K):
    sum+=pp[i]
for i in range(0,N-K):
    sum=max(sum,sum-pp[i]+pp[i+K])
print(sum)
Problem p03632 (python)

Fixed submission:
A,B,C,D=map(int,input().split())
x=min(B,D)-max(A,C)
if x>0:
    print(x)
else:
    print("0")

Buggy submission (verdict: Runtime Error):
A,B,C,D=int(input().split())
x=min(C,D)-max(A,B)
if x>0:
    print(x)
else:
    print("0")
Problem p03643 (python)

Fixed submission:
N=input()
print("ABC"+N)

Buggy submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split()]
a=[]
b=[]
c=[]
for i in range(M):
    x,y=[int(i) for i in input().split()]
    if x==1 :
        c.append(y)
    if y==N:
        c.append(x)
if len(c)==len(set(c)):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Buggy submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split()]
a=[]
b=[]
c=[]
flag=False
for i in range(M):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
    if x==1:
        c.append(y)
for i in range(M):
    if b[i]==N:
        flag=a[i] in c

if flag==False:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
Problem p03645 (python)

Fixed submission:
N,M=[int(i) for i in input().split()]
a=[]
b=[]
c=[]
for i in range(M):
    x,y=[int(i) for i in input().split()]
    if x==1 :
        c.append(y)
    if y==N:
        c.append(x)
if len(c)==len(set(c)):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=[],b=[],c=[]
flag=0
for i in range(M):
    x,y=map(int,input().split())
    x.append(a)
    y.append(b)
    if x==1:
        c.append(y)
for i in range(M):
    if b[i]==N:
        if a[i] in c:
            flag+=1
if flag==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
Problem p02761 (python)

Fixed submission:
n, m = [int(i) for i in input().split()]
sc = [list(map(int, input().split())) for _ in range(m)]


ans = -1
for i in range(10**(n-1) if n > 1 else 0, 10**n):
    for s, c in sc:
        if str(i)[s-1] != str(c):
            break
    else:
        ans = i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
sc = [list(map(int, input().split())) for _ in range(m)]


ans = -1
for i in range(10**(n-1), 10**n):
    for s, c in sc:
        if str(i)[s-1] != str(c):
            break
    else:
        ans = i
        break
if n == 1:
    if m == 0 or set(sc) == {[1, 0]}:
        ans = 0
print(ans)
Problem p02823 (python)

Fixed submission:
def main():
    N, A, B = [int(i) for i in input().split()]
    diff = B - A
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 + (diff - 1) // 2)
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, A, B = [int(i) for i in input().split()]
    diff = B - A
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 (diff - 1) // 2)
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, A, B = [int(i) for i in input().split()]
    diff = B - A
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 (diff - 1) // 2)
    print(ans)


if __name__ == '__main__':
    main()
Problem p02995 (python)

Fixed submission:
import fractions


def anti_division(n, d1, d2):
    g = fractions.gcd(d1, d2)
    l = (d1 * d2) // g
    ret = n - (n//d1 + n//d2) + n//l
    return ret


a, b, c, d = [int(i) for i in input().split()]
ans = anti_division(b, c, d) - anti_division(a - 1, c, d)
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, c, d = [int(i) for i in input().split()]
n = {i for i in range(a, b+1) if i % c != 0 and i % d != 0}4 9 2 3
ans = len(n)
print(ans)
Problem p03043 (python)

Fixed submission:
import math


n, k = [int(i) for i in input().split()]
prob = 0
for i in range(1, n + 1):
    if i >= k:
        exp = 0
    else:
        exp = math.ceil(math.log2(k) - math.log2(i))
    prob += (1 / n) * (1 / 2) ** exp
print(prob)

Buggy submission (verdict: Runtime Error):
import math


n, k = [int(i) for i in input().split()]
prob = 0
for i in range(1, n + 1):
    if i >= k:
        exp = 0
    else:
        exp = math.ceil(math.log2(k) - math.log2(i))
    prob += (1 / n) * (1 / 2) ** exp
print(prob)
Problem p03087 (python)

Fixed submission:
n, q = [int(i) for i in input().split()]
s = input()

count = [0] * (n + 1)
for i in range(n):
    count[i+1] += count[i]
    if s[i:i+2] == "AC":
        count[i+1] += 1
for i in range(q):
    l, r = [int(i) for i in input().split()]
    print(count[r-1] - count[l-1])

Buggy submission (verdict: Runtime Error):
n, q = [int(i) for i in input().split()]
s = input()

count = [0] * (n + 1)
for i in range(n):
    count[i+1] += count[i]
    if s[i:i+2] == "AC":
        count[i+1] += 1
for i in range(q):
    l, r = [int(i) for i in input().split()]
    print(count(r-1) - count(l-1))
Problem p03106 (python)

Fixed submission:
from fractions import gcd

A, B, K = [int(i) for i in input().split()]

count = 0
for i in range(gcd(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        count += 1
        if count == K:
            print(i)
            break

Buggy submission (verdict: Runtime Error):
from fractions import gcd

A, B, K = [int(i) for i in input()]

count = 0
for i in range(gcd(a, b), 0, -1):
    if A % i == 0 and B % i == 0:
        count += 1
        if count == K:
            print(i)
            break

Buggy submission (verdict: Runtime Error):
from fractions import gcd

A, B, K = [int(i) for i in input()]

gcd_ = gcd(A, B)
count = 0
flg = 0
for n in range(gcd_, 0, -1):
    if flg:
        break
    if A % n == 0 and B % n == 0:
        count += 1
        if count == K:
            print(n)
            flg = 1
            break
Problem p03145 (python)

Fixed submission:
h, w, _ = [int(i) for i in input().split()]
ans = h * w // 2
print(ans)

Buggy submission (verdict: Runtime Error):
h, w, _ = [int(i) for i in input()]
ans = h * w // 2
print(ans)
Problem p03164 (python)

Fixed submission:
import collections


MAX_N = 110
MAX_V = 100100

Item = collections.namedtuple("Item", ("weight", "value"))


def main():
    N, W = [int(i) for i in input().split()]
    items = [Item(int(i), int(j)) for (i, j) in [input().split() for _ in range(N)]]
    dp = [[float('inf')] * MAX_V for _ in range(MAX_N)]

    dp[0][0] = 0

    for i in range(N):
        item = items[i]
        for sum_v in range(MAX_V):
            # i番目の品物を選ぶ
            if sum_v - item.value >= 0:
                dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - item.value] + item.weight)
            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])

    ans = 0
    for sum_v in range(MAX_V):
        if dp[N][sum_v] <= W:
            ans = sum_v

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections


MAX_N = 110
MAX_V = 100100

Item = collections.namedtuple("Item", ("weight", "value"))


def main():
    N, W = [int(i) for input().split()]
    items = [Item(int(i), int(j)) for (i, j) in [input().split() for _ in range(N)]]
    dp = [[float('inf')] * MAX_V for _ in range(MAX_N)]

    dp[0][0] = 0

    for i in range(N):
        item = items[i]
        for sum_v in range(MAX_V):
            # i番目の品物を選ぶ
            if sum_v - item.value >= 0:
                dp[i + 1][sum_v] = max(dp[i + 1][sum_v], dp[i][sum_v - item.value] + item.weight)
            dp[i + 1][sum_v] = max(dp[i + 1][sum_v], dp[i][sum_v])

    ans = 0
    for sum_v in range(MAX_V):
        if dp[N][sum_v] <= W:
            ans = sum_v

    print(ans)

if __name__ == '__main__':
    main()
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2 << 28)

n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
    x, y = [int(i) for i in input().split()]
    al[x-1].add(y-1)

dp = [-1] * n


def rec(v):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for nv in al[v]:
        ret = max(ret, rec(nv) + 1)
    dp[v] = ret
    return ret


ans = 0
for v in range(n):
    ans = max(ans, rec(v))

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2 << 30)

n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
    x, y = [int(i) for i in input().split()]
    al[x-1].add(y-1)

dp = [-1] * n


def rec(v):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for nv in al[v]:
        ret = max(ret, rec(nv) + 1)
    dp[v] = ret
    return ret


ans = 0
for v in range(n):
    ans = max(ans, rec(v))

print(ans)

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
    x, y = [int(i) for i in input().split()]
    al[x-1].add(y-1)

dp = [-1] * n


def rec(v):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for nv in al[v]:
        ret = max(ret, rec(nv) + 1)
    dp[v] = ret
    return ret


ans = 0
for v in range(n):
    ans = max(ans, rec(v))

print(ans)

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
    x, y = [int(i) for i in input().split()]
    al[x-1].add(y-1)

dp = [-1] * n


def rec(v):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for nv in al[v]:
        ret = max(ret, rec(nv) + 1)
    dp[v] = ret
    return ret


ans = 0
for v in range(n):
    ans = max(ans, rec(v))

print(ans)
Problem p03239 (python)

Fixed submission:
N, T = [int(i) for i in input().split()]


min_cost = 1001
for c, t in [input().split() for _ in range(N)]:
    c, t = int(c), int(t)
    if t > T:
        continue
    min_cost = min(min_cost, c)

ans = min_cost if min_cost < 1001 else "TLE"
print(ans)

Buggy submission (verdict: Runtime Error):
N, T = [int(i) for i in input().split()]


min_cost = 1001
for c, t in [input().split() for _ in range(N)]
    c, t = int(c), int(t)
    if t > T:
        continue
    min_cost = min(min_cost, c)

ans = min_cost if min_cost < 1001 else "TLE"
print(ans)