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

Fixed submission:
n,k = map(int,input().split())
x = list(map(int,input().split()))
l,r = 0,0
anus = 10**9
for i in range(n):
  l = i
  r = i+(k-1)
  if r >= n:
    break
  anus = min(anus,abs(x[l])+abs(x[r]-x[l]),abs(x[r])+abs(x[r]-x[l]))
print(anus)

Buggy submission (verdict: Runtime Error):
import bisect
n,k = map(int,input().split())
x = list(map(int,input().split()))
bindex = bisect.bisect_left(x,0)
mainasu = x[:bindex] #[-30,-20,-10]
purasu = x[bindex:] #[10,20,30]
"""
for i in range(len(mainasu)-2,-1,-1): #0は対象ではない
  mainasu[i] = mainasu[i+1]+mainasu[i]
#[-60,-30,-10]
for i in range(1,len(purasu)):
  purasu[i] = purasu[i-1]+purasu[i]
#[10,30,60]
"""
ans = 10**9
if len(mainasu) >= k:
  ans = min(ans,abs(mainasu[-k]))
if len(purasu) >= k:
  ans = min(ans,purasu[k-1])
if mainasu != []:
  for i in range(len(mainasu)-k,len(mainasu)): #-2~2
    if i >= len(purasu):break
    a = abs(mainasu[i])
    b = purasu[i]
    ans = min(ans,a*2+b,a+b*2)
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n,k = map(int,input().split())
x = list(map(int,input().split()))
bindex = bisect.bisect_left(x,0)
mainasu = x[:bindex] #[-30,-20,-10]
purasu = x[bindex:] #[10,20,30]
"""
for i in range(len(mainasu)-2,-1,-1): #0は対象ではない
  mainasu[i] = mainasu[i+1]+mainasu[i]
#[-60,-30,-10]
for i in range(1,len(purasu)):
  purasu[i] = purasu[i-1]+purasu[i]
#[10,30,60]
"""
ans = 10**9
if len(mainasu) >= k:
  ans = min(ans,abs(mainasu[-k]))
if len(purasu) >= k:
  ans = min(ans,purasu[k-1])

for i in range(len(mainasu)-k,len(mainasu)): #-2~2
  if i >= len(purasu):break
  a = abs(mainasu[i])
  b = purasu[i]
  ans = min(ans,a*2+b,a+b*2)
print(ans)
Problem p03282 (python)

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


count = 0
for i in range(len(s)):
  if s[i] == "1":
    count = i+1
  else:
    st = s[i]
    break

if k <= count:
  print(1)
else:
  print(st)

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


count = 0
for i in range(len(s)):
  if s[i] == "1":
    count = i
  else:
    st = s[i]
    break
if count ==0:
  print(st)
elif k <= count+1:
  print(1)
else:
  print(st)
Problem p03283 (python)

Fixed submission:
n,m,q = map(int,input().split())
query = [[0 for j in range(501)] for i in range(501)]

for h in range(m):
    k,l = map(int,input().split())
    query[k][l] += 1

#リストを累積和にする
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i][j-1]
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i-1][j]
        

for h in range(q):
    k,l = map(int,input().split())
    A,B,C = 0,0,0
    if k > 1:
        A = query[k-1][l]
        B = query[l][k-1]
        C = query[k-1][k-1]
    print(query[l][l] - A - B + C)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m,q = map(int,input().split())
list_lr = [list(map(int,input().split())) for i in range(m)]
list_pq = [list(map(int,input().split())) for i in range(q)]

query = np.zeros((500,500),dtype=int)

for k,l in list_lr:
    query[k][l] += 1

def search(l,r):
    ans = 0
    for i in range(l,r+1):
        for j in range(l,r+1):
            ans += query[i][j]
    return ans

for k,m in list_pq:
    print(search(k,m))
Problem p03285 (python)

Fixed submission:
#4と、7
n =int(input())

