Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#1 question on hitachi contest
class Solution:
    def answer(self, str_in):
        n = len(str_in)
        if n == 1:
            return "No"
        
        i = 1
        arr = []

        for i in range(0,len(str_in)):
            
            if str_in[i] == 'h' and str_in[i+1]== 'i':
                arr.append(i)
                
            elif str_in[i] == 'i' and str_in[i-1] == 'h':
                
                if arr == []:
                    return "No"
                else:
                    arr.pop()
            else:
                return "No"
        if arr == []:
            return "Yes"
        else:
            return "No"

str_in = input()

s = Solution()
print(s.answer(str_in))

Fixed submission:
#1 question on hitachi contest
class Solution:
    def answer(self, str_in):
        n = len(str_in)
        if n == 1:
            return "No"
        if n%2 != 0:
            return "No"
        i = 1
        arr = []

        for i in range(0,len(str_in)):
            
            if str_in[i] == 'h' and str_in[i+1]== 'i':
                arr.append(i)
                
            elif str_in[i] == 'i' and str_in[i-1] == 'h':
                
                if arr == []:
                    return "No"
                else:
                    arr.pop()
            else:
                return "No"
        if arr == []:
            return "Yes"
        else:
            return "No"

str_in = input()

s = Solution()
print(s.answer(str_in))
Buggy python submission (verdict: Runtime Error):
from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
for i in reversed(range()):
  if max % (i+1)==0:
    k += 1
    if k == a[2]:
      print(i)
      break

Fixed submission:
from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
for i in list(reversed(range(1, min + 1))):
    if max % i == 0 and min % i == 0:
        k += 1
        if k == a[2]:
            print(i)
            break

Buggy python submission (verdict: Runtime Error):
from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
res 
for i in reversed(range()):
  if max % (i+1)==0:
    k += 1
    if k == a[2]:
      print(k)
      break

Fixed submission:
from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
for i in list(reversed(range(1, min + 1))):
    if max % i == 0 and min % i == 0:
        k += 1
        if k == a[2]:
            print(i)
            break
Buggy python submission (verdict: Runtime Error):
from sys import stdin

a = stdin.readline().rstrip().split('/')

if(int(a[1]) > 4) print("Heisei")
print("TBD")




Fixed submission:
import sys

a = sys.stdin.readline().rstrip().split('/')

if(int(a[1]) > 4):
    print("TBD")
else:
	print("Heisei")

Buggy python submission (verdict: Runtime Error):
from sys import stdin

a = stdin.readline().rstrip().split('/')

if(int(a[]) > 4) print("Heisei")
print("TBD")




Fixed submission:
import sys

a = sys.stdin.readline().rstrip().split('/')

if(int(a[1]) > 4):
    print("TBD")
else:
	print("Heisei")
Buggy python submission (verdict: Runtime Error):
import sys

n = sys.stdin.readline().rstrip()

sum = 0
for i in range(n):
  line = sys.stdin.readline().rstrip().split(" ")
  if(line[1] == "BTC"):
    sum += float(line[0]) * 380000.0
  else:
    sum += float(line[0])
print(sum)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())

sum = 0
for i in range(n):
  line = sys.stdin.readline().rstrip().split(" ")
  if(line[1] == "BTC"):
    sum += float(line[0]) * 380000.0
  else:
    sum += float(line[0])
print(sum)

Buggy python submission (verdict: Runtime Error):
import sys

n = sys.stdin.readline().rstrip()

sum = 0
for i in range(n):
  line = sys.stdinp.readline().rstrip().split(" ")
  if(line[1] == "BTC"):
    sum += float(line[0]) * 380000.0
  else:
    sum += float(line[0])
print(sum)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())

sum = 0
for i in range(n):
  line = sys.stdin.readline().rstrip().split(" ")
  if(line[1] == "BTC"):
    sum += float(line[0]) * 380000.0
  else:
    sum += float(line[0])
print(sum)

Buggy python submission (verdict: Runtime Error):
import sys

n = sys.stdinp.readline().rstrip()

sum = 0
for i in range(n):
  line = sys.stdinp.readline().rstrip().split(" ")
  if(line[1] == "BTC"):
    sum += float(line[0]) * 380000.0
  else:
    sum += float(line[0])
print(sum)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())

