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

Fixed submission:
from queue import PriorityQueue
import sys

sys.setrecursionlimit(10**9)

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

ans=0
MOD = 1000000007

def dfs(u,fa,k):
    temp=k
    if(fa==0): temp-=1
    else: temp-=2
    global ans
    global MOD
    vis[u]=1
    i=0
    for  v in a[u]:
        if(vis[v]==1):continue
        ans=(ans%MOD*(temp-i)%MOD)%MOD
        dfs(v,u,k)
        i+=1


IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

n,k = IA()
ans=k
a=[ [] for i in range(0,n+1)]
vis=[int(0) for i in range(0,n+1)]

for i in range(0,n-1):
     u,v=IA()
     a[u].append(v)
     a[v].append(u)

dfs(1,0,k)
print(ans)

Buggy submission (verdict: Runtime Error):
from queue import PriorityQueue


IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
ans=0
MOD = 1000000007

def dfs(u,fa,k):
    temp=k
    if(fa==0): temp-=1
    else: temp-=2
    global ans
    global MOD
    vis[u]=1
    i=0
    for  v in a[u]:
        if(vis[v]==1):continue
        ans=(ans%MOD*(temp-i)%MOD)%MOD
        
        dfs(v,u,k)
        i+=1


IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

n,k = IA()
ans=k
a=[ [] for i in range(0,n+1)]
vis=[int(0) for i in range(0,n+1)]

for i in range(0,n-1):
     u,v=IA()
     a[u].append(v)
     a[v].append(u)

dfs(1,0,k)
print(ans)

Buggy submission (verdict: Runtime Error):
from queue import PriorityQueue


IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
ans=1
MOD = 1000000007

def dfs(u,fa,k):
    global ans
    global MOD
    vis[u]=1
    i=0
    for  v in a[u]:
        if(vis[v]==1):continue
        ans=(ans%MOD*(k-i)%MOD)%MOD
        dfs(v,u,k-2)
        i+=1


IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

n,m = IA()

a=[[] for i in range(0,n+1)]
vis=[int(0) for i in range(0,n+1)]

for i in range(0,n-1):
     u,v=IA()
     a[u].append(v)
     a[v].append(u)

dfs(1,0,m)
print(ans)
Problem p03853 (python)

Fixed submission:
h, w = map(int, input().split())
p = [input() for i in range(h)]

for i in p:
    for n in range(2):
        print(i)

Buggy submission (verdict: Runtime Error):
h, w = map(int,input().split()) 
P = [list(map(int,input().split())) for i in range(M)]

th = []

for i in p:
    for n in range(2):
        th.append(i)

print(th)
Problem p03855 (python)

Fixed submission:
import sys

#Union Find

#木の根を求める
def find(x,par):
    if par[x] == x:
        return x
    else:
        return find(par[x],par)

#xとyの属する集合の併合
def unite(x,y,par,rank):
    x = find(x,par)
    y = find(y,par)
    
    if x != y:
        #xとyの属している集合が異なる時
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x]==rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y,par):
    return find(x,par) == find(y,par)
    
input = sys.stdin.readline
n,k,L = map(int,input().split())
rpar = [] #親
tpar = []
rrank = [0]*n#木の深さ
trank= [0]*n

#初期化
for i in range(n):
    #par[i]:i rank[i]:0
    rpar.append(i)
    tpar.append(i)


for i in range(k):
    x,y = map(int,input().split())
    unite(x-1,y-1,rpar,rrank)
for i in range(L):
    x,y = map(int,input().split())
    unite(x-1,y-1,tpar,trank)

num = []
d = {}
for i in range(n):
    num.append(find(i,rpar)+find(i,tpar)*10**6)
    if num[-1] in d:
        d[num[-1]] += 1
    else:
        d[num[-1]] = 1
res = ''
for i in range(n):
    if i != 0:
        res += ' '
    
    res += str(d[num[i]])

print(res)

Buggy submission (verdict: Runtime Error):
import sys


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        find = self.find(x)
        return [i for i in range(self.n) if self.find(i) == find]

    def finds(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.finds())

    def all_group_members(self):
        return {r: self.members(r) for r in self.finds()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.finds())


input = sys.stdin.readline
n, k, l = map(int, input().split())
w = [list(map(int, input().split())) for i in range(k+l)]

