TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

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

    for i in range(1,N):
        gcd_l.append(abs(x[i-1]-x[i]))
    if N==1:
        ans = gcd_l[0]
    else:
        a = [gcd_l[0],gcd_l[1]]
        ans = gcd(max(a),min(a))
        for n in range(2,len(gcd_l)):
            a = [ans,gcd_l[n]]
            ans = gcd(max(a),min(a))
    print(ans)

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

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

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

    for i in range(1,N):
        gcd_l.append(abs(x[i-1]-x[i]))
    if N==1:
        ans = gcd_l[0]
    else:
        for n in range(1,len(gcd_l)):
            a = [gcd_l[n-1],gcd_l[n]]
            ans = gcd(max(a),min(a))
    print(ans)

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

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

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

    for i in range(0,N):
        gcd_l.append(abs(X-x[i]))
    if N==1:
        ans = gcd_l[0]
    else:
        a = [gcd_l[0],gcd_l[1]]
        ans = gcd(max(a),min(a))
        for n in range(2,len(gcd_l)):
            a = [ans,gcd_l[n]]
            ans = gcd(max(a),min(a))
    print(ans)

main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def factor(num):
  tmp = num
  a = 2
  res = {}
  while a * a < num:
    while tmp % a == 0:
      if a in res:
        res[a] += 1
      else:
        res[a] = 1
      tmp /= a
    a+=1
  if tmp > 1:
    res[int(tmp)]=1
  return res

N, X = [int(item) for item in input().split()]
cities = [int(item) for item in input().split()]
cities.append(X)
cities.sort()
ans_dict = factor(cities[1] - cities[0])
for i in range(1, N):
  res = factor(cities[i+1] - cities[i])
  set_keys = set(res) & set(ans_dict)
  ans_dict = {key: min(res[key], ans_dict[key]) for key in set_keys}

ans = 1
for i, j in ans_dict.items():
  ans *= i**j
print(ans)

def gcd(a,b):
  n,  = max(a, b), min(a, b)
  if n % m == 0:
    return m
  else:
    return gcd(m, n%m)

N, X = [int(item) for item in input().split()]
cities = [int(item) for item in input().split()]
if N == 1:
  print(abs(cities[0]-X))
  exit()

mod = gcd(abs(cities[0] - X), abs(cities[1] - X))
for i in range(2, N):
  mod = gcd(mod, abs(cities[0] - X))
print(mod)

def gcd(a,b):
  n, m  = max(a, b), min(a, b)
  if n % m == 0:
    return m
  else:
    return gcd(m, n%m)

N, X = [int(item) for item in input().split()]
cities = [int(item) for item in input().split()]
if N == 1:
  print(abs(cities[0]-X))
  exit()

mod = gcd(abs(cities[0] - X), abs(cities[1] - X))
for i in range(2, N):
  mod = gcd(mod, abs(cities[i] - X))
print(mod)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
from functools import reduce

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

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

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

for x_i in x:
    subX.append(abs(x_i - X))

print(gcd_list(subX))

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

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

for i in range(len(x)):
    ans = gcd(ans, abs(x[i] - X))

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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(1, N+1):
    t = X[i+1] - X[i]
    if t < ans:
        ans = t
print(ans)

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

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

ans = abs(A[0]-X)
for a in A:
    ans = gcd(ans, abs(a-X))


print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
import functools import reduce

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

import functools import reduce
import math

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[inputcities[i]-X for i in range(N)]
D = functools.reduce(math.gcd, cities)
print(D)

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=list(set([abs(inputcities[i]-X) for i in range(N)]))
N=len(cities)
count=0
flag=0
minimum=min(cities)
for j in range(minimum+1)[::-1]:
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      i=N
    if count==N:
      print(j)
      flag=1
      break
    if i==N:
      for k in range(2,j)
        if j%k==0:
          j=k
          break
  if flag==1:
    break

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

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

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[inputcities[i]-X for i in range(N)]
count=0
minimum=min(cities)
for j in range(minimum+1)[::-1]
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      break
    if count==N:
      print(j)
      flag=1
      break
if flag==1:
  break


N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=set([abs(inputcities[i]-X) for i in range(N)])
N=len(cities)
count=0
flag=0
minimum=min(cities)
for j in range(minimum+1)[::-1]:
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      break
    if count==N:
      print(j)
      flag=1
      break
  if flag==1:
    break

