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

Fixed submission:
def collaz(n):
    if n%2 == 0:
        return n//2
    else:
        return int(3*n+1)

s = int(input())

box = [-1]*(int(1e6+1))

box[s] = 1

i = 1

while 1:
    if box[collaz(s)] == 1:
        print(i+1)
        break
    else:
        box[collaz(s)] = 1
        s = collaz(s)
        i += 1

Buggy submission (verdict: Runtime Error):
def collaz(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1

s = int(input())

box = [-1]*(int(1e10))

i = 1

while 1:
    if box[collaz(s)] == 1:
        print(i+1)
        break
    else:
        box[collaz(s)] = 1
        s = collaz(s)
        i += 1
Problem p03214 (python)

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

b = []
s = (sum(a)/len(a))
for i in range(len(a)):
    b.append(abs(a[i]-s))

print(b.index(min(b)))

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

b = []
s = int(sum(a)/len(a))
for i in range(len(a)):
    b.append(abs(a[i]-s)

print(b.index(min(b)))
Problem p03241 (python)

Fixed submission:
import numpy as np

def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))+1):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort(reverse=True)
    return a

N,M = map(int,input().split())
f = factorization(M)
for i in f:
    if i <= M/N:
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):
import numpy as np

def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort()
    return a

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

f = factorization(M)
f = np.array(f)
print(np.max(f[f<=M/N]))
Problem p03244 (python)

Fixed submission:
from collections import Counter

def main():
    
    N = int(input())
    V = list(map(int,input().split()))
    odd = V[1::2]
    even = V[0::2]
    mode_o = Counter(odd).most_common()
    mode_o.append([0,0])
    mode_e = Counter(even).most_common()
    mode_e.append([0,0])
    ans = 0
    if mode_o[0][0] != mode_e[0][0]:
        ans = N-mode_o[0][1]-mode_e[0][1]
    else:
        ans = N - max(mode_e[0][1]+mode_o[1][1],mode_e[1][1]+mode_o[0][1])
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from copy import deepcopy
n = int(input())
v = list(map(int,input().split()))

odd = []
even = []

