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:
# C
import math
from functools import reduce

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

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

N, X = map(int, input().split())
x = list(map(int, input().split()))
new_list = list(map(lambda l: abs(l - X), x))
new_list.sort()
print(gcd(*new_list))

Submission status: Runtime Error

Solution code:
n,x = (int(i) for i in input().split())
listx=[int(i) for i in input().split()]
#print(n,x,listx)
listy=[abs(listx[i]-x) for i in range(n)]
listy.reverse()
#print(listy)

def gcd(y, x):
    if x == 0:
        return y
    else:
        return gcd(x, y % x) #再帰定義
if x==1:
  ans=listy[0]
else:
  if listy[1]==0:
    ans=listy[0]
  else:
    ans=gcd(listy[0],listy[1])
    if n > 2:
      for i in range(n-2):
        if listy[i+2]==0:
          ans=ans
        else:
          ans=gcd(ans,listy[i+2])
  
print(ans)

Submission status: Runtime Error

Solution code:
n,x = (int(i) for i in input().split())
listx=[int(i) for i in input().split()]
#print(n,x,listx)
listy=[abs(listx[i]-x) for i in range(n)]
listy.sort()
#print(listy)

def gcd(y, x):
    if x == 0:
        return y
    else:
        return gcd(x, y % x) #再帰定義
if x==1:
  ans=listy[0]
else:
  ans=gcd(listy[0],listy[1])
  if n > 2:
    for i in range(n-2):
      ans=gcd(ans,listy[i+2])
  
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()
a=[]
for i in range(n-1):
        a.append(x[i+1]-x[i])        

def gcd(m,n):
        while n:
                m,n = n,m%n
        return m

ans=a[0]
for j in a:
        if j%ans != 0:
                ans = gcd(j,ans)
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()
a=[]
for i in range(n-1):
        a.append(x[i+1]-x[i])        

def gcd(m,n):
        while n:
                m,n = n,m%n
        return m

ans=min(a)
for j in a:
        if j%ans != 0:
                ans = gcd(j,ans)
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()
a=[]
for i in range(n-1):
        a.append(x[i+1]-x[i])        

def gcd(m,n):
        while n!=0:
                m,n = n,m%n
        return m

ans=min(a)
for j in a:
        if j%ans != 0:
                ans = gcd(j,ans)
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()
a=[]
for i in range(n-1):
        a.append(x[i+1]-x[i])        

def gcd(m,n):
        while n!=0:
                m,n = n,m%n
        return m

ans=min(a)
for j in a:
        if j%min(a) != 0:
                ans = gcd(j,ans)
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()
a=[]
for i in range(n-1):
        a.append(x[i+1]-x[i])        

def gcd(m,n):
        while n!=0:
                s = m%n
                m = n
                n = s
        return m

ans=min(a)
for j in a:
        if j%min(a) != 0:
                ans = gcd(j,ans)
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()
a=[]
for i in range(len(x)-1):
        a.append(x[i+1]-x[i])

def gcd(m,n):
        gcd(n,m%n)
        if m%n == 0:
                return n

for j in range(len(a)):
        if a[j]%min(a) == 0:
                ans = min(a)
        else:
                ans = gcd(j,min(a))
print(ans)

Submission status: Runtime Error

Solution code:
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
     
    N, X = input().split()
    xList = [int(x) for x in input().split()]
    N = int(N)
    X = int(X)
    xList.append(X)
    xList.sort()
    diffList = []
    for x, xx in zip(xList, xList[1:]):
        diffList.append(xx - x)
    if len(diffList) > 1:
        diffList.sort()
        gcdList = []
        for x in diffList[1:]:
            gcdList.append(gcd(diffList[0], x))
        gcdList.sort()
        print(gcdList[0])
    else:
        print(diffList[0])

Submission status: Runtime Error

Solution code:
import fraction

N, X = input().split()
xList = [int(x) for x in input().split()]
N = int(N)
X = int(X)
xList.append(X)
xList.sort()
diffList = []
for x, xx in zip(xList, xList[1:]):
    diffList.append(xx - x)

diffList.sort()

print(fraction.gcd(diffList[0], diffList[-1]))