def gcd(a,b):
    if a < b:
        a,b = b,a
    if a % b == 0:
        return b
    else:
        return gcd(b,(a % b))
 
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[abs(inputcities[i]-X) for i in range(N)]
cities.sort()
D=cities[0]
for i in range(N):
  D=gcd(D,cities[i])
print(D)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
  
n,x = map(int,input().split())
xlist = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans = gcd(int(xlist[i]-x),ans)
print(ans)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def main():
    N, X = map(int, input().split(' '))
    x_n = list(map(int, input().split(' ')))

    x_n = sorted(x_n)
    if len(x_n) == 1:
        print(abs(X-x_n[0]))
        return

    # print(N,X)
    # print(x_n)
    x_0 = x_n[0]
    x_n = [n - x_0 for n in x_n]
    
    D = 0
    
    
    for i in range(len(x_n) - 1):
        a = x_n[i]
        b = x_n[i+1]
        # print(a, b)
        max_kouyaku = gcd(a, b)
        if max_kouyaku >= D:
            D = max_kouyaku

    print(D)
    return





main()

from functools import reduce

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

def gcd(*num):
    return reduce(gcds, *num)

def main():
    N, X = map(int, input().split(' '))
    x_n = list(map(int, input().split(' ')))

    x_n = sorted(x_n)
    x_n = [n - X for n in x_n] 
    
    print(abs(gcd(x_n)))
    return

main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)


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

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

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

print(ans)


import math
n,x = map(int,input().split())
X = list(map(int,input().split()))
diff = []
for i in range(n):
	diff.append(abs(X[i]-x))
res = diff[0]
for i in range(1,n):
	res = math.gcd(res, diff[i])
print(res)




Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)


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

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

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

print(res)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def gcd(a, b):
    return gcd(b, a % b)


inputs = input().strip().split()

N  = int(inputs[0])
X  = int(inputs[1])

xi = list(map(lambda x: abs(X - int(x)), input().strip().split()))

if N == 1:
    print(xi[0])
else:
    a = xi[0]
    b = xi[1]

    nx = gcd(a, b)

    for i in range(2, len(xi)):
        nx = gcd(nx, xi[i])     

    print(nx)

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


inputs = input().strip().split()

N  = int(inputs[0])
X  = int(inputs[1])

xi = list(map(lambda x: abs(X - int(x)), input().strip().split()))

if N == 1:
    print(xi[0])
else:
    a = xi[0]
    b = xi[1]

    nx = gcd(a, b)

    for i in range(2, len(xi)):
        nx = gcd(nx, xi[i])     

    print(nx)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def gcd(a,b):
    while b!=0:
        a,b = b,b%a
    return a
def lcm(a,b):
    return (a*b)//gcd(a,b)

N,X = map(int,input().split())
x = list(map(int,input().split()))
x = list(map(lambda q:abs(q-X),x))

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

def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a
def lcm(a,b):
    return (a*b)//gcd(a,b)

N,X = map(int,input().split())
x = list(map(int,input().split()))
x = list(map(lambda q:abs(q-X),x))
ans = x[0]
for xx in x:
    ans = gcd(ans,xx)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, x = map(int,input().split())
xl = list(map(int,input().split()))

xl.append(x)
xl.sort()
sa = []
onesam = 2000000000
for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if one_sa % onesam == 0:
        continue
        
    if onesam > one_sa:
        onesam = one_sa
        
    
sa.sort()
samin = min(sa)

flag = 0
while flag == 0:
    amari = 0
    for i in sa:
        amari += i % samin
        if amari != 0:
            break
            
    if amari == 0:
        flag = 1
        break
    else:
        for j in range(1,samin+1):
            if samin % j == 0:
                samin = samin // j
                break
print(samin)
        

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

xl.append(x)
xl.sort()

onesam = 0
for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if onesam == 0:
        onesam = one_sa
    else:
        if one_sa % onesam == 0:
            onesam = one_sa
            continue
        else:
            short,big = min(onesam,one_sa),max(onesam,one_sa)
            if short == 1:
                onesam =1
                break
                
            while big % short != 0:
                for i in range(2,short):
                    if short % i == 0:
                        short = short // i
            if short == 1:
                onesam = 1
                break
            else:
                onesam = short
print(onesam)

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

xl.append(x)
xl.sort()

onesam = 0

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

for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if onesam == 0:
        onesam = abs(one_sa)
    else:
        short,big = min(onesam,one_sa),max(onesam,one_sa)
        if big % short == 0:
            onesam = short
            continue
        else:
            while big % short != 0:
                short = short -1
