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

Fixed submission:
from collections import deque


N,M=list(map(int,input().split()))
graph=[[] for _ in range(N+1)]
for _ in range(M):
    a,b,c=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
    
#seen[i]は、頂点iを訪問済みの場合はTrue、未訪問の場合はFalse
seen=[False]*(N+1)


count=0

for i in range(1,N+1):
    if seen[i]==False:
        seen[i]=True
        S=deque([i])
        
        while S:
            v=S.popleft()
            #訪問済みの頂点をTrueにする
            for i in graph[v]:
                if seen[i]==False:
                    seen[i]=True
                    S.append(i)
        count+=1

print(count)

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

graph=[[] for _ in range(N+1)]

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

for _ in range(M):
    a,b,c=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
    
#seen[i]は、頂点iを訪問済みの場合はTrue、未訪問の場合はFalse
seen=[False]*(N+1)


count=0

for i in range(1,N+1):
    if seen[i]==False:
        seen[i]=True
        S=deque([i])
        
        while S:
            v=S.popleft()
            #訪問済みの頂点をTrueにする
            for i in graph[v]:
                if seen[i]==False:
                    seen[i]=True
                    S.append(i)
        count+=1

print(count)
Problem p03834 (python)

Fixed submission:
#51
Haiku = str(input())
print(Haiku.replace(","," "))

Buggy submission (verdict: Runtime Error):
K,S=map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        if 0<=S-x-y<=K:
            count=count+1
print(count)

Buggy submission (verdict: Runtime Error):
K,S=map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                count = count +1
print(count)
Problem p02831 (python)

Fixed submission:
A, B = map(int, input().split())
 
import fractions
 
ans = A * B / fractions.gcd(A, B)
print(int(ans))

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

import math

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

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

import math

ans = A * B / math.gcd(A, B)
print(int(ans))
Problem p02834 (python)

Fixed submission:
N, U, V = map(int, input().split())
A = [[] for _ in range(N)]

import sys
import numpy as np
sys.setrecursionlimit(10**8)
for _ in range(N - 1):
    a, b = map(int, input().split())

    A[a - 1].append(b - 1)
    A[b - 1].append(a - 1)

C = [0] * N
D = [0] * N

def DFS(x, pre, cnt, C):
    C[x] = cnt
    cnt += 1
    for a in A[x]:
        if a == pre:
            continue

        DFS(a, x, cnt, C)


DFS(V - 1, -1, 0, C)
DFS(U - 1, -1, 0, D)

E = np.array(C) > np.array(D)
C = np.array(C)
ans = max(C[E]) - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, U, V = map(int, input().split())
A = [[] for _ in range(N)]

import sys
sys.setrecursionlimit(10**8)
for _ in range(N - 1):
    a, b = map(int, input().split())

    A[a - 1].append(b - 1)
    A[b - 1].append(a - 1)

C = [0] * N

def DFS(x, pre, cnt):
    if C[x] < cnt:
        C[x] = cnt
    cnt += 1
    for a in A[x]:
        if a == pre:
            continue

        if a == (U - 1):
            C[a] = cnt
            continue:
        
        DFS(a, x, cnt)


DFS(V - 1, -1, 0)
ans = max(C) - 1
if ans < 0:
    ans = 0
print(ans)
Problem p03634 (python)

Fixed submission:
import heapq


def dijkstra(K):
    c_l = [float('inf')] * N
    c_l[K] = 0
    hq = [(0, K)]
    while hq:
        u = heapq.heappop(hq)[1]
        for nv, c in adj_list[u]:
            if c_l[nv] > c_l[u] + c:
                c_l[nv] = c_l[u] + c
                heapq.heappush(hq, (c_l[u] + c, nv))
    return c_l


N = int(input())
adj_list = [[] for _ in range(N)]

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

Q, K = map(int, input().split())
c_l = dijkstra(K - 1)

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(c_l[x] + c_l[y])

Buggy submission (verdict: Runtime Error):
N = int(input())
adj_list = [[] for _ in range(N)]
depth = [float('inf')] * 100010


def dfs(v, p, d):
    depth[v] = d
    for adj in adj_list[v]:
        if adj[0] == p:
            continue
        dfs(adj[0], v, d + adj[1])


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

Q, K = map(int, input().split())
dfs(K - 1, -1, 0)

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(depth[x] + depth[y])
Problem p02847 (python)

Fixed submission:
s = input()
list = ['SUN','MON','TUE','WED','THU','FRI','SAT']
index = 0
for i in list:
    if s == i:
        ans = 7 - index
    index += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
