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: Wrong Answer

Solution code:
from fractions import gcd
n, x =map(int,input().split())
s = list(map(int,input().split()))
if n ==1:
    print(abs(s[0]- x))
else:
    a, b = abs(s[0] - x) ,abs(s[1] - x)
    for i in range(1,n-1):
        y = gcd(a, b)
        a, b = y, abs(s[i+1] - x)
    print(a)

Submission status: Wrong Answer

Solution code:
def gcd(x, y):
    while (y):
        x, y = y, x % y
    return x

n,x=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    print(abs(a[0]-x))
else:
    a.append(x)
    a.sort()
    s = set()
    for i in range(1, n):
        s.add(a[i] - a[i - 1])
    s = list(s)
    hcf = s[0]
    for i in s[1:]:
        if i!=0:
            hcf = gcd(hcf, i)
    print(hcf)

Submission status: Wrong Answer

Solution code:
def gcd(x, y):
    while (y):
        x, y = y, x % y
    return x

n,x=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    print(abs(a[0]-x))
else:
    a.append(x)
    a.sort()
    s = set()
    for i in range(1, n):
        s.add(a[i] - a[i - 1])
    s = list(s)
    hcf = s[0]
    for i in s:
        if i!=0:
            hcf = gcd(hcf, i)
    print(hcf)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
i = list(map(int, input().split()))
s = 10 ** 9
for num in i:
  dif = abs(x - num)
  if dif < s:
    s = dif
print(s)

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
A = list(map(int,input().split()))
ans = abs(X - A[0])
for i in range(N-1):
    ans = min(min(ans,abs(A[i+1]-A[i])),abs(X-A[i]))
print(ans)

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
A = list(map(int,input().split()))
ans = 10**9
for i in range(N-1):
    ans = min(abs(X-A[i]),min(ans,abs(A[i+1]-A[i])))
print(ans)

Submission status: Wrong Answer

Solution code:
# 最大公約数
def gcd(a,b):
    while b != 0:
        a,b = b, a%b
    return a

n,x = map(int,input().split())
X = list(map(int, input().split()))
a = []
dist = []
if len(X) == 1:
    print(abs(X[0]-x))
    exit()
for i in range(len(X)-1):
    a.append(abs(X[i]-x))
ans = 0
for d in a:
    ans = gcd(ans,d)
print(ans)

Submission status: Wrong Answer

Solution code:
# 最大公約数
def gcd(a,b):
    while b != 0:
        a,b = b, a%b
    return a

n,x = map(int,input().split())
X = list(map(int, input().split()))
X.sort()
dist = []
if len(X) == 1:
    print(abs(X[0]-x))
    exit()
for i in range(len(X)-1):
    dist.append(X[i+1] - X[i])
ans = 0
for d in dist:
    ans = gcd(ans,d)
print(ans)

Submission status: Wrong Answer

Solution code:
# 最大公約数
def gcd(a,b):
    while b != 0:
        a,b = b, a%b
    return a

n,x = map(int,input().split())
X = list(map(int, input().split()))
X.sort()
dist = []
if len(X) == 1:
    print(X[0]-x)
    exit()
for i in range(len(X)-1):
    dist.append(X[i+1] - X[i])
ans = 0
for d in dist:
    ans = gcd(ans,d)
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n):
        a[i] -=x
    if n == 1:
        print(a[0])
        return
    ans = abs(a[1] - a[0])
    for i in range(1, n):
        ans = gcd(abs(a[i] - a[i-1]), ans)
    print(ans)

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd


def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n):
        a[i] -=x
    if n == 1:
        print(a[0])
        return
    ans = a[1] - a[0]
    for i in range(2, n):
        ans = gcd(a[i] - a[i-1], ans)
    print(ans)

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a)
    for i in range(n):
        a[i] -=x
    if n == 1:
        print(a[0])
        return
    ans = a[1] - a[0]
    for i in range(1, n):
        ans = gcd(a[i] - a[i-1], ans)
    print(ans)

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

from fractions import gcd

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

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


for j in range(n):
    if j==0:
        ans = gcd(city[j],city[j+1])
    else:
        ans = gcd(ans,city[j])

