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

Fixed submission:
r=int(input())
print(2*r*3.14)

Buggy submission (verdict: Runtime Error):
r=int(input())
prnt(2*r*3.14)
Problem p03860 (python)

Fixed submission:
a,b,c=map(str,input().split())
ans=a[0]+b[0]+c[0]
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
ans=a[0]+b[0]+c[0]
print(ans)
Problem p03943 (python)

Fixed submission:
abc=list(map(int,input().split()))
abc.sort()
if abc[0]+abc[1]==abc[2]:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
abc=map(int,input().split())
abc.sort()
if abc[0]+abc[1]==abc[2]:
    print("Yes")
    exit()
print("No")
Problem p04043 (python)

Fixed submission:
abc=list(map(int,input().split()))
abc.sort()
if abc[0]==5 and abc[1]==5 and abc[2]==7:
    print("YES")
    exit()
print("NO")

Buggy submission (verdict: Runtime Error):
abc=list(map(int,input().split()))
abc.sort()
if a[0]==5 and a[1]==5 and a[2]==7:
    print("YES")
    exit()
print("NO")
Problem p04046 (python)

Fixed submission:
h,w,a,b=map(int,input().split())
fac=[0]*200001#iの階乗mod(1000000007)
inv=[0]*200001#iの逆元mod(1000000007)
fac[0]=1
ans=0
for i in range(1,200001):
    fac[i]=fac[i-1]*i%1000000007
inv[200000]=pow(fac[200000],1000000005,1000000007)
for i in range(199999,0,-1):
    inv[i]=(inv[i+1]*(i+1))%1000000007
    inv[0]=1
for i in range(h-a):
    if i==0:
        if h==1:
            x=1
        else:
            x=(fac[w-b+h-2
                   -i]*inv[w-1-b]*inv[h-1-i])%1000000007
    else:
        x=((fac[b-1+i]*inv[b-1]*inv[i])%1000000007)*((fac[w-b+h-2-i]*inv[w-b-1]*inv[h-1-i])%1000000007)
    ans=(ans+x)%1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
fac=[0]*200001#iの階乗mod(1000000007)
inv=[0]*200001#iの逆元mod(1000000007)
fac[0]=1
ans=0
for i in range(1,200001):
    fac[i]=fac[i-1]*i%1000000007
inv[200000]=pow(fac[200000],1000000005,1000000007)
for i in range(199999,0,-1):
    inv[i]=(inv[i+1]*(i+1))%1000000007
    inv[0]=1
for i in range(h-a):
    if i==0:
        if h==1:
            x=1
        else:
            x=(fac[w-b+h-2
                   -i]*inv[w-1-b]*inv[h-1-i])%1000000007
    elif w==b+1:
        x=(fac[b-1+i]*inv[b-1]*inv[i])%1000000007
    else:
        x=((fac[b-1+i]*inv[b-1]*inv[i])%1000000007)*((fac[w-b+h-2-i]*inv[w-b-1]*inv[h-1-i])%1000000007)
    ans=(ans+x)%1000000007
print(ans)
Problem p02630 (python)

Fixed submission:
N = int(input())
SUM = 0
map = [0] * 100001
for i in [int(i) for i in input().split()]:
  SUM += i
  map[i] += 1

Q = int(input())
for i in range(Q):
  [b,c] = [int(i) for i in input().split()]
  SUM += (c-b)*map[b]
  print(SUM)
  map[c] += map[b]
  map[b] = 0

Buggy submission (verdict: Runtime Error):
N = int(input())
SUM = 0
map = [0] * 100000
for i in [int(i) for i in input().split()]:
  SUM += i
  map[i] += 1

Q = int(input())
for i in range(Q):
  [b,c] = [int(i) for i in input().split()]
  SUM += (c-b)*map[b]
  print(SUM)
  map[c] += map[b]
  map[b] = 0
Problem p02631 (python)

Fixed submission:
N = int(input())
SUM = 0
A = []
O = []
for i in input().split():
  i = int(i)
  SUM ^= i
  A.append(i)

for a in A:
  O.append(SUM ^ a)

