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

Fixed submission:
N, M = map(int, input().split())
print(N*(N-1)//2 + M*(M-1)//2)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
print(N*(N-1)//2 + M*(M-1)//2))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
print(N*(N-1)/2 + M*(M-1)/2))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
print(N*(N-1)/2 + M*(M-1)/2))

Buggy submission (verdict: Runtime Error):
test
Problem p02699 (python)

Fixed submission:
s,w=map(int,input().split())
if w>=s:
	print("unsafe")
else:
	print("safe")

Buggy submission (verdict: Runtime Error):
n=int(input())
s,l=[],[]
s=[input() for i in range(n)]
for i in s:
  if i not in l:
      l.append(i)
print(len(l))
Problem p02779 (python)

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

A.sort()
# print(A)
# print(N//2)
for i in range(N // 2):
    # print(i)
    # print(A[i])
    # print(A[i+1])
    
    if A[i] == A[i+1]:
        print("NO")
        exit()
    elif A[-1-i] == A[-2-i]:
        print("NO")
        exit()

print("YES")

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

A.sort()
# print(A)
for i in range(N // 2 + 1):
    # print(A[i])
    # print(A[i+1])
    
    if A[i] == A[i+1]:
        print("NO")
        exit()
    elif A[-1-i] == A[-2-i]:
        print("NO")
        exit()

print("YES")

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

A.sort()
print(A)
for i in range(N // 2 + 1):
    # print(A[i])
    # print(A[i+1])
    
    if A[i] == A[i+1]:
        print("NO")
        exit()
    elif A[-1-i] == A[-2-i]:
        print("NO")
        exit()

print("YES")
Problem p02831 (python)

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

tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])

mo = 0
if A >= B:
    mo = gcd(A, B)
else:
    mo = gcd(B, A)
ans = (A * B) // mo

print(ans)

Buggy submission (verdict: Runtime Error):
import math
tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])

ans = (A * B) // math.gcd(A, B)

print(ans)
Problem p02891 (python)

Fixed submission:
S = input()
K = input()

if not(1 <= len(S) and len(S) <= 100):
    exit()
if not (S.isalpha() and S.islower()):
    exit()
if not float(K).is_integer():
    exit()
if not (1 <= int(K) and int(K) <= 10 ** 9):
    exit()

L = []
tmp = []
pre = ""
for s in S:
    if len(tmp) == 0:
        pre = s
        tmp.append(s)
    elif pre == s:
        tmp.append(s)
    else:
        L.append(tmp)
        pre = s
        tmp = [s]
L.append(tmp)

count = 0
for l in L:
    count += int(len(l) / 2)
    # print(l)
count *= int(K)
if len(L) == 1:
    if len(L[0]) == 1:
        count = int(int(K) / 2)
    elif len(L[0]) % 2 == 1:
        count += int(int(K) / 2)
    
elif L[0][0] == L[len(L)-1][0]:
    if len(L[0]) % 2 == 1 and len(L[len(L)-1]) % 2 == 1:
        count = count + int(K) - 1
print(count)

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

# if not(1 <= len(S) and len(S) <= 100):
#     exit()
# if not (S.isalpha() and S.islower()):
#     exit()
# if not float(K).is_integer():
#     exit()
# if not (1 <= int(K) and int(K) <= 10 ** 9):
#     exit()



L = []
tmp = []
pre = ""
for s in S:
    if len(tmp) == 0:
        pre = s
        tmp.append(s)
    elif pre == s:
        tmp.append(s)
    else:
        L.append(tmp)
        pre = s
        tmp = [s]
L.append(tmp)

count = 0
for l in L:
    count += int(len(l) / 2)

count *= int(K)
if len(L) == 1:
    print(count)
    exit()
if L[0][0] == L[len(L) - 1][0]:
    if len(L[0]) % 2 == 1 and len(L[len(L)]) % 2 == 1:
        count = count + 1 * int(K) - 1
print(count)

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

if not(1 <= len(S) and len(S) <= 100):
    exit()
if not (S.isalpha() and S.islower()):
    exit()
if not float(K).is_integer():
    exit()
if not (1 <= int(K) and int(K) <= 10 ** 9):
    exit()



L = []
tmp = []
pre = ""
for s in S:
    if len(tmp) == 0:
        pre = s
        tmp.append(s)
    elif pre == s:
        tmp.append(s)
    else:
        L.append(tmp)
        pre = s
        tmp = [s]
