Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

max_e = 0
l = [0] * N

for i in range(N):
    l[i] = (p[i] + 1) / 2

for i in range(N - K + 1):
    e = 0
    for j in range(K):
        e += l[i + j]
    if e > max_e:
        max_e = e

print(max_e)


### FIXED CODE ###

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

# cumulated value
c_p = [0] * N
c_p[0] = p[0]

for i in range(1, N):
    c_p[i] = c_p[i - 1] + p[i]

max_e = c_p[K - 1]

for i in range(K, N):
    e = c_p[i] - c_p[i - K]
    max_e = max(max_e, e)

print((max_e + K) / 2)
### BUGGY CODE ###

n,m=map(int,input().split())
data=[]
res=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    data.append(b)
  elif b==n:
    res.append(a)
for i in data:
  if i in res:
    print('POSSIBLE')
    exit()
print('IMPOSSIBLE')

### FIXED CODE ###

n,m=map(int,input().split())
data=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    data[b-1]+=1
    if data[b-1]==2:
      print('POSSIBLE')
      exit()
  if b==n:
    data[a-1]+=1
    if data[a-1]==2:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')
### BUGGY CODE ###

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

D = []
c = []

for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split()))) 

c1 = []
c2 = []
c3 = []

from itertools import product

for i,j in product(range(N),repeat=2):
    if (i+j)%3 == 0:
        c1.append(c[i][j])
    elif (i+j)%3 == 1:
        c2.append(c[i][j])
    else:
        c3.append(c[i][j])
val=[]

for i in product(range(C),repeat=3):
    dif = 0
    if i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        for j in range(C):
            dif += D[j][i[0]] * c1.count(j+1)
            dif += D[j][i[1]] * c2.count(j+1)
            dif += D[j][i[2]] * c3.count(j+1)
        val.append(dif)

print(min(val))

### FIXED CODE ###

N,C = map(int,input().split())
 
D = []
c = []
 
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split()))) 
 
c1 = []
c2 = []
c3 = []
 
from itertools import product
 
for i,j in product(range(N),repeat=2):
    if (i+j)%3 == 0:
        c1.append(c[i][j])
    elif (i+j)%3 == 1:
        c2.append(c[i][j])
    else:
        c3.append(c[i][j])
val=[]
cnt=[[],[],[]]
 
 
for j in range(C):
    cnt[0].append(c1.count(j+1))
    cnt[1].append(c2.count(j+1))
    cnt[2].append(c3.count(j+1))
 
for i in product(range(C),repeat=3):
    dif = 0
    if i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        for j in range(C):
            dif += D[j][i[0]] * cnt[0][j]
            dif += D[j][i[1]] * cnt[1][j]
            dif += D[j][i[2]] * cnt[2][j]
        val.append(dif)
 
print(min(val))
### BUGGY CODE ###

import numpy as np

N = int(input())
an = list(map(int,input().split()))
solve = []

while len(an) > 0:
    k = np.argmax(an)
    l = max(an)
    j = 0
    for i in range(k,N):
        j = l - an[i]
        solve.append(j)
    del an[k:N]
    N -= len(solve)

solved = sum(solve)

print(solved)

### FIXED CODE ###

N = int(input())
an = list(map(int,input().split()))
solve = []

ans = 0
maxnum = 0

for i in range(N):
    maxnum = max(maxnum,an[i])
    ans += maxnum - an[i]
print(ans)
### BUGGY CODE ###

import math
k = int(input())
s = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            t = math.gcd(i,j)
            s += math.gcd(t,l)
print(s)


### FIXED CODE ###

