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

Fixed submission:
S = input()

if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
def merge(A,B):
    C = []
    
    while len(A)!=0 and len(B) != 0:
        if A[0]>B[0]:
            C.append(A[0])
            del A[0]
        else:
            C.append(B[0])
            del B[0]

    if len(A)>len(B):
        C.extend(A)
    else:
        C.extend(B)

    return C

if __name__ == "__main__":
    X,Y,A,B,C = map(int,input().split())
    P = list(map(int,input().split()))
    Q = list(map(int,input().split()))
    R = list(map(int,input().split()))

    # 後で消す
    # P = [1,23,4,1,2]
    # Q = [4,3,56]
    # R = [70,20,1]

    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)

    S = merge(P[:X],Q[:Y])
    S = merge(S,R)
    
    score = 0
    for i in range(X+Y):
        score += S[i]
    print(score)
Problem p02915 (python)

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

Buggy submission (verdict: Runtime Error):
print(n**3)
Problem p02835 (python)

Fixed submission:
a1, a2, a3 = map(int, input().split())
if a1 + a2 + a3 >= 22:
  print('bust')
else:
  print('win')

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

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

p = len(format(max(A), 'b'))
digit = ['0' + str(p) + 'b'] * N
S = list(map(format, A, digit))
X = np.array([[int(c) for c in s] for s in S])
#print(X)
r = np.sum(X, 0)
#print(r)
r = r * (N - r)
#print(r)

res = 0
for j in range(p):
  res += r[j] * (2 ** (p-1-j))

print(res % (10**9 + 7))
Problem p02836 (python)

Fixed submission:
s = input()
l = int ((len(s) - len(s) % 2) / 2)

count = 0
for i in range(l):
  if s[i] != s[-(i+1)]:
    count += 1

print(count)

Buggy submission (verdict: Runtime Error):
s = input()
l = (len(s) - len(s) % 2) / 2

for i in range(l):
  if s[i] != s[len(s) - i]:
    count += 1

print(count)
Problem p02723 (python)

Fixed submission:
word = list(input())
if word[2]==word[3] and word[4]==word[5]:
    print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
word = input()
if word[2]==word[3] and word[4]==word[5]:
    print('Yes')
    sys.exit(0)
print('No')

Buggy submission (verdict: Runtime Error):
import sys

word = sys.argv[1]
if word[2]==word[3] and word[4]==word[5]:
    print('Yes')
    sys.exit(0)