sum = 0
for i in range(n):
  line = sys.stdin.readline().rstrip().split(" ")
  if(line[1] == "BTC"):
    sum += float(line[0]) * 380000.0
  else:
    sum += float(line[0])
print(sum)
Buggy python submission (verdict: Runtime Error):
from math import sqrt
a,b,c =(map(int,input().split()))
left = a+ b + 2*sqrt(a*b)
right = c
if left < right:
    print('Yes')
else :
    print('No')

Fixed submission:
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(array[k-1])

Buggy python submission (verdict: Runtime Error):
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(array[k+1])


Fixed submission:
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(array[k-1])

Buggy python submission (verdict: Runtime Error):
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(array[k+1])

Fixed submission:
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(array[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
List = list(map(int,input().split()))


cut = N
check =0
min = N

for i in range(1,N+1):
    
    if List[i-1]<=min:
        min = List[i-1]
        
        for k in range(1,i+1):
            if List[k-1]<List[i-1]:
                check = 1
                break
        if check==1:
            cut -= 1
        check = 0

    else:
        cut -=1

    




print(cut)

Fixed submission:
N = int(input())
List = list(map(int,input().split()))


cut = N
check =0
min = N

for i in range(1,N+1):
    
    if List[i-1]<=min:
        min = List[i-1]
        
    else:
        cut -=1

    




print(cut)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
List = list(map(int,input().split()))

cut = N
check =0
for i in range(1,N+1):
    for k in range(1,i+1):
        if List[k-1]<List[i-1]:
            check = 1
            break
    if check==1:
        cut -= 1
    check = 0

print(cut)



Fixed submission:
N = int(input())
List = list(map(int,input().split()))


cut = N
check =0
min = N

for i in range(1,N+1):
    
    if List[i-1]<=min:
        min = List[i-1]
        
    else:
        cut -=1

    




print(cut)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
List = list(map(int,input().split()))

cut = N
check =0
for i in range(1,N+1):
    for k in range(1,i+1):
        if List[k-1]<List[i-1]:
           check = 1
    if check==1:
        cut -= 1
    check = 0

print(cut)


Fixed submission:
N = int(input())
List = list(map(int,input().split()))


cut = N
check =0
min = N

for i in range(1,N+1):
    
    if List[i-1]<=min:
        min = List[i-1]
        
    else:
        cut -=1

    




print(cut)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
sum = a + b + c
if sum >= 22:
    print('bust')
else:
    print('win')

Fixed submission:
S = input()
Slist = []
for i in range(len(S)):
    Slist.append(S[i]) 

count = 0
##print(len(S))

for i in range(len(S)//2):
    ##print(Slist[i],Slist[-i-1])
    if Slist[i] != Slist[len(S)-1-i]:
        count +=1
    
    

print(count)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！
input_line = input()
lines = input_line.split()
x=int(lines[0])
y=int(lines[1])
input_num=x*y
if(x==1 or y==1):
  print(1)
  return
if((x*y)%2==1):
  print(int(input_num/2)+1)
else:
  print(int(input_num/2))

Fixed submission:
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！
input_line = input()
lines = input_line.split()
x=int(lines[0])
y=int(lines[1])
input_num=x*y
if(x==1 or y==1):
  print(1)
else:
  if((x*y)%2==1):
    print(int(input_num/2)+1)
  else:
    print(int(input_num/2))
Buggy python submission (verdict: Runtime Error):
num=list(map(int,input().split()))
nums=list(map(int, input().split()))
a=[0]*num[1]
max=-1
for i in nums:
    a.append((i+1)/2)
    a.pop(0)
    s=sum(a)
    if(s>max):
        max=s
print(max)

Fixed submission:
items=input().split()
nums=list(map(int, input().split()))
target=input()
if(target==items[0]):
    print(nums[0]-1,nums[1])
else:
    print(nums[0],nums[1]-1)
Buggy python submission (verdict: Runtime Error):
n=input()
sei=n/2
tmp=n%2
if tmp==0:
    
else:
    sei=sei+1
print(sei)

Fixed submission:
n=int(input())
sei=int(n/2)
tmp=n%2
if tmp==0:
    sei=sei
else:
    sei=sei+1
print(sei)
Buggy python submission (verdict: Runtime Error):
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(str(array[k + 1]))

Fixed submission:
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(str(array[k - 1]))

Buggy python submission (verdict: Runtime Error):
K = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(arr[K])

Fixed submission:
K = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(arr[K-1])
Buggy python submission (verdict: Runtime Error):
ans = 'APPROVED'

N = int(input())
A = input().split()

for i in range(N):
    if (int(A[i])%2 == 0) and (int(A[i])%3 != 0) and int(A[i])%5 != 0):
        ans = 'DENIED'
        break

print(ans)


Fixed submission:
ans = 'APPROVED'

N = int(input())
A = input().split()

for i in range(N):
    if (int(A[i])%2 == 0) and (int(A[i])%3 != 0) and (int(A[i])%5 != 0):
        ans = 'DENIED'
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
K,X=map(int,input().split())
C=[i for i in range(X-K+1,X+K)]

print(*C, '')


Fixed submission:
K,X=map(int,input().split())
C=[i for i in range(X-K+1,X+K)]

print(*C)
Buggy python submission (verdict: Runtime Error):
if float(c) - float(a+b)+2*(math.sqrt(a*b) > 0) :
  print ("Yes")
else :
  print ("No")


Fixed submission:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
from decimal import *
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

a, b, c = map(int, input().split())

if (c-a-b)**2 > 4*a*b and (c-a-b) > 0:
  print ("Yes")
else :
  print ("No")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#割引券を使う場合
ans = sys.maxsize
for _ in range(M) :
  x, y, c = map(int, input().split())
  ans = min(ans, a[x-1]+b[y-1]-c)

#その他の組み合わせ
for i in range(A) :
  for j in range(B) :
    ans = min(ans, a[i] + b[j])

print (ans)



Fixed submission:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#割引券を使う場合
ans = sys.maxsize
for _ in range(M) :
  x, y, c = map(int, input().split())
  ans = min(ans, a[x-1]+b[y-1]-c)

#その他の組み合わせ
ans = min(ans, min(a)+min(b))

print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

S = str(input())
Q = int(input())
#query = [["" for _ in range(3)] for _ in range(Q)]

for _ in range(Q) :
  stmp = input().split()
  #print (stmp)
  if stmp[0] == "1" :
    S = S[::-1]
  else :
    if stmp[1] == '1' :
      S = stmp[2] + S
    else :
      S = S + stmp[2]

print (S)




Fixed submission:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

S = str(input())
Q = int(input())
#query = [["" for _ in range(3)] for _ in range(Q)]

sl = [] #先頭リスト
el = [] #末尾リスト
f = True #反転正負
for _ in range(Q) :
  stmp = input().split()
  #print (stmp)
  
  if stmp[0] == "1" :
    f = not f
    tl = sl
    sl = el
    el = tl
    
  else :
    if stmp[1] == '1' :
      sl.append(stmp[2])
    else :
      el.append(stmp[2])

ans = ""
for i in range(len(sl)-1, -1, -1) :
  ans += sl[i]
if f :
  ans += S
else :
  ans += S[::-1]
for i in range(len(el)) :
  ans += el[i]
  
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, M = map(int, input().split())
L = []
for _ in range(M) :
  L.append(list(map(str, input().split())))
#print(L)
  
D = {}
for i in range(M) :
  if L[i][0] not in D :
    D[L[i][0]] = L[i][1]
  else :
    if L[i][1] == "AC" :
      D[L[i][0]] = L[i][1]

ACsum = 0
ACList = []
for mykey, myvalue in D.items() :
  if myvalue == "AC" :
    ACsum += 1
    ACList += [mykey]
    
#print(ACList)
ACEnd = []
WAsum = 0
for i in range(M) :
  if L[i][0] in ACList and L[i][0] not in ACEnd :
    if L[i][1] != "AC" :
      WAsum += 1
    else :
      ACEnd.append(L[i][0])

print(str(ACsum) + " " + str(WAsum))

Fixed submission:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, M = map(int, input().split())
L = []
for _ in range(M) :
  L.append(list(map(str, input().split())))
#print(L)

A = [[0 for _ in range(2)] for _ in range(N+1)]

for i in range(M) :
  if L[i][1] == "WA" and A[int(L[i][0])][1] != 1:
    A[int(L[i][0])][0] += 1
  else :
    A[int(L[i][0])][1] = 1

#print (A)
ACsum = 0
WAsum = 0
for j in range(N+1) :
  if A[j][1] == 1 :
    ACsum += 1
    WAsum += A[j][0]
  
print(str(ACsum) + " " + str(WAsum))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, M = map(int, input().split())
L = []
for _ in range(M) :
  L.append(list(map(str, input().split())))
#print(L)
  
D = {}
for i in range(M) :
  if L[i][0] not in D :
    D[L[i][0]] = L[i][1]
  else :
    if L[i][1] == "AC" :
      D[L[i][0]] = L[i][1]

ACsum = 0
ACList = []
for mykey, myvalue in D.items() :
  if myvalue == "AC" :
    ACsum += 1
    ACList += [mykey]
    
#print(ACList)
WAsum = 0
for k in range(len(ACList)) :
  for i in range(M) :
    #print(ACList[k])
    #print(L[i][0])
    #print(L[i][1])
    if ACList[k] == L[i][0] :
      if L[i][1] == "WA" :
        WAsum += 1
      else :
        break

print(str(ACsum) + " " + str(WAsum))

Fixed submission:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, M = map(int, input().split())
L = []
for _ in range(M) :
  L.append(list(map(str, input().split())))
#print(L)

A = [[0 for _ in range(2)] for _ in range(N+1)]

for i in range(M) :
  if L[i][1] == "WA" and A[int(L[i][0])][1] != 1:
    A[int(L[i][0])][0] += 1
  else :
    A[int(L[i][0])][1] = 1

#print (A)
ACsum = 0
WAsum = 0
for j in range(N+1) :
  if A[j][1] == 1 :
    ACsum += 1
    WAsum += A[j][0]
  
print(str(ACsum) + " " + str(WAsum))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

if N%2 == 1 :
  print (0)
else :
  cnt = 0
  i = 1
  N //= 2
  while N >= 5**i :
    cnt += N // (5**i)
    i += 1
    
print (cnt)
  
  

Fixed submission:
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

if N%2 == 1 :
  print (0)
  exit()
else :
  cnt = 0
  i = 1
  N //= 2
  while N >= 5**i :
    cnt += N // (5**i)
    i += 1
    
  print (cnt)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

if N % 2 == 1 :
  print (0)
  exit()
  
ans = 1
for i in range(1, N+1) :
  if i % 2 == 0 :
    ans *= i
    #print (i)

cnt = 0
s = str(ans)
for i in range(len(s)) :
  if s[len(s)-i-1] == "0" :
    cnt += 1
  else :
    break
print (cnt)


Fixed submission:
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

if N%2 == 1 :
  print (0)
  exit()
else :
  cnt = 0
  i = 1
  N //= 2
  while N >= 5**i :
    cnt += N // (5**i)
    i += 1
    
  print (cnt)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

ans = 1
for i in range(1, N+1) :
  if i % 2 == 0 :
    ans *= i
    #print (i)

cnt = 0
s = str(ans)
for i in range(len(s)) :
  if s[len(s)-i-1] == "0" :
    cnt += 1
  else :
    break
print (cnt)


Fixed submission:
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
N = int(input())

if N%2 == 1 :
  print (0)
  exit()
else :
  cnt = 0
  i = 1
  N //= 2
  while N >= 5**i :
    cnt += N // (5**i)
    i += 1
    
  print (cnt)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())
S = list(str(input()))

C = ["#" for _ in range(N)]

minN = sys.maxsize
for i in range(N+1) :
  cnt = 0
  for j in range(N) :
    if S[j] != C[j] :
      cnt += 1
  minN = min(minN, cnt)
  if i < N :
    C[i] = "."

print (minN)

Fixed submission:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())
S = list(str(input()))

