Harryxun/stf_run huggingface dataset:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

s = set(s)
tot = 0
for i in s:
  res = s.count(i) - t.count(i)
  tot = max(res,cnt)
  
print(tot)


### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

k = set(s)
tot = 0
for i in k:
  tot = max(s.count(i) - t.count(i),tot)
  
print(tot)
N = int(input())
S = list(map(int,input().split()))
if 'Y' in S:
    print('Four')
else:
    print('Three')

### FIXED CODE ###

N = int(input())
S = list(input())
if 'Y' in S:
    print('Four')
else:
    print('Three')
import numpy as np
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
A_ = [2*i for i in A]
A_ = [i%A[0] for i in A_]
A_ = sorted(set(A_))
if A_ == [0]*len(A_):
  print(A[0])
else:
  print(A_[1])

### FIXED CODE ###

import numpy as np
N,M = map(int,input().split())
X = list(map(int,input().split()))

if N < M:
  X = sorted(X,reverse = True)
  X_ = abs(np.array(X[1:]) - np.array(X[:M-1]))
  X_ = sorted(X_,reverse = True)
  print(sum(X_[N-1:]))
else:
  print('0')
#import time

def main():
    N = int(input())
    As = list(map(int, input().split()))

    As.sort()
    amax = max(As) + 1
    lis = [True] * amax
    ans = 0

    for i in range(N-1):
        if lis[As[i]]:
            for j in range(As[i], amax, As[i]):
                lis[j] = False
            if a[i] < a[i+1]:
                ans += 1
    if lis[-1]:
        ans += 1

    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    #print("経過時間:{}".format(elapsed_time * 1000) + "[msec]")

### FIXED CODE ###

#import time

def main():
    N = int(input())
    As = list(map(int, input().split()))

    As.sort()
    amax = max(As) + 1
    lis = [True] * amax
    ans = 0

    for i in range(N-1):
        if lis[As[i]]:
            for j in range(As[i], amax, As[i]):
                lis[j] = False
            if As[i] < As[i+1]:
                ans += 1
    if lis[-1]:
        ans += 1

    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    #print("経過時間:{}".format(elapsed_time * 1000) + "[msec]")
import math
N,X = map(int,input().split())
l = []
x = tuple(map(int,input().split()))

for i in range(N):
    l.append(abs(x[i]-X))
#print(l)
a = 10**9
for i in range(N-1):
    if a >= math.gcd(l[i],l[i+1]):
        a = math.gcd(l[i],l[i+1])
if N == 1:
    print(x[0]-X)
else:
    print(a)

### FIXED CODE ###

n, x = map(int,input().split())
li = list(input().split())
li = [abs(int(a)-x) for a in li]

def gcd(a,b):
    while a%b!=0:
        a,b = b,a%b
    return b
    
if n == 1:
    print(abs(li[0]))
    
elif n == 2:
    print(gcd(li[0],li[1]))
    
elif n >= 3:

    c = gcd(li[0],li[1])
    #print(c)
    for i in range(2,len(li)-1):
        c = gcd(c,li[i])
    print(c)
x,y,z =map(int,input().splilt())
t=0
t=x;x=y;y=t;
t=x;x=z;z=t;
print(x,y,z)

### FIXED CODE ###