import math
k = int(input())
s = 0
b = []
for i in range(1,k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            p = len(set([i,j,l]))
            if p ==1:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q
                b.append(q)
            elif p ==2:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q*3
                b.append(q)
            else:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q*6
                b.append(q)
print(s)
### BUGGY CODE ###

n, m =map(int, input().split())
a=list(map(int, input().split()))
for i in range(m):
  b,c =map(int, input().split())
  d = [c]*b
  a.extend(d)
a.sort(reverse=True)
print (sum(a[:n]))

### FIXED CODE ###

import heapq
from collections import defaultdict
n, m =map(int, input().split())
a=list(map(int, input().split()))

for i in range(n):
  a[i] *= -1


pri=list(set(a))
heapq.heapify(pri)
dict=defaultdict(int)
for i in a:
  dict[-i] += 1
for i in range(m):
  b, c = map(int, input().split())
  dict[c] += b
  heapq.heappush(pri,-c)
# print (pri)
# print (dict)

ans = 0
cnt = 0
old = 0
while True:
  x = heapq.heappop(pri)
  x *= -1
  if old == x:
    continue
  if cnt+dict[x] > n:
    ans += (n-cnt)*x
    cnt += n-cnt
  else:
    ans += dict[x]*x
    cnt += dict[x]
  if cnt >= n:
    break
  old = x
print (ans)
### BUGGY CODE ###

import numpy as np

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

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

if A[0] != 0:
    print(0)
    exit()
if A.count(0) != 1:
    print(0)
    exit()

k = max(A)

R = [1]
result = 1


for i in range(k):
    R.append(A.count(i + 1))

for j in range(k):
    result *= pow_k(R[j], R[j + 1])

    # if R[j + 1] % 2 == 0:
    #     result *= ((R[j] ** 2 % 998244353) ** (R[j + 1] // 2)) % 998244353
    # else:
    #     result *= R[j] * ((R[j] ** 2 % 998244353) ** (R[j + 1] // 2)) % 998244353

    result %= 998244353

    if result == 0:
        print(0)
        exit()

print(result % 998244353)


### FIXED CODE ###

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

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x % 998244353
        x *= x % 998244353
        n //= 2

    return K * x % 998244353


R = [0] * (k + 1)
result = 1
for i in A:
    R[i] += 1

if A[0] != 0 or R[0] != 1:
    print(0)
    exit()

for j in range(k):
    result *= pow_k(R[j], R[j + 1])

    if result == 0:
        print(0)
        exit()

print(result % 998244353)
### BUGGY CODE ###

x = int(input())

ans = 360//x
x = 360 % x

while x != 0:
    ans += 360//x
    x %= 360

print(ans)


### FIXED CODE ###

x = int(input())

ans = 0

while True:
    ans += 1
    if ans*x % 360 == 0:
        break

print(ans)
### BUGGY CODE ###

N, Z, W = list(map(int, input().split()))
A = [W] + list(map(int, input().split()))

S = set(A)
GX = {s:[None]*N + [abs(A[N]-s)] for s in S}
GY = {s:[None]*N + [abs(A[N]-s)] for s in S}
minGX = {s:10**10 for s in S}
maxGY = {s:0      for s in S}

#for s in S:
#    GX[s][N-1] = GY[A[N-1]][N]
#    GY[s][N-1] = GX[A[N-1]][N]

for k in range(N-1, -1, -1):
    ak = A[k]
    gx = max(GY[ak][k+1], maxGY[ak])
    gy = min(GX[ak][k+1], minGX[ak])
    for s in S:
        GX[s][k] = gx
        GY[s][k] = gy

    for s in S:
        maxGY[s] = max(GY[s][k+1], maxGY[s])
        minGX[s] = min(GX[s][k+1], minGX[s])

print(GX[W][0])


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, Z, W = list(map(int, input().split()))
A = [W] + list(map(int, input().split())) # A[0]=W, A[i]=ai

GX = [None]*N # GX[i] := YがA[i] を取った直後の状況から到達しうる最大のスコア
GY = [None]*N # GY[i] := XがA[i] を取った直後の状況から到達しうる最小のスコア
minGX = 10**20
maxGY = 0

for k in range(N-1, -1, -1):
    GX[k] = max(abs(A[k]-A[N]), maxGY)
    GY[k] = min(abs(A[k]-A[N]), minGX)
    minGX = min(minGX, GX[k])
    maxGY = max(maxGY, GY[k])

print(GX[0])
### BUGGY CODE ###

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

ans=1
if 0 in A:
    ans = 0
else:
    for a in A:
        A.reverse()
        if a > 10**18:
            ans = -1
            break
        else:
            ans *= a
            if ans > 10**18:
                ans = -1
                break
print(ans)

                


### FIXED CODE ###

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

ans=1
if 0 in A:
    ans = 0
else:
    A.sort(reverse=True)
    for a in A:
        if a > 10**18:
            ans = -1
            break
        else:
            ans *= a
            if ans > 10**18:
                ans = -1
                break
print(ans)
### BUGGY CODE ###

import sys
def main():
    input=sys.stdin.readline
    N,K=map(int,input().split())
    H=tuple(map(int,input().split()))
    if N-1<=K:
        print(H[N-1]-H[0])
        return
    inf=10**9+7
    dp=[inf]*N
    dp[0]=0

    for i,h in enumerate(H):
        if i==0:continue
        m=inf
        M=max(0,i-K)
        for ht,dpt in zip(H[M:i],dp[M:i]):
            m=min(m, dpt+abs(h-ht))
        dp[i]=m
    print(dp[N-1])

if __name__=="__main__":
    main()

### FIXED CODE ###

import sys
def main():
    input=sys.stdin.readline
    N,K=map(int,input().split())
    H=tuple(map(int,input().split()))
    if N-1<=K:
        print(H[N-1]-H[0])
        return
    inf=10**9+7
    dp=[inf]*N
    dp[0]=0

    for i,h in enumerate(H[1:]):
        m=inf
        for j in range(max(0,i-K+1), i+1):
            m=min(m, dp[j]+abs(h-H[j]))
        dp[i+1]=m
    print(dp[N-1])

if __name__=="__main__":
    main()
### BUGGY CODE ###

def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))

    tmp1_lst = []
    for i in range(k):
        tmp1_lst.append(p_lst[i])

    for i in range(n - k + 1):
        tmp2_lst = p_lst[i:i + k]
        if sum(tmp1_lst) < sum(tmp2_lst):
            tmp1_lst = tmp2_lst

    maximum = 0
    for i in range(k):
        number = tmp1_lst[i]
        maximum += number * (number + 1) / 2 / number

    print(maximum)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))
    lst = []

    for i in range(n):
        lst.append((p_lst[i] + 1) / 2)

    tmp_sum = sum(lst[:k])
    maximum = tmp_sum
    for i in range(n - k):
        tmp_sum -= lst[i]
        tmp_sum += lst[i + k]
        maximum = max(maximum, tmp_sum)

    print(maximum)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