print(abs(ans))

Submission status: Wrong Answer

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

from fractions import gcd

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

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


for j in range(n):
    if j==0:
        ans = gcd(city[j],city[j+1])
    else:
        ans = gcd(ans,city[j])

print(abs(ans))

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
xs = list(map(int, input().split()))
ds = []
for i in range(n):
  if xs[i]-x < 0:
    ds.append((xs[i]-x)*(-1))
  else:
    ds.append(xs[i]-x)
nums = sorted(list(set(ds)))
if n==1 or len(nums)==1:
  print(nums[0])
  quit()
else:
  a = nums[1]
  b = nums[0]
  while b>0:
    a,b = b, a%b
  print(a)

Submission status: Wrong Answer

Solution code:
import fractions
N,X=map(int,input().split())
x=list(map(lambda x: abs(int(x)-X), input().split()))
x_min=min(x)
g_min=1000000000000
for i in x:
  g=fractions.gcd(x_min,i)
  if g < g_min:
    g_min = g
print(g)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

def lcm(a,b):
    return a*b//math.gcd(a,b)

if __name__ == "__main__":
    n,x = map(int,input().split())
    X = list(map(int,input().split()))
    X.sort()
    a = bisect.bisect_left(X,x)
    X.insert(a,x)
    ans = []
    for i in range(1,len(X)):
        diff = X[i] - X[i-1]
        ans.append(diff)
    print(min(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
from fractions import gcd
n,x=map(int,input().split())
xl=list(map(int,input().split()))

xl.append(x)


p=min(xl)
for i in range(n):
    ans=gcd(xl[i]-p,x-p)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,x=map(int, input().split())
    l=list(map(int,input().split()))
    if n==1:
        print(l[0]-x)
    else:
        l.append(x)
        l.sort()
        S=[]
        for i in range(n):
            S.append(l[i+1]-l[i])
        from functools import reduce
        from fractions import gcd
        print(reduce(gcd,S))
resolve()

Submission status: Wrong Answer

Solution code:
import fractions
def GCD(a):
    gcd = a[0]
    N = len(a)
    for i in range(1, N):
        gcd = fractions.gcd(gcd, a[i])
    return gcd

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

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

x.append(X)
x.sort()

ans = float("inf")
d = []
for i in range(N-1):
    d.append(x[i+1] - x[i])

ans = GCD(d)
print(ans)

Submission status: Wrong Answer

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

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

x.append(X)
x.sort()

ans = float("inf")
for i in range(N-1):
    ans = min(ans, x[i+1] - x[i])

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate


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


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

A.sort()
d = [y - x for x, y in zip(A[:-1], A[1:])]
g = list(accumulate(d, func=GCD))[-1]

ans = g
for a in A:
    ans = max(ans, GCD(g, abs(X - a)))
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
n,x=map(int,input().split())
x_list=list(map(int,input().split()))
x_list.append(x)

x_list.sort()
x_sa=[]
a=x_list[1]-x_list[0]
for i in range(1,n-1):
  b=x_list[i+1]-x_list[i]
  a=fractions.gcd(a,b)
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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

print(gcd(*L))

Submission status: Wrong Answer

Solution code:
# C - Skip

import numpy as np
import fractions

N, X = map(int, input().split())
x = list(int(x) for x in input().split())
x.append(X)
x.sort()
x = np.array(x)
x = x - x[0]

ans = 10**18
if N == 1:
    print(x[1] - x[0])
else:
    for i in range(N):
        ans = fractions.gcd(ans, fractions.gcd(x[i], x[i+1]))
    print(ans)

Submission status: Wrong Answer

Solution code:
# C - Skip

import numpy as np
import fractions

N, X = map(int, input().split())
x = list(int(x) for x in input().split())
x.append(X)
x.sort()
x = np.array(x)
x = x - x[0]

ans = 10**18
if N == 1:
    print(x[1] - x[0])
else:
    for i in range(N-1):
        ans = min(ans, fractions.gcd(x[i], x[i+1]))
    print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,x=map(int,input().split())
a=list(map(int,input().split()))
M=max(a)-x
m=x-min(a)
D=gcd(M,m)
print(abs(D))

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
m = x[-1]

for i in range(1,N+1):
    if x[i]-x[i-1] < m:
        m = x[i]-x[i-1]

print(m)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,x = map(int,input().split())
l = list(map(int,input().split()))
l.append(x)
l.sort()
skyks = l[1]-l[0]
for i in range(1,n-1):
    y = l[i+1]-l[i]
    skyks = gcd(skyks,y)
print(skyks)

Submission status: Wrong Answer

Solution code:
import functools
import numpy as np

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

x.append(X)
x = np.array(x)
min_x = np.array([min(x) for _ in range(n+1)])
x = (x - min_x)


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


if n > 1:
    if x[0] == 0:
        ans = euclid(x[1], x[2])
    elif x[1] == 0:
        ans = euclid(x[0], x[2])
    else:
        ans = euclid(x[0], x[1])

    for xi in x[2:]:
        if xi != 0:
            ans = euclid(ans, xi)
        if ans == 1:
            break

else:
    ans = x[0]

print(ans)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split()) #n都市xスタート座標
a=list(map(int,input().split()))
import fractions
for i in range(n):
    a[i]=a[i]-x
ans=a[0]
for i in range(1,n-1):
    ans=fractions.gcd(ans,a[i])
print(abs(ans))

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split()) #n都市xスタート座標
a=list(map(int,input().split()))
import fractions
if n==1:
    print(a[0]-x)
    quit()
