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

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, M, X  = [int(x) for x in stdin.readline().rstrip().split()]

CA = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

knowledge_list = [[0 for _ in range(M)]]
money_list = [0]

for i in range(N):
    C = CA[i][0]
    A = CA[i][1:]

    # 購入する場合
    tmp2 = []
    for i, knowledge in enumerate(knowledge_list):
        tmp = []
        for k in range(len(knowledge)):
            tmp.append(knowledge[k] + A[k])
        
        tmp2.append(tmp)
        money_list.append(money_list[i]+C)

    knowledge_list = knowledge_list + tmp2

ans = INF
for i in range(len(money_list)):
    if min(knowledge_list[i]) >= X:
        ans = min(ans, money_list[i])

if ans != INF:
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, M, X  = [int(x) for x in stdin.readline().rstrip().split()]
CA = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

nums = [0, 1]
buy_or_not = list(itertools.product(nums, repeat=N))

knowledge_list = []
money_list = []

for bn in buy_or_not:
    knowledge = [0 for _ in range(M)]
    money = 0
    for i in range(M):
        if bn[i] == 1:
            money += CA[i][0]
            knowledge = [a + b for a, b in zip(knowledge, CA[i][1:])]

    knowledge_list.append(knowledge)
    money_list.append(money)

ans = INF

for i in range(len(money_list)):
    if min(knowledge_list[i]) >= X:
        ans = min(ans, money_list[i])

if ans != INF:
    print(ans)
else:
    print(-1)
Problem p02936 (python)

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# N <= 2*10^5
# Q <= 2*10^5
N, Q = [int(x) for x in stdin.readline().rstrip().split()]
ab = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]
px = [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]

node_value = [0] * (N+1)
parent = [-1] * (N+1)

for a, b in ab:
    parent[b] = a

for p, x in px:
    node_value[p] += x

#print(parent)

ans = [0] * (N+1)

for i in range(1, N+1):
    ans[i] = node_value[i]
    if parent[i] != -1:
        ans[i] += ans[parent[i]]

print(*ans[1:], sep=" ")

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

import sys
sys.setrecursionlimit(100000)

# N <= 2*10^5
# Q <= 2*10^5
N, Q = [int(x) for x in stdin.readline().rstrip().split()]
#ab = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]
#px = [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]

ans = [0] * (N+1)
child = []
for _ in range(N+1):
    child.append([])

def add(node, num):
    for x in child[node]:
        add(x, num)

    ans[node] += num

for a, b in [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]:
    child[a].append(b)

#print(child)

for p, x in [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]:
    add(p, x)

print(*ans[1:], sep=" ")
Problem p03006 (python)

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque
import collections
import itertools

INF = 10 ** 10


# N個のボールがあり、i番目のボールは(xi, yi)にある
N = int(stdin.readline().rstrip())
xy = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

data = []

if N == 1:
    print(1)
    exit()

for i in range(N):
    for j in range(i+1, N):
        x_diff = xy[i][0] - xy[j][0]
        y_diff = xy[i][1] - xy[j][1]
        data.append("{0},{1}".format(x_diff, y_diff))
        data.append("{0},{1}".format(-x_diff, -y_diff))

c = collections.Counter(data)

print(N - c.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque
import collections
import itertools

INF = 10 ** 10


# N個のボールがあり、i番目のボールは(xi, yi)にある
N = int(stdin.readline().rstrip())
xy = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

data = []

for i in range(N):
    for j in range(i+1, N):
        x_diff = abs(xy[i][0] - xy[j][0])
        y_diff = abs(xy[i][1] - xy[j][1])

        data.append("{0},{1}".format(x_diff, y_diff))

c = collections.Counter(data)

print(N - c.most_common()[0][1])
Problem p03044 (python)

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque

WHITE = 0
BLACK = 1

N = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]

# 木の繋がりと長さ
connect = [[] for _ in range(N+1)]
for u, v, w in data:
    connect[u].append([v,w])
    connect[v].append([u,w])

# 根から頂点までの距離
# 根は適当な頂点を選べば良いので、u_0とする
dist = [None] * (N+1)
dist[data[0][0]] = 0

que = deque([])
que.append(data[0][0])
is_visited = [False] * (N+1)

# BFSで根からの距離を求めていく
while len(que) != 0:
    u = que.popleft()

    if is_visited[u] == True:
        continue

    is_visited[u] = True

    for v, w in connect[u]:
        que.append(v)
        if dist[v] == None:
            dist[v] = dist[u] + w

# distが偶数の頂点には白で、奇数の頂点には黒で塗ることとする
for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(WHITE)
    else:
        print(BLACK)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque

WHITE = 0
BLACK = 1

N = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]

# 根から頂点までの距離
# 根は適当な頂点を選べば良いので、u_0とする
dist = [None] * (N+1)
dist[data[0][0]] = 0

# 根からの距離を算出
for u, v, w in data:
    # 木構造なので、どちらか一方はすでに求まっているはず
    if dist[u] != None:
        dist[v] = dist[u] + w
    else:
        dist[u] = dist[v] + w

# distが偶数の頂点には白で、奇数の頂点には黒で塗ることとする
for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(WHITE)
    else:
        print(BLACK)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque

WHITE = 0
BLACK = 1

N = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]

# 根から頂点までの距離
# 根は適当な頂点を選べば良いので、u_0とする
dist = [None] * (N+1)
dist[data[0][0]] = 0

# 根からの距離を算出
for u, v, w in data:
    # 木構造なので、どちらか一方はすでに求まっているはず
    if dist[u] != None:
        dist[v] = dist[u] + w
    else:
        dist[u] = dist[v] + w

# distが偶数の頂点には白で、奇数の頂点には黒で塗ることとする
for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(WHITE)
    else:
        print(BLACK)
Problem p03061 (python)

Fixed submission:
from sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
# インデックスを直感で使えるように先頭にダミーを入れる
A = [0] + A

"""
L(i) := A_1, A_2, ..., A_i-1 の最大公約数
R(i) := A_i, A_i+1, ..., A_N の最大公約数
Aiを書き換えることにした場合の最大公約数をM_iとすると
M_i = gcd(L(i), R(i+1))

ただし L(0)=0, R(N+1)=0
"""

L = [0 for _ in range(N+1)]
R = [0 for _ in range(N+2)]

for i in range(N):
    L[i+1] = fractions.gcd(L[i], A[i])


for i in range(N, 0, -1):
    R[i] = fractions.gcd(R[i+1], A[i])

M = []

for i in range(1, N+1):
    M_i = fractions.gcd(L[i], R[i+1])
    M.append(M_i) 

print(max(M))

Buggy submission (verdict: Runtime Error):
from sys import stdin
import fractions
 
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
 
res = []
 
for i in range(N):
    B = A[:]
    del B[i]
    B.sort()

    gcd_num = fractions.gcd(B[0], B[1])

    res.append(gcd_num)

 
print(max(res))

Buggy submission (verdict: Runtime Error):
from sys import stdin
import fractions
from collections import deque
 
 
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
#A = deque(A)
 
res = []
 
for i in range(N):
    B = A[:]
    del B[i]
    B.sort()

    res.append(fractions.gcd(B[0], B[1]))

 
print(max(res))
Problem p03086 (python)

Fixed submission:
from sys import stdin

S = stdin.readline().rstrip()
countlist = []

count = 0
for s in S:
    if s == "A" or s == "C" or s == "G" or s == "T":
        count += 1
    else:
        countlist.append(count)
        count = 0
countlist.append(count)
print(max(countlist))

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

S = stdin.readline().rstrip()

countlist = []

count = 0
for s in S:
    if s == "A" or s == "C" or s == "G" or s == "T":
        count += 1
    else:
        countlist.append(count)
        count = 0

print(max(countlist))
Problem p03106 (python)

Fixed submission:
from sys import stdin

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]


num_list = []

for i in range(1, min([A, B])+1):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

print(num_list[-(K)])

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

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]

# 最大公約数
gcd = math.gcd(A, B)

num_list = []

for i in range(1, gcd+1):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

print(num_list[-(K)])

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

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]

# 最大公約数
gcd = math.gcd(A, B)

num_list = []

for i in range(1, gcd+1):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

print(num_list[-(K)])
Problem p03164 (python)

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, W = [int(x) for x in stdin.readline().rstrip().split()]
wv = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

max_weight = W+1
max_cost = sum([v for w, v in wv])

# cost時の最小の重さ
# dp[cost] = weight
# 計算量は最大でもN=100*vi=10^3の10^5
dp = [INF for _ in range(max_cost+10)]
dp[0] = 0

for w, v in wv:
    # 前からやると重複を許してしまうことになるので後ろから
    # max_cost~v
    for i in reversed(range(v, max_cost+1)):
        dp[i] = min(dp[i], dp[i-v]+w)

# max_cost~0
for i in reversed(range(max_cost+1)):
    if dp[i] <= W:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, W = [int(x) for x in stdin.readline().rstrip().split()]
wv = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

