Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import ceil
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
c = ceil((n+1)/2)-1
for i in range(c, n):
    if a[i] == 1:
        b[i+1] = '1'
    else:
        b[i+1] = '0'
    
for i in reversed(range(0, c)):
    d = n // (i+1)
    cn = 0
    for j in range(1, d+1, i+1):
        if b[j] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
del b[0]
ee = []
for i,v in enumerate(b):
    if v == '1':
        ee.append(i)
print(' '.join(ee))

Fixed submission:
import sys
input = sys.stdin.readline

from math import ceil

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
    
for i in reversed(range(0, n)):
    d = n // (i+1)
    cn = 0
    for j in range(2, d+1):
        if b[j*(i+1)] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
ee = []
for i,v in enumerate(b):
    if i == 0:
        continue
    if v == '1':
        ee.append(str(i))
print(' '.join(ee))
Buggy python submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
mod = 10**9 + 7
for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    elif k-i== 0:
        print(combinations_count(n-k+1,i)% mod)
    else:
        a = int(math.factorial(k-1)/(math.factorial(k-i)*math.factorial(i-1)))
        print((combinations_count(n-k+1,i)*a) % mod)

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
mod = 10**9 + 7
for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    elif k-i== 0:
        print(combinations_count(n-k+1,i)% mod)
    else:
        a = math.factorial(k-1)//(math.factorial(k-i)*math.factorial(i-1))
        print((combinations_count(n-k+1,i)*a) % mod)

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
mod = 10**9 + 7
for i in range(1,k+1):
    if k-i== 0:
        print(combinations_count(n-k+1,i)% mod)
    else:
        print((combinations_count(n-k+1,i)*combinations_count(k-i+1,i-1) ) % mod)

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
mod = 10**9 + 7
for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    elif k-i== 0:
        print(combinations_count(n-k+1,i)% mod)
    else:
        a = math.factorial(k-1)//(math.factorial(k-i)*math.factorial(i-1))
        print((combinations_count(n-k+1,i)*a) % mod)

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
mod = 10**9 + 7
for i in range(1,k+1):
    print((combinations_count(n-k+1,i)*i**(k-i) ) % mod)

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
mod = 10**9 + 7
for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    elif k-i== 0:
        print(combinations_count(n-k+1,i)% mod)
    else:
        a = math.factorial(k-1)//(math.factorial(k-i)*math.factorial(i-1))
        print((combinations_count(n-k+1,i)*a) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
n ,m = map(int,input().split())
s = set()
for i in range(m):
    l,r = map(int, input().split())
    tmp = {i for i in range(l,r+1)}
    if not s:
        s = s | tmp
        continue
    s = s&tmp
print(len(s))

Fixed submission:
n ,m = map(int,input().split())
ll = 1
rr = n
for i in range(m):
    l,r = map(int, input().split())
    if l > ll:
        ll = l
    if r < rr:
        rr = r
ans = rr - ll +1
if ans > 0:
    print(ans)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
a = [int(input()) for x in range(5)]
sum = 0
b = []
for i in range(5):
    if a[i]%10 == 0:
        sum += a[i]
    else:
        c = a[i] + (10 -a[i]%10)
        sum += c
        b.append(a[i]%10)
if b is not None:
    b.sort()
    sum -= 10 - b[0]
print(sum)

Fixed submission:
a = [int(input()) for x in range(5)]
sum = 0
b = []
for i in range(5):
    if a[i]%10 == 0:
        sum += a[i]
    else:
        c = a[i] + (10 -a[i]%10)
        sum += c
        b.append(a[i]%10)
if b != []:
    b.sort()
    sum -= 10 - b[0]
print(sum)

Buggy python submission (verdict: Runtime Error):
a = [int(input()) for x in range(5)]
sum = 0
b = []
for i in range(5):
    if a[i]%10 == 0:
        sum += a[i]
    else:
        c = a[i] + (10 -a[i]%10)
        sum += c
        b.append(a[i]%10)
b.sort()
sum -= 10 - b[0]
print(sum)

Fixed submission:
a = [int(input()) for x in range(5)]
sum = 0
b = []
for i in range(5):
    if a[i]%10 == 0:
        sum += a[i]
    else:
        c = a[i] + (10 -a[i]%10)
        sum += c
        b.append(a[i]%10)
if b != []:
    b.sort()
    sum -= 10 - b[0]
print(sum)
Buggy python submission (verdict: Runtime Error):
s = input()
l = []
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        l.append(1)
    else:
        l.append(0)
tmp = 0
counter = []
for i in range(len(l)):
    if l[i] == 0:
        counter.append(tmp)
        tmp = 0
    else:
        tmp += 1

print(max(counter))

Fixed submission:
s = input()
l = []
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        l.append(1)
    else:
        l.append(0)
tmp = 0
counter = []
for i in range(len(l)):
    if l[i] == 0:
        counter.append(tmp)
        tmp = 0
    else:
        if i == len(l) - 1:
            tmp += 1
            counter.append(tmp)
        else:
            tmp += 1

print(max(counter))
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int , input().split( )))