p=[]
for i in range(1,n):
    p.append(a[i]-a[i-1])
if len(p)==1:
    ans=1
else:
    ans=p[0]
for i in range(1,n-1):
    ans=fractions.gcd(ans,p[i])
print(abs(ans))

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split()) #n都市xスタート座標
a=list(map(int,input().split()))
if n==1:
    print(a[0]-x)
    quit()
import fractions
p=[]
for i in range(1,n):
    p.append(a[i]-a[i-1])
ans=p[0]
for i in range(1,n-1):
    ans=fractions.gcd(ans,p[i])
print(abs(ans))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append(abs(l[i]-x))
g=0
for i in range(n-1):
  g=gcd(g,gcd(a[i],a[i+1]))
print(g)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append(abs(l[i]-x))
g=0
for i in range(n-1):
  g=gcd(a[i],a[i+1])
print(g)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
li = list(map(int, input().split()))
li.append(X)
li.sort()
min_step = max(li)
for i in range(N):
    min_step = min(min_step, li[i + 1] - li[i])

print(min_step)

Submission status: Wrong Answer

Solution code:
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
a.sort()
f = min([a[i+1]-a[i] for i in range(n)])
print(f)

Submission status: Wrong Answer

Solution code:
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
a.sort()
print(min([abs(a[i]-a[i+1]) for i in range(n)]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, s = map(int, input().split())
x = sorted(list(map(int, input().split()))+[s])
print(x)
ans = x[1] - x[0]
for i in range(1, n):
    ans = min(ans, x[i] - x[i - 1])
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,X = map(int,input().split())
l =  list(map(int,input().split()))
l.sort(reverse = True)
ans = 10**10
yakusuu = []
count= 0
if n == 1:
  print(l[0]-X)
  exit()
  
for i in l:
  kouho = i-X
  ans = min(ans,abs(i-X))
  if i-X < 0:
    break

for i in range(1,ans+1):
  if ans%i == 0:
    yakusuu.append(i)
    
yakusuu.reverse()

for i in yakusuu:
  for j in range(n-1):
    if (l[j]-l[j+1])%i != 0:
      break
    elif (l[j]-l[j+1])%i == 0:
      count += 1
      if count == len(l) - 1:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import functools
n, x = map(int,input().split())
place = list(map(int,input().split()))
place.append(x)
place.sort()
if n == 1:
    print(place[1] - place[0])
    exit()

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

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

def gcd(nums):
    return functools.reduce(euclid, nums)

print(gcd(k))

Submission status: Wrong Answer

Solution code:
n,x = map(int,input().split())
l = list(map(int,input().split()))
l.append(x)
l.sort()
d = [0]*n
for i in range(n):
  d[i] = l[i+1] - l[i]
print(min(d))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()
ans=x[1]-x[0]
if n>1:
    for i in range(2,n):
        ans=gcd(ans,x[i]-x[i-1])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

minX = 10 ** 19

for x in range(N):
    minX = min(abs(a[x] - X), minX)
    if x != N - 1:
        minX = min(a[x + 1] - a[x], minX)

print(minX)

Submission status: Wrong Answer

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

minX = 10 ** 19

for x in range(N):
    minX = min(abs(a[x] - X), minX)
print(minX)

Submission status: Wrong Answer

Solution code:
import sys
n, X = map(int, sys.stdin.buffer.readline().split())
x = list(map(int, sys.stdin.buffer.readline().split()))
x.append(X)
x.sort()
ans = 10**12
for i in range(n):
    tmp = x[i+1] - x[i]
    if tmp < ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N, X = map(int, sys.stdin.buffer.readline().split())
x = list(map(int, sys.stdin.buffer.readline().split()))
x.append(X)
x.sort()
ans = 10**10
for i in range(N):
    tmp = x[i+1] - x[i]
    if tmp < ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N, X = map(int, sys.stdin.buffer.readline().split())
x = list(map(int, sys.stdin.buffer.readline().split()))
x.append(X)
x.sort()
ans = 10**10
for i in range(N-1):
    tmp = x[i+1] - x[i]
    if tmp < ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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

x.append(x0)
x.sort()
dis=[]
for i in range(1,n):
    dis.append(x[i]-x[i-1])

def gcd(number_list):
    return reduce(fractions.gcd, number_list)

print(gcd(dis))

Submission status: Wrong Answer

Solution code:
import math
n,x = map(int,input().split())
X = list(map(int,input().split()))
X = list(map(lambda a:abs(a-x),X))
X_small = min(X)
res = list(map(lambda a:0 if a%X_small==0 else 1,X))
if sum(res) == 0:
    print(X_small)
else:
    print(1)

Submission status: Wrong Answer

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

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

near = 1001001001

for i in range(n):
    dis = abs(X-x[i])
    near = min(near, dis)

print(near)

Submission status: Wrong Answer

Solution code:
import bisect
n,x=map(int,input().split())
lst=list(map(int,input().split()))
lst.append(-1000000000)
lst.sort()
lst.append(1000000001)
ind=bisect.bisect_right(lst, x)
print(min(x-lst[ind-1], lst[ind]-x))

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
lst=list(map(int,input().split()))
dis=1000000000
for i in range(n):
  if abs(lst[i]-x)<dis:
    dis=abs(lst[i]-x)
print(dis)

Submission status: Wrong Answer

Solution code:
import sys, fractions

N, X = map(int, input().split())
x = list(map(int, sys.stdin.readline().rsplit()))

res = 0
for i in range(N):
    res = fractions.gcd(res, abs(x[i] - X))

Submission status: Wrong Answer

Solution code:
import fractions
n, x_start = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 0

for i in range(n):
    x[i] = int(abs(x[i] - x_start))

if x_start == 1:
    ans = x[i]
else:
    for i in range(n-1):
        ans = fractions.gcd(x[i], x[i+1])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


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


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

X = np.array([X])
x = np.concatenate([x, X])
x.sort()

ans = x[0]
for i in x:
    ans = gcd(ans, i)

print(ans)

Submission status: Wrong Answer

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

xlist = list(map(int, input().split()))
import fractions

ans = xlist[0]
for i in xlist[1:]:
    ans = fractions.gcd(ans, i)

print(ans)

Submission status: Wrong Answer

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

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

dis = list(map(lambda f: abs(f-x), xlist))
print(min(dis))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,x = map(int,input().split())
L = [abs(n-x) for n in map(int,input().split())]
ans = L[0]
for i in L[1:]:
    ans = gcd(ans,i)
    if ans == 1:
        print(1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))

ans=0
l=[]
for j in range(a):
    l.append(abs(b-i[j]))
for k in range(1,a):
    if k==1:
        ans=fractions.gcd(l[1],l[0])
    else:
        ans=fractions.gcd(ans,l[k])
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))