# 最大公約数を求めてWを何とか小さくする
gcd_num = W
for i in range(N):
    gcd_num = fractions.gcd(gcd_num, wv[i][0])

W = W // gcd_num
for i in range(N):
    wv[i][0] = wv[i][0] // gcd_num

# 重さiでの価値の最大
# 品物の重複選択を許さない
dp = [[0] * (W+10) for _ in range(N+10)]

for i in range(N):
    weight, value = wv[i]
    dp[i+1] = dp[i][:]
    for j in range(weight, W+1):
        dp[i+1][j] = max(dp[i][j], dp[i][j-weight]+value)

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, W = [int(x) for x in stdin.readline().rstrip().split()]
wv = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

# 最大公約数を求めてWを何とか小さくする
gcd_num = W
for i in range(N):
    gcd_num = fractions.gcd(gcd_num, wv[i][0])

W = W // gcd_num
for i in range(N):
    wv[i][0] = wv[i][0] // gcd_num

# 重さiでの価値の最大
# 品物の重複選択を許さない
dp = [[0] * (W+10) for _ in range(N+10)]

for i in range(N):
    weight, value = wv[i]
    dp[i+1] = dp[i][:]
    for j in range(weight, W+1):
        dp[i+1][j] = max(dp[i][j], dp[i][j-weight]+value)

print(dp[N][W])
Problem p03166 (python)

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque
import sys

# 再起の上限を変更
sys.setrecursionlimit(100000)

INF = 10 ** 10

# 深さ優先探索
def dfs(i):
    global is_visited
    global tsort_res

    if is_visited[i]:
        return 

    is_visited[i] = True
    for j in nextl[i]:
        dfs(j)
    
    # 帰りがけ順で追加
    # 追加は先頭に行う
    tsort_res.appendleft(i)


# トポロジカルソート
def tsort():
    for i in range(1, N+1):
        dfs(i)

if __name__ == "__main__":

    N, M = [int(x) for x in stdin.readline().rstrip().split()]

    # トポロジカルソートで頂点iより後ろのパスの最大長
    dp = [0] * (N+1)

    # 頂点xから頂点vへの有向辺
    nextl = [[] for _ in range(N+1)]
    for _ in range(M):
        x, v = list(map(int, stdin.readline().rstrip().split()))
        nextl[x].append(v)
    
    # トポロジカルソートされた結果の入るリスト
    tsort_res = deque([])

    is_visited = [False] * (N+1)

    tsort()

    # 今回は逆順に使うのでリバースする
    # 汎用性のため、dfsでは先頭に追加するようにしている
    tsort_res = list(tsort_res)[::-1]

    for x in tsort_res:
        for v in nextl[x]:
            dp[x] = max(dp[x], dp[v] + 1)


    # for DEBUG
    #print(dp)
    print(max(dp))

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

# 深さ優先探索
def dfs(i):
    global is_visited
    global tsort_res

    if is_visited[i]:
        return 

    is_visited[i] = True
    for j in nextl[i]:
        dfs(j)
    
    # 帰りがけ順で追加
    # 追加は先頭に行う
    tsort_res.insert(0, i)


# トポロジカルソート
def tsort():
    for i in range(1, N+1):
        dfs(i)

if __name__ == "__main__":

    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    xv = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]

    # トポロジカルソートで頂点iより後ろのパスの最大長
    dp = [0] * (N+1)

    # 頂点xから頂点vへの有向辺
    nextl = [[] for _ in range(N+1)]
    for x, v in xv:
        nextl[x].append(v)
    
    # トポロジカルソートされた結果の入るリスト
    tsort_res = []

    is_visited = [False] * (N+1)

    tsort()

    # 今回は逆順に使うのでリバースする
    # 汎用性のため、dfsでは先頭に追加するようにしている
    tsort_res = tsort_res[::-1]

    for x in tsort_res:
        for v in nextl[x]:
            dp[x] = max(dp[x], dp[v] + 1)


    # for DEBUG
    #print(dp)
    print(max(dp))
Problem p02909 (python)

Fixed submission:
S=input()
if S=="Sunny":
  	print("Cloudy")
elif S=="Cloudy":
  	print("Rainy")
elif S=="Rainy":
	print("Sunny")

Buggy submission (verdict: Runtime Error):
S=input()
if S="Sunny":
  	print("Cloudy")
elif S="Cloudy":
  	print("Rainy")
elif S="Rainy":
	print("Sunny")
Problem p02957 (python)

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

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
if (A-B)%2 == 1:
    print("IMPOSSIBLE")
else:
    print(int((A-B)/2)
Problem p02971 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A,reverse=True)
if B[0] == B[1]:
    for i in range(N):
        print(B[0])