Submission status: Runtime Error

Solution code:
n, s = map(int, input().split())
xl = [abs(int(i) - s) for i in input().split()]

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

y = xl[0]
for i in range(1,n-1):
    if xl[i]%y != 0:
        y = gcd(y, x[i])
print(y)

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()
a=[]
for i in range(len(x)-1):
    a.append(x[i+1]-x[i])
a.sort()
def gcd(m,n):
    while n:
        m,n=n,m%n
    return m
ans=a[0]
for j in range(1,len(a)):
    if a[j]%a[0]!=0:
        ans=math.gcd(ans,a[j])
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()
a=[]
for i in range(len(x)-1):
    a.append(x[i+1]-x[i])
a.sort()
ans=a[0]
for j in range(1,len(a)):
    if a[j]%a[0]!=0:
        ans=math.gcd(ans,a[j])
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()
a=[]
for i in range(len(x)-1):
    a.append(x[i+1]-x[i])
a.sort()
ans=a[0]
for j in range(1,len(a)):
    if a[j]>0:
        ans=math.gcd(ans,a[j])
    else:
        ans=ans
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()
a=[]
for i in range(len(x)-1):
    a.append(x[i+1]-x[i])
a.sort()
ans=a[0]
for j in range(1,len(a)):
    if a[j]%a[0]!=0:
        ans=math.gcd(ans,a[j])
    else:
        ans=ans
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()
a=[]
for i in range(len(x)-1):
    a.append(x[i+1]-x[i])
s=[]
for j in range(len(a)-1):
    s.append(math.gcd(a[j],a[j+1]))
print(min(s))

Submission status: Runtime Error

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
import math
from functools import reduce


N,X = map(int, input().split())
A = list(map(int, input().split()))
A = [ abs(a-X) for a in A]

print( reduce(math.gcd, A) )

Submission status: Runtime Error

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
N,X = map(int, input().split())
A = list(map(int, input().split()))
A = [ abs(a-X) for a in A]
import math
from functools import reduce

print( reduce(math.gcd, A) )

Submission status: Runtime Error

Solution code:
import fractions


def func(l):
    r = fractions.gcd(l[0], l[1])
    for i in range(1, len(l) - 1):
        r = fractions.gcd(r, l[i + 1])
    return r


def main():
    n, x = map(int, input().split())
    xl = [int(i) for i in input().split()]
    xl.append(x)
    xl.sort()
    
    dl = []
    for i in range(len(xl) - 1):
        d = xl[i + 1] - xl[i]
        dl.append(d)

    print(func(dl))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fraction


def func(l):
    r = math.gcd(l[0], l[1])
    for i in range(1, len(l) - 1):
        r = math.gcd(r, l[i + 1])
    return r


def main():
    n, x = map(int, input().split())
    xl = [int(i) for i in input().split()]
    xl.append(x)
    xl.sort()
    
    dl = []
    for i in range(len(xl) - 1):
        d = xl[i + 1] - xl[i]
        dl.append(d)

    print(func(dl))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math


def func(l):
    r = math.gcd(l[0], l[1])
    for i in range(1, len(l) - 1):
        r = math.gcd(r, l[i + 1])
    return r


def main():
    n, x = map(int, input().split())
    xl = [int(i) for i in input().split()]
    xl.append(x)
    xl.sort()
    
    dl = []
    for i in range(len(xl) - 1):
        d = xl[i + 1] - xl[i]
        dl.append(d)

    print(func(dl))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,x = map(int,input().split())
lst = list(map(int, input().split()))
 
lst.append(x)
lst.sort()
 
dif_lst = []
for i in range(len(lst)-1):
    dif = lst[i+1] - lst[i]
    dif_lst.append(lst[i+1] - lst[i])
dif_lst.sort()
 
def dif_get(lst):
    dif_lst = [lst[0]]
    for i in range(len(lst)-1):
        dif = lst[i+1] - lst[i]
        if dif == 0:
            continue
        else:
            dif_lst.append(lst[i+1] - lst[i])
    dif_lst.sort()
    if dif_lst[0] == 1:
        return 1
    elif len(dif_lst) == 1:
        return dif_lst[0]
    else:
        return dif_get(dif_lst)
 
