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

Fixed submission:
antena = [int(input()) for _ in range(5)]
k = int(input())

flg = True
for i in range(len(antena)):
  for j in range(len(antena)):
    if antena[i] - antena[j] > k:
      flg = False
      break
    
if flg:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
antena = [int(input()) for _ in range(5)]
k = int(input())

flg = True
for i in range(len(antena)):
  for j in range(len(antena)):
    if a[i] - a[j] > k:
      flg = False
      break
    
if flg:
  print('Yay!')
else:
  print(':(')
Problem p02881 (python)

Fixed submission:
import numpy as np

N = int(input())

for i in range(1, int(np.sqrt(N)) + 1):
    if N % i == 0:
        ans = (i - 1) + ((N / i) - 1)

print(int(ans))

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

N = int(input())

for i in range(1, int(np.sqrt(N))):
    if N % i == 0:
        ans = (i - 1) + ((N / i) - 1)

print(int(ans))
Problem p02959 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
d = 0
c = A[0]

for i in range(N):
    d += max(0, c - B[i])
    c = max(0, A[i+1] + min(0, c - B[i]))
            
            
print(sum(A) - (d + c))

Buggy submission (verdict: Runtime Error):
N = int(input())
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
c = A[0]
d = 0
for i in range(N):
    d += max(0, c - B[i])
    c = max(0, A[i+1] + min(0, c - B[i]))
    
print(sum(A) - (d + c))
Problem p03012 (python)

Fixed submission:
import numpy as np

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

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)

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

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)

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

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    diff = np.abs(S_1 - S_2)
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)

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

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    diff = np.abs(S_1 - S_2)
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
Problem p03013 (python)

Fixed submission:
N, M=map(int, input().split())
A = [int(input()) for _ in range(M)]
mod = 10**9 + 7
step = [1]*(N+1)

for a in A:
    step[a]=0
for i in range(2, N+1):
    step[i]=(step[i-1]+step[i-2])%mod*step[i]
print(step[-1])

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

N, M = map(int, input().split())
stairs_exist = np.ones(N+1)

for c in range(M):
    stairs_exist[int(input())] = 0
    
steps = np.zeros(N+1)
steps[0] = 1
for i in range(N):
    for j in range(i+1, min(N+1, i+3)):
        if stairs_exist[j]:
            steps[j] += steps[i]
            
print(int(steps[-1] % (10 ** 9 + 7)))

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

N, M = map(int, input().split())
stairs_exist = np.ones(N+1)

for c in range(M):
    stairs_exist[int(input())] = 0
    
steps = np.zeros(N+1)
steps[0] = 1
for i in range(N):
    for j in range(i+1, min(N+1, i+3)):
        if stairs_exist[j]:
            steps[j] += steps[i]
            
print(int(steps[-1]))

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

stairs = []

for i in range(M):
    stairs.append(int(input()))
path = []
index = 1
if stairs[-1] == N-1:
    path.extend([1, 0])
    index += 1
else:
    path.extend([1, 1])
# caluclate from N-2 step (second last)

if N >= 2:
    for n in range(2, N):
        if N - n != stairs[-index]:
#             print(n, N - n, index, stairs[-index])
            path.append(path[n-2] + path[n-1])
        else:
            path.append(0)
            index += 1
    print((path[-1] + path[-2]) % (10**9+7)) 
#     print(path)
elif N < 2:
    print(1)

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

N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

ans = np.zeros(N + 1)
ans[N] = 1
broken_a = np.zeros(N)
for a_ in a:
    broken_a[a_] = 1
if broken_a[N-1] != 1:
    ans[N - 1] = 1


for i in range(2, N + 1):
    if broken_a[N - i] != 1:
        ans[N - i] = (ans[N - i + 1] + ans[N - i + 2])
    else:
        ans[N - i] = 0
print(int(ans[0] % (10 ** 9 + 7)))

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

N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

ans = np.zeros(N + 1)
ans[N] = 1

if N - 1 not in a:
    ans[N - 1] = 1

for i in range(2, N + 1):
    if N - i not in a:
        ans[N - i] = (ans[N - i + 1] + ans[N - i + 2])
    else:
        ans[N - i] = 0
        
print(int(ans[0] % (10 ** 9 + 7)))

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

N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

ans = np.zeros(N + 1)
ans[N] = 1

if N - 1 not in a:
    ans[N - 1] = 1

print(ans[N])

for i in range(2, N + 1):
    if N - i not in a:
        ans[N - i] = (ans[N - i + 1] + ans[N - i + 2])
    else:
        ans[N - i] = 0
        
