peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import math

N, K = map(int, input().split())
A = list(input().split())
A_lis = [int(A[i]) for i in range(N)]
index = A_lis.index(1)

if N == K:
    print(1)
else:
    left = math.ceil(index / (K-1))
    leftamari = index % (K-1)
    right = math.ceil(max(0, N - 1 - index - (K - 1 - leftamari if leftamari != 0 else 0)) / (K-1))
    print(left + right)
# Judge status: Accepted

data = input()
data1 = input()

cnt = 0
for i in range(0, len(data)):
    if data[i] != data1[i]:
        cnt += 1

print(cnt)
# Judge status: Accepted
S = input()
K = int(input())

idx = min(K, len(S))
for s in S[:idx]:
    if s != "1": 
      print(s)
      break
else:
  print(1)
# Judge status: Accepted
def main():
    n = int(input())
    s = input()

    if len(s) % 2 != 0:
        print('No')
        exit()

    for i in range(len(s)//2):
        if s[i] != s[i+len(s)//2]:
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
s = input()

curr_change_cnt = min_change_cnt = sum(c == 'E' for c in s)
for i in range(1, n):
    if s[i - 1] == 'W':
        curr_change_cnt += 1

    if s[i] == 'E':
        curr_change_cnt -= 1

    min_change_cnt = min(curr_change_cnt, min_change_cnt)

print(min_change_cnt)
# Judge status: Wrong Answer
x,y = map(int,input().split())
p = 0
if min(x,y) != x:
    c = x
    x = y
    y = c
if 0 < x < y:
    print(y-x)
elif x < y < 0:
    print(y-x+2)
else:
    print(abs(abs(x)-abs(y))+1)
# Judge status: Accepted
n, k = map(int, input().split())

mod = 10 ** 9 + 7

ans = 0
for i in range(k, n + 2):
    # 等差数列の和 項数*(初項+末項)/2
    min = i * (0 + (i - 1)) // 2
    max = i * ((n - (i - 1)) + n)  // 2
    ans += (max - min) + 1
    ans %= mod
    
print(ans)
# Judge status: Accepted
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))

X = sorted(X)
diffs = [X[i] - X[i-1] for i in range(1, len(X))]
diffs = sorted(diffs, reverse=True)

# 一番遠い距離から、2点間の距離の中から大きい順に引いていくだけ
res = X[-1] - X[0]
for i in range(min(len(diffs), N-1)):
  res -= diffs[i]

print(res)
# Judge status: Wrong Answer
hoge = input().split()
print(len(set(hoge)))
# Judge status: Accepted
N = int(input())
dp = [0]
for i in range(N):
    P = int(input())
    dp_p = list(map(lambda x:x + P,dp))
    dp = list(set(dp + dp_p))

P_List = [0] + [i for i in dp if i % 10 != 0]
print(max(P_List))
# Judge status: Wrong Answer
N=input()
l=len(N)
if(N[:l]=='e'):
 print(N+'s')
elif(N[:l]=='s'):
 print(N+'es')
else:
 print(N+'s')
# Judge status: Wrong Answer
N = int(input())
D = list(map(int, input().split()))

mod = 998244353

from collections import Counter, deque, defaultdict

def solve(N,D):
    if D[0]!=0:
        return 0
    c = Counter(D)
    ans = 1
    m = max(D)
    for i in range(1,m):
        if c[i]==0:
            ans = 0
            continue
        ans *= pow(c[i],c[i+1],mod)
    return ans

print(solve(N,D))
# Judge status: Wrong Answer
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0 or c ==0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = c*3
    print(num)
# Judge status: Accepted
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))



X=int(input())

prime_l=[0]*(2*X)
for  i in range(2,X):
    if(prime_l[i]==0):
        for j in range(1,(2*X)//i):
            prime_l[i*j]+=1
        
while(1):
    if(prime_l[X]==0):
        print(X)
        sys.exit(0)
    X+=1
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
m = 1000
k = 0
for i in range(N-1):
  if A[i] < A[i+1]:
    k = m // A[i]
    m = m % A[i]
  elif A[i] > A[i+1]:
    m += k * A[i] 
    k = 0
m += k * A[N-1]
print(m)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n - 2):
  if min(p[i], p[i + 2]) < p[i + 1] < max(p[i], p[i + 2]):
    count += 1
print(count)
# Judge status: Accepted
n = int(input())