n=int(input())
al=input().split()
al_i = [int(s) for s in al]

m = 0
for x in range(n):
   if (m < al_i[x]):
      m = al_i[x]

gm = 0

for x in range(n):
   t = al_i[x]
   al_i[x] = m
   g = al_i[0]
   for y in range(n):
      g = gcd(g,al_i[y]) 
   al_i[x] = t
   if g>gm:
      gm = g
print(gm)

### FIXED CODE ###

import sys

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

n=int(input())
al=input().split()
al_i = [int(s) for s in al]

if (n == 2):
   print(max(al_i[0],al_i[1]))
   sys.exit()

fg = [0] * n
bg = [0] * n

for x in range(n):
   if (x == 0):
       fg[0] = al_i[0]
       y = 1
   else:
      while y <= x:
         fg[y] = gcd(fg[y-1], al_i[y])
         y += 1

for x in range(n):
   if (x == 0):
      bg[0] = al_i[n-1]
      y = 1
   else:
      while y <= x:
         bg[y] = gcd(bg[y-1], al_i[n-1-y])
         y += 1

m = 0
gm = 0

for x in range(n):
   if (x == 0):
      g = bg[n-2]
   elif (x == n-1):
      g = fg[n-2]
   else:
      g = gcd(fg[x-1],bg[n-2-x])
   if (g > gm):
      gm = g

print(gm)
### BUGGY CODE ###

N = int(input())
a = []
for i in range(N) :
    a.append(int(input()))

index = 1
cnt = 0

while True:
    index = a[index - 1]
    cnt += 1
    if index == 2 :
        break
    if index == 1 :
        cnt = -1
        break

print(cnt)


### FIXED CODE ###

