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

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

Submission status: Runtime Error

Solution code:
import fractions,sys
n,X=map(int,input().split())
x=list(map(int,input().split()))
y=[]
if n==1:
  print(abs(x[0]-X))
  sys.exit()
for i in range(n):
  y.append(abs(x[i]-X))
G=float'inf'
for j in range(n-1):
  G=min(G,fractions.gcd(y[j],y[j+1]))
print(G)

Submission status: Runtime Error

Solution code:
import fractions
n,X=map(int,input().split())
x=list(map(int,input().split()))
y=[]
for i in range(n):
  y.append(abs(x[i]-X))
G=float'inf'
for j in range(n-1):
  G=min(G,fractions.gcd(y[j],y[j+1]))
print(G)

Submission status: Runtime Error

Solution code:
import fractions
n,X=map(int,input().split())
x=list(map(int,input().split()))
y=[]
for i in range(n):
  y.append(abs(x[i]-X))
G=float'inf'
for j in range(n):
  G=min(G,fractions.gcd(y[j],y[j+1]))
print(G)

Submission status: Runtime Error

Solution code:
import fractions
n,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
  x[i]=x[i]-X
G=float'inf'
for j in range(n):
  G=min(G,fractions.gcd(x[j],x[j+1]))
print(G)

Submission status: Runtime Error

Solution code:
import fractions
n,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
  x[i]=x[i]-X
print(fractions.gcd(*x))

Submission status: Runtime Error

Solution code:
from fractions import gcd
import sys

N, X = map(int,input().split())
lis = list(map(int,input().split()))
diff = []

if N==1:
	print(lis[0]-X)
	sys.exit
for i in range(N):
	diff.append(abs(X-lis[i]))

for j in range(N-1):
	x = gcd(diff[i],diff[i+1])
print(x)

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
listx = list(map(int, input().split()))
subx = []

for i in range(N):
  subx.append(abs(listx[i] - X))
if N = 1:
  subx.append(subx[0])

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

ans = gcd(subx[0], subx[1])

if N > 2:
  for i in range(2, N):
    ans = gcd(ans, subx[i])
  
print(ans)

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
listx = list(map(int, input().split()))
subx = []

for i in range(N):
  subx.append(abs(listx[i] - X))

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

ans = gcd(subx[0], subx[1])

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from numpy import*;N,X=input().split();x=array(list(map(int,input().split())));print(gcd.reduce(x-int(X)))

Submission status: Runtime Error

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

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

distance = (abs(x-y) for y in town)
print(distance)
for d in distance:
    res = gcd(next(d), next(d))

print(res)

Submission status: Runtime Error

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

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

res = abs(town[0] - x)
for t in town[1:]:
    d = abs(t - x)
    res = gcd(res, d)

print(res)

Submission status: Runtime Error

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

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

res = abs(town[0] - x)
for t in town[1:]:
    d = abs(t - x)
    res = gcd(res, d)

print(res)

Submission status: Runtime Error

Solution code:
from math import gcd

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

res = abs(town[0] - x)
for t in town[1:]:
    d = abs(t - x)
    res = gcd(res, d)

print(res)

Submission status: Runtime Error

Solution code:
from math import gcd
from fractions import reduce

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

dist = map(lambda y: abs(x - y), town)
res = reduce(gcd, dist)
print(res)

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

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

dist = map(lambda y: abs(x - y), town)
res = reduce(gcd, dist)
print(res)

Submission status: Runtime Error

Solution code:
N, X = [int(nx) for nx in input().split()]
x = [abs(int(xx) - X) for xx in input().split()]

while len(x) > 1:
  x2 = []
  mn_x = min(x)
  for n in range(N):
    mod = x[n] % mn_x
    if mod != 0:
      x2.append(mod)
  x2.append(mn_x)
  x = x2
  
ans = x[0]
print(ans)

Submission status: Runtime Error

Solution code:
N, X = [int(nx) for nx in input().split()]
x = [abs(int(xx) - X) for xx in input().split()]

while len(x) > 1:
  x2 = []
  mn_x = min(x)
  for n in range(N):
    mod = x[n] % mn_x
    if mod != 0:
      x2.append(mod)
  x2.append(mn_x)
  x = x2
print(x)

Submission status: Runtime Error

Solution code:
n, x = map(int, input().split())
x = list(map(lambda y: abs(x - int(y)), input().split()))


from functools import reduce
from math import gcd
def greatest_common_divisor(iter):
    '''
    最大公約数を返す
    '''
    return reduce(gcd, iter)


print(greatest_common_divisor(x))

Submission status: Runtime Error

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

if n == 1:
    print(abs(x[0]-X))
else:
    for i in range(n-1):
        dif.append(x[i+1]-x[i])
        print(gcd_list(dif))
        break

