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

Fixed submission:

a = input().split()
b = input().split()
c = input()

A = int(a[0])
V = int(a[1])
B = int(b[0])
W = int(b[1])
T = int(c)

if (B>A):
	if(W>=V):
		print("NO")
	else:
		times = (B-A) / (V-W)
		if(times <= T):
			print("YES")
		else:
			print("NO")
else:
	if(W>=V):
		print("NO")
	else:
		times = (A-B) / (V-W)
		if(abs(times) <= T):
			print("YES")
		else:
			print("NO")

Buggy submission (verdict: Runtime Error):

a = input().split()
b = input().split()
c = input()

if(int(b[0])>int(a[0])):
	if(int(b[1])>=int(a[1])):
		print("NO")
	else:
		length = int(b[0]) - int(a[0])
		v = int(a[1]) - int(b[1])
		times = length / v
		if(times <= int(c)):
			print("YES")
		else:
			print("NO")
else:
	if(int(b[1])<=int(a[1])):
		print("NO")
	else:
		length = -int(b[0]) + int(a[0])
		v = int(-a[1]) + int(b[1])
		times = length / v
		if(times <= int(c)):
			print("YES")
		else:
			print("NO")

Buggy submission (verdict: Runtime Error):

a = input().split()
b = input().split()
c = input()

if(int(b[0]>int(a[0]))):
	if(int(b[1])>=int(a[1])):
		print("NO")
	else:
		length = int(b[0]) - int(a[0])
		v = int(a[1]) - int(b[1])
		times = length / v
		if(times <= int(c)):
			print("YES")
		else:
			print("NO")
else:
	if(int(b[1])<=int(a[1])):
		print("NO")
	else:
		length = -int(b[0]) + int(a[0])
		v = int(-a[1]) + int(b[1])
		times = length / v
		if(times <= int(c)):
			print("YES")
		else:
			print("NO")

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

if(int(b[0]>int(a[0]))):
	if(int(b[1])>=int(a[1])):
		print("NO")
	else:
		length = int(b[0]) - int(a[0])
		v = int(a[1]) - int(b[1])
		times = length / v
		if(times <= int(c)):
			print("YES")
		else:
			print("NO")
else:
	if(int(b[1])>=int(a[1])):
		print("NO")
	else:
		length = -int(b[0]) + int(a[0])
		v = int(a[1]) - int(b[1])
		times = length / v
		if(times <= int(c)):
			print("YES")
		else:
			print("NO")
Problem p02971 (python)

Fixed submission:
N = int(input())
list = [int(input()) for i in range(N)]
if sorted(list)[-1] == sorted(list)[-2]:
    list2 = [max(list)]*N
    print("\n".join(map(str,list2)))
else:
    list2 = [max(list)]*list.index(max(list))
    list2.append(sorted(list)[-2])
    list3 = [max(list)]*(N-list.index(max(list))-1)
    list2.extend(list3)
    print("\n".join(map(str,list2)))

Buggy submission (verdict: Runtime Error):
N = int(input())
list = [int(input()) for i in range(N)]
if sorted(list)[-1] == sorted(list)[-2]:
    list2 = [max(list)]*range(N)
    print("\n".join(map(str,list2)))
else:
    list2 = [max(list)]*list.index(max(list))
    list2.append(sorted(list)[-2])
    list3 = [max(list)]*(N-list.index(max(list))-1)
    list2.extend(list3)
    print("\n".join(map(str,list2)))
Problem p02675 (python)

Fixed submission:
n = str(input())
N = n[-1]

if N == "3":
  print("bon")
elif N == "0" :
  print("pon")
elif N == "1" :
  print("pon")
elif N == "6":
  print("pon")
elif N == "8":
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
import math

A = int(input())
B = int(input())
H = int(input())
M = int(input())
c = 0

h = H * 30 + 0.5 * M
m = 6 * M
#hh = abs(h - m)
hh = h - m
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = A * A + B * B - 2 * A * B * math.cos(c)
print(math.sqrt(C))
Problem p02677 (python)

Fixed submission:
import math
A,B,H,M = map(int,input().split())


h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = (A * A) + (B * B) - (2 * A * B * math.cos(c))
print(math.sqrt(C))

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

Buggy submission (verdict: Runtime Error):
import math
A = int(input())
B = int(input())
H = int(input())
M = int(input())