L_max = max(L)
L_sum = sum(L)

if L_max < L_sum - L_max:
    print("Yes")
else:
    print("No")

Fixed submission:
s = list(map(float ,input().split( )))
print(s[0]/s[1])

Buggy python submission (verdict: Runtime Error):
s = input().split( )
print(s[0]/s[1])

Fixed submission:
s = list(map(float ,input().split( )))
print(s[0]/s[1])
Buggy python submission (verdict: Runtime Error):
s = input().split() #s_1 s_2を分割して取得し、sに値を入れる
print(s[0] * s[1] / 2)

Fixed submission:
i = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる
print(int((i[0] * i[1]) / 2))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def chmin(min,cur):
	if min > cur:
		min = cur
	return min

n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float('inf')]*n
dp[0] = 0

for i in range(n):
	for j in range(k):
		try:
			dp[i+j+1] = chmin(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]))
		except:
			break

print(dp[n-1])

Fixed submission:
import sys
input = sys.stdin.readline

def chmin(min,cur):
	if min > cur:
		min = cur
	return min

n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float('inf')]*n
dp[0] = 0

for i in range(n):
	for j in range(k):
		try:
			dp[i+j+1] = chmin(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]))
		except:
			break

print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
def chmin(min,cur):
	if min > cur:
		min = cur
	return min

n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float('inf') for i in range(n)]
dp[0] = 0

for i in range(n):
	for j in range(k):
		try:
			dp[i+j+1] = chmin(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]))
		except:
			break

print(dp[n-1])

Fixed submission:
import sys
input = sys.stdin.readline

def chmin(min,cur):
	if min > cur:
		min = cur
	return min

n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float('inf')]*n
dp[0] = 0

for i in range(n):
	for j in range(k):
		try:
			dp[i+j+1] = chmin(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]))
		except:
			break

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
s = [int(input()) for i in range(3)]
if s[0] == 1:
    print('Hello World')
if s[0] == 2:
    print(int(s[1] + s[2]))

Fixed submission:
age = int(input())
if age == 1:
    print('Hello World')
    
if age == 2:
    s = [int(input()) for i in range(2)]
    print(int(s[0] + s[1]))
Buggy python submission (verdict: Runtime Error):
num = str(input())
for i in range(3):
    if num[i] == '1':
        num[i] = '9'
    else:
        num[i] = '1':
answer = num[0]+num[1]+num[2]
print(int(answer))

Fixed submission:
a = input()
b = []
for i in range(3):
    if a[i] == '1':
        b.append('9')
    else:
        b.append('1')
print(''.join(b))
Buggy python submission (verdict: Runtime Error):
n,k = map(int(), input().split())
if n%k==0:
    print(0)
else:
    print(1)

Fixed submission:
n,k = map(int, input().split())
if n%k==0:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
s = sorted(input().split())
ans = 0
for i in s:
    if s[i] == '+':
        ans+=1
    else:
        ans -=1
print(ans)

Fixed submission:
s = sorted(input())
ans = 0
for i in s:
    if i == '+':
        ans+=1
    else:
        ans -=1
print(ans)

Buggy python submission (verdict: Runtime Error):
s = sorted(input().split())
ans = 0
for i in s:
    if s[i] == '+':
        ans+=1
    else:
        ans -=1
print('ans')

Fixed submission:
s = sorted(input())
ans = 0
for i in s:
    if i == '+':
        ans+=1
    else:
        ans -=1
print(ans)

Buggy python submission (verdict: Runtime Error):
s = sorted(input())
ans = 0
for i in s:
    if s[i] == '+':
        ans+=1
    else:
        ans -=1
print('ans')

Fixed submission:
s = sorted(input())
ans = 0
for i in s:
    if i == '+':
        ans+=1
    else:
        ans -=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
if b<a:
    print(a)
else:
    print(a-1)

Fixed submission:
a,b = map(int,input().split())
if b<a:
    print(a-1)
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
c1 = list(input().split())
c2 = list(input().split())
c3 = list(input().split())

print(c1[0]+c2[1]+c3[2])

