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:
def run(n, x, xx):
    xx.append(x)
    xx = sorted(xx)
    d = [xx[i+1]-xx[i] for i in range(n)]
    d = sorted(d)
    min_d = d[0]
    if len(d) == 1:
        return min_d
    for i in range(1, len(d)):
        min_d = fractions.gcd(min_d, d[i])
    return min_d


def main():
    n, x = map(int, input().split())
    xx = list(map(int, input().split()))
    print(run(n, x, xx))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def gcd(a, b):
	if b == 0:
		return a
	_max = max(a, b)
	_min = min(a, b)
	return gcd(_min, _max % _min)

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

for i in range(N):
	if X < x[i]:
		x.insert(i, X)
		N += 1
diff = []
for i in range(N - 1):
	d = abs(x[i] - x[i+1])
	diff.append(d)

res = diff[0]
for i in range(N - 2):
	res = gcd(res, diff[i + 1])
print res

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

for i in range(len(arr)):
    arr[i] -= X
    
df = []
for i in range(1, len(arr)):
    df.append(arr[i] - arr[i-1])

if(N == 1):
    df.append(arr[0])

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

print(gcd_list(df))

Submission status: Runtime Error

Solution code:
import functools
import math

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

for x_i in x:
    subX.append(abs(x_i - X))

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

Submission status: Runtime Error

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

c.append(X)
c.sort()

D = float('inf')

for i in range(1,N+2):
    if c[i] - c[i-1] < D:
        D = c[i] - c[i-1]

print(int(D))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S, X):
    Xs = []
    for x in X:
        t = abs(x - S)
        Xs.append(t)

    if N == 1:
        return Xs[0]
    ans = math.gcd(Xs[0], Xs[1])
    for i in range(2, N):
        ans = math.gcd(ans, Xs[i])

    return ans


def main():
    N, S = read_int_n()
    X = read_int_n()
    print(slv(N, S, X))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
import math

line = input().split()
N = int(line[0])
X = int(line[1])

line = input().split()


diff = [abs(int(x)-X) for x in line]

min_ = math.gcd(diff[0], diff[0])

for df in diff:
    min_ = min(min_, math.gcd(diff[0], df))

print(min_)

Submission status: Runtime Error

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

def gcd(l):
    x = max(l)
    y = min(l)
    if x % y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z
        
if N == 1:
    print(x_list[0] - X)
    exit()

values = np.sort(np.array(x_list))[1:] - min(x_list)
print(gcd(values))

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()
y_list=[]
for i in range(N):
    y_list.append(x_list[i+1]-x_list[i])
z_list=list(set(y_list))


if len(z_list)==1:
    print(z_list[0])
else:
    out=math.gcd(z_list[0], z_list[1])
    if len(z_list)>=3:
        for i in range(len(z_list)-3):
            out=math.gcd(out, z_list[i+2])
    print(out)

Submission status: Runtime Error

Solution code:
n, s = map(int, input().split())
xxx = [abs(s - y) for y in map(int, input().split())]
d = 0
while True:
    d = min(xxx)
    xxx = [x % d for x in xxx]
    if all(x == 0 for x in xxx):
        break
print(d)

Submission status: Runtime Error

Solution code:
#import functools
import math
N,X = map(int,input().split())
L = list(map(int,input().split()))
L.append(X)
L = sorted(L)
D = []
for i in range(N) :
    d = L[i+1] - L[i]
    D.append(d)

D = sorted(D)
if N != 1 :
    for j in range(N-1) :
        answer = math.gcd(D[0],D[1])
        gcd = math.gcd(D[i-1],D[i])
        if answer > gcd :
            answer = gcd
else :
    answer = D[0]
print(answer)

Submission status: Runtime Error

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

xlist = map(int, input().split(" "))

x_dst = [xi - x for xi in xlist]

subt = lambda a, b = a-b
dst_list = map(subt, x_dst[:-1], x_dst[1:])