h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = (A * A) + (B * B) - (2 * A * B * math.cos(c))
print(math.sqrt(C))

Buggy submission (verdict: Runtime Error):
import math
A = int(input())
B = int(input())
H = int(input())
M = int(input())

h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = (A * A) + (B * B) - (2 * A * B * math.cos(c))
print(math.sqrt(C))

Buggy submission (verdict: Runtime Error):
import math
A = int(input())
B = int(input())
H = int(input())
M = int(input())
c = 0

h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = (A * A) + (B * B) - (2 * A * B * math.cos(c))

print(math.sqrt(C))

Buggy submission (verdict: Runtime Error):
import math
A = int(input())
B = int(input())
H = int(input())
M = int(input())
c = 0

h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = (A * A) + (B * B) - (2 * A * B * math.cos(c))

Buggy submission (verdict: Runtime Error):
import math
A = int(input())
B = int(input())
H = int(input())
M = int(input())
c = 0

h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = (A * A) + (B * B) - (2 * A * B * math.cos(c))

print(math.sqrt(C))

Buggy submission (verdict: Runtime Error):
import math
A = int(input())
B = int(input())
H = int(input())
M = int(input())
c = 0

h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

print(c)

#print(math.cos(math.radians(90)))
      
C = (A * A) + (B * B) - (2 * A * B * math.cos(c))
print(C)
print(math.sqrt(C))
Problem p02645 (python)

Fixed submission:
s = input()
print(s[0:3])

Buggy submission (verdict: Runtime Error):
S = input()
return s[0:3]
Problem p03246 (python)

Fixed submission:
n = int(input()) # sを取得し、strに値を入れる
num= input()
num=list(map(int,num.split()))

from collections import defaultdict

d0=defaultdict(int)
d1=defaultdict(int)
for i in range(n):
    if i%2==0:
        d0[num[i]]+=1
    else:
        d1[num[i]]+=1

l0=[(k,d0[k]) for k in d0]
l1=[(k,d1[k]) for k in d1]

l0=sorted(l0, key=lambda d:d[1],reverse=True)
l1=sorted(l1, key=lambda d:d[1],reverse=True)

l0.append(("wild card",0))
l1.append(("wild card",0))

if l0[0][0]!=l1[0][0]: #文字が同じ場合
    print(len(num)-l0[0][1]-l1[0][1])
elif n==2:
    print(1)
else:
    print(n-max(l0[0][1]+l1[1][1],l0[1][1]+l1[0][1]))

Buggy submission (verdict: Runtime Error):
n = int(input()) # sを取得し、strに値を入れる
num= input()
num=list(map(int,num.split()))

from collections import defaultdict

d0=defaultdict(int)
d1=defaultdict(int)
for i in range(n):
    if i%2==0:
        d0[num[i]]+=1
    else:
        d1[num[i]]+=1

l0=[(k,d0[k]) for k in d0]
l1=[(k,d1[k]) for k in d1]
l0=sorted(l0, key=lambda d:d[1],reverse=True)
l1=sorted(l1,key=lambda d:d[1],reverse=True)

if l0[0][0]!=l1[0][0]:
    print(len(num)-l0[0][1]-l1[0][1])
elif len(num)==2:
    print(1)
else:
    s=0
    if l0[0][1]>=l1[0][1]:
        s=l0[0][1]+l1[1][1]
    else:
        s=l0[1][1]+l1[0][1]
    print(len(num)-s)

Buggy submission (verdict: Runtime Error):
str = input() # sを取得し、strに値を入れる
num= input()
num=list(map(int,num.split()))

from collections import defaultdict

d0=defaultdict(int)
d1=defaultdict(int)
for i in range(len(num)):
    if i%2==0:
        d0[num[i]]+=1
    else:
        d1[num[i]]+=1

l0=[(k,d0[k]) for k in d0]
l1=[(k,d1[k]) for k in d1]
l0=sorted(l0, key=lambda d:d[1],reverse=True)
l1=sorted(l1,key=lambda d:d[1],reverse=True)

if l0[0][0]!=l1[0][0]:
    print(len(num)-l0[0][1]-l1[0][1])
elif len(num)==2:
    print(1)