for i in range(16):
  s = n - (i*7)
  if s < 0:
    break
  if s%4==0:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
#4と、7
n =int(input())

for i in 16:
  s = n - (i*7)
  if s < 0:
    break
  if s%4==0:
    print("Yes")
    exit()
print("No")
Problem p03287 (python)

Fixed submission:
#ABC105-D Candy Distribution
"""
al~arの合計がmの倍数となる通り数を調べる。
愚直に累積和をとって判定するには、O(n(n+1)/2)で不十分
実は、al~arの合計がmの倍数になる条件は、累積和をbとして、
b(l-1),brのmod m が同値になることである。
よって、累積和のmod mの個数をdictで保存しておいて、
同じ値のnC2つまり、n(n-1)//2の合計が答えとなる。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m = map(int,readline().split())
lst1 = list(map(int,readline().split()))
def cumsum(lst): #元のリストを保持
    res = lst[:]
    for i in range(1,len(res)):
        res[i] += res[i-1]
    return res
lst2 = cumsum(lst1)

dic1 = dict()
for i in lst2:
    res = i%m
    if res in dic1:
        dic1[res] += 1
    else:
        dic1[res] = 1

ans = 0
for i in dic1.values():
    if i >= 2:
        ans += i*(i-1)//2

res = 0 if 0 not in dic1 else dic1[0]
print(ans+res)

Buggy submission (verdict: Runtime Error):
#ABC105-D Candy Distribution
"""
al~arの合計がmの倍数となる通り数を調べる。
愚直に累積和をとって判定するには、O(n(n+1)/2)で不十分
実は、al~arの合計がmの倍数になる条件は、累積和をbとして、
b(l-1),brのmod m が同値になることである。
よって、累積和のmod mの個数をdictで保存しておいて、
同じ値のnC2つまり、n(n-1)//2の合計が答えとなる。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m = map(int,readline().split())
lst1 = list(map(int,readline().split()))
def cumsum(lst): #元のリストを保持
    res = lst[:]
    for i in range(1,len(res)):
        res[i] += res[i-1]
    return res
lst2 = cumsum(lst1)

dic1 = dict()
for i in lst2:
    res = i%m
    if res in dic1:
        dic1[res] += 1
    else:
        dic1[res] = 1

ans = 0
for i in dic1.values():
    if i >= 2:
        ans += i*(i-1)//2

print(ans+dic1[0])
Problem p03294 (python)

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

ans = 0
for i in list1:
    ans += i-1
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions as math

n = int(input())
list1 = list(map(int,input().split()))

#同じく最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

if n == 1:
    print(list1[0]-1)
    exit()

lcm = lcmlist(list1)
lcm -= 1
ans = 0
for i in list1:
    ans += lcm%i

print(ans)

Buggy submission (verdict: Runtime Error):
import fractions as math

n = int(input())
list1 = list(map(int,input().split()))

#同じく最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

if n == 1:
    print(list1[0]-1)

lcm = lcmlist(list1)
lcm -= 1
ans = 0
for i in list1:
    ans += lcm%i

print(ans)

Buggy submission (verdict: Runtime Error):
import fractions as math

n = int(input())
list1 = list(map(int,input().split()))

#同じく最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

lcm = lcmlist(list1)
lcm -= 1
ans = 0
for i in list1:
    ans += lcm%i

print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
list1 = list(map(int,input().split()))

#同じく最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

lcm = lcmlist(list1)
lcm -= 1
ans = 0
for i in list1:
    ans += lcm%i

print(ans)
Problem p03385 (python)

Fixed submission:
lst1 = list(input())
if len(lst1) != 3:
    print("No")
    exit()
for i in ["a","b","c"]:
    if not i in lst1:
        print("No")
        exit()
print("Yes")

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

def search(a,b,c):
    lst = [0,0,0]
    if a%2 == b%2:
        lst = [1,1,0]
        if a%2==c%2:
            lst = [1,1,1]
    elif a%2 == c%2:
        lst = [1,0,1]
    else:
        lst = [0,1,1]
    return lst


