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

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

n, q = map(int, input().split())
Graph = [[] for i in range(n)]
seen = [False]*n
point = [0]*n


def dfs(g, v, p):
    # vを訪問済みにする
    seen[v] = True
    if p != -1: point[v] += point[p]

    # vから行ける各頂点について
    for next_v in g[v]:

        # next_vが訪問済みだったらスルー
        if seen[next_v]: continue

        # 再帰的に探索
        dfs(g, next_v, v)


for i in range(n-1):
    a, b = map(int, input().split())
    a-=1
    b-=1

    # 無向グラフを想定
    Graph[a].append(b)
    Graph[b].append(a)


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


dfs(Graph, 0, -1)


print(*point)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
Graph = [[] for i in range(n)]
seen = [False]*n
point = [0]*n


def dfs(g, v, p):
    # vを訪問済みにする
    seen[v] = True
    if p != -1: point[v] += point[p]

    # vから行ける各頂点について
    for next_v in g[v]:

        # next_vが訪問済みだったらスルー
        if seen[next_v]: continue

        # 再帰的に探索
        dfs(g, next_v, v)


for i in range(n-1):
    a, b = map(int, input().split())
    a-=1
    b-=1

    # 無向グラフを想定
    Graph[a].append(b)
    Graph[b].append(a)


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


dfs(Graph, 0, -1)


print(*point)

Buggy submission (verdict: Runtime Error):
# 頂点数と変数
n, q = map(int, input().split())
Graph = [[] for i in range(n+1)]
seen = [False]*(n+1)
point = [0]*(n+1)


def dfs(g, v, x):

    # vを訪問済みにする
    seen[v] = True
    point[v] += x

    # vから行ける各頂点について
    for next_v in g[v]:

        # next_vが訪問済みだったらスルー
        if seen[next_v]: continue
        if next_v < v: continue

        # 再帰的に探索
        dfs(g, next_v, x)


for i in range(n-1):
    a, b = map(int, input().split())

    # 無向グラフを想定
    Graph[a].append(b)
    Graph[b].append(a)

for i in range(q):
    p, x = map(int, input().split())
    dfs(Graph, p, x)
    seen = [False] * (n+1)


for i in point:
    if i == 0: continue
    print(i)
Problem p03353 (python)

Fixed submission:
s = input()
k = int(input())
a = []

for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if j - i >= 6:
            break
        a.append(s[i:j])

res = sorted(set(a))
print(res[k-1])

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

for i in range(5):
    for j in range(i+1, len(s)):
        if j - i >= 5: break
        a.append(s[i:j])

res = sorted(set(a))
print(res[k-1])
Problem p03457 (python)

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

x = y = t = 0
for i in range(n):
    dx, dy, dt = l[i][1], l[i][2], l[i][0]
    dist = abs((dx - x) + (dy - y))

    if abs(dt - t) < dist:
        print("No")
        exit()
    if abs(dt - t) % 2:
        if dist % 2 == 0:
            print("No")
            exit()
    else:
        if dist % 2 == 1:
            print("No")
            exit()
    x, y, t = dx, dy, dt
print("Yes")

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

for _ in range(n):
    t, x, y = map(int, n.split())
    if x + y > t or (t - x - y) % 2:
        print("No")
        exit()
print("Yes")

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

for _ in range(0, n):
    t, x, y = map(int, n.split())
    if x + y > t or (t - x - y) % 2:
        print("No")
        exit()
print("Yes")

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

for _ in range(0, n):
    t, x, y = map(int(), n.split())
    if x + y > t or (t - x - y) % 2:
        print("No")
        exit()
print("Yes")
Problem p02687 (python)

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

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
a_set = set()
for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    a_set |= set(A)
 
people = a_set
 
print(N - len(people))
Problem p02767 (python)

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

head = min(X)
tail = max(X)

min_score = float('inf')
for p in range(head, tail+1):
    min_score = min(sum(map(lambda x: (x - p)**2, X)), min_score)

print(min_score)

Buggy submission (verdict: Runtime Error):
import math


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

head = min(X)
tail = max(X)