else:
    s=0
    if l0[0][1]>=l1[0][1]:
        s=l0[0][1]+l1[1][1]
    else:
        s=l0[1][1]+l1[0][1]
    print(len(num)-s)

Buggy submission (verdict: Runtime Error):
str = input() # sを取得し、strに値を入れる
num= input()
num=list(map(int,num.split()))

from collections import defaultdict

d0=defaultdict(int)
d1=defaultdict(int)
for i in range(len(num)):
    if i%2==0:
        d0[num[i]]+=1
    else:
        d1[num[i]]+=1

l0=[(k,d0[k]) for k in d0]
l1=[(k,d1[k]) for k in d1]
l0=sorted(l0, key=lambda d:d[1],reverse=True)
l1=sorted(l1,key=lambda d:d[1],reverse=True)


if l0[0][0]!=l1[0][0]:
    print(len(num)-l0[0][1]-l1[0][1])
else:
    s=0
    if l0[0][1]>=l1[0][1]:
        s=l0[0][1]+l1[1][1]
    else:
        s=l0[1][1]+l1[0][1]
    print(len(num)-s)
Problem p02678 (python)

Fixed submission:
# D

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import breadth_first_order

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

row = []
col = []
for i in range(M):
    r, c = list(map(int, input().split()))
    row.append(c-1)
    col.append(r-1)

data = [1] * (M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
_, proc = breadth_first_order(csr, 0, directed=False)

if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  print('\n'.join((proc[1:]+1).astype('str')))

Buggy submission (verdict: Runtime Error):
# D

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import breadth_first_order

N, M = list(map(int, input().split()))
ABs = np.array([list(map(int, input().split())) for i in range(M)])

row = ABs.T[0]
col = ABs.T[1]
data = [1] * (M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
_, proc = breadth_first_order(csr, 0, directed=False)

if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  print('\n'.join((proc[1:]+1).astype('str')))

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
import numpy as np
# D

N, M = list(map(int, input().split()))
ABs = np.array([list(map(int, input().split())) for i in range(M)])

ABsT = ABs.T
row = list(ABsT[0]-1) + list(ABsT[1]-1)
col = list(ABsT[1]-1) + list(ABsT[0]-1)
data = [1] * (2 * M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
from_starts, procs = dijkstra(csr, indices=[0], return_predecessors=True)
proc = procs[0]
 
print(csr.toarray())
print(proc)
if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  for i in range(N-1):
    print(int(proc[i+1]) + 1)
Problem p02684 (python)

Fixed submission:
# D

N, K = list(map(int, input().split()))
As = list(map(int, input().split()))

def compute(city, K):
    for i in range(K):
        # print('\t', city)
        city = As[city-1]
    print(city)

cities_visited = [False] * N
i = 0
city = 1
city_visited_time = {}

while not cities_visited[city - 1]:
    # print(city)
    cities_visited[city - 1] = True
    city_visited_time[city-1] = i
    city = As[city-1]
    i += 1

loop_start = city_visited_time[city-1]
loop_end = i


div = (K - loop_start) // (loop_end - loop_start)
if K - loop_start < 0 or div == 0:
    compute(1, K)
else:
    compute(city, K - loop_start - div * (loop_end - loop_start))

Buggy submission (verdict: Runtime Error):
# D

N, K = list(map(int, input().split()))
As = list(map(int, input().split()))

def compute(city, K):
    for i in range(K):
        # print('\t', city)
        city = As[city-1]
    print(city)


if N > K:
    compute(1, K)

cities_visited = [False] * N
i = 0
city = 1
city_visited_time = {}

while not cities_visited[city - 1]:
    # print(city)
    cities_visited[city - 1] = True
    city_visited_time[city-1] = i
    city = As[city-1]
    i += 1

loop_start = city_visited_time[city-1]
loop_end = i

if loop_end - loop_start == 1:
    return city
div = (K - loop_start) // (loop_end - loop_start + 1)
# print(loop_start, loop_end, div, K % (loop_end - loop_start + 1))
compute(city, K % (loop_end - loop_start + 1) + loop_start + 1)
Problem p02690 (python)

Fixed submission:
# D
import math
X = int(input())

B = -math.floor(math.pow(X, 0.2))
for b in range(B, 100000):
    tmp = math.pow(X + b ** 5, 0.2)
    if math.floor(math.floor(tmp+1.0e-6) - tmp + 1.0e-6) == 0:
        break
        
tmp = math.floor(tmp + 1.0e-6)
print(tmp, b)

Buggy submission (verdict: Runtime Error):
# D
import math
X = int(input())

B = -math.floor(math.pow(X, 0.2))
for b in range(B, 1000):
    a = int(math.pow(X + b ** 5, 0.2))
    if a ** 5 - b ** 5 == X:
        break
        
tmp = int(tmp)
print(a, b)
Problem p02696 (python)

Fixed submission:
# D

import math
inp = input().split(' ')
A, B, N = int(inp[0]), int(inp[1]), int(inp[2])

alpha, beta = math.floor(A/B), A%B
if B-1 < N:
    x = B-1
else:
    x = N
    
print(math.floor(A*x/B) - A * math.floor(x/B))

Buggy submission (verdict: Runtime Error):
# D

inp = input().split(' ')
A, B, N = int(inp[0]), int(inp[1]), int(inp[2])

alpha, beta = math.floor(A/B), A%B
if B-1 < N:
    x = B-1
else:
    x = N
    
print(math.floor(A*x/B) - A * math.floor(x/B))
Problem p02697 (python)

Fixed submission:
# E

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])

import math
def get_pairs(N, M):
    sizes_even, sizes_odd = sorted(list(range(0, M, 2)), reverse=True), sorted(list(range(1, M, 2)), reverse=True)
    M2_ceil = math.ceil(M/2.0)
    M2_flor = math.floor(M/2.0)
    pairs = []
    for i in range(M2_ceil):
        pairs.append([1+i, 1+i+sizes_even[i]+1])
    half = 2+sizes_even[0]
    for i in range(M2_flor):
        pairs.append([half+i+1, half+i+1+sizes_odd[i]+1])
    return pairs
pairs = get_pairs(N, M)
for pair in pairs:
    print(pair[0], pair[1])

Buggy submission (verdict: Runtime Error):
# E

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])

