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:
from math import gcd
from functools import reduce
N, X = map(int, input().split())
x = [abs(X-int(i)) for i in input().split()]

Submission status: Runtime Error

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

temp = []
for i in range(N):
    temp.append(abs(X - x[i]))
D = functools.reduce(math.gcd, temp)
print(D)

Submission status: Runtime Error

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

temp = []
for i in range(N):
    temp.append(abs(X - x[i-1]))
D = functools.reduce(math.gcd, temp)
print(D)

Submission status: Runtime Error

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

temp = []
for i in range(N):
    temp.append(X - x[i-1])
D = functools.reduce(math.gcd, temp)
print(abs(D))

Submission status: Runtime Error

Solution code:
from math import gcd

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

N, X = map(int, input().split())
arr = [int(_) for _ in input().split(' ')]

a = 1000000000000000

for i in range(N):
    for j in range(N):
        if math.gcd(abs(arr[i] - X), abs(arr[j] - X)) < a:
            a = math.gcd(abs(arr[i] - X), abs(arr[j] - X))

print(a)

Submission status: Runtime Error

Solution code:
import math

N, X = map(int, input().split())
arr = [int(_) for _ in input().split(' ')]

a = 1000000000000000

for i in range(N):
    for j in range(N):
        if math.gcd(abs(arr[i] - X), abs(arr[i] - X)) < a:
            a = math.gcd(abs(arr[i] - X), abs(arr[i] - X))

print(a)

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
N = 0
a_map = []
for i in range(H):
    a = list(map(int, input().split()))
    a_map.append(a)
result = []
for i in range(H):
    for j in range(W):
        if a_map[i][j]%2==1:
            if j < W - 1:
                N += 1
                result.append([i + 1, j + 1, i + 1, j + 2])
                a_map[i][j + 1] += 1;
                a_map[i][j] -= 1;
            elif i < H - 1:
                N += 1;
                result.append([i + 1, j + 1, i + 2, j + 1])
                a_map[i][j] -= 1;
                a_map[i + 1][j] += 1;
print(N)
for a in result:
    print(a[0], a[1], a[2], a[3])

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce
start = int(input().split()[1])
cities = [int(i) for i in input().split()]
print(reduce(gcd, [abs(i-start) for i in cities]))

Submission status: Runtime Error

Solution code:
import function
n, start = [int(i) for i in input().split()]
x_list = [int(i) for i in input().split()]
x_list.append(start)
x_list.sort()


current_gcd = x_list[1] - x_list[0]
for i in range(1, n-1):
    gap = x_list[i+1] - x_list[i]
    current_gcd = function.gcd(current_gcd, gap)

print(current_gcd)

Submission status: Runtime Error

Solution code:
from fractions import gcd
start = int(input().split()[1])
cities = [int(i) for i in input().split()]
print(reduce(gcd, [abs(i-start) for i in cities]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

# スペース区切りの整数の入力
N, X = map(int, input().split())
pos = [int(x.strip()) for x in input().split()]

# 一番近い場所を検索
tikai = [i - X for i in pos]
kyori = list(map(abs,tikai))

gcd = functools.reduce(math.gcd, kyori)

print(gcd)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
H, W = map(int, input().split())
list = []
for h in range(H):
    l = [int(w) for w in input().split()]
    list.append(l)
print(reduce(math.gcd, list))

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

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

z = list(set )
print(gcd_list(z))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

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

N,X=list(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])
print(gcd_list(y))

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=list(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])
print(gcd_list(y))

Submission status: Runtime Error

Solution code:
import math

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

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

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

if len(dic) > 1:
    for i in range(len(dic) - 1):
        ans = min(ans, math.gcd(dic[i], dic[i + 1]))

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

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

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(len(dic) - 1):
    ans = min(ans, math.gcd(dic[i], dic[i + 1]))

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

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

dic = []

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

dic.sort()
ans = dic[0]

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

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)
    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, x = map(int, input().split())
