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 
n,x = map(int,input().split())
ls = list(map(int,input().split()))
new = [0]*n
for i in range(n):
    new[i] = abs(ls[i]-x)
ans = new[0]
for j in range(1,n):
    ans = math.gcd(ans,new[j])
print(ans)

Submission status: Runtime Error

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

lst = []
for n in xlst:
    difference = abs(X - n)
    lst.append(difference)
ans = lst[0]
for i in range(1,N):
    ans = math.gcd(ans, lst[i])
print(ans)

Submission status: Runtime Error

Solution code:
import math
def gcd(x, y):
    gcd=math.gcd(x, y)
    return gcd


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

if n==1:
    print(abs(x-a[0]))

else:
    for i in range(n):
        a[i]=abs(x-a[i])
    
    ans=gcd(a[0], a[1])

    for i in range(2, n):
        ans=gcd(ans, a[i])
    
    print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

# input
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
k = [
    abs(X - p)
    if i == 0
    else
    abs(p - x[i - 1])
    for i, p in enumerate(x)
]
D = gcd(k[0], k[1])
for n in range(2, N):
    D = gcd(D, k[n])

print(D)

Submission status: Runtime Error

Solution code:
import math

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

gcd = 0

for x in range(N):
    gcd = math.gcd(abs(a[x] - X), gcd)
print(gcd)

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()

dis = []

for i in range(1, n+1):
    dis.append(x[i] - x[i-1])

for i in range(n):
    if i == 0:
        now = dis[i]
    else:
        now = math.gcd(dis[i], now)

print(now)

Submission status: Runtime Error

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

from itertools import combinations
from fraction import gcd
from functools import reduce

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

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


if len(X) > 1:
    DIFF = []
    for i in list(combinations(X,2)):
        
        DIFF.append(abs(i[1]-i[0]))
    print(gcd_list(DIFF))
else:
    print(X[0]-1)

Submission status: Runtime Error

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

from itertools import combinations
import math
from collections import gcd

from functools import reduce

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

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


if len(X) > 1:
    DIFF = []
    for i in list(combinations(X,2)):
        
        DIFF.append(abs(i[1]-i[0]))
    print(gcd_list(DIFF))
else:
    print(X[0]-1)

Submission status: Runtime Error

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

from itertools import combinations
import math
from functools import reduce

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

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


if len(X) > 1:
    DIFF = []
    for i in list(combinations(X,2)):
        DIFF.append(i[1]-i[0])
    print(gcd_list(DIFF))
else:
    print(X[0]-1)

Submission status: Runtime Error

Solution code:
import math
N,X=map(int,input().split())
x=[int(i) for i in input().split()]
A=[]
for t in x:
    A.append(abs(t-X))
ans=A[0]
for s in A:
    ans=math.gcd(ans,s)
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

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

x2 = x.copy() + [X]
x2 = sorted(x2)
diffs = []
for i in range(1, len(x2)):
    diffs.append(x2[i] - x2[i - 1])
if len(diffs) == 1:
    print(diffs[0])
else:
    diffs_gcd = gcd(diffs[0], diffs[1])
    for i in range(2, len(diffs)):
        diffs_gcd = gcd(diffs_gcd, diffs[i])
    print(diffs_gcd)

Submission status: Runtime Error

Solution code:
from math import gcd

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

S = []
for i in range(N):
    S.append(abs(a-X[i]))

ans = S[0]
for i in range(1, N):
    ans = gcd(ans,S[i])

print(ans)

Submission status: Runtime Error

Solution code:
import bisect

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

x.sort()
lb = bisect.bisect_left(x, X)
ub = bisect.bisect_right(x, X)
left = abs(x[lb] - X)
right = abs(x[ub] - X)
ans = min(left, right)

print(ans)

Submission status: Runtime Error

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

xlist = list(map(int, input().split()))
import math

ans = xlist[0]
for i in xlist[1:]:
    ans = math.gcd(ans, i)

print(ans)

Submission status: Runtime Error

Solution code:
import math
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))
i.append(b)
ans=0
l=[]
for j in range(1,a+1):
    l.append(abs(i[j]-i[j-1]))
