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

Fixed submission:
import sys

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

ans = 0

if 10 % P == 0:
    for r in range(len(A)):
        if int(A[r]) % P == 0:
            ans += r + 1
    print(ans)
    sys.exit()


A = "0" + A[::-1]

S = [0] * len(A)
cnt = [0] * P
cnt[0] = 1

for i in range(len(A) - 1):
    S[i + 1] = (S[i] + int(A[i + 1]) * pow(10, i, P)) % P
    cnt[S[i + 1] % P] += 1
# print(S, cnt)

# ans = cnt[0] * (cnt[0] - 1) // 2
for c in cnt:
    ans += c * (c - 1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
N,P = map(int,input().split())
S=input()
mem_mod = [0 for i in range(0,2019,1)]
counter = 0
S_num = list(map(int, S))
tmp=10

for i in range(1,N,1):
    S_num[N-i-1] = S_num[N-i] + S_num[N-i-1]*pow(10,i,P)

for i in range(0,N,1):
    X = S_num[N-i-1] % P
    if X==0:
        counter+=1
    counter += mem_mod[X]
    mem_mod[X] += 1
print(counter)
Problem p03075 (python)

Fixed submission:
a = [int(input())for i in range(5)]
k = int(input())
print( "Yay!" if max(a)-min(a) <= k else ":(" )

Buggy submission (verdict: Runtime Error):
a = [int(input())for i in range(5)]
k = int(input())
print( "Yay!" if max(a)-min(b) > k else ":(" )
Problem p03104 (python)

Fixed submission:
import sys
import bisect
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

A, B = tuple(li())

def F(num):
    if num == 0:
        return 0
    # there are a pair: (0,1), (2,3)... where xor in every pair is 1
    a = (num + 1) // 2
    ret = 0 if a % 2 == 0 else 1
    ret = ret ^ num if num % 2 == 0 else ret
    return ret
res = F(A - 1) ^ F(B)
print(res)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

A, B = tuple(li())


nums = list(range(A, B + 1))
res = 0
bit = 1
while B:
    cur = 0
    for num in nums:
        temp = num & bit
        cur ^= temp
    res += cur
    bit = bit << 1

    B = B >> 1
print(res)
Problem p03127 (python)

Fixed submission:
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):

    # normal gcd logic
    while B not in (1, 0):
        A, B = (A, B) if A > B else (B, A)
        _, mod = divmod(A, B)
        A, B = B, mod
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)

Buggy submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):
    # fast return
    if B == 1 or A == 1:
        return 1

    # normal gcd logic
    if A != B:
        return gcd(min(A, B), abs(A - B))
    else:
        return A

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)

Buggy submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):
    if A * B <= 0:
        # at least one is positive
        return max(A, B)
    # fast return
    if B == 1 or A == 1:
        return 1

    # normal gcd logic
    if A != B:
        return gcd(min(A, B), abs(A - B))
    else:
        return A

A.sort()
res = A[0]
for a in A:
    if a <= 0:
        continue
    res = gcd(a, res)
    if res == 1:
        break

print(max(res, 0))

Buggy submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):
    if B == 1 or A == 1:
        return 1
    if A > B:
        return gcd(B, A - B)
    elif A < B:
        return gcd(A, B - A)
    else:
        return A

A.sort()
res = A[0]
for a in A:
    res = gcd(a, res)
    if res == 1:
        break
print(res)

Buggy submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):
    if B == 1 or A == 1:
        return 1
    if A > B:
        return gcd(B, A - B)
    elif A < B:
        return gcd(A, B - A)
    else:
        return A

A.sort()
A.append(None)
res = A[0]
for i, a in enumerate(A):
    if not a:
        break
    res = gcd(a, res)
    if res == 1:
        break
print(res)
Problem p03326 (python)

Fixed submission:
from operator import mul
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())
Cs = []
for i in range(N):
    n = tuple(li())
    Cs.append(n)