Submission status: Runtime Error

Solution code:
import sys

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


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

if len(x) == 2:
    print(x[1]- x[0])
    sys.exit()

xx = [x[i+1] -x[i] for i in range(len(x)-1)]

g = gcd(xx[0],xx[1])

if len(xx) >= 3:
    for i in range(2,n-1):
        g = gcd(g,xx[n])

print(g)

Submission status: Runtime Error

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

xx = [x[i+1] -x[i] for i in range(len(x)-1)]

import math
from functools import reduce

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

print(gcd_list(xx))

Submission status: Runtime Error

Solution code:
from functools import reduce
import math


def solve():
    n, X = map(int, input().split())
    xs = list(map(int, input().split()))
    diffs = [abs(x - X) for x in xs]
    return reduce(math.gcd, diffs)


if __name__ == "__main__":
    print(solve())

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

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

ans=gcd_list(s)
   
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

ans = x_lis[0]
for i in range(n):
	ans = gcd(ans, x[i])
	if ans == 1:
		break
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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

Submission status: Runtime Error

Solution code:
import math

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

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

print(ans)

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
cities = [int(i) for i in input().split()]
cities.sort()
dist = [int(abs(i-X)) for i in cities]
dist.sort()
 
if N==1:
    print(max(dist))
else:
    while len(dist)>0:
        m = min(dist)
        dist = [int(i%m) for i in dist]
        dist.sort
        while len(dist)>0 and dist[0]==0:
            dist.remove(0)
        if len(dist)==0:
            break
        else:
            dist.append(m)
    print(m)

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
cities = [int(i) for i in input().split()]
cities.sort()
dist = [int(abs(i-X)) for i in cities]
dist.sort()

import math
if N==1:
    print(max(dist))
else:
    D = math.gcd(min(dist), max(dist))
    for i in reversed(range(1, D+1)): #最大公約数を1から順に考える
        for j in range(len(dist)): #全ての数を割ってみる
            if dist[j]%i != 0:
                flag = False
                break
            else:
                flag = True
        if flag:
            D = i
            break
    print(D)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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

diff = []
for i in range(len(l)-1):
    diff.append(abs(l[i] - l[i+1]))

for i in range(len(l)):
    diff.append(abs(l[i] - x))

gcd = gcd(diff[0], diff[1])
if n == 2:
    print(gcd)
    exit()

for i in range(2, len(diff)-1):
    gcd = gcd(gcd, diff[i])

print(gcd)

Submission status: Runtime Error

Solution code:
import math

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

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

diff = []
for i in range(len(l)-1):
    diff.append(abs(l[i] - l[i+1]))

for i in range(len(l)):
    diff.append(abs(l[i] - x))

gcd = math.gcd(diff[0], diff[1])
if n == 2:
    print(gcd)
    exit()

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

print(gcd)

Submission status: Runtime Error

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

x = np.array(list(map(int, input().split())))
x -= X

x = np.abs(x)
D = 0
from math import gcd

for d in x:
  D = gcd(D,d)

print(D)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
li = list(map(int,input().split()))
li = [abs(x-b) for x in li]
#print(li)
import functools
import math
li2 = []
for i in range(len(li)-1):
    c = (math.gcd(li[i],li[i+1]))
    li2.append(c)
print(min(li2))

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  if a == b:
    return b
  if a < b:
    a, b = b, a
  return gcd(a-b, b)

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

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def main():

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

    if N !=1:

        for i in range(N-1):
            diffList.append(targetList[i+1] - targetList[i])
    else:
        print(abs(targetList[0]-targetList[1]))
        exit()


    print(reduce(math.gcd,diffList))

        
    
if __name__== "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math

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

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

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

ans = math.gcd(x[0],x[1])

if N == 2:
    print(ans)
    exit()
    
for i in range(N-2):
    ans = math.gcd(ans,x[i+2])
    
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
N,X = map(int,input().split())
l = list(map(lambda x: abs(int(x)-X),input().split()))
print(reduce(fractions.gcd,l))

Submission status: Runtime Error

Solution code:
import math
from fractions import gcd
N,X = map(int,input().split())
l = list(map(lambda x: abs(int(x)-X),input().split()))
print(reduce(fractions.gcd,l))

Submission status: Runtime Error

Solution code:
import math
from fractions import gcd
N,X = map(int,input().split())
l = list(map(lambda x: abs(int(x)-X),input().split()))
print(reduce(gcd,l))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N,X = map(int,input().split())
l = list(map(lambda x: abs(int(x)-X),input().split()))
print(reduce(math.gcd,l))

Submission status: Runtime Error

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

def abs2(m):
    m = int(m)
    return abs(m-x)

# from fractions import gcd

import math
from functools import reduce

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

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