ro = w[:k]
ra = w[l:]
answer = ""
d = defaultdict(int)

ro_cl = UnionFind(n)
ra_cl = UnionFind(n)

for p, q in ro:
    ro_cl.union(p-1, q-1)

for p, q in ra:
    ra_cl.union(p-1, q-1)

for i in range(n):
    print(ro_cl.members(i))
    print(ra_cl.members(i))
    if i != 0:
        answer += " "
    answer += str(len([n for n in ro_cl.members(i) if n in ra_cl.members(i)]))
    # d[(ro_cl.find(i), ra_cl.find(i))] += 1

print(answer)
Problem p02789 (python)

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

if n == m :
    print('Yes')
else :
    print('No')

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

if n == m :
    print('Yes')
else :
    print('No')
Problem p02900 (python)

Fixed submission:
from fractions import gcd
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

a,b = map(lambda x : int(x),input().split())
ko = gcd(a,b)
if ko == 1 :
    print(1)
else :
    list = factorize(ko)
    print(len(set(list)) + 1)

Buggy submission (verdict: Runtime Error):
from math import gcd
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

a,b = map(lambda x : int(x),input().split())
ko = gcd(a,b)
if ko == 1 :
    print(1)
else :
    list = factorize(ko)

    print(len(set(list)) + 1)
Problem p02993 (python)

Fixed submission:
s = input()
if(s[0] == s[1] or s[1] == s[2] or s[2] == s[3]):print("Bad")
else: print("Good")

Buggy submission (verdict: Runtime Error):
s = input()
if(s[0] == s[1] or s[1] == s[2] || s[2] == s[3]):print("Bad")
else: print("Good")
Problem p02756 (python)

Fixed submission:




s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
lst = [x for x in range(n)]
dic = {}
not_found = False
special_case = False
for i in range(m):
    a, b = map(int, input().split())
    if str(a) not in list(dic.keys()):
        dic[str(a)] = b
    else:
        if dic[str(a)] != b:
            not_found = True
    lst[a - 1] = b
if m == 0:
    special_case = True
if not_found:
    print(-1)
elif special_case:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    else:
        print(100)
else:
    for i in range(n):
        if str(i + 1) not in list(dic.keys()):
            if i + 1 == 1:
                lst[i] = 1
            else:
                lst[i] = 0
    lst = list(map(str, lst))
    res = ''.join(lst)
    if res[0] == '0' and len(res) > 1:
        print(-1)
    else:
        print(int(res))

Buggy submission (verdict: Runtime Error):

n,m = map(int,input().split())
d = dict()
for i in range(m):
    k,v = map(int,input().split())
    if k in d:
        if d[k] !=v:
            print(-1)
            exit()
    else:
        d[k] = v
if 2 not in d:
    d[2] = 0
if 3 not in d:
    d[3] = 0
res = str(d[1])+str(d[2])+str(d[3])
if res == "000":
    print(-1)
    exit()
print(res)
Problem p02830 (python)

Fixed submission:
n = int(input())
a,b = input().split()
print(''.join([a[i]+b[i] for i in range(n)]))

Buggy submission (verdict: Runtime Error):
n = int(input())
a,b = input().split()
for i in range(n):
    str += a[i]+b[i]
print(str)
Problem p03063 (python)

Fixed submission:
N = int(input())
S = input()
 
cumsum_b = [0] * (N+1)
 
for i in range(N):#累積和
  if S[i] == "#":
    cumsum_b[i+1] = cumsum_b[i] + 1
  else:
    cumsum_b[i+1] = cumsum_b[i]

ans = N
tmp = 0
for i in range(N+1):#境界を全探索
  tmp = cumsum_b[i] + ((N-i) - (cumsum_b[-1] - cumsum_b[i]))
  ans = min(ans,tmp)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
cumsum_b = [0] * (N+1)
cumsum_w = [0] * (N+1)

for i in range(N):#累積和
  if S[i] == "#":
    cumsum_b[i+1] += cumsum_b[i] + 1
  else:
    cumsum_w[i+1] += cumsum_w[i] + 1

ans = N
for left in range(1,N+1):#白の範囲を全探索
  tmp = 0
  tmp += cumsum_b[left] - cumsum_b[1]
  tmp += cumsum_w[-1] - cumsum_w[left]
  ans = min(ans,tmp)