def make(a,b,c):
    lst = [a,b,c]
    lst.sort()
    lst[0] += 2
    return lst[0],lst[1],lst[2]

if __name__ == "__main__":
    ans = 0
    l = search(a,b,c)
    if sum(l) == 3:
        pass
    else:
        ans += 1
        a += l[0]
        b += l[1]
        c += l[2]
    while a != b or a != c:
        a,b,c = make(a,b,c)
        ans += 1
    print(ans)

Buggy submission (verdict: Runtime Error):
lst1 = list(input())
iflen(lst1) != 3:
    print("No")
    exit()
for i in ["a","b","c"]:
    if not i in lst1:
        print("No")
        exit()
print("Yes")
Problem p03399 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a,b)+min(c,d))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a,b)+min(c+d))
Problem p03424 (python)

Fixed submission:
n = int(input())
lst1 = list(input().split())

lst1 = list(set(lst1))

if len(lst1) == 4:
    print("Four")
else:
    print('Three')

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

lst1 = list(set(lst1))

if len(lst1) == 4:
    print("Four")
else:
    print('Three')
Problem p03436 (python)

Fixed submission:
from collections import deque
h,w = map(int,input().split())
list1 = [list(input()) for i in range(h) ]
visited = [[-1]*w for i in range(h)]
black_count = 0
for i in range(h):
	black_count += list1[i].count("#")
def bfs(maze, visited, sy, sx, gy, gx):
	queue = deque([[sy, sx]])
	visited[sy][sx] = 0
	while queue:
		y, x = queue.popleft()
		if [y, x] == [gy, gx]:
			return visited[y][x]
		for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
			new_y, new_x = y+j, x+k
			if 0 <= new_y < h and \
				0 <= new_x < w and\
				maze[new_y][new_x] == "." and \
				visited[new_y][new_x] == -1:
				
				visited[new_y][new_x] = visited[y][x] + 1
				queue.append([new_y, new_x])
	return -1

shortest = bfs(list1,visited,0,0,h-1,w-1)
if shortest == -1:
	print(-1)
	exit()
print(h*w - black_count - shortest-1) #-1はスタート地点

Buggy submission (verdict: Runtime Error):
from collections import deque
h,w = map(int,input().split())
list1 = [list(input()) for i in range(h) ]
visited = [[-1]*w for i in range(h)]
black_count = 0
for i in range(h):
	black_count += list1[i].count("#")
def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0 <= new_y < h and \
				0 <= new_x < w and\
				maze[new_y][new_x] == "." and \
                visited[new_y][new_x] == -1:
				
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])

shortest = bfs(list1,visited,0,0,h-1,w-1)

print(h*w - black_count - shortest-1) #-1はスタート地点
Problem p03503 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
lst1 = [list(map(int,readline().split())) for i in range(n)]

lst2 = [list(map(int,readline().split())) for i in range(n)]

#曜日、時刻にどの店が営業しているかを埋め込む
lst3 = [[] for _ in range(10)]
for i in range(n):
    for j in range(10):
        if lst1[i][j] == 1:
            lst3[j].append(i)

#ビット全探索
def bit_search(lst):
    keta = len(lst)
    bit_lst = []
    for i in range(2**keta):
        sub = [0]*n
        for j in range(keta):
            if ((i>>j) &1):
                for k in lst3[j]:
                    sub[k] += 1
        bit_lst.append(sub)
    return bit_lst


dummy = [0]*(10)
all_lst = bit_search(dummy)

ans = -10**9
for i in all_lst[1:]:
    res = 0
    for j in range(n):
        res += lst2[j][i[j]]
    ans = max(res,ans)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
lst1 = [list(map(int,readline().split())) for i in range(n)]

lst2 = [list(map(int,readline().split())) for i in range(n)]

