Problem:


Score : 300 points

Problem Statement

There are N cities on a number line. The i-th city is located at coordinate x_i.

Your objective is to visit all these cities at least once.

In order to do so, you will first set a positive integer D.

Then, you will depart from coordinate X and perform Move 1 and Move 2 below, as many times as you like:

Move 1: travel from coordinate y to coordinate y + D.

Move 2: travel from coordinate y to coordinate y - D.

Find the maximum value of D that enables you to visit all the cities.

Here, to visit a city is to travel to the coordinate where that city is located.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

1 \leq X \leq 10^9

1 \leq x_i \leq 10^9

x_i are all different.

x_1, x_2, ..., x_N \neq X

Input

Input is given from Standard Input in the following format:

N X
x_1 x_2 ... x_N

Output

Print the maximum value of D that enables you to visit all the cities.

Sample Input 1

3 3
1 7 11

Sample Output 1

2

Setting D = 2 enables you to visit all the cities as follows, and this is the maximum value of such D.

Perform Move 2 to travel to coordinate 1.

Perform Move 1 to travel to coordinate 3.

Perform Move 1 to travel to coordinate 5.

Perform Move 1 to travel to coordinate 7.

Perform Move 1 to travel to coordinate 9.

Perform Move 1 to travel to coordinate 11.

Sample Input 2

3 81
33 105 57

Sample Output 2

24

Sample Input 3

1 1
1000000000

Sample Output 3

999999999



Sample input:
3 3
1 7 11


Sample output:
2

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

N, X = map(int,(input().split()))
x = list(map(int,input().split()))
x_min = min(x)

x_0 = [x_- x_min for x_ in x]

ans = gcd_list(x_0)

if N==1:
    ans = abs(x[0] - X)

print(ans)

Submission status: Runtime Error

Solution code:
import math
import functools
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
br = []
for r in ar:
    br.append(abs(b-r))
ans = functools.reduce(math.gcd,br)
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
br = []
for r in ar:
    br.append(abs(b-r))
def gcd(*numbers):
    return reduce(math.gcd,numbers)
print(gcd(*br))

Submission status: Runtime Error

Solution code:
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

for i in range(N):
	x[i] -= X
if N == 1:
	print(abs(x[0]))