min_score = math.inf
for p in range(head, tail+1):
    min_score = min(sum(map(lambda x: (x - p)**2, X)), min_score)

print(min_score)
Problem p02842 (python)

Fixed submission:
N = int(input())

X = int(N / 1.08)

ans = ':('
for x in range(X-5, X+6):
    n = int(x * 1.08)
    if n == N:
        ans = x
        break
print(ans)

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

X = N / 1.08

for x in range(X-2, X+3):
    n = int(x * 1.08)
    if n == N:
        print(n)
print(':(')
Problem p02612 (python)

Fixed submission:
n = int(input())
while n>1000:
  n -= 1000
print(1000-n)

Buggy submission (verdict: Runtime Error):
#ABC173 A
n = input()
s = int(n[-3])*100
if s == 0:
  print(0)
else:
  print(1000-s)
Problem p02630 (python)

Fixed submission:
n= int(input())
a = list(map(int, input().split()))
q = int(input())
b = [list(map(int,input().split())) for i in range(q)]
num = [0]*(10**5+1)
for i in a:
  num[i] += 1
sum_a = sum(a)

for i in range(q):
  dif = b[i][1]-b[i][0]
  #print(dif)
  sum_a += dif*num[b[i][0]]
  num[b[i][1]] += num[b[i][0]]
  num[b[i][0]] = 0
  print(sum_a)

Buggy submission (verdict: Runtime Error):
2
1 2
3
1 100
2 100
100 1000
Problem p02660 (python)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
A  = factorization(N) 

count = 0
for i in A:
  judge = 1
  temp = i[1]
  while temp >= judge:
    count += 1
    temp -=judge
    judge += 1

if N == 1:
  count = 0

print(count)

Buggy submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A  = factorization(N) 

count = 0
for i in A:
  judge = 1
  temp = i[1]
  while temp >= judge:
    count += 1
    temp -=judge
    judge += 1

if N == 1:
  count = 0

print(count)
Problem p02909 (python)

Fixed submission:
w = ['Sunny', 'Cloudy', 'Rainy']
s = input()
i = w.index(s) +1
if i==3:
  i=0
print(w[i])

Buggy submission (verdict: Runtime Error):
w = ['Sunny', 'Cloudy', 'Rainy']
s = input()
i = w.index(s) +1
if i==3:
  i=0
print(w(i))

Buggy submission (verdict: Runtime Error):
w = ['Sunny', 'Cloudy', 'Rainy']
s = input()
i = w.index(s) +1
if i==3:
  i=0
print(weather(i))
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
c = 0
for i in range(0,3):
  if S[i:i+1] == T[i:i+1]:
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
c = 0

for i in range(0,3):
  if S[i:i+1] == T[i:i+1]:
    c += 1
  
print(c)
Problem p02573 (python)

Fixed submission:
import sys
import math
from collections import deque
n,m = map(int, input().split())

q = [0]*(n+1)