xs = list(map(abs2, input().split()))
# xs = list(map(int, input().split()))

if n == 1:
    ans = xs[0]
else:
    ans = gcd(*xs)

# ans = abs(x-xs[0])
# for y in xs:
#     ans = gcd(*[ans, abs(x-y)])

print(ans)

Submission status: Runtime Error

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

def abs2(m):
    m = int(m)
    return abs(m-x)

import math
from functools import reduce

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

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

xs = list(map(abs2, input().split()))

if n == 1:
    ans = xs[0]
else:
    ans = gcd(*xs)

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from collections import deque
n,X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.append(X)
x = sorted(x)
k = x[0]
x = deque([i-k for i in x])
x.popleft()

def gcdn():
    if len(x)==1:
        return
    p=x.pop()
    q=x.pop()
    x.append(gcd(p,q))
    gcdn()

gcdn()
print(x[0])

Submission status: Runtime Error

Solution code:
import numpy as np
n, x = map(int, input().split())
ans = 1
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.sort()
    return divisors
def check(n, li):
    for i in li:
        if i != 0:
            if abs(i) % n != 0:
                return False
    return True
li = list(map(int, input().split()))
li.append(x)
li = list(set(li))
li.sort()
start_index = li.index(x)
li = np.array(li)
if start_index == len(li)-1:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div[[-1]]:
        if check(i, li-x) and i > ans:
            ans = i
            break
        
elif start_index == 0:
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
else:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
        if ans > i:
            break

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

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

a = []
for i in b:
    if i != x:
        a.append(abs(i-x))
print(gcd(a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

a = []
for i in b:
    if i != x:
        a.append(abs(i-x))
print(gcd(a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

a = []
for i in b:
    a.append(abs(i-x))
print(gcd(a))

Submission status: Runtime Error

Solution code:
N,X = map(int, input().split())
List = [int(x) for x in input().split()]
 
import math
List.append(X)
List.sort()
 
distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])
 
d_min = min(distance)
 
num_list = []
 
c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1
 
num_list2 = [1]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])
 
num_list = num_list + num_list2
 
 
j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1
 
print(int(ans))

Submission status: Runtime Error

Solution code:
N,X = map(int, input().split())
List = [int(x) for x in input().split()]
 
import math
List.append(X)
List.sort()
 
distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])
 
d_min = min(distance)
 
num_list = []
 
c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1
 
num_list2 = [0]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])
 
num_list = num_list + num_list2
 
j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1
 
print(ans)

Submission status: Runtime Error

Solution code:
N,X = map(int, input().split())
List = [int(x) for x in input().split()]
 
import math
List.append(X)
List.sort()
 
distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])
 
d_min = min(distance)
 
num_list = []
 
c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1
 
num_list2 = [1]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])
 
num_list = num_list + num_list2
 
num_list.append(d_min)
j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1
 
print(ans)

Submission status: Runtime Error

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

import math
List.append(X)
List.sort()

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

d_min = min(distance)

num_list = []

c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1

num_list2 = [d_min]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = d_min/num_list[i]

num_list = num_list + num_list2


j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1

print(ans)

Submission status: Runtime Error

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

import math
List.append(X)
List.sort()

distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])

d_min = min(distance)

num_list = []

c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1

num_list2 = [1]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])

num_list = num_list + num_list2


j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1

print(ans,distance,num_list)

Submission status: Runtime Error

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

import math
List.append(X)
List.sort()

distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])

d_min = min(distance)

num_list = []

c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1

num_list2 = [0]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])

num_list = num_list + num_list2

num_list.append(d_min)
j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1

print(ans)

Submission status: Runtime Error

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

List.append(X)
List.sort()

distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])

d_min = min(distance)

num_list = []

c = 1
while c <= d_min:
    if d_min%c == 0:
        num_list.append(c)
    c += 1

j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] != 0:
            break
        else:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        break
    j -= 1

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

ans = X[1] - X[0]
for i in range(1, N+1):
    t = X[i+1] - X[i]
    if t < ans:
        ans = t
print(ans)

Submission status: Runtime Error

Solution code:
import math
N,X = map(int,input().split())
l = []
x = tuple(map(int,input().split()))

for i in range(N):
    l.append(abs(x[i]-X))
#print(l)
a = 10**9
for i in range(N-1):
    if a >= math.gcd(l[i],l[i+1]):
        a = math.gcd(l[i],l[i+1])
if N == 1:
    print(x[0]-X)
else:
    print(a)

Submission status: Runtime Error

Solution code:
import fractions

N, X = int(input())
cities = list(map(int, input().split()))
gcds = 0
for city in cities:
  if gcd == 0:
    gcds = fractions.gcd(abs(city-X))
  else:
    gcds = fractions.gcd(gcds, abs(city-X))