max_temp = dst_list[0]
for d in dst_list:
  max_c = 1
  for i in range(abs(d)):
    if abs(d) % i == 0:
      max_c = i
  if max_c < max_temp:
    max_temp = max_c
print(max_temp)

Submission status: Runtime Error

Solution code:
import math

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

m = min([min(toshi),X])

M = math.gcd(toshi[0]-m,X-m)

for i in toshi:
    M = math.gcd(M,i-m)

print(M)

Submission status: Runtime Error

Solution code:
import math
def gcd2(x3):
    if len(x3)>2:
        return gcd2([math.gcd(x3[0],x3[1]),]+x3[2:])
    elif len(x3) ==2:
        return math.gcd(x3[0],x3[1])
    else:
        return x3[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x2=sorted(x)
x3=[]
for i in range(len(x2)-1):
    x3.append(x2[i+1]-x2[i])
print(gcd2(x3))

Submission status: Runtime Error

Solution code:
import math
import functools import reduce

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[inputcities[i]-X for i in range(N)]
D = reduce(math.gcd, cities)
print(D)

Submission status: Runtime Error

Solution code:
import math
n, x = map(int, input().split())
xl = [int(_) for _ in input().split()]
for i in range(n):
    if x > xl[i]:
        xl[i] = x - xl[i]
    else:
        xl[i] = xl[i] - x
x_gcd = xl[0]
if n > 1:
    for i in range(1, n):
        x_gcd = math.gcd(x_gcd, xl[i])
print(x_gcd)

Submission status: Runtime Error

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

for i in range(1,n):
    ans = math.gcd(ans,x[i]-X)
print(ans)

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
l=list(map(int,input().split()))
sub=[abs(c-x) for c in l]

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

for x_i in x:
    subX.append(abs(x_i - X))

print(gcd_list(subX))

Submission status: Runtime Error

Solution code:
import functools import reduce
import math

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[inputcities[i]-X for i in range(N)]
D = functools.reduce(math.gcd, cities)
print(D)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

def solve():
  n, start = map(int, input().split())
  cities = input().split(" ")
  # Startを0からに変更
  cities = [int(i) - start for i in cities]
  print(gcd(*cities))

solve()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

if N == 1:
    print(x[0] - X)
else:
    x.append(X)
    x.sort()
    x = [n - x[0] for n in x]
    D = reduce(math.gcd, x)
    print(D)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fraction
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if N > 1:
    mini = x[1] - x[0]
    if mini > abs(X - x[0]) and abs(X - x[0]) != 0:
        mini = abs(X - x[0])
elif N == 1:
    mini = abs(x[0] - X)
for i in range(1, N):
    if mini > x[i] - x[i - 1]:
        mini = x[i] - x[i - 1]
    if mini> abs(X - x[i]) and abs(X - x[i]) != 0:
        mini = abs(X - x[i])
    if (x[i] - x[i - 1]) % mini != 0:
        #break
        mini = fraction.gcd(mini, x[i] - x[i - 1])
    if abs(X - x[i]) % mini != 0:
        #break
        mini = fraction.gcd(mini, X - x[i])
        

print(mini)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S, X):
    Xs = []
    for x in X:
        t = x - S
        if t < 0:
            t *= -1
        elif t == 0:
            continue
        Xs.append(t)

    if N == 1:
        return Xs[0]
    ans = math.gcd(Xs[0], Xs[1])
    for i in range(2, N):
        ans = math.gcd(ans, Xs[i])

    return ans


def main():
    N, S = read_int_n()
    X = read_int_n()
    print(slv(N, S, X))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import functools
import math

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[inputcities[i]-X for i in range(N)]
D = functools.reduce(math.gcd, cities)
print(D)

Submission status: Runtime Error

Solution code:
import math

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

xx0 = [abs(xi-x0) for xi in x ]

y = xx0[0]
for yi in xx0:
    y = math.gcd(y, yi)
    
print(y)

Submission status: Runtime Error

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