v = sorted(list(map(int, input().split()))+[x])
r = v[1] - v[0]
for i in range(2,n+1):
    r = gcd(r, v[i] - v[0])
print(r)

Submission status: Runtime Error

Solution code:
from math import gcd
scan = lambda: list(map(int, input().split()))
n, x = scan()
v = sorted(scan()+[x])
r = v[1] - v[0]
for i in range(2,n+1):
    r = gcd(r, v[i] - v[0])
print(r)

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

z = list(set(y))
'''
for r in range(z[0],0,-1):
    p=0
    for j in range(1,len(z)-1):
        if z[j]%r!=0:
            p=p+1
    if p==0:
        break
print(r)
'''
print(gcd_list(z))

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

dic = []

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

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())
l=[abs(c-x) for c in list(map(int,input().split()))]
print(gcd_list(l) if len(l)>1 else l[0])

Submission status: Runtime Error

Solution code:
import math

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

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

dic = []

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if len(dic) == 0 or tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

Submission status: Runtime Error

Solution code:

import math
from functools import reduce

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

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

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

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

z = list(set(y))
'''
for r in range(z[0],0,-1):
    p=0
    for j in range(1,len(z)-1):
        if z[j]%r!=0:
            p=p+1
    if p==0:
        break
print(r)
'''
print(gcd_list(z))

Submission status: Runtime Error

Solution code:
from functools import reduce
import math

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

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

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] - X)

ans = reduce(math.gcd,absList)
    
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
from functools import reduce
import math

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

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

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] - X)

ans = reduce(math.gcd,absList)
    
print(ans)

Submission status: Runtime Error

Solution code:

import numpy as np
import math

def main():
    N, X = map(int, input().split())
    x = np.asarray(list(map(int, input().split())))
    x = np.absolute(x - X)
    if N > 1:
        l = None
        for i, n in enumerate(x):
            if i == 0:
                l = n
            else:
                l = math.gcd(l, n)
        print(l)
    else:
        print(x[0])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import functools

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

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

diff_a=np.diff(a)
gcd=gcd(diff_a)
print(gcd)

Submission status: Runtime Error

Solution code:
import math

n,x=map(int,input().split())
z=[]
y=[]
z=list(map(int, input().split()))

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

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

Submission status: Runtime Error

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

field = [int(i) for i in input().split()]

diff = list(map(lambda a:abs(a-x),field))

def gcd(x,y):

    if x < y:
        x,y = y,x

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

ans = diff[0]


for i in diff[1:]:
    ans = gcd(i,ans)

print(ans)

Submission status: Runtime Error

Solution code:

import numpy as np
import math

def main():
    N, X = map(int, input().split())
    x = np.asarray(list(map(int, input().split())))
    x = np.absolute(x - X)
    if N > 1:
        d = np.absolute(x[:N-1] - x[1:N])
        l = None
        for i, n in enumerate(d):
            if i == 0:
                l = n
            else:
                l = math.gcd(l, n)
        print(l)
    else:
        print(x[0])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

import numpy as np
import math

def main():
    N, X = map(int, input().split())
    x = np.asarray(list(map(int, input().split())))
    x = np.absolute(x - X)
    if N > 1:
        d = np.absolute(x[:N-1] - x[1:N])
        l = None
        for i, n in enumerate(d):
            if i == 0:
                l = n
            else:
                l = math.gcd(l, n)
        print(l)
    else:
        print(x[0])


if __name__ == '__main__':
    main()))

Submission status: Runtime Error

Solution code:
import math
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
x.append(X)
x.sort()
y=[]

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

z = list(set(y))
'''
for r in range(z[0],0,-1):
    p=0
    for j in range(1,len(z)-1):
        if z[j]%r!=0:
            p=p+1
    if p==0:
        break
print(r)
'''
print(lcm_list(z))

Submission status: Runtime Error