import math
M2_ceil = math.ceil(M/2.0)
M2_flor = math.floor(M/2.0)
pairs = []
for i in range(M2_ceil):
    pairs.append([1+i, 1+i+sizes_even[i]+1])
for i in range(M2_flor):
    pairs.append([1+M2_ceil+1+i+1, 1+M2_ceil+1+i+1+sizes_odd[i]+1])
    
for pair in pairs:
    print(pair[0], pair[1])
Problem p02700 (python)

Fixed submission:
# B

inputs = input().split(' ')

d = inputs[0:2]
takahashi = {'Name': 'Takahashi', 'Hp': int(d[0]), 'Power': int(d[1])}
d = inputs[2:4]
aoki = {'Name': 'Aoki', 'Hp': int(d[0]), 'Power': int(d[1])}

players = [takahashi, aoki]

def compute(players):
    N =len(players)
    while True:
        for i in range(N):
            players[i-1]['Hp'] -= players[i]['Power']
            if players[i-1]['Hp'] <= 0:
                if players[i]['Name'] == 'Takahashi':
                    print('Yes')
                else:
                    print('No')
                return 

compute(players)

Buggy submission (verdict: Runtime Error):
# B

inputs = input().split(' ')

d = inputs[0:2]
takahashi = {'Name': 'Takahashi', 'Hp': int(d[0]), 'Power': d[1]}
d = inputs[2:4]
aoki = {'Name': 'Aoki', 'Hp': int(d[0]), 'Power': d[1]}

players = [aoki, takahashi]
N =len(players)
while True:
    for i in range(N):
        players[i-1]['Hp'] -= players[i]['Power']
        if players[i-1]['Hp'] <= 0:
            if players[i]['Name'] == 'Takahashi':
                print('Yes')
            else:
                print('No')

Buggy submission (verdict: Runtime Error):
inputs = input().split(' ')

d = inputs[0:2]
takahashi = {'Name': 'Takahashi', 'Hp': int(d[0]), 'Power': d[1]}
d = inputs[2:4]
aoki = {'Name': 'Aoki', 'Hp': int(d[0]), 'Power': d[1]}

players = [aoki, takahashi]
N =len(players)
while True:
    for i in range(N):
        players[i-1]['HP'] -= players[i]['Power']
        if players[i-1]['HP'] <= 0:
            if players[i]['Name'] == 'Takahashi':
                print('Yes')
            else:
                print('No')
