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

Fixed submission:
n, m = map(int, input().split())
ex = [0 for i in range(n)]
fri = {}

for i in range(m):
    a, b = map(int, input().split())
    if ex[a-1] == 0 and ex[b-1] == 0:
        if a > b:
            a, b = b, a
        ex[a-1] = a
        ex[b-1] = a
        fri[a] = [a, b]
    elif ex[a-1] == 0:
        ex[a-1] = ex[b-1]
        fri[ex[b-1]].append(a)
    elif ex[b-1] == 0:
        ex[b-1] = ex[a-1]
        fri[ex[a-1]].append(b)
    elif ex[a-1] == ex[b-1]:
        continue
    else:
        shozoku = min(ex[a-1], ex[b-1])
        mu = max(ex[a-1], ex[b-1])
        for j in range(len(fri[mu])):
            ex[fri[mu][j]-1] = shozoku
        fri[shozoku].extend(fri.pop(mu))

ans = 1
for key in fri:
    ans = max(ans, len(fri[key]))
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ex = [0 for i in range(n)]
fri = {}

for i in range(m):
    a, b = map(int, input().split())
    if ex[a-1] == 0 and ex[b-1] == 0:
        if a > b:
            a, b = b,a
        ex[a-1] = a
        ex[b-1] = a
        fri[a] = [a, b]
    elif ex[a-1] == 0:
        ex[a-1] = ex[b-1]
        fri[ex[b-1]].append(a)
    elif ex[b-1] == 0:
        ex[b-1] = ex[a-1]
        fri[ex[a-1]].append(b)
    elif ex[a-1] == ex[b-1]:
        continue
    else:
        shozoku = min(ex[a-1], ex[b-1])
        mu = max(ex[a-1], ex[b-1])
        fri[shozoku].extend(fri.pop(mu))

ans = 0
for key in fri:
    ans = max(ans, len(fri[key]))
print(ans)
Problem p02642 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
aMax = a[-1]
ans = 0
dp = [1] * (aMax+1)

for i in range(n-1):
    p = a[i]
    if dp[p] == 1:
        for j in range(aMax//p+1):
            dp[p*j] = 0
        if a[i] != a[i+1]:
            ans += 1
if dp[aMax] == 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0

for i in range(n-1):
    for j in range(i+1, n):
        if a[i]%a[j] == 0:
            break
        if j == n-1:
            ans+=1

if a[-1] != a[-2]:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = set(i for i in range(n))
ans = [0]*n
warizai_index = set()

for i in range(n):
    for wari in warizai_index:
        if a[i]%a[wari] == 0 and i != wari:
            ans[i] = 1
            b.remove(i)
            break
    if ans[i] == 1:
        continue
    
    for j in b:
        if i == j:
            continue
        if a[i]%a[j] == 0:
            ans[i] = 1
            b.remove(i)
            warizai_index.add(j)
            b.remove(j)
            break

print(ans.count(0))
Problem p02646 (python)

Fixed submission:
oni_x, oni_speed = map(int, input().split())
chi_x, chi_speed = map(int, input().split())
time = int(input())
ans = False


if oni_speed > chi_speed:
    sa = abs(oni_x - chi_x)
    sa_speed = oni_speed - chi_speed
    if sa_speed*time >= sa:
        ans = True

if ans:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
oni_x, oni_speed = map(int, input().split())
chi_x, chi_speed = map(int, input().split())
time = int(input())
ans = False


if oni_speed > chi_speed:
    sa = abs(oni_x, chi_x)
    sa_speed = oni_speed - chi_speed
    if sa_speed*time >= sa:
        ans = True

if ans:
    print('YES')
else:
    print('NO')
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
import sys
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
#print(graph)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b
# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now , prev = -1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next , now)

dfs(0)
print(*point)

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
#print(graph)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b
# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now , prev = -1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next , now)

dfs(0)
print(*point)

Buggy submission (verdict: Runtime Error):
def tuika(newNode,pea):
    nodes[pea].append(newNode)
    if pea != 1:
        tuika(newNode, nodes[pea][0])

n, q = map(int, input().split())
nodes = [[] for _ in range(n+1)]
nodes[1].append(0)
counts = [0 for _ in range(n+1)]

for i in range(n-1):
    pea, chi = map(int, input().split())
    nodes[chi].append(pea)
    tuika(chi, pea)

for i in range(q):
    p, q = map(int, input().split())
    if len(nodes[p]) != 1:
        for j in range(1,len(nodes[p])):
            counts[nodes[p][j]] += q
    counts[p] += q

str_counts = map(str, counts[1:])
print(' '.join(str_counts))

Buggy submission (verdict: Runtime Error):
def tuika(newNode,pea):
    nodes[pea].append(newNode)
    if pea != 1:
        tuika(newNode, nodes[pea][0])

n, q = map(int, input().split())
nodes = [[] for _ in range(n+1)]
nodes[1].append(0)
counts = [0 for _ in range(n+1)]

for i in range(n-1):
    pea, chi = map(int, input().split())
    nodes[chi].append(pea)
    tuika(chi, pea)

for i in range(q):
    p, q = map(int, input().split())
    for j in range(1,len(nodes[p])):
        counts[nodes[p][j]] += q
    counts[p] += q

#print(counts[1:])
str_counts = map(str, counts[1:])
print(' '.join(str_counts))
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())