inputs = input().strip().split()

N  = int(inputs[0])
X  = int(inputs[1])

xi = list(map(lambda x: abs(X - int(x)), input().strip().split()))

if N == 1:
    print(xi[0])
else:
    a = xi[0]
    b = xi[1]

    nx = gcd(a, b)

    for i in range(2, len(xi)):
        nx = gcd(nx, xi[i])     

    print(nx)

Submission status: Runtime Error

Solution code:
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
L=sorted(x+[X])
def GCD(LIST):
	if len(LIST)==2:
		return math.gcd(LIST[0],LIST[1])
	else:
		return GCD([math.gcd(LIST[0],LIST[1])]+LIST[2::])
if N==1:
	print(abs(X-x[0]))
else:
	LL=[L[i+1]-L[i] for i in range(N-1)]
	print(GCD(LL))

Submission status: Runtime Error

Solution code:
import math

info = list(map(int, input().split(" ")))
pos = list(map(int, input().split(" ")))

temp = [abs(info[1]-pos[i]) for i in range(len(pos))]

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

Submission status: Runtime Error

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

xx = [abs(xxx - X) for xxx in x]

l = xx[0]
if len(xx) > 1:
    for i in xx[1:]:
        l = math.gcd(l, i)


print(l)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(3000)

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

def gcd_list(li):
	if len(li) > 2:
		x = gcd(li[-1], li[-2])
		li = li[:-2] + [x]
		return gcd_list(li)
	else:
		return gcd(li[0], li[1])

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

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

li = [abs(i - X) for i in x]

li = [i for i in li if i]

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

Submission status: Runtime Error

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

N, X = map(int, input().split())
xn = list(map(int, input().split()))
xn2 = []

for xi in xn:
    xn2.append(xi - X)

xn2.sort()

gcd_num = max(xn2)
for xi2 in xn2:
    tmp = math.gcd(xi2,gcd_num)
    if tmp < gcd_num:
        gcd_num = tmp

print(gcd_num)

Submission status: Runtime Error

Solution code:
import math

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

xx = []

for i in range(n):
    xx.append(abs(x[i]-X))

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

xg = math.gcd(xx[0],xx[1])

if n == 2:
    print(xg)
    exit()

for i in range(2,n):
    xg = math.gcd(xg,xx[i])

print(xg)

Submission status: Runtime Error

Solution code:
n, x = map(int,input().split())
arr = list(map(int,input().split()))
ans = []

arr.append(x)
arr.sort()

if arr.index(x):
    ans.append(arr[arr.index(x)-1])
    ans.append(arr[arr.index(x)+1])
    print(abs(x - min(ans)))
else:
    print(arr[arr.index(x)+1] - x)

Submission status: Runtime Error

Solution code:
import fraction

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

x.sort()

# distance between each two cities
dist = [x[i] - x[i-1] for i in range(1, len(x))]

# distance between the first city and the start point
dist.append(abs(x[0] - X))

def listgcd(xs):
    g = xs[0]
    for i in range(1, len(xs)):
        g = fraction.gcd(g, xs[i])
    return g

print(listgcd(dist))

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()))
subX = []

for x_i in x:
    subX.append(abs(x_i - X))

print(gcd_list(subX))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N,X = map(int,input().split())
u = list(map(int,input().split()))
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
u.append(X)
u.sort()
sa = []
for i in range(len(u)-1):
    sa.append(u[i+1]-u[i])
print(gcd_list(sa))

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
def main2():
    def gcd(*numbers):
        return reduce(math.gcd, numbers)

    import math
    from functools import reduce
    N, X = list(map(int, input().split()))
    xs = list(map(int, input().split()))

    if len(xs) == 1:
        print(abs(xs[0] - X))
        exit()

    diffs = []
    for x in xs:
        diffs.append(abs(x-X))
    print(gcd(*diffs))

if __name__ == "__main__":
    main2()

Submission status: Runtime Error

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

