Harryxun/stf_run huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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

def main():
    n, k = MAP()
    p = LIST()
    p_ = list(accumulate(p))
    #print(p_)
    ans = 0
    tmp = 0

    for i in range(n-k):
        #print(i,p_[i+k]-p_[i])
        if tmp <= p_[i+k]-p_[i]:
            l = p[i+1:i+k+1]
            tmp = p_[i+k]-p_[i]

    #print('l:',l)
    k = list(accumulate(range(max(l)+1)))

    for x in l:
        ans += k[x]/x
        
    print(ans)

if __name__=='__main__':
    main()


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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

def main():
    n, k = MAP()
    p = LIST()
    ans = 0
    tmp = 0
    if n == k:
        k = list(accumulate(range(max(p)+1)))
        for x in p:
            ans += k[x]/x
        
        print(ans)
        sys.exit()

    p_ = list(accumulate(p))
    #print(p_)


    for i in range(n-k):
        #print(i,p_[i+k]-p_[i])
        if tmp <= p_[i+k]-p_[i]:
            l = p[i+1:i+k+1]
            tmp = p_[i+k]-p_[i]

    #print('l:',l)
    k = list(accumulate(range(max(l)+1)))

    for x in l:
        ans += k[x]/x
        
    print(ans)

if __name__=='__main__':
    main()
n = input()
A = [int(i) for i in input().split(' ')]

def trace(A):
    for index, v in enumerate(A):
        print(v, end='')
        if index != len(A) - 1:
            print(' ', end='')
    print()

def bubble_sort(A, n):
    i = n - 1
    counter = 0
    while i >= 0:
        j = i - 1
        while j >= 0:
            if A[i] < A[j]:
                A[i], A[j] = A[j], A[i]
                counter += 1
            j -= 1
        i -= 1
    trace(A)
    print(counter)

bubble_sort(A, n)

### FIXED CODE ###

n = int(input())
A = [int(i) for i in input().split(' ')]
# A = '0 33 43 62 29 0 8 52 56 56 19 11 51 43 5 8 93 30 66 69'.split(' ')
# A = [int(i) for i in A]

def trace(A):
    for index, v in enumerate(A):
        print(v, end='')
        if index != len(A) - 1:
            print(' ', end='')
    print()

def bubble_sort(A, n):
    i = 0
    counter = 0
    while i <= n - 1:
        j = n - 1
        while j >= i + 1:
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                counter += 1
            j -= 1
        i += 1
    trace(A)
    print(counter)

bubble_sort(A, n)
N,K=map(int, input().split())
p=20
count=0
for i in range(N):
  if i>=K:
    count+=1
  else:
    for j in range(20):
      if i*pow(j,2)>=K:
        ans+=pow(j,1/2)
        break
    
  
    
print(count/100+i/j*ans)

### FIXED CODE ###

import math
N,K=map(int, input().split())
p=20
count=0
ans=0
for i in range(N):
  if (i+1)>=K:
    count+=1
  else:
    for j in range(20):
      if (i+1)*math.pow(2,j)>=K:
        ans+=math.pow(1/2,j)
        break
    
  
if N<K:
    print(1/N*ans)
else:
    print(count/N+1/N*ans)
import itertools
n, m, q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(q)]
Max = 0
for A in itertools.combinations_with_replacement(range(1, m + 1) n):
    #score = sum([d for a, b, c, d in abcd if C[b - 1] - C[a - 1] == c])
    score = 0
    for ai, bi, ci, di in abcd:
        if A[bi - 1] - A[ai - 1] == ci:
            score += di
    Max = max(Max, score)
    #print(C)
print(Max)

### FIXED CODE ###

import itertools
n, m, q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(q)]
Max = 0
for A in itertools.combinations_with_replacement(range(1, m + 1), n):
    #score = sum([d for a, b, c, d in abcd if C[b - 1] - C[a - 1] == c])
    score = 0
    for ai, bi, ci, di in abcd:
        if A[bi - 1] - A[ai - 1] == ci:
            score += di
    Max = max(Max, score)
    #print(C)