L.append(tmp)

count = 0
for l in L:
    count += int(len(l) / 2)

count *= int(K)
if len(L) == 1:
    print(count)
    exit()
if L[0][0] == L[len(L) - 1][0]:
    if len(L[0]) % 2 == 1 and len(L[len(L)]) % 2 == 1:
        count = count + 1 * int(K) - 1
print(count)
Problem p02598 (python)

Fixed submission:
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
l = 0
r = 10**9
while l+1 < r:
    m = (l+r)//2
    cnt = 0
    for i in range(n): cnt += (a[i]+m-1)//m-1
    if cnt > k: l = m
    else: r = m
print(r)

Buggy submission (verdict: Runtime Error):
from math import ceil
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
l = -1
r = 10**9
while l+1 < r:
    m = (l+r)//2
    cnt = 0
    for i in range(n):
        cnt += ceil(a[i]/m)-1
    if cnt <= k: r = m
    else: l = m
print(r)
Problem p02771 (python)

Fixed submission:
a = input().split()
if len(set(a)) == 2:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
ans = "Yes" if len(set(a,b,c)) == 2 else "No"
print(ans)
Problem p02833 (python)

Fixed submission:
n = int(input())

if n%2 != 0:
    ans = 0
else:
    ans = 0
    x = 5
    while n >= x:
        ans += n//(x*2)
        x *= 5

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000000)

n,u,v = map(int,input().split())
u -= 1
v -= 1
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

dist = [-1]*n
dist[v] = 0
prev = [-1]*n
def dfs(now):
    for nxt in G[now]:
        if dist[nxt] != -1: continue
        dist[nxt] = dist[now]+1
        prev[nxt] = now
        dfs(nxt)
dfs(v)

color = [0]*n
now = u
while now >= 0:
    color[now] = 1
    now = prev[now]

def dfs2(now,prev,dist,cnt):
    if dist == 0: return cnt
    if dist == -1: return cnt-1
    if G[now] == [prev]: return cnt+dist-1
    res = 0
    for nxt in G[now]:
        if nxt == prev: continue
        if color[nxt]: res = max(res,dfs2(nxt,now,dist-2,cnt+1))
        else: res = max(res,dfs2(nxt,now,dist,cnt+1))
    return res

print(dfs2(u,-1,dist[u]-dist[v],0))
Problem p02834 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)

n,u,v = map(int,input().split())
u -= 1
v -= 1
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

distT = [-1]*n
distA = [-1]*n
distT[u] = 0
distA[v] = 0
def dfs(now,dist):
    for nxt in G[now]:
        if dist[nxt] != -1: continue
        dist[nxt] = dist[now]+1
        dfs(nxt,dist)
dfs(u,distT)
dfs(v,distA)

mx = 0
for i in range(n):
    if distT[i] < distA[i]:
        mx = max(mx, distA[i])
ans = mx-1
print(ans)

Buggy submission (verdict: Runtime Error):
n,u,v = map(int,input().split())
u -= 1
v -= 1
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

dist = [-1]*n
dist[v] = 0
prev = [-1]*n
def dfs(now):
    for nxt in G[now]:
        if dist[nxt] != -1: continue
        dist[nxt] = dist[now]+1
        prev[nxt] = now
        dfs(nxt)
dfs(v)

color = [0]*n
now = u
while now >= 0:
    color[now] = 1
    now = prev[now]

def dfs2(now,prev,dist,cnt):
    if dist == 0: return cnt
    if dist == -1: return cnt-1
    if G[now] == [prev]: return cnt+dist-1
    res = 0
    for nxt in G[now]:
        if nxt == prev: continue
        if color[nxt]: res = max(res,dfs2(nxt,now,dist-2,cnt+1))
        else: res = max(res,dfs2(nxt,now,dist,cnt+1))
    return res

print(dfs2(u,-1,dist[u]-dist[v],0))
Problem p02897 (python)

Fixed submission:

n = int(input())

if n%2==0:
    print(0.5)