Fixed submission:
c = [0,0,0]
for i in range(3):
    c[i] = list(input().split())
    
print(c[0][0][0]+c[1][0][1]+c[2][0][2])
Buggy python submission (verdict: Runtime Error):
C1 = list(input().split())
C2 = list(input().split())

if C1[0]==C2[2] and C1[1]==C2[1] and C1[2]==C2[0]:
    print('YES')
else:
    print('NO')

Fixed submission:
C1 = input()
C2 = input()

if C1[0]==C2[2] and C1[1]==C2[1] and C1[2]==C2[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
xt = list(map(int, input().split()))

if xt[0]-xt[1]>=0:
    print(xt[0]-xt[1])
else:
    print(0)print(xt[0]-xt[1])

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

if xt[0]-xt[1]>=0:
    print(xt[0]-xt[1])
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
if ab[0] == "H" and ab[1] == "H":
    print("H")
    
elif ab[0] == "H" and ab[1] == "D":
    print("D")
    
elif ab[0] == "D" and ab[1] == "H":
    print("D")
    
elif ab[0] == "D" and ab[1] == "D":
    print("H")

Fixed submission:
ab = list(input().split())

if ab[0] == "H" and ab[1] == "H":
    print("H")
    
elif ab[0] == "H" and ab[1] == "D":
    print("D")
    
elif ab[0] == "D" and ab[1] == "H":
    print("D")
    
elif ab[0] == "D" and ab[1] == "D":
    print("H")
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())
a = []
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            a.append(i+j+l)
b = a.count(s)
print(b)

Fixed submission:
k,s = map(int, input().split())
a = 0
for i in range(min(s+1, k+1)):
    for j in range(min(s - i + 1, s+1, k+1)):
        if s - i - j <= k:
            a += 1
print(a)
Buggy python submission (verdict: Runtime Error):
whn = list (map(int, input().split()))
x = 0
y = 0

for i in range(len(whn[2])):
    xya = list(map(int,input().split()))
    if xya[2] == 1:
        x = max(x, xya[0])
    elif xya[2] == 2:
        whn[0] = min(whn[0], xya[0])
    elif xya[2] == 3:
        y = max(y, xya[0])
    else:
        whn[1] = min(whn[1], xya[1])

print((whn[0]-x)*(whn[1]-y))


Fixed submission:
whn = list (map(int, input().split()))
x = 0
y = 0
flag = 0

for i in range(whn[2]):
    xya = list(map(int,input().split()))
    if xya[2] == 1:
        x = max(x, xya[0])
    elif xya[2] == 2:
        whn[0] = min(whn[0], xya[0])
    elif xya[2] == 3:
        y = max(y, xya[1])
    else:
        whn[1] = min(whn[1], xya[1])
    if x >= whn[0] or y >= whn[1]:
        print(0)
        flag += 1
        break
        
if flag == 0:
    print((whn[0]-x)*(whn[1]-y))
Buggy python submission (verdict: Runtime Error):
s = input().split() #s_1 s_2を分割して取得し、sに値を入れる
five = 0
seven = 0
for i range(3):
    if s[i] == '5':
        five += 1
    if s[i] == '7':
        seven += 1
        
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')

Fixed submission:
s = input().split() #s_1 s_2を分割して取得し、sに値を入れる
five = 0
seven = 0
for i in range(3):
    if s[i] == '5':
        five += 1
    if s[i] == '7':
        seven += 1
        
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
import sys
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
    sys.exit()
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
#C
from sympy import sieve
x = int(input())
print(min([i for i in sieve.primerange(x,10**6)]))

Fixed submission:
#C
x = int(input())
r = int(x**0.5)+1
l = len(str(x)) 
lst = [i for i in range(x,x+r)]

for i in range(2,r):
    for j in lst:
        if j % i == 0:
            lst.remove(j)