#曜日、時刻にどの店が営業しているかを埋め込む
lst3 = [[] for _ in range(10)]
for i in range(n):
    for j in range(10):
        if lst1[i][j] == 1:
            lst3[j].append(i)

#ビット全探索
def bit_search(lst):
    keta = len(lst)
    bit_lst = []
    for i in range(2**keta):
        sub = [0]*10
        for j in range(keta):
            if ((i>>j) &1):
                for k in lst3[j]:
                    sub[k] += 1
        bit_lst.append(sub)
    return bit_lst


dummy = [0]*(10)
all_lst = bit_search(dummy)

ans = -10**9
for i in all_lst[1:]:
    res = 0
    for j in range(n):
        res += lst2[j][i[j]]
    ans = max(res,ans)

print(ans)
Problem p03504 (python)

Fixed submission:
import sys
from operator import itemgetter
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c = map(int,readline().split())
ch = [[[0,0]] for _ in range(c)]
for i in range(n):
    s,t,c = map(int,readline().split())
    ch[c-1].append([s,t])
imos = [0]*(10**5+1)
for i in ch:
    i.sort()
    for j in range(1,len(i)):
        s,t = i[j]
        if i[j-1][1] < s:
            imos[s-1] += 1
        else:
            imos[s] += 1
        imos[t] -= 1

for i in range(1,len(imos)):
    imos[i] += imos[i-1]

print(max(imos))

Buggy submission (verdict: Runtime Error):
import sys
from operator import itemgetter
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c = map(int,readline().split())
ch = []*c
for i in range(n):
    s,t,c = map(int,readline().split())
    ch[c-1].append([s,t])
imos = [0]*(10**5+1)
for i in ch:
    i.sort()
    for j in range(1,len(i)):
        s,t = i[j]
        if i[j-1][1] < s:
            imos[s-1] += 1
        else:
            imos[s] += 1
        imos[t] -= 1

for i in range(1,len(imos)):
    imos[i] += imos[i-1]

print(max(imos))
Problem p03546 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
h,w = map(int,readline().split())
lst1 = [list(map(int,readline().split())) for i in range(10)]

#まず、数字をiから１に変える時の最小コストを計算する。
from scipy.sparse.csgraph import shortest_path,floyd_warshall
from scipy.sparse import csr_matrix
lc = csr_matrix(lst1)
cost_lst = shortest_path(lc,method="FW")

#全探索でコストを求める。
ans = 0
for i in range(h):
    lst2 = list(map(int,readline().split()))
    for j in lst2:
        if j != -1:
            ans += cost_lst[j][1]

print(int(ans))

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
h,w = map(int,readline().split())
lst1 = [list(map(int,readline().split())) for i in range(10)]

#まず、数字をiから１に変える時の最小コストを計算する。
from scipy.sparse.csgraph import shortest_path,floyd_warshall
from scipy.sparse import csr_matrix
lc = csr_matrix(lst1)
cost_lst = shortest_path(lc,method="FW")

#全探索でコストを求める。
ans = 0
for i in range(h):
    lst2 = list(map(int,readline().split()))
    for j in lst2:
        if j != -1:
            ans += cost_lst[j][1]

print(int(ans))
Problem p03569 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s = readline().rstrip().decode('utf-8')

t = ""
for i in s:
    if not i == "x":
        t += i

if t[::] != t[::-1]:
    print(-1)

else:
    ans = 0
    left,right = 0,len(s)-1
    while True:
        if right - left <= 0:
            break
        if s[left] == "x" and s[right] != "x":
            ans += 1
            left += 1
        elif s[left] != "x" and s[right] == "x":
            ans += 1
            right -= 1
        else:
            left += 1
            right -= 1
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s = readline().rstrip().decode('utf-8')

t = ""
for i in s:
    if not i == "x":
        t += i

if t[::] != t[::-1]:
    print(-1)

else:
    ans = 0
    left,right = 0,len(s)-1
    while True:
        if left == right:
            break
        if s[left] == "x" and s[right] != "x":
            ans += 1
            left += 1
        elif s[left] != "x" and s[right] == "x":
            ans += 1
            right -= 1
        else:
            left += 1
            right -= 1
    print(ans)
Problem p03600 (python)

Fixed submission:
import sys
from copy import deepcopy
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
lst1 = [list(map(int,readline().split())) for i in range(n)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
st = deepcopy(lst1)
st = warshall_floyd(st)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if lst1[i][j] > st[i][j]:
            print(-1)
            exit()
        elif lst1[i][j]==st[i][j]:
            #他に最短距離がある場合はcontinue
            res = [0]*n
            for k in range(n):
                res[k] += lst1[i][k] + lst1[j][k]
            res[i] = -1
            res[j] = -1
            if any([res[k]==lst1[i][j] for k in range(n)]):
                continue
            else:
                ans += lst1[i][j]
        else:
            ans += lst1[i][j]

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
lst1 = [list(map(int,readline().split())) for i in range(n)]

from scipy.sparse.csgraph import shortest_path,floyd_warshall
from scipy.sparse import csr_matrix
lc = csr_matrix(lst1)
st = shortest_path(lc,method="FW")
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if lst1[i][j] > st[i][j]:
            print(-1)
            exit()
        elif lst1[i][j]==st[i][j]:
            #他に最短距離がある場合はcontinue
            res = [0]*n
            for k in range(n):
                res[k] += lst1[i][k] + lst1[j][k]
            res[i] = -1
            res[j] = -1
            if any([res[k]==lst1[i][j] for k in range(n)]):
                continue
            else:
                ans += lst1[i][j]
        else:
            ans += lst1[i][j]

print(ans)
Problem p03609 (python)

Fixed submission:
x,t = map(int,input().split())
print(max(0,x-t))

Buggy submission (verdict: Runtime Error):
print(max(0,x-t))
Problem p03610 (python)

Fixed submission:
s = input()
ans = ""
for i in range(0,len(s),2):
  ans += s[i]
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = ""
for i in range(len(s),2):
  ans += s[i]
print(ans)
Problem p03697 (python)

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

if a+b >= 10:
    print("error")
else:
    print(a+b)

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

if a+b >= 10:
    print("error")
else:
    print(a+b)
Problem p03720 (python)

Fixed submission:
n,m = map(int,input().split())
lst1 = [list(map(int,input().split())) for i in range(m)]

lst2 = [0]*n

for i,j in lst1:
    lst2[i-1] += 1
    lst2[j-1] += 1

for i in lst2:
    print(i)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
lst1 = [list(map(int,input().split())) for i in range(m)]

lst2 = [0]*n

for i,j in lst1:
    lst2[i] += 1
    lst2[j] += 1

for i in lst2:
    print(i)
Problem p03732 (python)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
N,W = map(int,readline().split())
w,v = map(int,readline().split())
tmp = w
lst1 = [1,0,0,0]
v0 = [v]
v1 = []
v2 = []
v3 = []
for i in range(N-1):
    w,v = map(int,readline().split())
    if w == tmp:
        lst1[0] += 1
        v0.append(v)
    elif w == tmp+1:
        lst1[1] += 1
        v1.append(v)
    elif w == tmp+2:
        lst1[2] += 1
        v2.append(v)
    else:
        lst1[3] += 1
        v3.append(v)
v0.sort(reverse=True)
for i in range(1,lst1[0]):
    v0[i] += v0[i-1]
v1.sort(reverse=True)
for i in range(1,lst1[1]):
    v1[i] += v1[i-1]
v2.sort(reverse=True)
for i in range(1,lst1[2]):
    v2[i] += v2[i-1]
v3.sort(reverse=True)
for i in range(1,lst1[3]):
    v3[i] += v3[i-1]

ans = 0
for i in range(lst1[0]+1):
    for j in range(lst1[1]+1):
        for k in range(lst1[2]+1):
            for l in range(lst1[3]+1):
                res = i*tmp+j*(tmp+1)+k*(tmp+2)+l*(tmp+3)
                if W >= res:
                    res2 = 0
                    if i != 0:
                        res2 += v0[i-1]
                    if j != 0:
                        res2 += v1[j-1]
                    if k != 0:
                        res2 += v2[k-1]
                    if l != 0:
                        res2 += v3[l-1]


                    ans = max(ans,res2)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
N,W = map(int,readline().split())

#i:N,j:W,value:value
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(1,N+1):
    w,v = map(int,readline().split())
    for j in range(1,W+1):
        if j < w:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v)

print(dp[-1][-1])

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
N,W = map(int,readline().split())
wv = [list(map(int,readline().split())) for i in range(N)]

#i:N,j:W,value:value
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(1,N+1):
    for j in range(1,W+1):
        if j < wv[i-1][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-wv[i-1][0]]+wv[i-1][1])

print(dp[-1][-1])
Problem p04013 (python)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,a = map(int,readline().split())
lst1 = list(map(int,readline().split()))

import numpy as np

dp = np.zeros((n+1,3000),dtype=np.int64) # 枚数、目標数ごとに場合の数
dp[0,0] = 1

for x in lst1:
  dp[1:,x:] += dp[:-1,:-x].copy()
  
ans = 0
for i in range(1,n+1):
  ans += dp[i,i*a]
  
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,a = map(int,readline().split())
lst1 = list(map(int,readline().split()))

import numpy as np

dp = np.zeros((n+1,3000),dtype=np.int64) # 枚数、目標数ごとに場合の数
dp[0,0] = 1

for x in lst1:
  dp[1:,x:] += dp[:-1,:-x].copy()
  
ans = 0
for i in range(1,n+1):
  ans += dp[i,i*lst1]
  
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,a = map(int,readline().split())
lst1 = list(map(int,readline().split()))

import numpy as np

dp = np.zeros((n+1,3000),dtype=np.int64) # 枚数、目標数ごとに場合の数
dp[0,0] = 1

for x in lst1:
  dp[1:,x:] += dp[:-1,:-x].copy()
  
ans = 0
for i in range(1,n+1):
  ans += dp[i,i*lst1]
  
print(ans)
Problem p02548 (python)

Fixed submission:
N = int(input())
count = 0
for a in range(1,N+1):
  for b in range(a,N//a+1):
    if a * b < N:
      if a == b:
        count += 1
      else:
        count += 2
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
count = 0
for a in range(1,N+1):
  for b in range(a,N/a+1):
    count += 2
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
count = 0
for a in range(1,N+1):
  for b in range(a,N/a+1):
    count += 1
print(count)
Problem p02612 (python)

Fixed submission:
N = int(input())
import math
print(int(math.ceil(N / 1000) * 1000 - N))

Buggy submission (verdict: Runtime Error):
N = int(input())
import math
print(int(math.ceil(N / 1000) * 1000 - N)
Problem p02613 (python)

Fixed submission:
N = int(input())
S = [input() for n in range(N)]
assert len(S) == N
counts = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for s in S:
  counts[s] += 1

for key in ['AC', 'WA', 'TLE', 'RE']:
	print('{} x {}'.format(key, counts[key]))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for n in range(N)]
assert len(S) == N
counts = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for s in S:
  counts[s] += 1

for key in ['AC', 'WA', 'TLE', 'RE']:
	print('{} x {}'.format(key, counts[key])
Problem p02639 (python)

Fixed submission:
print(list(map(int,input().split())).index(0) + 1)

Buggy submission (verdict: Runtime Error):
print(list(map(int,input().split()).index(0) + 1)

Buggy submission (verdict: Runtime Error):
print(list(map(int,input().split()).index(0))