x,y,z =map(int,input().split())
t=0
t=x;x=y;y=t;
t=x;x=z;z=t;
print(x,y,z)
s=input()
bf='01'*(len(s)//2)
wf='10'*(len(s)//2)
if len(s)%2==1:
  bf+='0'
  wf+='1'
ans=min(len([x!=y if x,y in zip(s,bf)]),len([x!=y if x,y in zip(s,wf)]))
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
S = input()
bf = '01' * (len(S) // 2) + '0' * (len(S) & 1)
wf = '10' * (len(S) // 2) + '1' * (len(S) & 1)
ans = 10**5
ans = min(ans, [x != y for x, y in zip(S, bf)].count(True))
ans = min(ans, [x != y for x, y in zip(S, wf)].count(True))
print(ans)
#!/usr/bin/env python3
import sys
import math

def solve(A: int, B: int, C: int, D: int):
    E = C * D // math.gcd(C, D)
    count_c = B // C - (A-1) // C
    count_d = B // D - (A-1) // D
    count_e = B // E - (A-1) // E
    print(B-A+1 - count_c - count_d + count_e)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import fractions

def solve(A: int, B: int, C: int, D: int):
    E = C * D // fractions.gcd(C, D)
    count_c = B // C - (A-1) // C
    count_d = B // D - (A-1) // D
    count_e = B // E - (A-1) // E
    print(B-A+1 - count_c - count_d + count_e)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()
n = int(input())

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

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  elif t >= 8:
    c[t] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = min(sum(c[:-1]) + c[8], 8)
print(cmin, cmax)

### FIXED CODE ###

n = int(input())

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

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  else:
    c[8] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = sum(c)
print(cmin, cmax)
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

a,b = map(int,input().split())
c += max(a,b)
c += max(a,b)-1
print(c)


### FIXED CODE ###

#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

a,b = map(int,input().split())
c = max(a,b)
if a>b:
    a-=1
else:
    b-=1
c += max(a,b)
print(c)
if S=='SAT':
  print(1)
elif S=='FRI':
  print(2)
elif S=='THU':
  print(3)
elif S=='WED':
  print(4)
elif S=='TUE':
  print(5)
elif S=='MON':
  print(6)
else S=='SUN':
  print(7)

### FIXED CODE ###

S = input()

if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
else:
    print(1)
import sys
import math

def divlist(n):
   sl=[]
   ll=[]
   for x in range(1,int(math.sqrt(n))+1):
       if n%x==0:
           sl.append(x)
           ll.append(n//x)
   ll.reverse()
   sl.extend(ll)
   return sl

def f(b,n):
    if n<b:
        return n
    else:
        return f(b,n//b)+(n%b)

def main(n,s):
    if n<s:
        return print(-1)
    elif n==s:
        return prnit(n+1)
    else:
        dl=divlist(n-s)
        for x in dl:
            if s==f(x+1,n):
                return print(x+1)
        return print(-1)

n=int(sys.stdin.readline().strip())
s=int(sys.stdin.readline().strip())

main(n,s)


### FIXED CODE ###

import sys
import math

def divlist(n):
   sl=[]
   ll=[]
   for x in range(1,int(math.sqrt(n))+1):
       if n%x==0:
           sl.append(x)
           ll.append(n//x)
   ll.reverse()
   sl.extend(ll)
   return sl

def f(b,n):
    if n<b:
        return n
    else:
        return f(b,n//b)+(n%b)

def main(n,s):
    if n<s:
        return print(-1)
    elif n==s:
        return print(n+1)
    else:
        dl=divlist(n-s)
        for x in dl:
            if s==f(x+1,n):
                return print(x+1)
        return print(-1)

n=int(sys.stdin.readline().strip())
s=int(sys.stdin.readline().strip())

main(n,s)
n=int,input()
a=int,input()

if n%500==0:
    print('Yes')
elif n%500<=a:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n=int(input())
a=int(input())

if n%500==0:
    print('Yes')
elif n%500<=a:
    print('Yes')
else:
    print('No')
n = input()
ans = 0

if n % 2 == 0:
    ans = n/2
else:
    ans = int(n/2) + 1

print(ans)


### FIXED CODE ###

n = int(input())+1
ans = int(n/2)
print(ans)
N = int(input())
D = map(int,input().split())
count=0
for i in range(N):
  for j in D[i+1:]:
    A = D[i]*j
    count+=A
print(A)


### FIXED CODE ###

N = int(input())
D = list(map(int,input().split()))
count=0
for i in range(N-1):
  for j in D[i+1:]:
    A = D[i]*j
    count+=A
print(count)
N,K=map(int,input().split())
d=[]
a=[]
for i in range(K):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
    
aa=[0]*N
counts=0

for k in K:
    for j in a[k]:
        aa[j-1]=1
        
for x in range(N+1):
    if aa[x-1]==0:
        counts+=1

print(counts)

### FIXED CODE ###

N,K=map(int,input().split())
d=[]
a=[]
for i in range(K):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
    
aa=[0]*N
counts=0

for k in a:
    for j in k:
        aa[j-1]+=1
        
for x in aa:
    if x==0:
        counts+=1

print(counts)
import numpy as np
import sys
read = sys.stdin.buffer.read


N, M, K = map(int, input().split())
AB = np.array(read().split(), np.int32)
A = [0] + np.cumsum(AB[:N]).tolist()
B = [0] + np.cumsum(AB[N:]).tolist()
assert (N == len(A) - 1) and (M == len(B) - 1)

left = M
for i, b in enumerate(B):
    if b > K:
        left = i

ans = 0
for i in range(len(A)):
    if A[i] > K:
        break

    while A[i] + B[left] > K:
        left -= 1

    ans = max(ans, left + i)

print(ans)

### FIXED CODE ###

import numpy as np
import sys
read = sys.stdin.read


N, M, K = map(int, input().split())
AB = np.array(read().split(), np.int32)
A = [0] + np.cumsum(AB[:N]).tolist()
B = [0] + np.cumsum(AB[N:]).tolist()
assert (N == len(A) - 1) and (M == len(B) - 1)

ans = 0
left = M
for i in range(len(A)):
    if A[i] > K:
        break

    while A[i] + B[left] > K:
        left -= 1

    ans = max(ans, left + i)

print(ans)
n, k = map(int, input().split())
a = list(map(int, input().split()))

memo = [-1] * (k+1)
def rec(x):
    if memo[x] >= 0:
        return memo[x]
    flag = 0
    for i in range(n):
        if x - a[i] < 0:
            continue
        if rec(x - a[i]) == 0:
            flag = 1
    if flag == 1:
        memo[x] = 1
        return 1
    else:
        memo[x] = 0
        return 0

if rec(k) == 1:
    print("First")
else:
    print("Second")

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))

dp = [0] * (k+1)

for i in range(1, k+1):
    for a in A:
        if i - a < 0:
            break
        if dp[i-a] == 0:
            dp[i] = 1

if dp[k] == 1:
    print("First")
else:
    print("Second")
n = int(input())
s = [int(input()) for i in range(n)]

print("AC x " +  str(l.count('AC')))
print("WA x " +  str(l.count('WA')))
print("TLE x " +  str(l.count('TLE')))
print("RE x " +  str(l.count('RE')))

### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]
 
print("AC x " +  str(s.count('AC')))
print("WA x " +  str(s.count('WA')))
print("TLE x " +  str(s.count('TLE')))
print("RE x " +  str(s.count('RE')))
N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(sa)
if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()

print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(a)

if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()
if len(sa) != 3:
    print("No")
    exit()

if B[sa[0]] == B[sa[1]] == B[sa[2]]:
    print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")
else:
    print("No")
import math
from functools import reduce

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

def gcd(*numbers):
  return reduce(math.gcd, numbers)

print(gcd(A))

### FIXED CODE ###

import fractions
from functools import reduce

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

def gcd(numbers):
  return reduce(fractions.gcd, numbers)

print(gcd(A))
a = int(input())
b = int(input())
 
if a < b:
    print("a < b")
elif a > b:
    print("a < b")
else:
    print("a == b")

### FIXED CODE ###

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

if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")
import numpy as np

def main():
    """
    N, M, C = np.array([int(x) for x in input().split(' ')])
    b_arr = np.array([int(x) for x in input().split(' ')])
    a_mat = np.zeros((N,M))
    """
    N ,M, C = list(map(int, input().split()))
    b_arr = np.array(list(map(int, input().split())))
    a_mat = np.zeros((N,M))
    
    for i in range(N):
        a_mat[i] = np.array(list(map(int, input().split())))
        #a_mat[i] = np.array([int(x) for x in input().split(' ')])

        #print ( len(list( np.where( a_mat.dot(b_arr)> -C ) )[0]) )
    print ( np.array(np.where(a_mat.dot(b_arr) > -C)).shape[1] )

if __name__ == '__main__':
    main()


### FIXED CODE ###

H, W = map(int, input().split())
h, w = map(int, input().split())

res = (H-h)*(W-w)

print(res)
res = 1
for i in range(1, n+1):
    res *= i
    if res > 10**9+7:
        res %= 10 ** 9+7

print(res%(10**9+7))

### FIXED CODE ###

n = int(input())
res = 1
for i in range(1, n+1):
    res *= i
    if res >= 10**9+7:
        res %= 10 ** 9+7

print(res)
while True:
    w, h = map(int, input().split())
    vart = []
    hori = []
    if w == 0 and h ==0:
        break
    for i in range(2*h-1):
        if i % 2 == 0:
            vart.append(list(map(int, input().split())))
        else:
            hori.append(list(map(int, input().split())))
    node = [[0 for i in range(h)] for i in range(w)]
    queue = [(0,0,1)]
    res = 0
    while queue:
        p = queue.pop(0)
        x, y, z = p[0], p[1], p[2]
        if x == w-1 and y == h-1:
            res = z
            break
        node[x][y] = 1
        if y-1 >= 0 and hori[y-1][x] == 0 and node[x][y-1] == 0:
            queue.append((x,y-1,z+1))
        if y+1 < h and hori[y][x] == 0 and node[x][y+1] == 0:
            queue.append((x,y+1,z+1))
        if x-1 >= 0 and vart[y][x-1] == 0 and node[x-1][y] == 0:
            queue.append((x-1,y,z+1))
        if x+1 < w and vart[y][x] == 0 and node[x+1][y] == 0:
            queue.append((x+1,y,z+1))
    print(res)

### FIXED CODE ###

while True:
    m,n = map(int,input().split())
    sw = []
    bw = []
    if m == 0 and n == 0:
        break
    for i in range(2*n-1):
        if i % 2 == 0:
            sw.append(list(map(int,input().split())))
        else:
            bw.append(list(map(int,input().split())))
    flag = [[0 for i in range(m)] for j in range(n)]
    l = [(0,0,1)]
    res = 0
    while l:
        bf = l.pop(0)
        if bf[0] == n-1 and bf[1] == m-1:
            res = bf[2]
            break
        flag[bf[0]][bf[1]] = 1
        if 1 <= bf[0] and bw[bf[0]-1][bf[1]] == 0 and flag[bf[0]-1][bf[1]] == 0:
            flag[bf[0]-1][bf[1]] = 1
            l.append((bf[0]-1,bf[1],bf[2]+1))
        if bf[1] < m-1 and sw[bf[0]][bf[1]] == 0 and flag[bf[0]][bf[1]+1] == 0:
            flag[bf[0]][bf[1]+1] = 1
            l.append((bf[0],bf[1]+1,bf[2]+1))
        if 1 <= bf[1] and sw[bf[0]][bf[1]-1] == 0 and flag[bf[0]][bf[1]-1] == 0:
            flag[bf[0]][bf[1]-1] = 1
            l.append((bf[0],bf[1]-1,bf[2]+1))
        if bf[0] < n-1 and bw[bf[0]][bf[1]] == 0 and flag[bf[0]+1][bf[1]] == 0:
            flag[bf[0]+1][bf[1]] = 1
            l.append((bf[0]+1,bf[1],bf[2]+1))
    print(res)
H, W = map(int, input().split())
field = [list(input()) for i in range(H)]
flag = [[False] * H] * W
metaflag = []
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(H):
    for j in range(W):
        if field[i][j] == '#':
            inflag = [False] * 4
            for k in range(4):
                ni = i + dx[k]
                nj = j + dy[k]
                if ni < 0 or ni >= H or nj < 0 or nj >= W:
                    inflag[k] = False
                elif field[ni][nj] == '#':
                    inflag[k] = True
            flag[i][j] = any(inflag)
        elif field[i][j] == '.':
            flag[i][j] = True
        metaflag.append(flag[i][j])

if all(metaflag):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

H, W = map(int, input().split())
field = [list(input()) for i in range(H)]
flag = []
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(H):
    for j in range(W):
        if field[i][j] == '#':
            inflag = [False] * 4
            for k in range(4):
                ni = i + dx[k]
                nj = j + dy[k]
                if ni < 0 or ni >= H or nj < 0 or nj >= W:
                    inflag[k] = False
                elif field[ni][nj] == '#':
                    inflag[k] = True
            flag.append(any(inflag))
        elif field[i][j] == '.':
            flag.append(True)

if all(flag):
    print('Yes')
else:
    print('No')
x = int(input())

for i in range(10000):
 
  if x == 0:
    break
  print(Case i : x)

### FIXED CODE ###

i = 1

while True:

 x=int(input())
 if x==0:
  break
 print("Case {0}: {1}".format(i,x))
 i+=1
n = input()
n = n[-3:]
if n == '000':
  print('0')
else:
  print(str(1000 - int(n))

### FIXED CODE ###

n = input()
n = n[-3:]
if n == '000':
  print('0')
else:
  print(str(1000 - int(n)))
import math


def main() -> None:
    a, b = input().split()

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

    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math


def main() -> None:
    a, b = input().split()

    print((int(a)*int(b.replace('.', ''))) // 100)

    return


if __name__ == '__main__':
    main()
#!/usr/bin/python3

import numpy as np

def main():
    N, W = map(int, input().split())

    dp = np.zeros((N+1, W+1), dtype='uint16')

    for i in range(N):
        weight, value = map(int, input().split())

        dp[i+1][:weight] = dp[i][:weight]
        dp[i+1][weight:] = np.maximum(dp[i][weight:], dp[i][:-weight] + value)

    print(dp[-1][-1])

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/python3

import numpy as np

def main():
    N, W = map(int, input().split())

    dp = np.full((N+1, N * (10**3) +1), np.inf)
    dp[0][0] = 0

    for i in range(N):
        weight, value = map(int, input().split())

        dp[i+1][:value] = dp[i][:value]
        dp[i+1][value:] = np.minimum(dp[i][value:], dp[i][:-value] + weight)


    res = 0
    for i, weight in enumerate(dp[N]):
        if weight <= W: res = i

    print(res)

if __name__ == '__main__':
    main()
s = input()

abaababaabfor i in reversed(range(1, len(s)//2)):
    if s[:i] == s[i:2*i]:
        ans = i * 2
        break

print(ans)


### FIXED CODE ###

s = input()

for i in reversed(range(1, len(s)//2)):
    if s[:i] == s[i:2*i]:
        ans = i * 2
        break

print(ans)
import sys
input = sys.stdin.readline

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = sorted(list(map(int, input().split())))

n = 0
np = 0
nq = 0
ans = 0
while n < x + y:
    cs = []
    if p and np < x:
        cs.append(p[-1])
    if q and nq < y:
        cs.append(q[-1])
    if r:
        cs.append(r[-1])
    m = max(cs)
    if m == r[-1]:
        ans += r.pop()
    elif m == p[-1]:
        ans += p.pop()
        np += 1
    else:
        ans += q.pop()
        nq += 1
    n += 1

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = sorted(list(map(int, input().split())))

n = 0
np = 0
nq = 0
ans = 0
while n < x + y:
    cs = []
    if p and np < x:
        cs.append(p[-1])
    if q and nq < y:
        cs.append(q[-1])
    if r:
        cs.append(r[-1])
    m = max(cs)
    if r and m == r[-1]:
        ans += r.pop()
    elif p and m == p[-1]:
        ans += p.pop()
        np += 1
    else:
        ans += q.pop()
        nq += 1
    n += 1

print(ans)
n=int(input())
a=list(map(int,input().split()))
a = [None] + a
cnt = 0
for i in range(1, n):
  j = a[i]
  if j > i and a[j] == i:
    cnt += 1
print(cnt)

### FIXED CODE ###

input_line=input()
print (input_line[:4]+" "+input_line[4:])
# Not Divisible

N = int(input())
A = [int(n) for n in input().split()]

check = [0] * 1000000
A.sort()

ok = []
p = -1
for a in A:
    if a == p:
        continue
    p = a
    if check[a] == 1:
        continue
    for i in range(a, 1000000, a):
        check[i] = 1
    ok.append(a)

print(len(ok))


### FIXED CODE ###

# Not Divisible

N = int(input())
A = [int(n) for n in input().split()]

check = [0] * 1000001
A.sort()

ok = [-1]
p = 0
for a in A:
    if a == p:
        if ok[-1] == p:
            ok = ok[:-1]
        continue
    p = a
    if check[a] == 1:
        continue
    for i in range(a, 1000001, a):
        check[i] = 1
    ok.append(a)

print(len(ok) - 1)
C:\Users\ryo-2\Anaconda3\python.exe C:/Users/ryo-2/PycharmProjects/atcoder/ABC131/ABC131_D.py
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Yes

Process finished with exit code 0


### FIXED CODE ###

def dec(X, d):
    X[1] -= d
    return X


N = int(input())
task = [list(map(int, input().split())) for _ in range(N)]

task.sort(key=lambda x: x[1])
time = 0
for i in range(N):
    time += task[i][0]
    if time > task[i][1]:
        print("No")
        exit()

print("Yes")
def D_RainFlowsintoDams():
    import numpy as np
    N = int(input())
    A = [list(map(int, input().split()))]
    A = np.array(A)
    # XB = A のXを求める
    X = (np.eye(N) + np.eye(N, k=1) + np.eye(N, k=-N+1)) * 0.5
    # X^{-1} を求める
    B = np.linalg.solve(X, A.T)
    # 両辺に左からX^{-1}をかける
    for x in range(N):
        print(int(B.T[0][x]), end=" ")

if __name__ == "__main__":
    D_RainFlowsintoDams()


### FIXED CODE ###

def D_RainFlowsintoDams():
    N = int(input())
    A = list(map(int, input().split()))
    total = sum(A)
    x = total - 2*sum([A[i] for i in range(1, N -1, 2)])
    for i in range(N):
        print(x, end=" ")
        x = 2 * A[i] - x
def D_Determinant():
    # 行列式を使うと時間がかかりすぎる
    import numpy as np
    N = int(input())
    A = [list(map(int, input().split()))]
    A = np.array(A)
    # XB = A のXを求める
    X = (np.eye(N) + np.eye(N, k=1) + np.eye(N, k=-N+1)) * 0.5
    # X^{-1} を求める
    B = np.linalg.solve(X, A.T)
    # 両辺に左からX^{-1}をかける
    for x in range(N):
        print(int(B.T[0][x]), end=" ")

if __name__ == "__main__":
    D_RainFlowsintoDams()
N, K = map(int, input().split())

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

# 期待値は(1+P)/2 https://rikeilabo.com/sum-formula-of-numerical-sequence
# 累積和を求めておく．隣接するK個の和はS_{j+K} - S_j
# 期待値の前計算→累積和の計算→隣接するK項の和の計算 (１乗オーダー)
E_list = []
for dice in dices:
    E_list.append((1 + dice) * 0.5)

S_list = []  # i番目までのサイコロの期待値の累積和
for i in range(len(dices)):
    S_list.append(sum(E_list[:i + 1]))

print(max(list(S_list[j + K] - S_list[j] for j in range(len(dices) - K))))

### FIXED CODE ###

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

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

# 期待値は(1+P)/2 https://rikeilabo.com/sum-formula-of-numerical-sequence
# 累積和を求めておく．隣接するK個の和はS_{j+K} - S_j
# 期待値の前計算→累積和の計算→隣接するK項の和の計算 (１乗オーダー)
E_list = []
for dice in dices:
    E_list.append((1 + dice) * 0.5)

S_list = []  # i番目までのサイコロの期待値の累積和
for i in range(len(dices)):
    # S_list.append(sum(E_list[:i + 1]))  # アホ
    S_list.append(E_list[0] if i == 0 else S_list[i - 1] + E_list[i])

print(max(list(S_list[j + K] - S_list[j] for j in range(len(dices) - K))) if len(dices) != K else S_list[-1])
K,N=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=A[1:]-x[:-1]
B.append(K+A[0]-A[N-1])
print(K-max(B))

### FIXED CODE ###

import numpy as np

K,N=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
x=np.array(A[1:])
y=np.array(A[:-1])
B=x-y
C=B.tolist()
C.append(K+A[0]-A[N-1])
print(K-int(max(C)))