#                 for k in range(2,short+1):

#                         short = short // k
#                         break
            onesam = short
            
print(onesam)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,X = map(int, input().split())
List = [int(x) for x in input().split()]

import math
List.append(X)
List.sort()

distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])

d_min = min(distance)

num_list = []

c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1

num_list2 = [1]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])

num_list = num_list + num_list2


j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1

print(ans,distance,num_list)

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

import math
List.append(X)
List.sort()

distance = []
for i in range(len(List)-1):
    distance.append(List[i+1]-List[i])

d_min = min(distance)

num_list = []

c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1

num_list2 = [d_min]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = d_min/num_list[i]

num_list = num_list + num_list2


j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1

print(ans)

N,X = map(int, input().split())
List = [int(x) for x in input().split()]
 
import math
List.append(X)
List.sort()
 
distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])
 
d_min = min(distance)
 
num_list = []
 
c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1
 
num_list2 = [0]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])
 
num_list = num_list + num_list2

num_list.append(d_min)

j = len(num_list)-1

while j >= 0:
    c2 = 0
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1
 
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,x = map(int, input().split())
city = []
sub = []
city = list(map(int, input().split()))

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

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

for i in range(1,len(sub)):
	ans = gcd(sub[i-1], sub[i])

print(ans)

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

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

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


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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,x=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
a=abs(l[0]-x)
for i in range(l):
  a=gcd(a,abs(l[i]-x))
print(a)

n,x=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
a=abs(l[0]-x)
for i in range(n):
  a=gcd(a,abs(l[i]-x))
print(a)



Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import fraction

n, x = [int(_) for _ in input().split()]
x_list = [int(_) - x for _ in input().split()]
print(x_list)

x_sorted = sorted(x_list)

x_gaps = [x_sorted[i+1] - x_sorted[i] for i in range(0, n-1)]

result = x_sorted[0]
for i in range(0, n-2):
    if i == 0:
        result = fraction.gcd(x_gaps[0], x_gaps[1])
    else:
        result = fraction.gcd(result, x_gaps[i+1])

print(result)

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


n, x = [int(_) for _ in input().split()]
x_list = [int(_) - x for _ in input().split()]

x_sorted = sorted(x_list)

x_gaps = [x_sorted[i+1] - x_sorted[i] for i in range(0, n-1)]

if len(x_gaps) == 0:
    print(abs(x_sorted[0]))
elif len(x_gaps) == 1:
    print(gcd(abs(x_list[0]), abs(x_list[1])))
else:
    result = x_sorted[0]
    for i in range(0, n-2):
        if i == 0:
            result = gcd(x_gaps[0], x_gaps[1])
        else:
            result = gcd(result, x_gaps[i+1])
    print(result)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
n, x = map(int, input().split())
a = input().split()

b = list(map(int, a))
b.append(x)
b.sort()
print(b)
minimum = b[1] - b[0]
for i in range(n):
    if i <= n - 1:
        if minimum > b[i + 1] - b[i]:
            minimum = b[i + 1] - b[i]

print(minimum)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
n, x = map(int, input().split())
a = input().split()
b = list(map(int, a))
b.append(x)
b.sort()
if len(b) == 2:
    print(b[1] - b[0])
    exit(0)
c = [abs(a - x) for a in b]


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


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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def g(a,b):x=max([a,b]);y=min([a,b]);return g(y,x%y) if x%y else y
N,X=map(int,input().split());a=[abs(int(i)-X) for i in input().split()];ans=a[0]
for i in range(1,N):ans=g(ans,y[i])
print(ans)

def g(a,b):x=max([a,b]);y=min([a,b]);return g(y,x%y) if x%y else y
N,X=map(int,input().split());p=[abs(int(i)-X) for i in input().split()];ans=p[0]
for i in range(1,N):ans=g(ans,p[i])
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,x = map(int, input().split())

def check(n):
    return abs(n - x)

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

dist = list(map(check, city))
min_dist = min(dist)

if n < 2:
    print(min_dist)
    exit()

dists = []
prev = 0

city.sort()
for pos in city:
    if not prev == 0:
        dists.append(abs(prev - pos))
    prev = pos

for l in dists:
    if l > min_dist:
        if l % min_dist == 0:
            print(1)
            exit()
    if l < min_dist:
        if min_dist % l == 0:
            print(1)
            exit()

