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, M = map(int, input().split())
X = sorted(map(int, input().split()))

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

ans = X[1] - X[0]
for i in range(N-1):
    ans = gcd(ans, X[i+1] - X[i])

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import fractions

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


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


N, X = map(int, input().split())
x = list(map(int, input().split()))
dif = [abs(X - x[0])]

if N > 1:
    for i in range(N - 1):
        dif.append(x[i + 1] - x[i])
print(gcd_list(dif))

Submission status: Wrong Answer

Solution code:
def myAnswer(N:int,X:int,x:list) -> int:
   ans = -1
   for a in x:
      tmp = abs(X - a)
      if(ans == -1):
         ans = tmp
      elif(max(tmp,ans) % min(tmp,ans) == 0):
         ans = min(ans,tmp)
      else:
         ans = 1
         break
   return ans

def modelAnswer():
   return
def main():
   N,X = map(int,input().split())
   x = list(map(int,input().split()))
   print(myAnswer(N,X,x[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
def myAnswer(N:int,X:int,x:list) -> int:
   ans = 10**10
   for a in x:
      ans = min(ans,abs(X-a))
   return ans

def modelAnswer():
   return
def main():
   N,X = map(int,input().split())
   x = list(map(int,input().split()))
   print(myAnswer(N,X,x[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.append(x)
a.sort()

mi = max(a)
for i in range(1,len(a)):
  if a[i] - a[i-1] < mi:
    mi = a[i] - a[i-1]

print(mi)

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,X = map(int,input().split())
arrA = list(map(int,input().split()))
arrA.append(X)
arrA.sort()
ans = 10**9
for i in range(len(arrA)-1):
    ans = min(ans,arrA[i+1]-arrA[i])
    
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Wrong Answer

Solution code:
import fractions

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

minimum = x[0]
for i in range(len(x)):
    x[i] = x[i] - X
    minimum = min(x[i], minimum)
# print(x, minimum)

gcd_value = fractions.gcd(x[0], x[0])
for i in range(len(x)):
    gcd_value = fractions.gcd(gcd_value, x[i])
    # print(gcd)
print(gcd_value)

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
xlis = list(map(int, input().split()))
d = float('inf')
for i in xlis:
    d = min(d, abs(x-i))
print(d)

Submission status: Wrong Answer

Solution code:
import fractions
n,x = map(int,input().split())
s = set(map(int,input().split()))
s.add(x)
l = list(s)
l.sort()
t = set([])
for i in range(len(l)-1):
  t.add(l[i+1]-l[i])
u = list(t)
if len(u) == 1:
  print(u[0])
  exit()
y = fractions.gcd(u[0],u[1])
if len(u) == 2:
  print(y)
  exit()
else:
  for i in range(1,len(u)-1):
    y = fractions.gcd(y,l[i+1])
  print(y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,x=map(int,input().split())
    X=[int(_) for _ in input().split()]
    X.append(x)
    X.sort()
    XX=[0]*n
    for i in range(n):
        XX[i]=X[i+1]-X[i]
    print(min(XX))

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

x.append(y)
x.sort()
d = []
for i in range(n):
    d.append(x[i+1]-x[i])
ans = d[0]
for i in range(n-1):
    ans = fractions.gcd(ans,d[i])
print(ans)

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,x = readInts()
    X = readInts()
    sa = float('inf')
    for i in range(n):
        sa = min(sa,abs(x-X[i]))
    print(sa)



if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

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

from fractions import gcd
GCD=gcd(abs(B[0]),abs(B[1]))
#print(B)
if N>2:
  for i in range(2,N):
    GCD=gcd(GCD, abs(B[i]))
  
print(GCD)

Submission status: Wrong Answer

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

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

from fractions import gcd
GCD=gcd(B[0],B[1])
#print(B)
if N>2:
  for i in range(2,N):
    GCD=gcd(GCD, abs(B[i]))
  
print(GCD)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
diff = []
for i in range(0, N - 1):
    diff.append(x[i + 1] - x[i])

if diff:
    ans = gcd_list(diff)
else:
    ans = x[0] - 1

print(ans)

Submission status: Wrong Answer

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

A=[abs(int(i)-x) for i in input().split()]
print(min(A))

Submission status: Wrong Answer

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

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

d = min(x)
for i in range(d, 0, -1):
    for c in x:
        ok = False
        if c % i == 0:
            ok = True
    if ok:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

ans = x[0] - X
for i in range(1, N):
    ans = gcd(ans, x[i] - X)

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, X = (int(i) for i in input().split())
    A = [int(i) for i in input().split()] + [X]
    A.sort()
    diff = [A[i+1] - A[i] for i in range(N)]
    from collections import Counter
    c = Counter([d % 2 for d in diff])
    if c[0] > 0 and c[1] > 0:
        print(1)
    else:
        print(min(diff))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

import fractions
#import math
from functools import reduce

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

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

print(gcd_list(l))

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
if len(W) == 2:
  print(W[1]-W[0])
  exit()
for i in range(1,N+1):
  dist = min(dist, W[i]-W[i-1])
  while (W[i]-W[i-1])%dist != 0:
    dist //= 2
  if dist == 1:
    break
print(dist)

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
print(W)
if len(W) == 2:
  print(W[1]-W[0])
  exit()
for i in range(1,N+1):
  dist = min(dist, W[i]-W[i-1])
  while (W[i]-W[i-1])%dist != 0:
    dist //= 2
  if dist == 1:
    break
print(dist)

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
if len(W) == 2:
  print(W[1]-W[0])
  exit()
for i in range(1,N):
  dist = min(dist, W[i]-W[i-1])
for j in range(1,N):
  while (W[i]-W[i-1])%dist != 0:
    dist -= 1
print(dist)

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
if len(W) == 2:
  print(W[1]-W[0])
  exit()
for i in range(1,N):
  dist = min(dist, W[i]-W[i-1])
for j in range(1,N):
  if (W[i]-W[i-1])%dist != 0:
    dist -= 1
print(dist)

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
if len(W) == 2:
  print(W[1]-W[0])
  exit()
for i in range(1,N):
  dist = min(dist, W[i]-W[i-1])
print(dist)

Submission status: Wrong Answer

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

print(W[1]-W[0])

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def func(a):
  global k,x,d
  k += 1
  if k == 1:
    d = abs(int(a)-x)
    return abs(int(a)-x)
  else:
    return gcd(d,abs(int(a)-x))
n,x =map(int,input().split())
k = 0
d = 0
xlist = list(map(func,input().split()))
print(xlist[n-1])

Submission status: Wrong Answer

Solution code:
n, k  = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = max(x)
for i in range(n):
    if abs(x[i]-k) < ans:
        ans = abs(x[i]-k)

print(ans)

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
Alist = list(map(int,input().split()))
for i in range(len(Alist)):
    Alist[i] = abs(Alist[i]-X)
Alist.sort()
p = []
q = 1
for i in range(1,len(Alist)):
    if Alist[i] % Alist[0] != 0:
        p.append(Alist[i] % Alist[0])
        q = q*0
p.sort()
r = 1
if p != []:
    for i in range(0,len(Alist)):
        if Alist[i] % p[0] != 0:
            r = r*0
if len(Alist) > 1:
    if q == 0 and r == 1:
        print(p[0])
    if q == 0 and r == 0:
        print(1)
    if q == 1:
        print(Alist[0])
else:
    print(Alist[0])

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
Alist = list(map(int,input().split()))
for i in range(len(Alist)):
    Alist[i] = abs(Alist[i]-X)
Alist.sort()
p = 10**10
q = 1
for i in range(1,len(Alist)):
    if Alist[i] % Alist[0] != 0:
        p = min(p,Alist[i] % Alist[0])
        q = q*0
if len(Alist) > 1:
    if q == 0:
        print(p)
    else:
        print(Alist[0])
else:
    print(Alist[0])

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
Alist = list(map(int,input().split()))
for i in range(len(Alist)):
    Alist[i] = abs(Alist[i]-X)
Alist.sort()
p = 1
for i in range(1,len(Alist)):
    if Alist[i] % Alist[0] != 0:
        p = p*0
if len(Alist) > 1:
    if p == 0:
        print(1)
    else:
        print(Alist[0])
else:
    print(Alist[0])

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

input = sys.stdin.readline

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

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

x.append(X)
x.sort()
diff = []
ans = []

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

for i in range(N-1):
    ans.append(gcd(diff[i], diff[i+1]))

print(diff)
print(min(ans))

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
Alist = list(map(int,input().split()))
for i in range(len(Alist)):
    Alist[i] = abs(Alist[i]-X)
Alist.sort()
p = 1
for i in range(1,len(Alist)):
    if Alist[i] % Alist[0] == 0:
        p = p*0
if len(Alist) > 1:
    if p == 0:
        print(Alist[0])
    else:
        print(1)
else:
    print(Alist[0])

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
def lcm(a,b):
    if b==0:
        return a 
    return lcm(b,a%b)
ans=0

for i in range(n-1):
    sa=x[i+1]-x[i]
    ans=lcm(sa,ans)
print(ans)

Submission status: Wrong Answer

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

print(min(list(map(lambda x: abs(x-X),sorted(x)))))

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    if b==0: return a
    else: return gcd(b, a%b)
n, x = map(int, input().split())
L = list(map(int, input().split()))
d = 100
for l in L:
    d = gcd(d, abs(x-l))
print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    print(a[0]-x)
    exit()
def gcd(m,n):
    x,y=max(m,n),min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
b=[]
for i in range(n):
    b.append(a[i]-x)
c=gcd(b[0],b[1])
for i in range(n-2):
    c=gcd(c,b[i+2])
print(abs(c))

Submission status: Wrong Answer

Solution code:
import numpy as np
n,x=map(int,input().split())
p=list(map(int,input().split()))
p.append(x)
p.sort()
p=np.array(p)
p=abs(p-x)
p1=np.array(abs(p[1:]-p[:-1]))
print(min(p1))

Submission status: Wrong Answer

Solution code:
import numpy as np
n,x=map(int,input().split())
p=list(map(int,input().split()))
p.append(x)
p.sort()
p=np.array(p)
p=p-x
p1=np.array(p[1:]-p[:-1])
print(min(p1))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import sys

N, X = map(int, input().split())
x = list(map(int, input().split()))
if N == 1:
    print(abs(x[0] - X))
    sys.exit()
x.append(X)
x.sort()
dif_list = list()
for i in range(N - 1):
    dif_list.append(x[i + 1] - x[i])
dif_set = list(set(dif_list))
if len(dif_set) == 1:
    print(dif_set[0])
    sys.exit()
ans = 1000000000
for i in range(len(dif_set) - 1):
    tmp = gcd(dif_set[i], dif_set[i + 1])
    if tmp < ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
n,X= list(map(int, input().split()))
x= list(map(int, input().split()))
x.append(X)
x.sort()
init=x.pop(0)
li=[]
for i in x:
    li.append(i-init)
    init=i
li.sort()
flag=0
mini=li[0]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors

for i in make_divisors(mini):
    if flag==0:
        for j in li:
            if flag==0:
                ans=i
                flag=1
                if j%i!=0:
                    flag=0
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import sys

N, X = map(int, input().split())
x = list(map(int, input().split()))
if N == 1:
    print(abs(x[0] - X))
    sys.exit()
x.append(X)
x.sort()
dif = list()
for i in range(N - 1):
    dif.append(x[i + 1] - x[i])
print(gcd(min(dif), max(dif)))

Submission status: Wrong Answer

Solution code:

from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce

from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n, X = map(int, readline().split())
  x = np.array(readline().split(), dtype='int64')
  x -= X
  ans = reduce(gcd, x)
  print(ans)
  
  
  
  
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import sys

N, X = map(int, input().split())
x = list(map(int, input().split()))
if N == 1:
    print(abs(x[0] - X))
    sys.exit()
x = list(map(lambda y: y - X, x))
x.append(0)
x.sort()
dif = list()
for i in range(N - 1):
    dif.append(x[i + 1] - x[i])
print(gcd(min(dif), max(dif)))

Submission status: Wrong Answer

Solution code:
n,X= list(map(int, input().split()))
x= list(map(int, input().split()))
x.append(X)
x.sort()
init=x.pop(0)
li=[]
for i in x:
    li.append(i-init)
    init=i
li.sort()
flag=0
mini=li[0]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors

for i in make_divisors(mini):
    if flag==0:
        for j in li:
            ans=i
            flag=1
            if j%i!=0:
                flag=0
print(ans)

Submission status: Wrong Answer

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


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

if N == 1:
    print(abs(X-xl[0]))
    exit(0)

if not(X in xl):
    xl.append(X)
    xl.sort()

k = []
for i in range(1, N):
    tmp = xl[i]-xl[i-1]
    if not(tmp in k):
        k.append(tmp)

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

Submission status: Wrong Answer

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


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

if N == 1:
    print(abs(X-xl[0]))
    exit(0)

xl.append(X)
xl.sort()

k = []
for i in range(1, N):
    tmp = xl[i]-xl[i-1]
    if not(tmp in k):
        k.append(tmp)

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

Submission status: Wrong Answer

Solution code:
from math import sqrt


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    divisors.sort(reverse=True)
    return divisors


if __name__ == "__main__":
    n, start = map(int, input().split())
    x = list(map(int, input().split()))

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

    # まずx[0]の約数を列挙する
    div = Calc_Divisors(x[0])

    # 大きい約数から順に割っていき、割れなかったら消す
    for i in range(n):
        for d in div:
            if x[i] % d != 0:
                div.remove(d)

    print(div[0])

Submission status: Wrong Answer

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

ans = 10 ** 9
for i in range(N):
 if abs(X - x[i]) < ans:
   ans = abs(X- x[i])
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,x = map(int,input().split())
X = list(map(int,input().split()))
X.append(x)
X.sort()
def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)

pro = X[1]-X[0]

for i in range(n-1):
  pro = gcd(abs(X[i+1]-X[i]),pro)
print(pro)

Submission status: Wrong Answer

Solution code:
n, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
a = n
for i in range(n):
    if X < x[i]:
        a = i
        break
if 0 < a < n:
    ans = min(X-x[a-1],x[a]-X)
elif a == 0:
    ans = x[a] - X
else:
    ans = X - x[a-1]
print(ans)

Submission status: Wrong Answer

Solution code:
N,s=map(int, input().split())
*X,=map(int, input().split())
X.sort()
X = [s] + X

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

g=0
for i in range(N):
    g = gcd(g, X[i+1]-X[i])
print(g)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,X = LI()
x = LI()
ans = inf
for i in x:
    ans = min(ans, abs(i-X))
print(ans)

Submission status: Wrong Answer

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

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

x.sort()
import numpy as np
x = np.array(x)
x -= X
print(gcd(*x))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n, x = tuple(map(int, input().split(' ')))
d = 0
l = list(map(int, input().split(' ')))
for i in range(n):
  s = l[i]
  if i == 0:
    d = s - x
  else:
    d = gcd(d, s-x)
print(d)

Submission status: Wrong Answer

Solution code:
def main():
    import fractions
    n, x, *l = map(int, open(0).read().split())
    a = list(map(lambda i: abs(i-x), l))
    if n == 1:
      print(abs(x-l[0]))
      exit()
    a.sort()
    i, j = a[0], a[1]
    k = fractions.gcd(i, j)
    print(k)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
if len(x_list) >= 3:
  a = []
  for i in range(1,n+1):
    a.append(x_list[i] - x_list[i-1])
  a = sorted(a)
  c = [a[1],a[0]]
  while c[0]%c[1] != 0:
    c.append(c[0]%c[1])
    c.pop(0)
  else:
    print(c[1])
else:
  print(x_list[1]-x_list[0])

Submission status: Wrong Answer

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

if len(x_list) >= 3:
  c = [x_list[2] - x_list[1],x_list[1] - x_list[0]]
  while c[0]%c[1] != 0:
    c.append(c[0]%c[1])
    c.pop(0)
  else:
    print(c[1])
else:
  print(x_list[1]-x_list[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
c = [abs(x-int(i)) for i in input().split()]
c.sort()
c_ = c[0]
for ci in c[1:]:
    if ci % c_ != 0:
        print(1)
        exit()
print(c[0])

Submission status: Wrong Answer

Solution code:
import copy
from fractions import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))
z=copy.deepcopy(x)+[X]
z.sort()

if N>1:
  y=[0]*N
  for i in range(N):
    y[i] = z[i+1]-z[i]
  ans=y[0]
  for j in range(N):
    ans = gcd(z[j],ans)
  print(ans)
else:
  print(abs(X-x[0]))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))
z=x+[X]
z.sort()

if N>1:
  y=[0]*N
  for i in range(N):
    y[i] = z[i+1]-z[i]
  ans=y[0]
  for j in range(N):
    ans = gcd(z[j],ans)
  print(ans)
else:
  print(abs(X-x[0]))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))+[X]
x.sort()

if N>1:
  y=[0]*N
  for i in range(N):
    y[i] = x[i+1]-x[i]
  ans=y[0]
  for j in range(N):
    ans = gcd(y[j],ans)
  print(ans)
else:
  print(abs(X-x[0]))

Submission status: Wrong Answer

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

if N>1:
  y=[0]*(N-1)
  for i in range(N-1):
    y[i] = x[i+1]-x[i]
  ans=y[0]
  for j in range(N-1):
    ans = gcd(y[j],ans)
  print(ans)
else:
  print(abs(X-x[0]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, x = MAP()
xx = LIST()
xx = [xx[i] - x for i in range(n)]
d = xx[0]
for i in range(1, n):
    d = gcd(d, abs(xx[i]))
print(d)

Submission status: Wrong Answer

Solution code:
from collections import deque

n,X = map(int,input().split())
x = list(map(int,input().split()))
y = sorted(x)
y1 = y[0] - X
if n == 1:
	print(abs(X-x[0]))
	exit()
def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b,a%b)
for i in range(n):
	y[i] = y[i] - X - y1

li = gcd(y[0],y[1])
i = 1
d = deque()
d1 = deque()
while i * i <= li:
	if li%i == 0:
		d.append(i)
		d1.appendleft(li//i)
	i += 1
d.extend(d1)
#print(d)
for i in range(2,n):
	while y[i]%d[-1] != 0:
		d.pop()
	if d[-1] == 1:
		break	



print(d[-1])
#print(y)

Submission status: Wrong Answer

Solution code:
import fractions

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

ma=abs(x-max(x2))
mi=abs(x-min(x2))

print(fractions.gcd(ma,mi))

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
x2=list(map(int,input().split()))
li=[abs(x-x2[i]) for i in range(n)]

print(min(li))

Submission status: Wrong Answer

Solution code:
N,X=map(int,input().split())
L=list(map(int,input().split()))
L.append(X)
LS=sorted(L,reverse=True)
ans=1000000000
for i in range(N):
  tmp=LS[i]-LS[i+1]
  ans=min(ans,tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
def euclid(x, y):
    if(y != 0):
        tmp = y
        y = x % tmp
        x = tmp
        return euclid(x,y)
    else:
        return x
    
def main():
    N, X = map(int, input().split())
    x= list(map(int, input().split()))
    
    D = 10**10
    if(X > 1):
        for i in range(1, N):
            D = min(D, euclid(abs(x[i]-X), abs(x[i-1]-X)))     
        print(D)
    else:
        D = abs(x[0]-X)
        print(D)
main()

Submission status: Wrong Answer

Solution code:
def main():
    N, X = map(int, input().split())
    x= list(map(int, input().split()))
    
    D = 10**10
    for i in range(N):
        D = min(D, abs(x[i]-X))    
    print(D)
    
main()

Submission status: Wrong Answer

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


def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    x.append(X)
    x.sort()
    x_min = float("inf")

    for i in range(1, N + 1):
        x_min = min(x_min, x[i] - x[i - 1])
    print(x_min)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
N,X = map(int,input().split())
L = [el for el in map(int,input().split())]
L.append(X)
L.sort()
q = 0
if N == 1:
  print(L[0]-X)
  sys.exit(0)
for p in range(L[0]+1,0,-1):
  q = 0
  for j in range(0,len(L)):
    if L[j] % p != L[0] % p:
      q = 1
      break
  if q == 0:
    print(p)
    break

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()))
kari=[]
for i in range(N):
    kari.append(abs(x[i]-X))
K=min(kari)
if K == 0:
    kari.pop(K)
for i in range(N):
    ans=gcd(K,kari[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()))
kari=[]
for i in range(N):
    kari.append(abs(x[i]-X))
K=min(kari)
for i in range(N):
    ans=gcd(K,kari[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()))
kari=[]
for i in range(N):
    kari.append(abs(x[i]-X))

for i in range(N):
    ans=gcd(min(kari),kari[i])
print(ans)