ans = 0
for j in range(1, n+1):
    y = n // j
    ans += y * (2 * j + (y - 1) * j) // 2

print(ans)
# Judge status: Wrong Answer
N=int(input())
XL=sorted(tuple(map(int,input().split())) for i in range(N))
count=0
left=-10**9
for x,l in XL:
    if left<=x-l:
        count+=1
        left=x+l
print(count)
# Judge status: Accepted
n = int(input())

C = [[0]*10 for i in range(10)]

for i in range(1, n+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    
    C[a][b] += 1
        
answer = sum([C[i][j]*C[j][i] for i in range(10) for j in range(10)])

print(answer)
# Judge status: Accepted
a,b,c=map(int,input().split(' '))
if(a+b+c>=22):
  print('bust')
else:
  print('win')
# Judge status: Accepted
N, M, X, Y = map(int, input().split())
x = max(list(map(int, input().split())))
y = min(list(map(int, input().split())))
print('No War' if x < y and X < y and x < Y else 'War')
# Judge status: Wrong Answer
def main():
    n, *a = map(int, open(0).read().split())
    if n == 1:
        print(1)
        return

    m = max(a) + 1
    l = [0] * m
    for i in a:
        for j in range(i, m, i):
            l[j] += 2
        l[i] -= 1

    ans = sum(l[i] == -1 for i in a)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
Ai = list(map(int, input().split()))
Ai_set = set(Ai)
if len(Ai) - len(Ai_set) == 0:
    print('YES')

else:
    print('NO')
# Judge status: Wrong Answer
D, T, S = map(int, input().split(' '))
if(T*S>=D): print('YES')
if(T*S< D): print('NO')
# Judge status: Accepted
from collections import deque
s = deque(input())
t = input()
ans = 'No'
for i in range(len(s)):
  s.appendleft(s.pop())
  string = ''.join(s)
  if string == t:
    ans = 'Yes'
print(ans)
# Judge status: Wrong Answer
from collections import Counter
S = input()
work = list(Counter(S).values())
a = work[0]
b = work[1] if len(work)>1 else 0
c = work[2] if len(work)>2 else 0
result = "YES"
if ((a > b + 1 or a > c + 1) or c == 0) and (not len(S)==1) and (not (len(S) == len(work) == 2)):
    result = "NO"
print(result)
# Judge status: Accepted
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  	print("Bad")
else:
  	print("Good")
# Judge status: Wrong Answer
w = input()
k = [0]*26
flag = 0
for i in range(len(w)):
  k[ord(w[i])-97] += 1
for i in range(len(k)):
  if k[i]%2 == 0:
    continue
  else:
    flag += 1
    print("No")
if flag == 0:
  print("Yes")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
temp=sum(a)
ans=0
t=999999999
tsum=0
ta=0
for i in range(n):
  tsum=tsum+a[i]
  if abs(tsum-temp/2)<t:
    t=abs(tsum-temp/2)
    ta=tsum
print(abs(int(ta)*2-temp))
# Judge status: Accepted
N = int(input())
S = str(input())
V = 'abcdefghijklmnopqrstuvwxyz'
Lavida = [1]*26
for i in range (0, N):
	Lavida[V.index(S[i])]+=1

count = 1
for i in range (0, 26):
	count*=Lavida[i]
	count=count%(10**9+7)

print((count-1)%(10**9+7))
# Judge status: Accepted
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T1=input()
T2=T1.replace('r', str(P)+' ').replace('s',str(R)+' ').replace('p',str(S)+' ')[:-1]
T2=list(map(int, T2.split()))
for i in range(N):
  if i >=K and T1[i]==T1[i-K] and T2[i-K] != 0:T2[i]=0
print(sum(T2))
# Judge status: Accepted
l=sorted(list(map(int,input().split())),reverse=True);print(int(str(l[0])+str(l[1]))+l[2])
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())

ttol=a%d
atol=c%b

tt=a//d
at=c//d
    
if ttol>=atol:
    print("Yes")
elif tt>at and ttol<atol:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S = input()
if S=='ABC':
	print('ARC')
else:
	print('ARC')
# Judge status: Accepted
a, b = input().split()
print("Yes" if (a==b) else "No")
# Judge status: Accepted
n,m=map(int,input().split())
ax=set()
bx=set()
for i in range(m):
   a,b=map(int,input().split())
   if a==1:
      ax.add(b)
   if b==n:
      bx.add(a)
