Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
num=[int(input()) for _ in range(5)]

cnt=0
stay=[0]*5
move=[0]*5
stay[0]=n
while(sum(stay)>0):
    for i in range(5):
        if stay[i]>=num[i]:
            move[i]=num[i]
            stay[i]-=num[i]
        elif stay[i]!=0:
            move[i]=stay[i]
            stay[i]=0
        elif stay[i]==0:
            move[i]=0
    
    for i in range(1,5):
        stay[i]+=move[i-1]
    
    cnt+=1
    
print(cnt)

Fixed submission:
n=int(input())
num=[int(input()) for _ in range(5)]

print(-(-n//min(num))+4)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()

for _ in range(q):
    l,r=map(int,input().split())
    cnt=s[l-1:r].count("AC")
    print(cnt)

Fixed submission:
# 1文字目からi文字目までに何個ACがあるかを調べておき
# その情報を使い回す
n,q=map(int,input().split())
s=input()
AC=[0]*(n+1)

for i in range(n):
    if s[i:i+2]=="AC":
        AC[i+1]=AC[i]+1
    else:
        AC[i+1]=AC[i]    

for _ in range(q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
count=0
import itertools
for i in range(1,n+1):
    combs=list(itertools.combinations(s,i))
    for comb in combs:
        if len(comb)==len(set(comb)):
            count+=1
print(count%(10**9+7))

Fixed submission:
n=int(input())
s=input()

abc = "abcdefghijklmnopqrstuvwxyz"

ans = 1
for i in abc:
    ans *= s.count(i)+1
print((ans-1)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()

i=0
cnt=0
while(True):
    if len(s)<2 or i+1>=len(s):
        break
    if s[i]!=s[i+1]:
        cnt+=1
        s=s[:i]+s[i+2:]
        i=0
    else:
        i+=1
print(cnt*2)
        

Fixed submission:
s=input()
cnt_0=0
cnt_1=0
for i in range(len(s)):
    if s[i]=="0":
        cnt_0+=1 
    else:
        cnt_1+=1
        
    
print(min(cnt_0,cnt_1)*2)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()

i=0
cnt=0
while(True):
    if len(s)<2 or i+1>=len(s):
        break
    if s[i]!=s[i+1]:
        cnt+=1
        s=s[:i]+s[i+2:]
        i=0
    else:
        i+=1
print(cnt*2)
        

Fixed submission:
s=input()
cnt_0=0
cnt_1=0
for i in range(len(s)):
    if s[i]=="0":
        cnt_0+=1 
    else:
        cnt_1+=1
        
    
print(min(cnt_0,cnt_1)*2)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c=map(int, input().split())
count=0

while(True):
    if c>0:
        if b>0:
            c-=1
            b-=1
            count+=2
        else:
            if a>0:
                c-=1
                a-=1
                count+=1
            else:
                c-=1
                count+=1
                break
    else:
        count+=b
        break
print(count)

Fixed submission:
a,b,c=map(int, input().split())
count=0

if c>=b:
    count+=2*b
    c=c-b
    if c>a:
        count+=a
        c=c-a
        if c>0:
            count+=1
    else:
        count+=c
else:
    count+=c+b

print(count)
Buggy python submission (verdict: Runtime Error):
n=int(input())
d,x=map(int,input().split())

for i in range(n):
    A=0
    count=0
    while(A*int(input())+1<=d):
        count+=1
        A+=1
    x+=count
print(x)

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

a=[int(input()) for _ in range(n)]
sum_count=0
for i in range(n):
    A=0
    count=0
    
    while(A*a[i]+1<=d):
        count+=1
        A+=1
    sum_count+=count
print(sum_count+x)
Buggy python submission (verdict: Runtime Error):
ss = ''.join(sorted(input()))
tt = ''.join(sorted(t, reverse=True))

if ss<tt:
    print("Yes")
else:
    print("No")

Fixed submission:
ss = ''.join(sorted(input()))
tt = ''.join(sorted(input(), reverse=True))

if ss<tt:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))

count=0
for a_ele in set(a):
    if a.count(a_ele)%2==1:
        count+=1

print(count)

Fixed submission:
n=int(input())
a={}
for _ in range(n):
    num=int(input())
    if num not in a:
        a[num]=1
    else:
        a[num]+=1
all_count=0
for _, count in a.items():
    if count%2==1:
        all_count+=1
print(all_count)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for _ in range(n):
    num=int(input())
    if num not in a:
        a.append(num)
    else:
        a.remove(num)
print(len(a))

Fixed submission:
n=int(input())
a={}
for _ in range(n):
    num=int(input())
    if num not in a:
        a[num]=1
    else:
        a[num]+=1
all_count=0
for _, count in a.items():
    if count%2==1:
        all_count+=1
print(all_count)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

n=int(input())

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

num_list=[]
for _ in range(n):
    num_list.append(int(input()))
print(lcm(*num_list))

Fixed submission:
n=int(input())

# 最上公倍数を考える
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

num_list=[]
for _ in range(n):
    num_list.append(int(input()))
print(lcm(*num_list))

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

# 最上公倍数を考える
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

num_list=[]
for _ in range(n):
    num_list.append(int(input()))
print(lcm(*num_list))

Fixed submission:
n=int(input())

# 最上公倍数を考える
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

num_list=[]
for _ in range(n):
    num_list.append(int(input()))
print(lcm(*num_list))
Buggy python submission (verdict: Runtime Error):
n,p=map(int, input().split())
a=list(map(int, input().split()))
total=sum( n%2 for i in a )

if total=0:
    if p==0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))