N = int(input())
a = []
for i in range(N) :
    a.append(int(input()))

index = 1
cnt = 0

for i in range(N):
    index = a[index - 1]
    cnt += 1
    if index == 2 :
        break
    if index == 1 :
        cnt = -1
        break
    if i == N - 1 :
        cnt = -1

print(cnt)
### BUGGY CODE ###

import math
#import itertools
num = (int)(input())
total = 0
#for i, j, k in itertools.product(list(range(1, num + 1)), list(range(1, num + 1)), list(range(1, num + 1))):
#  total += math.gcd(math.gcd(i, j), k)
#print(total)
for i in range(1, num + 1):
  for j in range(1, num + 1):
    for k in range(1, num + 1):
      total += math.gcd(math.gcd(i, j), k)
print(total)

### FIXED CODE ###

import math
num = (int)(input())
total = 0

for i in range(1, num + 1):
  for j in range(1, num + 1):
    sub = math.gcd(i, j)
    for k in range(1, num + 1):
      total += math.gcd(sub, k)
print(total)
### BUGGY CODE ###

import math

memo = dict()
def move(n):
    if n in memo:
        return memo[n]
    twonum = n // 2
    com = 0
    for i in range(twonum + 1):
        up = n - i
        com += math.factorial(up) // (math.factorial(up - i) * math.factorial(i))
    memo[n] = com
    return com

N, M = map(int, input().split())
a = []
a.append(0)
for i in range(M):
	a.append(int(input()))
a.append(N+1)

s = 1
for i in range(M+1):
	step = a[i+1] - a[i] - 1
	m = move(step)
	s = s * m
	a[i+1] += 1

print(s % 1000000007)


### FIXED CODE ###

MOD = 1000000007

fact = [0 for i in range(100001)] # fact[i] = i! mod MOD
inv_fact = [0 for i in range(100001)] # inv_fact[i] = i!のmod MODでの逆元
 
# aのn乗をPで割った余りを求めるよ
def mod_pow(a, n, P):
	if n == 0: # aの0乗は1（それはそう）
		return 1
	if n%2 == 0: # aの4乗は（aの2乗）の2乗、みたいなノリ
		x = mod_pow(a, n/2, P)
		return (x*x)%P
	# aの5乗はa×（aの4乗）、みたいなノリ
	return (a*mod_pow(a, n-1, P))%P
 
# nCk mod MODを求める！！
def comb(n, k):
	if n < k:
		return 0
	ans = fact[n]
	ans = (ans * inv_fact[k])%MOD
	ans = (ans * inv_fact[n-k])%MOD
	return ans

def move(n):
	twonum = n // 2
	com = 0
	for i in range(twonum + 1):
		up = n - i
		com += comb(up, i)
	return com

# fact,inv_factを初期化
fact[0] = inv_fact[0] = 1
for i in range(100000):
	# (i+1)!ってi!に(i+1)をかけたものだよね
	fact[i+1] = (fact[i]*(i+1))%MOD
	# (i+1)!の逆元って、i!の逆元に(i+1)の逆元をかけたものだよね
	inv_fact[i+1] = (inv_fact[i]*mod_pow(i+1, MOD-2, MOD))%MOD

N, M = map(int, input().split())
a = []
a.append(0)
for i in range(M):
	a.append(int(input()))
a.append(N+1)

s = 1
for i in range(M+1):
	step = a[i+1] - a[i] - 1
	if step > MOD:
		step = step % MOD
	m = move(step)
	s = (s * m) % MOD
	a[i+1] += 1

print(s)
### BUGGY CODE ###

import sys
from collections import deque

s = list(sys.stdin.readline().rstrip())
q = int(sys.stdin.readline())
s = deque(s)

for _ in range(q):
    query = sys.stdin.readline().split()
    if len(query) == 1:
        s.reverse()
    else:
        if query[1] == '1':
            s.appendleft(query[2])
        else:
            s.append(query[2])

print(''.join(s))


### FIXED CODE ###

import sys
from collections import deque

s = list(sys.stdin.readline().rstrip())
q = int(sys.stdin.readline())
head = 0
s = deque(s)