else:
	a = x[0]
	for i in range(N - 1):
		b = x[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a

print(abs(a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n,x = map(int,input().split())
A = list(map(int,input().split()))
for i in range(n):
    A[i] -= x
print(reduce(math.gcd, A))

Submission status: Runtime Error

Solution code:
import functools
import math
N,X = map(int,input().split())
L = list(map(int,input().split()))
L.append(X)
L = sorted(L)
M = [0]*(len(L)-1)
for i in range(0,len(L)-1):
    M[i] = L[i+1]-L[i]
print(functools.reduce(math.gcd,M))

Submission status: Runtime Error

Solution code:
import functools
import math
N,X = map(int, input().split())
L = list(map(int, input().split()))
L.append(X)
L = sorted(L)
M = [0]*(len(L)-1)
for i in range(0,len(L)-1):
    M[i] = L[i+1]-L[i]
print(functools.reduce(math.gcd,M))

Submission status: Runtime Error

Solution code:
import functools
import math
N,X = map(int, input().split())
L = list(map(int, input().split()))
L.append(X)
L = sorted(L)
M = [0]*(len(L)-1)
for i in range(0,len(L-1)):
    M[i] = L[i+1]-L[i]
print(functools.reduce(math.gcd,M))

Submission status: Runtime Error

Solution code:
####################
def pri(n):
  i = 2
  X = {}
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i in X:
        X[i] = X[i] + 1
      else:
        X[i] = 1
    i += 1
  if n > 1:
    X[n] = 1
  return X
####################


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

x = list(map(int, input().split()))
x.append(X)

x.sort()

d = []
for i in range(N):
  dif = x[i+1] - x[i]
  if dif not in d:
    d.append(dif)

d.sort()

if len(d) == 1:
  print(d[0])
  exit()

min = d[0]
P = pri(d[0])

for i in range(1,len(d)):
  if d[i] % min != 0:
    t = pri(d[0])
    min = 1
    for j in P:
      if j in t:
        P[j] = min(P[j], t[j])
        min *= j ** P[j]
      else:
        del P[j]

print(min)

Submission status: Runtime Error

Solution code:
import math
n, init = map(int,input().split())
x = list(map(lambda x: abs(int(x)-init), input().split()))
g = x[0]
for i in range(1,n):
    g = math.gcd(g,x[i])
print(g)

Submission status: Runtime Error

Solution code:
import math
n, init = map(int,input().split())
x = list(map(lambda x: abs(int(x)-init), input().split()))
g = x[0]
for i in range(n):
    g = math.gcd(g,x[i])
print(g)

Submission status: Runtime Error

Solution code:
n, init = map(int, input().split())
x = list(map(int, input().split()))
def gcd(m,n):
    if n > m:
        gcd(n,m)
    elif m%n == 0:
        return n
    else:
        gcd(n,m%n)
def myabs(x):
    if x < 0:
        return -x
    else:
        return x
g = myabs(x[0]-init)
for i in range(n):
    if g == 1:
        break
    elif (myabs(x[i]-init) % g) != 0:
        g = gcd(g,x[i])
print(g)

Submission status: Runtime Error

Solution code:
n, init = map(int, input().split())
y = list(map(int, input().split()))
x = list(map(lambda a: abs(a-init),y))
def gcd(m,n):
    if n > m:
        gcd(n,m)
    elif m%n == 0:
        return n
    else:
        gcd(n,m%n)
g = x[0]
for i in range(n):
    if g == 1:
        break
    elif (x[i] % g) != 0:
        g = gcd(g,x[i])
print(g)

Submission status: Runtime Error

Solution code:
n, init = map(int, input().split())
x = list(map(lambda a: abs(int(a)-init), input().split()))
def gcd(m,n):
    if n > m:
        gcd(n,m)
    elif m%n == 0:
        return n
    else:
        gcd(n,m%n)
g = x[0]
for i in range(n):
    if g == 1:
        break
    elif x[i] % g != 0:
        g = gcd(g,x[i])
print(g)

Submission status: Runtime Error

Solution code:
import math
n, init = map(int, input().split())
x = list(map(lambda a: abs(int(a)-init), input().split()))
g = x[0]
for i in range(n):
    if g == 1:
        break
    elif x[i] % g != 0:
        g = math.gcd(g,x[i])
print(g)

Submission status: Runtime Error

Solution code:
import math
n, init = map(int, input().split())
x = list(map(lambda a: int(a)-init, input().split()))
g = x[0]
for i in range(n-1):
    if g == 1:
        break
    elif x[i+1] % g != 0:
        g = math.gcd(g,x[i+1])
print(g)

Submission status: Runtime Error

Solution code:
import math
n, init = map(int, input().split())
x = list(map(lambda a: int(a)-init, input().split()))
g = x[0]
for i in range(n-1):
    g = math.gcd(g,x[i+1])
print(g)

Submission status: Runtime Error

Solution code:
from functools import reduce

def gcd(a, b):
    if a == b:
        return a
    if a > b:
        return gcd(a-b, b)
    else:
        return gcd(a, b-a)

N, X = map(int, input().split())
x = [int(i) for i in input().split()]

delta = [abs(X-i) for i in x]
print(reduce(gcd, delta))

Submission status: Runtime Error

Solution code:
# coding: utf8

import math
from functools import reduce

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


def read_int_n():
    return list(map(int, input().split()))


n, x = read_int_n()
y = read_int_n()
y.append(x)

y.sort()
w = [y[i] - y[i-1] for i in range(1, len(y))]
print(gcd(*w))

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
x_list = list(map(int, input().split()))

x_abs = []
for i in x_list:
    x_abs.append(abs(X - i))

def gcd(i, j):
    if i % j == 0:
        return j
    else:
        k = i % j
        gcd(j, k)

x_abs.sort(reverse=True)
ans = 0
if len(x_abs) == 1:
    ans = x_abs[0]
else:
    for i in range(N-2):
        temp = gcd(x_abs[i], x_abs[i + 1])
        ans = gcd(temp, x_abs[i + 2])
    
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

N, X = map(int,input().split()) 
nums=list(map(int,input().split()))
nums=list(map(lambda i: abs(i - X),nums))
 
D = reduce(gcd, nums)
print(D)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

N, X = map(int, input().split())
nums = list(map(int, input().split()))
nums.append(X)
nums.sort()
dists = []

for i in range(N):
    dist = nums[i + 1] - nums[i]
    dists.append(dist)
    
D = gcd(*dists)

print(D)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N, X = map(int, input().split())
nums = list(map(int, input().split()))
nums = list(map(lambda i: abs(i - X), nums))

D = reduce(gcd, nums)
print(D)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

N, X = map(int, input().split())
nums = list(map(int, input().split()))
nums.append(X)
nums.sort()
dists = []

for i in range(N):
    dist = nums[i + 1] - nums[i]
    dists.append(dist)
    
D = gcd(*dists)

print(D)

Submission status: Runtime Error

Solution code:
import math

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

max = abs(t[0]-x)
for i in range(1,len(t)):
    t[i] = abs(t[i]-x)
    max = math.gcd(t[i],max)

print(max)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
from functools import reduce
N,X=map(int,input().split(" "))
x=np.array(list(map(int, input().split(' '))))
y=abs(x-X)
print(reduce(math.gcd,y))

Submission status: Runtime Error

Solution code:
import math
N,X=map(int,input().split(" "))
x=np.array(list(map(int,input().split(' '))))
y=abs(x-X)
print(reduce(math.gcd,y))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
array = []
for i in range(N-1):
    array.append(x[i+1]-x[i])

if len(array) > 1:
    result = reduce(gcd, array)
else:
    result = array[0]
print(result)

Submission status: Runtime Error

Solution code:
from fraction import gcd
from functools import reduce

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
array = []
for i in range(N-1):
    array.append(x[i+1]-x[i])

if len(array) > 1:
    result = reduce(gcd, array)
else:
    result = array[0]
print(result)

Submission status: Runtime Error

Solution code:
import math
n,x=map(int,input().split())
l = [abs(int(i) - x) for i in input().split()]
ans = l[0]
for i in l:
    y = math.gcd(ans,i)
    ans = y
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,x=map(int,input().split())
l = [abs(int(i) - x) for i in input().split()]
ans = l[0]
for i in l:
    ans = math.gcd(ans,i)
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
n,x=map(int,input().split())
l = [abs(int(i) - x) for i in input().split()]
ans = l[0]
for i in l:
    ans = gcd(ans,i)
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

N, X = map(int, input().split())
A = list(map(lambda a: abs(X - a), map(int, input().split())))

ans = A[0]
for a in A:
    ans = gcd(ans, a)
print(ans)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)


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

if not(St in X):
    X.append(St)
X = sorted(X)

del_X = []
for i in range(len(X)-1):
    del_X.append(X[i+1] - X[i])
del_X = sorted(list(set(del_X)))

# print(X)
# print(del_X)

for i in range(len(del_X)):
    if i == 0:
        tmp = gcd(del_X[i],del_X[i])
    else:
        tmp = gcd(tmp, X_del[i])
print(tmp)

Submission status: Runtime Error

Solution code:
import math

N, X = list(map(int, input().split()))
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()

m = xlist[1] - xlist[0]
for i in range(1, len(xlist) - 1):
    d = xlist[i + 1] - xlist[i]
    m = math.gcd(d, m)
print(m)

Submission status: Runtime Error

Solution code:
import sys
from functools import reduce
from math import gcd


def main():
    n, x = list(map(int, input().split()))
    values = list(map(int, input().split()))
    values.append(x)
    values.sort()
    v = [values[i + 1] - values[i] for i in range(len(values) - 1)]
    res = v[0]
    print(reduce(gcd, v[1:], v[0]))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math
N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
abs_xlist = list(map(lambda x:abs(X - x), xlist))
ans = abs_xlist[0]

for i in range(N):
    if abs_xlist[i] % ans != 0:
        num = math.gcd(abs_xlist[i],ans)
        ans = min(num,ans)
print(ans)

Submission status: Runtime Error

Solution code:
import math
N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
abs_xlist = list(map(lambda x:abs(X - x), xlist))
ans = abs_xlist[0]

for i in range(N):
    if abs_xlist[i] % ans != 0:
        num = math.gcd(xlist[i],ans)
        ans = min(num,ans)
print(ans)

Submission status: Runtime Error

Solution code:
import math
N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
abs_xlist = list(map(lambda x:abs(X - x), xlist))
abs_xlist.sort()
ans = abs_xlist[0]

for i in range(N):
    if abs_xlist[i] % ans != 0:
        num = math.gcd(xlist[i],ans)
        ans = min(num,ans)
print(ans)

Submission status: Runtime Error

Solution code:
import functools
import math
N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
xlist.sort()
xlist_2 = list(map(lambda x:x - xlist[0], xlist))

if len(xlist) == 1:
    ans = xlist[0] - X
elif len(xlist) >= 2:
    ans = functools.reduce(math.gcd,xlist_2)

print(abs(ans))

Submission status: Runtime Error

Solution code:
import math
N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
xlist.sort()

if len(xlist) == 1:
    ans = xlist[0] - X
elif len(xlist) >= 2:
    ans = xlist[1] - xlist[0]
    for i in range(0,N-1):
        num = xlist[i+1] - xlist[i]
        ans = math.gcd(ans,num)

print(ans)

Submission status: Runtime Error

Solution code:
from bisect import bisect_right
n,X = map(int,input().split())
a = sorted(list(map(int,input().split())))
ind = bisect_right(a,X)
if ind == 0:
    print(a[1]-X)
elif ind == n:
    print(X-a[ind-1])
else:
    print(min(a[ind]-X,X-a[ind-1]))

Submission status: Runtime Error

Solution code:
from bisect import bisect_right
n,X = map(int,input().split())
a = list(map(int,input().split()))
ind = bisect_right(a,X)
if ind == 0:
    print(a[1]-X)
else:
    print(min(a[ind]-X,X-a[ind-1]))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(nums):
    return reduce(math.gcd, nums)

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

x_sorted = x
x_sorted.append(X)
x_sorted.sort()

diff = []
for i, xi in enumerate(x_sorted):
    if i == 0:
        continue
    else:
        diff.append(xi - x_sorted[i-1])

print(gcd(diff))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
gcd_list=[]
for i in range(N):
    gcd_list.append(X-x[i])

print(abs(gcd_t(gcd_list)))

Submission status: Runtime Error

Solution code:
def gcd_t(s):
    if(len(s)==1):    return s[0]
    else:
        if(len(s)==2):    return gcd(s[0],s[1])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
gcd_list=[]
for i in range(N):
    gcd_list.append(X-x[i])
    
print(abs(gcd_t(gcd_list)))

Submission status: Runtime Error

Solution code:
def gcd_t(s):
    if(len(s)==1):    return s[0]
    if(s[-2]==0):    return s[-1]
    else:
        if(len(s)==2):
            return gcd(s[-1],s[-2])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
gcd_list=[]
for i in range(N):
    gcd_list.append(X-x[i])
    
print(abs(gcd_t(gcd_list)))

Submission status: Runtime Error

Solution code:
def gcd_t(s):
    if(len(s)==1):    return s[0]
    if(s[-2]==0):    return s[-1]
    else:
        if(len(s)==2):
            return gcd(s[0],s[1])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
gcd_list=[]
for i in range(N):
    gcd_list.append(X-x[i])
    
print(abs(gcd_t(gcd_list)))

Submission status: Runtime Error

Solution code:
def gcd_t(s):
    if(len(s)==1):    return s[0]
    if(s[-2]==0):    return s[-1]
    else:
        if(len(s)==2):
            return gcd(s[0],s[1])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
x.sort()
    
gcd_list=[]
for i in range(N-1):
    gcd_list.append(x[i+1]-x[i])
for i in range(N):
    gcd_list.append(X-x[i])
    
print(abs(gcd_t(gcd_list)))

Submission status: Runtime Error

Solution code:
def gcd_t(s):
    if(len(s)==1):    return s[0]
    if(s[-2]==0):    return s[0]
    else:
        if(len(s)==2):
            return gcd(s[0],s[1])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
x.sort()
    
gcd_list=[]
for i in range(N-1):
    gcd_list.append(x[i+1]-x[i])
for i in range(N):
    gcd_list.append(X-x[i])
    
print(abs(gcd_t(gcd_list)))

Submission status: Runtime Error

Solution code:
import math

N,X=input().split()
N=int(N)
X=int(X)
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
de=[]#deference 差
for i in range( 0, len(x)-1 ):
    dei=x[i+1]-x[i]
    if(dei>0):
        de.append(dei)

#最大公約数だった
#その数を作る素因数をすべて抜き出し、
#一致するものをすべて抜き出せばできる
gcd=de[0]#最大公約数
for i in range(1,len(de)):
    gcd=math.gcd(gcd,de[i])
print(gcd)

Submission status: Runtime Error

Solution code:
N,X=input().split()
N=int(N)
X=int(X)

x = [int(i) for i in input().split()]
x.append(X)
x.sort()

de=[]#deference 差
for i in range( 0, len(x)-1 ):
    dei=x[i+1]-x[i]
    if(dei>0):
        de.append(dei)

#最大公約数だった
#その数を作る素因数をすべて抜き出し、
#一致するものをすべて抜き出せばできる
import math
gcd=de[0]#最大公約数
for i in range(1,len(de)):
    gcd=math.gcd(gcd,de[i])

print(gcd)

Submission status: Runtime Error

Solution code:
import fractions.

[n, x] = list(map(int, input().split()))
xn = list(map(int, input().split()))

xn = sorted(xn + [x])
gcd = xn[1] - xn[0]
b = xn[1]
for a in xn[2:]:
    gcd = fractions..gcd(b - a, gcd)
    b = a
print(gcd)

Submission status: Runtime Error

Solution code:
import math

[n, x] = list(map(int, input().split()))
xn = list(map(int, input().split()))

xn = sorted(xn + [x])
gcd = xn[1] - xn[0]
b = xn[1]
for a in xn[2:]:
    gcd = math.gcd(b - a, gcd)
    b = a
print(gcd)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N,X = map(int,input().split(" "))
x = list(map(int,input().split(" ")))
Y = [i-X for i in x]

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

print(gcd_list(Y))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N,X = map(int,input().split(" "))
x = list(map(int,input().split(" ")))
Y = [i-X for i in x]

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

print(gcd_list(Y))

#Yの最大公約数を求める

Submission status: Runtime Error

Solution code:
import sys
# Python < 3.5
# from math import gcd
# Python >= 3.5
from fractions import gcd

def gcdall(*args):
  if len(args) == 1:
    return args[0]
  return gcdall(gcd(args[0], args[1]), *args[2:])

N, X = map(int, input().split())
d = [abs(int(s) - X) for s in input().split()]

print(gcdall(*d))

Submission status: Runtime Error

Solution code:
n, x = map(int,input().split())
li_x = list(map(int,input().split()))

for i in range(len(li_x)):
    li_x[i] = li_x[i] - x
    if li_x[i] < 0:
        li_x[i] = - li_x[i]
gcd = 10 ** 10
gc = 10 ** 10
for i in range(len(li_x)):
    for j in range(len(li_x)):
        if li_x[i] > li_x[j]:
            while li_x[j] != 0:
                li_x[i], li_x[j] = li_x[j], li_x[i] % li_x[j]
            g = li_x[i]
        if gc > g:
            gc = g
    if gcd > gc:
        gcd = gc
print(gcd)

Submission status: Runtime Error

Solution code:
from functools import reduce

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

for i in range(len(li_x)):
    li_x[i] = li_x[i] - x
    if li_x[i] < 0:
        li_x[i] = - li_x[i]
gcd = 10 ** 10
gc = 10 ** 10
for i in range(len(li_x)):
    for j in range(len(li_x)):
        if li_x[i] > li_x[j]:
            while li_x[j] != 0:
                li_x[i], li_x[j] = li_x[j], li_x[i] % li_x[j]
            g = li_x[i]
        if gc > g:
            gc = g
    if gcd > gc:
        gcd = gc
print(gcd)

Submission status: Runtime Error

Solution code:
import math


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

for i in range(len(li_x)):
  if li_x[i] - x < 0:
    li_x[i] =x - li_x[i]
  else:
    li_x[i] = li_x[i] -x

if len(li_x)==1:
  print(li_x[0])

elif len(li_x)==2:
  print(gcd(li_x[0],li_x[1]))

else:
  g =gcd(li_x[0],li_x[1])
  k=2
  while k<len(li_x):
    g=gcd(g,li_x[k])
    k+=1
  print(g)

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

Submission status: Runtime Error

Solution code:
import math

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)
      

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

for i in range(len(li_x)):
    if li_x[i] - x < 0:
        li_x[i] =x - li_x[i]
    else:
        li_x[i] = li_x[i] -x

g =gcd(li_x[0],li_x[1])
k=2
if len(li_x)>2:
  while k<len(li_x):
    g=gcd(g,li_x[k])
    k+=1
print(g)

Submission status: Runtime Error

Solution code:
import math

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)
      

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