print("POSSIBLE" if len(ax&bx)!=0 else "IMPOSSIBLE")
# Judge status: Accepted
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=sorted(list(map(int,input().split())),reverse=True)

list=p[:x]+q[:y]

if len(list)<x+y:
  ll=len(list)
  for i in range((x+y)-len(list)):
    list.append(r[i])
  r=r[(x+y)-ll:]
list=sorted(list)

for i in range(len(r)):
  if list[i]<r[i]:
    list[i]=r[i]
  else:
    break
print(sum(list))
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
N=int(input())
S=list(input())

ans=0
log=[0]*26
for item in S:
    item=ord(item)-97
    log[item]+=1
    temp=2**(26-log.count(0))
    sub=0
    for index,num in enumerate(log):
        if index!=item:
            sub+=(temp//2//2)*max((num-1),0)
    ans+=temp//2+sub
    ans%=10**9+7
print(ans)
# Judge status: Accepted
def f(yen, coin, cnt=0):
    while yen > 0: cnt += yen % coin; yen //= coin
    return cnt

ans = n = int(input())
for yen6 in range(0, n+1):
    ans = min(ans, f(n-yen6, 9, f(yen6, 6)))
print(ans)
# Judge status: Accepted
from collections import deque

k = int(input())
lunlun = []
q = deque([1,2,3,4,5,6,7,8,9])
while len(lunlun) <= k:
    first = q.popleft()
    lunlun.append(first)
    if first%10-1 >= 0:
        q.append(first*10 + (first%10-1))
    q.append(first*10 + first%10)
    if first%10+1 <= 9:
        q.append(10*first + (first%10+1))
print(lunlun[k-1])
# Judge status: Accepted
w, h, n = map(int, input().split())
l, r, t, b = 0, w, h, 0
for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    l = max(x, l)
  elif a == 2:
    r = min(x, r)
  elif a == 3:
    b = max(y, b)
  else:
    t = min(y, t)
if (r - l) <= 0 or (t - b) <= 0:
  print(0)
else:
  print((r - l) * (t - b))
# Judge status: Accepted
n, k = map(int, input().split())
table = [i for i in range(n+1)]
mod = 10**9 + 7
mx, mn = int((1/2)*k*(table[-k] + table[-1])), int((1/2)*k*(table[0] + table[k-1]))
ans = mx - mn + 1

for i in range(k+1, n+2):
    mx += table[-i]
    mn += table[i-1]
    ans += mx - mn + 1
print(ans%mod)
# Judge status: Wrong Answer
import numpy as np

N, M = input().split()
H = np.array(input().split())
canGoH = np.copy(H)
             
for i in range(int(M)):
    position1, position2 = input().split()
    if H[int(position1)-1] > H[int(position2)-1]:
        canGoH[int(position2)-1] = H[int(position1)-1]
    elif H[int(position2)-1] > H[int(position1)-1]:
        canGoH[int(position1)-1] = H[int(position2)-1]

        
print(sum(canGoH == H))
# Judge status: Wrong Answer
import math 

a, b = map(int, input().split())
x = (a + b) / 2
print(math.floor(x))
# Judge status: Accepted
from collections import defaultdict, deque
n, m = map(int, input().split())
li = [[] for _ in range(n)]
check = [-1] * (n)
check[0] = 0
que = deque([1])
memo = defaultdict(int)
for i in range(m):
    a, b = map(int, input().split())
    li[a-1].append(b)
    li[b-1].append(a)
while que:
    now = que.popleft()
    for l in li[now-1]:
        if check[l-1] != -1: continue
        check[l-1] = now
        que.append(l)

if -1 in check:
    print('No')
else:
    print('Yes')
    print(*check[1:], sep='\n')
# Judge status: Wrong Answer
import sys
import numpy as np

readline = sys.stdin.buffer.readline
a = np.array([])
for _ in range(3):
  a = np.append(a,list(map(int, readline().split())))
n = int(readline())

a = a.reshape(3,3)
a_2 = np.append(a,np.diag(a))
a_2 = np.append(a_2,[a[0][2],a[1][1],a[2][0]])

a_2 = a_2.reshape(5,3)
for _ in range(n):
  a_2[a_2==int(readline())]=0

print('Yes' if 0 in np.sum(a_2, axis=1) else 'No')
# Judge status: Wrong Answer
string = input()
index = string.index("A")
count = 1
i = index
while string[i] != "Z":
  count +=1
  i+=1
print(count+1)
# Judge status: Accepted
n=int(input())
s=list(input())
max=0
x=0
for c in s:
  if c=="D":
    x-=1
  else :
    x+=1
    if max<x:
      max=x
      
print(max)
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    low = []
    high = []

    for i in range(n):
        a, b = map(int, input().split())
        low.append(a)
        high.append(b)

    low.sort()
    high.sort()

    if n%2 == 1:
        l = low[n//2]
        h = high[n//2]
    else:
        l = low[n//2 - 1] + low[n//2]
        h = high[n//2 - 1] + high[n//2]

    ans = h - l + 1

    print(ans)

main()
# Judge status: Accepted
N = int(input())
K = int(input())
x = int(input())
y = int(input())
if N>K:
  ans = x*K + y*(N-K)
  print(ans)
else:
  ans = x*N 
  print(ans)
# Judge status: Wrong Answer
s = input()
t = input()

for _ in range(len(s)-1):
  if s == t:
    print("Yes")
    break
  s = s[-1] + s[:-1]
else:
  print("No")
# Judge status: Accepted
abcd = input()


for bit in range(1<<3):
  f = abcd[0]
  sum = int(f)
  for i in range(3):
    if bit & 1<<i:
      f += '+' + abcd[i+1]
      sum += int(abcd[i+1])
    else:
      f += '-' + abcd[i+1]
      sum -= int(abcd[i+1])
  
  if sum == 7:
    print(f + '=7')
    exit()
# Judge status: Accepted
x = int(input())
c = 1
while True:
    if c*100 <= x <= c*105:
        print(1)
        break

    if c*100 > x:
        print(0)
        break
    c += 1
# Judge status: Wrong Answer
import sys
import math

s = input()
k = int(input())
TRI = 5 * 10 ** 15
if (len(s) == 1):
    print(s)
else:
    s1 = s[0]
    s2 = s[1]
    if (s1 == s2 == '1'):
        for i in range(len(s)):
            if (s[i] != '1'):
                print(s[i])
                sys.exit()
    else:
        if (s1 == '1'):
            print(s2)
        else:
            print(s1)
# Judge status: Wrong Answer
n=int(input())
dic={0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j'}
ans=[['a',1]]
for i in range(1,n):
  tmp=[]
  for prev,val in ans:
    for j in range(val+1):
      if j!=val:
        tmp.append([prev+dic[j],val])
      else:
        tmp.append([prev+dic[j],val+1])
  ans=tmp
ans=sorted(ans,key=lambda x:x[0])
print(len(ans))
for i in range(len(ans)):
  print(ans[i][0])
# Judge status: Wrong Answer
import numpy as np
#N=map(int, input().split())
N=int(input())
count=0
for i in range(0,N):
    if i%3!=0 and i%5!=0:
        count=int(count+i)
print(count)
# Judge status: Accepted
import bisect

n = int(input())
l = list(map(int, input().split()))  

l.sort()

ans = 0
for i in range(n):
    for j in range(i+1,n):
        idx = bisect.bisect_left(l,l[i]+l[j])
        ans += idx-1-j
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

p = set()
q = 0
for i in range(n):
  if a[i] < 3200:
    p.add(a[i]//400)
  else:
    q += 1

p = len(p)
print(max(p, 1), p+q)
# Judge status: Accepted
import sys
import collections
import bisect


def main():
    n = int(input())
    a = [str(i + 1)[0] + str(i + 1)[-1] for i in range(n)]
    b = [str(i + 1)[-1] + str(i + 1)[0] for i in range(n)]
    ac, bc = collections.Counter(a), collections.Counter(b)
    print(sum(ac[i] * bc[i] for i in ac.keys()))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n=int(input())
h=list(map(int,input().split()))
ct=0
ans=0
for i in range(n-1):
    ct+=1
    if h[i]<h[i+1]:
        if ans<ct:
            ans=ct
        ct=0
if ans<ct:
    ans=ct
print(ans)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq

N, M = map(int,input().split())
A = list(map(lambda x:int(x) * (-1),input().split()))
heapq.heapify(A)

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

print(-sum(A))
# Judge status: Wrong Answer
# AtCoder Beginner Contest 145
# C - Average Length
# https://atcoder.jp/contests/abc145/tasks/abc145_c
from itertools import permutations

N, *A = map(int, open(0).read().split())
X = A[0::2]
Y = A[1::2]
print(X, Y)


def distance(a, b):
    return ((X[a]-X[b])**2 + (Y[a]-Y[b])**2)**0.5


length = 0
cnt = 0
print(*[p for p in permutations(range(N))])
for P in permutations(range(N)):
    cnt += 1
    prev = P[0]
    for i in P[1:]:
        length += distance(prev, i)
        prev = i

print(length/cnt)
# Judge status: Accepted
n,m=map(int,input().split())
c=n*m
if c==1:
    print(1)
elif n==1 or m==1:
    print(c-2)
else:
    print(c-n*2-(m-2)*2)
# Judge status: Accepted
s = input()
def cntUpper(s):
    cnt = 0
    for a in s:
        if a.isupper():
            cnt += 1
    return cnt
print('AC') if s[0] == 'A' and 'C' in s[2:-1] and cntUpper(s) == 2 else print('WA')
# Judge status: Wrong Answer
a,b,k = map(int,input().split())
count = 0
for i in range(1,100):
    if round(a/i,10)==round(a/i,15) and round(b/i,10)==round(b/i,15):
        count += 1
        if count == k:
            print(i)
            exit(0)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
a = Counter(res)
k = 0
for i in a.keys():
    a[i] -= 1
    sums = 0
    for j in a.values():
        sums += j * (j - 1) // 2
    a[i] += 1
    res = [sums if x == i else x for x in res]
for k in res:
    print(k)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
rank = [0] * 9
for i in a:
    if i < 3200:
        rank[i // 400] += 1
    else:
        rank[8] += 1

s = 0
for i in range(8):
    if rank[i] > 0:
        s += 1
if s > 0:
    s1 = s
else:
    s1 = 1
s2 = s + rank[8]
print(s1, s2)
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))

if N == 1:
    print("Yes")
    exit()

for i in range(len(H)-2):
    if H[i+1] - H[i] >= 2:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

print("yes" if len(set(S))==len(S) else "no")
# Judge status: Accepted
s=input()

for i in range(0,len(s)-1):
    if(s[i]==s[i+1]):
        print('Bad')
        break
    elif(i==2):
        print('Good')
# Judge status: Accepted
n,d = map(int,input().split())
x = d*2 + 1
print((n+d*2)//x)
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

dp =[0 for i in range(n+1)]
dp[0]=1

for i in range(n):
  if not i+1 in a:
    dp[i+1] += dp[i]
  if i < n-2:
    if not i+2 in a:
      dp[i+2] += dp[i]
if n in a:
  print(0)
else:
  print((dp[n-1]+dp[n-2])%1000000007)
# Judge status: Accepted
l, r, d = map(int, input().split())
num = 0
for i in range(r - l +1):
    if (i + l) / d == int((i + l) / d):
        num += 1
print(num)
# Judge status: Accepted
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = [''.join(sorted(list(sr()))) for _ in range(N)]

counter = Counter(S)
answer = sum(x*(x-1)//2 for x in counter.values())
print(answer)
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 0

if 2 not in a:
  print(-1)

x = 1
for i in range(n):
  x = a[x-1]
  cnt += 1
  if x == 2:
    print(cnt)
    exit()

print(-1)
# Judge status: Wrong Answer
S = input()
count = 0

leng = len(S)

if(leng %2 == 0):
    for i in range(0,leng):
        if(S[i] != S[leng-i-1]):
            count+=1
    count /= 2
        
if(leng %2 != 0):
    leng = int((leng-1)/2)
    for i in range(0,leng):
        if(S[i] != S[leng-i-1]):
            count+=1
    count /= 2
    count +=1
    
print("%d"%(count))
# Judge status: Accepted
import copy
N = int(input())
S = input()
LAlphabet = [False] * 26
L = []
for s in S:
    LAlphabet[ord(s)-97] = True
    L.append(copy.deepcopy(LAlphabet))

RAlphabet = [False] * 26
R = []
for s in reversed(S):
    RAlphabet[ord(s)-97] = True
    R.append(copy.deepcopy(RAlphabet))
R.reverse()
ans = 0

print(max([sum([L[l][t] and R[l+1][t] for t in range(26)]) for l in range(N-1)]))
# Judge status: Accepted
s = list(input())
ans = []
for i in range(len(s) - 2):
  num = s[i] + s[i + 1] + s[i + 2]
  ans.append(abs(753 - int("".join(num))))
print(min(ans))
# Judge status: Accepted
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 

n, X = map(int, input().split())
x = list(map(int, input().split()))
if len(x) == 1:
  print(abs(x[0] - X))
else:
  x.sort()
  s = x[1] - x[0]
  for i in range(1, n-1):
    s = gcd(s, x[i+1]-x[i])
  a = 1
  for i in range(n):
    a = max(a, gcd(abs(X-x[i]), s))
  print(a)
# Judge status: Accepted
n,k = map(int,input().split())
s = input()
c = []
buf = 1
for i in range(n-1):
    if s[i]==s[i+1]:
        buf += 1
    else:
        c.append(buf)
        buf = 1
c.append(buf)
n = len(c)
l = min(n,2*k+1)
ans = buf = sum(c[:l])
ind = 0
for i in range(n-l):
    buf = buf-c[i]+c[i+l]
    if ans<buf:
        ind = i+1
        ans = buf
ans -= 1
for i in range(n):
    if ind<=i<ind+l:
        continue
    ans += c[i]-1
print(ans)
# Judge status: Wrong Answer
import heapq as hp
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()))

lp = hp.nlargest(x, p)
lq = hp.nlargest(y, q)
pq = lp + lq
lpq = hp.nlargest(x+y, pq)
lr = hp.nlargest(c, r)
d = min(len(lr),len(lpq))
for i in range(1,d):
  if lpq[x+y-i] < lr[i-1]:
    lpq[x+y-i] = lr[i-1]
  else:
    break

ans = 0
for i in range(0,len(lpq)):
  ans += lpq[i]
print(ans)
# Judge status: Wrong Answer
W, a, b = map(int,input().split())

if a+W<=b:
  print(b-(a+W))
elif (a<= b)and (b<(a+W)):
  print(b-a)
elif (b<=a) and(a<b+W):
  print(a-b)
elif (b+W)<a:
  print(a-(b+W))
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
a = [list(input())[: -1] for _ in range(3)]
for i in range(3): a.reverse()
x = 0
c = ["a", "b", "c"]
while True:
  t = a[x].pop()
  for i in range(3):
    if t == c[i]:
      x = i
      break
  if len(a[0]) == 0:
    print("A")
    break
  elif len(a[1]) == 0:
    print("B")
    break
  elif len(a[2]) == 0:
    print("C")
    break
# Judge status: Accepted
from math import sqrt

def readinput():
    n=int(input())
    return n

def main(n):
    k=int((-1+sqrt(1+8*n))/2)
    while(k*(k+1)//2<n):
        k+=1
    dif=k*(k+1)//2 - n
    for i in range(1,dif):
        print(i)
    for i in range(dif+1,k+1):
        print(i)

if __name__=='__main__':
    n=readinput()
    main(n)
# Judge status: Wrong Answer
def func(a):
    x = (a) + (a**2) + (a**3)
    return int(x)

a = int(input( " enter number : "))
print(func(a))
# Judge status: Accepted
A, B, C = map(int, input().split())

cnt = 0

last = [A, B, C]

while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    a = A // 2
    b = B // 2
    c = C // 2
    cnt += 1
    A = b + c
    B = a + c
    C = a + b
    if A in last and B in last and C in last:
        print(-1)
        exit()

    last = [A, B, C]

print(cnt)
# Judge status: Accepted
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    num = 1
    l = []
    s = [1]*n

    while s[num-1]:
        l.append(num)
        s[num-1] = 0
        num = a[num-1]

    if l.index(num) <= k:
        l2 = l[l.index(num):]
        kk = (k-len(set(l)-set(l2)))%len(l2)
        print(l2[kk])
    else:
        print(l[k])

main()
# Judge status: Wrong Answer
N,K = map(int,input().split())
if (N//K)==0:
  print(N)
else:
  x=N-K*(N//K)
  print(min(x,abs(x-K)))
# Judge status: Wrong Answer

x = input()
ls_x = x.split()

# print(ls_x)

for i in range(len(ls_x)):
    ls_x[i] = int(ls_x[i])

gA = [1,3,5,7,8,10,12]
gB = [4,6,9,11]

if ls_x[0] == 2 or ls_x[1] == 2:
    print("No")

if ls_x[0] == gA[i] and ls_x[1] == gA[i]:
    print("Yes")


if ls_x[0] == gB[i] and ls_x[1] == gB[i]:
    print("Yes")
else:
    ("No")