else:
  print(ans)
Problem p03089 (python)

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

ans = []
while(True):
    if len(b) == 0:
        ans.reverse()
        print(*ans,sep="\n")
        break
    for i in range(len(b)-1,-1,-1):
        if b[i] == i+1:
            ans.append(b.pop(i))
            break
    else:
        print(-1)
        break

Buggy submission (verdict: Runtime Error):
N = int(input())
b = list(map(int,input().split()))

if 1 not in b:
    print(-1)
else:
    lst = []
    index = -1
    for i in range(N):
        if b[i] == 1:
            lst.append([])
            index += 1
        lst[index].append(b[i])
            
    flag = False
    ans = []
    if N < max(b):
        print(-1)
    else:
        if len(lst) == 0:
            print(-1)
        else:
            lst.reverse()
            for i in range(len(lst)):
                for j in range(len(lst[i])):
                    if lst[i][j] > j+1:
                        flag = True
                        print(-1)
                        break
                if flag:
                    break
            
            for i in range(len(lst)):
                lst[i].reverse()
                cnt = 1
                while(len(lst[i]) > 0 ):
                    
                    if lst[i][0] <= cnt:
                        ans.append(lst[i].pop(0))
                    else:
                        ans.append(cnt)
        
                        lst[i].reverse()
                        lst[i].pop(lst[i].index(cnt))
                        lst[i].reverse()             
                        
                    cnt += 1
            else:
                print(*ans,sep="\n")
Problem p03206 (python)

Fixed submission:
D = input()

if D == "25":
  print("Christmas")
elif D == "24":
  print("Christmas Eve")
elif D == "23":
  print("Christmas Eve Eve")
elif D == "22":
  print("Christmas Eve Eve Eve")
else:
  pass

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
B = [-1 for i in range(51)]
P = [-1 for i in range(51)]

def buns(L):
    if L == 0:#再帰終了条件
        B[L] = 0
        return B[L]
    else:
        if B[L] == -1:
            B[L] = buns(L-1)*2 + 2
            return B[L]
        else:
            return B[L]

def patty(L):
    if L == 0:#再帰終了条件
        P[L] = 1        
        return P[L]
    else:
        if P[L] == -1:
            P[L] = patty(L-1)*2 + 1
            return P[L]
        else:
            return P[L]

buns(N)
patty(N)
memo = [B[i] + P[i] for i in range(51)]

def func(L,X):

    if L == 0:
        if X <= 0:
            return 0
        else:
            return 1
    elif X <= memo[L-1]+1:
        return func(L-1,X-1)
    else :
        return P[L-1] + 1 + func(L-1,X-2-memo[L-1])


print(func(N,X))
Problem p03231 (python)

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return int(a)
    r = a % b
    return gcd(b, r)

def lcm(a,b):
  return int(a*b/gcd(a,b))
 
N,M = map(int,input().split())
S = input()
T = input()
L = lcm(N,M)
flag = True
min_len = min(N,M)
s_index = int(int(L/M)/gcd(int(L/M),int(L/N)))
t_index = int(int(L/N)/gcd(int(L/M),int(L/N)))

if N == M:
  for i in range(N):
    if S[i] == T[i]:
      continue
    else:
      flag = False
      break
else:
  for i in range(min_len):
    if i * s_index < N-1 and i*t_index < M - 1:
      if S[i*s_index] == T[i*t_index]:
        continue
      else:
        flag = False
        break
    else:
      break
    
if flag:  
  print(L)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return int(a)
    r = a % b
    return gcd(b, r)

def lcm(a,b):
  return int(a*b/gcd(a,b))
 
N,M = map(int,input().split())
S = input()
T = input()
L = lcm(N,M)
flag = True
min_len = min(Na,M)
s_index = int(int(L/M)/gcd(int(L/M),int(L/N)))
t_index = int(int(L/N)/gcd(int(L/M),int(L/N)))

if N == M:
  for i in range(N):
    if S[i] == T[i]:
      continue
    else:
      flag = False
      break
else:
  for i in range(min_len):
    if i * s_index < N-1 and i*t_index < M - 1:
      if S[i*s_index] == T[i*t_index]:
        continue
      else:
        flag = False
        break
    else:
      break
    
if flag:  
  print(L)
else:
  print(-1)
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1 :
  print("Hello World")