print(dif_get(dif_lst))

Submission status: Runtime Error

Solution code:
n,x = map(int,input().split())
lst = list(map(int, input().split()))
 
lst.append(x)
lst.sort()
 
dif_lst = []
for i in range(len(lst)-1):
    dif = lst[i+1] - lst[i]
    if dif == 0:
        continue
    else:
        dif_lst.append(lst[i+1] - lst[i])
dif_lst.sort()
 
def dif_get(lst):
    dif_lst = [lst[0]]
    for i in range(len(lst)-1):
        dif = lst[i+1] - lst[i]
        if dif == 0:
            continue
        else:
            dif_lst.append(lst[i+1] - lst[i])
    dif_lst.sort()
    if dif_lst[0] == 1:
        return 1
    if len(dif_lst) == 1:
        return dif_lst[0]
    else:
        return dif_get(dif_lst)
 
print(dif_get(dif_lst))

Submission status: Runtime Error

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

lst.append(x)
lst.sort()

dif_lst = []
for i in range(len(lst)-1):
    dif_lst.append(lst[i+1] - lst[i])
dif_lst.sort()

def dif_get(lst):
    dif_lst = [lst[0]]
    for i in range(len(lst)-1):
        dif = lst[i+1] - lst[i]
        if dif == 0:
            continue
        else:
            dif_lst.append(lst[i+1] - lst[i])
    dif_lst.sort()
    if dif_lst[0] == 1:
        return 1
    if len(dif_lst) == 1:
        return dif_lst[0]
    else:
        return dif_get(dif_lst)

print(dif_get(dif_lst))

Submission status: Runtime Error

Solution code:
import numpy as np

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

X = list(map(int,input().split()))
X = [abs(i-x) for i in X]
# print(X)

def gcd(m,n):
    mx = max(m,n)
    mn = min(m,n)
    tmp = mx%mn
    if tmp == 0:
        return mn
    else:
        return gcd(mn, tmp)

def gcd_list(data):
    if len(data)==1:
        return data[0]
    tmp = gcd(data[0], data[1])
    if len(data)==2:
        return tmp
    else:
        new_data = [tmp]+data[2:]
        return gcd_list(new_data)

# print(gcd_list([2,4,8]))
print(gcd_list(X))

Submission status: Runtime Error

Solution code:
import fraction

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

if len(x) > 1:
  gcd = fraction.gcd(x[0], x[1])
  for i in x:
    gcd = fraction.gcd(gcd, i)
else:
  gcd = x[0]
print(gcd)

Submission status: Runtime Error

Solution code:
import fraction

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

if len(x) > 1:
  gcd = math.gcd(x[0], x[1])
  for i in x:
    gcd = math.gcd(gcd, i)
else:
  gcd = x[0]
print(gcd)

Submission status: Runtime Error

Solution code:
import math

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

if len(x) > 1:
  gcd = math.gcd(x[0], x[1])

  for i in x:
    gcd = math.gcd(gcd, i)
else:
  gcd = x[0]

print(gcd)

Submission status: Runtime Error

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

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

ans=gcd(abs(x[0]-x0),abs(x[1]-x0))
for i in range(n):
    ans=gcd(ans,abs(x[i]-x0))
print(ans)

Submission status: Runtime Error

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

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

ans=gcd(abs(x[0]-x0),abs(x[1]-x0))
for i in range(n):
    ans=gcd(ans,abs(x[0]-x0))
print(ans)

Submission status: Runtime Error

Solution code:
n,x0=map(int,input().split())
x=sorted(list(map(int,input().split())))
y=[]
for i in range(n-1):
    y.append(x[i+1]-x[i])
mindelta=min(y)
ans=1
for i in range(1,mindelta+1):
    flag=True
    if abs(x0-x[0])%i!=0:
        flag=False
    for j in range(n-1):
        if y[j]%i!=0:
            flag=False
    if flag:
        ans=i
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator, math
from bisect import *

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