xx = [abs(xxx - X) for xxx in x]

l = xx[0]
for i in xx[1:]:
    l = math.gcd(l, i)


print(l)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
n, x = map(int, input().split())
buf = input().split()
X = np.abs(np.array([int(buf[i]) for i in range(n)]) - x)
#print(X)
if(X.shape[0] == 1):
	r = X[0]
else:
	r = math.gcd(X[0], X[1])
	for i in range(n-2):
		r = math.gcd(r, X[i+2])
print(r)

Submission status: Runtime Error

Solution code:
import math

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

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    if diff != 0:
        diffs.append(diff)


if len(diffs) > 1:
    com = math.gcd(diffs[0],diffs[1])
    for i in range(len(diffs)-2):
        com = math.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Submission status: Runtime Error

Solution code:
from math import gcd
n_str,x_str = input().split()
n = int(n_str)
x = int(x_str)

point_list = []
point_str_list = input().split()
for i in point_str_list:
    i = int(i)
    point_list.append(i)

point_list.sort()

def_list = []
for i in range(n-1):
    defference = point_list[i+1] - point_list[i]
    def_list.append(defference)

a = def_list[0]
for i in def_list:
    a = gcd(a,i)

print(a)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

city_num, start_pos = list(map(int, input().split()))
city_list = list(map(int, input().split()))

# スタート位置を入れて
city_list.append(start_pos)
# 昇順に並び替え
city_list.sort()

# city毎の距離のリストを生成する
distance_list = [city_list[i+1] - city_list[i] for i in range(city_num)]

# 昇順に並び替え
distance_list.sort()

# 出力
print(reduce(math.gcd, distance_list))

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
import math
x_list.sort()
if N ==1:
    print(x_list[0]-X)
    exit()

m0 = abs(X - x_list[0])

D = float("inf")
for i in range(N-1):
    m1 = abs(x_list[i] - x_list[i+1])
    g = math.gcd(m1, m0)

    if g <= D:
        D = g
print(D)

Submission status: Runtime Error

Solution code:
import math
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if N > 1:
    mini = x[1] - x[0]
    if mini > abs(X - x[0]) and abs(X - x[0]) != 0:
        mini = abs(X - x[0])
elif N == 1:
    mini = abs(x[0] - X)
for i in range(1, N):
    if mini > x[i] - x[i - 1]:
        mini = x[i] - x[i - 1]
    if mini> abs(X - x[i]) and abs(X - x[i]) != 0:
        mini = abs(X - x[i])
    if (x[i] - x[i - 1]) % mini != 0:
        #break
        mini = math.gcd(mini, x[i] - x[i - 1])
    if abs(X - x[i]) % mini != 0:
        #break
        mini = math.gcd(mini, X - x[i])
        

print(mini)

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    r = modlog(x, y)
    while r != 0:
        x = y
        y = r
        r = modlog(x, y)
    return y

def modlog(x, y):
    r = x % y
    return r

if __name__ == '__main__' :
    N,X = map(int, input().split())
    x = list(map(int, input().split()))

    dist_list = [abs(d-X) for d in x]

    alpha = gcd(dist_list[0],dist_list[1])
    for d in dist_list:
        alpha = gcd(alpha,d)

    print(alpha)

Submission status: Runtime Error

Solution code:
import math

a,b=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
s=abs(x[-1]-b)
d=set()
for i in range(a-1):
    s=min(s,abs(x[i]-b))
    d.add(x[i+1]-x[i])
if a==1:
    print(abs(b-x[0]))
    exit()
ans=s
while d:
    ans=math.gcd(ans,d.pop())
print(ans)

Submission status: Runtime Error

Solution code:
import math
from sys import stdin

N, X = map(int, input().split())
koyaku = 0
index = 0
for x in stdin.readline().rstrip().split():
    x = int(x)
    if index == 0:
        koyaku = abs(x - X)
        index = 1
    else:
        l = abs(x - X)
        koyaku = math.gcd(koyaku, l)