for i in range(len(li_x)):
    if li_x[i] - x < 0:
        li_x[i] =x - li_x[i]
    else:
        li_x[i] = li_x[i] -x

g =gcd(li_x[0],li_x[1])
k=2
while k<len(li_x):
  g=gcd(g,li_x[k])
  k+=1
print(g)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n, x = map(int,input().split())
li_x = list(map(int,input().split()))
for i in range(len(li_x)):
    if li_x[i] - x < 0:
        li_x[i] =x - li_x[i]
    else:
        li_x[i] = li_x[i] -x

g = reduce(math.gcd,li_x)
print(g)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n, x = map(int,input().split())
li_x = list(map(int,input().split())) + [x]
li_x = sorted(li_x)
li_s = []
print(li_x)

for i in range(len(li_x)-1):
    li_s = li_s + [li_x[i+1]-li_x[i]]

g = reduce(math.gcd,li_s)
print(g)

Submission status: Runtime Error

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

N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(N==1):
    print(abs(x[0]-X))
    exit()
x=list(map(lambda y:abs(y-X) , x))
ans=gcd(x[0],x[1])
for i in range(2:N):
    ans=gcd(x[i],ans)
    
print(ans)

Submission status: Runtime Error

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

N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(N==1):
    print(abs(x[0]-X))
    exit()
