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())
h=[int(i) for i in input().split()]
tmp=abs(x-h[0])
for q in range(1,n-1):
    tmp=math.gcd(abs(x-h[q]),tmp)
print(tmp)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,x = map(int,input().split())
xs = list(map(int,input().split()))
xs.append(x)
xs.sort()
n_xs = []
for i in range(1,n):
  n_xs.append(xs[i]-xs[i-1])
import fractions
ans = n_xs[0]
for i in range(1, n-1):
  ans = fractions.gcd(ans, n_xs[i])
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
d = []
min=abs(x[0]-X)
for i in range(N):
    d.append(abs(x[i] - X))

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

g = gcd(d[0], d[1])
for i in range(2,N):
    g=gcd(g,d[i])
print(g)

Submission status: Runtime Error

Solution code:
import fractions

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

Submission status: Runtime Error

Solution code:
import fractions

n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x2=sorted(x)
a=x2[1]-x2[0]
if len(x2)<=2:
    print(a)
else:
    for i in range(1,n-1):
        b=x2[i+1]-x2[i]
        ans=fractions.gcd(a,b)
        a=ans
    print(ans)

Submission status: Runtime Error

Solution code:
import fractions

n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x2=sorted(x)
a=x2[1]-x2[0]
if len(x2)==2:
    print(a)
else:
    for i in range(1,n-1):
        b=x2[i+1]-x2[i]
        ans=fractions.gcd(a,b)
        a=ans
    print(ans)

Submission status: Runtime Error

Solution code:
import fractions

n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x2=sorted(x)
a=x2[1]-x2[0]
if len(x2)==2:
    print(a)
else:
    for i in range(1,n-1):
        b=x2[i+1]-x2[i]
        ans=fractions.gcd(a,b)
        a=b
    print(ans)

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()
Y = []
for i in range(n):
  Y.append(x[i+1]-x[i])

ans = Y[0]
for y in Y:
  ans = math.gcd(ans,y)
print(ans)

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()
y = []
for i in range(n):
  y.append(x[i+1]-x[i])

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N, X = map(int, input().split(' '))
city = list(map(int, input().split(' ')))
for i in range(N):
    city[i] = city[i] - X
    
def gcd(numbers):
    return reduce(math.gcd, numbers)

if N == 1:
    ans = city[0]
else:
    ans = gcd(city)

print(ans)

Submission status: Runtime Error

Solution code:
import fractions

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

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

Submission status: Runtime Error

Solution code:
from sys import stdin
import fractions

n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))