list = ['SUN','MON','TUE','WED','THU','FRY','SAT']
index = 0
for i in list:
    if s == i:
        ans = 7 - index
    index += 1
print(ans)
Problem p02711 (python)

Fixed submission:
S = input()

ans = 0
for i in range(3):
	if S[i] == "7":
		print("Yes")
		ans = 1
		break

if ans == 0:
	print("No")

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

for i in range(3):
	if S[i] == "7":
		print("Yes")
		exit(1)

print("No")
Problem p02771 (python)

Fixed submission:
import numpy as np

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

if (a == b or a == c or b == c) and not(a == b == c):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
data = [input() for i in range(N)]

dicdata = collections.Counter(data)

m = max(dicdata.values())

newdata = [k for k, v in dicdata.items() if v == m]

newdata.sort()

[print(i) for i in newdata]
Problem p02831 (python)

Fixed submission:
import numpy as np

input_line = input().split()

a = int(input_line[0])
b = int(input_line[1])

x = a * b

if a < b:
	tmp = a
	a = b
	b = tmp

r = a % b
while r != 0:
	a = b
	b = r
	r = a % b

print(int(x / b))

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

input_line = input().split()

x = int(input_line[0])
y = int(input_line[1])

print((x * y) // math.gcd(x, y))
Problem p02832 (python)

Fixed submission:
import numpy as np

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

nxt = 1
ans = 0

for data in x:
	if nxt == data:
		nxt += 1
	else:
		ans += 1
if ans == N:
	ans = -1

print(ans)

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

N = int(input())
x = input().split()

data = [0 for i in range(N)]
for i in range(N):
	data[i] = int(x[i])

nxt = 1
ans = 0

for i in range(N):
	if nxt == data[i]:
		nxt += 1
	else:
		ans += 1
if ans == N:
	print(-1)
	exit(1)

print(ans)
Problem p02699 (python)

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

if W>=S:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
cnt=0
S=str(input())
mc=[0]*2019
L=len(S)

tg=0
digit=1
for s in S[::-1]:
    tg+=int(s)*digit
    mt=tg%2019
    if mt==0:cnt+=1
    cnt+=mc[mt]
    mc[mt]+=1
    digit*=10
    
print(cnt)
Problem p02959 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))+[0]
ans=c=0
for i in range(N+1):
    a=A[i]
    b=B[i]
    ans+=min(a,c)
    a=max(a-c,0)
    ans+=min(a,b)
    c=max(b-a,0)
print(ans)

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

Fixed submission:
import math
N,K=map(int,input().split())
R=N-K
mod = 10**9+7    
def cnr(n,r):
    a=math.factorial(n)
    b=math.factorial(n - r)
    c=math.factorial(r)
    return a//(b*c)

# def cmb(n, r, mod):
#     if ( r<0 or r>n ):
#         return 0
#     r = min(r, n-r)
#     return g1[n] * g2[r] * g2[n-r] % mod


# N = 10**5
# g1 = [1, 1]
# g2 = [1, 1]
# inverse = [0, 1]

# for i in range( 2, N + 1 ):
#     g1.append( ( g1[-1] * i ) % mod )
#     inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
#     g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(1,K+1):
    if R+2>i:
        print(cnr(K-1,i-1)*cnr(R+1,i)%mod)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import math
N,K=map(int,input().split())
R=N-K
D=int(10**9+7)


def cnr(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1,K+1):
    print(cnr(K-1,i-1)*cnr(R+1,i)%D)
Problem p02701 (python)

Fixed submission:
N = int(input())

lis = []

for n in range(N):
  lis.append(input())

s = set(lis)
print(len(s))

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

lis = []

for n in range(N):
  s = input()
  if not s in lis:
    s.append(s)

print(len(lis))
Problem p02759 (python)