for k in range(1,a):
    if k==1:
        ans=l[1]-l[0]
    else:
        ans=math.gcd(ans,l[k]-l[k-1])
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
n, start = map(int, input().split())
x = list(map(int, input().split()))

x.append(start)
x.sort()

distance = []
for i in range(n):
    dis = abs(x[i+1] - x[i])
    distance.append(dis)
if len(distance) == 1:
    D = distance[0]
else:
    D = gcd(distance[0], distance[1])
    for i in range(2, n):
        D = gcd(D, distance[i])
print(D)

Submission status: Runtime Error

Solution code:
import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(list(itertools.accumulate(X,math.gcd))[-1])

Submission status: Runtime Error

Solution code:
import math,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(list(itertools.accumulate(X,math.gcd))[-1])

Submission status: Runtime Error

Solution code:
import bisect
N, X = map(int, input().split())
x = sorted(list(map(int, input().split()))+[X])

i = bisect.bisect_left(x, X)
print(min(abs(x[i-1]-x[i]), abs(x[i]-x[i+1])))

Submission status: Runtime Error

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

i = bisect.bisect_left(x, X)
print(min(abs(x[i-1]-X), abs(X-x[i])))

Submission status: Runtime Error

Solution code:
import math
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
xmod = list(map(lambda y:int(y)-x,input().split()))
#print(xmod)
num = xmod[0]
for i in xmod:
    gcd = math.gcd(num,i)

print(gcd)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import sys
import numpy as np
from fractions import gcd

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

N, X = lr()
X = np.array(lr())
Xdiff = np.abs(np.diff(X)).tolist()
g = Xdiff[0]
for i in range(1, N):
    g = gcd(g, Xdiff[1])

answer = g
print(answer)

Submission status: Runtime Error

Solution code:
import numpy as np
from functools import reduce

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

N, X = map(int, input().split())
x = np.array(list(map(int, input().split())))
if N == 1:
    print(np.abs(x[0] - X))
else:
    x = np.abs(x - X)
    print(min(gcd(x)))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
from functools import reduce

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

N, X = map(int, input().split())
x = np.array(list(map(int, input().split())))
if N == 1:
    print(np.abs(x[0] - X))
else:
    x = np.abs(x - X)
    print(min(gcd(x)))

Submission status: Runtime Error

Solution code:
import bisect
import fractions

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

s.sort()
index = bisect.bisect_left(s,x)
s.insert(index,x)

if n == 1:
    print(s[1]-s[0])
    exit()

for i in range(len(s)-1):
    tmp = s[i+1] - s[i]
    if tmp%2 != 0:
        print(1)
        exit()
    ans = fractions.gcd(tmp,ans)

print(ans)

Submission status: Runtime Error

Solution code:
import bisect

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

s = list(set(s))
s.sort()
index = bisect.bisect_left(s,x)
index2 = bisect.bisect_right(s,x)
if index == 0:
    ans = abs(s[0] - x)
elif index2 == len(s)-1:
    ans = abs(x - s[-1])
else:
    s.insert(index,x)
    ans = min(abs(s[index] - s[index-1]), abs(s[index2] -s[index2+1]))
    
print(ans)

Submission status: Runtime Error

Solution code:
n,start=map(int,input().split())
town=list(map(int,input().split()))

kyori=[]

for item in town:
    kyori.append(abs(item-start))

import math
temp=kyori[0]

for item in kyori:
    temp=math.gcd(item, temp)

print(temp)

Submission status: Runtime Error

Solution code:
from fractions import gcd
N , X = (map(int , input().split()))
x = list(map(int , input().split()))
x.sort()
ans_list = [x[i+1] - x[i] for i in range(0,len(x)-1)]
if X == 1 or len(ans_list) == 1:
    ans = ans_list[0]
    print(ans)
elif len(ans_list) >= 2:
    gcd_list = [gcd(ans_list[i], ans_list[i+1]) for i in range(0,len(ans_list)-1)]
    ans = min(gcd_list)
    print(ans)
else:
    ans = gcd(ans_list[0] , ans_list[1])
    print(ans)

Submission status: Runtime Error