MIN = 2018
if R-L > 4039:
    MIN = 0


MOD = 2019
L = L%MOD
R = R%MOD
if L > R:
    L, R = R, L
elif L == R:
    MIN = 0


for i in range(L, R):
    for j in range(i+1, R+1):
        buf = (i*j) % MOD
        #print(i, j)
        MIN = min(buf, MIN)

print(MIN)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

MIN = 2018
if R-L > 4039:
    MIN = 0


MOD = 2019
L = L%MOD
R = R%MOD
if L > R:
    L, R = R, L
else if L == R:
    MIN = 0


for i in range(L, R):
    for j in range(i+1, R+1):
        buf = (i*j) % MOD
        #print(i, j)
        MIN = min(buf, MIN)

print(MIN)
Problem p03000 (python)

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

L = list(map(int, input().split()))

dis = 0
ans = 1
for i in range(n):
    dis += L[i]
    if dis > x:
        dis -= L[i]
        break
    ans += 1

print(ans)

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

L = list(map(int, input().split()))

dis = 0
ans = 1
for i in range(n+1):
    dis += L[i]
    if dis > x:
        dis -= L[i]
        break
    ans += 1

print(ans)
Problem p03730 (python)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

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

if c%gcd(a, b) == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
import math

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

if c%math.gcd(a, b) == 0:
    print('YES')
else:
    print('NO')
Problem p03761 (python)

Fixed submission:
n = int(input())

s = []
for i in range(n):
    s.append(input())

ans = ""

for i in range(len(s[0])):
    check = 0
    for j in range(n):
        if not s[0][i] in s[j]:
            check = 1
    if check == 0:
        ans = ans + s[0][i]
        for j in range(1,n):
            re = s[0][i]
            s[j] = s[j].replace(re , '', 1)

ans = ''.join(sorted(ans))
print(ans)

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

s = []
for i in range(n):
    s.append(input())

ans = ""

for i in range(len(s[0])):
    check = 0
    for j in range(n):
        if not s[0][i] in s[j+1]:
            check = 1
    if check == 0:
        ans = ans + s[0][i]

ans = ''.join(sorted(ans))
print(ans)
Problem p03773 (python)

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

ans = a+b

if ans > 23:
    ans = ans - 24

print(ans)

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

ans = a+b

if ans > 24:
    ans -=24

print(ans)
Problem p03797 (python)

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

if n*2 < m:
    c = m - (n*2)
    ans = int(c/4) + n
else:
    ans = int(m/2)

print(ans)

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

if n*2 < m:
    c = m - (n*2)
    ans = int(c/4) + n
else:
    ans = int(c/2)

print(ans)
Problem p02642 (python)

Fixed submission:
n = int(input())
li = list(map(int, input().split()))
li.sort()
inf = (10**6)+1
isprime = [False]*(inf+1)
for i in li:
    isprime[i] = True
temp = 0
for i in li:
    if i == temp:
        isprime[i] = False
    if not isprime[i]:
        continue
    for k in range(i*2, inf+1, i):
        isprime[k] = False
    temp = i
prime_list = []
for i in range(len(li)):
      if i+1<len(li):
            if li[i] == li[i+1]:
                isprime[li[i]] = False
for i in range(1, inf+1):
    if isprime[i]:
        prime_list.append(i)
print(len(prime_list))

Buggy submission (verdict: Runtime Error):
from numba import jit
n = int(input())
li = list(map(int, input().split()))
li.sort()
inf = (10**6)+1
isprime = [False]*(inf+1)
for i in li:
    isprime[i] = True
temp = 0
@jit
for i in li:
    if i == temp:
        isprime[i] = False
    if not isprime[i]:
        continue
    for k in range(i*2, inf+1, i):
        isprime[k] = False
    temp = i
prime_list = []
@jit
for i in range(len(li)):
      if i+1<len(li):
            if li[i] == li[i+1]:
                isprime[li[i]] = False
for i in range(1, inf+1):
    if isprime[i]:
        prime_list.append(i)
print(len(prime_list))

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
li.sort()
inf = (10**6)+1
isprime = [False]*(inf+1)
for i in li:
    isprime[i] = True
for i in li:
    if i == temp:
        isprime[i] = False
    if not isprime[i]:
        continue
    for k in range(i*2, inf+1, i):
        isprime[k] = False
    temp = i
prime_list = []
for i in range(1, inf+1):
    if isprime[i]:
        prime_list.append(i)
print(len(prime_list))

Buggy submission (verdict: Runtime Error):

n = int(input())
li = list(map(int, input().split()))
li.sort()
inf = 2*(10**5)+1
isprime = [False]*(inf)
for i in li:
    isprime[i] = [True]
for i in range(len(li)):
    if i+1<len(li):
      if li[i] == li[i+1]:
        isprime[li[i]] = False
for i in li:
    if not isprime[i]:
        continue
    for k in range(i+i, inf, i):
        isprime[k] = False
prime_list = []
for i in range(inf):
    if isprime[i]:
        prime_list.append(i)
print(len(prime_list))
Problem p02708 (python)

Fixed submission:
N, K = map(int, input().split())
S1 = 0
S2 = 0
for k in range(1, N+1):
    S1 += k*N - k*(k-1) +1
    S1 %= 10**9 + 7
for k in range(1, K):
    S2 += k*N - k*(k-1) +1
    S2 %= 10**9 + 7
    
S = S1 - S2 + 1
S %= 10**9 +7

print(S)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.readline
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10 ** 9 + 7

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

k = np.arange(K, N + 2, dtype=np.int64)
low = (k - 1) * k // 2
high = N * k - low
cnt = high - low + 1
print(cnt.sum() % MOD)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10 ** 9 + 7

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

k = np.arange(K, N + 2, dtype=np.int64)
low = (k - 1) * k // 2
high = N * k - low
cnt = high - low + 1
print(cnt.sum() % MOD)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10 ** 9 + 7

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

k = np.arange(K, N + 2, dtype=np.int64)
low = (k - 1) * k // 2
high = N * k - low
cnt = high - low + 1
print(cnt.sum() % MOD)
Problem p02720 (python)

Fixed submission:
#n桁のるんるん数のrisutoを求める
import sys

sys.setrecursionlimit(10**9)

def runrun(n):
    if n == 1:
        return [['1','2','3','4','5','6','7','8','9']]
    else:
        li = runrun(n-1)
        li2 = []
        for i in range(len(li[n-2])):
            p = int(li[n-2][i][-1])
            if p == 0:
                li2.append(li[n-2][i]+'0')
                li2.append(li[n-2][i]+'1')
            elif p == 9:
                li2.append(li[n-2][i]+str(8))
                li2.append(li[n-2][i]+'9')
            else:
                li2.append(li[n-2][i]+str(p-1))
                li2.append(li[n-2][i]+str(p))
                li2.append(li[n-2][i]+str(p+1))
        li2 =[li2]
        li.extend(li2)
        return li
    


x = int(input())
t = True
k=1
b = 0
while t:
    a = runrun(k)
    b = 0
    #k桁までに何個るんるん数があるか数えるもの
    for i in range(len(a)):
        b+=(len(a[i]))
        #k桁ということが確定したあと以下の処理を行う
    if x <= b:
        t = False
        if k == 1:
            print(x)
        else:
            tmp = runrun(k-1)
            c = 0
#まずk-1桁までのるんるん数の数を数える
            for i in range(len(tmp)):
                c += (len(tmp[i]))
            s = a[k-1][x-c-1]
            print(int(s))
    else:
        k += 1

Buggy submission (verdict: Runtime Error):
#n桁のるんるん数のrisutoを求める
import sys

sys.setrecursionlimit(10**9)
def runrun(n):
    if n == 1:
        return [['1','2','3','4','5','6','7','8','9']]
    else:
        li = runrun(n-1)
        li2 = []
        for i in range(len(li[n-2])):
            p = int(li[n-2][i][-1])
            if p == 0:
                li2.append(li[n-2][i]+'0')
                li2.append(li[n-2][i]+'1')
            elif p == 9:
                li2.append(li[n-2][i]+str(8))
                li2.append(li[n-2][i]+'9')
            else:
                li2.append(li[n-2][i]+str(p-1))
                li2.append(li[n-2][i]+str(p))
                li2.append(li[n-2][i]+str(p+1))
        li2 =[li2]
        li.extend(li2)
        return li
    


x = int(input())
t = True
k=1
b = 0
while t:
    
    a = runrun(k)
    #k桁までに何個るんるん数があるか数えるもの
    for i in range(len(a)):
        b+=(len(a[i])-1)
        #k桁ということが確定したあと以下の処理を行う
    if x <= b:
        t = False
        if k == 1:
            print(x)
        else:
            tmp = runrun(k-1)
            c = 0
            for i in range(len(tmp)):
                c+=len(tmp[i])
            s = a[k-1][x-c-1]
            print(int(s))
    else:
        b += 1
        k += 1
Problem p02727 (python)

Fixed submission:
x,y,a,b,c = map(int, input().split())
li_p = list(map(int, input().split()))
li_q = list(map(int, input().split()))
li_r = list(map(int, input().split()))
li_p.sort(reverse=True)
li_q.sort(reverse=True)
li_r.sort(reverse=True)
r = []
for i in range(x):
  r.append(li_p[i])
for i in range(y):
  r.append(li_q[i])
for i in range(c):
  r.append(li_r[i])
r.sort(reverse=True)
print(sum(r[:x+y]))

Buggy submission (verdict: Runtime Error):
x,y,a,b,c = map(int, input().split())
li_p = list(map(int, input().split()))
li_q = list(map(int, input().split()))
li_r = list(map(int, input().split()))
li_p.sort(reverse=True)
li_q.sort(reverse=True)
li_r.sort(reverse=True)
p,q = [],[]
for i in range(x):
  r.append(li_p[i])
for i in range(y):
  r.append(li_q[i])
for i in range(c):
  r.append(li_r[i])
r.sort(reverse=True)
print(sum(r[:x+y]))
Problem p02765 (python)

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

if N > 9:
  print(R)
else:
  R += 100*(10-N)
  print(R)

Buggy submission (verdict: Runtime Error):
N = int(input())
R = int(input())

if N > 9:
  print(R)
else:
  R += 100*(10-N)
  print(R)
Problem p02780 (python)

Fixed submission:
x,y = map(int,input().split())
li = list(map(int,input().split()))
from collections import deque
l = []
for i in range(len(li)):
    l.append((1+ li[i])/2)
from itertools import accumulate
a = list(accumulate(l))
M = a[y-1]
for i in range(len(a)-y):
    m = a[i+y] - a[i]
    if m > M:
        M = m
print(M)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
li = list(map(int,input().split()))
from collections import deque
l = []
for i in range(len(li)):
    l.append((1+ li[i])/2)
from itertools import accumulate
a = list(accumulate(l))
M = a[y-1]
for i range(len(a)-y):
    m = a[i+y] - a[i]
    if m > M:
        M = m
print(M)
Problem p02802 (python)

Fixed submission:
x, y = map(int, input().split())
dd = {}
c = 0 #間違い数
p = 0 #AC数
for i in range(x):
    dd[i+1] = 0
for _ in range(y):
    a, b = map(str, input().split())
    a = int(a)
    if b == 'WA':
        if dd[a] == 'o':
            continue
        else:
            dd[a] += 1
    else:
        if dd[a] == 'o':
            continue
        else:
            c += dd[a]
            p += 1
            dd[a] = 'o'
            
print(p, c)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
li = []
k = 0 #カウント数
for _ in range(y):
    a, b = map(str, input().split())
    if b == 'AC':
        if a in li:
            continue
        else:
            li.append(a)
    elif b == 'WA':
        if a in li:
            continue
        else:
            k += 1
s = 0
for _ in dd:
    s += 1
            
print(s, k)
Problem p02885 (python)

Fixed submission:
x, y = map(int, input().split())
if x - 2*y >= 0:
  print(x-2*y)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
x, y = map(int(input().split()))
if x - 2*y >= 0:
  print(x-2*y)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
x, y = int(input().split())
if x - 2*y >= 0:
  print(x-2*y)
else:
  print(0)
Problem p02909 (python)

Fixed submission:
di = {'Sunny':'Cloudy', 'Cloudy':'Rainy', 'Rainy':'Sunny'}
x = input()
print(di[x])

Buggy submission (verdict: Runtime Error):
di = {'Sunny':'Cloudy', 'Cloudy':'Rainy', 'Sunny'}
x = input()
print(di[x])
Problem p02917 (python)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))
ans = [0]*n
ans[0] = b[0]
for i in range(1, n-1):
  ans[i] = min(b[i-1], b[i])