Fixed submission:
n,p=map(int, input().split())
a=list(map(int, input().split()))
total=sum( i%2 for i in a )

if total==0:
    if p==0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
power=1
for i in range(1,N+1):
    power*=i
print(power%(10**9+7))

Fixed submission:
import math
print(math.factorial(int(input()))%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if (i+j+k == S):count+=1

print(count)
        
        

Fixed submission:
K,S=map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
        if (S-i-j <= K and S-i-j>=0):count+=1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
count=0
for i in range(a, b+1):
    if i%x==0:
        count+=1
print(count)

Fixed submission:
a, b, x = map(int, input().split())

print( b//x - (a-1)//x )

Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
count:int=0
for i in range(a, b+1):
    if i%x==0:
        count+=1
print(count)

Fixed submission:
a, b, x = map(int, input().split())

print( b//x - (a-1)//x )

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
count=0
for i in range(a, b+1):
    if i%x==0:
        count+=1
print(count)

Fixed submission:
a, b, x = map(int, input().split())

print( b//x - (a-1)//x )
Buggy python submission (verdict: Runtime Error):
a,b=map(int, input().split())
num_list=list(range(a,b+1))

if a>0:
    print("Positive")
else:
    if b>=0:
        print("Zero")
    elif (a-b-1)%2==0:
        print("Positive")
    elif (a-b-1)%2==1:
        print("Negative")

Fixed submission:
a,b=map(int, input().split())

if a>0:
    print("Positive")
else:
    if b>=0:
        print("Zero")
    elif (a-b-1)%2==0:
        print("Positive")
    else:
        print("Negative")
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()


print(s) if a >= 

Fixed submission:
a = int(input())
s = input()


print(s) if a >= 3200 else print("red")
Buggy python submission (verdict: Runtime Error):
N = int(input())

count = 0

if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(9 + min(N,999) - 100 + 1)
elif N < 10000:
    print(9 + 900)
elif N < 100000:
    print(9 + 900 + min(N , 99999) - 10000 + 1)
else:
    print(90909)

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

print(max(0, c-(a-b)))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,m = map(int,input().split())
a = list(map(int,input().split()))

b = []
for ai in a:
    bisect.insort(b,ai )
# print(b)

for i in range(m):
    tmp = b.pop()//2
    bisect.insort(b, tmp)
    # print(b)

print(sum(b))

Fixed submission:
import heapq
import math

n,m = map(int,input().split())
a = list(map(int,input().split()))

b = []
for ai in a:
    heapq.heappush(b, ai* -1)
# print(b)

for i in range(m):
    tmp = math.ceil(heapq.heappop(b)/2)
    heapq.heappush(b, tmp)
    # print(b)

print(sum(b) * -1)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,m = map(int,input().split())
a = list(map(int,input().split()))

b = []
for ai in a:
    bisect.insort(b,ai )
# print(b)

for i in range(m):
    tmp = b.pop()//2
    bisect.insort(b, tmp)
    # print(b)

print(sum(b))

Fixed submission:
import heapq
import math

n,m = map(int,input().split())
a = list(map(int,input().split()))

b = []
for ai in a:
    heapq.heappush(b, ai* -1)
# print(b)

for i in range(m):
    tmp = math.ceil(heapq.heappop(b)/2)
    heapq.heappush(b, tmp)
    # print(b)

print(sum(b) * -1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m = map(int,input().split())
ab = [[0] for _ in range(m)]

day_max = [0 for _ in range(m)]
for i in range(n):
    a,b = map(int,input().split())
    if a<= m:
        bisect.insort(ab[a-1],b)

for i in range(m):
    day_max[i] = ab[i][-1]
    if day_max[i] > 0:
        ab[i] = ab[i][0:-1]

# print(ab)
# print(day_max)

ans = 0
for day in range(m):
    gain = 0
    dayi = -1
    for i in range(day+1):
        if gain < day_max[i]:
            gain = day_max[i]
            dayi = i
    if dayi != -1:
        ans += day_max[dayi]
        day_max[dayi] = ab[dayi][-1]
        if day_max[dayi] > 0:
            ab[dayi] = ab[dayi][0:-1]
    # print(ans, day, dayi)

print(ans)


Fixed submission:
import heapq
import bisect

n,m = map(int,input().split())
ab = [[0,0,0] for _ in range(n)]

for i in range(n):
    a,b = map(int,input().split())
    ab[i] = [-b,a,b]

ab = sorted(ab, key=lambda x:x[1])

# print(ab)

day = 1
# ans = []
ans = 0
pqueue = []

for i in range(n):
    if ab[i][1] > m:
        break

    if ab[i][1] <= day:
        heapq.heappush(pqueue, ab[i])
    else:
        for j in range(day, ab[i][1]):
            if len(pqueue) > 0:
                ans += heapq.heappop(pqueue)[2]
                # ans += [heapq.heappop(pqueue)[2]] // debug
                day = ab[i][1]
        heapq.heappush(pqueue, ab[i])
    # print(f"i:{i} day:{day} ans:{ans} queue:{pqueue}")

for k in range(day, m+1):
    if len(pqueue) > 0:
        ans += heapq.heappop(pqueue)[2]
        # ans += [heapq.heappop(pqueue)[2]] //debug
        # print(f"## i:{i} day:{k} ans:{ans} queue:{pqueue}")

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int(input())
A = deque(sorted(list(map(int,input().split()))))

operation = []
for i in range(N-1):
    if i%2==0: # Negative
        x = A.pop()
        y = A.popleft()
        operation.append(f'{x} {y}')
        A.appendleft(y + x * -1)
    else: # Positive
        x = A.popleft()
        y = A.pop() 
        operation.append(f'{x} {y}')
        A.append(y + x * -1)

print(sum(list(A)))
for o in operation:
    print(o)

Fixed submission:
import sys
N = int(input())
A = sorted(list(map(int,input().split())))

mn = A[0]
mx = A[-1]
if N ==2:
    print(A[1] - A[0])
    print(A[1],A[0])
    sys.exit()
ope = []
for a in A[1:-1]:
    if a <=0:
        ope.append([mx, a])
        mx -= a
    else:
        ope.append([mn, a])
        mn -= a
ope.append([mx,mn])
print(mx-mn)
for o in ope:
    print(o[0],o[1])

Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int(input())
A = deque(sorted(list(map(int,input().split()))))

operation = []
for i in range(N-1):
    if i%2==0: # Negative
        x = A.pop()
        y = A.popleft()
        operation.append(f'{x} {y}')
        A.appendleft(y + x * -1)
    else: # Positive
        x = A.popleft()
        y = A.pop() 
        operation.append(f'{x} {y}')
        A.append(y + x * -1)

print(sum(list(A)))
for o in operation:
    print(o)

Fixed submission:
import sys
N = int(input())
A = sorted(list(map(int,input().split())))

mn = A[0]
mx = A[-1]
if N ==2:
    print(A[1] - A[0])
    print(A[1],A[0])
    sys.exit()
ope = []
for a in A[1:-1]:
    if a <=0:
        ope.append([mx, a])
        mx -= a
    else:
        ope.append([mn, a])
        mn -= a
ope.append([mx,mn])
print(mx-mn)
for o in ope:
    print(o[0],o[1])
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int, input().split())
S = [list(input()) for _ in range(H)]

w_score = [[0]*W for _ in range(H)]
h_score = [[0]*W for _ in range(H)]

begin = -1
streak = 1
for hi in range(H):
    for wi in range(W):
        if begin == -1 and S[hi][wi]=='.':
            begin = wi
        elif begin != -1 and S[hi][wi] == '.':
            streak += 1
        if wi ==W-1 or(begin != -1 and S[hi][wi]=='#'):
            if wi == W-1 and S[hi][wi]=='.':
                w_score[hi][wi]=streak
            for i in range(W)[begin:wi]:
                w_score[hi][i] = streak
            streak = 1
            begin = -1

# for s in w_score:
#     print(s)
# print('-'*10)

begin = -1
streak = 1
for wi in range(W):
    for hi in range(H):
        if begin == -1 and S[hi][wi]=='.':
            begin = hi
        elif begin != -1 and S[hi][wi] == '.':
            streak += 1
        if hi ==H-1 or(begin != -1 and S[hi][wi]=='#'):
            if hi == H-1 and S[hi][wi]=='.':
                h_score[hi][wi]= streak
            for i in range(H)[begin:hi]:
                h_score[i][wi] = streak
            streak = 1
            begin = -1

# for s in h_score:
#     print(s)
# print('-'*10)

ans = 0
score = [[0]*W for _ in range(H)]
for hi in range(H):
    for wi in range(W):
        w =w_score[hi][wi] 
        h= h_score[hi][wi] 
        score_ = w+h
        score_ += -1 if w>0 and h>0 else 0
        ans = max(ans,score_)
        score[hi][wi] = score_
        
# for s in score:
#     print(s)

print(ans)


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

w_score = [[0]*W for _ in range(H)]
h_score = [[0]*W for _ in range(H)]

begin = -1
streak = 1
for hi in range(H):
    for wi in range(W):
        if begin == -1 and S[hi][wi]=='.':
            begin = wi
        elif begin != -1 and S[hi][wi] == '.':
            streak += 1
        if wi ==W-1 or(begin != -1 and S[hi][wi]=='#'):
            if wi == W-1 and S[hi][wi]=='.':
                w_score[hi][wi]=streak
            for i in range(W)[begin:wi]:
                w_score[hi][i] = streak
            streak = 1
            begin = -1

# for s in w_score:
#     print(s)
# print('-'*10)

begin = -1
streak = 1
for wi in range(W):
    for hi in range(H):
        if begin == -1 and S[hi][wi]=='.':
            begin = hi
        elif begin != -1 and S[hi][wi] == '.':
            streak += 1
        if hi ==H-1 or(begin != -1 and S[hi][wi]=='#'):
            if hi == H-1 and S[hi][wi]=='.':
                h_score[hi][wi]= streak
            for i in range(H)[begin:hi]:
                h_score[i][wi] = streak
            streak = 1
            begin = -1

# for s in h_score:
#     print(s)
# print('-'*10)

ans = 0
score = [[0]*W for _ in range(H)]
for hi in range(H):
    for wi in range(W):
        w =w_score[hi][wi] 
        h= h_score[hi][wi] 
        score_ = w+h
        score_ += -1 if w>0 and h>0 else 0
        ans = max(ans,score_)
        score[hi][wi] = score_
        
# for s in score:
#     print(s)

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

def prob_wins(x,k):
    if x>=k:
        return 1
    return 0.5**math.ceil(math.log2(k/x))

ans = 0
for i in range(1,N+1):
    ans += prob_wins(i,K)
    # print(i,prob_wins(i,K))
print(ans/N)

Fixed submission:
import math
from math import log2
from math import ceil

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

def prob_wins(x,k):
    if x>=k:
        return 1
    return 0.5**ceil(log2(k/x))

ans = 0
for i in range(1,N+1):
    ans += prob_wins(i,K)
    # print(i,prob_wins(i,K))
print(ans/N)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
black_appered = False
ans = 10**9
count =0
# [BBB...WWW...]の組を抽出する
for i in range(n+1):
    left = s[:i]
    right = s[i:]
    count = left.count('#') + right.count('.')
    ans = min(ans,count)
    # print(left," | ", right," | ", count, ans)
print(ans)

Fixed submission:
n = int(input())
s = input()
black_in_left = 0
white_in_right = s.count('.')
ans = black_in_left + white_in_right

for x in s:
    if x == '#':
        black_in_left += 1
    if x == '.':
        white_in_right -= 1
    cost = black_in_left + white_in_right
    ans = min(ans, cost)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
lr = [list(map(lambda x: int(x)-1, input().split())) for _ in range(q)]
for x in lr:
    tmp = s[x[0]:x[1]+1]
    print(tmp.count('AC'))

Fixed submission:
n,q = map(int, input().split())
s = input()
lr = [list(map(lambda x: int(x)-1, input().split())) for _ in range(q)]

ac = [0]*n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        ac[i+1]= ac[i]+1
    else:
        ac[i+1] = ac[i]
for x in lr:
    print(ac[x[1]] - ac[x[0]])
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
ans = a
for x in range(a+1,b+1):
    ans = ans ^ x
print(ans)

Fixed submission:
a,b = map(int,input().split())

ans = 0
length = b-a+1
if a%2 != 0:
    ans = ans^a
if b%2 == 0:
    length -= 1
    ans = ans^b
pair_count= length//2
ans = ans^(pair_count%2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aa = list(map(int,input().split()))

# print(aa)
def mod(xx):
    bb=[]
    minX = min(xx)
    for i in range(len(xx)):
        b = xx[i] % minX if xx[i]>min(xx) else xx[i]
        if b>0:
            bb.append(b)
    return list(set(bb))

while True:
    bb = mod(aa)
    # print(bb)
    if min(aa)==min(bb) or min(bb)==1:
        break
    aa=bb
print(min(bb))

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

ans=aa[0]
for i in range(1,n):
    ans = gcd(ans, aa[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#C
n = int(input())
aa = list(map(int,input().split()))

# print(aa)
def mod(xx):
    bb=[]
    for i in range(len(xx)):
        b = xx[i] if (0<xx[i] and xx[i] <= min(xx)) else xx[i] % min(xx)
        if b>0:
            bb.append(b)
    return list(set(bb))

while True:
    bb = mod(aa)
    # print(bb)
    if min(aa)==min(bb):
        break
    aa=bb
print(min(bb))

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

ans=aa[0]
for i in range(1,n):
    ans = gcd(ans, aa[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# #A
# a,b = map(int,input().split())

# print((a+b) if b%a==0 else (b-a))

#B
# n,m = map(int,input().split())
# aa = []
# kk=[]
# for i in range(n):
#     tmp = list(map(int,input().split()))
#     kk.append(tmp[0])
#     aa.append(tmp[1:])

# aaa = []
# for a in aa:
#     for ai in a:
#         aaa.append(ai)
# ans=0
# for i in range(m):
#     if aaa.count(i+1)==n:
#         ans+=1
# print(ans)

#C
n = int(input())
aa = list(map(int,input().split()))

# print(aa)
def mod(xx):
    bb=[]
    for i in range(len(xx)):
        b = xx[i] if (0<xx[i] and xx[i] <= min(xx)) else xx[i] % min(xx)
        if b>0:
            bb.append(b)
    return bb

while True:
    bb = mod(aa)
    # print(bb)
    if min(aa)==min(bb):
        break
    aa=bb
print(min(bb))

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

ans=aa[0]
for i in range(1,n):
    ans = gcd(ans, aa[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# D-Knapsack 1
N,W = map(int,input().split())
Weight = [0 for _ in range(N)]
Value = [0 for _ in range(N)]
for i in range(N):
    Weight[i],Value[i] = map(int,input().split())

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
    # あらゆる合計重量sum_wに対して品物iを入れるべきか計算する
    for sum_w in range(W+1):
        # i番目を選ぶ場合
        if sum_w - Weight[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - Weight[i]] + Value[i])

        #　i番目を選ばない場合
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

# for d in dp:
#     print(d)

print(dp[N][W])

Fixed submission:
# D-Knapsack 1
N,W = map(int,input().split())
Weight = [0 for _ in range(N)]
Value = [0 for _ in range(N)]
for i in range(N):
    Weight[i],Value[i] = map(int,input().split())

MAX_N = 110
MAX_V = 100100
dp = [[10**15 for i in range(MAX_V)] for j in range(MAX_N)]
dp[0][0] = 0

for i in range(N):
    # あらゆる合計重量sum_wに対して品物iを入れるべきか計算する
    for sum_v in range(MAX_V):
        # i番目を選ぶ場合
        if sum_v - Value[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - Value[i]] + Weight[i])

        # i番目を選ばない場合
        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)
Buggy python submission (verdict: Runtime Error):
a,b,k = list(map(int, input().split()))

def eat(a,b):
    a-= a%2
    b=int(b+a/2)
    a= int(a/2)
    return a,b

for i in range(k):
    if i%2==0:
        a,b = eat(a,b)
    else:
        b,a = eat(b,a)
print(a,b)

Fixed submission:
s = str(input())
if len(s)==2:
    print(s)
else:
    print(s[::-1])
Buggy python submission (verdict: Runtime Error):
%%time
# B
a,b,k = list(map(int, input().split()))

def eat(a,b):
    a-= a%2
    b=int(b+a/2)
    a= int(a/2)
    return a,b

for i in range(k):
    if i%2==0:
        a,b = eat(a,b)
    else:
        b,a = eat(b,a)
print(a,b)

Fixed submission:
# B
a,b,k = list(map(int, input().split()))

def eat(a,b):
    a-= a%2
    b=int(b+a/2)
    a= int(a/2)
    return a,b

for i in range(k):
    if i%2==0:
        a,b = eat(a,b)
    else:
        b,a = eat(b,a)
print(a,b)