else:
  A = int(input())
  B = int(input())
  print( A + B )

Buggy submission (verdict: Runtime Error):
import math
 
N,M = map(int,input().split())
 
ans = 1
for i in range(1,M+1):
  if M % i != 0:#約数ではないとき
    continue
  B = M / i
  
  if (i * N <= M):
    ans = max(ans,i)
  if (B * N <= M):
    ans = max(ans,B)

print(ans)
Problem p03241 (python)

Fixed submission:
import math
 
N,M = map(int,input().split())
 
ans = 1
for i in range(1,int(math.sqrt(M))+1+1):
  if M % i != 0:#約数ではないとき
    continue
  B = int(M / i)#intとらないと，N = 1 , M = 100 のとき　ans = 100.0になってエラー？
  
  if (i * N <= M):
    ans = max(ans,i)
  if (B * N <= M):
    ans = max(ans,B)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

ans = 1
for i in range(1,int(math.sqrt(M)+1)+1):
  if M % i != 0:#約数ではないとき
    continue
  B = M / i
  
  if (A * N <= M):
    ans = max(ans,A)
  if (B * N <= M):
    ans = max(ans,B)

print(ans)
Problem p03109 (python)

Fixed submission:
s = input()
s = s.replace("/","")
s = int(s)
print("Heisei" if s <= 20190430 else "TBD")

Buggy submission (verdict: Runtime Error):
s = input()
s = s.replace("/","")
print("Heisei" if s <= 20190430 else "TBD")
Problem p03206 (python)

Fixed submission:
print('Christmas' + ' Eve'*(25-int(input())))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
a = sorted(a)
print((max(a) // 2) + sum(a) -max(a))
Problem p02761 (python)

Fixed submission:
n,m = map(int, input().split())
a = [input() for _ in range(m)]

x = 10 ** (n - 1)
if n == 1: x = 0
ans = [-1]

while x < 10 ** n:
    s = str(x)
    if all(s[int(ai[0]) - 1] == ai[2] for ai in a):
        ans.append(x)
        break
    x += 1

print(ans[-1])

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [input() for _ in range(m)]
b = set(a)
c = [list(map(int, ai.split())) for ai in a]
d = dict(c)

if len(d) != len(b):
    print(-1)
else:
    if n == 1:
        print(d[1])
    else:
        if d[1] == 0:
            print(-1)
        else:
            ans = ["0"] * n
            for k in d:
                ans[k-1] = str(d[k])
            print(int("".join(ans)))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [input() for _ in range(m)]
b = set(a)
c = [list(map(int, ai.split())) for ai in a]
d = dict(c)

if len(d) != len(b):
    print(-1)
else:
    if n == 1:
        print(d[0])
    else:
        if d[0] == 0:
            print(-1)
        else:
            ans = ["0"] * n
            for k in d:
                ans[k-1] = str(d[k])
            print("".join(ans))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [input() for _ in range(m)]
b = set(a)
c = [list(map(int, ai.split())) for ai in a]
d = dict(c)

if len(d) != len(b):
    print(-1)
else:
    if n == 1:
        print(d[1])
    else:
        if d[1] == 0:
            print(-1)
        else:
            ans = ["0"] * n
            for k in d:
                ans[k-1] = str(d[k])
            print("".join(ans))
Problem p02774 (python)

Fixed submission:
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())), np.int64)

A = np.sort(A)
zero = A[A == 0]
pos = A[A > 0]
neg = A[A < 0]