def f():
    X.sort()
    L = len(X)
    if L == 1:
        return abs(X[0] - L)
    
    i = bisect_left(X, x)
    
    d = [t - u for t,u in zip(X[1:], X[:-1])]
    s = None
    if i == 0:
        s = set(d)
        s.add(x[0] - x)
    elif i == len(X):
        s = set(d)
        s.add(x - X[-1])
    else:
        s = set(d[:i - 1])
        s.update(d[i+1:])
        s.update({x - X[i-1], X[i] - x})
    return reduce(lambda a,x: math.gcd(a, x), s)

print(f())

Submission status: Runtime Error

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

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

sub_list = []
for i in range(N-1):
  sub_list.append(abs(x[i] - x[i+1]))

ind = 0
for i in range(1,len(sub_list)):
  ans = gcd(sub_list[ind], sub_list[i])
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]
# print(diff)
for i in range(N-1):
    diff[i+1] = gcd(diff[i], diff[i+1])
print(diff[N-1])

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import math
from functools import reduce

def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    y = list(map(lambda v: abs(v - X), x))

    a = reduce(math.gcd, y)

    print(a)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import math
#from functools import reduce

def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    lmd = lambda v: abs(v - X)
    y = list(map(lmd, x))

#    g = reduce(math.gcd, y)

    a = y.pop(0)
    while 0 < len(y):
        b = y.pop(0)
        a = math.gcd(a, b)

    print(a)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import math
#from functools import reduce

def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    y = list(map(lambda v: v - X, x))

#    g = reduce(math.gcd, y)

    a = y.pop(0)
    while 0 < len(y):
        b = y.pop(0)
        a = math.gcd(a, b)

    print(a)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import math
from functools import reduce

def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    y = list(map(lambda v: v - X, x))

    g = reduce(math.gcd, y)

    print(g)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math

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

ans = None
for i in xi:
    distance = abs(i-x)
    if ans is None:
        ans = distance
    else:
        ans = math.gcd(ans, distance)
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

ans = None
for ind, i in enumerate(x):
    x[ind] = abs(i - X)
    if ans is None:
        ans = x[ind]
    else:
        ans = math.gcd(ans, x[ind])
print(ans)

Submission status: Runtime Error

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

for i, n in enumerate(xi):
    xi[i] = abs(xi[i]-x)

if len(xi)==1:
    print(xi[0])
    exit()
    
xi.sort()
print(math.gcd(xi[0], xi[1]))

Submission status: Runtime Error

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

for i, n in enumerate(xi):
    xi[i] = abs(xi[i]-x)

while 1:
    out = min(xi)
    for i, n in enumerate(xi):
        if n%out!=0:
            for j in range(2,out+1):
                if out%j==0:
                    out = out / j
            continue
    print(int(out))
    exit()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

N, X = input().split(" ")
N = int(N)
X = int(X)
list = input().split(" ")
ans_list = [abs(X - int(list[i])) for i in range(N)]
print(int(gcd(ans_list)))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

N, X = input().split(" ")
N = int(N)
X = int(X)
list = input().split(" ")
ans_list = [abs(X- int(list[i])) for i in range(N)]
print(gcd(ans_list))

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()]
#d = [abs(X-i) for i in x if abs(X-i)!=0]
d = [abs(X-i) for i in x]

gcd = d[0]
i=1
while True:
    if i>=N:
        break
    gcd = math.gcd(gcd,d[i])
    i=i+1 

print(gcd)

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()]
d = [abs(X-i) for i in x if abs(X-i)!=0]

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

print(gcd)

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()]
d = [abs(X-i) for i in x if abs(X-i)!=0]

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

print(gcd)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

def func(nums):
    return reduce(math.gcd, nums)

print(func(x))

Submission status: Runtime Error

Solution code:
n,s = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if n>1:
    dif = []
    for i in range(n-1):
        dif.append(x[i+1]-x[i])

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

    for i in range(res):
        flag = True
        for j in range(n-1):
            if dif[j]%(res-i)!=0:
                flag = False
                break
        if flag:
            res -= i
            break
                
    print(res)
else:
    print(abs(x[0]-s))

Submission status: Runtime Error