print(koyaku)

Submission status: Runtime Error

Solution code:
import math

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

x.sort()

# distance between each two cities
dist = [x[i] - x[i-1] for i in range(1, len(x))]

# distance between the first city and the start point
dist.append(abs(x[0] - X))

def listgcd(xs):
    g = xs[0]
    for i in range(1, len(xs)):
        g = math.gcd(g, xs[i])
    return g

print(listgcd(dist))

Submission status: Runtime Error

Solution code:
import math

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

ans = None
for a in A:
    x = int(abs(a - X))
    if ans is None:
        ans = x
    else:
        ans = math.gcd(ans, x)

print(ans)

Submission status: Runtime Error

Solution code:
import math
def solve(N, X, cities):
    dists = [abs(city - X) for city in cities]
    gcd = min(dists)
    for d in dists:
        if d % gcd == 0:
            continue
        else:
            gcd = math.gcd(gcd, d % gcd)
    return gcd

  
if __name__ == "__main__":
    l = input()
    N, X = int(l.split()[0]),int(l.split()[1])
    cities = [int(c) for c in input().split()]
    print(solve(N, X, cities))

Submission status: Runtime Error

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

xl.append(x)
xl.sort()

onesam = 0
for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if onesam == 0:
        onesam = one_sa
    else:
        if one_sa % onesam == 0:
            continue
        else:
            short,big = min(onesam,one_sa),max(onesam,ne_sa)
            if short == 1:
                onesam =1
                break
                
            while big % short != 0:
                for i in range(2,short):
                    if short % i == 0:
                        short = short // i
            if short == 1:
                onesam = 1
                break
            else:
                onesam = short
print(onesam)

Submission status: Runtime Error

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

def gcd_list(li):
	if len(li) > 2:
		x = gcd(li[-1], li[-2])
		li = li[:-2] + [x]
		return gcd_list(li)
	else:
		return gcd(li[0], li[1])

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

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

li = [abs(i - X) for i in x]

li = [i for i in li if i]

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

Submission status: Runtime Error

Solution code:
import math

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

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    if diff != 0:
        diffs.append(diff)


if len(diffs) > 1:
    com = math.gcd(diffs[0],diffs[1])
    for i in range(n-2):
        com = math.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Submission status: Runtime Error

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