print(Max)
N = int(input())
w = list(map(int, input().split(' ')))


border = N // 2
w1 = sum(w[:border])
w2 = sum(w[border:])

sub = w1 - w2
direction = None
if sub < 0:
  # w1が大きい
  direction = -1
elif sub > 0:
  # w2が大きい
  direction = 1
else:
  # 両者等しい
  print('0')
  return

prev_sub = 0
while(True):
  prev_sub = sub
  w1 += direction * w[border]
  w2 += -direction * w[border]
  border += direction

  sub = w1 - w2
  if abs(sub) >= abs(prev_sub):
    print(abs(sub))
    return
    
  
  
      

### FIXED CODE ###

N = int(input())
w = list(map(int, input().split(' ')))


border = N // 2
w1 = sum(w[:border])
w2 = sum(w[border:])

sub = w1 - w2
direction = None
if sub > 0:
  # w1が大きい
  direction = -1
  border -= 1
elif sub < 0:
  # w2が大きい
  direction = 1
else:
  # 両者等しい
  print('0')
  exit()

prev_sub = 0
while(True):
  prev_sub = sub
  w1 += direction * w[border]
  w2 += -direction * w[border]
  border += direction

  sub = w1 - w2
  if abs(sub) >= abs(prev_sub):
    print(abs(prev_sub))
    exit()
h,w=map(int,input().split())
lis=[list(input()) for i in range(h)]

fin=[]

for l in lis:
  if l.count(".") != w:
    fin.append(l)
  else:  
    h=h-1

num=[]
for i in range(w):
  cnt=0
  for f in fin:
    if f[i] == ".":
      cnt+=1
  if cnt == h:
    num.append(i)
      
for i in num:
  for f in fin:
    f.pop(i)
    
for i in fin:
  print(*i)

### FIXED CODE ###

h,w=map(int,input().split())
lis=[list(input()) for i in range(h)]

fin=[]
num=[0]*w

for l in lis:
  if l.count(".") != w:
    fin.append(l)
  for i in range(w):
    if l[i]==".":
      num[i]+=1

for f in fin:
  ans=[]
  for i in range(len(num)):
    if num[i]!=h:
      ans.append(f[i])
  print(*ans,sep='')
x = int(input())
y = int(input())

print(x*y)

### FIXED CODE ###

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

print(a * b)
n,s=open(0);a=i=j=0
while j<int(n):
 if s[l:j]in s[j:]:a=max(a,j-i);j+=1
 else:i+=1
print(a)

### FIXED CODE ###

from subprocess import*
with open('e.cpp','w')as f:f.write(r"""
#include<iostream>
using namespace std;
main(){
  int n;
  string s;
  cin>>n>>s;
  int a=0;
  for(int i=0;i<n;++i){
    int t=0;
    for(int j=0;j<n-i;++j){
      t=(t+1)*(s[j]==s[j+i]);
      a=max(a,min(t,i));
    }
  }
  cout<<a;
}""")
call(('g++','e.cpp'))
call('./a.out')
main()
    k,q = map(int, input().split())
    D=list(map(int, input().split()))

    for _ in range(q):
        n,x,m=map(int, input().split())
        mods=[d%m for d in D]

        #Sで総和を作成,何回通過したかを計算
        a=sum(mods)
        S=sum(mods)*((n-1)//k)+x%m
        S+=sum(mods[:(n-1)%k])
        through=S//m

        #カウント回数が答え
        ans=n-through-1
        #カウントしたうち0を省く
        ans-=mods.count(0)*((n-1)//k)+mods[:(n-1)%k].count(0)
        print(ans)
main()

### FIXED CODE ###

import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

k,q=map(int,readline().split())
D=np.array(readline().split(),dtype=np.int64)
NXM = map(int, read().split())

NXM=iter(NXM)
NXM=zip(NXM,NXM,NXM)

for n,x,m in NXM:
    tmpD=D%m
    SD=np.hstack((np.zeros(1,dtype=np.int64), tmpD))#結合
    SD=np.cumsum(SD)
    n-=1
    x=x%m
    x+=SD[-1]*(n//k)
    x+=SD[n%k]
    count=(k-np.count_nonzero(tmpD))*(n//k)
    count+=n%k-np.count_nonzero(tmpD[:n%k])
    ans=n-x//m-count
    print(ans)
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans = 1
for i in range(N):
    ans *= A[i]
    if ans >> 10**18:
        flg = False
        break
if flg == False:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans = 1
flg = True
for i in range(N):
    ans *= A[i]
    if A[-1] != 0:
        if ans > 10**18:
            flg = False
            break
    if A[-1] == 0:
        ans = 0
        break
if flg == False:
    print(-1)
else:
    print(ans)
import math
N, = map(int, input().split())
xs = []
ys = []
for _ in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)

def bb(a,b,c,d,e,f):
    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f
    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))
    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))
    return px, py