new_min = min(dists)

if min_dist > new_min and min_dist % new_min == 0:
    print(tmp)
elif new_min > min_dist and new_min % min_dist == 0:
    print(min_dist)
else:
    print(1)


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

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

city.append(x)
city.sort()

dist = []
for i in range(len(city)-1):
    dist.append(abs(city[i]-city[i+1]))

if len(dist) < 2:
    min_dist = dist[0]
else:
    min_dist = 0
    for i in range(len(dist)-1):
        if min_dist == 0:
            min_dist = gcd(dist[i], dist[i+1])
        else:
            min_dist = min(min_dist, gcd(dist[i], dist[i+1]))

print(min_dist)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# coding: utf-8


def main():
    n, x = map(int, input().split())
    xi = map(int, input().split())

    diffs = []
    for i in xi:
        diffs.append(abs(x - i))

    for diff in diffs:
        if diff % min(diffs)) != 0:
            print('1')
            return

    print(min(diffs))


if __name__ == '__main__':
    main()


# coding: utf-8

from functools import reduce


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


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


def main():
    n, x = map(int, input().split())
    xi = map(int, input().split())

    diffs = []
    for i in xi:
        diffs.append(abs(x - i))

    print(gcd_list(diffs))


if __name__ == '__main__':
    main()


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def gcd(x,y):
     if x%y==0:
             return y
     else:
             return gcd(y, x%y)

[n,m]=[int(i) for i in input().split()]
x=[int(i)-m for i in input().split()]
x.append(0)

li=[]
f=1
if n==1:
    f=0
    print(abs(x[0]-x[1]))

for i in range(len(x)-1):
    li.append(abs(x[i]-x[i+1]))
temp=abs(min(x))
li.append(temp)
try:
    x.remove(temp)
except:
    x.remove(-temp)
temp=abs(min(x))
li.append(temp)



if f:
    for i in range(len(li)-1):
        a=li[0]
        a=gcd(a, li[i+1])
    print(a)


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

[n,m]=[int(i) for i in input().split()]
x=[int(i)-m for i in input().split()]
x.append(0)

li=[]
f=1
if n==1:
    f=0
    print(abs(x[0]-x[1]))

for i in range(len(x)-1):
    li.append(max(abs(x[i]-x[i+1]), (abs(x[i+1]-x[i]))))
temp=abs(min(x))
li.append(temp)


if f:
    a=li[0]
    for i in range(len(li)-1):
        a=gcd(a, li[i+1])
    print(a)


Verdicts: Runtime Error

Accepted
Problem: 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.

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

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import math


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

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

A.append(X)
A = sorted(A)

anslis = [0]*N

for i in range(N):
    anslis[i] = A[i+1] - A[i]

g = anslis.pop(0)
for c in cost_li:
    g = math.gcd(g,c)

print(g)

import sys
import math


N, X = 3,3
A = [1,7,11]

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

A.append(X)
A = sorted(A)

anslis = [0]*N

for i in range(N):
    anslis[i] = A[i+1] - A[i]

g = anslis.pop(0)
for c in cost_li:
    g = math.gcd(g,c)

print(g)

import sys
import math


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

A.append(X)
A = sorted(A)

anslis = [0]*N
for i in range(N):
    anslis[i] = A[i+1] - A[i]

g = anslis.pop(0)
for c in anslis:
    g = math.gcd(g,c)

print(g)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,X=map(int,input().strip().split())
x=list(map(int,input().strip().split()))

x.sort()

d=[]
for n in range(1,N):
    d.append(x[n]-x[n-1])

def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    tmp=x%y
    if tmp==0:
        return y
    else:
        gcd(y,tmp)

if len(d)==0:
    print(abs(x[0]-X))
else:
    D=d[0]
    for i in range(1,len(d)):
        D=gcd(D,d[i])
    print(D)

N,X=map(int,input().strip().split())
x=list(map(int,input().strip().split()))
x.append(X)
x.sort()
    
d=[]
for n in range(1,N+1):
    d.append(x[n]-x[n-1])
    
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    tmp=x%y
    if tmp==0:
        return y
    else:
        return gcd(y,tmp)
    
if len(d)<=1:
    print(d[0])
else:
    D=d[0]
    for i in range(1,len(d)):
        D=gcd(D,d[i])
    print(D)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, place = [int(x) for x in input().split(' ')]