Problem p02717 (python)

Fixed submission:
n = input()
n_lis = n.split(" ")

print(n_lis[2],n_lis[0],n_lis[1])

Buggy submission (verdict: Runtime Error):
r_l = [1,2,3,4,5,6,7,8,9,10,11,12,21,22,23,32,33,34,43,44,45,54,55,56,65,66,67,76,77,78,87,88,89,98,99,100,101,110,111,112,113,121,122,123,210,211,212,221,222,223,232,233,234]
N = int(input())
print(r_l[N-1])
Problem p02692 (python)

Fixed submission:
N, A, B, C = map(int, input().split())
opts = []
for _ in range(N):
    opt = input()
    opts.append((ord(opt[0]) - ord("A"), ord(opt[1]) - ord("A")))

choices = []
nums = [A, B, C]
for i, opt in enumerate(opts):
    if nums[opt[0]] == 0 and nums[opt[1]] == 0:
        print("No")
        break
    if nums[opt[0]] == 1 and nums[opt[1]] == 1:
        if i < N - 1 and opt != opts[i + 1]:
            choice = (set(opt) & set(opts[i + 1])).pop()
            nums[choice] += 1
            nums[choice ^ opt[0] ^ opt[1]] -= 1
            choices.append(choice)
            continue
    if nums[opt[0]] >= nums[opt[1]]:
        choices.append(opt[1])
        nums[opt[1]] += 1
        nums[opt[0]] -= 1
    else:
        choices.append(opt[0])
        nums[opt[0]] += 1
        nums[opt[1]] -= 1
else:
    print("Yes")
    for c in choices:
        print(chr(c + ord("A")))

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
opts = []
for _ in range(N):
    opt = input()
    opts.append((ord(opt[0]) - ord("A"), ord(opt[1]) - ord("A")))

choices = []
nums = [A, B, C]
for i, opt in enumerate(opts):
    if nums[opt[0]] == 0 and nums[opt[1]] == 0:
        print("No")
        break
    if nums[opt[0]] == 1 and nums[opt[1]] == 1:
        if i < N - 1 and opt != opts[i + 1]:
            choice = next(set(opt) ^ set(opts[i + 1]))
            nums[opt] += 1
            nums[opt ^ opt[0] ^ opt[1]] -= 1
            choices.append(choice)
            continue
    if nums[opt[0]] >= nums[opt[1]]:
        choices.append(opt[1])
        nums[opt[1]] += 1
        nums[opt[0]] -= 1
    else:
        choices.append(opt[0])
        nums[opt[0]] += 1
        nums[opt[1]] -= 1
else:
    print("Yes")
    for c in choices:
        print(chr(c + ord("A")))
Problem p02710 (python)

Fixed submission:
N = int(input())
Cs = list(map(int, input().split()))
adj = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)

degs = [0] * N
clusters = [[] for _ in range(N)]


def go(curr, fro):
    col = Cs[curr] - 1
    deg = 1
    clust = {}
    for n in adj[curr]:
        if n == fro:
            continue
        ch_deg, ch_clust = yield n, curr
        clusters[col].append(ch_deg - ch_clust.get(col, 0))
        if len(ch_clust) > len(clust):
            clust, ch_clust = ch_clust, clust
        for k, v in ch_clust.items():
            clust[k] = clust.get(k, 0) + v
        deg += ch_deg
    clust[col] = deg
    return deg, clust


def tramp(gen_fn, *args):
    stack = [gen_fn(*args)]
    val = None
    while stack:
        gen = stack[-1]
        try:
            params = gen.send(val)
        except StopIteration as e:
            stack.pop()
            val = e.value
        else:
            stack.append(go(*params))
            val = None
    return val


_, root_clust = tramp(go, 0, -1)
for i in range(N):
    clusters[i].append(N - root_clust.get(i, 0))


for clust in clusters:
    tot = (N * N + N) // 2
    for cnt in clust:
        tot -= (cnt * cnt + cnt) // 2
    print(tot)

Buggy submission (verdict: Runtime Error):
import asyncio

N = int(input())
Cs = list(map(int, input().split()))
adj = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)

degs = [0] * N
clusters = [[] for _ in range(N)]