pxs = []
pys = []
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            px, py = bb(xs[i],ys[i],xs[j],ys[j],xs[k],ys[k])
            pxs.append(px)
            pys.append(py)
for i in range(N):
    for j in range(i+1, N):
        pxs.append((xs[i]+xs[j])/2)
        pys.append((ys[i]+ys[j])/2)

rr = 10**10
for px, py in zip(pxs,pys):
    r = 0
    for x, y in zip(xs, ys):
        r = max(r, (x-px)**2+(y-py)**2)
    rr = min(rr, r)
print(rr**0.5)


### FIXED CODE ###

import math
N, = map(int, input().split())
xs = []
ys = []
for _ in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)

def bb(a,b,c,d,e,f):
    if not (c-a)*(f-b)-(e-a)*(d-b):
        return None, None
    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f
    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))
    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))
    return px, py


pxs = []
pys = []
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
#            print(i,j,k)
            px, py = bb(xs[i],ys[i],xs[j],ys[j],xs[k],ys[k])
            if not px:
                continue
            pxs.append(px)
            pys.append(py)
for i in range(N):
    for j in range(i+1, N):
        pxs.append((xs[i]+xs[j])/2)
        pys.append((ys[i]+ys[j])/2)

rr = 10**10
for px, py in zip(pxs,pys):
    r = 0
    for x, y in zip(xs, ys):
        r = max(r, (x-px)**2+(y-py)**2)
    rr = min(rr, r)
print(rr**0.5)
num = int(input())
i = 0
while True:
    bef = range(1,i)
    i += 1
    aft = range(1,i)
    if bef < num <= aft:
        print(i-1)
        break

### FIXED CODE ###

num = int(input())
i = 1
bef = 0
while True:
    bef += i-1
    aft = bef + i
    if bef < num <= aft:
        print(i)
        break
    i += 1
S = input()
K = 'keyence'

bf = False
judge = False
kn = 0
for i in range(len(S)):
    if S[i] == K[kn]:
        if bf == True:
            judge = True
        kn += 1
    else:
        if judge == True:
            print('NO')
            exit()
        if bf == True:
            continue
        else:
            bf = True

if kn == 7:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

S = input()
for i in range(7):
    if S[:i] + S[-7+i:] == 'keyence':
        print('YES')
        exit()
print('NO')
def judge1(Num,a):
    s = list(range(Num+1))
    for l in range(2,Num+1):
        if Num%l == 0:
            alpha = list(a)
            j = int(Num/l - 1)
            b = []
            c = []
            for i in range(j+1):
                b.append(alpha[i])
            for k in range(l):
                c = c + b
            if alpha == c:
                s[l] = 1
            else:
                s[l] = 0
        else:
            s[l] = 0
    return s


N = int(input())
S = input()
a = judge1(N,S)
if 1 == a[2]:
    print("yes")
else:
    print("No")

### FIXED CODE ###

def judge(N,str):
    a = list(str)
    b = []
    c = []
    if N%2 == 0:
        for k in range(int(N/2)):
            b.append(a[k])
            c.append(a[k+int(N/2)])
        if b == c:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