print(gcd)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
import math
import functools
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
gcd = functools.reduce(math.gcd,a)
print(gcd)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 18:34:07 2018
ABC109C
@author: maezawa
"""
import math
n, x0 = list(map(int, input().split()))
x = list(map(int, input().split()))

xx0 = [abs(xi-x0) for xi in x ]

y = xx0[0]
for yi in xx0:
    y = math.gcd(y, yi)
    
print(y)

Submission status: Runtime Error

Solution code:
import math

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

m = min(toshi + [X])

temp = []
for i in toshi+[X]:
    temp.append(i-m)

m = math.gcd(temp[0],temp[1])
for i in temp:
    m = math.gcd(m,i)

print(m)

Submission status: Runtime Error

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

xl.append(x)
xl.sort()

onesam = 0
for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if onesam == 0:
        onesam = one_sa
    else:
        if one_sa % onesam == 0:
            continue
        else:
            short,big = min(onesam,one_sa),max(onesam,ne_sa)
            if short == 1:
                onesam =1
                break
                
            while big % short != 0:
                for i in range(2,short):
                    if short % i == 0:
                        short = short // i
            if short == 1:
                onesam = 1
                break
            else:
                onesam = short
print(onesam)

Submission status: Runtime Error

Solution code:
import math
import sys

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

zahyo = list(map(lambda x : int(x),input().split()))

zahyo.append(x)
zahyo.sort()

min = zahyo[1] - zahyo[0]

is_odd = False
is_even = False

odds = list()

for i in range(n):
    diff = zahyo[i+1] - zahyo[i]

    if diff % 2 == 0:
        is_even == True
    else:
        is_odd = True
        odds.append(diff)

    if diff < min:
        min = zahyo[i+1] - zahyo[i]

# print(is_odd)
# print(is_even)
if len(odds) >= 1:
    for i in range(len(odds)):
        for j in range(len(odds)):
            if math.gcd(odds[i], odds[j]) == 1:
                print(1)
                sys.exit()


if is_odd == True and is_even == True:
    print(1)
else:
    print(min)

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

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

xn = [abs(i - x) for i in xn]

if n != 1 :
    print(reduce(gcd, xn))
else:
    print(xn[0])

Submission status: Runtime Error

Solution code:
import math
 
N, X = map(int, input().split())
town = list(map(int, input().split()))
 
for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X
  
gcd = town[0]
for i in range(1, N):
  gcd = math.gcd(gcd, town[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())
toshi = list(map(int, input().split()))

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

diff = []

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

print(gcd_list(diff))

Submission status: Runtime Error

Solution code:
import math
import sys

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

zahyo = list(map(lambda x : int(x),input().split()))

zahyo.append(x)
zahyo.sort()

min = zahyo[1] - zahyo[0]

is_odd = False
is_even = False

odds = list()

for i in range(n):
    diff = zahyo[i+1] - zahyo[i]

    if diff % 2 == 0:
        is_even == True
    else:
        is_odd = True
        odds.append(diff)

    if diff < min:
        min = zahyo[i+1] - zahyo[i]

# print(is_odd)
# print(is_even)
if len(odds) >= 1:
    for i in range(if len(odds)):
        for j in range(len(odds)):
            if math.gcd(odds[i], odds[j]) == 1:
                print(1)
                sys.exit()


if is_odd == True and is_even == True:
    print(1)
else:
    print(min)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

info = list(map(int, input().split(" ")))
pos = list(map(int, input().split(" ")))

temp = [abs(info[1]-pos[i]) for i in range(len(pos))]

print(gcd(*temp))

Submission status: Runtime Error

Solution code:
import math

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

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    if diff != 0:
        diffs.append(diff)


if n > 1:
    com = math.gcd(diffs[0],diffs[1])
    for i in range(n-2):
        com = math.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Submission status: Runtime Error

Solution code:
import math, functools

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

if N > 1:
  for n in range(N-1):
    a = abs(x[n] - x[n+1])
    A.append(a)

  D = functools.reduce(math.gcd, A)
else:
  D = x[0] - X
print(D)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
def solve(N, X, cities):
    dists = [abs(city - X) for city in cities]
    gcd = min(dists)
    for d in dists:
        if d % gcd == 0:
            continue
        else:
            gcd = math.gcd(gcd, d)
    return gcd

if __name__ == "__main__":
    l = input()
    N, X = int(l.split()[0]),int(l.split()[1])
    cities = [int(c) for c in input().split()]
    print(solve(N, X, cities))

Submission status: Runtime Error

Solution code:
import sys,collections,math,functools;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n, s = Is()
xs = Is()
xs2 = [e-s for e in xs]
gcd = functools.reduce(math.gcd, xs2)
print(gcd)

Submission status: Runtime Error

Solution code:
import math
N,X=map(int,input().split(" "))
xl=list(map(int,input().split(" ")))
xl.append(X)
xl=sorted(xl)
xx=[xl[i+1]-xl[i] for i in range(len(xl)-1)]
ans=max(xx)
for i in range(len(xx)):
    ans=math.gcd(ans,xx[i])

print(ans)

Submission status: Runtime Error

Solution code:
from math import fractions


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

x.append(X)
x.sort()

last = x[0]
ans = abs(x[0] - x[1])
for i in x[1:]:
    ans = gcd(ans, abs(last - i))
    last = i

print(ans)

Submission status: Runtime Error

Solution code:
import math
n,x=map(int,input().split())
a=list(map(int,input().split()))
dis1=x-min(a)
dis2=max(a)-x
print(math.gcd(dis1,dis2))