Solution code:
N , X = (map(int , input().split()))
x = list(map(int , input().split()))
x.sort()
ans_list = [x[i+1] - x[i] for i in range(0,len(x)-1)]
if X == 1:
    print(x[0]-X)
else:
    from fractions import gcd
    print(gcd(ans_list[0], ans_list[1]))

Submission status: Runtime Error

Solution code:
import math

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

ans = 0
for i in range(len(x)):
    ans = math.gcd(ans, abs(X - x[i]))

print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**5)

import math
N, X = map(int, input().split())
Y = list(map(int, input().split()))
ans = abs(Y[0]-X)
for i in range(1,N):
    ans = math.gcd(ans, abs(Y[i]-X))

print(ans)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

distances = [abs(i - X) for i in target]

def GCD(x,y):
    if x == 0:
        return y
    else:
        return GCD(y, x % y)
res = 0
for d in distances:
    res = GCD(res, d)
print(res)

Submission status: Runtime Error

Solution code:
import math


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

A.append(X)
A.sort()

diff = []
for a,b in zip(A, A[1:]):
    diff.append(b-a)

ans = diff[0]
for i in range(1,len(diff)):
    ans = math.gcd(ans, diff[i])


print(ans)

Submission status: Runtime Error

Solution code:
import math
n,x=map(int,input().split())
pl=sorted(list(map(int,input().split()))+[x])
ans=abs(pl[1]-pl[0])
if len(pl)>1:
    for i in range(len(pl)-2):
        ans=math.gcd(ans,abs(pl[i+2]-pl[i+1]))
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,x=map(int,input().split())
pl=list(map(int,input().split()))
ans=abs(pl[1]-pl[0])
if len(pl)>1:
    for i in range(len(pl)-2):
        ans=math.gcd(ans,abs(pl[i+2]-pl[i+1]))
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


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


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


N, X = map(int, input().split())
x = list(map(int, input().split()))
dif = [abs(X - x[0])]

if N > 1:
    for i in range(N - 1):
        dif.append(x[i + 1] - x[i])
print(gcd_list(dif))

Submission status: Runtime Error

Solution code:
from fractions import gcd
n, X = map(int, input().split())
x = sorted([int(i) for i in input().split()] + [X])
diff_x = [x[i + 1] - x[i] for i in range(n)]
if len(diff_x) == 1:
    print(diff_x[0])
else:
    gcd = gcd(diff_x[0], diff_x[1])
    for i in range(2, n):
        gcd = gcd(gcd, diff_x[i])
    print(gcd)

Submission status: Runtime Error

Solution code:
from fractions import gcd
n, X = map(int, input().split())
x = sorted([int(i) for i in input().split()] + [X])
diff_x = [x[i + 1] - x[i] for i in range(n)]
if len(diff_x) == 1:
    print(diff_x[0])
else:
    gcd = gcd(diff_x[0], diff_x[1])
    for i in range(2, n - 1):
        gcd = gcd(gcd, diff_x[i])
    print(gcd)

Submission status: Runtime Error

Solution code:

from functools import reduce
from fanctions import gcd
#from math import gcd

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

for i in range(n):
    x[i]=abs(x[i]-x0)

print(reduce(gcd, x))

Submission status: Runtime Error

Solution code:

from functools import reduce
from math import gcd

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

for i in range(n):
    x[i]=abs(x[i]-x0)

print(reduce(gcd, x))

Submission status: Runtime Error

Solution code:
import fractions
#import math
n,x = map(int,input().split())
x = list(map(int,input().split()))
x.sort()

if n == 1:
    print(x[0]-x)
    exit()
a = x[1] - x[0]
b = x[2] - x[1]

print(fractions.gcd(a,b))
#print(math.gcd(a,b))

Submission status: Runtime Error

Solution code:
import fractions
#import math
n,x = map(int,input().split())
x = list(map(int,input().split()))
x.sort()

if n == 1:
    print(x[0]-1)
    exit()
a = x[1] - x[0]
b = x[2] - x[1]

print(fractions.gcd(a,b))
#print(math.gcd(a,b))

Submission status: Runtime Error

Solution code:
import functools
import math

n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.append(x)
a.sort()

for i in range(len(a)):
  a[i] = abs(a[i] - x)

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

Submission status: Runtime Error

Solution code:
n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.append(x)
a.sort()

if n == 1:
  print(max(a) - min(a))
  exit()


for i in range(1,len(a)):
  if a[i] == x:
    print(min(x-a[i-1] , a[i+1] - x))
    exit()

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, = map(int, input().split())

dl = []
for i in range(N):
    dl.append(abs(x[i]-X))

print(gcd_list(dl))

Submission status: Runtime Error

Solution code:
import math


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

minimum = x[0]
for i in range(len(x)):
    x[i] = x[i] - X
    minimum = min(x[i], minimum)
# print(x, minimum)

gcd_value = math.gcd(x[0], x[0])
for i in range(len(x)):
    gcd_value = math.gcd(gcd_value, x[i])
    # print(gcd)
print(gcd_value)

Submission status: Runtime Error

Solution code:
import math


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

minimum = x[0]
for i in range(len(x)):
    x[i] = x[i] - X
    minimum = min(x[i], minimum)
# print(x, minimum)

gcd = math.gcd(x[0], x[0])
for i in range(len(x)):
    gcd = math.gcd(gcd, x[i])
    # print(gcd)
print(gcd)

Submission status: Runtime Error

Solution code:
import math


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

minimum = x[0]
for i in range(len(x)):
    x[i] = x[i] - X
    minimum = min(x[i], minimum)
# print(x, minimum)

gcd = math.gcd(x[0], x[0])
for i in range(len(x)):
    gcd = math.gcd(gcd, x[i])
    # print(gcd)
print(gcd)

Submission status: Runtime Error

Solution code:
n, x = map(int, input().split())
xlis = list(map(int, input().split()))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

d = gcd(abs(xlis[0]-x), abs(xlis[1]-x))
for i in range(2, n):
    d = gcd(d, abs(xlis[i]-x))
print(d)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#109_c
import numpy as np
import math
from functools import reduce

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

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

x.append(X)
sort_x = np.array(sorted(x))
kaisa = np.diff(sort_x, n=1).tolist()

print(gcd_list(kaisa))

Submission status: Runtime Error

Solution code:
from math import gcd

def GCD(A):
    if len(A) == 1:
        return A[0]
    elif len(A) == 2:
        g = gcd(A[0],A[1])
    else:
        g = gcd(A[0],A[1])
        for i in range(2,len(A)):
            g = gcd(g,A[i])
    return g

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

x.sort()
for i in reversed(range(N+1)):
    x[i] -= x[0]

ans = GCD(x)
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N, K = [int(i) for i in input().split(' ')]
X = [int(i) for i in input().split(' ')]

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

X.append(K)
diff = []
for i,x in enumerate(X):
    if i != 0:
        diff.append(abs(X[i-1] - x))

print(gcd_list(diff))

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

dX = [abs(X - x) for x in X_list]
if len(dX) == 1:
    print(dX[0])
    exit(0)

D = [abs(X_list[i] - X_list[i + 1]) for i in range(0, N - 1)]
res = gcd(D[0], D[1])
for x in D[2:]:
    res = gcd(res, x)

ans = 0
for d in dX:
    ans = max(gcd(res, d), ans)
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

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

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

if diff:
    ans = gcd_list(diff)
else:
    ans = x[0] - 1

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.insert(0, X)
distance = []
for i in range(1, len(x)):
    distance.append(abs(x[i] - x[i - 1]))

ans = distance[0]
for i in range(1, len(distance)):
    ans = gcd(ans, distance[i])
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)

dif = np.abs(A - K)
ans = np.gcd.reduce(dif)
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
#import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
n, k  = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(k)
x.sort()


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

dif = []
for i in range(n):
    dif.append(x[i+1]-x[i])

ans = gcd_list(dif)
print(ans)

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())
li = list(map(int,input().split()))
d = [abs(x-li[0])]

for i in range(n-1):
    d.append(abs(li[i]-li[i+1]))

print(gcd(*d))

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())
li = list(map(int,input().split()))
d = [abs(x-li[0])]

for i in range(n-1):
    d.append(abs(li[i]-li[i+1]))