for _ in range(q):
    query = sys.stdin.readline().split()
    if len(query) == 1:
        head = 1 if head == 0 else 0
    elif (query[1] == '1' and head == 1) or (query[1] == '2' and head == 0):
        s.append(query[2])
    else:
        s.appendleft(query[2])

if head == 1:
    s.reverse()

print(''.join(s))
### BUGGY CODE ###

import math
from functools import reduce
from collections import defaultdict


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A_max = max(A)

    primes = set({})
    is_pairwise_coprime = True

    D = [-1] * (A_max + 1)
    for i in range(2, A_max + 1):
        if D[i] == -1:
            D[i] = i
            p = 2
            while i * p <= A_max:
                D[i * p] = i
                p += 1

    def factorization(n):
        assert 0 < n <= A_max
        primes = defaultdict(int)
        temp = n
        while temp > 1:
            primes[D[temp]] += 1
            temp = temp // D[temp]

        return primes

    for i in range(N):
        for p in factorization(A[i]).keys():
            if p in primes:
                is_pairwise_coprime = False
            else:
                primes.add(p)

    gcd_ = reduce(math.gcd, A)

    if is_pairwise_coprime:
        print('pairwise coprime')
    elif gcd_ == 1:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
from functools import reduce
from collections import defaultdict


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A_max = max(A)

    is_pairwise_coprime = True

    D = [-1] * (A_max + 1)
    for i in range(2, A_max + 1):
        if D[i] == -1:
            D[i] = i
            for j in range(i*i, A_max+1, i):
                D[j] = i

    def factorization(n):
        # assert 0 < n <= A_max
        primes_ = defaultdict(int)
        temp = n
        while temp > 1:
            primes_[D[temp]] += 1
            temp = temp // D[temp]

        return primes_

    P = [False]*(A_max+1)

    # primes = set({})
    for i in range(N):
        for p in factorization(A[i]).keys():
            # if p in primes:
            if P[p]:
                is_pairwise_coprime = False
                break
            else:
                # primes.add(p)
                P[p] = True

    gcd_ = reduce(math.gcd, A)

    if is_pairwise_coprime:
        print('pairwise coprime')
    elif gcd_ == 1:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
elements= input().split()
q=int(input())
actions=[]
for i in range(q):
    actions.append(input().split())
 
number_list=[]
count_list=[]
for e in elements:
    if int(e) in number_list:
        count_list[number_list.index(int(e))]+=1
    else:
        number_list.append(int(e))
        count_list.append(1)
 
sum=0
for i in range(len(count_list)):
    sum+=number_list[i]* count_list[i]

for act in actions:
    if int(act[0]) in number_list:
        index0=number_list.index(int(act[0]))
        
        if int(act[1]) in number_list:
            index1=number_list.index(int(act[1]))
            sum+=(number_list[index1]-number_list[index0])* count_list[index0]
            count_list[index1]+=count_list[index0]
        else:
            sum+=(int(act[1])-number_list[index0])* count_list[index0]
            number_list.append(int(act[1]))
            count_list.append(count_list[index0])

        count_list[index0]=0
 
 
    print(str(sum))

### FIXED CODE ###

n=int(input())
elements= input().split()
q=int(input())
actions=[]
for i in range(q):
    actions.append(input().split())
 
dict={}
for e in elements:
    count=dict.get(e,0)
    count+=1
    dict[e]=count
 
sum=0
for key in dict.keys():
    sum+=int(key)* dict[key]

for act in actions:
    count=dict.get(act[0],0)
    sum+=(int(act[1])-int(act[0]))*count
    count+=dict.get(act[1],0)
    dict[act[1]]=count
    dict[act[0]]=0
 
    print(str(sum))
### BUGGY CODE ###

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

ab = []
for i in a:
  for j in b:
    ab.append(i+j)
ab.sort()
abc = []
for i in ab[:-k-1:-1]:
  for j in c:
    abc.append(i+j)
abc.sort()
for i in abc[:-k-1:-1]:
  print(i)

### FIXED CODE ###

x, y, z, k = list(map(int, input().split()))
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))