# state:  x, y, z, point
state = [0, 0, 0, 0]
maximum = 0
trans = []
for per in range(8):
    ops = [1 if (per&4)>>2 else -1, 1 if (per&2)>>1 else -1, 1 if per&1 else -1]
    trans.clear()
    for i in range(N):
        trans.append(list(map(mul, Cs[i], ops)))
    trans.sort(key=lambda x: -sum(x))
    maximum = max(maximum, sum(sum(t) for t in trans[:M]))
        

print(maximum)

Buggy submission (verdict: Runtime Error):
from operator import mul
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())
Cs = []
for i in range(N):
    n = tuple(li())
    Cs.append([-sum(map(abs, n)), n])
# state:  x, y, z, point
state = [0, 0, 0, 0]
maximum = 0
trans = []
for per in range(8):
    ops = [(per&4)>>2, (per&2)>>1, per&1]
    trans.clear()
    for i in range(N):
        trans.append(list(map(mul, Cs[i], ops)))
    tans.sort(key=lambda x: -sum(x))
    maximum = max(maximum, sum(trans[:M]))
        

print(maximum)
Problem p02572 (python)

Fixed submission:
n = int(input())

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

sigma = 0
after = sum(a[0:])
for i in range(len(a)-1):
  start = a[i]
  after = after - a[i]
  sigma = sigma + start * after
  if sigma >= (10**9 + 7):
    sigma = sigma % (10**9+7)

print(sigma)

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

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

sigma = sum(a)
count = 0
for i in range(len(a)-1):
  start = a[i]
  sigma = sigma-a[i]
  count = count + start * 
  if count >= 10**9+7:
    count = count % (10**9+7)

print(count)

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

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

sigma = 0
after = sum(a[0:])
for i in range(len(a)-1):
  start = a[i]
  after = after - [i]
  if after >= (10**9 + 7):
    after = after % (10**9+7)
  sigma = sigma + start * after
  if sigma >= (10**9 + 7):
    sigma = sigma % (10**9+7)

print(sigma)
Problem p02571 (python)

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

mS = []
d = len(S) - len(T)
m = 0

if len(S) == len(T) :
    for i in range(len(T)):
        if S[i] != T[i] :
            m += 1
    print(m)

else :

    for j in range(d):
        m = 0
        for i in range(len(T)):
            if S[i] != T[i] :
                m += 1

        mS.append(m)
        S = S[1:]
    print(min(mS))

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

mS = []
d = len(S) - len(T)


for j in range(d):
    m = 0
    for i in range(len(T)):
        if S[i] != T[i] :
            m += 1

    mS.append(m)
    S = S[1:]
print(min(mS))

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

mS = []
d = len(S) - len(T)

for j in range(d):
    m = 0
    for i in range(len(T)):
        if S[i] == T[i] :
            m += 1

    mS.append(m)
    S = S[1:]
print(len(T) - max(mS))
Problem p02688 (python)

Fixed submission:
N, K = map(int, input().split())
A = []
for i in range(K) :
    d = int(input())
    a = list(map(int, input().split()))
    A += a

print(N - len(set(A)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
d = int(input())
Ax = [list(map(int,input().split())) for i in range(N + K - d)]

print( N - d)
Problem p03329 (python)

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

def count(val1, val2):
    num = 1
    while True:
        if val1 < (val2 ** num):
            break
        num += 1

    cnt = 0
    digit = num
    while True:
        if val1 >= val2 ** digit:
            val1 -= val2 ** digit
            cnt += 1
        else:
            digit -= 1
        
        if digit== 0:
            break

    return cnt,val1


N = int(input())
ans = N

for i in range(0,N+1):
    n = i
    m = N - i
    res = 0

    cnt, nn = count(n, 9)
    n = nn
    res += cnt

    cnt, mm = count(m, 6)
    m = mm
    res += cnt

    res += n + m
    ans = min(ans, res)

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)  # RecursionError対策

def func(n):
    if n==0:
        return 0 # 終端条件
    if memo[n] != -1:
        return memo[n] # 探索済み

    res = n

    for i in range(1,n+1):
        pow6 = 6 ** i
        if pow6 > n:
            break
        res = min(res, func(n-pow6)+1)

    for i in range(1,n+1):
        pow9 = 9 ** i
        if pow9 > n:
            break
        res = min(res, func(n-pow9)+1)

    memo[n] = res
    return res


N = int(input())

max_n = 110000
memo = [-1] * max_n
ans = func(N)
print(ans)

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

def func(n):
    if n==0:
        return 0 # 終端条件
    if memo[n] != -1:
        return memo[n] # 探索済み

    res = n

    for i in range(1,n+1):
        pow6 = 6 ** i
        if pow6 <= n:
            res = min(res, func(n-pow6)+1)
        else:
            break

    for i in range(1,n+1):
        pow9 = 9 ** i
        if pow9 <= n:
            res = min(res, func(n-pow9)+1)
        else:
            break

    memo[n] = res
    return res


N = int(input())

max_n = 110000
memo = [-1] * max_n
ans = func(N)
print(ans)
Problem p02547 (python)

Fixed submission:
#B
N=int(input())
cnt=0
flag=False
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag=True
        break
if flag:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#B
N=int(input())
cnt=0
flag=False
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt=3:
        flag=True
        break
if flag:
    print("Yes")
else:
    print("No")
Problem p02831 (python)

Fixed submission:
#C
A,B=map(int,input().split())
GCD=1
for i in range(2,10**5+1):
    if A%i==0 and B%i==0:
        GCD=i

LCM=A*B/GCD
print(int(LCM))

Buggy submission (verdict: Runtime Error):
#C
from math import gcd
A,B=map(int,input().split())
LCM=A*B/gcd(A,B)
print(int(LCM))
Problem p02834 (python)

Fixed submission:
from collections import deque

INF = 1000000
N,T,A=map(int,input().split())
T -= 1
A -= 1
G = [ [] for i in range(N) ]
DT = [ INF for _ in range(N) ]
DA = [ INF for _ in range(N) ]
for i in range(N-1):
    h1,h2=map(int,input().split())
    h1 -= 1
    h2 -= 1
    G[h1].append(h2);
    G[h2].append(h1);

DT[T] = 0
DA[A] = 0

q = deque()

# BFS
q.append(T)
while len(q) > 0:
    v = q.popleft()
    for nv in G[v]:
        if DT[nv] == INF:
            DT[nv] = DT[v] + 1
            q.append(nv)

q.clear()
q.append(A)
while len(q) > 0:
    v = q.popleft()
    for nv in G[v]:
        if DA[nv] == INF:
            DA[nv] = DA[v] + 1
            q.append(nv)

max_da = 0
for i in range(N):
    #print(i, " T:", DT[i], " A:", DA[i])
    if DA[i] - DT[i] >= 1 :
        max_da = max(DA[i], max_da)
print(max_da-1)

Buggy submission (verdict: Runtime Error):
INF = 1000000
N,T,A=map(int,input().split())
T -= 1
A -= 1
G = [ [] for i in range(N) ]
DT = [ INF for _ in range(N) ]
DA = [ INF for _ in range(N) ]
for i in range(N-1):
    h1,h2=map(int,input().split())
    h1 -= 1
    h2 -= 1
    G[h1].append(h2);
    G[h2].append(h1);

def DFS_T( v, d ):
    for nv in G[v]:
        if DT[nv] != INF:
            continue
        DT[nv] = d + 1
        DFS_T(nv, d + 1)

def DFS_A( v, d ):
    for nv in G[v]:
        if DA[nv] != INF:
            continue
        DA[nv] = d + 1
        DFS_A(nv, d+1)

DT[T] = 0
DA[A] = 0
DFS_T(T,0)
DFS_A(A,0)
max_da = 0
for i in range(N):
    #print(i, " T:", DT[i], " A:", DA[i])
    if DA[i] - DT[i] >= 1 :
        max_da = max(DA[i]-1, max_da)
print(max_da)

Buggy submission (verdict: Runtime Error):
INF = 1000000
N,T,A=map(int,input().split())
T -= 1
A -= 1
G = [ [] for i in range(N) ]
DT = [ INF for _ in range(N) ]
DA = [ INF for _ in range(N) ]
for i in range(N-1):
    h1,h2=map(int,input().split())
    h1 -= 1
    h2 -= 1
    G[h1].append(h2);
    G[h2].append(h1);

def DFS_T( v, d ):
    for nv in G[v]:
        if DT[nv] != INF:
            continue
        DT[nv] = d + 1
        DFS_T(nv, d + 1)

def DFS_A( v, d ):
    for nv in G[v]:
        if DA[nv] != INF:
            continue
        DA[nv] = d + 1
        DFS_A(nv, d+1)

DT[T] = 0
DA[A] = 0
DFS_T(T,0)
DFS_A(A,0)
max_da = 0
for i in range(N):
    #print(i, " T:", DT[i], " A:", DA[i])
    if DA[i] - DT[i] >= 1 :
        max_da = max(DA[i], max_da)
print(max_da-1)
Problem p02836 (python)

Fixed submission:
S=input()
slen = len(S)
slen2 = slen // 2
ans=0
for i in range (slen2):
  if S[i] != S[-i-1]:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
slen = len(S)
slen2 = slen // 2
ans=0
for i in range slen2:
  if S[i] != S[-i]:
    ans += 1
print(ans)
Problem p03242 (python)

Fixed submission:
S=input()
S = S.replace("1", "Z")
S = S.replace("9", "1")
S = S.replace("Z", "9")
print(S)

Buggy submission (verdict: Runtime Error):
S=input()
for i in range(3):
  if S[i]=='1':
    S[i] = '9'
  elif S[i]=='9':
    S[i] = '1'
print(S)
Problem p02711 (python)

Fixed submission:
N=input()
a=int(N[0])
b=int(N[1])
c=int(N[2])
 
if a==7 or b==7 or c==7:
  print('Yes')
else :
  print('No')

Buggy submission (verdict: Runtime Error):
N=input()
a=int(N[0])
b=int(N[1])
c=int(N[2])

if a=7 or b=7 or c=7:
  print('Yes')
else :
  print('No')
Problem p02571 (python)

Fixed submission:
s = input()
t = input()
n, m = len(s), len(t)
print(min(sum(si != ti for si, ti in zip(s[i: i+m], t)) for i in range(n-m+1)))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
n, m = len(s), len(t)
print(min(sum(si != ti for si, ti in zip(s[i: i+m], t)) for i in range(n-m)))
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())
print(a*b if (0<a<10) & (0<b<10) else -1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(a＊b if 0<a<10 & 0<b<10 else -1)
Problem p02884 (python)

Fixed submission:
# reference: https://www.onakasuitacity.com/abc144-f/

import numpy as np

n, m = map(int, input().split())
outgoing = [[] for _ in range(n)]
incoming = [[] for _ in range(n)]
for _ in range(m):
    si, ti = map(int, input().split())
    outgoing[si-1].append(ti-1)
    incoming[ti-1].append(si-1)


ex_dp = np.zeros(n)
for v in reversed(range(n-1)):   # O(m)
    outgoing_degree = len(outgoing[v])
    ex_dp[v] = 1 + sum(ex_dp[post] for post in outgoing[v])/outgoing_degree if outgoing_degree!=0 else np.inf

p_dp = np.ones(n)
for v in range(1,n):      # O(m)
    p_dp[v] = sum(p_dp[prev]/len(outgoing[prev]) for prev in incoming[v])

min_ex = ex_dp[0]
for v, posts in enumerate(outgoing):      # O(m)
    outgoing_degree = len(outgoing[v])
    if outgoing_degree <= 1:
        continue

    max_post = max(posts, key= lambda pos: ex_dp[pos])
    diff_v_ex = 0
    for w in posts:
        if w == max_post:
            diff_v_ex -= 1/outgoing_degree * ex_dp[w]
        else:
            diff_v_ex += 1/(outgoing_degree*(outgoing_degree-1)) * ex_dp[w]
    min_ex = min(ex_dp[0] + p_dp[v] * diff_v_ex, min_ex)

print(min_ex)

Buggy submission (verdict: Runtime Error):
import copy
import numpy as np
from scipy.sparse import csr_matrix

def openinput():
    n, m = map(int, input().split())
    s ,t = [], []
    for _ in range(m):
        si, ti = map(int, input().split())
        s.append(si - 1)
        t.append(ti - 1)
    return n, m, s, t

def make_adjacency_matrix(weights, edges, num_of_nodes):
    return csr_matrix((weights, edges), shape=(num_of_nodes, num_of_nodes)).toarray()

def edit_mat(mat, weight, edge_from, edge_to):
    copied = copy.deepcopy(mat)
    copied[edge_from, edge_to] = weight
    return copied

def depth_first_search(mat, start_node):
    to_visit = [(start_node, 0, 1.0)]    # (node, depth, expected_value)
    depth_expecteds = []  # expected value of path length from 0 to n-1
    while to_visit:
        visit, depth, expected = to_visit.pop()
        if visit == n-1:
            depth_expecteds.append(depth * expected)
        else:
            nexts = [v for v, c in enumerate(mat[visit]) if c > 0]
            if nexts:
                for next in nexts:
                    to_visit.append((next, depth+1, expected/len(nexts)))
            else:   # leaf node but not n
                depth_expecteds.append(np.inf)
    return sum(depth_expecteds)





if __name__ == "__main__":
    n, m, s, t = openinput()
    adjacency_matrix = make_adjacency_matrix([1]*m, (s,t), n)

    rawcols = np.where(adjacency_matrix == 1)
    expecteds = []
    for r, c in zip(rawcols[0], rawcols[1]):
        mat = edit_mat(adjacency_matrix, 0, r, c)
        expecteds.append(depth_first_search(mat, 0))

    min_expected = np.min(expecteds)
    if np.isinf(min_expected):
        print(depth_first_search(adjacency_matrix, 0))
    else:
        print(min_expected)
Problem p02723 (python)

Fixed submission:
from sys import stdin
import math
inp = lambda : stdin.readline().strip()

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

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
inp = lambda : stdin.readline().strip()

t = int(inp())
for _ in range(t):
    s = inp()
    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No")
Problem p02682 (python)

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


if A >= K:
    print(K)
elif A+B >=K:
    print(A)
else:
    print(A+(A+B-K))

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


if A >= K:
    print(K)
elif A+B >=K:
    print(A)
else:
    print(A-1*(A+B-k))

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

sum = 0
li = [1] * A
Bli = [0] * B
Cli = [-1] * C

li.extend(Bli)
li.extend(Cli)

for k in range(K):
    sum = sum + li[k]

print(sum)
Problem p02578 (python)

Fixed submission:
def main():
  n = int(input())
  As = list(map(int, input().split()))
  r = 0
  max_a = 0
  for i in range(n):
    max_a = max(max_a, As[i])
    r += max_a - As[i]
  print(r)

main()

Buggy submission (verdict: Runtime Error):
from numpy import max
from array import array
def main():
  n = int(input())
  As = list(map(int, input().split()))
  r = 0
  max_a = max(array('L', As))
  for i in range(n-1, 0, -1):
    if i == 0:
      break
    if As[i] < As[i-1]:
      if(max_a not in As[0:i-1]):
        max_a = As[i-1]
      r += max_a - As[i]
  print(r)

main()
Problem p02707 (python)

Fixed submission:
n = int(input())
As = list(map(int, input().split()))
 
x = [0] * n
for i in As:
    x[i-1] += 1
for y in x:
    print(y)

Buggy submission (verdict: Runtime Error):
N = int(input())
As = list(map(int, input().split()))
sort_as = sorted(As)
shine = [x + 1 for x in range(N)]
c = 0
s = 0
j = 0
for x in range(N):
  if len(As) == 0:
    print(0)
    continue
  for y in range(len(As)):
    if shine[x] == As[y]:
      c += 1
  print(c)
  c = 0
  if len(As) != 0:
    As.remove(shine[x])

Buggy submission (verdict: Runtime Error):
N = int(input())
As = list(map(int, input().split()))
sort_as = sorted(As)
shine = [x + 1 for x in range(N)]
c = 0
s = 0
j = 0
for x in range(N):
  if len(As) == 0:
    continue
  for y in range(len(As)):
    if shine[x] == As[y]:
      c += 1
  print(c)
  c = 0
  if len(As) != 0:
    As.remove(shine[x])

Buggy submission (verdict: Runtime Error):
N = int(input())
As = list(map(int, input().split()))
sort_as = sorted(As)
shine = [x + 1 for x in range(N)]
c = 0
s = 0
j = 0
for x in range(N):
  for y in range(len(As)):
    if shine[x] == As[y]:
      c += 1
  print(c)
  c = 0
  if len(As) != 0:
    As.remove(shine[x])
Problem p02725 (python)

Fixed submission:
def check(a):
  if a < 0:
    return a * -1
  else:
    return a

def main():
  K, N = map(int, input().split())
  As = list(map(int, input().split()))
  r = []
  r.append(K-As[-1]+As[0])
  for x in range(N-1, -1, -1):
    solve = As[x] - As[x-1]
    r.append(check(solve))
  ans = sorted(r)
  ans.remove(ans[-1])
  print(K-ans[-1])

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
def check(a):
  if a < 0:
    return a * -1
  else:
    return a

def main():
  K, N = map(int, input().split())
  As = list(map(int, input().split()))
  r = []
  for x in range(N-1, -1, -1):
    if As[x] == 0:
      r.append(check(K - As[x-1]))
      continue
    elif As[x-1] == 0:
      r.append(check(As[x]))
      continue
    solve = As[x] - As[x-1]
    r.append(check(solve))
  ans = sorted(r)
  print(K-ans)

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

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

def lcm(x, y):
    return (x * y)//gcd(x, y)
a, b = map(int, input().split())
print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a, b = map(int, input().split())
print(lcm(a, b))
Problem p03041 (python)

Fixed submission:
n,k = input().split()
s = list(input())
s[int(k)-1] = s[int(k)-1].lower()
print(''.join(s))

Buggy submission (verdict: Runtime Error):
n,k = input().split()
s = list(input())
s[int(k)] = s[int(k)].lower()
print(''.join(s))
Problem p03803 (python)

Fixed submission:
card_power = {'2':'1','3':'2','4':'3','5':'4','6':'5','7':'6','8':'7','9':'8','10':'9','11':'10','12':'11','13':'12',"1":'13'}
A,B = input().split()
if int(card_power[A]) == int(card_power[B]):
  print('Draw')
elif int(card_power[A]) > int(card_power[B]):
  print('Alice')
elif int(card_power[A]) < int(card_power[B]):
  print('Bob')

Buggy submission (verdict: Runtime Error):
card_power = {'2':'1','3':'2','4':'3','5':'4','6':'5','7':'6','8':'7','9':'8','10':'9','11':'10','11':'12','13':'12','1':'13'}
A,B = input().split()
if int(card_power[A]) > int(card_power[B]):
  print('Alice')
elif int(card_power[A]) < int(card_power[B]):
  print('Bob')
else:
  print('Alice')

Buggy submission (verdict: Runtime Error):
card_power = {'2':'0','2':'1','3':'2','4':'3','5':'4','6':'5','7':'6','8':'7','9':'8','10':'9','11':'10','11':'12','13':'12','1':'13'}
A,B = input().split()
if int(card_power[A]) > int(card_power[B]):
  print('Alice')
elif int(card_power[A]) < int(card_power[B]):
  print('Bob')
else:
  print('Draw')