x=list(map(lambda y:abs(y-X) , x))
x.sort()
print(math.gcd(x[0],x[1]))

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  n,  = max(a, b), min(a, b)
  if n % m == 0:
    return m
  else:
    return gcd(m, n%m)

N, X = [int(item) for item in input().split()]
cities = [int(item) for item in input().split()]
if N == 1:
  print(abs(cities[0]-X))
  exit()

mod = gcd(abs(cities[0] - X), abs(cities[1] - X))
for i in range(2, N):
  mod = gcd(mod, abs(cities[0] - X))
print(mod)

Submission status: Runtime Error

Solution code:
import math
N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(len(x)==1):
    print(abs(x[0]-X))
    exit()
xx=list(map(lambda y:abs(y-X) , x))
xx.sort()
print(math.gcd(xx[0],xx[1]))

Submission status: Runtime Error

Solution code:
import math
N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(len(x)==1):
    print(abs(x[0]-X))
    exit()
x=list(map(lambda y:abs(y-X) , x))
x.sort()
print(math.gcd(x[0],x[1]))

Submission status: Runtime Error

Solution code:
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(N):
    ans = math.gcd(ans,x[i+1]-x[i])
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(N-1):
    ans = gcd(ans,x[i+1]-x[i])
print(ans)

Submission status: Runtime Error