N = int(input())
S = input()
judge(N,S)
while True:
   D=input()
   
   if str.isupper(D):
       print("A")
   else:
        print("a")

### FIXED CODE ###

a=input()
   
if str.isupper(a):
    print("A")
else:
    print("a")
import string

n = int(raw_input())
while n != 0:
	from = []
	to = []
	for i in xrange(n):
		l = raw_input().split()
		from.append(l[0])
		to.append(l[1])
	a = string.maketrans(''.join(from), ''.join(to))
	s = []
	for i in xrange(int(raw_input())):
		s.append(raw_input().strip())
	print s.translate(a)
	n = int(raw_input())

### FIXED CODE ###

import string

n = int(raw_input())
while n != 0:
	l  = [raw_input().split() for i in xrange(n)]
	f = [i for i,j in l]
	t = [j for i,j in l]
	d = string.maketrans(''.join(f), ''.join(t))
	s = [raw_input().strip() for i in xrange(int(raw_input()))]
	print ''.join(s).translate(d)
	n = int(raw_input())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M-2)
elif N != 1 and M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))


### FIXED CODE ###

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

if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M-2)
elif N != 1 and M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))
# coding: utf-8
N, M = map(int, input().split())
d = {}
ans = ["0" for _ in range(N)]
for i in range(M):
    s, c = map(int, input().split())
    if s not in d.keys():
        d[s-1] = c
        ans[s-1] = str(c)
    else:
        if d[s-1] != c:
            ans = -1
            print(ans)
            exit()
if ans[0] == "0" and 0 not in d.keys():
    ans[0] = "1"
ans = "".join(ans)
if len(str(int(ans))) != N:
    ans = -1
print(ans)

### FIXED CODE ###

# coding: utf-8
N, M = map(int, input().split())
d = {}
ans = ["0" for _ in range(N)]
for i in range(M):
    s, c = map(int, input().split())
    if str(s) not in d.keys():
        d[str(s)] = c
        ans[s-1] = str(c)
    else:
        if d[str(s)] != c:
            print(-1)
            exit()
if N == 1:
    print("".join(ans))
    exit()
if "1" not in d.keys():
    ans[0] = "1"
ans = "".join(ans)
if ans[0] == "0" and N != 1:
    print(-1)
else:
    print(int(ans))
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(M)]
AB.sort()

ans=0
while AB:
  a=AB[-1][0]
  AB=list(filter(lambda x:x[1]<=a,AB))
  ans+=1
  
print(ans)

### FIXED CODE ###

A=list(map(int,input().split()))
print(max(A)-min(A))
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,N):
  for j in range(1,K+1):
      dpx = min(dpx, abs(h[i]-h[N-j])+dp[N-j])
  dp.append(dpx)
print(dp[-1])

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*N
    for i in range(1,N):
        dp[i]= min(abs(h[i]-h[j])+dp[j] for j in range(max(0,i-K),i))
    print(dp[-1])
main()
import numpy as np
h, w = [int(i) for i in input().split()]
s = [input() for _ in range(h)]

a = np.zeros((h, w), dtype=np.int64)
for i in range(h):
    k = 0
    for j in range(w):
        if s[i][j] == ".":
            k += 1
        else:
            k = 0
        a[i][j] += k
for i in range(h):
    k = 0
    for j in reversed(range(w)):
        if s[i][j] == ".":
            k += 1
        else:
            k = 0
        a[i][j] += k
for j in range(w):
    k = 0
    for i in range(h):
        if s[i][j] == ".":
            k += 1
        else:
            k = 0
        a[i][j] += k
for j in range(w):
    k = 0
    for i in reversed(range(h)):
        if s[i][j] == ".":
            k += 1
        else:
            k = 0
        a[i][j] += k
a = np.where(a == 0, 0, a-3)
print(np.max(a))


### FIXED CODE ###

h, w = [int(i) for i in input().split()]
s = [input() for _ in range(h)]

a = [[0]*w for _ in range(h)]
for i in range(h):
    k = 0
    for j in range(w):
        if s[i][j] == ".":
            k += 1
        else:
            k = 0
        a[i][j] += k