Solution code:
n,s = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if n>1:
    dif = []
    for i in range(n-1):
        dif.append(x[i+1]-x[i])

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

    print(res)
    for i in range(res):
        flag = True
        for j in range(n-1):
            if dif[j]%(res-i)!=0:
                flag = False
                break
        if flag:
            res -= i
            break
                
    print(res)
else:
    print(abs(x[0]-s))

Submission status: Runtime Error

Solution code:
n,s = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
dif = []
for i in range(n-1):
    dif.append(x[i+1]-x[i])


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

res = min(min(dif),min(difs))
for i in range(res):
    flag = True
    for j in range(n-1):
        if dif[j]%(res-i)!=0:
            flag = False
            break
    if flag:
        res -= i
        break
            
print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fracion
from functools import reduce

S = list(map(int,input().split()))
N = S[0]
X = S[1]
x = list(map(int,input().split()))
x.append(X)
xmin = min(x)
xlist = list(map(lambda y: y-xmin ,x))
xlist.remove(0)

answer = reduce(fraction.gcd, xlist)
print(answer)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

S = list(map(int,input().split()))
N = S[0]
X = S[1]
x = list(map(int,input().split()))
x.append(X)
xmin = min(x)
xlist = list(map(lambda y: y-xmin ,x))
xlist.remove(0)

answer = reduce(math.gcd, xlist)
print(answer)

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())

A = list(input().split())
B = []
ans = abs(int(A[0])-b)
for i in A:
    aa = abs(int(i) - b)
    ans = math.gcd(ans, aa)

print(ans)

Submission status: Runtime Error

Solution code:
N_X = list(map(int,input().split()))
data = list(map(int,input().split()))
k = 0

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

def mulgcd(list):
    if len(list)==2:
        return gcd(list[0],list[1])
    return gcd(mulgcd(list[1:]),list[0])


for i in data:
    data[k] = abs(i - N_X[1])
    k += 1


if N_X[0] == 1:
    print(abs(data[0]))
else:
    print(mulgcd(data))

Submission status: Runtime Error

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

G=[abs(x0-X) for x0 in x]

def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def divisorize(fct):
    b, e = fct.pop() 
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
   
for i,g in enumerate(G):
    fct = factorize(g)
    DIV=[]
    for div in divisorize(fct):
        DIV.append(num(div))
    if i==0:
        result=DIV[:]
    else:
        result=list(set(result)&set(DIV))
        
print max(result)

Submission status: Runtime Error

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

G=[abs(x0-X) for x0 in x]

def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
   
for i,g in enumerate(G):
    fct = factorize(g) # 素因数
    DIV=[]
    for div in divisorize(fct):
        DIV.append(num(div))
    if i==0:
        result=DIV[:]
    else:
        result=list(set(result)&set(DIV))
        
print max(result)

Submission status: Runtime Error

Solution code:
import math

def solve(X, xs):
    xs = list(xs) + [X]
    xs.sort()
    minx = min(xs)
    zs = [x - minx for x in xs]

    gcd = None
    for z in zs:
        if z == 0:
            gcd = z
        else:
            gcd = math.gcd(gcd, z)
    return gcd

def test():
    print(solve(13, [16 + 3 * 102485 * i for i in range(10**5)]))

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

    print(solve(X, xs))

Submission status: Runtime Error

Solution code:
import math

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

xs.append(X)
xs = sorted(xs)