b = 0
w = 0
for i in range(N) :
  if S[i] == "." :
    w += 1

minN = w
for j in range(N) :
  if S[j] == "#" :
    b += 1
  else :
    w -= 1
  minN = min(minN, b+w)
print (minN)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())

N, W = map(int, input().split())
H = []
for _ in range(N) :
  H.append(list(map(int, input().split())))
#print(H)

#N(i+1)個目の品物を追加したときにWjとなる場合のWj地点の最大価値
dp = [0 for _ in range(W+1)]

for i in range(N) :
  dptemp = copy.deepcopy(dp)
  for j in range(W+1) :
    if dptemp[j] > 0 and j+H[i][0] <= W:
      dp[j+H[i][0]] = max(dptemp[j+H[i][0]], dptemp[j] + H[i][1])
    
  dp[H[i][0]] = max(dptemp[H[i][0]], H[i][1])
  #print (dp)      
#print (dp)

print (max(dp))

Fixed submission:
# -*- coding: utf-8 -*-
import math
import datetime
import itertools
import sys
import copy

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())

N, W = map(int, input().split())
H = []
for _ in range(N) :
  H.append(list(map(int, input().split())))
#print(H)

#N(i+1)個目の品物を追加したときにWjとなる場合のWj地点の最大価値
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(1, N+1) :
  for j in range(W+1) :
    dp[i][j] = max(dp[i-1][j], dp[i][j])
    if dp[i-1][j] > 0 and j+H[i-1][0] <= W:
      dp[i][j+H[i-1][0]] = max(dp[i-1][j+H[i-1][0]], dp[i-1][j] + H[i-1][1])
    
  dp[i][H[i-1][0]] = max(dp[i-1][H[i-1][0]], H[i-1][1])
  #print (dp[i])      