ans=0
l=[]
for j in range(a):
    l.append(abs(b-i[j]))
for k in range(1,a):
    if k==1:
        ans=abs(l[1]-l[0])
    else:
        ans=fractions.gcd(ans,abs(l[k]-l[k-1]))
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))
i.append(b)
ans=0
l=[]
for j in range(1,a+1):
    l.append(abs(i[j]-i[j-1]))
for k in range(1,a):
    if k==1:
        ans=abs(l[1]-l[0])
    else:
        ans=fractions.gcd(ans,abs(l[k]-l[k-1]))
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))
i.append(b)
ans=0
l=[]
for j in range(1,a+1):
    l.append(abs(i[j]-i[j-1]))
for k in range(1,a):
    if k==1:
        ans=l[1]-l[0]
    else:
        ans=fractions.gcd(ans,abs(l[k]-l[k-1]))
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))
i.append(b)
ans=0
l=[]
for j in range(1,a+1):
    l.append(abs(i[j]-i[j-1]))
for k in range(1,a):
    if k==1:
        ans=l[1]-l[0]
    else:
        ans=fractions.gcd(ans,l[k]-l[k-1])
print(ans)

Submission status: Wrong Answer

Solution code:
n, start = map(int, input().split())
x = list(map(int, input().split()))
if start not in x:
    x.append(start)
    x.sort()
