Problem:


Score : 300 points

Problem Statement

There are N cities on a number line. The i-th city is located at coordinate x_i.

Your objective is to visit all these cities at least once.

In order to do so, you will first set a positive integer D.

Then, you will depart from coordinate X and perform Move 1 and Move 2 below, as many times as you like:

Move 1: travel from coordinate y to coordinate y + D.

Move 2: travel from coordinate y to coordinate y - D.

Find the maximum value of D that enables you to visit all the cities.

Here, to visit a city is to travel to the coordinate where that city is located.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

1 \leq X \leq 10^9

1 \leq x_i \leq 10^9

x_i are all different.

x_1, x_2, ..., x_N \neq X

Input

Input is given from Standard Input in the following format:

N X
x_1 x_2 ... x_N

Output

Print the maximum value of D that enables you to visit all the cities.

Sample Input 1

3 3
1 7 11

Sample Output 1

2

Setting D = 2 enables you to visit all the cities as follows, and this is the maximum value of such D.

Perform Move 2 to travel to coordinate 1.

Perform Move 1 to travel to coordinate 3.

Perform Move 1 to travel to coordinate 5.

Perform Move 1 to travel to coordinate 7.

Perform Move 1 to travel to coordinate 9.

Perform Move 1 to travel to coordinate 11.

Sample Input 2

3 81
33 105 57

Sample Output 2

24

Sample Input 3

1 1
1000000000

Sample Output 3

999999999



Sample input:
3 3
1 7 11


Sample output:
2

Submission status: Runtime Error

Solution code:
import math

gcd = math.gcd

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

def gcdList(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList([_ - X for _ in x]))

Submission status: Runtime Error

Solution code:
from fractions import Fraction

gcd = fractions.gcd

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

def gcdList(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList([_ - X for _ in x]))

Submission status: Runtime Error

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