def gcd_all(list):
    return gcd_all([fractions.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
gcd = gcd_all(lin)
print(gcd)

Submission status: Runtime Error

Solution code:
import fractions

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

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


if n == 1:
  print(abs(L[0]-x))
else:
  L.append(x)
  L = sorted(L)
  a = L[1]-L[0]
  for i in range(n-2):
    b = L[i+2]-L[i+1]
    a = fractions.gcd(a,b)
print(a)

Submission status: Runtime Error

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

Y=[0]*N

for i in range(N):
    Y[i]=abs(X[i]-M)

tmp=Y[0]
for i in range(N-1):
    tmp=math.gcd(tmp,Y[i+1])

print(tmp)

Submission status: Runtime Error

Solution code:
import math

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

ans=0

for xi in x:
    ans=math.gcd(ans,xi-X)

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
n,x = map(int,input().split())
X = list(map(int,input().split()))
X = [x-X[0] for x in X]
print(reduce(gcd,X))

Submission status: Runtime Error

Solution code:
import numpy as np
n,x = map(int,input().split())
X = list(map(int,input().split()))
a = X[0]
X = np.array(X)
print(np.gcd.reduce(X-a))

Submission status: Runtime Error

Solution code:
import fractinos
N, X = map(int, input().split())
ary = list(map(int, input().split()))
arr = [i - X for i in ary]
ans = arr[0]
for i in range(1,N-1):
    ans = fractions.gcd(ans,arr[i])
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

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

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

if n == 1:
  a.append(a[0])

d = []
for i in range(n):
  y = abs(a[i] - x)
  d.append(y)

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

Submission status: Runtime Error

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

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

d = []
for i in range(n):
  y = abs(a[i] - x)
  d.append(y)

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

Submission status: Runtime Error

Solution code:
import fractions

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

if N == 1:
    if X < x_list[0]:
        x_list.insert(0, X)
    else:
        x_list.insert(1, X)
else:
    for i in range(N-1):
        if x_list[i] < X < x_list[i+1]:
            x_list.insert(i+1, X)

x_list.sort()

x_diff = [0]*N
for i in range(N):
    x_diff[i] = x_list[i+1] - x_list[i]

ans = x_diff[0]
for i in range(1, N):
    ans = fractions.gcd(ans, x_diff[i])
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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()
y = [ x[i]-x[i-1] for i in range(1,n)]
d = gcd(y[1], y[0])
for i in range(2,n-1):
    d = gcd(d, y[i])
print(d)

Submission status: Runtime Error

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

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 = sorted(x)
diff_x = []
for i in range(len(x)-1):
    diff_x.append(x[i+ 1] - x[i])


ans = reduce(gcd, diff_x)

print(ans)

Submission status: Runtime Error

Solution code:
import math
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    ans=b[0]
    for i in b[1:]:
        ans=math.gcd(ans,i)
    print(ans)

Submission status: Runtime Error

Solution code:
import math
n,s,*x=map(int,open(0).read().split())
a=[abs(i-s) for i in x]
set(a)
ans=min(a)
for i in a:
    if i%ans==0:
        continue
    else:
        ans=math.gcd(ans,ans%i)
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,s,*x=map(int,open(0).read().split())
a=[abs(i-s) for i in x]
set(a)
ans=a[0]
for i in a[1:]:
    if i%ans==0:
        continue
    else:
        ans=math.gcd(ans,i)
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    print(gcd(b[0],b[1]))

Submission status: Runtime Error

Solution code:
import math
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    ans=b[0]
    for i,j in zip(b[1:],b[:-1]):
        ans=min(ans,gcd(i,j))
    print(ans)

Submission status: Runtime Error

Solution code:
import math
import itertools
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    ans=b[0]
    for i,j in itertools.combinations(b, 2):
        ans=min(ans,gcd(i,j))
    print(ans)

Submission status: Runtime Error

Solution code:
import math
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
ans=a[0]
b=a[0]
for i in a[1:]:
    ans=min(ans,math.gcd(i,b))
    b=i
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
ans=b=a[0]
for i in a[1:]:
    ans=min(ans,math.gcd(i,b))
    b=i
print(ans)

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
d = 10 ** 9

for i in range(N+1):
    d = min(d, x[i+1] - x[i])

print(d)

Submission status: Runtime Error

Solution code:
import numpy as np

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

if N >= 3:
    dis_list = []
    for i in range(N - 1):
        dis_list.append(city_list[i + 1] - city_list[i])

    D_list = []
    for i in range(N - 2):
        gcd = np.gcd(dis_list[i], dis_list[i + 1])
        D_list.append(gcd)

    D = min(D_list)

    for c in city_list:
        if (c - X) % D != 0:
            print(str(1))
            break
        else:
            pass
    else:
        print(D)
elif N == 2:
    D_1 = abs(city_list[0] - X)
    D_2 = abs(city_list[-1] - X)
    gcd = np.gcd(D_1, D_2)
    print(gcd)
else:
    print(abs(city_list[0] - X))

Submission status: Runtime Error

Solution code:
import numpy as np

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

if N >= 3:
    dis_list = []
    for i in range(N - 1):
        dis_list.append(city_list[i + 1] - city_list[i])

    D_list = []
    for i in range(N - 2):
        gcd = np.gcd(dis_list[i], dis_list[i + 1])
        D_list.append(gcd)

    D = min(D_list)

    for c in city_list:
        if (c - X) % D != 0:
            print(str(1))
            break
        else:
            pass
    else:
        print(str(D))
elif N == 2:
    D_1 = abs(city_list[0] - X)
    D_2 = abs(city_list[-1] - X)
    gcd = np.gcd(D_1, D_2)
    print(gcd)
else:
    print(abs(city_list[0] - X))

Submission status: Runtime Error

Solution code:
import numpy as np

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

if N >= 2:
    dis_list = []
    for i in range(N - 1):
        dis_list.append(city_list[i + 1] - city_list[i])

    D_list = []
    for i in range(N - 2):
        gcd = np.gcd(dis_list[i], dis_list[i + 1])
        D_list.append(gcd)

    D = min(D_list)

    for c in city_list:
        if (c - X) % D != 0:
            print(str(1))
            break
        else:
            pass
    else:
        print(str(D))
else:
    print(abs(city_list[0] - X))

Submission status: Runtime Error

Solution code:
import numpy as np

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

if N >= 2:
    dis_list = []
    for i in range(N - 1):
        dis_list.append(city_list[i + 1] - city_list[i])

    D_list = []
    for i in range(N - 2):
        gcd = np.gcd(dis_list[i], dis_list[i + 1])
        D_list.append(gcd)

    D = min(D_list)

    for c in city_list:
        if (c - X) % D == 0:
            pass
        else:
            print(str(1))
    else:
        print(str(D))
else:
    print(abs(city_list[0] - X))

Submission status: Runtime Error

Solution code:
import numpy as np

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

if N >= 2:
    dis_list = []
    for i in range(N - 1):
        dis_list.append(city_list[i + 1] - city_list[i])

    city_gcd_list = []
    for i in range(N - 2):
        x = np.gcd(dis_list[i], dis_list[i + 1])
        city_gcd_list.append(x)

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

    x_min_dif = min(dif_list)

    result_list = []
    for i in range(N - 2):
        m = np.gcd(city_gcd_list[i], x_min_dif)
        result_list.append(m)

    print(min(result_list))
else:
    print(abs(X - city_list[0]))

Submission status: Runtime Error

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

print(c)

Submission status: Runtime Error

Solution code:
import math
n, X = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
x = [abs(X-i) for i in x]
c = x[0]
for i in range(1, n):
    gc = math.gcd(c, x[i])
    if c <= gc:
        continue
    else:
        c = gc
print(c)

Submission status: Runtime Error

Solution code:
line = raw_input()
N, X = [int(s) for s in line.split(' ')]
line = raw_input()
xs = [int(s) for s in line.split(' ')]

xs = [x - X for x in xs]
X = 0
if len(xs) == 1:
    print abs(xs[0])
else:
    sub = [a - b for a, b in zip(xs[1:], xs)]
    abs_sub = [abs(s) for s in sub]
    max_s = max(abs_sub)
    min_s = min(abs_sub)
    ret = 1
    for i in range(2, min_s + 1):
        if max_s % i == 0 and min_s % i == 0: 
            ret = i
    print ret

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
input = sys.stdin.readline


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

    B = np.array([abs(A[i]-X) for i in range(N)])
    print(np.gcd.reduce(B))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
import numpy as np
N, X = map(int, input().split())
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()
sa = list(np.array(xlist[1:]) - np.array(xlist[:-1]))
print(reduce(math.gcd, sa))

Submission status: Runtime Error

Solution code:
import numpy as np
N, X = map(int, input().split())
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()
sa = np.array(xlist[1:]) - np.array(xlist[:-1])
print(np.gcd.reduce(sa))

Submission status: Runtime Error

Solution code:
import numpy as np

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

print(np.gcd.reduce([x - x0 for x in X]))

Submission status: Runtime Error

Solution code:
import math

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

g = X.pop() - x0
for x in X:
    g = math.gcd(g, x - x0)
print(g)

Submission status: Runtime Error

Solution code:
import math

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

xXMin = abs(X - x[n-1])
xxMin = 10**10

if n != 1:
    for i in range(n-1):
        if xXMin > abs(X-x[i]):
            xXMin = abs(X-x[i])
        if xxMin > abs(x[i+1]-x[i]):
            xxMin = abs(x[i+1]-x[i])
    print(math.gcd(xXMin, xxMin))
else:
    print(abs(X - x[n-1]))

Submission status: Runtime Error

Solution code:
import math

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

xXMin = abs(X - x[n-1])
xxMin = 10**10

if n != 1:
    for i in range(n-1):
        if xXMin > abs(X-x[i]):
            xXMin = abs(X-x[i])
        if xxMin > abs(x[i+1]-x[i]):
            xxMin = abs(x[i+1]-x[i])
print(math.gcd(xXMin, xxMin))

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

#x_list.append(X)
#x_list_new=sorted(x_list)
x_list_new_dif=[abs(x_list_new[i]-X) for i in range(len(x_list_new))]

for i in range(len(x_list_new_dif)):
    if i==0:
        skip=x_list_new_dif[0]
    else:
        skip=gcd(skip,x_list_new_dif[i])
print(skip)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

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

tmp=dis[0]
for i in range(1,N):
    tmp = math.gcd(tmp,dis[i])
print(tmp)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
n,x=map(int,input().split())
li=np.array(input().split(),dtype=np.int64)

li=abs(li-x)

if len(li)==1:
    print(li[0])
else:
    mini=fractions.gcd(li[0],li[1])
    for i in range(2,n):
        mini=math.gcd(mini,li[i])
    print(mini)

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
n,x=map(int,input().split())
li=np.array(input().split(),dtype=np.int64)

li=abs(li-x)

if len(li)==1:
    print(li[0])
else:
    mini=fractions.gcd(li[0],li[1])
    for i in range(2,n):
        gc=math.gcd(mini,li[i])
        mini=gc
    print(mini)

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
n,x=map(int,input().split())
li=np.array(input().split(),dtype=np.int64)

li=abs(li-x)

if len(li)==1:
    print(li[0])
else:
    mini=fractions.gcd(li[0],li[1])
    for i in range(2,n):
        gc=math.gcd(mini,li[i])
        mini=min(mini,gc)
    print(mini)

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
n,x=map(int,input().split())
li=np.array(input().split(),dtype=np.int64)

li=abs(li-x)

if len(li)==1:
    print(li[0])
else:
    mini=fractions.gcd(li[0],li[1])
    for i in range(1,n):
        gc=math.gcd(mini,li[i])
        mini=min(mini,gc)
    print(mini)

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
n,x=map(int,input().split())
li=np.array(input().split(),dtype=np.int64)

li=abs(li-x)

if len(li)==1:
    print(li[0])
else:
    mini=fractions.gcd(li[0],li[i+1])
    for i in range(1,n):
        gc=math.gcd(mini,li[i])
        mini=min(mini,gc)
    print(mini)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
n,x=map(int,input().split())
li=np.array(input().split(),dtype=np.int64)

li=abs(li-x)

if len(li)==1:
    print(li[0])
else:
    mini=math.gcd(li[0],li[i+1])
    for i in range(1,n):
        gc=math.gcd(mini,li[i])
        mini=min(mini,gc)
    print(mini)

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
city_lst = list(map(int, input().split()))
city_lst.sort()
dif_lst = []
tmp = city_lst[0]
for i in range(1, N):
	dif_lst.append(city_lst[i] - tmp)
	tmp = city_lst[i]
# print(city_lst)

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	# print("D = {}".format(D))
	for dif in dif_lst:
		if dif % D != 0:
			fail = 1
			# print("fail = 1")
			break
	if not fail:
		print(D)
		break

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
city_lst = list(map(int, input().split()))
city_lst.sort()
dif_lst = []
for i in range(1, N):
	dif_lst.append(city_lst[i] - city_lst[i - 1])
# print(city_lst)

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	# print("D = {}".format(D))
	for dif in dif_lst:
		if dif % D != 0:
			# print(city_lst[i], city_lst[i - 1])
			fail = 1
			# print("fail = 1")
			break
	if not fail:
		print(D)
		break

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
city_lst = list(map(int, input().split()))
city_lst.sort()
# print(city_lst)

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	# print("D = {}".format(D))
	for i in range(1, N):
		if (city_lst[i] - city_lst[i - 1]) % D != 0:
			# print(city_lst[i], city_lst[i - 1])
			fail = 1
			# print("fail = 1")
			break
	if not fail:
		print(D)
		break

Submission status: Runtime Error

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

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	for i in range(1, N + 1):
		if not (city_lst[i] - city_lst[i - 1]) % D:
			break
	if not fail:
		print(D)
		break

Submission status: Runtime Error

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

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	for i in range(1, N + 1):
		if not city_lst[i] - city_lst[i - 1] == D:
			break
	if not fail:
		print(D)
		break

Submission status: Runtime Error

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

dis_list = [abs(int(i) - X) for i in input().split()]
if len(dis_list) < 2:
    print(dis_list[0])
    sys.exit()


first_gc = math.gcd(dis_list[0], dis_list[1])

for i in range(len(dis_list)):
    first_gc = math.gcd(first_gc, dis_list[i])

print(first_gc)

Submission status: Runtime Error

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

import functools
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,X = map(int, sys.stdin.readline().split())
    x = list(map(int, sys.stdin.readline().split()))
    l=[]
    for i in range(N):
        l.append(abs(X-x[i]))
    ans = functools.reduce(math.gcd,l)
    print(ans)

Submission status: Runtime Error

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

import functools

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,X = map(int, sys.stdin.readline().split())
    x = list(map(int, sys.stdin.readline().split()))
    l=[]
    for i in range(N):
        l.append(abs(X-x[i]))
    ans = functools.reduce(math.gcd,l)
    print(ans)

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()
y = []
for i in range(N):
    y.append(x[i + 1] - x[i])
y.sort()
ans = math.gcd(y[0], y[1])
for i in range(2, len(y)):
    ans = math.gcd(ans, y[i])
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

# 左端点から右端点に行くパターン
# 右端点から左端点に行くパターン
# 求めるのはDの最大値
# 差のgcdとか？

N, X =  map(int, sys.stdin.readline().split())
L =  list(map(int, sys.stdin.readline().split()))
L = sorted(L.append(X))
D = [x2 - x1 for x1, x2 in zip(l , l[1::])]
print(reduce(gcd, D))

Submission status: Runtime Error

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, x = na()
x_li = na()
li = []
for i in range(n):
    li.append(abs(x - x_li[i]))
import functools
import math

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

Submission status: Runtime Error

Solution code:
import math


def func():
    N, init = map(int, input().split())
    x = list(map(int, input().split()))

    x.append(init)
    x.sort()

    ans = x[1] - x[0]
    for i in range(N):
        ans = math.gcd(ans, x[i+1] - x[i])

    print(ans)


if __name__ == '__main__':
    func()

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

y = [0] * N
for i in range(N):
    y[i] = abs(X-x[i])

print(gcd_list(y))

Submission status: Runtime Error

Solution code:
import numpy as np

stdin = open(0, 'rb')
N, X = map(int, stdin.readline().split())
x = np.fromstring(stdin.readline(), dtype=np.int64, sep=' ') - X
ans = np.gcd.reduce(x)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

if len(arr) == 0:
    print(arr[0])
else:
    print(gcd(arr))

Submission status: Runtime Error

Solution code:
import numpy as np

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

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

print(gcd(arr))

Submission status: Runtime Error

Solution code:
import numpy as np
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

print(np.gcd.reduce(arr))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

print(np.gcd.reduce(arr))