print(gcd_list(d))

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
N, K = map(int, input().split())
X = sorted(list(map(int, input().split())) + [K])
# print(X)
S = [X[i+1] - X[i] for i in range(N)]
# print(S)
D = reduce(gcd, S, S[0])
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())
l=[int(i) for i in input().split()]
print(reduce(gcd,[abs(i-x) for i in l]))

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())
l=[int(i) for i in input().split()]
print(reduce(math.gcd,[abs(i-x) for i in l]))

Submission status: Runtime Error

Solution code:
N,X = map(int,input().split())
Alist = list(map(int,input().split()))
for i in range(len(Alist)):
    Alist[i] = abs(Alist[i]-X)
Alist.sort()
p = []
q = 1
for i in range(1,len(Alist)):
    if Alist[i] % Alist[0] != 0:
        p.appnd(Alist[i] % Alist[0])
        q = q*0
p.sort()
r = 1
if p != []:
    for i in range(0,len(Alist)):
        if Alist[i] % p[0] != 0:
            r = r*0
if len(Alist) > 1:
    if q == 0 and r == 1:
        print(p[0])
    if q == 0 and r == 0:
        print(1)
    if q == 1:
        print(Alist[0])
else:
    print(Alist[0])

Submission status: Runtime Error

Solution code:
import sys
from fractions import gcd

input = sys.stdin.readline

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

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

x.append(X)
x.sort()
diff = []
ans = []

for i in range(N-1):
    diff.append(x[i+1] - x[i])

for i in range(N-2):
    ans.append(gcd(diff[i], diff[i+1]))

print(min(ans))

Submission status: Runtime Error

Solution code:
import sys
from fractions import gcd

input = sys.stdin.readline

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
diff = []
ans = []

for i in range(N-1):
    diff.append(x[i+1] - x[i])

for i in range(N-2):
    ans.append(gcd(diff[i], diff[i+1]))

print(min(ans))

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
def lcm(a,b):
    if b==0:
        return a 
    return lcm(b,a%b)
ans=x[1]-x[0]

for i in range(n-1):
    sa=x[i+1]-x[i]
    ans=lcm(sa,ans)
print(ans)

Submission status: Runtime Error

Solution code:
import itertools

n, x = map(int, input().split())
a = input()

a = [int(x.strip()) for x in a.split()]

cities = a
cities.append(x)
cities.sort()

combi = []
combi = list(itertools.combinations(cities, 2))

tmp = 0
ans = 99999999999

for i in range(n*(n-1)):
  tmp = abs(combi[i][0] - combi[i][1])
  if tmp < ans:
    ans = tmp

print(ans)

Submission status: Runtime Error

Solution code:
import fractions

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

ans = fractions.gcd(abs(a[0]-x),abs(a[1]-x))
for i in range(2,n) :
  ans = fractions.gcd(ans,abs(a[i]-x))
  
print(ans)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
from functools import reduce
n,x=map(int,input().split())
p=list(map(int,input().split()))
p=np.array(p)
p=p-x

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

Submission status: Runtime Error

Solution code:
import math
import numpy as np
from functools import reduce
n,x=map(int,input().split())
p=list(map(int,input().split()))
p=np.array(p)
p=p-x

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
print(gcd=list(p))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

n, x = map(int,input().split())
City = list(map(int, input().split()))
Distance = [0] * n

for i in range(n):
    Distance[i] = abs(City[i]-x)

ans = reduce(gcd, Distance)

print(ans)

Submission status: Runtime Error

Solution code:
import math
from fractions import gcd
from functools import reduce
n,x = map(int, input().split())
y_ls = list(map(int, input().split()))
y_ls.sort()
d_ls = []

for i in range(n-1):
    distance = y_ls[i+1] - y_ls[i] 
    d_ls.append(distance)

ans = reduce(gcd, d_ls)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
from functools import reduce
from fractions import gcd
readline = sys.stdin.buffer.readline

def main():
  n, X = map(int, readline().split())
  x = np.array(readline().split(), dtype='int64')
  x -= X
  if len(x) == 1:
    ans = x[0]
  else:
    ans = reduce(gcd, x)
  print(abs(ans))
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
import sys

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

c=list(map(int,input().split()))
if b<c[0]:
    c.insert(0,b)
else:

    for i in range(a-1):
        if c[i]<=b and c[i+1]>=b:
            c.insert(i+1,b)
            break
    
    if len(c)==a:
        c.append(b)
d=[0]*(a)
for i in range(1,a+1):
    d[i-1]=c[-i]-c[-i-1]
if a==1:
    print(c[1]-b)
    sys.exit()

def gcd_list(numbers):
    import math
    from functools import reduce
    return reduce(math.gcd, numbers)
print(gcd_list(d))

Submission status: Runtime Error

Solution code:
import sys

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

c=list(map(int,input().split()))
d=[0]*(a-1)
for i in range(1,a):
    d[i-1]=c[-i]-c[-i-1]
if len(c)==1:
    print(c[0]-b)
    sys.exit()

def gcd_list(numbers):
    import math
    from functools import reduce
    return reduce(math.gcd, numbers)
print(gcd_list(d))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N, X = map(int, input().split())
a = list(map(int, input().split()))
y = []

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

for i in a:
    y.append(abs(X-i))

print(gcd_list(y))

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
y = []
import math
from functools import reduce
def gcd_list(num):
    return reduce(math.gcd, num)

for i in x:
    y.append(abs(X-i))

print(gcd_list(y))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import math

def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    x = [abs(i - X) for i in x]
    if len(x) == 1:
        print(x[0])
        exit()
    
    ans = math.gcd(x[0], x[1])
    for i in range(2,N):
        ans = math.gcd(ans,x[i])

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


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


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


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

if N == 1:
    print(abs(X-xl[0]))
    exit(0)

xl.append(X)
xl.sort()

k = []
for i in range(1, N):
    tmp = xl[i]-xl[i-1]
    if not(tmp in k):
        k.append(tmp)

if len(k) <= 1:
    print(k[0])
else:
    print(gcd_list(k))

Submission status: Runtime Error

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

ans = []
for i in range(N):
 ans.append(abs(X- x[i]))
print(np.gcd.reduce(ans))

Submission status: Runtime Error

Solution code:
from fraction import gcd
from functools import reduce
def gcd_list(xs):
    return reduce(gcd, xs)

n, x = map(int, input().split())
xs = [abs(x-i) for i in map(int, input().split())]
print(gcd_list(xs))

Submission status: Runtime Error

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

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

x.sort()
import numpy as np
x = np.array(x)
x -= X
print(gcd(*x))

Submission status: Runtime Error

Solution code:
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
def gcd(*numbers):
    return reduce(gcd, numbers)


n, start = map(int, input().split())
a = list(map(int, input().split()))
gap = []
a.append(start)
a.sort()
for i in range(1, n + 1):
    gap.append(abs(a[i] - a[i - 1]))
# print(gap)
print(gcd(*gap))

Submission status: Runtime Error

Solution code:
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
def gcd(*numbers):
    return reduce(math.gcd, numbers)


n, start = map(int, input().split())
a = list(map(int, input().split()))
gap = []
a.append(start)
a.sort()
for i in range(1, n + 1):
    gap.append(abs(a[i] - a[i - 1]))
# print(gap)
print(gcd(*gap))

Submission status: Runtime Error

Solution code:
from fractions import math
n, x = tuple(map(int, input().split(' ')))
d = 0
l = list(map(int, input().split(' ')))
for i in range(n):
  s = l[i]
  if i == 0:
    d = abs(s - x)
  else:
    d = math.gcd(d, s-x)
print(d)

Submission status: Runtime Error

Solution code:
def main():
    import fraactions
    from functools import reduce

    n, x, *l = map(int, open(0).read().split())
    a = list(map(lambda i: abs(i-x), l))
    ans = reduce(fractions.gcd, a)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    import math
    from functools import reduce

    n, x, *l = map(int, open(0).read().split())
    a = list(map(lambda i: abs(i-x), l))
    ans = reduce(math.gcd, a)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
n, x = tuple(map(int, input().split(' ')))
d = 0
l = list(map(int, input().split(' ')))
for i in range(n):
  s = l[i]
  if i == 0:
    d = s - x
  else:
    d = math.gcd(d, s-x)
print(d)