def gcdList(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

def gcd(p, q):
    if p < 0:
        return gcd(-p, q)
    if q < 0:
        return gcd(p, -q)
    if q > p:
        return gcd(q, p)
    if p % q == 0:
        return q
    else:
        return gcd(q, p % q)

print(gcdList([_ - X for _ in x]))

Submission status: Runtime Error

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

def gcd_list(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcd_list([gcd(numbers[0], numbers[1])] + numbers[2:])

def gcd(p, q):
    if p < 0:
        return gcd(-p, q)
    if q < 0:
        return gcd(p, -q)
    if q > p:
        return gcd(q, p)
    if p % q == 0:
        return q
    else:
        return gcd(q, p % q)

xmod = [_ - X for _ in x]
print(gcd_list(xmod))

Submission status: Runtime Error

Solution code:
import math
import numpy as np
n, x0 = map(int, input().split())
x = np.abs(np.array(list(map(int, input().split()))) - x0)
xx = x[0]
for i in range(1, n):
    xx = math.gcd(xx, x[i])
print(xx)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
n, x0 = map(int, input().split())
x = np.array(list(map(int, input().split()))) - x0
xx = x[0]
for i in range(1, n):
    xx = math.gcd(xx, x[i])
print(xx)

Submission status: Runtime Error

Solution code:
import numpy as np
import fraction
from functools import reduce
import sys

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

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

if(n==1):
    print(abs(y[0]-z))
    sys.exit()
y=np.array(y)
y=y-z
t=[]
for i in range(1,n):
    t.append(abs(y[i]-y[i-1]))

print(gcd_list(t))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fractions
import sys

li = []
n, x = map(int, input().split())

li.append(x)

a = list(map(int, input().split()))
l = li + a

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

else:
    l.sort()
    ans = []
    for i in range(1, n):
        ans.append(l[i] - l[i-1])
    
    d = ans[0]
    for i in range(n-1):
        d = fraction.gcd(d, ans[i])
    
    print(d)

Submission status: Runtime Error

Solution code:
import math
import sys

li = []
n, x = map(int, input().split())

li.append(x)

a = list(map(int, input().split()))
l = li + a

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

else:
    l.sort()
    ans = []
    for i in range(1, n):
        ans.append(l[i] - l[i-1])
    
    d = ans[0]
    for i in range(n-1):
        d = math.gcd(d, ans[i])
    
    print(d)

Submission status: Runtime Error

Solution code:
import math
import sys

li = []
n, x = map(int, input().split())

if n == 1:
    print(abs(x - int(input())))
    sys.exit()

li.append(x)

a = list(map(int, input().split()))
l = li + a

l.sort()

ans = []
for i in range(1, n):
    ans.append(l[i] - l[i-1])

d = ans[0]

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

print(d)

Submission status: Runtime Error

Solution code:
import math
N,X=[int(i) for i in input().split()]
a=[abs(int(i)-X) for i in input().split()]
c=max(a)
for i in range(len(a)):
    c=math.gcd(c,a[i])
print(c)

Submission status: Runtime Error

Solution code:
import math

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

for i in range(len(x)):
    x2.append(abs(x[i]-X))

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

Submission status: Runtime Error

Solution code:
import math

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

for i in range(len(x)):
    x2.append(abs(x[i]-X))

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

Submission status: Runtime Error

Solution code:
import functools
import math

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

for i in range(len(x)):
    x2.append(abs(x[i]-X))

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

Submission status: Runtime Error

Solution code:
# Skip
from math import gcd
n, large_x = map(int, input().split())
x = (list(map(int, input().split())))
d = -1
if n == 1:
    print(abs(x[0] - large_x))
    exit()
for i in range(n):
    x[i] = x[i] - large_x
for i in range(n):
    if d == -1:
        d = gcd(x[0], x[1])
    d = gcd(d, x[i])
print(d)

Submission status: Runtime Error

Solution code:
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
y = x[0]
for i in range(N):
    if x[i] % y == 0:
        continue
    y = gcd(y, x[i])
print(min(gcd_x))

Submission status: Runtime Error

Solution code:
import math
import functools

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

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

l = []
for i in range(n):
    l.append(abs(xi[i] - x))

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

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] = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
xdiff = []

for i in xs:
    xdiff.append(abs(x - i))

print(gcd_list(xdiff))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

A.append(X)
sortedA = sorted(A)
B = [sortedA[i+1] - sortedA[i] for i in range(len(sortedA)-1)]

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

Submission status: Runtime Error

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

residual = [abs(x - X) for x in x_list]

def gcd(a,b):
    if(b==0):
        return a
    else:
        return gcd(b, a%b)
        
max_ = 0
for i in range(len(residual)):
    if(i == 0):
        max_ = gcd(residual[i], residual[i+1])
    elif(i == N-1):
        print(max_)
    else:
        max_ = gcd(residual[i], max_)

Submission status: Runtime Error

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

residual = [abs(x - X) for x in x_list]

def gcd(a,b):
    if(b==0):
        return a
    else:
        gcd(b, a%b)
        
max_ = 0
for i in range(len(residual)):
    if(i == 0):
        max_ = gcd(residual[i], residual[i+1])
    elif(i == N-1):
        print(max_)
    else:
        max_ = gcd(residual[i], max_)

Submission status: Runtime Error

Solution code:
import fraction

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

min_distance = abs(x[0] - X)
for i in x: min_distance = fraction.gcd(abs(i - X), min_distance)

print(min_distance)

Submission status: Runtime Error

Solution code:
import math

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

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

print(min_distance)

Submission status: Runtime Error

Solution code:
import math

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

min_distance = abs(x[0] - X)
for i in x[1:]: min_distance = math.gcd(abs(i - X), min_distance)

print(min_distance)

Submission status: Runtime Error

Solution code:
import math

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

dx = [abs(X - v) for v in x]
ans = dx[0]
for b in dx[1:]:
    ans = math.gcd(ans, b)
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
print(difference)
print(gcd([2, 4, 6, 8]))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
print(difference)
print(gcd([2, 4, 6, 8]))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
for city in cityies[1:]:
    diff = abs(city - stan)
    difference.append(diff)

max_num = gcd(difference)
print(max_num)

Submission status: Runtime Error

Solution code:
from functools import *
N, X = list(map(int, input().split(" ")))
xs = list(map(int, input().split(" ")))
xs = list(map(lambda x: X-x if X>x else x-X, xs))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b) 
r = reduce(gcd, d)
print(r)