if len(set(v)) == 1:
    print(n//2)
    exit()

for i in range(n):
    if i%2 == 0:
        even.append(v[i])
    else:
        odd.append(v[i])

box_e = [0]*int(1e5+1)
box_o = [0]*int(1e5+1)
e = {}
o = {}
for i in range(n//2):
    if even[i] in e:
        e[even[i]] += 1
    else:
        e[even[i]] = 1
    if odd[i] in o:
        o[odd[i]] += 1
    else:
        o[odd[i]] = 1
values_e = list(e.values())
keys_e = list(e.keys())
values_o = list(o.values())
keys_o = list(o.keys())
Oddlist = []
Evenlist = []
for i in range(len(keys_e)):
    Evenlist.append([values_e[i],keys_e[i]])
for j in range(len(keys_o)):
    Oddlist.append([values_o[i],keys_o[i]])
Evenlist.sort()
Oddlist.sort()
mode_even = Evenlist[-1]
mode_even_2 = 0
if len(keys_e) >= 2:
    mode_even_2 = Evenlist[-2]
mode_odd = Oddlist[-1]
mode_odd_2 = 0
if len(keys_o) >= 2:
    mode_even_2 = Oddlist[-2]

ans = 0

if mode_even[1] != mode_odd[1]:
    ##print("hoge")
    for i in range(n//2):
        if odd[i] != mode_odd[1]:
            ans += 1
        if even[i] != mode_even[1]:
            ans += 1
else:
    if mode_even[0] > mode_odd[0]:
        for i in range(n//2):
            if odd[i] != mode_odd[1]:
                ans += 1
            if even[i] != mode_even_2[1]:
                ans += 1
    else:
        for i in range(n//2):
            if odd[i] != mode_odd_2[1]:
                ans += 1
            if even[i] != mode_even[1]:
                ans += 1
print(ans)

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

odd = []
even = []

if len(set(v)) == 1:
    print(n//2)
    exit()

for i in range(n):
    if i%2 == 0:
        even.append(v[i])
    else:
        odd.append(v[i])

box_e = [0]*int(1e5)
box_o = [0]*int(1e5)

for i in range(n//2):
    box_e[even[i]] += 1
    box_o[odd[i]] += 1

mode_e = box_e.index(max(box_e))
mode_o = box_o.index(max(box_o))

ans = 0

for i in range(n//2):
    if odd[i] != mode_o:
        ans += 1
    if even[i] != mode_e:
        ans += 1

print(ans)
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

N,X = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
dist = []

if X == 1:
    print(abs(x[0]-X))
    exit()

tmp = []
for i in range(N):
    tmp.append(abs(x[i]-X))
mindist = min(tmp)
for i in range(N-1):
    dist.append(abs(x[i]-x[i+1]))

ans = mindist

for i in range(N-1):
    ans = gcd(ans,dist[i])

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

N,X = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
dist = []

if X == 1:
    print(abs(x[0]-X))
    exit()
    
for i in range(N-1):
    dist.append(abs(x[i]-x[i+1]))

ans = dist[0]

for i in range(N-1):
    ans = gcd(ans,dist[i])

print(ans)
Problem p03387 (python)

Fixed submission:
A = list(map(int,input().split()))
A.sort()
B = []
for i in A:
    B.append(i%2)

ans = 0

if B.count(1) == 1:
    for i in range(3):
        if B[i] == 0:
            A[i] += 1
    ans += 1
elif B.count(0) == 1:
    for i in range(3):
        if B[i] == 1:
            A[i] += 1
    ans += 1

ans += A[2] - A[1]
A[0] += A[2] - A[1]
ans += (A[2]-A[0])//2

print(ans)

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

p = [i%2 for i in N]

ans = 0

if sum(p) == 0 or sum(p) == 3:
    m = max(N)
    for i in N:
        ans += (m-i)//2
elif sum(p) == 1:
    for i in range(3):
        if N[i]%2 == 0:
            N[i] += 1
    ans += 1
    m = max(N)
    for i in N:
        ans += (m-i)//2
else:
    for i in range(3):
        if N[i]%2 == 1:
            N[i] += 1
    ans += 1
    for i in N:
        ans += (m-i)//2

print(ans)
Problem p03409 (python)

Fixed submission:
##実装のバグがとれぬ　答えを見る

N = int(input())
ab = []
cd = []
for i in range(N):
    a,b = map(int,input().split())
    ab.append([b,a,i])
for i in range(N):
    c,d = map(int,input().split())
    cd.append([c,d,i])

ab.sort()
cd.sort()

ans = 0
flag_ab = [1]*N
for i in range(N):
    pos = -1
    for j in range(N):
        if ab[j][0] < cd[i][1] and ab[j][1] < cd[i][0] and flag_ab[j]:
            pos = max(pos,j)
    if pos != -1:
        flag_ab[pos] = 0
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ab = []
cd = []
for i in range(N):
    a,b = map(int,input().split())
    ab.append([0,a,b])
for i in range(N):
    c,d = map(int,input().split())
    cd.append([0,c,d])

cover = []
for i in range(N):
    cnt = 0
    cov = []
    for j in range(N):
        if ab[j][1] < cd[i][1] and ab[j][2] < cd[i][2]:
            cnt += 1
            cov.append(j)
    cd[i][0] = cnt
    cover.append(cov)

cover.sort()
cd.sort()
cd_dist = []
for i in range(N):
    dist = []
    if cd[i][0] != 0:
        for j in cover[i]:
            d = (ab[j][1]-cd[i][1])**2+(ab[j][2]-cd[i][2])**2
            dist.append([d,j])
        dist.sort()
        cd_dist.append(dist)
    else:
        cd_dist.append([])

flag = [1]*N
ans = 0
for i in range(N):
    for j in range(cd[i][0]):
        if flag[cd_dist[i][j][1]]:
            ans += 1
            flag[cd_dist[i][j][1]] = 0
            break

print(ans)
Problem p03493 (python)

Fixed submission:
a = input()
print(a.count("1"))

Buggy submission (verdict: Runtime Error):
import random
input()
print(random.random(0,3))

Buggy submission (verdict: Runtime Error):
import random
print(random.random(0,3))

Buggy submission (verdict: Runtime Error):
print(input().count(1))
Problem p03496 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
process = []

def cumsum(reverse=False):
    global A,ans,process
    if reverse == False:
        for i in range(len(A)-1):
            A[i+1] += A[i]
            ans += 1
            process.append([i+1,i+2])
    else:
        for i in reversed(range(len(A)-1)):
            A[i-1] += A[i]
            ans += 1
            process.append([i+2,i+1])

def addmax():
    global A,ans,process
    ind = A.index(max(A))
    m = max(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def addmin():
    global A,ans,process
    ind = A.index(min(A))
    m = min(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def main():
    global A,ans,process
    if max(A) <= 0:##すべての要素が0以下の場合
        cumsum(reverse=True)
    elif min(A) >= 0:##すべての要素が0以上の場合
        cumsum()
    else:##正、負が両方ある場合
        if -1*min(A) < max(A):##最大値を足すほうが早い
            addmax()
            cumsum()
        else:##最小値を引くほうが畑井
            addmin()
            cumsum(reverse=True)
    ##出力
    print(ans)
    for i in range(ans):
        print(*process[i])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
ans = 0
process = []

def cumsum(reverse=False):
    global A,ans,process
    if reverse == False:
        for i in range(len(A)-1):
            A[i+1] += A[i]
            ans += 1
            process.append([i+1,i+2])
    else:
        for i in range(reversed(len(A)-1)):
            A[i-1] += A[i]
            ans += 1
            process.append([i,i+1])

def addmax():
    global A,ans,process
    ind = A.index(max(A))
    m = max(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def addmin():
    global A,ans,process
    ind = A.index(min(A))
    m = min(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def main():
    global A,ans,process
    if max(A) <= 0:##すべての要素が0以下の場合
        cumsum(reverse=True)
    elif min(A) >= 0:##すべての要素が0以上の場合
        cumsum()
    else:##正、負が両方ある場合
        if -1*min(A) < max(A):##最大値を足すほうが早い
            addmax()
            cumsum()
        else:##最小値を引くほうが畑井
            addmin()
            cumsum()
    ##出力
    print(ans)
    for i in range(ans):
        print(*process[i])

if __name__ == "__main__":
    main()
Problem p03573 (python)

Fixed submission:
from collections import Counter
a = Counter(list(map(int,input().split()))).most_common()
print(a[1][0])

Buggy submission (verdict: Runtime Error):
from copy import deepcopy

def warshallfloyd(cost,V):
    INF = float("inf")
    for k in range(V):
        for i in range(V):
            for j in range(V):
                if cost[i][k]!=INF and cost[k][j]!=INF:
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

    for i in cost:
        if float("inf") in i:
            return False
    
    return True

N,M = map(int,input().split())
edge = [[float("inf") for i in range(N)] for j in range(N)]

for _ in range(M):
    a,b = map(int,input().split())
    edge[a-1][b-1] = 1
    edge[b-1][a-1] = 1

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        if edge[i][j]:
            tmp = deepcopy(edge)
            tmp[i][j] = float("inf")
            tmp[j][i] = float("inf")
            if not warshallfloyd(tmp,N):
                ans += 1

print(ans)
Problem p03597 (python)

Fixed submission:
N = int(input())
A = int(input())
print(N**2-A)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(N**2-int(input())
Problem p03605 (python)

Fixed submission:
N = input()
if "9" in N:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
##from scipy.sparse.csgraph import csgraph_from_dense,floyd_warshall
import numpy as np
from itertools import permutations
N,M,R = map(int,input().split())
r = list(map(int,input().split()))

"""
https://juppy.hatenablog.com/entry/2018/11/01/%E8%9F%BB%E6%9C%AC_python_%E5%85%A8%E7%82%B9%E5%AF%BE%E6%9C%80%E7%9F%AD%E7%B5%8C%E8%B7%AF%E6%B3%95%EF%BC%88%E3%83%AF%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%83%95%E3%83%AD%E3%82%A4%E3%83%89%E6%B3%95
"""

def warshall_floyd(d):
    n = len(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

graph = [[float("inf") for i in range(N)] for j in range(N)] 
for i in range(M):
    A,B,C = map(int,input().split())
    graph[A-1][B-1] = C
    graph[B-1][A-1] = C

dist = warshall_floyd(graph)

ans = 1e10
for i in permutations(r):
    flag = True
    way = list(i)
    tmp = 0
    for i in range(len(way)-1):
        if dist[way[i]-1][way[i+1]-1] < 0:
            flag = False
            break
        tmp += dist[way[i]-1][way[i+1]-1]
    if flag:
        ans = min(tmp,ans)

print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
if "9" in N:
  print("Yes")
else:
  print("No)
Problem p03611 (python)

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

num = [0]*(max(A)+2)

for i in A:
    num[i] += 1
m = max(A)
ans = 0
for i in range(0,max(A)+2):
    if i == 0:
        tmp = num[i] + num[i+1]
    elif i == m+1:
        tmp = num[i-1] + num[i]
    else:
        tmp = num[i-1] + num[i] + num[i+1]
    ans = max(ans,tmp)

print(ans)

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

num = [0]*(max(A)+1)

for i in A:
    num[i] += 1

ans = 0
for i in range(0,max(A)+1):
    if i == 0:
        tmp = num[i] + num[i+1]
    elif i == max(A):
        tmp = num[i-1] + num[i]
    else:
        tmp = num[i-1] + num[i] + num[i+1]
    ans = max(ans,tmp)

print(ans)
Problem p03612 (python)

Fixed submission:
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
    if p[i] == i+1:
        try:
            p[i+1],p[i] = p[i],p[i+1]
        except:
            pass
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
    if p[i] == i+1:
        p[i],p[i+1] = p[i+1],p[i]
        ans += 1
print(ans)
Problem p03700 (python)

Fixed submission:
import sys
from math import ceil

def input():
    return sys.stdin.readline().strip()

def check(k):
    tmp = list(h)
    for i in range(N):
        tmp[i] -= B*k
    if sum([int(i<=0) for i in tmp]) == N:
        return True

    lf = 0
    for i in tmp:
        if i > 0:
            lf += ceil(i/(A-B))

    if lf <= k:
        return True
    else:
        return False

N,A,B = map(int,input().split())
h = tuple(int(input()) for _ in range(N))

left = -1
right = 1e9

while abs(left-right) > 1:

    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid

print(int(right))

Buggy submission (verdict: Runtime Error):
from numpy import ceil,array,sum

def is_ok(m):

    tmp = h - m*B

    if not any(tmp):
        return True

    rem = [ceil(i/(A-B)) for i in tmp[tmp>0]]
    
    if rem > m:
        return False

    return True

N,A,B = map(int,input().split())
h = array(list(int(input()) for _ in range(N)))
s = sum(h)
##二分散策

r = 10**9
l = 0

while abs(l-r) > 1:

    m = (r+l)//2

    if is_ok(m):
        r = m
    else:
        l = m

print(r)

Buggy submission (verdict: Runtime Error):
import numpy as np

def is_ok(m):
    tmp = h - B*m

    if not any(tmp):
        return False
    
    rem = sum([np.ceil(i/(A-B)) for i in tmp])

    if rem > m:
        return False

    return True

N,A,B = map(int,input().split())
h = np.array(list(int(input()) for _ in range(N)))
s = np.sum(h)
##二分散策

r = 10**10
l = 0

while abs(l-r) > 1:

    m = (r+l)//2

    if is_ok(m):
        r = m
    else:
        l = m

print(r)
Problem p03713 (python)

Fixed submission:
H,W = map(int,input().split())

ans = 1e19
##縦方向の探索
for i in range(1,H):
    tate = W*i##上から横に切る
    ##横に切る
    if i < H-1:
        mini = W*((H-i)//2)##分割したやつ
        ##print(tate,mini,H*W-mini-tate)
        ans = min(ans,max(tate,mini,H*W-mini-tate)-min(tate,mini,H*W-mini-tate))

    ##縦に切る
    mini = (H-i)*(W//2)
    ##print(tate,mini,H*W-mini-tate)
    ans = min(ans,max(tate,mini,H*W-tate-mini)-min(tate,mini,H*W-tate-mini))

##横方向の探索
for i in range(1,W):
    yoko = H*i
    if i < W-1:
        mini = H*((W-i)//2)
        ##print(yoko,mini,H*W-mini-yoko)
        ans = min(ans,max(yoko,mini,H*W-mini-yoko)-min(yoko,mini,H*W-yoko-mini))
    mini = (W-i)*(H//2)
    ##print(yoko,mini,H*W-yoko-mini)
    ans = min(ans,max(yoko,mini,H*W-yoko-mini)-min(yoko,mini,H*W-yoko-mini))

print(ans)

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

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

##縦方向の探索

ans = 1e10

for i in range(1,H-1):
    tate = W*i##上から切る
    mini = (H-i)*(W//2)##半分に分割したちっこいほう

    ans = min(ans,max(tate,mini,H*W-tate-mini)-min(tate,mini,H*W-tate-mini))

##横方向の探索
for i in range(1,W-1):
    yoko = H*i
    mini = (W-i)*(W//2)
    ans = min(ans,max(yoko,mini,H*W-tate-mini)-min(yoko,mini,H*W-tate-mini))

print(ans)
Problem p03738 (python)

Fixed submission:
A = int(input())
B = int(input())

if A == B:
    print("EQUAL")
elif A < B:
    print("LESS")
else:
    print("GREATER")

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

if A == B:
    print("EQUAL")
elif A < B:
    print("LESS")
else:
    print("GREATER")
Problem p03828 (python)

Fixed submission:
from collections import defaultdict

def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

N = int(input())

if N <= 2:
    print(N)
    exit()
else:
    num = defaultdict(int)
    for i in range(2,N+1):
        for n,m in prime_factorize(i):
            num[n] += m


ans = 1
mod = int(1e9+7)
for i in num.values():
    ans = ((i+1)*ans)%mod

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

N = int(input())

if N <= 2:
    print(N)
else:
    num = defaultdict(int)
    for i in range(2,N+1):
        for n,m in prime_factorize(i):
            num[n] += m


ans = 1
mod = int(1e9+7)
for i in num.values():
    ans = ((i+1)*ans)%mod

print(ans)
Problem p03997 (python)

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

print((a+b)*c//2)

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

print((a+b)*h//2)

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

print((a+b)*h//2)
Problem p04000 (python)

Fixed submission:
"""
参考(神様)
https://atcoder.jp/contests/abc045/submissions/6046010
"""

###かぶるやつを考える.例えばあるマスのかぶり値が9だとしたら,
###周囲はすべて黒->j=9のが1つとカウントしてよい,他の値についても同様.

import sys
from collections import defaultdict,Counter

def input():
    return sys.stdin.readline().strip()

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

covered = defaultdict(int)
vector = [(0,0),(0,1),(0,-1),(1,0),(-1,0),(1,1),(-1,-1),(1,-1),(-1,1)]

for _ in range(N):
    a,b = map(int,input().split())

    for i,j in vector:
        x = a+i-1
        y = b+j-1

        if 0 < x < H-1 and 0 < y < W-1:
            covered[(x,y)] += 1

num = Counter(covered.values())
##print(num)
num[0] = (H-2)*(W-2)-sum(num.values())

for i in range(10):
    print(num[i])

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict

def input():
    return sys.stdin.readline().strip()

def recordnum(a,b):
    if not (0 < a < H-1 and 0 < b < W-1):
        return 
    else:
        res = M[(a,b)]
        for i,j in vector:
            res += M[(a+i,b+j)]
        num[res] += 1
        return


def dfs(a,b,color):

    if visited[(a,b)]:
        return
    
    recordnum(a,b)
    visited[(a,b)] = True

    if color == "b":
        for i,j in vector:
            x = a+i
            y = b+j
            if 0 < x < H-1 and 0 < y < W-1:
                if M[(x,y)]:
                    dfs(x,y,"b")
                else:
                    dfs(x,y,"w")
    else:
        ##白い箇所から白い箇所への探索はしない
        for i,j in vector:
            x = a+i
            y = b+j
            if 0 < x < H-1 and 0 < y < W-1 and M[(x,y)]:
                dfs(a,b,"b")

    


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

M = defaultdict(int)
visited = defaultdict(int)
ab = []

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


vector = [[0,1],[0,-1],[1,0],[-1,0],[1,1],[-1,-1],[1,-1],[-1,1]]
num = [0]*10

for a,b in ab:
    dfs(a,b,"b")

num[0] = (H-2)*(W-2) - sum(num)

for i in num:
    print(i)
Problem p02601 (python)

Fixed submission:
R,G,B = map(int,input().split())
K = int(input())
ans = 'No'

while (K > 0):
  if R >= G:
    G *= 2
    K -= 1
  elif G >= B:
    B *= 2
    K -= 1
  else:
    K -= 1
      
if R < G < B:
  ans = 'Yes'
  
print(ans)

Buggy submission (verdict: Runtime Error):
R,G,B = map(int,input().split())
K = int(input())
ans = 'No'

while (K > 0):
  if R >= G:
    G *= 2
    K -= 1
  elif G >= B:
    B *= 2
    K -= 1
  else:
    k -= 1
      
if R < G < B:
  ans = 'Yes'
  
print(ans)
Problem p03289 (python)

Fixed submission:
S = list(input())
last = len(S) - 1

S_head = S[0]

S_bothEnd = [S[0],S[1],S[last]]
S_center = list(set(S)-set(S_bothEnd))

S_clone = S
if "A" in S_clone:
  S_clone.remove('A')
if "C" in S_clone:
  S_clone.remove('C')

evalLow = "".join(S_clone)

if S_head == "A" and S_center.count("C")  == 1 and evalLow.islower() == 1:
  print('AC')
else:
  print('WA')

Buggy submission (verdict: Runtime Error):
S = list(input())
last = len(S) - 1

S_head = S[0]

S_clone = S
S_bothEnd = [S[0],S[1],S[last]]
S_center = list(set(S)-set(S_bothEnd))

S_clone.remove('A')
S_clone.remove('C')

evalLow = "".join(S_clone)

if S_head == "A" and S_center.count("C")  == 1 and evalLow.islower() == 1:
  print('AC')
else:
  print('WA')
Problem p02861 (python)

Fixed submission:
import math
import itertools

def distance(p1, p2):
    return math.sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)

n = int(input())
points = {i: list(map(int,  input().split())) for i in range(n)}

total_distance = 0

for cource in itertools.permutations(range(n)):
    for i in range(1, n):
        total_distance += distance(points[cource[i-1]], points[cource[i]])

print(total_distance/math.factorial(n))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import math
import itertools

def distance(p1, p2):
    return math.sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)

n = input()
points = {i:input().split() for i in range(n)}

total_distance = 0

for cource in itertools.permutations(range(n)):
    for i in range(1, n):
        total_distance += distance(cource[i-1], cource[i])

print(total_distance/math.factorial(n))
Problem p02553 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
if a<0 and b<0 and c>=0 and d>=0:
  print(b*c)
elif a<0 and b<0 and c<0 and d>=0:
  print(a*c)
elif a<0 and b>=0 and c<0 and d<0:
  print(a*c)
elif a<0 and b<0 and c<0 and d<0:
  print(a*c)
elif a<0 and b>=0 and c<0 and d>=0 and abs(a*c)>=abs(b*d):
  print(a*c)
elif a>=0 and b>=0 and c<0 and d<0:
  print(a*d)
else:
  print(b*d)

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if a<=0 and b<=0 and c<=0 and d<=0:
  print(a*c)
elif a>=0 and b>=0 and c>=0 and d>=0:
  print(b*d)
elif b>=0 and c<=0 d<=0:
  print(b*c)
else:
  print(a*d)