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

Fixed submission:
n,a,b= list(map(int, input().split()))
if a>b:
    print("0")
    exit(0)
if n==1:
    if a!=b:
        print("0")
    else:
        print("1")
    exit(0)
n-=2;b-=a;a=0
print(b*n+1)

Buggy submission (verdict: Runtime Error):
n,a,b= list(map(int, input().split()))
if a>b:
    print("0")
    exit(0)
else n==1:
    if a!=b:
        print("0")
    else:
        print("1")
    exit(0)
n-=2;b-=a;a=0
if n>=b:
    print(b*n+1)
Problem p02577 (python)

Fixed submission:
n=[int(i) for i in input().split()]
 
if sum(n)%9==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=[int(i) for i in input().split()]

if sum(n)%9==0:
  print("Yes)
else:
  print("No")
Problem p02659 (python)

Fixed submission:
a,b=[i for i in input().split()]

a=int(a)
b=round(float(b)*100)

print(a*b//100)

Buggy submission (verdict: Runtime Error):
import math
a,b=[i for i in input().split()]

a=int(a)
b=int(b*100)

print(math.floor(a*b/100))

Buggy submission (verdict: Runtime Error):
a,b=[int(i) for i in input().split()]a,b=[float(i) for i in input().split()]

print(int(a*b))
Problem p02773 (python)

Fixed submission:
n=int(input())

candidates={}
for i in range(n):
    candidate=input()
    if candidate in candidates:
        candidates[candidate]+=1
    else:
        candidates[candidate]=1

max_k_list = []
maxvalue=max(candidates.values())
for candidate in candidates:
    if candidates[candidate]==maxvalue:
        max_k_list.append(candidate)


max_k_list.sort()
for i in max_k_list:
    print(i)

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

s=[]
for i in range(n):
    s.append(input())
k=s.copy()   
candidates=list(set(k))

maxnum=0
for candidate in candidates:
    maxnum=max(maxnum,s.count(candidate))
    
ans=[]
for candidate in candidates:
    if s.count(candidate)==maxnum:
        ans.append(candidate)
ans.sort()


for i in ans:
    print(i)
Problem p02792 (python)

Fixed submission:
n = int(input())

graph = [[0] * 9 for i in range(9)]

for i in range(1, n + 1):
    if i % 10 != 0:
        i = str(i)
        sentou = int(i[0])
        matubi = int(i[-1])
        graph[sentou - 1][matubi - 1] += 1

import numpy as np

graph = np.array(graph)

print(np.trace(np.dot(graph, graph)))

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

graph = [[0] * 9 for i in range(9)]

for i in range(1, n + 1):
    if i % 10 != 0:
        i = str(i)
        sentou = int(i[0])
        matubi = int(i[-1])
        graph[sentou - 1][matubi - 1] += 1

import numpy as np

graph = np.array(graph)

print(np.trace(np.dot(graph, graph)))

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





graph=[[0]*9 for i in range(9)]

for i in range(1,n+1):
    if i%10!=0:
        i=str(i)
        sentou=int(i[0])
        matubi=int(i[-1])
        graph[sentou-1][matubi-1]+=1


import numpy as np

graph=np.array(graph)

print(np.trace(np.dot(graph,graph)))
Problem p02831 (python)

Fixed submission:
import sys
sys.setrecursionlimit(20000000)
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

a,b=[int(i) for i in input().split()]

print(a*b//gcd(a,b))

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


a,b=[int(i) for i in input().split()]

print(a*b//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(20000000)


a,b=[int(i) for i in input().split()]
import math
print(a*b//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(20000000)


a,b=[int(i) for i in input().split()]
import math
print(a*b//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import sys

sys.sys.setrecursionlimit(20000000)


a,b=[int(i) for i in input().split()]
import math
print(a*b//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
a,b=[int(i) for i in input().split()]
import math
print(a*b//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math

a,b=[int(i) for i in input().split()]
print(math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
a,b=[int(i) for i in input().split()]
import math
print(a*b//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
a,b=[int(i) for i in input().split()]
import math
print(a*b//math.gcd(a,b))
Problem p02833 (python)

Fixed submission:
n=input()
m=len(n)
n=int(n)

if n%2==1:
    print(0)
else:
    if m==1:
        print(0)
    else:
        ans=0
        i=1
        while True:
            ans_plus=n//(2*5**i)
            if ans_plus==0:
                break
            ans+=ans_plus

            i+=1
        print(ans)

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

if n%2==1:
    print(0)
else:
    if m==1:
        print(0)
    else:
        ans=0
        i=1
        while True:
            ans_plus=n//(2*5**i)
            if ans_plus==0:
                break
            ans+=ans_plus

            i+=1
    print(ans)

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

if n%2==1:
    print(0)
else:
    if m==1:
        print(0)
    else:
        ans=0
        i=1
        while True:
            ans_plus=n//(2*5**i)
            if ans_plus==0:
                break
            ans+=ans_plus

            i+=1
print(ans)
Problem p02862 (python)

Fixed submission:
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 = 10**9+7 #出力の制限
N = 10**6
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 )

    
x,y=[int(i) for i in input().split()]

m=1000000007

    

if y<=2*x  and x<=2*y and (2*x-y)%3==0 and (2*y-x)%3==0:
    a=(2*y-x)//3
    b=(2*x-y)//3
    
    print(cmb(a+b,b,m))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math


x,y=(int(i) for i in input().split())

l=10**9+7
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)
        
    

#そもそもマスに進めることができないとき
if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print(0)
    
    
#マスへ進められるとき
else:
    a=(2*y-x)//3
    b=(2*x-y)//3
    
    # a+b C aを計算
    up=1
    down=1
    print(permutations_count(a+b,a)%l)
Problem p02912 (python)

Fixed submission:
import heapq
n,m=[int(i) for i in input().split()]
a=[-1*int(i) for i in input().split()]
heapq.heapify(a)
for i in range(m):
    b=heapq.heappop(a)
    b=b/2
    heapq.heappush(a,b)
ans=0
for i in a:
    ans-=int(i)
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
n,m=[int(i) for i in input().split()]
a=[-int(i) for i in input().split()]
for i in range(m):
    heapq.heapify(a)
    b=heapq.heappop(a)
    b=b/2
    heapq.heappush(a,b)
ans=0
for i in c:
    ans-=int(i)
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
n,m=[int(i) for i in input().split()]
a=[-int(i) for i in input().split()]
for i in range(m):
    heapq.heapify(a)
    b=heapq.heappop(a)
    b=b/2
    heapq.heappush(a,b)
ans=0
for i in c:
    ans-=int(i)
print(ans)
Problem p02916 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=sum(b)
pre=0
for i in range(n):
    tabeta=a[i]
    if tabeta==pre+1 and i!=0:
        ans+=c[pre-1]
    pre=tabeta
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=sum(b)
pre=None
for i in range(n):
    tabeta=a[i]
    if tabeta==pre+1:
        ans+=c[pre-1]
    pre=tabeta
print(ans)
Problem p02987 (python)

Fixed submission:
word=input()
listword=list(word)
listword.sort()

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

Buggy submission (verdict: Runtime Error):
word=input()
listword=list(word)
listword.sort()
print(listword)
if listword[0]==listword[1] and listword[2]==listword[3] and list[0]!=list[3]:
    print("Yes")
else:
    print("No")
Problem p03013 (python)

Fixed submission:
n,m=[int(i) for i in input().split()]
badone=[int(input()) for i in range(m)]
badstares=[1 for i in range(n)]
for i in badone:
    badstares[i-1]=0


stares=[-1 for i in range(n)]
if n==1:
    print(1)
else:
    for i in range(n):

        i=n-1-i
        if i==n-1:
            stares[i]=1
        elif i==n-2:
            if badstares[i]==0:
                stares[i]=-1
            else:
                stares[i]=1
        else:
            if badstares[i]==0:
                stares[i]=-1
            else:
                if stares[i+1]==-1 and stares[i+2]==-1:
                        stares[i]=-1
                elif stares[i+1]==-1 and stares[i+2]!=-1:
                        stares[i]=stares[i+2]
                elif stares[i+2]==-1:
                    stares[i]=stares[i+1]
                else:
                    stares[i]=stares[i+1]+stares[i+2]

    if stares[0]==-1 and stares[1]==-1:
        print(0)
    elif stares[0]==-1:
        print(stares[1]%1000000007)
    elif stares[1]==-1:
        print(stares[0]%1000000007)
    else:
        print((stares[0]+stares[1])%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
badone=[int(input()) for i in range(m)]
badstares=[1 for i in range(n)]
for i in badone:
    badstares[i-1]=0


stares=[-1 for i in range(n)]
for i in range(n):
    
    i=n-1-i
    if i==n-1:
        stares[i]=1
    elif i==n-2:
        if badstares[i]==0:
            stares[i]=-1
        else:
            stares[i]=1
    else:
        if badstares[i]==0:
            stares[i]=-1
        else:
            if stares[i+1]==-1 and stares[i+2]==-1:
                    stares[i]=-1
            elif stares[i+1]==-1 and stares[i+2]!=-1:
                    stares[i]=stares[i+2]
            elif stares[i+2]==-1:
                stares[i]=stares[i+1]
            else:
                stares[i]=stares[i+1]+stares[i+2]
    
if stares[0]==-1 and stares[1]==-1:
    print(0)
elif stares[0]==-1:
    print(stares[1]%1000000007)
elif stares[1]==-1:
    print(stares[0]%1000000007)
else:
    print((stares[0]+stares[1])%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
badone=[int(input()) for i in range(m)]
badstares=[1 for i in range(n)]
for i in badone:
    badstares[i-1]=0


stares=[-1 for i in range(n)]
for i in range(n):
    
    i=n-1-i
    if i==n-1:
        stares[i]=1
    elif i==n-2:
        if badstares[i]==0:
            stares[i]=-1
        else:
            stares[i]=1
    else:
        if badstares[i]==0:
            stares[i]=-1
        else:
            if stares[i+1]==-1:
                if stares[i+2]==-1:
                    stares[i]=-1
                else:
                    stares[i]=stares[i+2]
            elif stares[i+2]==-1:
                stares[i]=stares[i+1]
            else:
                stares[i]=stares[i+1]+stares[i+2]
    
print(max(stares[0]+stares[1],0)%1000000007)
Problem p02549 (python)

Fixed submission:
def solve(l, r, i):
    if i - l < 1:
        return 0
    return dp[i - l] - dp[max(i - r - 1, 0)]


n, k = map(int, input().split())
MOD = 998244353
lr = [list(map(int, input().split())) for _ in range(k)]

dp = [0] * (n + 1)
dp[1] = 1

for i in range(2, n + 1):
    tmp = 0
    for l, r in lr:
        tmp += solve(l, r, i)
    tmp = tmp % MOD
    dp[i] = (dp[i - 1] + tmp) % MOD

print(tmp)

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

lr = []
for _ in range(k):
    l, r = map(int, input().split())
    lr += (list(range(l, r + 1)))

lr.sort()
lr = np.array(lr)

dp = np.zeros(n + n, dtype=np.int64)
dp[0] = 1
dp2 = dp.copy()

for i in range(n):
    idx = i + lr
    dp2[idx] += dp[i]
    dp2 %= MOD
    dp = dp2

print(dp[n - 1])
Problem p02572 (python)

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

MOD = 10**9 + 7

ans = 0
sum_arr = sum(arr)

for x in arr:
    sum_arr -= x
    ans += x * sum_arr
    ans %= MOD

print(ans)

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

ans = 0
sum_arr = sum(arr)

for x in arr:
    ans += x * (sum_arr - x) // 2
    ans %= MOD

print(ans)
Problem p02580 (python)

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

h_max = max(h)
w_max = max(w)

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

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

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

h = np.zeros(H + 1, np.int64)
w = np.zeros(W + 1, np.int64)
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x] += 1
    w[y] += 1
    boms.add((x, y))

h_max = h.max()
w_max = w.max()

h_idx = np.where(h == h_max)[0]
w_idx = np.where(w == w_max)[0]


@njit
def solve(h_max, w_max, boms):
    minus = -1
    for x in h_idx:
        for y in w_idx:
            if (x, y) in boms:
                minus = 0
                break
    return h_max + w_max + max(minus)


print(solve(h_max, w_max, boms))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

h_max = max(h)
w_max = max(w)

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_idx + minus)

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

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

h = []
w = []
for _ in range(M):
    x, y = map(int, input().split())
    h.append(x)
    w.append(y)

ch = Counter(h)
cw = Counter(w)

h_max = max(ch.values())
w_max = max(cw.values())

h_idx = [x for (x, y) in ch.items() if y == h_max]
w_idx = [x for (x, y) in cw.items() if y == w_max]

boms = set([(x, y) for x, y in zip(h, w)])

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)

print(h_max + w_max + max(minus))

Buggy submission (verdict: Runtime Error):
from numba import njit

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

arr = []
for _ in range(M):
    h, w = map(int, input().split())
    arr.append((h, w))


@njit
def solve(arr):
    ans = 0
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            tmp = max(ans, sum([x == i or y == j for (x, y) in arr]))
            if ans < tmp:
                ans = tmp
    return ans


print(solve(arr))
Problem p02598 (python)

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

l = 0
r = max(arr)

while l + 1 < r:
    m = (l + r) // 2

    cut = 0
    for x in arr:
        cut += (x - 1) // m

    if cut > k:
        l = m
    else:
        r = m

print(r)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
arr = np.array(list(map(int, input().split())))

l = 1
r = max(arr)

while l + 1 < r:
    m = (l + r) // 2

    cut = 0
    for x in arr:
        cut += (x - 1) // m

    if cut > k:
        l = m
    else:
        r = m

print(r)
Problem p02695 (python)

Fixed submission:
import itertools

n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

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

A = list(itertools.combinations_with_replacement(range(1, m + 1), n))

cnt = 0

for i in range(len(A)):
    tmp = 0
    for j in range(q):
        if(A[i][b[j]-1] - A[i][a[j]-1]) == c[j]:
            tmp = tmp + d[j]
    cnt = max(cnt, tmp)
print(cnt)

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

n, m, q = map(int, input().split())
a = np.zeros(q, type=int)
b = np.zeros(q, type=int)
c = np.zeros(q, type=int)
d = np.zeros(q, type=int)

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

A = np.array(list(itertools.combinations_with_replacement(range(1, m + 1), n)))

cnt = 0

for i in range(len(A)):
    tmp = 0
    for j in range(q):
        if(A[i][b[j]-1] - A[i][a[j]-1]) == c[j]:
            tmp = tmp + d[j]
    cnt = max(cnt, tmp)
print(cnt)

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

n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

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

A = np.array(list(itertools.combinations_with_replacement(range(1, m + 1), n)))

cnt = 0

for i in range(len(A)):
    tmp = 0
    for j in range(q):
        if(A[i][b[j]-1] - A[i][a[j]-1]) == c[j]:
            tmp = tmp + d[j]
    cnt = max(cnt, tmp)
print(cnt)

Buggy submission (verdict: Runtime Error):
n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

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

A = []
tmp = []
for i in range(1, m+1):
    for j in range(i, m+1):
        for k in range(j, m+1):
            A.append([i, j, k])

cnt = 0

for i in range(len(A)):
    tmp = 0
    for j in range(q):
        if(A[i][b[j]-1] - A[i][a[j]-1]) == c[j]:
            tmp = tmp + d[j]
    cnt = max(cnt, tmp)
print(cnt)
Problem p02699 (python)

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

Buggy submission (verdict: Runtime Error):
s = input()[::-1]
length = len(s)
a = [0] * length
d = [0] * length
ans = [0] * 2019
x = 10

a[0] = int(s[0])
d[0] = a[0]
ans[d[0]] += 1

for i in range(1, length):
    a[i] = int(s[i]) * x % 2019
    d[i] = (d[i-1] + a[i]) % 2019
    ans[d[i]] += 1
    x = x * 10 % 2019

print(int(sum([ans[i] * (ans[i]-1) for i in range(2019)]) / 2) + ans[0])

Buggy submission (verdict: Runtime Error):
s, w = map(int, input())
print("unsafe" if s <= w else "safe")
Problem p02712 (python)

Fixed submission:
import numpy as np
a = np.array([i for i in range(1, int(input())+1)])
print(a[np.where((a % 3 != 0) & (a % 5 !=0))].sum())

Buggy submission (verdict: Runtime Error):
import numpy
a = np.array([i for i in range(1, int(input())+1)])
print(a[np.where((a % 3 != 0) & (a % 5 !=0))].sum())
Problem p02725 (python)

Fixed submission:
import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().split())))
a1 = np.zeros(1, dtype=int)
a1 = np.append(a1, a)
a2 = a
a2 = np.append(a2, a[0]+k)
print(k - max(a2[1:] - a1[1:]))

Buggy submission (verdict: Runtime Error):
import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().split())))
print(max(abs(a1 - a2)))

Buggy submission (verdict: Runtime Error):
import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().split())))
print(max(abs(a1 - a2)))
Problem p02754 (python)