Solution code:

import numpy as np
import math

def main():
    N, X = map(int, input().split())
    x = np.asarray(list(map(int, input().split())))
    x = np.absolute(x - X)
    if N > 1:
        d = x[:N-1] - x[1:N]
        l = None
        for i, n in enumerate(d):
            if i == 0:
                l = n
            else:
                l = math.gcd(l, n)
        print(l)
    else:
        print(x[0])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math

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

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

dic = []

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

Submission status: Runtime Error

Solution code:
L=[input()for x in' '*int(input())];print('YNeos'[any(i[-1]!=j[0]*L.count(i)for i,j in zip(L,L[1:]))::2])

Submission status: Runtime Error

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

field = [int(i) for i in input().split()]

diff = list(map(lambda a:a-x,field))

ans = diff[0]

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

print(ans)

Submission status: Runtime Error

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

field = [int(i) for i in input().split()]

diff = list(map(lambda a:a-x,field))

ans = diff[0]

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

print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import fractions
 
N,X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
y=[]
 
i=0
while i < n:
    y.append(x[i+1]-x[i])
    i +=1
y.sort()
 
y=list(set(y))
m=len(y)
z=y[0]
i=0
while i < m:
    z=fractions.gcd(z,y[i])
    i+=1
 
print(z)

Submission status: Runtime Error

Solution code:
n,x = input().split()
ll = []
listen = input().split()
if x < listen[0]:
 ll.append(int(listen[0])-int(x))
for i in range(int(n)-1):
 if listen[i] < x < listen[int(i)+1]:
  ll.append(x-listen[i])
  ll.append(listen[i+1] - x)
 else:
  ll.append(int(listen[i+1])-int(listen[i]))
m = 0
for i in range(1,ll[0]+1):
 p = 1
 for k in range(int(n)):
  if ll[k]%i != 0:
   p = 0
 if p == 1:
  m = i
print(m)

Submission status: Runtime Error

Solution code:
import math

n,x=map(int,input().split())
z=[]
y=[]
z=list(map(int, input().split()))

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

if n==1:
  print(y[0])
else:
  for i in range(n):
    if i<2:
      gcm=math.gcd(y[0],y[1])
    else:
      gcm=math.gcd(gcm,y[i])
  print(gcm)

Submission status: Runtime Error

Solution code:
N,X=list(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()
y = list(set(y))

for r in range(y[0],1,-1):
    p=0
    for j in range(1,len(y)-1):
        if y[j]%r!=0:
            p=p+1
    if p==0:
        break
print(r)

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
pos=list(map(int,input().split()))
pos2=[abs(p-x) for p in pos]
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)
 
        return divisor_list

if n==1: ans=pos2[0]
else:
    minpos= min(pos2)
    divs=make_divisor_list(minpos)[::-1]
    if divs[0]==1:ans=1
    else:
        for j in divs:
        if all(x%j==0 for x in pos2):
            ans=j
            break
print(ans)

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
pos=list(map(int,input().split()))
pos2=[abs(p-x) for p in pos]
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)
 
        return divisor_list

if n==1: ans=pos2[0]
else:
    minpos= min(pos2)
    divs=make_divisor_list(minpos)[::-1]
    if divs[0]==1:ans=1
        else:
            for j in divs:
            if all(x%j==0 for x in pos2):
                ans=j
                break
print(ans)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import functools

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


diff_a=np.diff(a)
gcd=functools.reduce(math.gcd,diff_a)
print(gcd)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math

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

x = [X]
dic = []

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

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import Fraction
n , x = map(int,input().split())

field = [int(i) for i in input().split()]

tmp = []

for i in field:
    tmp.append(abs(i-x))


ans = tmp[0]

for i in range(1,n):
    ans = min(ans,fractions.gcd(ans,tmp[i]))

print(ans)

Submission status: Runtime Error

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

x = x - X

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