for i in range(h):
    k = 0
    for j in reversed(range(w)):
        if s[i][j] == ".":
            k += 1
        else:
            k = 0
        a[i][j] += k
for j in range(w):
    k = 0
    for i in range(h):
        if s[i][j] == ".":
            k += 1
        else:
            k = 0
        a[i][j] += k
for j in range(w):
    k = 0
    for i in reversed(range(h)):
        if s[i][j] == ".":
            k += 1
        else:
            k = 0
        a[i][j] += k
b = max([max(i) for i in a])
print(0 if b == 0 else b-3)
import sys

def plus_and_check(lines):
c, d = lines.split()
number = c + d
return len(str(number))

a = []
for line in sys.stdin:
    a.append(int(line))

answer = []

i = 0
while i < len(a):
    answer = plus_and_check(a[i])

j = 0
while j < len(answer):
    print answer[i]

### FIXED CODE ###

import sys

a = []
answer_array = []
for line in sys.stdin:
    a.append(map(int, line.strip().split()))
    #except StopIteration:
        #break

for i in range(len(a)):
    sum_up = a[i][0] + a[i][1]

    answer = len(str(sum_up))

    answer_array.append(answer)

for j in range(len(answer_array)):
    print answer_array[j]
N=int(input())
M=int(input())
A=list(range(M+1))
play_day=N-sum(A)
if play_day>0:
    print(play_day)
else:
    print("-1")

### FIXED CODE ###

a,b=map(int,input().split())
C=list(map(int,input().split()))
play_day=a-sum(C)
if play_day>=0:
    print(play_day)
else:
    print("-1")
from collections import Counter

N,M = map(int, input().split())
 
# 隣接リスト
l = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int, input().split())
    l[a].append(b)
    l[b].append(a)

nodes_color = {node:0 for node in range(1, N+1)}#set([a for ab in ab_list for a in ab])}

def func(v,c):
    if nodes_color[v] == c:
        return True
    if nodes_color[v] == -c:
        return False
    
    if nodes_color[v] == 0:
        nodes_color[v] = c
    for node in l[v]:
        if not func(node, -c):
            return False
    
    return True

chk = func(1,1)

if chk:
    b,w = Counter(nodes_color.values()).values()
    print(int(b*w-M))
else:
    print(int(N*(N-1)/2-M))

### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(1000000)
N,M = map(int, input().split())
 
# 隣接リスト
l = [[] for i in range(N+1)] 
for i in range(M):
    a, b = list(map(int, input().split()))
    l[a].append(b)
    l[b].append(a)

nodes_color = {node:0 for node in range(1, N+1)}#set([a for ab in ab_list for a in ab])}

nibu = True
stack = [1]

nodes_color[1] = 1

while stack:
    node = stack.pop()
    for next_node in l[node]:
        if nodes_color[next_node]==0:
            stack.append(next_node)
            nodes_color[next_node] = - nodes_color[node]
        else:
            if nodes_color[next_node]==nodes_color[node]:
                nibu = False
                break
    if not nibu:
        break

if nibu:
    b,w = Counter(nodes_color.values()).values()
    print(int(b*w-M))
else:
    print(int(N*(N-1)/2-M))
n=int(input())
a=[]
ma=0
for i in range(n):
    a.append(int(input()))
for j in range(n):
    if(ma=a[j]):
        for h in range(n):
            if(h!=j):
                if(ma<a[h]):
                    ma=a[h]
        print(str(ma))  


### FIXED CODE ###

while True:
    n=int(input())
    if(2<=n<=200000):
        break
a=[]
for i in range(n):
        a.append(int(input()))
ma=a[0]
b=0
for j in range(1,n):
    if(ma==a[j]):
        b=a[j]
    if(ma<a[j]):
        ma=a[j]
        continue
    if(b<a[j]):
        b=a[j]
for l in range(n):
    if(a[l]!=ma):
        print(str(ma))
    else:
        print(str(b))
N, M = map(int, input().split())
s2 = []
for _ in range(M):
    s = list(map(int, input().split()))
    del s[0]
    s2.append(s)