#print (dp)

print (max(dp[N]))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy

# 入力
N, W = map(int, input().split())
H = []
H.append([0,0])
for _ in range(N) :
  S = str(input())
  H.append(list(map(int, S.split())))
#index
Hw = 0
Hv = 1

#print (H)
#Vmax = (10**3) * N
Vmax = (60) * N

#合計価値viのときの最小重量
dp = [[sys.maxsize for _ in range(Vmax+1)] for _ in range(N+1)]


for i in range(1, N+1) :
  if i == 1 : 
    dp[i][H[i][Hv]] = H[i][Hw]
  else :
    dp[i][H[i][Hv]] = min(H[i][Hw], dp[i][H[i][Hv]])
    for j in range(Vmax+1) :
      if dp[i-1][j] != sys.maxsize and (j + H[i][Hv]) <= Vmax+1 :
        dp[i][j + H[i][Hv]] = min(dp[i-1][j + H[i][Hv]], dp[i][j] + H[i][Hw])
  #print (dp[i][:])
  out = copy.deepcopy(dp[i][:])
  line = ""
  for x in range(len(out)) :
      if out[x] == sys.maxsize :
        line += "_" + " "
      else :    
        line += str(out[x]) + " "
  print(line)

for k in range(Vmax) :
  if dp[N][Vmax-k] <= W :
    print(Vmax-k)
    exit()