async def go(curr, fro):
    col = Cs[curr] - 1
    deg = 1
    clust = {}
    for n in adj[curr]:
        if n == fro:
            continue
        ch_deg, ch_clust = await go(n, curr)
        clusters[col].append(ch_deg - ch_clust.get(col, 0))
        if len(ch_clust) > len(clust):
            clust, ch_clust = ch_clust, clust
        for k, v in ch_clust.items():
            clust[k] = clust.get(k, 0) + v
        deg += ch_deg
    clust[col] = deg
    return deg, clust


_, root_clust = asyncio.get_event_loop().run_until_complete(go(0, -1))
for i in range(N):
    clusters[i].append(N - root_clust.get(i, 0))


for clust in clusters:
    tot = (N * N + N) // 2
    for cnt in clust:
        tot -= (cnt * cnt + cnt) // 2
    print(tot)
Problem p02761 (python)

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


def answer():
    digs = [-1] * N
    for _ in range(M):
        s, c = map(int, input().split())
        s -= 1
        if digs[s] not in {c, -1}:
            return -1
        digs[s] = c
    if digs[0] == -1:
        digs[0] = int(N > 1)
    elif digs[0] == 0 and N > 1:
        return -1
    for i in range(1, N):
        if digs[i] == -1:
            digs[i] = 0
    return "".join(map(str, digs))


print(answer())

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


def answer():
    digs = [-1] * N
    for _ in range(M):
        s, c = map(int, input().split())
        s -= 1
        if s == 0 and c == 0:
            return -1
        if digs[s] not in {c, -1}:
            return -1
        digs[s] = c
    if digs[0] == -1:
        digs[0] = 1
    if digs[1] == -1:
        digs[1] = 0
    if digs[2] == -1:
        digs[2] = 0
    return "".join(map(str, digs))


print(answer())
Problem p02784 (python)

Fixed submission:
H, N = map(int, input().split())
attacks = list(map(int, input().split()))
if sum(attacks) >= H:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
H, N = map(int, input().split())
attacks = [*map(int, input().split())]
if sum(attacks) >= H:
    print("Yes")
else:
    print("No")
Problem p02646 (python)

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

if abs(a-b) <= t* (v-w):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = input()

a = A #+ (int(V) * int(T))
b = B #+ (int(W) * int(T))

for i in range(1, T + 1, 1):
    a += V
    b += W

    if a == b:
        print("YES")
        break

if (a != b):
    print("NO")
Problem p03163 (python)

Fixed submission:
# DP
def main():
    N, W = map(int, input().split())

    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] == -1:
                continue
            if dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v
    print(max(dp))


main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""
import numpy as np
import sys

EMPTY = (0, 0, frozenset())


def solve(values, _nb, max_capacity):
    dp = [0] * (max_capacity + 1)
    for w, v in values:
        # dp = dp[:w] + [max(dp[j], dp[j - w] + v) for j in range(w, max_capacity + 1)]
        dp = dp[:w] + [
            np.max(dpj, dpjw + v)
            for dpj, dpjw in zip(dp[w:], dp[: (max_capacity + 1 - w)])
        ]
    return dp[max_capacity]


def solve_slow(values, nb, max_capacity):
    dp = [[0 for _ in range(max_capacity + 1)] for _ in range(nb + 1)]
    for i in range(1, nb + 1):
        w, v = values[i - 1]
        for j in range(1, max_capacity + 1):
            if w <= j:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
            else:
                dp[i][j] = dp[i - 1][j]
    # print("\n".join(map(str, dp)))
    return dp[nb][max_capacity]


def do_job():
    "Do the work"
    # first line is number of test cases
    N, W = map(int, input().split())
    values = []
    for _ in range(N):
        values.append(list(map(int, input().split())))
    result = solve(values, N, W)
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())
Problem p02675 (python)

Fixed submission:
n = input()
s = int(n[-1])
if s == 3:
  print('bon')
elif s == 2 or s == 4 or s == 5 or s== 7 or s== 9:
  print('hon')
else:
  print('pon')

Buggy submission (verdict: Runtime Error):
n = int(input())
if n[-1] == 3:
  print('bon')
elif n[-1] ==2 or 4 or 5 or 7 or 9:
  print('hon')
else:
  print('pon')