print(gcds)

Submission status: Runtime Error

Solution code:
import math
import fractions

n,k = list(map(int, input().split()))
b = list(map(int, input().split()))

c = [b-b[0] for i in range(n)]

print(fractions.gcd(c))

Submission status: Runtime Error

Solution code:
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')



n,x = map(int,input().split())
a = list(map(int,input().split()))
p = []
for i in a:
    p.append(abs(i - x))
g = p[0]
for i in p:
    g = gcd(i, g)
print(g)y

Submission status: Runtime Error

Solution code:
import math

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

gcd = numbers[0]
for i in numbers:
  gcd = math.gcd(gcd, i)
print(gcd)

Submission status: Runtime Error

Solution code:
import functools
import math

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

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

Submission status: Runtime Error

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

dist = []
for i in range(N-1):
    dist.append(x[i+1] - x[i])
    
g = dist[0]

for i in range(N-2):
    g = fractions.gcd(g, dist[i+1])

print(g)

Submission status: Runtime Error

Solution code:
import functools
import math


def resolve():
	n,x=map(int,input().split())
	x_list=list(map(int,input().split()))
	x_list.append(x)
	a=[i-j for i in x_list for j in x_list if i!=j]
	print(functools.reduce(math.gcd,a))
resolve()

Submission status: Runtime Error

Solution code:
import math

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

if(len(point) == 1):
  ans = abs(point[0] - x)
else:
  gcd = abs(point[0] - x)
  for i in range(len(point) - 1):
    dif.append(abs(point[i+1] - point[i]))
    gcd = math.gcd(gcd, dif[i])
  ans = gcd
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

if(len(point) == 1):
  ans = abs(point[0] - x)
else:
  gcd = abs(point[0] - x)
  for i in range(len(point) - 1):
    dif.append(point[i+1] - point[i])
    gcd = math.gcd(gcd, dif[i])
  ans = gcd
print(ans)

Submission status: Runtime Error

Solution code:
# Setup
import sys
sys.setrecursionlimit(4100000)

a, b = [int(i) for i in input().split()]
c = [b-int(i) for i in input().split()]
import fractions
import fractions
temp = fractions.gcd(c[1],c[0])
for i in range(2,a):
    temp = fractions.gcd(temp,c[i])
print(temp)

Submission status: Runtime Error

Solution code:
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X) #len(x)=N+1
x.sort()

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

init=x[0]
x=[i-init for i in x]
d=x[1]
for i in range(N-1):   # 0 2 4 6 10 14   N=5
    d=gcd(d,x[i+2])
print(d)

Submission status: Runtime Error

Solution code:
import math

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

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

while len(distance) > 1:
        cd = math.gcd(distance[0],distance[1])
        distance.append(cd)
        del distance[0]
        del distance[0]

print(distance[0])

Submission status: Runtime Error

Solution code:
import math

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

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

while len(distance) > 1:
        cd = math.gcd(distance[0],distance[1])
        del distance[0]
        del distance[0]
        distance.append(cd)

print(distance[0])

Submission status: Runtime Error

Solution code:
import math

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

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

while True:
    if len(distance) > 1:
        cd = math.gcd(distance[0],distance[1])
        del distance[0]
        del distance[0]
        distance.append(cd)
        if len(distance) == 1:
            print(distance[0])
            exit()
    else:
        print(distance[0])
        break

Submission status: Runtime Error

Solution code:
import math

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

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

while True:
    if len(distance) > 1:
        cd = math.gcd(distance[0],distance[1])
        del distance[0]
        del distance[0]
        distance.append(cd)
        if len(distance) == 1:
            print(distance[0])
            exit()
    else:
        print(distance[0])
        exit()

Submission status: Runtime Error

Solution code:
import math

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

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

while True:
    if len(distance) > 1:
        cd = math.gcd(distance[0],distance[1])
        del distance[0]
        del distance[0]
        distance.append(cd)
        if len(distance) == 1:
            print(distance[0])
            exit()
    else:
        print(distance[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.sort()
kyori_list = []
for i, x in enumerate(X_list):
    if i == len(X_list) - 1:
        break
    kyori_list.append(X_list[i + 1] - x)

import math
from functools import reduce

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


print(gcd_list(*kyori_list))
# print(X_list)

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.sort()
kyori_list = []
for i, x in enumerate(X_list):
    if i == len(X_list) - 1:
        break
    kyori_list.append(X_list[i + 1] - x)

import math
from functools import reduce

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


print(gcd(*kyori_list))
# print(X_list)

Submission status: Runtime Error

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

from math import gcd

x=[x[i+1]-x[i] for i in range(N)]

ans=0
for i in range(N):
    ans=gcd(ans,x[i])
print(abs(ans))