Solution code:
import functools
import math

n, X = map(int, input().split())
x = input().split()
x = [int(m) for m in x]

z = x
z.append(X)
z.sort()

w = []

for i in range(n + 1):
    if i != 0:
        w.append(z[i] - z[i - 1])

gcd = functools.reduce(math.gcd, w)
print(gcd)

Submission status: Runtime Error

Solution code:
def LCM(m,n):
  for i in range(1,m+1)[::-1]:
    if n%i==0:
      return i
    
N,X=(int(i) for i in input().split(' '))
x=[int(i) for i in input().split(' ')]
x=[X]+x
D=x[1]-x[0]
for i in range(N):
  D=LCM(D,x[i+1]-x[i])
print(D)

Submission status: Runtime Error

Solution code:
n,x = map(int,input().split())
li = list(map(int,input().split()))

li2 = [i-x for i in li]
li3 = [abs(i) for i in li2]
a = min(li3)
flag = 1
b = li3[0]

import math

for i in li3:
    b = math.gcd(b,i)

print(b)

Submission status: Runtime Error

Solution code:
n,x = map(int,input().split())
li = list(map(int,input().split()))

li2 = [i-x for i in li]
li3 = [abs(i) for i in li2]
a = min(li3)
flag = 1

import math
from functools import reduce

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

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