Fixed submission:
print((int(input())+1)//2)

Buggy submission (verdict: Runtime Error):
print(((int(input())+1)//2)
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()

if N % 2 == 1:
  ans = "No"
else:
  zenhan = S[0:int(N/2)] 
  kouhan = S[int(N/2):N]
  if zenhan == kouhan:
    ans = "Yes"
  else:
    ans = "No"

print(ans)

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

if N % 2 == 1:
  ans = "No"
else:
  zenhan = S[0:int(N/2)] 
  kouhan = S[int(N/2):N]
  if zenhan == kouhan:
    ans = "Yes"

print(ans)
Problem p02897 (python)

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

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = N /2
print(ans)
N = int(input())
if N % 2 ==0:
  ans = 0.5
else:
  ans = (N + 1) / N / 2

print(ans)
Problem p03012 (python)

Fixed submission:
N = input()
N = int(N)
W = input().split()

for i in range(N):
  W[i] = int(W[i])
  
total = sum(W)
prefix = []
delta = []
for i in range(N):
  prefix.append(sum(W[:i+1]))
  
for i in range(N):
  delta.append(abs(prefix[N-1] /2 - prefix[i]))
  
answer = min(delta) * 2
print(int(answer))

Buggy submission (verdict: Runtime Error):
total = sum(W)
prefix = []
delta = []
for i in range(N):
  prefix.append(sum(W[:i+1]))
  
for i in range(N):
  delta.append(abs(prefix[N-1] /2 - prefix[i]))
  
print(min(delta) * 2)
Problem p03315 (python)

Fixed submission:
S = input()

n = 0

i = 0

while i < 4:
    if S[i] == '+':
        n += 1
    else:
        n -= 1
    i += 1

print(n)

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

n = 0

for i in S:
    if S[i] == '+':
        n += 1
    else:
        n -= 1

print(n)
Problem p02793 (python)

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return (a*b)//gcd(a,b)
input()
a=[int(i) for i in input().split()]
l=a[0]
for i in a:
    l=lcm(i,l)
s=0
for i in a:
    s+=(l//i)
print(s%1000000007)

Buggy submission (verdict: Runtime Error):
import math as m
def lcm(a,b):
    return (a*b)//m.gcd(a,b)
input()
a=[int(i) for i in input().split()]
l=a[0]
for i in a:
    l=lcm(i,l)
s=0
for i in a:
    s+=(l//i)
print(s%1000000007)

Buggy submission (verdict: Runtime Error):
import math as m
def lcm(a,b):
    return (a*b)//m.gcd(a,b)
n=int(input())
a=[int(i) for i in input().split()]
l=a[0]
for i in a:
    l=lcm(i,l)
s=0
for i in a:
    s+=(l/i)
print(int(s%1000000007))

Buggy submission (verdict: Runtime Error):
import math as m
def lcm(a,b):
    return (a*b)//m.gcd(a,b)
n=int(input())
a=[int(i) for i in input().split()]
l=a[0]
for i in a:
    l=lcm(i,l)
s=0
for i in a:
    s+=(l/i)
print(int(s%1000000007))
Problem p02990 (python)

Fixed submission:
import math
N,K = map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def cmb(n, r, mod):

    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 1000000007
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1,K+1):
    # print(i)
    if N-K+1-i<0:
        print(0)
    else:
        first = int(cmb(N-K+1, i,mod))
        last  = int(cmb(K-1, i-1,mod))
        print((first*last)%mod)

Buggy submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

for i in range(1,K+1):
    if N-K+1-i<0:
        print(0)
    else:
        print(int(combinations_count(N-K+1, i)*combinations_count(K-1, i-1)%1000000007))

Buggy submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

for i in range(1,K+1):
    print(int(combinations_count(N-K+1, i)*combinations_count(K-1, i-1)%1000000007))
Problem p03774 (python)

Fixed submission:
#-*-coding:utf-8-*-

def main():
    n, m = map(int, input().split())

    ab_list = []
    cd_list = []
    for _ in range(n):
        ab_list.append(list(map(int, input().split())))
    for _ in range(m):
        cd_list.append(list(map(int, input().split())))
    
    for i in ab_list:
        min_distance = float('inf')
        for j in range(m):
            distance = abs(i[0] - cd_list[j][0]) + abs(i[1] - cd_list[j][1])
            if distance < min_distance:
                min_distance = distance
                min_coord = j + 1
        print(min_coord)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#-*-coding:utf-8-*-

def main():
    n, m = map(int, input().split())

    ab_list = []
    cd_list = []
    for _ in range(n):
        ab_list.append(list(map(int, input().split())))
    for _ in range(m):
        cd_list.append(list(map(int, input().split())))
    

    for i in ab_list:
        min_distance = 2 * 10 ** 8
        for j in range(m):
            distance = abs(i[0] - cd_list[j][0]) + abs(i[1] - cd_list[j][1])
            if distance < min_distance:
                min_distance = distance
                min_coord = j + 1
        print(min_coord)

if __name__ == '__main__':
    main()
Problem p02831 (python)

Fixed submission:
#a,bの最小公倍数
a, b = list(map(int, input().split()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

print(lcm(a, b))

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

start_num = 1
result_list = []
for num in nums:
    if num == start_num:
        result_list.append(num)
        start_num += 1

if len(result_list) == 0:
    print(-1)
else:
    print(n - len(result_list))
Problem p02862 (python)

Fixed submission:
mod = 10 ** 9 + 7
x, y = map(int,  input().split())

def nCm_mod(A, B, mod):
    mul_one = 1
    mul_two = 1

    for i in range(B):
        mul_one *= A - i
        mul_two *= i + 1
        mul_one %= mod
        mul_two %= mod
    
    return (mul_one * pow(mul_two, mod-2, mod)) % mod

n = (2 * y - x) // 3
m = (2 * x - y) // 3

if (x + y) % 3 != 0 or n < 0 or m < 0:
    print(0)
else:
    comb_num = nCm_mod(n+m, min(n,m), mod)
    print(comb_num)

Buggy submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
x, y = map(int,  input().split())

def nCm_mod(A, B, mod):
    mul_one = 1
    mul_two = 1

    for i in range(B):
        mul_one *= A - i
        mul_two *= i + 1
        mul_one %= mod
        mul_two %= mod
    
    return (mul_one * pow(mul_two, mod-2, mod)) % mod

if (x + y) % 3 != 0 or n<0 or n>m:
    print(0)
else:
    n = (2 * y - x) // 3
    m = (2 * x - y) // 3

    comb_num = nCm_mod(n+m, min(n,m), mod)
    print(comb_num)
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb

n,k = map(int,input().split())
mod = 10**9 + 7

for i in range(k):
    print(comb(k-1,i,exact=True) * comb(n-k+1,i+1,exact=True) % mod)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

n,k = map(int,input().split())
mod = 10**9 + 7

for i in range(k):
    print(comb(k-1,i,exact=True) * comb(n-k+1,i+1,exact=True) % mod)
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split(" "))
a=[0] * (n+1)
mod = 10 ** 9 + 7
for i in range(m):
    a[int(input())] = 1

dp = [0] * (n+1)
for j in range(n+1):
    if a[j] == 1:
        dp[j] = 0
    elif j == 1 or j == 0:
        dp[j] = 1
    else:
        dp[j] = (dp[j-1] + dp[j-2]) % mod

print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split(" "))
a=[]
ans = 1
for i in range(m):
    a.append(int(input()))
    if a[i]-1 == a[i-1]:
        ans = 0
if ans == 1:
    t,w,v = 0,0,0
    for j in range(len(a)):
        if j+1 == m:
            if n-a[j] >= 3:
                v += 1
                w += n-a[j]
            break
        elif a[j] - t >= 3:
            v += 1
            w += a[j] - t
            t = a[j] + 1
        else:
            t = a[j] + 1
ans = v * 2
t = ans // 2
for k in range(w):
    temp = ans
    ans += t
    t = temp

print(ans % 1000000007)
Problem p03072 (python)

Fixed submission:
n = int(input())
mountain = [ int(s) for s in input().split(" ")]
ans = 0
highest = 0

for m in mountain:
    if m >= highest:
        ans += 1
        highest = m

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
mountain = [ s for s in input().split(" ")]
highest = 0
ans = 0

for m in mountain:
  if m >= highest:
    ans += 1
    highest = m

print(ans)
Problem p02793 (python)

Fixed submission:
import fractions

MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
u = sorted(set(a))
if len(u) == 1:
    print(n)
    exit()
else:
    g = 1
    for x in u:
        g = (g * x) // fractions.gcd(g, x)
    b = 0
    for i in range(n):
        b = b + (g // a[i])
print(b%MOD)

Buggy submission (verdict: Runtime Error):
import math

MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
u = sorted(set(a))
if len(u) == 1:
    print(n)
    exit()
else:
    g = 1
    for x in u:
        g = (g * x) // math.gcd(g, x)
    b = 0
    for i in range(n):
        b = b + (g // a[i])
print(b%MOD)

Buggy submission (verdict: Runtime Error):
import math

MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
u = set(a)
if len(u) == 1:
    print(n)
    exit()
else:
    g = 1
    for x in u:
        g = g * x // math.gcd(g, x)
    b = 0
    for i in range(n):
        b = b + (g // a[i])
print(b%MOD)
Problem p02819 (python)

Fixed submission:
def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

if __name__ == '__main__':
    n = int(input())
    while not is_prime(n):
        n += 1
    print(n)

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

if n != 2:
    if n % 2 == 0:
        n += 1
    while not is_prime(n):
        n += 2
    print(n)
else:
    print(n)

def is_prime(q):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in xrange(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

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

if n % 2 == 0:
    n += 1
while not is_prime(n):
    n += 2
print(n)

def is_prime(q):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in xrange(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

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

if n != 2:
    if n % 2 == 0:
        n += 1
    while not is_prime(n):
        n += 2
    print(n)
else:
    print(n)

def is_prime(q):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

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

if n != 2:
    if n % 2 == 0:
        n += 1
    for p in range(n, 10**5, 2):
        if is_prime(p):
            print(p)
            break
else:
    print(n)

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
Problem p02833 (python)

Fixed submission:
n = int(input())

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
total_breaks = 0
position = 0
for i in range(1, n + 1):
    try:
        breaks = a[position::].index(i)
        total_breaks += breaks
        position = position + breaks + 1
    except ValueError:
        if position == 0:
            total_breaks = -1
            break
        else:
            total_breaks = total_breaks + n - position
            break
print(total_breaks)
Problem p02831 (python)

Fixed submission:
A, B = map(int,input().split())
import fractions
def lcm(A,B):
    return (A * B) // fractions.gcd(A, B)
print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())
import math
def lcm(A,B):
    return (A * B) // math.gcd(A, B)
print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())
import math
g = math.gcd(A,B)
l = A * B // g
print(l)
Problem p02833 (python)

Fixed submission:
N = int(input())

if N%2:
  print("0")
else:
  ans = 0
  i = 1
  while True:
    ans += N // (10*i)
    i *= 5
    if i > N:break
  print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N%2:
  print("0")
else:
  ans = 0
  i = 1
  while True:
    ans += N // (10*i)
    i *= 5
    if i > N:break
      
print(ans)
Problem p02915 (python)

Fixed submission:
n = int(input())
print(n**3)

Buggy submission (verdict: Runtime Error):
n = int(inupt())
print(n**3)
Problem p02987 (python)

Fixed submission:
s = [i for i in input()]
s.sort()
if s[0]==s[1] and s[2]==s[3] and len(set(s)) != 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
s.sort()
if s[0]==s[1] and s[2]==s[3]:
  print("Yes")
else:
  print("No")
Problem p03011 (python)

Fixed submission:
p,q,r = map(int,input().split())
print(min(p+q,p+r,q+r))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
a = [int(input()) for i in range(M)]
dp = [0 for i in range(N+1)]
dp[0] = 1
dp[1] = 1
for i in range(2,N+1):
  if (i-2 in a) and (i-1 in a):
    dp[-1] = 0
    break
  elif i-2 in a:
    dp[i] = dp[i-1]
  elif i-1 in a:
    dp[i] = dp[i-2]
  else:
    dp[i] = dp[i-1] + dp[i-2]

print(dp[-1]%(7+10**9))
Problem p03013 (python)

Fixed submission:
N, M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0 for i in range(N+1)]
dp[0] = 1
dp[1] = 1
for i in range(2,N+1):
  if (i-2 in a) and (i-1 in a):
    dp[-1] = 0
    break
  elif i-2 in a:
    dp[i] = dp[i-1]
  elif i-1 in a:
    dp[i] = dp[i-2]
  else:
    dp[i] = dp[i-1] + dp[i-2]

print(dp[-1]%(7+10**9))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
a = [int(input()) for i in range(M)]
dp = [0 for i in range(N+1)]
dp[0] = 1
dp[1] = 1
for i in range(2,N+1)
  if (i-2 in a) and (i-1 in a):
    dp[-1] = 0
    break
  elif i-2 in a:
    dp[i] = dp[i-1]
  elif i-1 in a:
    dp[i] = dp[i-2]
  else:
    dp[i] = dp[i-1] + dp[i-2]

print(dp[-1]%(7+10**9))
Problem p02836 (python)

Fixed submission:
S = input()
print(len([True for i in range(len(S)//2) if S[i] != S[-1-i]]))

Buggy submission (verdict: Runtime Error):
S = input()
print(len([True for s in range(len(S)//2) if S[i] != S[-1-i]]))
Problem p03012 (python)

Fixed submission:
N = int(input())
W = list(map(int, input().split()))
print(min([abs(sum(W[:i]) - sum(W[i:])) for i in range(N)]))

Buggy submission (verdict: Runtime Error):
N = input()
W = list(map(int, input().split()))
print(min([abs(sum(W[:i]) - sum(W[i:])) for i in range(N)]))