Fixed submission:
n, a, b = map(int, input().split())
q, m = divmod(n, a+b)
print(a * q + min(m, a))

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
a = math.ceil(a / 0.08)
b = math.ceil(b / 0.1)
tmp_a = set([i for i in range(a, a+13)])
tmp_b = set([i for i in range(b, b+10)])
if len(tmp_a & tmp_b) == 0:
    print(-1)
else:
    print(min(tmp_a & tmp_b))
Problem p02759 (python)

Fixed submission:
import math
print(math.ceil(int(input())/2))

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


class UnionFind:
    def __init__(self, n):
        self.root = list(range(n + 1))
        self.size = [1] * (n + 1)

    def find(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy


n, m, k = map(int, input().split())


uf = UnionFind(n)

friends = defaultdict(int)
chain = defaultdict(int)

for _ in range(m):
    a, b = map(int, input().split())
    friends[a] += 1
    friends[b] += 1
    uf.union(a, b)

for i in range(1, n + 1):
    for j in range(1, n + 1):
        if uf.find(i) == uf.find(j):
            chain[i] += 1

for _ in range(k):
    c, d = map(int, input().split())
    if uf.find(c) == uf.find(d):
        friends[c] += 1
        friends[d] += 1

ans = []
for i in range(1, n + 1):
    ans.append(chain[i] - friends[i] - 1)

print(*ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
s = [0] * m
c = [0] * m
tmp = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())
    
for x, y in zip(s, c):
    if tmp[x-1]==0:
        tmp[x-1] = y
    elif tmp[x-1]==y:
        continue
    else:
        print(-1)
        exit()

ans = 0

for i, a in enumerate(tmp[::-1]):
    ans += a*10**(i)

if n==1 & ans==0:
    print(ans)
elif ans // 10**(m-1) < 1:
    print(-1)
    exit()
    
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
n, m = map(int, input().split())
S = [0] * m
C = [0] * m
tmp = [0] * n

for i in range(m):
    S[i], C[i] = map(int, input().split())

for s, c in zip(S, C):
    if tmp[s-1] == 0:
        tmp[s-1] = c
    elif tmp[s-1] == c:
        pass
    else:
        print(-1)
        sys.exit()

ans = 0
for i, a in enumerate(tmp[::-1]):
    ans += a*10**(i)

print(ans)
Problem p02777 (python)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()

if s==u:
    a = a-1
if t==u:
    b = b-1

print(a, b)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate

N, K = map(int, input().split())
p = list(map(int, input().split()))

p = list(accumulate(p))

ans = 0
for i in range(N - K):
    ans = max(ans, p[i + K]-p[i])

ans = (ans + K) / 2

print(ans)
Problem p02831 (python)

Fixed submission:
def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

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

print(a*b // gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))
Problem p02833 (python)

Fixed submission:
n = int(input())

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

    print(ans)

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

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

print(ans)

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

if n % 2 == 1:
    print(0)
else:
    a = 10
    coef = 5
    cnt = 0
    ans = 0
    while a*coef**cnt <= n:
        ans += n // (a*coef**cnt)
        cnt += 1

print(ans)