else:
    x.sort()
distance = []
distance_start = []
for i in range(len(x)-1):
    dis = x[i+1] - x[i]
    distance.append(dis)
    if x[i+1] == start:
        distance_start.append(dis)
    if x[i] == start:
        distance_start.append(dis)

D = max(1, min(distance_start))
for i in distance:
    if i % D == 0:
        continue
    else:
        D = 1
        break
print(D)

Submission status: Wrong Answer

Solution code:
n, start = map(int, input().split())
x = list(map(int, input().split()))
if start not in x:
    x.append(start)
    x.sort()
else:
    x.sort()
distance = []
distance_start = []
for i in range(n):
    dis = x[i+1] - x[i]
    distance.append(dis)
    if x[i+1] == start:
        distance_start.append(dis)
    if x[i] == start:
        distance_start.append(dis)

D = max(1, min(distance_start))
for i in distance:
    if i % D == 0:
        continue
    else:
        D = 1
        break
print(D)

Submission status: Wrong Answer

Solution code:
import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(list(itertools.accumulate(X,func = fractions.gcd))[-1])

Submission status: Wrong Answer

Solution code:
from functools import reduce
from math import gcd

n, x = map(int, input().split())
a = [abs(int(A) - x) for A in input().split()]
a.sort()
print(a)
print(reduce(gcd, a))

Submission status: Wrong Answer

Solution code:
import fractions

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

if N == 1:
    print(x[0])
else:
    for i in range(N-1):
        dx.append(x[i+1]-x[i])
    ans = dx[0]
    for i in dx[1:]:
        ans = fractions.gcd(ans,i)
    print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

if N == 1:
    print(x[0])
else:
    for i in range(N-1):
        dx.append(x[i+1]-x[i])
    ans = max(dx)
    for i in dx:
        ans = fractions.gcd(ans,i)
    print(ans)

Submission status: Wrong Answer

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

i = bisect.bisect_left(x, X)
if i == 0:
    print(abs(x[i]-x[i+1]))
elif i == N:
    print(abs(x[i-1]-x[i]))
else:
    print(min(abs(x[i-1]-x[i]), abs(x[i]-x[i+1])))

Submission status: Wrong Answer

Solution code:
#import math
import fractions
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
xmod = list(map(lambda y:abs(int(y)-x),input().split()))
#print(xmod)
num = xmod[0]
for i in xmod:
    gcd = fractions.gcd(num,i)

print(gcd)

Submission status: Wrong Answer

Solution code:
#import math
import fractions
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
xmod = list(map(lambda y:int(y)-x,input().split()))
#print(xmod)
num = xmod[0]
for i in xmod:
    gcd = fractions.gcd(num,i)