p = list(map(int, input().split()))
 
ans = 0
for i in range(2**N):
    judge = True
    for g in range(len(s2)):
        for j in range(M-1):
            count = 0
            s3 = s2[g][j]
            if i >> (s3-1) & 1:
                count += 1
            if count % 2 != p[g]:
                judge = False
    if judge:
        ans += 1
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
res = 0

q = []
for i in range(m):
    q.append(list(map(int,input().split())))
p = list(map(int,input().split()))


for s in range(2**n): 
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1,len(q[i])):
            w = q[i][j]
            if s >> (w-1) & 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge = False
    if judge:
        res += 1
print(res)
from sys import stdin
from functools import reduce
import math

input = stdin.readline

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

xn = [abs(X - int(i)) for i in input().split()]


def main():
    print(reduce(math.gcd, xn))
    return


main()


### FIXED CODE ###

from sys import stdin

input = stdin.readline


def gcd(a, b):
    result = a
    k = 0
    n = b

    while True:
        k = result % n
        result = n
        n = k
        if k == 0:
            break

    return result


def gcd_n(numbers):
    l = numbers[0]

    for i in range(len(numbers)):
        l = gcd(l, numbers[i])

    return l


def lcm(a, b):
    g = gcd(a, b)

    return a * (b / g)


def lcm_n(numbers):
    l = numbers[0]

    for i in range(len(numbers)):
        l = lcm(l, numbers[i])

    return l


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

xn = [abs(X - int(i)) for i in input().split()]


def main():
    print(gcd_n(xn))
    return


main()
n, m = map(int, input().split())
l0, r0 = 1, n
for j in range(m):
    l1, r1 = map(int, inp)
    l0 = max(l0, l1)
    r0 = min(r0, r1)
print(max(0, r0-l0+1))


### FIXED CODE ###

N,M=map(int,input().split())
L=[]
R=[]
for m in range(M):
    Lm,Rm=map(int,input().split())
    L.append(Lm)
    R.append(Rm)
maxL=max(L)
minR=min(R)
print(max(minR-maxL+1,0))
N = int(input())
A = list(map(int, input().split()))
X = [0 for i in range(N)]
S = 0
A2n = 0
for i in range(N):
    S += A[i]
    if i % 2 == 1:
        A2n += A[i]
X[0] = S - 2 * A2n
print(X[0], end=" ")
for i in range(1, N):
    X[i] = 2 * (A[i - 1] - int(X[i - 1] / 2))
    if i = N:
        print(X[i], end="")
    else:
        print(X[i], end=" ")

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
X = [0 for i in range(N)]
S = 0
A2n = 0
for i in range(N):
    S += A[i]
    if i % 2 == 1:
        A2n += A[i]
X[0] = S - 2 * A2n
print(X[0], end=" ")
for i in range(1, N):
    X[i] = 2 * (A[i - 1] - int(X[i - 1] / 2))
    if i == N:
        print(X[i], end="")
    else:
        print(X[i], end=" ")
weather = input()

if weather == 'Sunny':
    print 'Cloudy'

if weather == 'Cloudy':
    print 'Rainy'
    
if weather == 'Rainy':
    print 'Sunny'

### FIXED CODE ###

weather = input()

if weather == 'Sunny':
    print('Cloudy')

if weather == 'Cloudy':
    print('Rainy')

if weather == 'Rainy':
    print('Sunny')
a,b = int(input().split())

if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')

### FIXED CODE ###

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

if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')
a,b,k = map(int,input().split())

ans_t = max(a-k,0)
if a-k < 0:
  ans_a = max(b-(k-a),0)
print(ans_t,ans_a)  

### FIXED CODE ###

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

ans_t = max(a-k,0)
if a-k < 0:
  b = max(b-(k-a),0)
print(ans_t,b)
a,b = map(float,input().split())
c = a*b
s,sc =c.split('.')
print(s)

### FIXED CODE ###

from decimal import Decimal
a,b = input().split()
c = int(a)*Decimal(b)
print(int(c))