print(gcd_list(li3))

Submission status: Runtime Error

Solution code:
N,X = map(int,input().split())
x_list = list(map(int,input().split()))

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

def gcd_mul(lis):
    if len(lis) == 2:
        return gcd(lis[0],lis[1])
    elif len(lis) == 1:
        return lis[0]
    new = gcd(lis[0],lis[1])
    del lis[0]
    lis[0] = new
    return gcd_mul(lis)

x_list.append(X)
x_list.sort()

x_len = list()
for i in range(1,N+1):
    x_len.append(x_list[i]-x_list[i-1])

x_len.sort(reverse = True)
print(gcd_mul(x_len))

Submission status: Runtime Error

Solution code:
# |xs - X|の最大公約数を求めればOK
N, X = map(int, input().split())
*xs, = map(int, input().split())
*xs, = map(lambda a: abs(a - X), xs)

xs = sorted(xs, reverse=True)

def egcd(a, b, c):
    if not c:
        return gcd(a, b)
    else:
        return egcd(gcd(a, b), c[0], c[1:])

def gcd(a, b=0):
    if b ==0:
        return a
    else:
        return gcd(b, a % b)

if len(xs) == 1:
    print(xs[0])
else:
    print(egcd(xs[0], xs[1], xs))

Submission status: Runtime Error