else:
    for i in range(N):
        if A[i] == B[0]:
            print(B[1])
        else:
            print(B[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A,reverse=True)
if B[0] = B[1]:
    for i in range(N):
        print(B[0])
else:
    for i in range(N):
        if A[i] = B[0]:
            print(B[1])
        else:
            print(B[0])
Problem p03160 (python)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
dp = [0, abs(L[0] - L[1])]
if N == 2:
    print(dp[1])
else:
    for i in range(2, N):
        dp.append(min(dp[i - 2] + abs(L[i] - L[i - 2]), dp[i - 1] + abs(L[i] - L[i - 1])))
    print(dp[N - 1])

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
H = list(map(int, input().split()))
dp = [-1]*N
for i in range(1, N):
    if i <= K:
        mi = abs(H[i] - H[0])
        for j in range(1, i):
            if dp[j] + abs(H[i] - H[j]) < mi:
                mi = dp[j] + abs(H[i] - H[j])
        dp[i] = mi
    else:
        mi = dp[i - K] + abs(H[i] - H[i - K])
        for j in range(i - K, i):
            if dp[j] + abs(H[i] - H[j]) < mi:
                mi = dp[j] + abs(H[i] - H[j])
        dp[i] = mi
print(dp[N - 1])
Problem p03455 (python)

Fixed submission:
l = input().split()
a = int(l[0])
b = int(l[1])
if (a * b) % 2 == 1:
  print("Odd")
else:
  print("Even")

Buggy submission (verdict: Runtime Error):
l = input().split()
a = int(l[0])
b = int(l[1])
if (a * b) % 2 = 1:
  print("Odd")
else:
  print("Even")

Buggy submission (verdict: Runtime Error):
l = input().split()
a = int(l[0])
b = int(l[1])
if (a * b) % 2 = 1:
  print(Odd)
else:
  print(Even)

Buggy submission (verdict: Runtime Error):
l = input().split()
a = l[0]
b = l[1]
if (a * b) % 2 = 1:
  print(Odd)
else:
  print(Even)
Problem p03472 (python)

Fixed submission:
NH = input().split()
N = int(NH[0])
H = int(NH[1])
a = []
b = []
for v in range(N):
    L = input().split()
    a.append(L[0])
    b.append(L[1])
a = list(map(int, a))
b = list(map(int, b))
a.sort(reverse = True)
b.sort(reverse = True)
c = 0
count = 0
while c < H:
    if len(b) > 0 and a[0] < b[0]:
        c = c + b.pop(0)
        count = count + 1 
    else:
        break
if c < H:
    count = count -(-(H - c)//a[0])
print(count)

Buggy submission (verdict: Runtime Error):
NH = input().split()
N = int(NH[0])
H = int(NH[1])
a = []
b = []
for v in range(N):
    L = input().split()
    a.append(L[0])
    b.append(L[1])
a = list(map(int, a))
b = list(map(int, b))
a.sort(reverse = True)
b.sort(reverse = True)
c = 0
count = 0
while c < H:
    if a[0] >= b[0] or len(b) == 0:
        c = c + a[0]
        count = count + 1
    else:
        c = c + b.pop(0)
        count = count + 1 
print(count)
Problem p02658 (python)

Fixed submission:
N = int(input())
lst = sorted([int(x) for x in input().split() if x != "1"], reverse=True)

if len(lst) == 0:
    print(1)
    exit()
if lst[-1] == 0:
    print(0)
    exit()

ret = 1
for x in lst:
    ret *= x
    if ret > 10 ** 18:
        print(-1)
        exit()

print(ret)

Buggy submission (verdict: Runtime Error):
N = int(input())
lst = sorted([int(x) for x in input().split() if x != "1"], reverse=True)
if lst[-1] == 0:
    print(0)
    exit()

ret = 1
for x in lst:
    ret *= x
    if ret > 10 ** 18:
        print(-1)
        exit()

print(ret)
Problem p02705 (python)

Fixed submission:
from math import pi
print(int(input()) * 2 * pi)

Buggy submission (verdict: Runtime Error):
from math import pi
print(int(input() * 2 * pi)
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
if M == 0:
    if N == 1:
        print(0)
    else:
        print("1" + "0" * (N - 1))
    exit()

dic = {}
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit()
    n = dic.get(s)
    if n is not None and n != c:
        print(-1)
        exit()
    dic[s] = c

lst = [0] * N
for k, v in dic.items():
    lst[k - 1] = v

if len(lst) != 1 and lst[0] == 0:
    lst[0] = 1

print("".join(map(str, lst)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lst = [0] * N
if M == 0 and N != 1:
    lst[0] = 1
else:
    dic = {}
    for _ in range(M):
        s, c = map(int, input().split())
        n = dic.get(s)
        if n is not None and n != c:
            print(-1)
            exit()
        dic[s] = c

for k, v in dic.items():
    lst[k - 1] = v

if N != 1 and lst[0] == 0:
    print(-1)
    exit()

if len(lst) != 0 and lst[0] == 0:
    lst[0] = 1

print("".join(map(str, lst)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lst = [0] * N
if M == 0 and N != 1:
    lst[0] = 1
else:
    dic = {}
    for _ in range(M):
        s, c = map(int, input().split())
        n = dic.get(s)
        if n is not None and n != c:
            print(-1)
            exit()
        dic[s] = c

if N != 1 and lst[0] == 0:
    print(-1)
    exit()

for k, v in dic.items():
    lst[k - 1] = v

if len(lst) != 0 and lst[0] == 0:
    lst[0] = 1

print("".join(map(str, lst)))
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
print(max(0, A - B * 2))

Buggy submission (verdict: Runtime Error):
N = int(input())
lst = list(map(int, input().split()))
ret = 0
for idx_a, a in enumerate(lst[:-2]):
    for idx_b, b in enumerate(lst[idx_a + 1:-1]):
        for idx_c, c in enumerate(lst[idx_a + idx_b + 2:]):
            if a < b + c and b < c + a and c < a + b:
                ret += 1
print(ret)

Buggy submission (verdict: Runtime Error):
N = int(input())
lst = list(map(int, input().split()))
ret = 0
for idx_a, a in enumerate(lst[:-2]):
    for idx_b, b in enumerate(lst[idx_a + 1:-1]):
        for idx_c, c in enumerate(lst[idx_a + idx_b + 2:]):
            if a < b + c and b < c + a and c < a + b:
                ret += 1
print(ret)
Problem p02957 (python)

Fixed submission:
A, B = map(int, input().split())
if (A - B) % 2 == 1:
    print('IMPOSSIBLE')
else:
    print(abs(A + B) // 2)

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

n = 0
for x, y in zip(lst1, lst2):
    if x != y:
        n += 1
        if n > 2:
            break

if n > 2:
    print('NO')
else:
    print('YES')
Problem p02999 (python)

Fixed submission:
X, A = map(int, input().split())
if X >= A:
    print(10)
else:
    print(0)

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

s = W * H
if x == 0:
    a = W * y
    b = W * (H - y)
    p = 1 if a == b else 0
elif y == 0:
    a = H * x
    b = H * (W - x)
elif W % x == 0 and H % y == 0:
    a = b = W * H // 2
else:
    a = W * y
    b = H * x

p = 1 if a == b else 0
print("{0} {1}".format(min(a, b), p))
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())
if W / 2 == x and H / 2 == y:
    p = 1
else:
    p = 0

print("{} {}".format(W * H / 2, p))

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

s = W * H
if W % x == 0 and H % y == 0:
    print("{0} {1}".format(W * H // 2, 1))
else:
    a = W * y
    b = H * x
    p = 1 if a == b else 0
    print("{0} {1}".format(min(a, b), p))
Problem p03161 (python)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
lst = np.array([int(x) for x in input().split()])
dp = np.zeros(N, dtype=int)

for i in range(1, N):
    start = max(i - K, 0)
    dp[i] = np.min(dp[start:i] + np.abs(lst[start:i] - lst[i]))
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
dp = [math.inf] * N
dp[0] = 0
dp[1] = abs(lst[0] - lst[1])
for i in range(2, N):
    j = K
    while j > 0:
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + abs(lst[i - j] - lst[i]))
        j -= 1
print(dp[-1])
Problem p03164 (python)

Fixed submission:
import numpy as np

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

dp = np.full(N * 1000 + 1, W + 1, dtype=np.int64)
dp[0] = 0

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

print(((dp <= W) * np.arange(N * 1000 + 1)).max())

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    w, v = map(int, input().split())
    for j in range(W + 1):
        if j < w:
            dp[i][j] = max(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])
Problem p03206 (python)

Fixed submission:
D = int(input())
lst = ['Christmas'] + ['Eve'] * (25 - D)
print(' '.join(lst))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
lst = []
for _ in range(N):
    lst.append(int(input()))
lst = sorted(lst)
ret = 100000000000
 
for idx, x in enumerate(lst[:-K+1], 0):
    tmp = lst[idx + K-1] - x
    if tmp < ret:
        ret = tmp
print(ret)