def f(x):
    cnt_tpl = 0
    if x >= 0: cnt_tpl += len(zero) * N
    cnt_tpl += np.searchsorted(A, x // pos, side='right').sum()
    cnt_tpl += (N - np.searchsorted(A, (-x - 1) // (-neg), side='right')).sum()
    cnt_tpl -= np.count_nonzero(A * A <= x)
    # assert cnt_tpl % 2 == 0
    return cnt_tpl // 2

left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= K:
        right = x
    else:
        left = x

print(right)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype="int64")

size = n*(n-1)//2

asort = np.sort(a)
x = np.multiply.outer(asort, asort)
xtril = np.tril(x, -1)

xunder0 = np.sort(xtril[xtril < 0])
xunsize = xunder0.size
xupper0 = np.sort(xtril[xtril > 0])
xupsize = xupper0.size
x0size = size - xunsize - xupsize
### print(x0size, xunsize, xupsize) ###

if k <= xunsize:
    print(xunder0[k-1])
elif k <= xunsize + x0size:
    print(0)
else:
    print(xupper0[k-xunsize-x0size-1])
Problem p02848 (python)

Fixed submission:
n = int(input())
s = input()
s1 = []

alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for a in s:
    s1.append(alph[(alph.index(a) + n)%26])

print("".join(s1))

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

alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for a in s:
    s1.append(alph[alph.index(a) + n])

print("".join(s1))
Problem p02861 (python)

Fixed submission:
from itertools import combinations as comb
from math import sqrt
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]


s = sum(sqrt((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2) for i,j in comb(range(n), 2))
print(s * 2 / n)

Buggy submission (verdict: Runtime Error):
from itertools import combinations as comb
from math import sqrt
n = int(input())
xy = [[*map(int, input().split())] for _ in range(n)]


s = sum(sqrt((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2) for i,j in comb(range(n), 2))
print(s * 2 / n)
Problem p02981 (python)

Fixed submission:
n,a,b=map(int,input().split());print(min([n*a,b]))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int(input().split()));print(min([n*a,b]))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int(input()));print(min([n*a,b]))
Problem p03000 (python)

Fixed submission:
from itertools import accumulate
n,x = map(int, input().split())
a = [0] + list(map(int, input().split()))
print(len([i for i in accumulate(a) if i < x+1]))

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
n,x = map(int, input().split())
a = [0, *map(int, input().split())]
print(len([i for i in accumulate(a) if i < x+1]))
Problem p03163 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import numpy as np

EDPC = "https://atcoder.jp/contests/DP/"
TDPC = "https://atcoder.jp/contests/tDPc/tasks"

################ DANGER ################
test = ""
#test = \
"""
3 8
3 30
4 50
5 60
ans 90
"""

"""
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
ans 5000000000(>int32)
"""

"""
6 15
6 5
5 6
6 4
6 6
3 5
7 2
ans 17
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
########################################  
# np.maximum(np.array([1,3,2]), np.array([2, 1, 3]))
N, W = map(int, input2().split())
WV = np.array([tuple(map(int, input2().split())) for _ in range(N)])

dp = np.zeros(W + 1, dtype="int64")
for w, v in WV:
    dp[W:w-1:-1] = np.maximum(dp[W:w-1:-1], dp[W-w::-1] + v)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for _ in range(N)], dtype="int64")
dp = np.zeros(W + 1, dtype="int64")

for w, v in wv:
    dp[W:w-1:-1] = np.maximum(dp[W:w-1:-1], dp[W-w::-1] + v)
    print(dp)
    
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for _ in range(N)])
dp = np.zeros(W + 1, dtype="int64")

for w, v in wv:
    dp[W:w-1:-1] = np.maximum(dp[W:w-1:-1], dp[W-w::-1] + v)
    print(dp)
    
print(dp[-1])
Problem p03434 (python)

Fixed submission:
input()
li = list(map(int, input().split()))
li.sort(reverse=True)
alice = sum([i for index,i in enumerate(li) if index % 2 == 0])
ans = alice * 2 - sum(li)
print(ans)

Buggy submission (verdict: Runtime Error):
input()
li = list(map(int, input().split()))
li.sort(reverse=True)
alice = [i for index,i in enumerate(li) if index % 2 == 0]
ans = alice * 2 - sum(li)
print(alice)
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a*500+b*100+c*50 == X:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for a in A:
  for b in B:
    for c in C:
      if a*500+b*100+c*50 == X:
        cnt += 1
print(cnt)
Problem p03478 (python)

Fixed submission:
li = list(map(int, input().split()))
ans = 0
for i in range(li[0]):
  i += 1
  s = sum(list(map(int, str(i))))
  if s >= li[1] and s <= li[2]: ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
li = list(map(int, input().split()))
ans = 0
for i in range(li[0] + 1):
  s = sum(list(map(int, str(i))))
  if sum >= li[1] and sum <= li[2]:
    ans += s
print(ans)

Buggy submission (verdict: Runtime Error):
li = list(map(int, input().split()))
ans = 0
for i in range(li[0] + 1):
  sum = sum(list(map(int, str(i))))
  if sum >= a and sum <= b:
    ans += sum
print(ans)