city_address = [int(x) - place for x in input().split(' ')]

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

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

print(answer)

n, place = [int(x) for x in input().split(' ')]
city_address = sorted([abs(int(x) - place) for x in input().split(' ')], reverse=True)
print(city_address)
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
 
answer = city_address[0]
for address in city_address:
	answer = gcd(answer, address)
 
print(answer)

n, place = [int(x) for x in input().split(' ')]
city_address = sorted([abs(int(x) - place) for x in input().split(' ')], reverse=True)
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

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

print(answer)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,x=map(int,input().split())
xlist= list(map(int,input().split()))
xlist.append(x)
xsort = sorted(xlist, reverse=True)
if n == 1:
  print(xsort[0]-xsort[1])
  exit()
ylist = []
for i in range(n-1):
  ylist.append(xsort[i]-xsort[i+1])
from functools import reduce
from math import gcd
print(reduce(gcd,ylist))

n,x=map(int,input().split())
xlist= list(map(int,input().split()))
xlist.append(x)
xsort = sorted(xlist, reverse=True)
ylist = []
for i in range(n-1):
  ylist.append(xsort[i]-xsort[i+1])
from functools import reduce
from math import gcd
print(reduce(gcd,ylist))

n,x=map(int,input().split())
xlist= list(map(int,input().split()))
if n == 1:
  print(abs(xlist[0]-x))
  exit()
ylist = []
for i in range(n):
  ylist.append(abs(xlist[i]-x))
from functools import reduce
from math import gcd
print(reduce(gcd,ylist))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, X = map(int, input().split())
x = list(map(abs, [i-X for i in list(map(int, input().split()))]))
x.sort()
ans = 1
if x[0] == 0:
    del x[0]
    n -= 1
if n == 1:
    ans = x[0]
elif min(x) != 1:
    for i in range(2, min(x)):
        go = True
        while go:
            go = False
            cnt = 0
            for j in x:
                if j%i == 0:
                    cnt += 1
            if cnt == n:
                ans *= i
                go = True
                for j in range(n):
                    x[j] //= i
            else:
                break
print(ans)

n, X = map(int, input().split())
x = list(map(abs, [i-X for i in list(map(int, input().split()))]))
x.sort()
if x[0] == 0:
    del x[0]
    n -= 1
def gcd(a, b):
    while True:
        c = a%b
        if c == 0:
            break
        a = b
        b = c
    return b

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

import math
#n,x=map(int,input().split())
#pos=list(map(int,input().split()))

n,x=3,81
pos=[33,105,57]
pos2=[p-x for p in pos]

width= max(pos2)-min(pos2)
ans = 1
for i in range(2,width+1):
    if all([ x%i==0 for x in pos2 ]):ans=i

print(ans)

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

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

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

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

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
from functools import reduce


def gcd_list(numbers):
    return reduce(math.gcd, numbers)
n,x=map(int,input().split())
l=[abs(c-x) for c in list(map(int,input().split()))]
del l[l.index(0)]
print(gcd_list(l) if len(l)>1 else l[0])

from functools import reduce
def gcd(a,b):
        while b:
            a,b=b,a%b
        return a
def solve(lis,x):
    ans=abs(lis[0]-x)
    lis=[abs(c-x) for c in lis]
    for x in lis:
        if x!=0:
            ans=gcd(ans,x)
    return ans 
n,x=map(int,input().split())
l=list(map(int,input().split()))
print(solve(l,x))


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N, X = map(int, input().split())
x = list(map(int, input().split()))
x_gcd = []
for i in range(N):
    x_gcd.append(abs(X-x[i]))


def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a
ans = [0]*(N-1)

for i in range(N-1):
    ans[i] = gcd(x_gcd[i], x_gcd[i+1])
if ans:
    print(max(ans))
else:
    print(x[0] - X)

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


def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a
ans = [0]*(N-1)

for i in range(N-1):
    ans[i] = gcd(x_gcd[i], x_gcd[i+1])
if ans:
    print(max(ans))
else:
    print(x[0] - X)

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


def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a
ans = [0]*(N-1)

for i in range(N-1):
    ans[i] = gcd(x_gcd[i], x_gcd[i+1])
if ans:
    print(max(ans))
else:
    print(x[0] - X)

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


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


ans = x_gcd[0]
for i in range(N):
    ans = gcd(ans, x_gcd[i])
if ans:
    print(ans)
else:
    print(x[0] - X)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted