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 = tuple(map(int, input().split(' ')))
d = 0
for i in range(n):
  s = int(input())
  if i == 0:
    d = s - x
  else:
    d = math.gcd(d, s-x)
print(d)

Submission status: Runtime Error

Solution code:
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
if len(x_list) >= 3:
  a = []
  for i in range(1,n+1):
    a.append(x_list[i] - x_list[i-1])
  a = sorted(a)
  c = [a[1],a[0]]
  while c[0]%c[1] != 0:
    c.append(c[0]%c[1])
    c.pop(0)
  else:
    print(c[1])
else:
  print(x_list[1]-x_list[0])

Submission status: Runtime Error

Solution code:
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)

if len(x_list) >= 3:
  a = []
  for i in range(1,n):
    a.append(x_list[i] - x_list[i-1])
  a = sorted(a)
  c = [a[1],a[0]]
  while c[0]%c[1] != 0:
    c.append(c[0]%c[1])
    c.pop(0)
  else:
    print(c[1])
else:
  print(x_list[1]-x_list[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

def main():
    n,x = map(int,input().split())
    x_s = [int(i) for i in input().split()]
    x_s = sorted(x_s)
    diffs = []
    for i in x_s:
        diffs.append(abs(x-i))
    print(reduce(gcd,diffs))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from numpy import gcd

def main():
    n,x = map(int,input().split())
    x_s = [int(i) for i in input().split()]
    x_s = sorted(x_s)
    diffs = []
    for i in x_s:
        diffs.append(abs(x-i))
    print(gcd.reduce(diffs))





if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import random
data=input().rstrip().split()
n=int(data[0])
x=int(data[1])

roc = input().rstrip().split()
roc=[abs(int(i)-x) for i in roc]
ans=0
a=min(roc)
if len(roc)>5:
  roc2=[]
  for i in range(5):
    roc2.append(roc[random.randint(0,len(roc))])
  roc2.append(max(roc))
  roc=roc2
while ans!=len(roc):
  ans=0
  for j in roc:
    if j%a==0:
      ans+=1
    else:
      continue
  a-=1
print(a+1)

Submission status: Runtime Error

Solution code:
import random
data=input().rstrip().split()
n=int(data[0])
x=int(data[1])

roc = input().rstrip().split()
roc=[abs(int(i)-x) for i in roc]
ans=0
a=min(roc)
if len(roc)>8:
  roc2=[]
  for i in range(8):
    roc2.append(roc[random.randint(0,len(roc))])
  roc=roc2
while ans!=len(roc):
  ans=0
  for j in roc:
    if j%a==0:
      ans+=1
    else:
      continue
  a-=1
print(a+1)

Submission status: Runtime Error

Solution code:
import copyfrom fractions import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))
z=copy.deepcopy(x)+[X]
z.sort()

if N>1:
  y=[0]*N
  for i in range(N):
    y[i] = z[i+1]-z[i]
  ans=y[0]
  for j in range(N):
    ans = gcd(z[j],ans)
  print(ans)
else:
  print(abs(X-x[0]))

Submission status: Runtime Error

Solution code:

n,x = map(int,input().split())
x = list(map(int,input().split()))
l = [abs(i-x) for i in x]

#ユークリッド互除法
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

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

Submission status: Runtime Error

Solution code:

n,x = map(int,input().split())
x = list(map(int,input().split()))
l = [abs(i-x) for i in x]

#ユークリッド互除法
def gcd(x,y):
    if y == 0:
        return
    else:
        return gcd(y,x%y)

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

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

n,x = map(int,input().split())
lst=list(map(int,input().split()))
new_lst=[abs(i-x) for i in lst]

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

print(gcd(*new_lst))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n,x = map(int,input().split())
lst=list(map(int,input().split()))
new_lst=[abs(i-x) for i in lst]

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

print(gcd(*new_lst))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n,x = map(int,input().split())
lst=list(map(int,input().split()))
new_lst=[abs(i-x) for i in lst]

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

print(gcd(*new_lst))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n,x = map(int,input().split())
lst=list(map(int,input().split()))
new_lst=[abs(i-x) for i in lst]

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

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

print(gcd(*new_lst))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n,x = map(int,input().split())
lst=list(map(int,input().split()))
new_lst=[abs(i-x) for i in lst]

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

print(gcd(*new_lst))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

pos.append(x)
pos.sort()

dist = []
for i in range(len(pos)-1):
    dist.append(pos[i+1]-pos[i])

print(gcd_list(dist))

Submission status: Runtime Error

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

l.insert(0, X)
diff_list = [0] * (int(len(l)/2) + 1)

ans = abs(l[0] - l[1])
ix = 2
for i in l[1:len(l)-1]:
    tmp = abs(i - l[ix])
    ans = math.gcd(ans, tmp)
    ix += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

l.insert(0, X)
diff_list = [0] * (int(len(l)/2) + 1)

for ix,i in enumerate(l[1:]):
    diff_list.append(abs(l[ix] - i))

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

print(gcd_list(diff_list))

Submission status: Runtime Error

Solution code:
import numpy as np
import fractions
import functools
N, X = map(int, input().split())
x = np.array(sorted(list(map(int, input().split()))))
x =  np.insert(x, np.where(x > X)[0], X) if len(np.where(x > X)) > 0 else np.insert(x, -1, X)
x = np.diff(x)
print(functools.reduce(fractions.gcd, x))

Submission status: Runtime Error

Solution code:
import numpy as np
import fractions
import functools
N, X = map(int, input().split())
x = np.array(sorted(list(map(int, input().split()))))
x = np.insert(x, np.where(x > X)[0], X)
x = np.diff(x)
print(functools.reduce(fractions.gcd, x))

Submission status: Runtime Error

Solution code:
from math import gcd 

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

print(ans)

Submission status: Runtime Error

Solution code:
#merci drken
from fractions import Fraction
from 
N,X = map(int,input().split())
L = [(_-X) for _ in map(int,input().split())]
def gcd_list(numbers):
  return reduce(math.gcd,numbers)
print(gcd_list(L))

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
l=list(map(int,input().split()))
l=sorted([abs(i-x) for i in l],reverse=True)

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

p=gcd(l[0],l[1])
for i in l[2:]:
    q=gcd(i,p)
    p=q
print(p)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

if n == 1:
    ans = xx[0] - x
else:
    dist = [xx[i + 1] - xx[i] for i in range(n - 1)]
    ans = reduce(math.gcd, dist)

print(ans)

Submission status: Runtime Error

Solution code:
N,X = [int(i) for i in input().split()]
xa = [int(i) for i in input().split()]
from math import gcd
lia = [0]*N
for i in range(N):
    lia[i] = abs(X-xa[i])
ans = lia[0]
for i in range(1,N):
    ans = gcd(ans,lia[i])
print(ans)

Submission status: Runtime Error

Solution code:
import math

def main():
    n, x = [int(e) for e in input().split()]
    X = [int(e) for e in input().split()]

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fractions

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

y = []

x.sort()
for i in range(1, N):
    x1 = x[i] - x[i-1]
    y.append(x1)

d = x[0] - X if X == 1 else y[0]

for i in range(1, N-1):
    d = fractions.gcd(y[i], d)

print(d)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

n, *spot = map(int, open(0).read().split())
spot.sort()
dist = set([spot[i+1]-spot[i] for i in range(n)])
print(gcd_list(dist))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    x.sort()
    l = []
    for i in range(N-1):
        l.append(x[i+1]-x[i])
    print(reduce(fractions.gcd, l))
main()

Submission status: Runtime Error

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

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())
city = list(map(int, input().split()))
city.append(x)
city = sorted(city)
diff = [city[i+1] - city[i] for i in range(len(city)-1)]

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

Submission status: Runtime Error

Solution code:
import itertools as it
import collections as col
import math
from functools import reduce

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


n,x=map(int,input().split())
P=list(map(int,input().split()))
if(n==1):
    print(abs(P[0]-x))
    exit(0)
P.sort()
if(x<=P[0]):
    P.insert(0,x)
elif(x>=P[n-1]):
    P.append(x)
else:
    for i in range(1,n):
        if(P[i-1]<=x and x<=P[i]):
            P.insert(i,x)
D=[0]
for i in range(1,n):
    D.append(P[i]-P[i-1])
print(gcd_list(D))

Submission status: Runtime Error

Solution code:
from fractions import Fraction
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
minus = []
if len(x)==1:
    ans = x[0]-X

else:
    ans = abs(x[0]-X)
    for i in range(len(x)-1):
        ans1 = abs(x[i+1]-x[i])
        ans = fractions.gcd(ans,ans1) 
print(ans)

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
l = list(map(int, input().split()))
m=[]
from functools import reduce
from math import gcd
for i in l:
    m.append(abs(i-X))
print(reduce(gcd,m))

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
l = list(map(int, input().split()))
m=[]
from functools import reduce
from math import gcd
for i in l:
    m.append(abs(i-N))
print(reduce(gcd,m))

Submission status: Runtime Error

Solution code:
xN, X = map(int, input().split())
l = list(map(int, input().split()))
m=[]
from functools import reduce
from fractions import gcd
for i in l:
    m.append(abs(i-N))
print(reduce(gcd,m))

Submission status: Runtime Error

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

n, X = map(int, input().split())
x = list(map(int, input().split()))
if len(x) == 1:
  print(abs(x[0] - X))
else:
  x.sort()
  s = []
  for i in range(n-1):
    s.append(x[i+1] - x[i])

  for i in range(len(s)-1):
    a = gcd(s[i], s[i+1])
  u = 0
  for i in range(n):
    u = max(u, gcd(abs(X-x[i]), a))
  print(u)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcd

n, x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list.sort()
dis_list = []

for i in range(n):
    dis_list.append(x_list[i+1] - x_list[i])

ans = dis_list[0]
for i in range(n):
    ans = gcd(dis_list[i],ans)

print(ans)

Submission status: Runtime Error

Solution code:
import math
n, x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list.sort()
dis_list = []
for i in range(n):
    dis_list.append(x_list[i+1]-x_list[i])

ans = dis_list[0]
for i in range(n):
    ans = math.gcd(dis_list[i],ans)

print(ans)

Submission status: Runtime Error

Solution code:
import math
n, x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list.sort()
dis_list = []
for i in range(n):
    dis_list.append(x_list[i+1]-x_list[i])

print(ans)

Submission status: Runtime Error

Solution code:
import math
n, x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list.sort()
dis_list = []
for i in range(n):
    dis_list.append(x_list[i+1]-x_list[i])

gcd = dis_list[0]
for i in range(n):
    gcd = math.gcd(dis_list[i],gcd)

print(gcd)

Submission status: Runtime Error

Solution code:
def main():
    from fractions import gcd
    n,x=map(int,input().split())
    num=[abs(int(i)-x) for i in input().split() if abs(int(i)-x)!=0]
    n=len(num)
    
    def gcd2(num,n):
        if n<=1:
          return num[0]
        elif n==2:
            return gcd(num[0],num[1])
        else:
            x=num.pop()
            return gcd(gcd2(num,n-1),x)
    
    print(gcd2(num,n))
if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    from fractions import gcd
    n,x=map(int,input().split())
    num=[abs(int(i)-x) for i in input().split()]

    def gcd2(num,n):
        if n<=1:
          return num[0]
        elif n==2:
            return gcd(num[0],num[1])
        else:
            x=num.pop()
            return gcd(gcd2(num,n-1),x)
    
    print(gcd2(num,n))
if __name__=='__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fractions
N, X = map(int, input().split())
*x, = sorted(list(map(int, input().split())))
kyori = sorted([abs(X - xx) for xx in x])
print(fractions.gcd(kyori[0], kyori[1]))

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())
x = list(map(int,input().split()))
x.sort()
dist = []

if X == 1:
    print(abs(x[0]-X))
    exit()
    
for i in range(N-1):
    dist.append(abs(x[i]-x[i+1]))

ans = dist[0]

for i in range(N-1):
    ans = gcd(ans,dist[i])

print(ans)

Submission status: Runtime Error

Solution code:
import sys
n, x = map(int, input().split())
points = [int(e) for e in input().split()]
points.sort(reverse=True)
min_difference = float('inf')
difference_list = []
for i in range(len(points)-1):
    difference_list.append(points[i] - points[i+1])
difference_list.append(abs(points[i] - x))
min_difference = min(difference_list)
difference = 0
for i in range(min_difference):
    difference = min_difference - i
    for ind, j in enumerate(set(difference_list)):
        if (j % difference) == 0:
            if ind == len(set(difference_list))-1:
                print(difference)
                sys.exit()
        else:
            break

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    if a > b:
        a, b = b, a
    if b % a == 0:
        return a
    a, b = b / a, a


def reduce(f, l):
    if len(l) == 1:
        return l[0]
    c = l[0]
    for i in l[1:]:
        c = f(c, i)
    return c


X = int(input().split()[1])
x = [abs(int(x) - X) for x in input().split()]

print(reduce(gcd, x))

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd

X = int(input().split()[1])
x = [abs(int(x) - X) for x in input().split()]

print(reduce(gcd, x))

Submission status: Runtime Error

Solution code:
from math import sqrt, floor
from functools import reduce


def divisors(a):
    return {i for i in range(1, floor(sqrt(a)) + 1) if a % i == 0}\
        .union({a // i for i in range(1, floor(sqrt(a)) + 1) if a % i == 0})


def greatest_common_divisor(a, b):
    return max(divisors(a).intersection(divisors(b)))


def greatest_common_divisor_of(lst):
    return reduce(greatest_common_divisor, lst)


X = int(input().split()[1])
xi = list(map(int, input().split()))
x = [x - X for x in xi]
print(greatest_common_divisor_of(x))

Submission status: Runtime Error

Solution code:
import fractions
a = list(map(int,input().split()))
N = a[0]
b = []
x = list(map(int,input().split()))
x.append(a[1])
x.sort()
flag = 0
for i in range(N):
    c = x[i+1] - x[i]
    if flag == 1:
        ans = fractions.gcd(c, b[i-1]) # 最大公約数を求める
    b.append(c)
    flag = 1
print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
from fractions import gcd
n,x=map(int,input().split())
x=[abx(x-int(i)) for i in input().split()]
print(reduce(gcd,x))

Submission status: Runtime Error

Solution code:
def gcd(x1, x2):
    if x2 == 0:
        return x1
    return gcd(x2, x1 % x2)

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

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

def gcd_calc(a):
  ans = a[0]
  for i in range(1, len(a)):
    ans = gcd(ans, a[i])
  return ans

x.sort()
for i,_x in enumerate(x):
  if (_x-X)>0:
    x.insert(i, X)
    break
list=[]
for i in range(len(x)-1):
  list.append(x[i+1]-x[i])

print(gcd_calc(list))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

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

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
print(max(min(B),gcd_list(B)))

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
A = list(map(int,input().split()))
​
B = []
for i in range(N):
    B.append(abs(X- A[i]))
print(min(B))

Submission status: Runtime Error

Solution code:
import math

n, x = [int(x) for x in input().split(' ')]
cities = [int(x) for x in input().split(' ')]

ans = abs(x - cities[0])
for i in range(1, n):
    ans = math.gcd(ans, x-cities[i])

print(ans)

Submission status: Runtime Error

Solution code:
import math

n, x = [int(x) for x in input().split(' ')]
cities = [int(x) for x in input().split(' ')]

ans = abs(x - cities[0])
for i in range(1, n):
    ans = math.gcd(ans, x-cities[1])

print(ans)

Submission status: Runtime Error

Solution code:
import functools
import math

n,x=map(int,input().split())
xx=[int(t) for t in input().split()]
buf=[]

for value in xx:
    buf.append(abs(value - x))

print(functools.reduce(math.gcd, buf))

Submission status: Runtime Error

Solution code:
from math import gcd

def solve(n, x0, X):
    X = [abs(x - x0) for x in X]
    g = X.pop()
    for x in X:
        g = gcd(g, x)
    return g

_n , _x0 = map(int, input().split())
_X = map(int, input().split())
print(solve(_n, _x0, _X))

Submission status: Runtime Error

Solution code:
import math

def solve(n, x0, X):
    X = [x - x0 for x in X]
    g = X.pop()
    for x in X:
        g = math.gcd(g, x)
    return g

_n , _x0 = map(int, input().split())
_X = map(int, input().split())
print(solve(_n, _x0, _X))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

N,X=map(int,input().split())
ls=[]

for _ in range(N):
    ls.append(abs(int(input())-X))

print(reduce(gcd,ls))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

N,X=map(int,input().split())
ls=[abs(int(input())-X) for _ in range(N)]

print(reduce(gcd,ls))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

numbers.append(X)
numbers = sorted(numbers)

diff_numbers = []

for i in range(len(numbers)-1):
    diff_numbers.append(abs(numbers[i] - numbers[i+1]))

gcd = gcd_list(diff_numbers)

print(gcd)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

numbers.append(X)
numbers = sorted(numbers)

diff_numbers = []

for i in range(len(numbers)-1):
    diff_numbers.append(abs(numbers[i] - numbers[i+1]))

print(gcd_list(diff_numbers))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  divisors.append(n)
  return divisors
n,x=map(int,input().split())
y=list(map(int,input().split()))
y.append(x)
y.sort()
z=[]
for i in range(n-1):
  z.append(y[i+1]-y[i])
z.sort()
p=make_divisors(z[0])
a=[]
for i in p:
  for j in z:
    if j%i:
      break
  else:
    a.append(i)
print(max(a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

print(reduce(math.gcd, x))

Submission status: Runtime Error

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

import math
from functools import reduce

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

print(gcd(*x))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x

N,X = cin.mapInt()
A = cin.mapInt()
A.append(X)

def solve():
    A.sort()
    subs = [0] * (N)
    for i in range(N):
        subs[i] = A[i + 1] - A[i]
    ans = subs[0]
    for i in range(1,N - 1):
        ans = math.gcd(ans,subs[i])
    return ans
print(solve())

Submission status: Runtime Error

Solution code:
import fractions
import math

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

#print(x)

difflis = [0] * (n)

for i in range(n):
    difflis[i] = math.fabs(x[i+1] - x[i])

ans = difflis[0]
for i in range(i,len(difflis)):
    ans = fractions.gcd(ans,difflis[i])
print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions
import math

n,X= map(int,input().split())
x = list(map(int, input().split()))
ins = 0
for i in range(n):
    if x[i] >=X:
        ins = i
        break
#x.insert(ins,X)
x = sorted(x)

print(x)

difflis = [0] * (n)

for i in range(n):
    difflis[i] = math.fabs(x[i+1] - x[i])

ans = difflis[0]
for i in range(i,len(difflis)):
    ans = fractions.gcd(ans,difflis[i])
print(int(ans))

Submission status: Runtime Error

Solution code:
#提出の際にmathをfractionsにする(2020/1/17現在)
from math import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
if (N == 1):
   print(ans)
   exit(0)
for i in range(1, len(x)):
    ans = gcd(abs(x[i] - x[i - 1]), ans)
print(ans)

Submission status: Runtime Error

Solution code:
#提出の際にmathをfractionsにする(2020/1/17現在)
from math import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
if (N == 1):
   print(x[0])
   exit(0)
ans = abs(X - x[0])
for i in range(1, len(x)):
    ans = gcd(abs(x[i] - x[i - 1]), ans)
print(ans)

Submission status: Runtime Error

Solution code:
import math

N, X = map(int, input().split())
xlist = list(map(int, input().split()))
gaplist = []
for i in range(N):
    tmp = abs(xlist[i] - X)
    if tmp==0:
        tmp = 1
    gaplist.append(tmp)

ans = gaplist[0]
for i in range(1,N):
    ans = math.gcd(ans, gaplist[i])
    #次のxとの最大公約数を動的計画法求めるメソッド O(logX)

print(ans)

Submission status: Runtime Error

Solution code:
import math

N, X = map(int, input().split())
xlist = list(map(int, input().split()))
gaplist = []
for i in range(N):
    tmp = abs(xlist[i] - X)
    if tmp==0:
        tmp = 1
    gaplist.append(tmp)

ans = gaplist[0]
for i in range(1,N):
    print(ans)
    ans = math.gcd(ans, gaplist[i])
    #次のxとの最大公約数を動的計画法求めるメソッド O(logX)

print(ans)

Submission status: Runtime Error

Solution code:
import math

N, X = map(int, input().split())
xlist = list(map(int, input().split()))
gaplist = []
for i in range(N):
    tmp = abs(xlist[i] - X)
    gaplist.append(tmp)

ans = gaplist[0]
for i in range(1,N):
    print(ans)
    ans = math.gcd(ans, gaplist[i])
    #次のxとの最大公約数を動的計画法求めるメソッド O(logX)

print(ans)

Submission status: Runtime Error

Solution code:
n,x = map(int,input().split())
a = list(map(int, input().split()))
b = [0]*(n-1)
for i in range(n-1):
    b[i]= a[i+1]-a[i]
c = 0
for j in b:
    c = gcd(c, j)
print(c)

Submission status: Runtime Error

Solution code:
import math

n, x = map(int, input().split())
x = list(map(int, input().split()))
m = min(x)
xr = [e - m for e in x]
if n == 1:
    gcd = xr[0]
    print(gcd)
    exit()
gcd = math.gcd(xr[0], xr[1])
for i in xr[2:]:
    gcd = math.gcd(gcd, i)
print(gcd)

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())
y = list(map(int,input().split()))
dist = []
for b in y:
    dist.append(abs(b-x))
print(gcd_list(dist))

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.append(x)
a=sorted(a)
b=[0]*n
for i in range(n):
  b[i]=(a[i+1]-a[i])
import fractions
x1=(b[0]*b[1]) // fractions.gcd(b[0],b[1])
i=2
while i<=n-1:
  lcm=(x1*b[i])//fractions.gcd(x1,b[i])
  x1=lcm
  i+=1
print(x1)

Submission status: Runtime Error

Solution code:
import fractions

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

d = list(map(int, input().split()))

m = (d[0] - x).abs()
for di in d:
  m = fractions.gcd(m, (di - x).abs())

print(m)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce


def gcd_expand(values):
    return reduce(gcd, values)


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

x_abs = [abs(X - i) for i in x]
print(gcd_expand(x_abs))

Submission status: Runtime Error

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

if len(x)==1:
  print(x[0]-X)
else:
  if base==N-1:
    a=abs(int(x[base-1])-X)
    b=abs(int(x[base-2])-X)
  elif base==x[0]:
    a=abs(int(x[base+2])-X)
    b=abs(int(x[base+1])-X)
  else:
    a=abs(int(x[base-1])-X)
    b=abs(int(x[base+1])-X)
  if a<b:
    a,b=b,a
  i=b

  while a%b!=0:
    a,b=b,a%b
    
print(b)

Submission status: Runtime Error

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

if len(x)==1:
  print(x[0]-X)
else:
  a=abs(int(x[base-1])-X)
  b=abs(int(x[base+1])-X)
  if a<b:
    a,b=b,a
  i=b

  while a%b!=0:
    a,b=b,a%b
    
print(b)

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,x=map(int,input().split())
h=[abs(x-int(a)) for a in input().split()]
print(reduce(gcd,h))

Submission status: Runtime Error

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