graph = [[] for _ in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

if m == 0:
    print(1)
    exit()

d = deque()
a = 0
for l,j in enumerate(q):
    b = set()
    if j == 0:
        d.append(l)
        while d:
            v = d.popleft()
            b.add(v)
            q[v] = -1

            for i in graph[v]:
                b.add(i)
                q[i] = -1

                if dist[i] != -1:
                    continue
                dist[i] = dist[v] + 1
                d.append(i)
        a = max(a,len(b))
print(a)

Buggy submission (verdict: Runtime Error):
import sys
import math
from collections import deque
n,m = map(int, input().split())

q = [0]*(n+1)

graph = [[] for _ in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

if m == 0:
    print(0)
    exit()

d = deque()
a = 0
for l,j in enumerate(q):
    b = set()
    if j == 0:
        d.append(l)
        while d:
            v = d.popleft()
            b.add(v)
            q[i] = -1

            for i in graph[v]:
                b.add(i)
                q[i] = -1
                
                if dist[i] != -1:
                    continue
                dist[i] = dist[v] + 1
                d.append(i)
        a = max(a,len(b))
print(a)
Problem p02602 (python)

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

B = 0
s = 1
for i, a in enumerate(A):
    if i >= K:
        B = A[i-K]
        s = a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
s = 1
for i, a in enumerate(A):
    if i < K:
        s *= a
        B = s
    elif:
        s /= A[i-K]
        s *= a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')
        B = s
Problem p02603 (python)

Fixed submission:

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


dp = [0] * 100
dp[0] = 1000
for i in range(1,N):
    dp[i] = dp[i-1]
    for j in range(0,i):
        V = int(dp[j] / A[j])
        W = dp[j] + (A[i] - A[j]) * V
        dp[i] = max(dp[i], W)
print(dp[N-1])

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


dp = [0] * 10
dp[0] = 1000
for i in range(1,N):
    dp[i] = dp[i-1]
    for j in range(0,i):
        V = int(dp[j] / A[j])
        W = dp[j] + (A[i] - A[j]) * V
        dp[i] = max(dp[i], W)
print(dp[N-1])
Problem p02645 (python)

Fixed submission:
import sys
import numpy as np
 

 
N =  input()
print(N[0:3])

Buggy submission (verdict: Runtime Error):


A, V = map(int,input().split())
B, W = map(int,input().split())

a = A
b = B

T = int(input())
a += V * T
b += W * T

if a < b:
    print('NO')
else:
    print('YES')
Problem p02675 (python)

Fixed submission:
N = str(input())
N = int(N[-1])
if N in [2,4,5,7,9]:
    print('hon')
elif N in [0,1,6,8]:
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
N = int(input())
S = str(input())
if N < len(S):
    S = S[:N]+'...'
print(S)
Problem p02687 (python)

Fixed submission:
S = input()

if S == "ABC":
    print("ARC")
if S == "ARC":
    print("ABC")

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

if S = "ABC":
    print("ARC")
if S = "ARC":
    print("ABC")

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

if S = "ABC":
    print("ARC")
elif S = "ARC":
    print("ABC")
Problem p02705 (python)

Fixed submission:
import math
R = input()
print(2*int(R)*math.pi)

Buggy submission (verdict: Runtime Error):
N,M = input().split()
A = list(map(int, input().split()))
if int(N) - sum(A) < 0:
    print(-1)
else:
    print(int(N)-sum(A))

Buggy submission (verdict: Runtime Error):
N,M = input().split()
A = list(map(int, input().split()))
if int(N) - sum(A) < 0:
    print(-1)
else:
    print(int(N)-sum(A))
Problem p02717 (python)

Fixed submission:
A, B, C = map(int, input().split())
x = A
A = B
B = x
x = A
A = C
C = x

print(' '.join(map(str, [A,B,C])))

Buggy submission (verdict: Runtime Error):
A = int(input("X=?"))
B = int(input("Y=?"))
C = int(input("Z=?"))
x = A
A = B
B = x
x = A
A = C
C = x

print(' '.join(map(str, [A,B,C])))

Buggy submission (verdict: Runtime Error):
A = input("X=?")
B = input("Y=?")
C = input("Z=?")
x = A
A = B
B = x
x = A
A = C
C = x
print(str(A)+" "+str(B)+" "+str(C))

Buggy submission (verdict: Runtime Error):
A = input("X=?")
B = input("Y=?")
C = input("Z=?")
x = A
A = B
B = x
x = A
A = C
C = x
print(str(A)+" "+str(B)+" "+str(C))

Buggy submission (verdict: Runtime Error):
A = input("X=?")
B = input("Y=?")
C = input("Z=?")
x = A
A = B
B = x
x = A
A = C
C = x
print(%d %d %d %(A,B,C))
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split(" "))
A = [i for i in map(int, input().split(" "))]

hist = [-1 for i in range(N)]
route = []
loop = []

jump = 0
cur = A[0] - 1
route.append(0)
hist[0] = jump
while hist[cur] == -1:
    jump = jump + 1
    route.append(cur)
    hist[cur] = jump
    cur = A[cur] - 1

loop = route[hist[cur]:]

#print(cur, hist, route, loop)

if K < len(route):
    print(route[K] + 1)
else:
    K = K - len(route)
    #print(K)
    K = K % len(loop)
    #print(K)
    print(loop[K] + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split(" "))
A = [i for i in map(int, input().split(" "))]

hist = [0 for i in range(N)]
route = []
loop = []

jump = 1
cur = A[0] - 1
route.append(0)
hist[0] = jump
while hist[cur] == 0:
    jump = jump + 1
    route.append(cur)
    hist[cur] = jump
    cur = A[cur] - 1

loop = route[cur:]

if K < len(route):
    print(route[K] + 1)
else:
    K = K - len(route) - 1
    K = K % len(loop)
    print(loop[K] + 1)
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
sc=sorted([list(map(int,input().split())) for i in range(m)])
ans=[0 for i in range(n)]
res=True
for i in range(m):
    if (i>0 and sc[i][0]==sc[i-1][0] and sc[i][1]!=sc[i-1][1]) or (n>1 and sc[i][0]==1 and sc[i][1]==0):
        res=False
        break
    else:
        ans[sc[i][0]-1]=sc[i][1]

if n>1 and ans[0]==0:
    ans[0]=1

ans2=int("".join([str(i) for i in ans])) if res else -1
print(ans2)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
sc=sorted([list(map(int,input().split())) for i in range(m)])
ans=[0 for i in range(n)]
res=True
ans[sc[0][0]-1]=sc[0][1]
for i in range(1,m):
    if sc[i][0]==sc[i-1][0] and sc[i][1]!=sc[i-1][1]:
        res=False
        break
    else:
        ans[sc[i][0]-1]=sc[i][1]

ans2=int("".join([str(i) for i in ans])) if res and not (n>1 and ans[0]==0) else -1
print(ans2)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
sc=sorted([list(map(int,input().split())) for i in range(m)])
ans=[0,0,0]
res=True
ans[sc[0][0]-1]=sc[0][1]
for i in range(1,m):
    if sc[i][0]==sc[i-1][0] and sc[i][1]!=sc[i-1][1]:
        res=False
        break
    else:
        ans[sc[i][0]-1]=sc[i][1]

ans2=int("".join([str(i) for i in ans])) if res and not (n>1 and ans[0]==0) else -1
print(ans2)
Problem p03308 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A.sort()
print(A[-1]-A[0])

Buggy submission (verdict: Runtime Error):
N=int(input)
A=list(map(int,input().split()))
A.sort()
print(A[-1]-A[0])
Problem p03599 (python)

Fixed submission:
A,B,C,D,E,F=map(int,input().split())
weight=100*A
suger=0
c=0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range((i*A+j*B)*E//C+1):
            for l in range((i*A+j*B)*E//D+1):
                if 100*(i*A+j*B)+k*C+l*D<=F and k*C+l*D<=(i*A+j*B)*E and (i*i+j*j+k*k+l*l)!=0 and (k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)>c:
                    c=(k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)
                    weight=100*(i*A+j*B)+k*C+l*D
                    suger=k*C+l*D


print("{} {}".format(weight,suger))

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F=map(int,input().split())
water=[]
suger=[]
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        if 0<100*(i*A+j*B)<=F:
            water.append(100*(i*A+j*B))
        if 100*(i*A+j*B)>F:
            break

for i in range((F*E/(100+E))//C+1):
    for j in range((F*E/(100+E))//D+1):
        if 0<=i*C+j*D<=F*E/(100+E):
            suger.append(i*C+j*D)
        if i*C+j*D>F*E/(100+E):
            break


c=0
w=0
s=0
for i in range(len(water)):
    for j in range(len(suger)):
        if water[i]+suger[j]<=F and water[i]*E/100>=suger[j] and suger[j]/(water[i]+suger[j])>c:
            c=suger[j]/(water[i]+suger[j])
            w=water[i]
            s=suger[j]

print(w+s,s)

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F=map(int,input().split())
weight=0
suger=0
c=0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range(i*A+j*B)*E//C+1):
            for l in range((i*A+j*B)*E//D+1):
                if 100*(i*A+j*B)+k*C+l*D<=F and k*C+l*D<=(i*A+j*B)*E and (i*i+j*j+k*k+l*l)!=0 and (k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)>c:
                    c=(k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)
                    weight=100*(i*A+j*B)+k*C+l*D
                    suger=k*C+l*D


print("{} {}".format(weight,suger))
Problem p03624 (python)

Fixed submission:
S=input()
x="None"
T="abcdefghijklmnopqrstuvwxyz"
num=[0 for i in range(26)]
for i in range(26):
    num[i]+=S.count(T[i])

for j in range(26):
    if num[j]==0:
        x=T[j]
        break

print(x)

Buggy submission (verdict: Runtime Error):
S=input()
x="None"
num=[False for i in range(26)]
for i in range(len(S)):
    num[ord(S[i])-ord("a")]=True

for j in range(26):
    if !num[j]:
        x=chr(j+ord("a"))
        break

print(x)
Problem p03711 (python)

Fixed submission:
x,y=map(int,input().split())
if x==y==2:
    print("Yes")
elif x==4:
    if y==6 or y==9 or y==11:
        print("Yes")
    else:
        print("No")
elif x==6:
    if y==4 or y==9 or y==11:
        print("Yes")
    else:
        print("No")
elif x==9:
    if y==6 or y==4 or y==11:
        print("Yes")
    else:
        print("No")
elif x==11:
    if y==6 or y==9 or y==4:
        print("Yes")
    else:
        print("No")


else:
    if y!=2 and y!=4 and y!=6 and y!=9 and y!=11:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
a=[0,1,3,1,2,1,2,1,1,2,1,2,1
if a[x]==a[y]:
    print("Yes")
else:
    print("No")
Problem p03962 (python)

Fixed submission:
abc=sorted(list(map(int,input().split())))
if abc[0]==abc[2]:
    print(1)
elif abc[0]==abc[1] or abc[1]==abc[2]:
    print(2)
else:
    print(3)

Buggy submission (verdict: Runtime Error):
abc=sorted(list(map(int,input().split())))
if a==c:
    print(1)
elif a==b or b==c:
    print(2)
else:
    print(3)
Problem p02582 (python)

Fixed submission:
s = input()
count = 0
if 'RRR' in s:
  print(3)
elif 'RR' in s:
  print(2)
elif 'SSR' in s or 'SRS' in s or 'RSS' in s or 'RSR' in s:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
s = input()
count = 0
if 'RRR' in s:
  print(3)
elif 'RR' in s:
  print(2)
elif 'SSR' in s or 'SRS' in s or 'RSS' in sor 'RSR' in s:
  print(1)
else:
  print(0)
Problem p02584 (python)

Fixed submission:
x, k, d = map(int, input().split())

x = abs(x)
straight = min(k, x//d)
k -= straight
x -= straight*d

if k%2 == 0:
  print(x)
else:
  print(d-x)

Buggy submission (verdict: Runtime Error):
x, k, d = map(int ,input().split())
ans_min = x

def dfs(i, ans):
  global ans_min
  if abs(ans_min) > abs(ans) and ans >= 1:
    ans_min = ans
  if i == k:
    return abs(ans_min)
  dfs(i + 1, ans + d)
  dfs(i + 1, ans - d)

dfs(0, x)
print(ans_min)

Buggy submission (verdict: Runtime Error):
x, k, d = map(int ,input().split())
ans_min = x

def dfs(i, ans):
  global ans_min
  if abs(ans_min) > abs(ans) and ans != 0:
    ans_min = ans
  if i == k:
    return abs(ans_min)
  dfs(i + 1, ans + d)
  dfs(i + 1, ans - d)

dfs(0, x)
print(ans_min)

Buggy submission (verdict: Runtime Error):
x, k, d = map(int ,input().split())
ans_min = x

def dfs(i, ans):
  global ans_min
  if abs(ans_min) > abs(ans):
    ans_min = ans
  if i == k:
    return abs(ans_min)
  dfs(i + 1, ans + d)
  dfs(i + 1, ans - d)

dfs(0, x)
print(ans_min)
Problem p02621 (python)

Fixed submission:
a = int(input())
print(int(a + a**2 + a**3))

Buggy submission (verdict: Runtime Error):
a = input()
print(a + a**2 + a**3)
Problem p02718 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
select = 0
a.sort(reverse=True)
for i in range(m):
    if a[i]/sum(a) >= 1/(4*m):
        select = 1
    else:
        select = 0

if select == 1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
select = 0
a.sort(reverse=True)
for i in range(m+1):
    if a[i]/sum(a) > 1/(4*m):
        select = 1
    else:
        select = 0

if select == 1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
select = 0
a.sort(reverse=True)
for i in range(m+1):
    if a[i]/sum(a) > 1/(4*m):
        select = 1
    else:
        select = 0

if select == 1:
    print('Yes')
else:
    print('No')
Problem p02772 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 1

for _ in  A:
    if _ % 2 == 0:
        if _ % 3 == 0 or _ % 5 == 0:
            ans *= 1
        else:
            ans *= 0

if ans == 1:
    print('APPROVED')
else:
    print('DENIED')

Buggy submission (verdict: Runtime Error):
for _ in  A:
    if _ % 2 == 0:
        if _ % 3 == 0 or _ % 5 == 0:
            ans *= 1
        else:
            ans *= 0

if ans == 1:
    print('APPROVED')
else:
    print('DENIED')
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
P = [0]*n
AC = [False]*n
correct = 0
penalty = 0
for i in range(m):
  ans = input().split()
  problem = int(ans[0])
  result = ans[1]
  if AC[problem-1] == False:
    if result == 'AC':
      AC[problem-1] = True
      correct += 1
      penalty += P[problem-1]
    else:
      P[problem-1] += 1
print(correct, penalty)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
cnt = 0
ans = [0]*n
num = 0
for i in range(0, m):
  num = int(l[i][0])
  if l[i][1] == 'AC':
    ans[num] = 1
  elif ans[num] != 1:    
    cnt += 1
print(sum(ans), cnt)
Problem p02641 (python)

Fixed submission:
X,N,*P = map(int,open(0).read().split())
if P != []:
  P = sorted(list(P),reverse=True)
else:
  print(X)
  exit()

min_diff = 101
min_val = 101

for i in range(101,-1,-1):
  #print(i,min_val,min_val)
  if not i in P:
    if abs(X-i) <= min_diff and min_val >=i:
      min_diff = abs(X-i)
      min_val = i
  ans = min_val
print(ans)

Buggy submission (verdict: Runtime Error):
X,N,*P = map(int,open(0).read().split())
if P != []:
  P = sorted(list(map(int,P.split())),reverse=True)
else:
  print(X)
  exit()

min_diff = 101
min_val = 101

if N == 100:
  if X <=50:
    ans = 0
  else:
    ans = 101
else:
  for i in range(100,-1,-1):
    #print(i,min_val,min_val)
    if not i in P:
      if abs(X-i) <= min_diff and min_val >i:
      	min_diff = abs(X-i)
      	min_val = i
  ans = min_val
print(ans)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
A,B =map(int,input.split())
print(A*B)
Problem p02678 (python)

Fixed submission:
N,M = map(int,input().split()) #n:頂点数　w:辺の数


way = [[] for i in range(N)]
depth = [float("inf") for i in range(N)]
visited = [False for i in range(N)]
que=[0]

for i in range(M):
    x,y = map(int,input().split())
    way[x-1].append(y-1)
    way[y-1].append(x-1)

for i in que:
  for j in way[i]:
    if visited[j]:
      continue
    que.append(j)
    visited[j]=True
    depth[j] = min(i+1,depth[j])
print("Yes")
for i in range(1,N):
  print(depth[i])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split()) #n:頂点数　w:辺の数


way = [[] for i in range(M)]
depth = [float("inf") for i in range(N)]
visited = [False for i in range(N)]
que=[0]

for i in range(M):
    x,y = map(int,input().split())
    way[x-1].append(y-1)
    way[y-1].append(x-1)

for i in que:
  for j in way[i]:
    if visited[j]:
      continue
    que.append(j)
    visited[j]=True
    depth[j] = min(i+1,depth[j])
print("Yes")
for i in range(1,N):
  print(depth[i])