a = gcd(x[0],x[1])
for k in range(2,len(x)):
    a = gcd(a,x[k])
print(a)

Submission status: Runtime Error

Solution code:
import math

n,x=map(int,input().split())
z=[]
y=[]
z=list(map(int, input().split()))

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

if n==1:
  print(y[0])
else:
  gcm=math.gcd(y[0],y[1])
  for i in range(2,n):
    gcm=math.gcd(gcm,y[i])
  print(gcm)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:

import numpy as np
import math

def main():
    N, X = map(int, input().split())
    x = np.asarray(list(map(int, input().split())))
    x = np.absolute(x - X)
    if N > 1:
        d = []
        for i in range(x.size-2):
            d.append(x[i+1] - x[i])
        d = list(map(abs, list(set(d))))
        print(mygcd(d))
    else:
        print(x[0])

def mygcd(seq):
    if len(seq) == 1:
        return seq[0]
    else:
        a = seq.pop()
        b = seq.pop()
        return mygcd(seq.append(math.gcd(a, b)))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,X=list(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()
for r in range(y[0],1,-1):
    p=0
    for j in range(1,len(y)-1):
        if y[j]%r!=0:
            p=p+1
    if p==0:
        break
print(r)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

N,X = map(int,input().rstrip().split())
x = []
x = list(map(int,input().rstrip().split()))
x.append(X)
x = sorted(x)

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

Submission status: Runtime Error

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

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

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

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] -X)

ans = functools.reduce(math.gcd,absList)

    
print(ans)

Submission status: Runtime Error

Solution code:
def gcd3(x,y):
    if x>=y:
        if x%y==0:
            return y
        else:
            return gcd3(y,x%y)
    else:
        if y%x==0:
            return x
        else:
            return gcd3(x,y%x)
def gcd2(x4):
    if len(x4)>2:
        return gcd2([gcd3(x4[0],x4[1]),]+x4[2:])
    elif len(x4) ==2:
        return gcd3(x4[0],x4[1])
    else:
        return x4[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x3=[]
for i in range(len(x)-1):
    x3.append(abs(x[i+1]-x[i]))
print(gcd2(x3))

Submission status: Runtime Error

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

field = [int(i) for i in input().split()]

tmp = []

for i in field:
    tmp.append(abs(i-x))


ans = tmp[0]

for i in range(1,n):
    ans = min(ans,math.gcd(ans,tmp[i]))

print(ans)

Submission status: Runtime Error

Solution code:
import math
import functools

n, x = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
 
xs.append(x)
xs.sort()
 
dxs = list()
 
for i in range(1, n+1):
    if xs[i-1] != xs[i]:
        dxs.append(xs[i] - xs[i-1])
 
print(functools.reduce(math.gcd, dxs))

Submission status: Runtime Error

Solution code:
import numpy as np

N, X = map(int, input().split())
city = [X] + list(map(int, input().split()))
city_diff = np.array([abs(city[i + 1] - city[i]) for i in range(N)])
ans = np.gcd.reduce(city_diff)
print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import fraction
from functools import reduce

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

def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)
N,X=map(int,input().split())
x=list(map(int,input().split()))
x_dif=[]
for i in x:
    x_dif.append(X-i)
print(gcd_list(x_dif))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

town_list = town_list - X
print(min(town_list))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

a = [int(i) for i in input().split()]
N = a[0]
X = a[1]
x = [int(i) for i in input().split()]
dis = [i-X for i in x]

print(reduce(math.gcd, dis))

Submission status: Runtime Error

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

town_list = town_list - N
print(min(town_list))

Submission status: Runtime Error

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

field = [int(i) for i in input().split()]

tmp = []

for i in field:
    tmp.append(abs(i-x))


ans = tmp[0]

for i in tmp:
    ans = math.gcd(ans,i)

print(ans)

Submission status: Runtime Error