d = [y-x for x,y in zip(xs[:-1], xs[1:])]

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

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;
int main() {
    int n, x;
    cin >> n >> x;
    const int N = 100000;
    int xx[N];
    xx[0] = x;
    for (int i = 1; i <= n; ++i) {
        cin >> xx[i];
    }
    sort(xx, xx + n + 1);
    int Min = 11111111;
    for (int i = 0; i < n; ++i) {
        if (Min > xx[i + 1] - xx[i]) {
            Min = xx[i + 1] - xx[i];
        }
    }
    cout << Min << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
N, X = map(int, input().split())
loc = list(map(int, input().split()))

print(reduce(gcd, [abs(l-X) for l in loc]))

Submission status: Runtime Error

Solution code:
from functools import reduce
from collections import Counter

N, X = map(int, input().split())
loc = list(map(int, input().split()))
mem = {}

def prime_factors(n):
    if mem.get(n) is not None:
        return mem[n]
    else:
        i = 2
        factors = []
        while i*i <= n:
            if n % i == 0:
                factors.append(i)
                n = n // i
            else:
                i += 1
        if n > 1:
            factors.append(n)
        mem[n] = factors
    return factors


def find_shared_factors(factor1, factor2):
    counters = [Counter(factor1), Counter(factor2)]
    if len(factor2) == 0:
        return factor1
    elif len(factor1) == 0:
        return factor2
    else:
        return list(reduce(lambda x,y: x&y, counters).elements())

factors = []
for l in loc:
    factors = find_shared_factors(prime_factors(abs(l-X)), factors)
for i in range(N):
    for j in range(N):
        if i < j:
            factors = find_shared_factors(prime_factors(abs(loc[i]-loc[j])), factors)

r = reduce(lambda x,y: x*y, factors)

print(r)

Submission status: Runtime Error

Solution code:
from functools import reduce
from collections import Counter

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

def prime_factors(n):
    i = 2
    factors = []
    while i*i <= n:
        if n % i == 0:
            factors.append(i)
            n = n // i
        else:
            i += 1
    if n > 1:
        factors.append(n)
    return factors

def find_shared_factors(factors):
    counters = [Counter(factor) for factor in factors]
    shared = []
    keys = reduce(lambda x,y: x|y, [set(c.keys()) for c in counters])
    for key in keys:
        r = [counter[key] for counter in counters]
        if min(r) > 0:
            for _ in range(min(r)):
                shared.append(key)
    return shared

d1 = find_shared_factors([prime_factors(abs(l-X)) for l in loc])
d2 = find_shared_factors([prime_factors(abs(loc[i] - loc[j])) for i in range(N) for j in range(N) if i <= j])
d3 = find_shared_factors([d1, d2])
r = reduce(lambda x,y: x*y, d3) if len(d3) > 0 else reduce(lambda x,y: x*y, d1)
print(r)

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

clist = [X]
diff = []

a = list(map(int, input().split()))
clist.extend(a)

clist.sort(reverse = False)

for s in range(1, N+1):
    diff.append(clist[s] - clist[s-1])

print(gcd_list(diff))

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

clist = [X]
diff = []

for i in range(N):
    clist.append(list(map(int, input().split)))

clist.sort(reverse = False)

for s in range(1, N+1):
    diff.append(clist[s] - clist[s-1])

print(gcd(*diff))

Submission status: Runtime Error

Solution code:
#include<stdio.h>
int buffer[1000];
void merge(long a[],int left,int right){
    if(left<right){
        int axis=(left+right)/2,i=left,p=0,q=left,r=0;
        merge(a,left,axis);
        merge(a,axis+1,right);
        while(i<=axis)buffer[p++]=a[i++];
        while(i<=right && r<p)a[q++]=(a[i]<=buffer[r])?a[i++]:buffer[r++];
        while(r<p)a[q++]=buffer[r++];
    }
}
int main(void){
    long N,X;
    scanf("%ld%ld",&N,&X);
    long Xi[N];
    for(int i=0;i<N;i++){
        scanf("%ld",&Xi[i]);
    }
    for(int i=0;i<N;i++){
        Xi[i]=Xi[i]-X;
        if(Xi[i]<0){
            Xi[i]=-1*Xi[i];
        }
    }
    merge(Xi,0,N-1);
    long D=Xi[0];
    long c=0;
    long a=0;
    while(c!=1){
        for(int i=0;i<N;i++){
            a=0;
            if((Xi[i]%D)!=0){
                a=1;
                D-=1;
                break;
            }
        }
        if(a==0){c=1;}
    }
    printf("%ld\n",D);
}

Submission status: Runtime Error

Solution code:
import math

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

x_0 = [x_- x_min for x_ in x]

gcd = x_0[0]
for x_0_ in x_0:
    gcd = math.gcd(gcd,x_0_)

ans = gcd

if N==1:
    ans = abs(x[0] - X)

print(ans)