print('No')
Problem p02831 (python)

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
A, B = list(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 = list(map(int, input().split()))
print(lcm(A, B))
Problem p02912 (python)

Fixed submission:
import math
import heapq

N, M = list(map(int, input().split()))
A = list(map(lambda a: -int(a), input().split()))
A.sort()
heapq.heapify(A)

for i in range(M):
  a = heapq.heappop(A)
  a = -(-a / 2.0)
  heapq.heappush(A, a)

amount = 0
for a in A:
  amount += math.floor(-a)
print(amount)

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

N, M = list(map(int, input().split()))
A = list(map(lambda a: -int(a), input().split()))
A.sort()
heapq.heapify(A)

for i in range(M):
  a = heapq.heappop(A)
  a =/ 2.0
  heapq.heappush(A, a)

amount = 0
for a in A:
  amount += math.floor(-a)
print(amount)
Problem p02726 (python)

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

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
l=[0]*n
for i in range(n):
  for j in range(i+1,n):
    temp=min(abs(j-i),abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(j-x))
    l[temp]+=1
for i in range(1,n):
  print(l[i])
Problem p02723 (python)

Fixed submission:
[a,b,c,d,e,f] = input()

if c == d and e == f:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
[a,b,c,d,e,f] = import()

if c = d and e = f:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
[a,b,c,d,e,f] = import()

if c = d and e = f:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
[a,b,c,d,e,f] = import()

if c = d and e = f:
    print("Yes")
else:
    print("No")
Problem p02729 (python)

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

print(
    (N*(N-1))//2 +
    (M*(M-1))//2
)

Buggy submission (verdict: Runtime Error):
from sys import stdin

N, M = stdin.readline().rstrip().split()

#全ての組み合わせのうち、奇数になるもののみ除く（奇数 + 偶数）

total = ((N+M)*(N+M-1))/2
odd = N*M

print(total - odd)

Buggy submission (verdict: Runtime Error):
from sys import stdin

N, M = stdin.readline().rstrip().split()

#全ての組み合わせのうち、奇数になるもののみ除く（奇数 + 偶数）

NM = N*M
total = (NM*(NM-1))/2
odd = NM/2

print(total - odd)
Problem p02777 (python)

Fixed submission:
from sys import stdin

def slove():
    S, T = stdin.readline().rstrip().split()
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    U = input()

    if S == U:
        print(A-1, B)
    elif T == U:
        print(A, B-1)
    else:
        print(A, B)


slove()

Buggy submission (verdict: Runtime Error):
from sys import stdin

def slove():
    S, T = stdin.readline().rstrip().split()
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    U = input()

    if S == U:
        print(A-1, B)
    else T == U:
        print(A, B-1)
    else:
        print(A, B)


slove()
Problem p02847 (python)

Fixed submission:
from sys import stdin

S = stdin.readline().rstrip()
days  = ["MON","TUE","WED","THU","FRI","SAT","SUN"]

if S == "SUN":
    print(7)
else:
    i = days.index(S)
    print(6 - i)

Buggy submission (verdict: Runtime Error):
from sys import stdin

S = stdin.readline().rstrip()
days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

for i in range(len(days)):
    if S == days[i]:
        t = i
        break
    else:
        i += 1

print(days[t + 1])

Buggy submission (verdict: Runtime Error):
S = input()
days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

for i in range(6):
    if S == days[i]:
        t = i
        break
    else:
        i =+ 1

print(days[t + 1])

Buggy submission (verdict: Runtime Error):
S = input()
days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

for i in days:
    if S == days[i]:
        t = i
        break
    else:
        i =+ 1

print(days[t + 1])
Problem p02897 (python)

Fixed submission:
from sys import stdin

A = int(stdin.readline().rstrip())

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

Buggy submission (verdict: Runtime Error):
from sys import stdin

A = int(stdin.readline().rstrip())

if A%2 == 0:
    print(A/(A/2))
else:
    print(A/(A//2))
Problem p02723 (python)

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

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

Fixed submission:
S = input()

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

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

distance = []
diff = 0

for i in range(0, N):
    
    if i == N-1:
        diff = K + A_list[0] - A_list[i]
        distance.append(diff)
        
    else:
        diff = A_list[i+1] - A_list[i]
        distance.append(diff)
        

print(sum(distance) - max(distance))

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

if (input_line[2] == input_line[3]) & (input_line[4] == input_line[5]):
  print("Yes")
else:
  pritn("No")
Problem p02829 (python)

Fixed submission:
number1 = int(input())
number2 = int(input())

n_list = [1,2,3]

n_list.remove(number1)
n_list.remove(number2)

print(n_list[0])

Buggy submission (verdict: Runtime Error):
num = int(input())
 
s1,s2 = input().split()
 
ans = ''
 
for i in range(num):
	ans = ans + s1[i]
	ans = ans + s2[i]
    
print(ans)
Problem p02831 (python)

Fixed submission:
import fractions
 
a,b = map(int, input().split())
 
print((a*b)//fractions.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import fractions

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

print((a*b)//fractions.gcd(a,b)
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
S = input()
if S[2]==S[3] and S[4]==S[5]:\
    print(Yes)
else:
    print(No)

Buggy submission (verdict: Runtime Error):
if __name__=='__main__':
    S = input()
    if S[2]==S[3] and S[4]==S[5]:\
      print(Yes)
    else:
      print(No)
Problem p02831 (python)

Fixed submission:
def LMC(a,b):
  i = 1
  while(1):
    c = a * i
    if c % b == 0:
      return c
    i += 1

num_line = [int(i) for i in input().split(" ")]
print(LMC(num_line[0],num_line[1]))

Buggy submission (verdict: Runtime Error):
def lmc(a,b):
  i = 1
  while(1):
    c = a*i
	if c % b == 0:
      return c
	i += 1

print("a= ",end="")
a= int(input())
print("b= ",end="")
b= int(input())
print(lmc(a,b))

Buggy submission (verdict: Runtime Error):
def lmc(a,b):
	i = 1
	while(1):
		c = a*i
		if c % b == 0:
			return c
		i += 1

print("a= ",end="")
a= int(input())
print("b= ",end="")
b= int(input())
print(lmc(a,b))
Problem p02723 (python)

Fixed submission:
def coffee(word):
    ar = [char for char in word] 
    if (ar[2] == ar[3]) and (ar[4] == ar[5]):
      return 'Yes'
    else:
      return 'No'

if __name__ == '__main__':

    ar = str(input())

    result = coffee(ar)
    print(result)

Buggy submission (verdict: Runtime Error):
def coffee(n, ar):
    status = []
    if ar[3] == ar[4] and ar[5] == ar[6]:
      return 'Yes'
    else:
      return 'No'

if __name__ == '__main__':

    n = int(input())

    ar = list(map(str, input().rstrip().split()))

    result = coffee(n, ar)
    print(result)
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
n, x, y = map(int, input().split())
X = min(x,y)
Y = max(x,y)
x =X
y = Y
sum = x +y +1
dist = x+1
for i in range(2,dist):
	sum += dist//i
dist = n+1-y
for j in range(2,dist):
	sum += dist//j
dist = y+1-x
sum+= dist
for k in range(2,dist):
  sum += dist//k
sum+= y-n+2
Problem p03834 (python)

Fixed submission:
print(*input().split(','))

Buggy submission (verdict: Runtime Error):
s = [input().split()]
print('{} {} {}'.format(s))
Problem p03038 (python)

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
BC = [list(map(int,input().split())) for i in range(M)]
BC.sort(key = lambda x:-x[1])

index = 0
for i in range(len(BC)):
    for j in range(BC[i][0]):
        if index == len(A) or A[index] >= BC[i][1]:
            break

        else:
            A[index] = BC[i][1]
            index += 1

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
BC = [list(map(int,input().split())) for i in range(M)]
BC.sort(key = lambda x:-x[1])

index = 0
for i in range(len(BC)):
    for j in range(BC[i][0]):
        if A[index] >= BC[i][1]:
            break
        else:
            A[index] = BC[i][1]
            index += 1
            if index == len(A):
                break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
BC = [list(map(int,input().split())) for i in range(M)]
BC.sort(key = lambda x:-x[1])

index = 0
for i in range(len(BC)):
    for j in range(BC[i][0]):
        if A[index] >= BC[i][1]:
            break
        else:
            A[index] = BC[i][1]
            index += 1

print(sum(A))
Problem p03208 (python)

Fixed submission:
N,K = map(int,input().split())
A = [int(input()) for _ in range(N)]
A.sort()
m = []
for i in range(N-K+1):
    m.append(A[K-1+i]-A[i])
print(min(m))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [int(input()) for _ in range(N)]
A.sort()
m=A[K-1]-A[0]
for i in range(N-K):
    if m > A[K+i]-A[i+1]:
        m = A[K+1]-A[i+1]
print(m)
Problem p02723 (python)

Fixed submission:
S = input()

if S[2]==S[3] and S[4]==S[5] and len(S)==6 :
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
if len(S) != 6:
    print('No')
    return

if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')
Problem p02729 (python)

Fixed submission:
import math
N, M= list(map(int, input().split()))
'''
# 組み合わせ計算
print(math.factorial(N)//math.factorial(N-2)//2)
print(math.factorial(M)//math.factorial(max(M-2, 1))//2)
'''
num = math.factorial(N)//math.factorial(max(N-2, 1))//2 + math.factorial(M)//math.factorial(max(M-2, 1))//2
print(num)

Buggy submission (verdict: Runtime Error):
import math
N, M= list(map(int, input().split()))
'''
# 組み合わせ計算
print(math.factorial(N)//math.factorial(N-2)//2)
print(math.factorial(M)//math.factorial(max(M-2, 1))//2)
'''
num = math.factorial(N)//math.factorial(N-2)//2 + math.factorial(M)//math.factorial(max(M-2, 1))//2
print(num)
Problem p02754 (python)

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

count = N // (A + B)
amari = N%(A+B)
sum_blue = A * count + min(A, amari)

print(sum_blue)

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

count = - (-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * max(count, 1) + min(A, amari)
if N = 0: sum_blue = 0
print(sum_blue)
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, c, d, e, f = input()
if c==d and e==f:
  print(Yes)
else:
  print(No)
Problem p02725 (python)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
m = K + A[0] - A[N-1]
for i in range(N-1):
  d = A[i+1] - A[i]
  m = max([d, m])
print(K-m)

Buggy submission (verdict: Runtime Error):
K, N = int(input())
A = list(map(int, input().split()))
m = K + A[0] - A[N-1]
for i in range(N-1):
  d = A[i+1] - A[i]
  if d > m:
    m = d
print(K-m)

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

Fixed submission:

n = int(input())
s = input()

if n < 3200:
  print("red")
else:
  print(s)

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

if n < 3200:
  print("red")
else:
  print(s)
Problem p02723 (python)

Fixed submission:
s = input()

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

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

500yen = x//500*1000
5yen = x%500//5*5

print(500yen + 5yen)

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

500yen = x//500*1000
5yen = (x - x//500)//5*5

print(500yen + 5yen)

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

if(s[3] == s[4] and s[5] == s[6]):
  print("Yes")
  
else:
  print("No")
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
if s[3] == s[4] and s[5] == s[6]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
def func(data):
  if data[2] == data[3] and data[4] == data[5]:
    print('Yes')
  else:
    print('No')

func(s)

Buggy submission (verdict: Runtime Error):
def func(data):
  if data[2] == data[3] and data[4] == data[5]:
    print('Yes')
  else:
    print('No')
func(S)
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
n=input()
if n.islower:
	if n[2]==n[3] and n[4==n[5]:
		print("Yes")
	else:
		print("No")
else:
	print("No")
Problem p02723 (python)

Fixed submission:
inputs=input()

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

Buggy submission (verdict: Runtime Error):
s = input()
str3=inputs[2]
str4=inputs[3]
str5=inputs[4]
str6=inputs[5]

iscoffee=False
if str3==str4 and str5==str6:
    iscoffee=True
print(str(iscoffee))
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
def main():
  word = input()
  if (word[2]==word[3]) and (word[4]==word[5]):
    print("Yes")
  else:
    print("No")
    
 main()
Problem p02723 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# get a integer
a = input()
# output
if len(a) == 6 and a[2] == a[3] and a[4] == a[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# get a integer
a = input()
# output
if len(a) == 6 and a[2] == a[3] and a[4] == a[5]:
	print('Yes')
else
	print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# get a integer
a = raw_input()
# output
print(len(a) == 6 and a[2] == a[3] and a[4] == a[5])
Problem p02725 (python)

Fixed submission:
k, n = map(int, input().split())
l = list(map(int, input().split()))
maxi = k-l[-1]+l[0]
for i in range(1, n):
    maxi = max(l[i] - l[i-1], maxi)
print(k-maxi)

Buggy submission (verdict: Runtime Error):
k, n = map(int, input().split())
l = list(map(int, input().split()))
maxi = [k-l[-1]+l[0]]
for i in range(1, n):
  maxi = max(l[i] - l[i-1], maxi)
print(k-maxi)

Buggy submission (verdict: Runtime Error):
k, n = map(int, input())
l = list(map(int, input()))
maxi = [k-l[-1]+l[0]]
for i in range(1, n):
  maxi = max(l[i] - l[i-1], maxi)
print(k-maxi)
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
x = input()
 
happyPoints = 0
 
y = x - (x % 500)
 
if x % 500 !== x:
  happyPoints += (x/500)*1000
  	if y % 5 !== y:
      z = y - (y % 5)
      happyPoints += y
elif x % 5 !== x:
  w = x - (x % 5)
  happyPoints += w
 
  print(happyPoints)

Buggy submission (verdict: Runtime Error):
x = input()
 
happyPoints = 0
 
y = x - (x % 500)
 
if x % 500 !== x:
  happyPoints += (x/500)*1000
  	if y % 5 !== y:
      z = y - (y % 5)
      happyPoints += y
elif x % 5 !== x:
  w = x - (x % 5)
  happyPoints += w
 
  print(happyPoints)

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

if s[2] == s[3] & s[4] == s[5]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
if s[2] == s[3] & s[4] == s[5]:
  print('Yes')
else:
  print('No')
Problem p03631 (python)

Fixed submission:
n = input()

if n == n[::-1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import fractions

def lcm(a,b):
    g = fractions.gcd(a,b)
    return (a/g) * b

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(ans,t)

print(int(ans))
Problem p02723 (python)

Fixed submission:
s = input()

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

Buggy submission (verdict: Runtime Error):
if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
Problem p02759 (python)

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

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
if n == 1:
  start,end = 0,9
elif n == 2:
  start,end = 10,99
else:
  start,end = 100, 999

for i in range(start, end+1):
  flg = True
  for j in l:
    si = str(i)
    if len(si) < j[0]:
      flg = False
      continue

    if si[j[0]-1] != str(j[1]):
      flg = False
      
  if flg == True:
    print(i)
    break
else:
  print(-1)
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
s = input()
return s[2]==s[3] and s[4] == s[5]
Problem p02725 (python)

Fixed submission:
K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
dists = []
for base, switch in zip(As[:-1], As[1:]):
    dists.append(switch - base)
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
As = map(int, input().split())
dists = []
for base, switch in zip(As[:-1], As[1:]):
    dists.append(switch - base)
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))

Buggy submission (verdict: Runtime Error):
lines = input().split()
dists = []
for base, switch in zip(As[:-1], As[1:]):
    dists.append(switch - base)
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))

Buggy submission (verdict: Runtime Error):
lines = input().split()
K, N = map(int, lines[0].split())
As = map(int, lines[1].split())
dists = []
for base, switch in zip(As[:-1], As[1:]):
    dists.append(switch - base)
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))

Buggy submission (verdict: Runtime Error):
lines = input().split()
K, N = map(int, lines[0].strip().split())
As = map(int, lines[1].strip().split())
dists = []
for base, switch in zip(As[:-1], As[1:]):
    dists.append(switch - base)
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))

Buggy submission (verdict: Runtime Error):
lines = map(int, input().split())
K, N = map(int, lines[0].strip().split())
As = map(int, lines[1].strip().split())
dists = []
for base, switch in zip(As[:-1], As[1:]):
    dists.append(switch - base)
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))

Buggy submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
K, N = map(int, lines[0].strip().split())
As = map(int, lines[1].strip().split())
dists = []
for base, switch in zip(As[:-1], As[1:]):
  dists.append(switch - base)
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))

Buggy submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
K, N = map(int, lines[0].strip().split())
As = map(int, lines[1].strip().split())
dists = []
for idx, A in enumerate(As[:-1]):
  dists.append(A - As[idx+1])
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))

Buggy submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
K, N = map(int, lines[0].strip().split())
As = map(int, lines[1].strip().split())
for idx, A in enumerate(As[:-1]):
  dists.append(A - As[idx+1])
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))