print(abs(gcd))

Submission status: Wrong Answer

Solution code:
#import math
import fractions
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
xmod = list(map(lambda y:int(y)-x,input().split()))
#print(xmod)
num = xmod[0]
for i in xmod:
    gcd = fractions.gcd(num,i)

print(gcd)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
import numpy as np
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X0 = lr()
X = np.array(lr())
Xdiff = (X-X0).tolist()
g = Xdiff[0]
for i in range(1, N):
    g = gcd(g, Xdiff[i])

answer = g
print(answer)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
import numpy as np
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X0 = lr()
X = np.array(lr())
Xdiff = (X-X0).tolist()
g = Xdiff[0]
for i in range(1, N):
    g = gcd(g, Xdiff[1])

answer = g
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions
from functools import reduce

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

N, X = map(int, input().split())
x = np.array(list(map(int, input().split())))
if N == 1:
    print(np.abs(x[0] - X))
else:
    x = np.abs(x - X)
    print(min(gcd(x)))

Submission status: Wrong Answer

Solution code:
import bisect
import fractions

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

s.sort()
index = bisect.bisect_left(s,x)

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

ans = 10**9
for i in range(len(s)-1):
    tmp = abs(s[i+1] - s[i])
    if tmp%2 != 0:
        print(1)
        exit()
    ans = min(ans,fractions.gcd(tmp,abs(x-s[i])))
    
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import fractions

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

s.sort()
index = bisect.bisect_left(s,x)
s.insert(index,x)

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

ans = 0
for i in range(len(s)):
    tmp = abs(x - s[i])
    if tmp%2 != 0:
        print(1)
        exit()
    ans = fractions.gcd(tmp,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import fractions

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

s.sort()
index = bisect.bisect_left(s,x)
s.insert(index,x)

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

ans = 0
for i in range(len(s)-1):
    tmp = s[i+1] - s[i]
    if tmp%2 != 0:
        print(1)
        exit()
    ans = fractions.gcd(tmp,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

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

s.sort()
index = bisect.bisect_left(s,x)
if index == 0:
    ans = abs(s[0] - x)
elif index == len(s):
    ans = abs(s[-1] - x)
else:
    s.insert(index,x)
    ans = min(abs(s[index] - s[index-1]), abs(s[index] -s[index+1]))
    
print(ans)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort(reverse=True)

mx = 0
for i in range(1, N+1):
    diff = abs(x[i-1] - x[i])
    if diff < mx:
        mx = diff
    else:
        mx = max(diff, mx)
print(mx)

Submission status: Wrong Answer

Solution code:
import fractions
N,X=[int(s) for s in input().split()]
ls=[int(s)-X for s in input().split()]
a=0
for e in ls:
  a=fractions.gcd(a,e)
print(a)

Submission status: Wrong Answer

Solution code:
import fractions

N, X = map(int, input().split(" "))
X = [X]
X.extend(map(int, input().split(" ")))
X.sort()
ans = X[1] - X[0]
for i in range(1, N - 1):
    ans = fractions.gcd(ans, X[i + 1] - X[i])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
from fractions import gcd
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, X = il()
    T = il()
    T = sorted(T + [X])
    ret = abs(T[0] - T[1])
    for i in range(len(T)-1):
        ret = gcd(ret, T[i]-T[i+1])
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,x = map(int,input().split())
c = list(map(int,input().split()))
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
c.append(x)
c.sort()
g = c[1]-c[0]
for i in range(1,n-1):
    g = gcd(g,c[i+1]-c[i])
print(g)

Submission status: Wrong Answer

Solution code:
import fractions

n,x=list(map(int,input().split()))
X=list(map(int,input().split()))
X.append(x)
X=sorted(X)
Y=[X[i+1]-X[i] for i in range(n)]

if n==1:
  print(max(X)-x)
else:
  gcd=fractions.gcd(Y[0],Y[1])
  for i in range(2,n):
    gcd=fractions.gcd(gcd,Y[i])
  print(gcd)