print(' '.join([str(s) for s in O]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
  
O = [0] * 4

for i in range(N):
  for j in range(N):
    if i == j:
      continue
    O[i] ^= A[j]

print(O)
Problem p02639 (python)

Fixed submission:
array = [int(i) for i in input().split()]
i = 1

for x in array:
  if x == 0:
    print(i)
    break
  i += 1

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

if Y % 2 == 1:
  print("No")
else:
  for x in range(S+1):
    y = S - x
    if 4*x + 2*y == Y:
      print("Yes")
      break
  else:
    print("No")
Problem p02743 (python)

Fixed submission:
import math
[a,b,c] = [int(i) for i in input().split()]

if a == b:
  l = 4*a
  r = c
else:
  if a+b < c:
  	l = 4*a*b
  	r = (c -(a+b))**2
  else:
    l = 2 * math.sqrt(a*b)
    r = c - (a + b)
    
if l < r:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
[a,b,c] = [int(i) for i in input().split()]

if a == b:
  l = 4*a
  r = c
else:
  if a+b < c:
  	l = 4*a*b
  	r = (c -(a+b))**2
  else:
    print("No")
    
if l < r:
  print("Yes")
else:
  print("No")
Problem p02602 (python)

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

for i in range(k, n):
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
val = 1
for i in range(0, k):
    val *= a[i]
    
for i in range(k, n):
    num = val*a[i-k+1]/a[i+1]
    if num > val:
        print('Yes')
    else:
        print('No')
    val = num
Problem p02608 (python)

Fixed submission:
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v < 10050:
                ans[v] += 1
for i in range(n):
    print(ans[i+1])

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = [0 for _ in range(10000)]
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v < 10000:
                ans[v] += 1
for i in range(n):
    print(ans[i+1])
Problem p02642 (python)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
M = A[-1]
b = [True]*(M + 1)

count = 0
for i, a in enumerate(A):
    if not b[a]:
        continue
    for j in range(a, M+1, a):
        b[j] = False
    if i < N-1 and A[i+1] == a:
        continue
    count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
if len(a) >= 3:
    b = [x for x in a[:-2] if (x % a[-1] != 0 and x != a[-1]) and (x % a[-2] != 0 and x != a[-2])]
    b += a[-2:]

N = len(b)
count = 0
for i in range(len(b)):
    for j, k in enumerate(b[i+1:]):
        if b[i] % k == 0:
            break
        elif j+i == N-2:
            count += 1
if b[-1] != b[-2]:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
count = 0
for i in range(N-1):
    for j, k in enumerate(a[i+1:]):
        if a[i] % k == 0:
            break
        if j == N-i-2:
            count += 1
if a[-1] != a[-2]:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
count = 0
for i in range(N-1):
    for j, k in enumerate(a[i+1:]):
        if i != j+1:
            if a[i] % k == 0:
                break
        if j == N-i-2:
            count += 1
if a[-1] != a[-2]:
    count += 1
print(count)
Problem p02675 (python)

Fixed submission:
N = input()

try:
  if 0 <= int(N) <= 999:
    if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
      print('hon')
    elif N[-1] == '0' or N[-1] =='1' or N[-1] =='6' or N[-1] =='8':
      print('pon')
    elif N[-1] == '3':
      print('bon')
except ValueError:
  exit()

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

try:
	if 0 <= int(N) <= 999:
      if N[-1] is '2' or '4' or '5' or '7' or '9':
        print('hon')
      elif N[-1] is '0' or '1' or '6' or '8':
        print('pon')
      elif N[-1] is '3':
        print('bon')
except ValueError:
  exit()

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

try:
	if 0 <= int(N) <= 999:
      if N[-1] is 2 or 4 or 5 or 7 or 9:
        print('hon')
      elif N[-1] is 0 or 1 or 6 or 8:
        print('pon')
      elif N[-1] is 3:
        print('bon')
except ValueError:
  exit()
Problem p02677 (python)

Fixed submission:
import math

A, B, H, M = (float(x) for x in input().split())

theta = H*30 + (M/60)*30 - M*6
cos = math.cos(math.radians(theta))
res = math.sqrt(A**2 + B**2 - 2*A*B*cos)
print(res)

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

A, B, H, M = input.split()

theta = abs(int(H)*30 - int(M)*6)
cos = math.cos(math.radians(theta))

res = math.sqrt(int(A)**2 + int(B)**2 - 2 * int(A) * int(B) * cos)
print(res)

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

A = input()
B = input()
H = input()
M = input()

theta = abs(int(H)*30 - int(M)*6)
cos = math.cos(math.radians(theta))

res = math.sqrt(int(A)**2 + int(B)**2 - 2 * int(A) * int(B) * cos)
print(res)
Problem p02684 (python)

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

route = []
town = set()
now = 1

while True:
    now = a[now-1]
    if now in town:
        break
    town.add(now)
    route.append(now)

count = route.index(now)
if count >= k:
    print(route[k-1])
else:
    route = route[count:]
    num = (k-count)%len(route)
    print(route[num-1])

Buggy submission (verdict: Runtime Error):
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
now, route = 1, []

while not now in route:
    route.append(now)
    now = a[now-1]
route.append(now)
route.pop(0)
num = k%len(route)

count = route.index(route[-1])
if k-1 <= count:
    print(route[k-1])
    sys.exit()
else:
    if count != len(route)-1:
        route = route[count:]
if num == 0:
    num = len(route)
print(route[num-1])

Buggy submission (verdict: Runtime Error):
N, K = (int(x) for x in input().split())
trip = input().split()

now = 1
way = [now]

for k in range(K):
  now = int(trip[now-1])
  way.append(now)
  if way.count(now) == 2:
    index = way.index(now)
    if index != 0:
      del way[:index]
      a = (K-index) % (len(way)-1)
      break
print(way[a])

Buggy submission (verdict: Runtime Error):
N, K = (int(x) for x in input().split())
trip = input().split()
 
now = 1
way = []
 
for k in range(K): 
  now = int(trip[now-1])
  way.append(now)
  if way.count(now) == 2:
    a = K % len(way)
    break

print(way[a])
Problem p02687 (python)

Fixed submission:
S = input()
 
if S == 'ABC':
  print('ARC')
else:
  print('ABC')

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

X = int(input())
 
for i in range(-118, 119):
  for j in range(-119, 118):
    if math.pow(i, 5) - math.pow(j, 5) == X:
      print("%d %d" % (i, j))
      sys.exit()

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

X = int(input())
 
for i in range(1000):
  for j in range(-100, 1000):
    if math.pow(i, 5) - math.pow(j, 5) == X:
      print("%d %d" % (i, j))
      sys.exit()

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

X = int(input())

for i in range(-100, 1000):
  for j in range(-100, 1000):
    if	math.pow(i, 5) - math.pow(j, 5)	== X:
      print("%d %d" % (i, j))
      sys.exit()

Buggy submission (verdict: Runtime Error):
S = input()
 
if S == 'ABC':
  print(ARC)
else:
  print(ABC)
Problem p02690 (python)

Fixed submission:
import sys
x = int(input())

for i in range(-1000, 1001):
    for j in range(-1000, 1001):
        if i**5-j**5 == x:
            print(i, j)
            sys.exit()

Buggy submission (verdict: Runtime Error):
import math

X = int(input())

i = 0
j = 0
while True:
   i += 1
   a = math.pow((X + math.pow(i, 5)), float(1/5))
   if a.is_integer():
      print("%d %d" % (a, i))
      exit()
   j -= 1
   a = math.pow((X + math.pow(j, 5)), float(1/5))
   if a.is_integer():
      print("%d %d" % (a, j))
      exit()

Buggy submission (verdict: Runtime Error):
import math

X = int(input())

i = 0
while True:
   i += 1
   b = - math.pow((X - math.pow(i, 5)), float(1/5))
   if b.is_integer():
      print("%d %d" % (i, b))
      exit()
Problem p02714 (python)

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

num = len(s)
ans = s.count('R')*s.count('G')*s.count('B')

for i in range(num):
    for j in range(i+1, num):
        if 0 <= 2*j-i < num:
            if s[i] != s[j] and s[j] != s[2*j-i] and s[2*j-i] != s[i]:
                ans -= 1
print(ans)

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

num = len(s)
ans = 0
for i in range(num):
    a = set(s[i])
    for j in range(i+1, num):
        if s[j] in a:
            continue
        a.add(s[j])
        for k in range(j+1, num):
            if s[k] in a or j-i == k-j:
                continue
            ans += 1
        a.remove()

print(ans)
Problem p02732 (python)

Fixed submission:
from scipy.special import comb

N = int(input())
index = list(map(int, input().split()))
val = [0]*max(index)
for i in index:
    val[i-1] += 1
total = 0
for i in val:
    if i >= 2:
        total += comb(i, 2, exact=True)
for i in index:
    if val[i-1] >= 2:
        print(total-(comb(val[i-1], 2, exact=True)-comb(val[i-1]-1, 2, exact=True)))
    else:
        print(total)

Buggy submission (verdict: Runtime Error):
from math import factorial

N = int(input())
index = list(map(int, input().split()))
val = [0]*max(index)
for i in index:
    val[i-1] += 1
total = 0
for i in val:
    if i >= 2:
        total += comb(i, 2, exact=True)
for i in index:
    if val[i-1] >= 2:
        print(total-(comb(val[i-1], 2, exact=True)-comb(val[i-1]-1, 2, exact=True)))
    else:
        print(total)
Problem p02787 (python)

Fixed submission:
def num():
    from sys import stdin
    h, n = map(int, input().split())
    magic = [list(map(int, stdin.readline().split())) for _ in range(n)]
    INF = float('inf')
    ans = [INF]*(h+1)
    ans[-1] = 0

    for i in range(h, 0, -1):
        if ans[i] != INF:
            for j, k in magic:
                if i-j < 0:
                    num = ans[i]+k
                    if ans[0] > num:
                        ans[0] = num
                else:
                    num = ans[i]+k
                    if ans[i-j] > num:
                        ans[i-j] = num
    return ans[0]
print(num())

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

@jit(nopython=True)
def num():
    h, n = map(int, input().split())
    magic = [list(map(int, stdin.readline().split())) for _ in range(n)]
    INF = float('inf')
    ans = [INF]*(h+1)
    ans[-1] = 0

    for i in range(h, 0, -1):
        if ans[i] != INF:
            for j in magic:
                if i-j[0] < 0:
                    num = ans[i]+j[1]
                    if ans[0] > num:
                        ans[0] = num
                else:
                    num = ans[i]+j[1]
                    if ans[i-j[0]] > num:
                        ans[i-j[0]] = num
    return ans[0]
print(num())

Buggy submission (verdict: Runtime Error):
from numba import jit

@jit
def num():
    from sys import stdin
    h, n = map(int, input().split())
    magic = [list(map(int, stdin.readline().split())) for _ in range(n)]
    INF = float('inf')
    ans = [INF]*(h+1)
    ans[-1] = 0

    for i in range(h, 0, -1):
        if ans[i] != INF:
            for j in magic:
                if i-j[0] < 0:
                    num = ans[i]+j[1]
                    if ans[0] > num:
                        ans[0] = num
                else:
                    num = ans[i]+j[1]
                    if ans[i-j[0]] > num:
                        ans[i-j[0]] = num
    return ans[0]
print(num())
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
ans = [0 for _ in range(n)]
trees = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    trees[a-1].append(b-1)
    trees[b-1].append(a-1)

for _ in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

visited = [False]*n
def dfs(n):
    visited[n] = True
    for i in trees[n]:
        if visited[i]:
            continue
        ans[i] += ans[n]
        dfs(i)
dfs(0)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
ans = [0 for _ in range(n)]
trees = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    trees[a-1].append(b-1)
    trees[b-1].append(a-1)

for _ in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

visited = [False]*n
def dfs(n):
    visited[n] = True
    for i in trees[n]:
        if visited[i]:
            continue
        ans[i] += ans[n]
        dfs(i)
dfs(0)
for i in ans:
    print(i)
Problem p02947 (python)

Fixed submission:
N = int(input())
s = sorted([sorted(input()) for _ in range(N)])
total = 0
count = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        total += count * (count - 1) / 2
        count = 1
total += count * (count - 1) / 2
print(int(total))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N = int(input())
s = sorted([sorted(input()) for _ in range(N)])
total = 0
count = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        total += comb(count, 2)
        count = 1
total += comb(count, 2)
print(int(total))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb
N = int(input())
a, b = [], []
for i in range(N):
    b = sorted([x for x in input()])
    a += [int(''.join([str(ord(x)) for x in b]))]
count = Counter(a)
total = 0
for i in count.items():
    if i[1] >= 2:
        total += comb(i[1], 2)
print(int(total))
Problem p02969 (python)

Fixed submission:
print(3*int(input())**2)

Buggy submission (verdict: Runtime Error):
rint(3*int(input())**2)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
A, B, C, D = list(map(int, input().split()))

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

print(B-A+1-((B//C+B//D-B//(num(C, D)))-((A-1)//C+(A-1)//D-(A-1)//(num(C, D)))))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = list(map(int, input().split()))

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

print(B-A+1-((B//C+B//D-B//(num(C, D)))-((A-1)//C+(A-1)//D-(A-1)//(num(C, D)))))
Problem p03029 (python)

Fixed submission:
def main():

    apple, apple_piece = (int(val) for val in input().split())

    apple_piece += apple * 3
    apple_pie = int(apple_piece / 2)

    print(apple_pie)

if __name__ == '__main__':

    main()

Buggy submission (verdict: Runtime Error):
def main():

    N = int(input())
    if 0 > N or N > 100:
        print("input N error")
        exit()
        
    a = []
    for i in range(N):
        b = input().split()
        if len(b[0]) > 10 or len(b[0]) < 1:
            print("input S error")
            exit()

        if int(b[1]) < 0 or int(b[1]) > 100:
            print("input P error")
            exit()

        b.append(i + 1)
        a.append(b)
        
    a.sort()
    print(a)
    c = []
    answer = []
    
    for i in range(len(a)):
        c.append(a[i])

        if len(a) == 1:
         answer += c   
        
        elif a[i][0] != a[i+1][0] and i != len(a) - 2:
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
            c = []

        elif a[i][0] != a[i+1][0] and i == len(a) - 2:
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
            c = []
            c.append(a[i+1])
            answer += c
            break

        elif a[i][0] == a[i+1][0] and i == len(a) - 2:
            c.append(a[i+1])
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
            break

    print(answer)
    for i in range(len(answer)):
        print(answer[i][2])
        
        
if __name__ == '__main__':

    main()

Buggy submission (verdict: Runtime Error):
def main():

    N = int(input())
    if 0 > N or N > 100:
        print("input N error")
        exit()
        
    a = []
    for i in range(N):
        b = input().split()
        if len(b[0]) > 10 or len(b[0]) < 1:
            print("input S error")
            exit()

        if int(b[1]) < 0 or int(b[1]) > 100:
            print("input P error")
            exit()

        b.append(i + 1)
        a.append(b)
        
    a.sort()
    c = []
    answer = []
    
    for i in range(len(a) - 1):
        c.append(a[i])

        if i == len(a) - 2:
            elif a[i][0] != a[i+1][0]:
                c.sort(key=lambda x: int(x[1]), reverse=True)
                answer += c
                answer.append(a[i+1])

            else:
                c.append(a[i+1])
                c.sort(key=lambda x: int(x[1]), reverse=True)
                answer += c
                
        elif a[i][0] != a[i+1][0]:
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
            c = []

            
    for i in range(len(answer)):
        print(answer[i][2])
        
        
if __name__ == '__main__':

    main()
Problem p03141 (python)

Fixed submission:
n = int(input())
ans, a, b = 0, [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x+y)
    b.append([x, y])
num = [x for x in range(n)]
a, a0 = zip(*sorted(zip(a, num)))
a, a0 = list(a), list(a0)

for i in range(n):
    val = a0.pop()
    a.pop()
    if i%2 == 0:
       ans += b[val][0]
    else:
       ans -= b[val][1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a, b, c = [], [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(max(y-x, x))
    b.append(max(x-y, y))
    c.append([x, y])
num = [x for x in range(n)]
a, a0 = zip(*sorted(zip(a, num)))
b, b0 = zip(*sorted(zip(b, num)))
ans = 0
a, a0, b, b0 = list(a), list(a0), list(b), list(b0)
for i in range(n):
    if i%2 == 0:
       val = a0.pop()
       ans += c[val][0]
       a.pop()
       b.pop(val)
       b0.pop(val)
    else:
       val = b0.pop()
       ans -= c[val][1]
       b.pop()
       a.pop(val)
       a0.pop(val)
print(ans)
Problem p03164 (python)

Fixed submission:
import numpy as np

N, W = map(int, input().split())
a = [list(map(int,input().split())) for _ in range(N)]
vmax = sum([a[i][1] for i in range(N)])
INF = float('inf')
dp = np.full(vmax+1, INF)
dp[0] = 0

for i in range(N):
  w, v = a[i-1]
  dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
print(max([i for i in range(vmax+1) if dp[i] <= W]))

Buggy submission (verdict: Runtime Error):
import numpy as np

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

dp = np.zeros(W+1, dtype=np.int64)

for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w]+v)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import numpy as np

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

dp = np.zeros(W + 1, dtype = np.int64)

for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w] + v)

print(dp.max())

Buggy submission (verdict: Runtime Error):
import numpy as np

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

dp = np.zeros(W + 1, dtype = np.int64)

for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w] + v)

    print(dp.max())
Problem p03197 (python)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
ans = [x for x in a if x%2 != 0]

if len(ans) == 0:
    print('second')
else:
    print('first')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
num = a[-1]-a[-2]
if num%2 == 0:
    print('second')
else:
    print('first')
Problem p03200 (python)

Fixed submission:
S = input()
ans = 0
count = 0
for i in S:
    if i == 'B':
        count += 1
    elif i == 'W':
        ans += count
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import permutations
N = int(input())

val = []
for _ in range(N):
    val.append(int(input()))
ans = 10**10
for i in permutations(val):
    for j in range(1, N):
        ans = min(max(sum(i[:j]), sum(i[j:])), ans)
if N == 1:
    print(val[0])
else:
    print(ans)