print(min(lst))
Buggy python submission (verdict: Runtime Error):
import math
a, b = list(map(int,input().split()))
print(int(a * b // math.gcd(a, b)))

Fixed submission:
from fractions import gcd
a, b = list(map(int,input().split()))
print(int(a * b//gcd(a, b)))

Buggy python submission (verdict: Runtime Error):
import math
a, b = list(map(int,input().split()))
print(int(a * b / math.gcd(a, b)))

Fixed submission:
from fractions import gcd
a, b = list(map(int,input().split()))
print(int(a * b//gcd(a, b)))

Buggy python submission (verdict: Runtime Error):
import math
a, b = list(map(int,input().split()))
print(int(a * b / math.gcd(a, b)))

Fixed submission:
from fractions import gcd
a, b = list(map(int,input().split()))
print(int(a * b//gcd(a, b)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
    print(int((N*(N-1))//2))

Fixed submission:
N = int(input())
print(int((N*(N-1))//2))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(N):
    ans += i
print(ans)

Fixed submission:
N = int(input())
print(int((N*(N-1))//2))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(N):
    ans += i
print(ans)

Fixed submission:
N = int(input())
print(int((N*(N-1))//2))
Buggy python submission (verdict: Runtime Error):
#ABC135A - Harmony
A, B = list(map(int,input().split()))
if (max(A,B) - min(A,B)) % 2 == 1:
    print("IMPOSSIBLE")
else:a
    print((A+B)//2)

Fixed submission:
#ABC135A - Harmony
A, B = list(map(int,input().split()))
if (max(A,B) - min(A,B)) % 2 == 1:
    print("IMPOSSIBLE")
else:
    print((A+B)//2)

Buggy python submission (verdict: Runtime Error):
#ABC135A - Harmony
import math
A, B = list(map(int,input().split()))
if math.abs(A-B) % 2 == 1:
    print("IMPOSSIBLE")
else:
    print((A+B)//2)

Fixed submission:
#ABC135A - Harmony
A, B = list(map(int,input().split()))
if (max(A,B) - min(A,B)) % 2 == 1:
    print("IMPOSSIBLE")
else:
    print((A+B)//2)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = list(map(int,input().split()))
lt = []
for k in range(L,R+1):
    if k % 2019 == 0:
        print(0)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            s = 0
            t = 0
            s = i % 2019 
            t = j % 2019
            ans = (s*t) % 2019
            lt.append(ans)
    print(min(lt))

Fixed submission:
L,R = list(map(int,input().split()))
lt = []
if R-L == 1:
    print((L*R) % 2019)
elif R-L >= 2:
    for k in range(L,R+1):
        if k % 673 == 0:
            lt.append(0)
            break
    l = L % 673
    r = R % 673
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = (i*j) % 2019
            lt.append(ans)
    print(min(lt))

Buggy python submission (verdict: Time Limit Exceeded):
L,R = list(map(int,input().split()))
lt = []
for i in range(L,R+1):
    for j in range(i+1,R+1):
        s = 0
        t = 0
        s = i % 2019 
        t = j % 2019
        ans = (s*t) % 2019
        lt.append(ans)
print(min(lt))

Fixed submission:
L,R = list(map(int,input().split()))
lt = []
if R-L == 1:
    print((L*R) % 2019)
elif R-L >= 2:
    for k in range(L,R+1):
        if k % 673 == 0:
            lt.append(0)
            break
    l = L % 673
    r = R % 673
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = (i*j) % 2019
            lt.append(ans)
    print(min(lt))
Buggy python submission (verdict: Runtime Error):
#ABCA - Security
a = int(input())
s = list(a)
count = 0
for i in range(3):
    if s[i] != s[i+1]:
        count += 1
if count == 3:
    print("Good")
else:
    print("Bad")

Fixed submission:
#ABCA - Security
a = str(input())
s = list(a)
count = 0
for i in range(3):
    if s[i] != s[i+1]:
        count += 1
if count == 3:
    print("Good")
else:
    print("Bad")
Buggy python submission (verdict: Time Limit Exceeded):
#動的計画法
#B 問題 - Frog 2
n, k = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("INF")]*(n)
dp[0] = 0
for i in range(1,n):
    for j in range(min(k,i)+1):
        dp[i] = min(dp[i],(dp[i-j]+abs(h[i]-h[i-j])))
    
print(dp[n-1])

Fixed submission:
#https://qiita.com/drken/items/dc53c683d6de8aeacf5a(DP問題集)
#https://atcoder.jp/contests/dp/tasks/dp_b
#ボトムアップ的
N, K = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N,1):
    dp[i] = min([dp[i-j] + abs(h[i] - h[i-j]) for j in range(1,min(i+1,K+1))])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
#動的計画法
#B 問題 - Frog 2
n, k = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("INF")]*(n)
dp[0] = 0
for i in range(1,n):
    kouho= []
    for j in range(min(k,i)+1):
        kouho.append(dp[i-j]+abs(h[i]-h[i-j]))
    dp[i] = min(kouho)
    
print(dp[n-1])

Fixed submission:
#https://qiita.com/drken/items/dc53c683d6de8aeacf5a(DP問題集)
#https://atcoder.jp/contests/dp/tasks/dp_b
#ボトムアップ的
N, K = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N,1):
    dp[i] = min([dp[i-j] + abs(h[i] - h[i-j]) for j in range(1,min(i+1,K+1))])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
#https://qiita.com/drken/items/dc53c683d6de8aeacf5a(DP問題集)
#https://atcoder.jp/contests/dp/tasks/dp_b
#ボトムアップ的
N, K = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N,1):
    dp[i] = min([dp[i-j] + abs(h[i] - h[i-j]) for j in range(1,min(i+1,K+1))])

print(dp[N-1])

Fixed submission:
#https://qiita.com/drken/items/dc53c683d6de8aeacf5a(DP問題集)
#https://atcoder.jp/contests/dp/tasks/dp_b
#ボトムアップ的
N, K = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N,1):
    dp[i] = min([dp[i-j] + abs(h[i] - h[i-j]) for j in range(1,min(i+1,K+1))])

print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
# 動的計画法
#D - Knapsack 1
#https://atcoder.jp/contests/dp/tasks/dp_d
#インデックスと重さを対応させていく
N, W = list(map(int,input().split()))
item = [list(map(int,input().split())) for i in range(N)]
dp = [-1]*(W+1)
dp[0] = 0
for i in range(N):
    w = item[i][0]
    v = item[i][1]
    #print(w,v)
    for j in range(W-w,-1,-1):
        if dp[j] != -1:
            if dp[j] + v > dp[j+w]:
                dp[j+w] = dp[j] + v
        #print(dp)
print(max(dp))

Fixed submission:
#動的計画法
#D - Knapsack 1
#インデックスの順番でなく重さを基準に動的計画していく
N, W = list(map(int,input().split()))
item = [list(map(int,input().split())) for i in range(N)]
dp = [-1]*(W+1)
dp[0] = 0
for i in range(N):
    w = item[i][0]
    v = item[i][1]
    #print(w,v)
    for j in range(W-w,-1,-1):
        if dp[j] != -1:
            if dp[j] + v > dp[j+w]:
                dp[j+w] = dp[j] + v
        #print(dp)
print(max(dp))
Buggy python submission (verdict: Runtime Error):
#ABC104C - All Green
import math
def dfs(i,s,c,r):
    global ans
    if i == d:
        if s < g:
            use = max(r)
            n = min(pc[use -1][0], math.ceil((g-s)/(use*100)))
            c += n
            s += n+use*100
        if s >= g:
            ans = min(ans,c)
    
    else:
        dfs(i+1, s, c, r)
        dfs(i+1, s+ pc[i][0]*(1+1)*100+pc[i][1],c+pc[i][0],r-{i+1})
        
d,g = list(map(int,input().split()))
pc = [list(map(int,input().split())) for i in range(d)]

ans = float("inf")

dfs(0,0,0,set(range(1,d+1)))
print(ans)

Fixed submission:
#ABC104C - All Green
import math
def dfs(i,s,c,r):
    global ans
    if i == d:
        if s < g:
            use = max(r)
            n = min(pc[use -1][0], math.ceil((g-s)/(use*100)))
            c += n
            s += n*use*100
        if s >= g:
            ans = min(ans,c)
    
    else:
        dfs(i+1, s, c, r)
        dfs(i+1, s+ pc[i][0]*(i+1)*100+pc[i][1],c+pc[i][0],r-{i+1})
        
d,g = list(map(int,input().split()))
pc = [list(map(int,input().split())) for i in range(d)]

ans = float("inf")

dfs(0,0,0,set(range(1,d+1)))
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())

a = len(s)
b = len(t)
#最小の文字列となるためには前にaを固めたほうが良いため後ろから入れる
for i in range(a-b,-1,-1):
    t_kamo = s[i:i+b]
    count = 0
    for j in range(b):
        if t_kamo[j] == t[j] or t_kamo[j] == "?":
            count += 1
    if count == b:
        #replaceメソット(リストには使えない,strに直接使う？)
        #条件分で記述
        ans = "".join(s[:i]+t+s[i+b:])
        print(ans.replace("?","a"))
        sys.exit()
        #ans = []"a" if "?" for i in ans]
        #print("join.(ans)")でもいけるはず
        
print("UNRESTORABLE")
            
    

Fixed submission:
import sys
S = list(input())
T = list(input())

n = len(S)
m = len(T)

for i in range(n-m,-1,-1):
    K = []
    K = S[i:i+m]
    #print(K)
    for j in range(m):
        if K[j] == "?":
            K[j] = T[j]
    if K == T:
        print("".join((S[:i]+T+S[i+m:])).replace("?","a"))
        sys.exit()

print("UNRESTORABLE")