ans[n-1] = b[n-2]
print(sum(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().split()))
ans = [0]*n
for i in range(n):
  ans[i] = max(ans[i], b[i])
  if i >= 1:
    ans[i] = max(ans[i], b[i-1])
print(sum(ans))
Problem p02921 (python)

Fixed submission:
x = input()
y = input()
ans = 0
for i in range(len(x)):
  for j in range(len(y)):
    if i == j:
      if x[i] == y[j]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
x = input()
y = input()
ans = 0
for i in range(len(x)):
  for j in range(len(y)):
    if i == j:
      if li[i] == li[j]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
x = input()
y = input()
ans = 0
for i in range(len(x)):
  for j in range(len(y)):
    if i == j:
      if li[i] != li[j]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s1 = list(map(str, input().split()))
s2 = list(map(str, input().split()))
ans = 0
for i in range(3):
  if s1[i] == s2[i]:
    ans += 1
print(ans)
Problem p02945 (python)

Fixed submission:
x, y = map(int, input().split())
vv = max(x+y, x-y)
vv = max(vv, x*y)
print(vv)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input())
vv = max(x+y, x-y)
vv = max(vv, x*y)
print(vv)
Problem p03109 (python)

Fixed submission:
s = input()
year = int(s[:4])
month = int(s[5:7])
day = int(s[9:])
if year > 2019:
  print('TBD')
elif year < 2019:
  print('Heisei')
else:
  if month > 4:
    print('TBD')
  elif month < 4:
    print('Heisei')
  else:
    if day > 30:
      print('TBD')
    else:
      print('Heisei')

Buggy submission (verdict: Runtime Error):
s = list(input())
year = int(s[:4])
manth = int(s[5:7])
day = int(s[9:])
if year > 2019:
  print('TBD')
elif year < 2019:
  print('Heisei')
else:
  if month > 4:
    print('TBD')
  elif month < 4:
    print('Heisei')
  else:
    if day > 30:
      print('TBD')
    else:
      print('Heisei')
Problem p03125 (python)

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

Buggy submission (verdict: Runtime Error):
import math.gcd
a, b = map(int, input.split())
if gcd(a, b) != 1:
  print(b-a)
else:
  print(a+b)

Buggy submission (verdict: Runtime Error):
import fanctions.gcd
a, b = map(int, input.split())
if gcd(a, b) != 1:
  print(b-a)
else:
  print(a+b)
Problem p03164 (python)

Fixed submission:
n, W = map(int, input().split())
w = [0]*n
v = [0]*n
for i in range(n):
    w[i], v[i] = map(int, input().split())
    
INF = 10 ** 15
dp = [[INF]*(10**5+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for sum_v in range(10**5+1):
        if sum_v - v[i] >= 0:
            dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - v[i]]+w[i] )
        else:
            dp[i+1][sum_v] = dp[i][sum_v]

max_v =0
for sum_v in range(10**5+1):
    if dp[n][sum_v] <= W:
        max_v = sum_v

print(max_v)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

x, y  = map(int, input().split())
li =[]
for i in range(x):
    l = list(map(int, input().split()))
    li.append(l)
dp = [[0]*(y+1) for _ in range(x+1)]
for i in range(x):
    for j in range(1, y+1):
        if j - li[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j - li[i][0] ]+ li[i][1])
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
print(dp[x][y])
Problem p03264 (python)

Fixed submission:
n = int(input())
s = n//2
k = n-s
print(s*k)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = n//2
k = s-k
print(s*k)
Problem p03337 (python)

Fixed submission:
a, b = map(int, input().split())
s = a+b
t = a-b
p = a*b
li = [s, t, p]
li.sort()
print(li[-1])

Buggy submission (verdict: Runtime Error):
a, b = int(input())
s = a+b
t = a-b
p = a*b
li = [s, t, p]
li.sort()
print(li[-1])
Problem p03377 (python)

Fixed submission:
a, b, x = map(int, input().split())
if x < a:
  print('NO')
elif a+b < x:
  print('NO')
else:
  print('YES')

Buggy submission (verdict: Runtime Error):
a, b, x = int(input())
if x < a:
  print('NO')
elif a+b < x:
  print('NO')
else:
  print('YES')
Problem p03605 (python)

Fixed submission:
li = list(input())
if '9' in li:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
if '9' in li:
  print('Yes')
else:
  print('No')