else:
    print((n//2+1)/n)

Buggy submission (verdict: Runtime Error):
from math import sqrt

a,b = map(int,input().split())
 
L = []
 
if a < b: a,b = b,a
while b!=0:
    r = a%b
    a,b = b,r
 
G = a
 
for i in range(2,int(sqrt(G))+1):
    if G%i==0:
        L.append(i)
        while G%i==0:
            G/=i

if G!=1:
    L.append(G)

print(len(L)+1)

Buggy submission (verdict: Runtime Error):
from math import sqrt

a,b = map(int,input().split())

L = []

if a < b: a,b = b,a
while b!=0:
    r = a%b
    a,b = b,r

G = a

for i in range(2,G+1):
    for j in L:
        if i%j==0: 
            break
    else:
        if G%i==0: 
            L.append(i)

print(len(L)+1)
Problem p02987 (python)

Fixed submission:
s = list(input())
s.sort()

if s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Buggy submission (verdict: Runtime Error):
s = list(input())
s.sort()

if s[0]==s[1] and s[2]==s[3] ans s[0]!=s[2]:
    ans = "Yes"
else:
    ans = "No"

print(ans)
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
aa = [int(input()) for i in range(m)]

cnt2 = 0
cnt1 = 1
aa.append(-1)
a = aa.pop(0)


for i in range(1,n):
    if i == a:
        cnt2, cnt1 = cnt1, 0
        a = aa.pop(0)
    else:
        cnt2, cnt1 = cnt1, cnt2+cnt1
else:
    ans = (cnt2+cnt1)%1000000007

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
mod = 10**9+7
memo = [-1]*(n+1)
def rec(x):
    if memo[x] != -1: pass
    elif x == 0: memo[x] = 1
    elif a and x == a[-1]:
        memo[x] = 0
        a.pop()
    elif x == 1: memo[x] = 1
    else: memo[x] = rec(x-1)+rec(x-2)
    return memo[x]%mod
print(rec(n))
Problem p03038 (python)

Fixed submission:
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
bc = [[int(i) for i in input().split()] for i in range(m)]
ans = 0
cnt = 0
d = {}

for i in range(n): 
    d[a[i]] = d.get(a[i],0)+1
for k in d: 
    bc.append([d[k],k])
bc.sort(key= lambda x:x[1],reverse=True)

for i in range(len(bc)):
    if cnt < n:
        ans += bc[i][1]*bc[i][0]
        cnt += bc[i][0]
    else:
        ans -= (cnt-n)*bc[i-1][1]
        break
else:
    ans -= (cnt-n)*bc[i][1]

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
bc = [[int(i) for i in input().split()] for i in range(m)]
a.sort()
bc.sort(key=lambda x:x[1],reverse=True)
d = []
cnt1 = 0
cnt2 = 0
x = 0

for lst in bc:
    cnt2 = 0
    while cnt1 < n and cnt2 < lst[0]:
        d.append(lst[1])
        cnt1 += 1
        cnt2 += 1

for i in range(n):
    if d[i] - a[i] < 0:
        x = i
        break

print(sum(d[:x]+a[x:]))
Problem p03107 (python)

Fixed submission:
s = input()
zero = 0
one = 0

for i in range(len(s)):
    if s[i]=="0":
        zero += 1
    else:
        one += 1
else:
    ans = min(zero,one)*2

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
zero = 0
one = 0

for i in len(s):
    if s[i]=="0":
        zero += 1
    else:
        one += 1
else:
    ans = min(zero,one)*2

print(ans)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
a,b = map(Decimal,input().split())
c = int(a*b)
print(c)

Buggy submission (verdict: Runtime Error):
a,b = map(Decimal,input().split())
c = int(a*b)
print(c)
Problem p02552 (python)

Fixed submission:
x=int(input())

if x == 1:
    print(0)
else:
    print(1)

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

x = a*c

if a*c < a*d:
    x=a*d
elif a*d < b*c:
    x=b*c
elif b*c < b*d:
    x=b*d

print(x)
Problem p02984 (python)

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

x = [None] * N
x[0] = 0
for i in range(2, N, 2):
    x[i] = x[i-2] + (A[i-1] - A[i-2]) * 2
x[1] = x[-1] + (A[0] - A[-1]) * 2
for i in range(3, N-1, 2):
    x[i] = x[i-2] + (A[i-1] - A[i-2]) * 2

import numpy as np
ma = np.mean(A)
mx = np.mean(x)
x = (np.array(x) + ma - mx + 0.1).astype(int)
for i in range(N-1):
    print(x[i], end=" ")
print(x[-1])

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

import numpy as np
W = np.zeros((N, N))
for i in range(N-1):
    W[i, i] = 0.5
    W[i, i+1] = 0.5
W[N-1, N-1] = 0.5
W[N-1, 0] = 0.5

A = np.array(A)

x = (np.linalg.inv(W).dot(A)+0.1).astype(int)

for xx in x[:-1]:
    print(xx, end=' ')
print(x[-1])

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

import numpy as np
W = np.zeros((N, N))
for i in range(N-1):
    W[i, i] = 0.5
    W[i, i+1] = 0.5
W[N-1, N-1] = 0.5
W[N-1, 0] = 0.5

A = np.array(A)

x = np.linalg.inv(W).dot(A).astype(int)

for xx in x[:-1]:
    print(xx, end=' ')
print(x[-1])
Problem p02990 (python)

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

# 赤いボールの数
R = N - K

import itertools
import math
def comb(n, k):
    if n-k < 0:
        return 0
    return math.factorial(n)//math.factorial(n-k)//math.factorial(k)



for i in range(1, K+1):
    a = comb(K-1, i-1)
    b = comb(R+1, i)
    print(a * b % 1000000007)

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

# 赤いボールの数
R = N - K

import itertools
import math
def comb(n, k):
    return math.factorial(n)//math.factorial(n-k)//math.factorial(k)



for i in range(1, K+1):
    a = comb(K-1, i-1)
    b = comb(R+1, i)
    print(a * b % 1000000007)
Problem p03013 (python)

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

dp_f = [None] * (10**5 + 2)
dp_f[1] = 1
dp_f[2] = 1
for i in range(3, 10**5 + 1):
    dp_f[i] = dp_f[i-1] + dp_f[i-2]
def f(n):
    if n == 1:
        return 1
    elif n == 2:
        return 1
    elif dp_f[n] is not None:
        return dp_f[n]
    v = f(n-1) + f(n-2)
    dp_f[n] = v
    return dp_f[n]

if M == 0:
    m = f(N+1)
    m %= 1000000007
    print(m)
    sys.exit(0)

A = [int(input()) for i in range(M)]

S = []
S.append(A[0])
for i in range(1, M):
    if A[i] == A[i-1] + 1:
        print(0)
        sys.exit(0)
    S.append(A[i] - A[i-1] - 1)
S.append(N - A[-1])

m = 1
for s in S:
    m *= f(s)
    m %= 1000000007

print(m)

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

dp_f = [None] * 10**5
def f(n):
    if n == 1:
        return 1
    elif n == 2:
        return 1
    elif dp_f[n] is not None:
        return dp_f[n]
    v = f(n-1) + f(n-2)
    dp_f[n] = v
    return dp_f[n]

if M == 0:
    print(f(N))
    sys.exit(0)

A = [int(input()) for i in range(M)]

S = []
S.append(A[0])
for i in range(1, M):
    if A[i] == A[i-1] + 1:
        print(0)
        sys.exit(0)
    S.append(A[i] - A[i-1] - 1)
S.append(N - A[-1])

m = 1
for s in S:
    m *= f(s)
    m %= 1000000007

print(m)
Problem p03104 (python)

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


_beki = [None] * 50
def ni_beki(n):
    return 2 ** n


# １-nのそれぞれの2進数で下からn桁目(n=0,1,...)の中の1の個数を返す関数
def f(x, n):
     a, b = divmod(x, ni_beki(n+1))
     p = ni_beki(n)
     return a * p + max(b - (p - 1), 0)

# 2進数での桁数を求める
def g(n):
    c = 0
    while True:
        if ni_beki(c) >= n + 1:
            return c
        c += 1

keta = g(B)
# 下から数えていく
d = []
for i in range(keta):
    p = f(B, i)
    q = f(A-1, i)
    d.append(p - q)

# 表示順に
d.reverse()

# 01文字に
e = list(map(lambda x: str(x % 2), d))

# 文字列に
e = ''.join(e)

if e == '':
    e = "0"
print(int(e, 2))

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


_beki = [None] * 50
def ni_beki(n):
    return 2 ** n


# １-nのそれぞれの2進数で下からn桁目(n=0,1,...)の中の1の個数を返す関数
def f(x, n):
     a, b = divmod(x, ni_beki(n+1))
     p = ni_beki(n)
     return a * p + max(b - (p - 1), 0)

# 2進数での桁数を求める
def g(n):
    c = 0
    while True:
        if ni_beki(c) >= n + 1:
            return c
        c += 1

keta = g(B)
# 下から数えていく
d = []
for i in range(keta):
    p = f(B, i)
    q = f(A-1, i)
    d.append(p - q)

# 表示順に
d.reverse()

# 01文字に
e = list(map(lambda x: str(x % 2), d))

# 文字列に
e = ''.join(e)

print(int(e, 2))
Problem p02699 (python)

Fixed submission:
s,w = map(int,input().split())

if s<w or s==w:
	print("unsafe")
else:
	print("safe")

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

aoki_new = (a+d-1)/d
taka_new1 = (c+b-1)/b

if aoki_new >= taka_new1:
	print("Yes") #takahasi is loses because its heath is zero first
else:
	print("No")

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

aoki_new = (a+d-1)/d
taka_new1 = (a+b-1)/b

if taka_new1 <= aoki_new :
	print("Yes") #takahasi is loses because its heath is zero first
else:
	print("No")

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

aoki_new = (a+d-1)/d
taka_new1 = (a+b-1)/b

if taka_new1 < aoki_new :
	print("No") #takahasi is loses because its heath is zero first
else:
	print("Yes")
Problem p02693 (python)

Fixed submission:

k = int(input())
a,b = map(int,input().split())

for i in range(a,b+1):
    if i % k == 0:
        print('OK')
        exit()
print('NG')

Buggy submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())

maxpoint = 0
if b > n:
    for i in range(n+1):
        tmp = int((a * i) / b)  - a * int(i/b) 
        maxpoint = max(tmp,maxpoint)
else:
    for i in reversed(range(n+1)):
        tmp = int((a * i) / b)  - a * int(i/b) 
        if b > 1:
            if i % (b-1) == 0 :
                maxpoint = max(tmp,maxpoint)
                print(maxpoint) 
                exit()
        elif b == 1:
            print(0)
            exit()
        maxpoint = max(tmp,maxpoint)
        # print(maxpoint)

print(maxpoint)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
a = set(int(input()) for _ in range(M))
dp = [0] * (N + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1

for i in range(2, N + 1):
    for k in [-2, -1]:
        if i + k not in a:
            dp[i] += dp[i+k]

print(dp[N] % 1000000007)

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    a = [0] * (1 + 10 ** 5)
    for _ in range(M):
        a[int(input())] = 1
    dp = [0] * (N + 1)
    dp[0] = 1
    if not a[1]:
        dp[1] = 1

    for i in range(2, N + 1):
        if not a[i]:
            dp[i] += dp[i-1] + d[i-2]
            dp[i] %= 1000000007

    print(dp[N])

main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    a = [0] * (1 + 10 ** 5)
    for _ in range(M):
        a[int(input())] = 1
    dp = [0] * (N + 1)
    dp[0] = 1
    if not a[1]:
        dp[1] = 1

    for i in range(2, N + 1):
        if not a[i]:
            dp[i] = 0
        else:
            dp[i] += dp[i-1] + d[i-2]
            dp[i] %= 1000000007

    print(dp[N])

main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    a = {int(input()): 1 for _ in range(M)}
    dp = [0] * (N + 1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1

    for i in range(2, N + 1):
        if a[i]:
            dp[i] = 0
        else:
            dp[i] += dp[i-1] + d[i-2]
            dp[i] %= 1000000007

    print(dp[N])

main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    a = {int(input()): 1 for _ in range(M)}
    dp = [0] * (N + 1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1

    for i in range(2, N + 1):
        if a[i]:
            dp[i] = 0
        else:
            dp[i] += dp[i-1] + d[i+1]
            dp[i] %= 1000000007

    print(dp[N])

main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    a = {int(input()): 1 for _ in range(M)}
    dp = [0] * (N + 1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1

    for i in range(2, N + 1):
        for k in [-2, -1]:
            if a[i + k]:
                dp[i] = 0
            else:
                dp[i] += dp[i+k]
        dp[i] %= 1000000007

    print(dp[N])

main()
Problem p03329 (python)

Fixed submission:
n = int(input())
def func(n, i):
    ans = 0
    while n>0:
        ans += n%i
        n //= i
    return ans
b=n
for i in range(n+1):
    tmp = func(i, 6) + func(n-i, 9)
    b = min(tmp, b)
print(b)

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

def func(n, i):
    ans = 0
    while  n > 0:
        ans += n % i
        n // = i
    return ans

b = n
for i in range(n+1):
    tmp = func(i, 6) + func(n-1, 9)
    b = min(tmp, b)

print(b)
Problem p02547 (python)

Fixed submission:
i = int(input())
count = 0
res = False
for i in range(i):
  a, b = input().split(' ')
  if a == b:
    count += 1
  else:
    count = 0
  if count >= 3:
    res = True
print('Yes' if res else 'No')

Buggy submission (verdict: Runtime Error):
i = int(input())
count = 0
for i in range(i):
  a, b = input().split(' ')
  if a == b:
    count += 1
print('Yes' if count >= 3 else 'No'
Problem p02699 (python)

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

Buggy submission (verdict: Runtime Error):
S, W = map(int.input(" ")) 
if W >= S :
    print("Unsafe")
else:
    print("Safe")
Problem p02835 (python)

Fixed submission:
a = [int(x) for x in input().split(" ")]
print("bust") if sum(a) >= 22 else print("win")

Buggy submission (verdict: Runtime Error):
A1=int(input())
A2= int(input())
A3= int(input())
if(A1+A2+A3>=22):
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
A1 = int(input())
A2 = int(input())
A3 = int(input())
sum  = A1+A2+A3
if(sum>=22):
    print("bust")
else:
    print("win")
Problem p02627 (python)

Fixed submission:
alpha = input()
if alpha.isupper():
    print("A")
else:
    print("a")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0]*Q
C = [0]*Q
S = [0]*Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())

for i in range(Q):
    A_replace = [C[i] if a == B[i] else a for a in A]

    A = A_replace
    S[i] = sum(A_replace)

for i in range(Q):
    print(S[i])
Problem p02897 (python)

Fixed submission:
N = int(input())

if N % 2 == 0:
  print(1/2)
else:
  n = N // 2 + 1
  print(n /N )

Buggy submission (verdict: Runtime Error):
import fractions
import math
import heapq
import collections

A,B = map(int, input().split(" "))
G = fractions.gcd(A,B)

S = set()


def p_fac(N):
  ans = 2
  if (N % 2 == 0):
    ans += 1
    while(N % 2 ==0):
      N = N // 2
  a = 3
  while(a < N):
    if (N % a == 0):
      ans += 1
      while( N % a == 0):
        N = N // a
    a += 2

  return ans

print(p_fac(G))
Problem p02580 (python)

Fixed submission:
from collections import defaultdict

def main()->str:
    H,W,M=map(int,input().split())
    ch=[0]*H
    cw=[0]*W
    bm=defaultdict(lambda:False)
    for _ in range(M):
        h,w=map(int,input().split())
        h-=1
        w-=1
        bm[(h,w)]=True
        ch[h]+=1
        cw[w]+=1
    hb=max(ch)
#    max_h=[i for i, x in enumerate(ch) if x == hb]
    max_h=[]
    for i in range(len(ch)):
        if ch[i]==hb: max_h.append(i)
    wb=max(cw)
#    max_w=[i for i, x in enumerate(cw) if x == wb]
    max_w=[]
    for i in range(len(cw)):
        if cw[i]==wb: max_w.append(i)
    
    z=hb+wb
    for mh in max_h:
        for mw in max_w:
            if bm[(mh,mw)]==False:
                return(z)
    return(z-1)

if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
h=a[0]
w=a[1]
m=a[2]
sh=[0]*1000000
sw=[0]*1000000
mw=0
mh=0
for i in range (0,m):
    s=list(map(int,input().split()))
    sh[s[0]]+=1
    if sh[s[0]]>mh:
        mh=sh[s[0]]
        hh=s[0]
    sw[s[1]]+=1
    if sw[s[0]]>mw:
        mw=sw[s[0]]
        ww=s[1]
z=mh+mw
if sh[hh]>0 and sw[ww]>0:
    z-=1

print(z)
Problem p02552 (python)

Fixed submission:
x = input()

if int(x) == 0:
  print(1)
elif int(x) == 1:
  print(0)

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

if x = "1":
  print(0)
elif x = "0":
  print(1)
Problem p02594 (python)

Fixed submission:
x = input()

if int(x) >= 30:
  print("Yes")
else:
  print("No")

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

if x >= 30:
  print("yes")
else:
  print("no")