Submission status: Runtime Error

Solution code:
N,X = map(int,input().split())
list = [int(x) for x in input().split()]
list_dist = sorted([abs(x - X) for x in list])

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

ans = list_dist[0]

for x in list_dist[1:]:
    result = gcd(result,x)

print(result)

Submission status: Runtime Error

Solution code:
N,X = map(int,input().split())
list = [int(x) for x in input().split()]
list_dist = sorted([abs(x - X) for x in list])

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

print(gcd(list_dist[0],list_dist[1]))

Submission status: Runtime Error

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

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)
a = list(map(int,input().split()))
n = a[0]
x = a[1]
li = list(map(int,input().split()))
li.append(x)
li = sorted(li)
#print(li)
s = []
for i in range(len(li)-1):
    if li[i+1]-li[i] == 0:
        continue
    s.append(li[i+1]-li[i])
print(gcd_list(s))

Submission status: Runtime Error

Solution code:
from function import gcd
n,x=map(int,input().split())
s=list(map(int,input().split()))
b=s[0]
t=abs(b-x)
for i in range(1,n):
    t=gcd(t,abs(s[i]-x))   
print(t)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import io
import sys
import math
from functools import reduce



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

def solve(lista,x):
    listd = []
    listc1 = []
    listc1 += lista
    listc1.append(x)
    listc = sorted(listc1)


    for i in range(len(listc)-1):
        ans = listc[i+1] - listc[i]
        listd.append(ans)
        

    listb = []
    for i in lista:
        if i > x:
            ans = i-x
            listb.append(ans)
        else:
            ans = x-i
            listb.append(ans)
    if gcd_list(listb)>=min(listd):
        return gcd_list(listb)
    else:
        return min(listd)


def readQuestion():

    line1 = sys.stdin.readline().rstrip()
    list1 = line1.split(" ")
    line2 = sys.stdin.readline().rstrip()
    list2 = line2.split(" ")
    list3 = [int(a) for a in list2]
    return [list3,int(list1[1])]

def main():
    n,x = readQuestion()
    answer = solve(n,x)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import io
import sys
import math
from functools import reduce



def gcd_list(numbers):#最大公約数を求める
    return reduce(math.gcd, numbers)

def solve(lista,x):
    listd = []
    listc1 = []
    listc1 += lista
    listc1.append(x)
    listc = sorted(listc1)

    #一番近い値の差をlistdに入れる
    for i in range(len(listc)-1):
        ans = listc[i+1] - listc[i]
        listd.append(ans)
        
    #それぞれの都市の位置-自分の位置の値をlistbに入れる
    listb = []
    for i in lista:
        if i > x:
            ans = i-x
            listb.append(ans)
        else:
            ans = x-i
            listb.append(ans)
    #print(listd,gcd_list(listb))
    if gcd_list(listb)>=min(listd):
        return gcd_list(listb)
    else:
        return min(listd)

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():

    line1 = sys.stdin.readline().rstrip()
    list1 = line1.split(" ")
    line2 = sys.stdin.readline().rstrip()
    list2 = line2.split(" ")
    list3 = [int(a) for a in list2]
    return [list3,int(list1[1])]

def main():
    n,x = readQuestion()
    answer = solve(n,x)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

import sys
import math
from functools import reduce

def gcd_list(numbers):#最大公約数を求める
    return reduce(math.gcd, numbers)