print(int(ans[0] % (10 ** 9 + 7)))
Problem p03042 (python)

Fixed submission:
X = input()

X1 = 10*int(X[0]) + int(X[1])
X2 = 10*int(X[2]) + int(X[3])
if (1 <= X1 <= 12) and ((X2 > 12) or (X2 == 0)):
    print("MMYY")
elif ((X1 > 12) or (X1 == 0)) and (1 <= X2 <= 12):
    print("YYMM")
elif (1 <= X1 <= 12) and (1 <= X2 <= 12):
    print("AMBIGUOUS")
else:
    print("NA")

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

X1 = 10*int(X[0]) + int(X[1])
X2 = 10*int(X[2]) + int(X[3])

if (1 <= X1 <= 12) and ((X2 > 12) or (X2 == 0)):
    print("MMYY")
elif ((X2 > 12) or (X2 == 0) and (1 <= X1 <= 12):
    print("YYMM")
elif (1 <= X1 <= 12) and (1 <= X2 <= 12):
    print("AMBIGUOUS")
else:
    print("NA")
Problem p03127 (python)

Fixed submission:
import fractions

N = int(input())
A = list(map(int, input().split()))
ans = A[0]
for i in range(1, N):
    ans = fractions.gcd(ans, A[i])
    
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

print(int(reduce(math.gcd, A)))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

print(reduce(math.gcd, A))

Buggy submission (verdict: Runtime Error):
import fractions

N = int(input())
A = list(map(int, input().split()))
ans = A[0]
for i in range(1, N):
    ans = gcd(ans, A[i])
    
print(ans)
Problem p03221 (python)

Fixed submission:
import collections
import bisect

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

ans = collections.defaultdict(list)

for p, y in sorted(P):
    ans[p] += [y]
for p, y in P:
    print("%06d%06d"%(p, bisect.bisect(ans[p], y)))

Buggy submission (verdict: Runtime Error):
import collections
import bisect

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

ans = collections.defaultdict(list)

for p, y in sorted(P):
    ans[p] += [y]
for p, y in P:
    print("%06d%06d"%(p, bisect.bisect(a[p], y)))
Problem p02729 (python)

Fixed submission:
N, M = map(int, raw_input().split())
res = 0
if N >= 2:
    res += N*(N-1)/2
if M >= 2:
    res += M*(M-1)/2

print(res)

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
A = map(int, raw_input().split())
 
count = [0]*(N+2)
for i in range(N):
    id = A[i]
    count[id] = count[id]+1
 
sumN = long(0)
for i in range(N+1):
    sumN = sumN + long(long(count[i]*(count[i]-1))/2)
 
for i in range(N):
    id = A[i]
    sumz = sumN - (count[id] - 1)
    print(sumz)
Problem p02753 (python)

Fixed submission:
S = str(raw_input())
res = (S[0] == S[1] == S[2])
if res:
  print "No"
else:
  print "Yes"

Buggy submission (verdict: Runtime Error):
S = raw_input()
res = (S[0] == S[1] == S[2])
if res:
  print "No"
 else:
  print "Yes"
Problem p02689 (python)

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

edge = [[] for _ in range(n)]

## 接している各頂点をまとめる
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

cnt = 0

for node in range(n):
    good = True 
    for neighbor in edge[node]:
        if h[node] <= h[neighbor]:
            good = False
    
    if good:
        cnt += 1

print(cnt)

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

ab = [list(map(int, input().split())) for i in range(len(h)-1)]

ans = [0]*n

for a, b in ab:
    if h[a-1] > h[b-1]:
        ans[a-1] += 1
    else:
        ans[b-1] += 1

print(ans.count(0))
Problem p02723 (python)

Fixed submission:
# 文字列の読み込み
s = input()
a = list(s)
if a[2] == a[3] and a[4] == a[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
coin = int(input())
siawase = 0
if coin >= 500:
    siawase = siawase + int(coin / 500) * 1000
    amari = coin % 500
    siawase = siawase + int(amari / 5) *5
elif coin >= 5:
    siawase = siawase + int(coin / 5) * 5
    
print(int(siawase))

Buggy submission (verdict: Runtime Error):
coin = int(input())
siawase = 0
if coin >= 500:
    siawase = siawase + int(coin / 500) * 1000
    amari = int(coin % 500)
    siawase = siawase + int(amari / 5) *5
elif coin >= 5:
    siawase = siawase + int(coin / 5) * 5
    
print(int(siawase))

Buggy submission (verdict: Runtime Error):
# 文字列の読み込み
s = input()
a = list(s)
    if a[2] == a[3] and a[4] == a[5]:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
# 文字列の読み込み
s = input()
a = list(s)
if a[2] == a[3] || a[4] == a[5]:
    print('Yes')
else:
    print('No')
Problem p02711 (python)

Fixed submission:
n = input()
judge = False
for i in range(len(n)):
    if n[i] == "7":
        judge = True
        break
if judge == True:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
judge = False
for i in range(len(n)):
  if n[i] == 7:
    judge = True
    break
if judge == True:
  return "Yes"
else:
  return "No"
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
if S <= W:
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
S, W = map(int, input().split())
if S =< W:
  print("unsafe")
else:
  print("safe")
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
bonus = 0

for i in range(N-1):
  if A[i+1]==A[i]+1:
    bonus+=C[A[i]-1]

print(sum(B)+bonus)

Buggy submission (verdict: Runtime Error):
N = inT(input())
A = list(map(int, input()))
B = list(map(int, input()))
C = list(map(int, input()))

print(sum(B))
print(C)
Problem p02723 (python)

Fixed submission:
s=input()
print("Yes" if s[2]==s[3] and s[4]==s[5] else "No")

Buggy submission (verdict: Runtime Error):
s=input()
print("Yes" if s[3]==s[4] and s[5]==s[6] else "No")
Problem p02711 (python)

Fixed submission:
N = str(input())

if N[0]!="7" and N[1]!="7" and N[2]!="7":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N = str(input())
print("Yes","No")[N[0]!="7" and N[1]!="7" and N[2]!="7"]
Problem p02712 (python)

Fixed submission:
N = int(input())
a = 0
for i in range(N):
  x =i+1
  if x%3!=0 and x%5!=0:
    a+=x
print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = 0
for i in range(N):
  x =i+1
  if x%3!=0 andx%5!=0:
    a+=x
print(x)
Problem p02712 (python)

Fixed submission:
N = int(input())
total = 0
for i in range(1,N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    total = total + i
print(total)

Buggy submission (verdict: Runtime Error):
N = int(input())
total = 0
for i in range(1,N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    t = t + i
print(total)
Problem p02723 (python)

Fixed submission:
S = input()
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
hit = 0
for i in range(3):
    if S[i] == T[i]:
        hit = hit + 1
print(hit)
Problem p02790 (python)

Fixed submission:
a,b = input().split()
if a * int(b) > b * int(a):
    print(b * int(a))
else:
    print(a * int(b))

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
if "a" * b > "b" * a:
    print("b" * a)
else:
    print("a" * b)
Problem p02847 (python)

Fixed submission:
s = input()
day = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
n = day.index(s)
print(7 - n)

Buggy submission (verdict: Runtime Error):
S = input()
day = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
n = day.index(s)
print(7 - n)
Problem p02933 (python)

Fixed submission:
a = int(input())
# s = int(input())
# C = int(input())
s= input()
print(s if a >= 3200 else "red")

Buggy submission (verdict: Runtime Error):
a = int(input())
s = int(input())
# C = int(input())
# b = input()
print(s if a >= 3200 else "red")
Problem p03135 (python)

Fixed submission:
T,X = map(int, input().split())
print(T / X)

Buggy submission (verdict: Runtime Error):
T,N = map(int, input().split())
print(T / X)
Problem p03315 (python)

Fixed submission:
S = input()
print(S.count("+") - S.count("-"))

Buggy submission (verdict: Runtime Error):
S = input()
print(S.count(+) - S.count(-))
Problem p02699 (python)

Fixed submission:
class Main:

    s1, s2= map(int,input().split());

    if s1 <= s2:
        print("unsafe");
    else:
        print("safe");

Buggy submission (verdict: Runtime Error):

class Main:

    t1, a1, t2, a2= map(int,input().split());

    while(t1 > 0 and t2 > 0):
        if t2 <= 0:
            break;
        t2 -= a1;
        if t1 <= 0:
            break;
        t1 -= a2;

    if t1 >= t2:
        print("Yes");
    else:
        print("No")

Buggy submission (verdict: Runtime Error):


class Main:

    s1, s2= int(input().split());

    if s1 <= s2:
        print("unsafe");
    else:
        print("safe");

Buggy submission (verdict: Runtime Error):

class Main:

    s = int(input().split());

    if s[0] <= s[1]:
        print("unsafe");
    else:
        print("safe");

Buggy submission (verdict: Runtime Error):

class Main:

    def main(s1,s2):
        if s1 <= s2:
            print("unsafe");
        else:
            print("safe");
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = int(input.split());
    if s[1] <= s[2]:
        print("unsafe");
    else:
        print("safe");
main()
Problem p02701 (python)

Fixed submission:



class Main:
    N = int(input());
    s = set([input() for i in range(N)]);
    print(len(s))

Buggy submission (verdict: Runtime Error):
import sys;


class Main:
    s = set([i.sprit() for i in sys.stdin.readlines()]);

    print(len(s));
Problem p02701 (python)

Fixed submission:
import sys
import math
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False

n = aint()
get = []
for i in range(n):
    s = input()
    get.append(s)
ss = set(get)
print(len(ss))

Buggy submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))

n = aint()
get = [[],[],[],[],[],[],[],[],[],[]]
for i in range(n):
    s = input()
    if s not in get[len(s)-1]:
        get[len(s)-1].append(s)

ss = 0
for cont in get:
    ss += sum(cont)
print(ss)

Buggy submission (verdict: Runtime Error):
port sys
import math
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False

n = aint()
get = []
for i in range(n):
  s = input()
  if s not in get:
    get.append(s)
print(len(get))
Problem p02726 (python)

Fixed submission:
n,x,y = list(map(int,input().split()))
ans = [0]*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        ans[min(j-i,1+abs(x-1-i)+abs(y-1-j))-1]+=1
for num in ans:
    print(num)

Buggy submission (verdict: Runtime Error):
NXY = list(map(int, input().split()))
N, X, Y = NXY[0], NXY[1], NXY[2]


def flatten_2dim(array):
    return [item for sublist in array for item in sublist]


dp = []
for i in range(N):
    dp.append([])
    for j in range(N):
        if j < i:
            dp[i].append(0)
        else:
            dp[i].append(j-i)

for i in range(int(N*0.5)):
    for j in range(int(N*0.5)):
        if i == 0 and j == 0:
            dp[X-1][Y-1] = 1
        else:
            dp[X-1-i][Y-1-j] = min(1+i+j, dp[X-1-i][Y-1-j])
            dp[X-1+i][Y-1-j] = min(1+i+j, dp[X-1+i][Y-1-j])
            dp[X-1-i][Y-1+j] = min(1+i+j, dp[X-1-i][Y-1+j])
            dp[X-1+i][Y-1+j] = min(1+i+j, dp[X-1+i][Y-1+j])
print(dp)
for k in range(1, N):
    print(flatten_2dim(dp).count(k))
Problem p02759 (python)

Fixed submission:
N = int(input())
if N %2 == 0:
    print(int(N/2))
else:
    print(N//2 + 1)

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j]=-1
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==-1:
        print('Yes')
        exit()
    if a[0][i]==a[1][i]==a[2][i]==-1:
        print('Yes')
        exit()
if a[0][0]==a[1][1]==a[2][2]==-1 or a[0][2]==a[1][1]==a[2][0]==-1:
    print('Yes')
    exit()
print('No')
Problem p02819 (python)

Fixed submission:
x = int(input())

is_prime = [True] * (10**6+1)   #全部Trueに
is_prime[0] = False
is_prime[1] = False

for i in range(2,int(10**3)+1):  
    if is_prime[i]:
        for j in range(i * 2, 10**6 + 1, i):
            is_prime[j] = False

while True:
    if is_prime[x]:
      break
    x+=1
print(x)

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

is_prime = [True] * (10**5+1)   #全部Trueに
is_prime[0] = False
is_prime[1] = False

for i in range(2,int(10**2.5)+1):  
    if is_prime[i]:
        for j in range(i * 2, 10**5 + 1, i):
            is_prime[j] = False

while True:
    if is_prime[x]:
      break
    x+=1
print(x)
Problem p02847 (python)

Fixed submission:
s=input()
lst=['SUN','MON','TUE','WED','THU','FRI','SAT']
lst2=[7,6,5,4,3,2,1]
print(lst2[int(lst.index(s))])

Buggy submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
l=0
r=10**9+1

while r-l >1:
    mid=(r+l)//2
    if x < a*(mid) + b+len(str(mid)):
        max=mid
    else:
        min=mid

print(min)
Problem p02881 (python)

Fixed submission:
n=int(input())
c=10**13
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        j=int(n/i)
        if i+j < c:
            c=int(i+j)

print(c-2)

Buggy submission (verdict: Runtime Error):
n=int(input())
c=10**9
for i in range(1,n**0.5):
    if n%i==0:
        j=n/i
        if i+j < c:
            c=int(i+j)

print(c-2)
Problem p03077 (python)

Fixed submission:

import math
n=int(input())
l=[int(input()) for _ in range(5)]
print(math.ceil(n/min(l)+4))

Buggy submission (verdict: Runtime Error):
import math
n=int(input)
l=[int(input) for _ in range(5)]
print(math.ceil(n/min(l)+4))

Buggy submission (verdict: Runtime Error):
import math
n=int(input)
l=[int(input) for _ in range(5)]
print(ceil(n/min(l)+4))
Problem p03805 (python)

Fixed submission:
nmax = 8
graph = [[0]*nmax for i in range(nmax)]
visited = [0] * nmax


def dfs(v, N, visited):
    all_visited = True
    for i in range(N):
        if visited[i] == 0:
            all_visited = False
    if all_visited:
        return 1
  
    ret = 0
    for i in range(N):
        if graph[v][i] == 0:
            continue
        if visited[i] == 1:
            continue
        visited[i] = 1
        ret += dfs(i, N, visited)
        visited[i] = 0
    return ret
      

N, M = [int(i) for i in input().split()]
for j in range(M):
    a, b = [int(j) for j in input().split()]
    graph[a-1][b-1] = graph[b-1][a-1] = 1


visited[0] = 1
print(dfs(0, N, visited))

Buggy submission (verdict: Runtime Error):
nmax = 8
graph = [[0]*nmax for i in range(nmax)]
visited = [0] * nmax

def dfs(v, N, visitied):
  all_visited = True
  for i in range(N):
    if visitied[i] == 0:
      all_visited = False
    if all_visited:
      return 1
  
  ret = 0
  for i in range(N):
    if graph[v][i] == 0:
      continue
    if visited[i] == 0:
      continue
    visited[i] = 1
    ret += dfs(i, N, visited)
    visited[i] = False
  return ret
      

N, M = [int(i) for i input().split()]
for j in range(M):
  a, b = [int(j) for j in input().split()]
  graph[a-1][b-1] = graph[b-1][a-1] = 1

visited[0] = 1
print(dfs(0, N, visited))
Problem p02682 (python)

Fixed submission:
#B
i = input()
a = int(i.split()[0])
b = int(i.split()[1])
c = int(i.split()[2])
k = int(i.split()[3])

count = 0

if k < a:
    count += a-(a-k)
elif k <= a+b:
    count += a
elif a+b < k:
    count += (a)-(k-(a+b))
print(count)

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

count = 0

if k <= a+b:
    count += a
else:
    count += a-(k-(a+b))
print(count)
Problem p02699 (python)

Fixed submission:
s, w = [int(x) for x in input().strip().split()]
print("safe" if s > w else "unsafe")

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


def count_multi(s, d):
  m = a = np.array([int(c) for c in s])  # .astype(np.int)
  keta = 1
  count = np.count_nonzero(m == 0)
  while len(m) > 1:
    m = (m[:-1]*10 + a[keta:]) % d
    keta += 1
    count += np.count_nonzero(m == 0)
  return count
        
print(count_multi(input().strip(), 2019))

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


def count_multi(s, d):
  m = a = np.array([c for c in s]).astype(np.int)
  keta = 1
  count = np.count_nonzero(m == 0)
  while len(m) > 1:
    m = (m[:-1]*10 + a[keta:]) % d
    keta += 1
    count += np.count_nonzero(m == 0)
  return count
        
print(count_multi(input().strip(), 2019))

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


def count_multi(s, d):
  a = np.array([c for c in s]).astype(np.int)
  m = a  # % d
  keta = 1
  count = np.count_nonzero(m == 0)
  while len(m) > 1:
    m = (10*m[:-1] + a[keta:]) % d
    keta += 1
    count += np.count_nonzero(m == 0)
  return count
        
print(count_multi(input().strip(), 2019))
Problem p02701 (python)

Fixed submission:
import sys
n = int(input().strip())
items = set()
for _ in range(n):
  items |= {sys.stdin.readline().strip()}
print(len(items))

Buggy submission (verdict: Runtime Error):
import sys
n = int(input().strip())
items = set()
for _ in range(n):
  items |= {sys.readline().strip()}
print(len(items))

Buggy submission (verdict: Runtime Error):
import sys
n = int(input().strip())
items = set()
for _ in range(n):
  items |= {sys.readline().strip()}