ab = sorted(x+y for x in a for y in b)[:-k-1:-1]
abc = sorted(x+y for x in ab[:k] for y in c)[:-k-1:-1]
print(*abc, sep='\n')
### BUGGY CODE ###

import math

k = int(input())

cache = {}
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans = ans + cache.get( (a,b,c), math.gcd(math.gcd(a, b), c))
print(ans)

### FIXED CODE ###

import itertools
import math

k = int(input())
x = 0
for v in itertools.combinations_with_replacement(list(range(1, k+1)), 3):
    a, b, c = v
    x = x + math.gcd(math.gcd(a,b), c)

y = 0
for v in itertools.combinations(list(range(1, k+1)), 3):
    a, b, c = v
    y = y + math.gcd(math.gcd(a,b), c)

z = k * (1 + k) / 2
print( int(3 * x  + y * 3  -  2 * z))
### BUGGY CODE ###

n, x = map(int,input().split())
xl = list(map(int,input().split()))

xl.append(x)
xl.sort()
sa = []
for i in range(len(xl)-1):
    sa.append(xl[i+1] - xl[i])
sa.sort()
samin = min(sa)

flag = 0
while flag == 0:
    amari = 0
    for i in sa:
        amari += i % samin
        if amari != 0:
            break
            
    if amari == 0:
        flag = 1
        break
    else:
        for j in range(1,samin+1):
            if samin % j == 0:
                samin = samin // j
                break
print(samin)
        

### FIXED CODE ###

n, x = map(int,input().split())
xl = list(map(int,input().split()))

xl.append(x)
xl.sort()

onesam = 0

if len(xl) == 1:
    print(abs(xl[0] - x))
    exit()

for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if onesam == 0:
        onesam = abs(one_sa)
    else:
        short,big = min(onesam,one_sa),max(onesam,one_sa)
        if big % short == 0:
            onesam = short
            continue
        else:
            while big % short != 0:
                short = short -1
#                 for k in range(2,short+1):
#                     if short % k == 0:
#                         short = short // k
#                         break
            onesam = short
            
print(onesam)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

h, w, d = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for _ in range(h)]
q = int(input())
lr = [[int(x) for x in input().split()] for _ in range(q)]

dic = {}

for i in range(h):
    for j in range(w):
        dic[a[i][j]] = (i, j)

for i in range(q):
    l, r = lr[i]
    res = 0
    while l < r:
        res += abs(dic[l][0] - dic[l + d][0]) + abs(dic[l][1] - dic[l + d][1])
        l += d
    print(res)


### FIXED CODE ###

import sys
input = sys.stdin.readline

h, w, d = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for _ in range(h)]
q = int(input())
lr = [[int(x) for x in input().split()] for _ in range(q)]

dic = {}

for i in range(h):
    for j in range(w):
        dic[a[i][j]] = (i, j)

dis = {}

for i in range(1, d + 1):
    dis[i] = 0
    while i + d <= h * w:
        dis[i + d] = dis[i] + abs(dic[i + d][0] - dic[i][0]) + abs(dic[i + d][1] - dic[i][1])
        i += d

for i in range(q):
    l, r = lr[i]
    print(dis[r] - dis[l])
### BUGGY CODE ###

N = int(input())
*D, = map(int, input().split())
M = int(input())
*T, = map(int, input().split())

B = set(T)

if sum([D.count(b) >= T.count(b) for b in B]) == len(B):
    print('YES')
else:
    print('NO')

### FIXED CODE ###

import collections
import sys

N = int(input())
*D, = map(int, input().split())
M = int(input())
*T, = map(int, input().split())

d = collections.Counter(D)
t = collections.Counter(T)

for k,v in t.items():
    if d[k] >= v:
        pass
    else:
        print('NO')
        sys.exit()
print('YES')
### BUGGY CODE ###

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
ab.sort()
c = []

for i in range(M):
    if ab[i][0] == 1:
        c.append(ab[i][1])
    if ab[i][0] in c and ab[i][1] == N:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

### FIXED CODE ###

N, M = map(int, input().split())
A = set()
B = set()

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        A.add(b)
    elif b == N:
        B.add(a)

if A & B:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')