def solve(lista,x):
    listd = []
    listc1 = []
    listc1 += lista
    listc1.append(x)
    listc = sorted(listc1)

    #一番近い値の差をlistdに入れる
    for i in range(len(listc)-1):
        ans = listc[i+1] - listc[i]
        listd.append(ans)
        
    #それぞれの都市の位置-自分の位置の値をlistbに入れる
    listb = []
    for i in lista:
        if i > x:
            ans = i-x
            listb.append(ans)
        else:
            ans = x-i
            listb.append(ans)
    #print(listd,gcd_list(listb))
    if gcd_list(listb)>=min(listd):
        return gcd_list(listb)
    else:
        return min(listd)

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():

    line1 = sys.stdin.readline().rstrip()
    list1 = line1.split(" ")
    line2 = sys.stdin.readline().rstrip()
    list2 = line2.split(" ")
    list3 = [int(a) for a in list2]
    return [list3,int(list1[1])]

def main():
    n,x = readQuestion()
    answer = solve(n,x)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import io
import sys
import math
from functools import reduce

def gcd_list(numbers):#最大公約数を求める
    return reduce(math.gcd, numbers)

def solve(lista,x):
    listd = []
    listc1 = []
    listc1 += lista
    listc1.append(x)
    listc = sorted(listc1)

    #一番近い値の差をlistdに入れる
    for i in range(len(listc)-1):
        ans = listc[i+1] - listc[i]
        listd.append(ans)
        
    #それぞれの都市の位置-自分の位置の値をlistbに入れる
    listb = []
    for i in lista:
        if i > x:
            ans = i-x
            listb.append(ans)
        else:
            ans = x-i
            listb.append(ans)
    #print(listd,gcd_list(listb))
    if gcd_list(listb)>=min(listd):
        return gcd_list(listb)
    else:
        return min(listd)

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():

    line1 = sys.stdin.readline().rstrip()
    list1 = line1.split(" ")
    line2 = sys.stdin.readline().rstrip()
    list2 = line2.split(" ")
    list3 = [int(a) for a in list2]
    return [list3,int(list1[1])]

def main():
    n,x = readQuestion()
    answer = solve(n,x)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# coding:utf-8

import math

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

dist_list = [abs(x-y) for x in map(int, input().split())]

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

print(d)

Submission status: Runtime Error

Solution code:
# coding:utf-8

import math

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

dist_list = [abs(x-y) for x in map(int, input().split())]

dist_list.sort()

if n == 1:
    d = dist_list[0]
else:
    for i in reversed(range(n)):
        if i == n-1:
            d = math.gcd(dist_list[i], dist_list[i-1])
        else:
            d = math.gcd(dist_list[i-1], d)    

print(d)

Submission status: Runtime Error

Solution code:
# coding:utf-8

import math

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

dist_list = [abs(x-y) for x in map(int, input().split())].sort()

if n == 1:
    d = dist_list[0]
else:
    for i in reversed(range(n)):
        if i == n-1:
            d = math.gcd(dist_list[i], dist_list[i-1])
        else:
            d = math.gcd(dist_list[i-1], d)    

print(d)

Submission status: Runtime Error

Solution code:
# coding:utf-8

import math

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

dist_list = [abs(x-y) for x in map(int, input().split())]

if n == 1:
    d = dist_list[0]
else:
    for i in reversed(range(n)):
        if i == n-1:
            d = math.gcd(dist_list[i], dist_list[i-1])
        else:
            d = math.gcd(dist_list[i-1], d)    

print(d)

Submission status: Runtime Error

Solution code:
import math

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

dist_list = [abs(x-y) for x in map(int, input().split())]

if n == 1:
    d = dist_list[0]
else:
    for i in reversed(range(n-1)):
        if i == n-1:
            d = math.gcd(dist_list[i], dist_list[i-1])
        else:
            d = math.gcd(dist_list[i-1], d)    

print(d)

Submission status: Runtime Error

Solution code:
# coding:utf-8

import math

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

dist_list = [abs(x-y) for x in map(int, input().split())]

if n == 1:
    d = dist_list[0]
elif n >= 2:
    for i in reversed(range(n-1)):
        if i == n-2:
            d = math.gcd(dist_list[i], dist_list[i-1])
        else:
            d = math.gcd(dist_list[i-1], d)    

print(d)

Submission status: Runtime Error

Solution code:
import math
n,x = map(int, input().split())
list_x = list((map(int, input().split())))
list_x.append(x)
list_x.sort()
list_dist = []
for i in range(0,n):
    list_dist.append(list_x[i+1] - list_x[i])
gcd1 = list_dist[0]
for i in range(1,n):
    gcd1 = math.gcd(gcd1, list_dist[i])
print(gcd1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math,functools
n,x = map(int, input().split())
list_x = list((map(int, input().split())))
list_x.append(x)
list_x.sort()
list_dist = []
for i in range(0,n):
    list_dist.append(list_x[i+1] - list_x[i])
print(functools.reduce(math.gcd,list_dist))

Submission status: Runtime Error

Solution code:
import math
import functools
n,x = map(int, input().split())
list_x = list((map(int, input().split())))
list_x.append(x)
list_x.sort()
list_dist = []
for i in range(0,n):
    list_dist.append(list_x[i+1] - list_x[i])
print(functools.reduce(math.gcd,list_dist))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#! /usr/bin/python
from math import gcd
from functools import reduce
#N, X = 3, 3
#CITY = [1, 7, 11]
#
#N, X = 3, 81
#CITY = [33, 105, 57]

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

nanka = [abs(X - c) for c in CITY]
print(reduce(lambda x, y: gcd(x, y), nanka))

Submission status: Runtime Error

Solution code:
N,X=map(int,input().split())
x=list(map(int,input().split()))
absx=[]
for i in range(len(x)):
    absx.append(abs(x[i]-X))
import math
from functools import reduce

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math
import functools

def main():
    N,X = (int(i) for i in input().split())
    x=list(map(int,input().split()))

    gcd_l = []
    gcd_l.append(abs(X-x[0]))

    for i in range(1,N):
        gcd_l.append(abs(x[i-1]-x[i]))

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

main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def main():
    N,X = (int(i) for i in input().split())
    x=list(map(int,input().split()))

    gcd_l = []
    gcd_l.append(abs(X-x[0]))

    for i in range(1,N):
        gcd_l.append(abs(x[i-1]-x[i]))

    print(reduce(math.gcd,gcd_l))

main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

gcd_l = []
gcd_l.append(abs(X-x[0]))

for i in range(1,N):
    gcd_l.append(abs(x[i-1]-x[i]))

print(reduce(math.gcd,gcd_l))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def func():
    n,x0 = map(int,input().split())
    x = [int(i) for i in input().split()]
    x.append(x0)
    x.sort()
    x.reverse()
    
    l = []
    before = 0
    before = None
    for xi in x:
        if before == None:
            before = xi
            continue
        l.append(xi-before)
        before = xi
    
    print(reduce(math.gcd,l))
func()

Submission status: Runtime Error

Solution code:
c.sort()
ans = c[1]-c[0]

for i in range(n-1):
    ans = gcd(ans,c[i+2]-c[i+1])

print(ans)

Submission status: Runtime Error

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

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

from math import gcd

c.sort()
ans = c[1]-c[0]

for i in range(n-1):
    ans = gcd(ans,c[i+2]-c[i+1])

print(ans)

Submission status: Runtime Error

Solution code:
import math
n, x = list(map(int, input().split()))
list = list(map(int, input().split()))
list = [abs(i - x) for i in list]
min = min(list)
for num in list:
    min = math.gcd(min, num)
print(min)

Submission status: Runtime Error

Solution code:
n, place = [int(x) for x in input().split(' ')]
city_address = [int(x) - place for x in input().split(' ')]

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

answer = city_address[0]
for address in city_address:
	answer = gcd(answer, address)

print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()
k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
print(gcd_list(b))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()

k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1

m = min(b) 

lo = []

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


                
print(gcd_list(b))

Submission status: Runtime Error

Solution code:
import fractions

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

Submission status: Runtime Error

Solution code:
n,x = map(int, input().split())
l = [ abs(i - x) for i in list(map(int, input().split()))]
l.sort(reverse=True)
if len(l) == 1:ans = l[0]
else:
  while len(l) != 1:
    l.sort(reverse=True)
    if 0 not in l: l.append(0)
    l = [ l[i] - l[i+1] for i in range(len(l) - 1)]
    l = list(set(l))
    for i in l:
      if i % min(l) != 0:break
    else:
      l[0] = min(l)
      break
  ans = l[0]
print(ans)

Submission status: Runtime Error

Solution code:
n,x = map(int, input().split())
l = [ abs(i - x) for i in list(map(int, input().split()))]
l.sort(reverse=True)
if len(l) == 1:ans = l[0]
else:
  while len(l) != 1:
    l.sort(reverse=True)
    l.append(0)
    l = [ l[i] - l[i+1] for i in range(len(l) - 1)]
    l = list(set(l))
    for i in l:
      if i % min(l) != 0:break
    else:
      l[0] = min(l)
      break
  ans = l[0]
print(ans)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
t=[]
s=list(map(int,input().split()))
for i in s:
    t.append(abs(i-k))
import math
from functools import reduce
print(reduce(math.gcd,t))

Submission status: Runtime Error

Solution code:
import fraction
N, X = [int(i) for i in input().split()]
x = [int(x) for x in input().split()]
x.append(X)
x.sort()

distance = []
for i,xe in enumerate(x):
    if i is not 0:
        distance.append(xe - x[i-1])

print(fraction.gcd(distance))

Submission status: Runtime Error

Solution code:
def gcd(s):
    b=s[0]
    if b==1:
        return 1
    
    for i in range(b,1,-1):
        if b%i==0:
            flag=0
            for j in s:
                if j%i!=0:
                    flag=1
                    break
            if flag==0:
                c.append(i)
            for j in range(len(s)):
                s[j]=int(s[j]/i)
            
            
            

N,X=map(int,input().split())
a=list(map(int,input().split()))
import numpy as np
a=np.array(a)

a-=X
m=min(a)
a-=m
a=sorted(a)
s=a[1:]
s=np.array(s)
c=[]
gcd(s)
ans=1
for i in c:
    ans*=i
print(ans)

Submission status: Runtime Error

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


def allgcd(d):
    if len(d) == 1:
        return d
    ret_gcd = d[0]
    for i in d:
        ret_gcd = gcd(ret_gcd, i)
    return ret_gcd


def maxNumVisitCity(N, X, x):
    if len(x) == 1:
        return abs(x[0] - X)

    d = []
    for i in x:
        d.append(abs(i - X))
    return allgcd(d)


def main():
    N, X = map(int, input().split())
    x = map(int, input().split())
    print(maxNumVisitCity(N, X, x))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


def maxNumVisitCity(N, X, x):
    d = []
    for i in x:
        d.append(abs(i - X))
    return reduce(math.gcd, d)


def main():
    N, X = map(int, input().split())
    x = map(int, input().split())
    print(maxNumVisitCity(N, X, x))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

rec = []
fil = []
memo_1 = 0
memo_2 = 0
count = 0

for i in range(N[0]):
    mint = X[i] - N[1]
    if mint < 0:
        mint *= -1
    rec.append(mint)
else:
    if len(set(rec)) == 1:
        print(rec[0])
    else:
        while len(set(rec)) != 1:
            a = max(rec)
            rec.remove(max(rec))
            b = max(rec)
            rec.remove(max(rec))
            rec.append(math.gcd(a, b))

        else:
            print(rec[0])

Submission status: Runtime Error

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

for i in range(len(city)):
	sub.append(abs(x - city[i]))


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


if sub == 1:
	print(sub[0])
elif sub == 2:
	print(gcd(sub[0],sub[1]))
else:
	p = gcd(sub[0], sub[1])
	for i in range(2,len(sub)):
		p = gcd(p,sub[i])
	print(p)