Fixed submission:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
N, W = map(int, input().split())
H = []
H.append([0,0])
for _ in range(N) :
  S = str(input())
  H.append(list(map(int, S.split())))
#index
Hw = 0
Hv = 1
 
#print (H)
Vmax = (10**3) * N
#Vmax = (60) * N
 
#合計価値viのときの最小重量
dp = [[sys.maxsize for _ in range(Vmax+1)] for _ in range(N+1)]

for i in range(1, N+1) :
  #Niのvの反映
  dp[i][H[i][Hv]] = min(H[i][Hw], dp[i][H[i][Hv]])
  #VjのときにNiを選んだ場合/選ばない場合
  for j in range(Vmax+1) :
    if dp[i-1][j] != sys.maxsize :
      #Niを選ばないとき
      dp[i][j] = min(dp[i-1][j], dp[i][j])
      #Niを選ぶとき
      if (j + H[i][Hv]) <= Vmax+1 :
        dp[i][j + H[i][Hv]] = min(dp[i-1][j] + H[i][Hw], dp[i][j + H[i][Hv]])
        
  #print (dp[i][:])
  """
  out = copy.deepcopy(dp[i][:])
  line = ""
  for x in range(len(out)) :
      if out[x] == sys.maxsize :
        line += "_" + "\t"
      else :    
        line += str(out[x]) + "\t"
  print(line)
  """

for k in range(Vmax) :
  if dp[N][Vmax-k] <= W :
    print(Vmax-k)
    exit()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 入力
N = str(input())
#X, Y = map(str, input().split())

if N[0] == N[1] and N[1] == N[2] :
  print ("Yes")1234
elif N[1] == N[2] and N[2] == N[3]:
  print ("Yes")
else :
  print ("No")


Fixed submission:
# -*- coding: utf-8 -*-
# 入力
N = str(input())
#X, Y = map(str, input().split())

if N[0] == N[1] and N[1] == N[2] :
  print ("Yes")
elif N[1] == N[2] and N[2] == N[3]:
  print ("Yes")
else :
  print ("No")