Solution code:
import fractions
l = map(int, raw_input().split())
toshisuu= l[0]
starttoshi= l[1]
mathlist=[0]
toshilist = map(int, raw_input().split())
ans=100000000000000000000
das=0
for i in toshilist:
    counts=abs(i-starttoshi)
    if das==0:
        mathlist[0]=counts
        das=1
    else:
        mathlist.append(counts)
mathlist.sort(reverse = True)
# print mathlist
print fractions.gcd(mathlist[0], mathlist[1])

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def serch_index(X,x):
    for i in range(len(x)):
        if X >=x[i]:
            return i
# def check_ans(temp_sub,ans):
#     count = 0
#     for i in temp_sub:
#         if i%ans ==0:
#             count += 1
#         else:
#             pass
#     # print(count)
#     if count == len(temp_sub):
#         return False
#     else:
#         return True
def cal_gcd(temp_sub,ans):
    for i in temp_sub:
        temp_ans = math.gcd(i,ans)
        true_ans = min(ans,temp_ans)
    return true_ans
def gcd_list(temp_sub):
    return reduce(math.gcd,temp_sub)


N,X = map(int,input().split())
x = list(map(int, input().split()))
if N == 1:
    print(abs(x[0]-X))
else:    
    X_index = serch_index(X, x)
    if X_index == None:
        x.insert(0,X)
    else:
        x.insert(X_index+1, X)
    x.sort()
    # print(x)
    temp_sub = []
    # print(x)
    for i in range(N):
        temp_sub.append(x[i+1]-x[i])
    # print(temp_sub)
    ans = abs(min(temp_sub))
    print(gcd_list(temp_sub))
    # true_ans = cal_gcd(temp_sub, ans)
    
    # judge = True
    # while judge:
    #    judge = check_ans(temp_sub, ans)
    #    if judge:
    #         ans -=2
    # print(true_ans)

Submission status: Runtime Error

Solution code:
from math import gcd

def gcd2(x):
    y = x.pop(0)
    for i in x:
        y = gcd(i, y)
    return y

n, x = map(int, input().split())
xs = map(int, input().split())
xs2 = list(map(lambda y: abs(y - x), xs))
print(gcd2(xs2))

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())
l=[]
for c in list(map(int,input().split())):
	if c==x:
		continue
	else:
		l.append(abs(c-x))

print(gcd_list(l) if len(l)>1 else l[0])

Submission status: Runtime Error

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

town_list = town_list - N
print(min(town_list))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
pos=list(map(int,input().split()))
pos2=[abs(p-x) for p in pos]
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)
 
        return divisor_list
 
minpos= min(pos2)
divs=make_divisor_list(minpos)[::-1]
if divs[0]==1:ans==1
else:
  for j in divs:
    if all(x%j==0 for x in pos2):
        ans=j
        break
print(ans)

Submission status: Runtime Error

Solution code:
a = input().split()
n = int(a[0])
x = int(a[1])
b = input().split()
l = [int(i) for i in b]

import functools
import fraction

l.append(x)
ld = sorted(l, reverse=True)
tmp = []
for i in range(1, len(ld)):
    tmp.append(abs(ld[i] - ld[i-1]))
gcd = functools.reduce(fraction.gcd, tmp)
print(gcd)

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = []
d = []
co = 0
for i in range(a[0]):
	c.append(abs(b[i]-a[1]))
	if b[i]-a[1] > 0 and co == 0:
		c.insert(i,0)
		co += 1
if co == 0:
	c.append(0)

for i in range(len(c)-1):
	d.append(abs(c[i+1]-c[i]))
k = min(d)
for i in range(len(d)):
	if d[i] % k != 0:
		d[0] = 1
		break
print(d[0])

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
x_list.append(X)
def gcd_1(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)

if N == 2:
    print(values[0])
    exit()

print(gcd_1(values))

Submission status: Runtime Error

Solution code:
import math
n, x = list(map(int, input().split()))
array = list(map(int, input().strip().split()))

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