Solution code:
import math

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

L = [list(input().split())]

print(math.gcd_list(L))

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

N, X = map(int, input().split())
a = [abs(int(i)-X) for i in input().split()]
ans = gcd(a[0], a[1])

if N == 1:
    print(abs(X-a[0]))
else:
    for i in range(N):
        ans = gcd(ans, a[i])
    print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def calc(n_list):
    return reduce(math.gcd, n_list)

N, X = map(int, input().split())
c = list(map(int, input().split()))
c = [ abs(x-X) for x in c ]

print(calc(c))

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce


def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)


N, X=map(int,input().split( ))
x=list(map(int,input().split( )))
def minus_d(x):
	x = abs(x-X)
	return x

def percent_d(x):
	x = x % d
	return x

dis = list(map(minus_d, x))
ans = gcd_list(dis)
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
a,b=input().split()
l=sorted([int(x)-int(b) for x in input().split()])
print(abs(reduce(math.gcd, l)))

Submission status: Runtime Error

Solution code:

import math
from functools import reduce
a,b=input().split()
l=sorted([int(x)-int(b) for x in input().split()])
print(abs(reduce(math.gcd, l)))

Submission status: Runtime Error

Solution code:
N, X = [int(_) for _ in input().split()]
xs = [abs(int(_) - X) for _ in input().split()]

def gcd(p, q):
    if p < q:
        return gcd(q, p)
    if q == 0:
        return p
    else:
        return gcd(q, p % q)

def gcdList(numbers):
    if len(numbers) == 1:
        return numbers[0]
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList(xs))

Submission status: Runtime Error

Solution code:
N, X = [int(_) for _ in input().split()]
xs = [abs(int(_) - X) for _ in input().split()]

def gcd(p, q):
    if p < q:
        return gcd(q, p)
    if p % q == 0:
        return q
    return gcd(q, p % q)

def gcdList(numbers):
    if len(numbers) == 1:
        return numbers[0]
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList(xs))

Submission status: Runtime Error

Solution code:
N, X = [int(_) for _ in input().split()]
xs = [int(_) - X for _ in input().split()]

def gcd(p, q):
    if p < 0:
        return gcd(-p, q)
    if q < 0:
        return gcd(p, -q)
    if p < q:
        return gcd(q, p)
    if p % q == 0:
        return q
    return gcd(q, p % q)

def gcdList(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList(xs))