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):
from fraction import gcd
from functools import reduce

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

if len(array) > 1:
    result = reduce(gcd, array)
else:
    result = array[0]
print(result)


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

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

if len(array) > 1:
    result = gcd(array[0], array[1])
    for i in range(2, len(array)):
        result = gcd(result, array[i])
else:
    result = array[0]
    
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):
import fraction
from functools import reduce

n,X = map(int,input().split())
x =list(map(int,input().split()))
x.append(X)
x.sort()
a = []*n
for i in range(n):
  a[i] = x[i+1]-x[i]
  
g = gcd(*a)
print(g)



n,X = map(int,input().split())
x =list(map(int,input().split()))
x.append(X)
x.sort()
a = []
for i in range(n):
  a.append(x[i+1]-x[i])
  
g = []
h = min(a)
for i in range(1,h+1):
  if h%i == 0:
    g.append(i)
    
gcd = []
for i in g:
  if all(a[j]%i == 0 for j in range(n)):
    gcd.append(g)
    
print(max(gcd))
    
  
  




n,X = map(int,input().split())
x =list(map(int,input().split()))
x.append(X)
x.sort()
a = []
for i in range(n):
  a.append(x[i+1]-x[i])
  
h = min(a)
gcd = 1
for i in range(h,0,-1):
  if h%i == 0:
    if all(a[j]%i == 0 for j in range(n)):
      gcd = i
      break
      
print(gcd)
    

    
    
    


    gcd = i
    break
    
    
print(gcd)
    
  
  




n,X = map(int,input().split())
x =list(map(int,input().split()))
x.append(X)
x.sort()
a = []
for i in range(n):
  a.append(x[i+1]-x[i])
  
g = []
h = min(a)
gcd = 1
for i in range(h,0,-1):
  if h%i == 0:
    if all(a[j]%i == 0 for j in range(n)):
      gcd = i
      break
      
print(gcd)
    

    
    
    


    gcd = i
    break
    
    
print(gcd)
    
  
  




n,X = map(int,input().split())
x =list(map(int,input().split()))
x.append(X)
x.sort()
a = []
for i in range(n):
  a.append(x[i+1]-x[i])
  
h = min(a)
gcd = 1
for i in range(h,0,-1):
  if h%i == 0:
    if all(a[j]%i == 0 for j in range(n)):
      gcd = i
      break
      
print(gcd)
  
  




Verdicts: Runtime Error

Wrong Answer

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())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
print(a)

n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
import math
from functools import reduce
print(a)

n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
import math
from functools import reduce
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
ans = reduce(gcd, a)
print(int(ans))

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):
from functools import reduce

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

if X not in x_list:
    x_list.append(X).sort()
    N += 1    

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

if N >= 3:
    space = [abs(x_list[i + 1] - x_list[i]) for i in range(N - 1)]
    print(reduce(gcd, space))
elif N == 2:
    space = x_list[1] - x_list[0]
    print(space)
elif N == 1:
    space = x_list[0]
    print(space)






from functools import reduce

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

if X not in x_list:
    x_list.append(X)
    x_list.sort()
    N += 1    

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

if N >= 3:
    space = [abs(x_list[i + 1] - x_list[i]) for i in range(N - 1)]
    print(reduce(gcd, space))
elif N == 2:
    space = x_list[1] - x_list[0]
    print(space)
elif N == 1:
    space = x_list[0]
    print(space)






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 y>x:
        a=y
        y=x
        x=a
    a=1
    while a*y:
        a=x%y
        x=y
        y=a
    return x

a,b=map(int,input().split())
c=list(map(int,input().split()))
c.append(b)
c.sort()
for i in range(a):
    c[-1-i]-=c[-2-i]
c[0]=0
for i in range(a):
    b=gcd(c[i],c[i+1])
print(b)

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

a,b=map(int,input().split())
c=list(map(int,input().split()))
c.append(b)
c.sort()
for i in range(a):
    c[-1-i]-=c[-2-i]
b=0
for i in range(a):
    b=gcd(c[i+1],b)
print(b)

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):
from numpy import gcd

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

x.sort()
diff_x = [x[i+1] - x[i] for i in range(n-1)]
ans = 1
for x_i in x:
    ans = int(gcd(ans, x_i))

print(ans)


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

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

x = list(set(x))
x.sort()
if len(x) >= 3:
    diff_x = [x[i+1] - x[i] for i in range(n)]
    ans = diff_x[0]
    for dx in diff_x[1:]:
        ans = int(gcd(ans, dx))
elif len(x) == 2:
    ans = x[1] - x[0]


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())
l = list(map(int, input().split()))

def gcd(x, y):
    while (y != 0):
        x, y = y, x%y

    return x

diff = []

for j in l:
    diff.append(abs(j - x))

ans = diff[0]

for d in range(d[1:]):
    ans = gcd(ans, d)

print(ans)



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

def gcd(x, y):
    while (y != 0):
        x, y = y, x%y

    return x

ans = abs(l[0] - x)

for d in l[1:]:
    ans = gcd(ans, abs(d - 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):
# -*- coding: utf-8 -*-
#ABC109C
import sys

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

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
x=hoge[1]

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

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


# -*- coding: utf-8 -*-
#ABC109C
import sys

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

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
x=hoge[1]

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

res = abs(x-hoge[0])
for i in range(1,n):
	res=gcd(res, abs(hoge[i]-hoge[i-1]))
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):
list1 = list(map(int, input().split()))
n = list1[0]
x = list1[1]
list2 = list(map(int, input().split()))
list2.append(x)
list2.sort()

list3 = []
list4 = []
length = len(list2)
index =1
while index < length:
    if list2[index] ==x or list2[index-1]==x:
        list4.append(list2[index]-list2[index-1])
    else:
        list3.append(list2[index]-list2[index-1])
    index+=1
list3.append(max(list4))
list3.append(min(list4)+max(list4))

list3.sort()
mimN = list3[0]
ans =0
index2 =mimN
if len(list3) ==1:
    print(mimN)
else:
    flag2 =0
    for number in list3:
       if number%mimN !=0:
           flag2 =1
    if flag2 ==0:
        print(mimN)
    else:
        while index2>=1:
            flag=0
            for number in list3:
                if number%index2 ==0:
                    flag =1
                else:
                    flag =0
            if flag ==1:
                ans = index2
                break
            else:
                index2-=1
            
        print(ans)

list1 = list(map(int, input().split()))
n = list1[0]
x = list1[1]
list2 = list(map(int, input().split()))
list2.append(x)
list2.sort()

list3 = []
list4 = []
length = len(list2)
index =1
while index < length:
    list3.append(list2[index]-list2[index-1])
    index+=1

list3.sort()
mimN = list3[0]
ans =0
index2 =mimN
if len(list3) ==1:
    print(mimN)
else:
    flag2 =0
    for number in list3:
       if number%mimN !=0:
           flag2 =1
    if flag2 ==0:
        print(mimN)
    else:
        while index2>=1:
            flag=0
            for number in list3:
                if number%index2 ==0:
                    flag =1
                else:
                    flag =0
                    break
            if flag ==1:
                ans = index2
                break
            else:
                index2-=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())
a=sorted(list(map(int,input().split())))
b=[a[i+1]-a[i]for i in range(n-1)]
b.insert(0,a[0]-x)

def search_common_divisor(x,y):
    if x<y:
        x,y=y,x
    while y!=0:
        x,y=y,x%y
    return x

def search_list_common_divisor(*numbers):
    b=[search_common_divisor(numbers[0],numbers[1])]
    for i in numbers:
        b.append(search_common_divisor(b[-1],i))
    return b[-1]


if n!=1:
    print(search_list_common_divisor(*b))
else:
    print(b[0])


n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[a[i+1]-a[i]for i in range(n-1)]
b.insert(0,abs(a[0]-x))

def search_common_divisor(x,y):
    if x<y:
        x,y=y,x
    while y!=0:
        x,y=y,x%y
    return x

def search_list_common_divisor(*numbers):
    b=[search_common_divisor(numbers[0],numbers[1])]
    for i in numbers:
        b.append(search_common_divisor(b[-1],i))
    return b[-1]


if n!=1:
    print(search_list_common_divisor(*b))
else:
    print(b[0])


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):
    if b == 0:
        return a
    return gcd(b, a %b)

def main():
    n, x = map(int, input().split())
    a = [int(v) for v in input().split(' ')]
    a.append(x)
    a.sort()
    dis = [x2 - x1 for x1, x2 in zip(a, a[1:])]
    max_ = 0
    for i in range(n):
        if len(dis) == 1:
            max_ = dis[0]
            break
        try:
            g = max([gcd(d1, d2) for d1, d2 in zip(dis[i:], dis[i+1:])])
        except ValueError:
            break
        if g > max_:
            max_ = g
    print(max_)

if __name__ == '__main__':
    main()


import math

def main():
    n, x = map(int, input().split())
    a = [int(v) for v in input().split(' ')]
    a.append(x)
    a.sort()
    dis = [x2 - x1 for x1, x2 in zip(a, a[1:])]
    max_ = 0
    for i in range(n):
        if len(dis) == 1:
            max_ = dis[0]
            break
        try:
            g = max([math.gcd(d1, d2) for d1, d2 in zip(dis[i:], dis[i+1:])])
        except ValueError:
            break
        if g > max_:
            max_ = g
    print(max_)

if __name__ == '__main__':
    main()


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

def gcdlist(l):
    if len(l) == 2:
        return gcd(l[0], l[1])
    f = l.pop()
    s = l.pop()
    m = gcd(f, s)
    l.append(m)
    return gcdlist(l)


def main():
    n, x = map(int, input().split())
    a = [int(v) for v in input().split(' ')]
    a.append(x)
    a.sort()
    dis = [x2 - x1 for x1, x2 in zip(a, a[1:])]
    max_ = 0
    for i in range(n):
        if len(dis) == 1:
            max_ = dis[0]
            break
        try:
            max_ = gcdlist(dis)
        except:
            max_ = 1
    print(max_)

if __name__ == '__main__':
    main()


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):
from fractions import gcd
n,x = map(int,input().split())
l = list(map(int,input().split()))
ll = []
for i in range(n-1):
    ll.append(l[i+1]-l[i])
ans = ll[0]
for i in range(len(ll)):
    ans = gcd(ans,ll[i])
print(ans)

from functools import reduce
def gcd_list(n):
    return reduce(gcd, n)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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

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 euclid(a, b):
        if a < b:
            a, b = (b, a)
     
        while True:
            r = a % b
            if r == 0:
                break
            a, b = (b, r)
     
        return b
     
     
    if __name__ == '__main__':
        n, x = tuple(map(int, input().split()))
        points = [int(x) for x in input().split()]
        if not x in points:
            points.append(x)
     
        buf = [abs(points[i + 1] - points[i]) for i in range(len(points) - 1)]
        while len(buf) > 1:
            buf = [euclid(buf[i + 1], buf[i]) for i in range(len(buf) - 1)]
     
        print(buf[0])

def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == '__main__':
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]
    if not x in points:
        points.append(x)

    buf = [abs(points[i + 1] - points[i]) for i in range(len(points) - 1)]
    while len(buf) > 1:
        print(buf)
        buf = [euclid(buf[i + 1], buf[i]) for i in range(len(buf) - 1)]

    print(buf[0])


from functools import reduce

def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == '__main__':
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]
    if not x in points:
        points.append(x)

    buf = [abs(points[i + 1] - points[i]) for i in range(len(points) - 1)]
    print(reduce(lambda a,b: euclid(a, b), bur))


from functools import reduce

def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == '__main__':
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]
    if not x in points:
        points.append(x)

    buf = [abs(points[i + 1] - points[i]) for i in range(len(points) - 1)]
    print(reduce(lambda a,b: euclid(a, b), buf))


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):
#-*-coding:utf-8-*-

def main():
    n, x = map(int, input().split())
    x_list = list(map(int, input().split()))
    if n == 1:
        print(abs(x_list[0] - x))
        exit()
    x_list.append(x)
    x_list.sort()
    diff = []
    for i in range(1, n):
        print('aaaa')
        diff.append(x_list[i] - x_list[i - 1])
    print(min(diff))

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())
    x_list = list(map(int, input().split()))
    x_list.append(x)
    x_list.sort()
    diff = []
    for i in range(n):
        diff.append(x_list[i + 1] - x_list[i])
    print(gcd_list(diff))

if __name__ == '__main__':
    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):
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

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


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

N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(N==1):
    print(abs(x[0]-X))
    exit()
x=list(map(lambda y:abs(y-X) , x))
ans=gcd(x[0],x[1])
for i in range(2:N):
    ans=gcd(x[i],ans)
    
print(ans)


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

N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(N==1):
    print(abs(x[0]-X))
    exit()
x=list(map(lambda y:abs(y-X) , x))
ans=gcd(x[0],x[1])
for i in range(2,N):
    ans=gcd(x[i],ans)
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):
import math

N, X = map(int,input().split())
city = list(map(int,input().split()))
X_diff = [0]*N
for i in range(N):
    X_diff[i] = abs(X-city[i])
    
ans = X_diff[0]
for i in range(1,N):
    ans = gcd(ans,X_diff[i])

print(ans)

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

N, X = map(int,input().split())
city = list(map(int,input().split()))
X_diff = [0]*N
for i in range(N):
    X_diff[i] = abs(X-city[i])
    
ans = X_diff[0]
for i in range(1,N):
    ans = gcd(ans,X_diff[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):
headData=[int(n) for n in input().split()]
cityNum=headData[0]
pos_x=int(headData[1])
cityList=[int(n) for n in input().split()]
allList=[]
allList.append(pos_x)
for n in cityList:
    allList.append(n)

allList=sorted(allList)
print(allList)

diffList=[]

for n in range(len(allList)-1):
    diffList.append(allList[n+1]-allList[n])

answer = min(diffList)

while True:
    isAnswer = True
    for n in diffList:
        if n % answer != 0:
            isAnswer = False
            break
    if isAnswer:
        print(answer)
        break
    else:
        answer = answer-1

headData=[int(n) for n in input().split()]
cityNum=headData[0]
pos_x=int(headData[1])
cityList=[int(n) for n in input().split()]
allList=[]
allList.append(pos_x)
for n in cityList:
    allList.append(n)

allList=sorted(allList)

diffList=[]

for n in range(len(allList)-1):
    diffList.append(allList[n+1]-allList[n])

answer = min(diffList)

while True:
    isAnswer = True
    for n in diffList:
        if n % answer != 0:
            isAnswer = False
            break
    if isAnswer:
        print(answer)
        break
    else:
        answer = answer-1

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):
from fractions import Fraction
n , x = map(int,input().split())

field = [int(i) for i in input().split()]

tmp = []

for i in field:
    tmp.append(abs(i-x))


ans = tmp[0]

for i in range(1,n):
    ans = min(ans,fractions.gcd(ans,tmp[i]))

print(ans)

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

field = [int(i) for i in input().split()]

diff = list(map(lambda a:abs(a-x),field))

def gcd(x,y):
    # print(x,y)
    if x < y:
        x,y = y,x

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

ans = diff[0]


for i in diff[1:]:
    ans = gcd(i,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):
n,s = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if n>1:
    dif = []
    for i in range(n-1):
        dif.append(x[i+1]-x[i])

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

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

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

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

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

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

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

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

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

tmp = 1
for i in range(len(x)-1):
    x[i+1] = f(x[i], x[i+1])

print(x[len(x)])


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

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

tmp = 0
for i in range(1, len(x)):
    tmp = f(x[i-1], x[i])

print(tmp)


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

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

tmp = 1
for i in range(len(x)-1):
    x[i+1] = f(x[i], x[i+1])

print(x[len(x)-1])


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):
import math
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
m=xlist[-1]
while xlist==[0]*n:
   for i in range(n):
        xlist[i]%=m
        if xlist[i]>0:
            m=math.gcd(m,xlist[i])
print(m)

n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda x:abs(x))
m=xlist[0]-x
while xlist==[0]*n:
   for i in range(n):
        xlist[i]-=x
        xlist[i]%=m
        m=min((m,xlist[i]))
print(m)

n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
m=abs(xlist[0]-x)
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs[xlist[i]]
while xlist==[0]*n:
   for i in range(n):
        xlist[i]%=m
        if xlist[i]>0:
            m=min((m,xlist[i]))
print(m)

def gcd(x,y):
    while x%y:
        x%=y
        x,y=(y,x)
    return y
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
m=xlist[-1]
while xlist!=[0]*n:
    for i in range(n):
        
        xlist[i]%=m
        if xlist[i]>0:
            m=gcd(m,xlist[i])
print(m)

Verdicts: Wrong Answer

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):
from fractions import Fraction

gcd = fractions.gcd

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

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

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

N, X = [int(_) for _ in input().split()]
xs = [abs(int(_) - X) for _ in input().split()]

def gcd(p, q):
    while q != 0:
        p, q = q, p % q
    return p

y = xs[0]
for i in range(N):
    if xs[i] % y != 0:
        y = gcd(y, xs[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):
n,x=map(int,input().split())
l=list(map(int,input().split()))

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

def gcd(x,y):
    if y==0:
      return x
    else:
      return gcd(y,x%y) 
    
if n==1:
  x=l[0]
else:
  x=gcd(l[0],l[1])
  if n>2:
    for i in range(2,n):
      x=gcd(x,l[i])
print(x)

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

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

def gcd(x,y):
    if y==0:
      return x
    else:
      return gcd(y,x%y) 
    
if n==1:
  x=l[0]
else:
  x=gcd(l[0],l[1])
  if n>2:
    for i in range(2,n):
      x=gcd(x,l[i])
print(x)

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=list(map(int,input().split()))
Y=list(map(int,input().split()))
X=[abs(Y[i]-n[1]) for i in range(n[0])]
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y) 
for i in range(n[0]-1):
    X[0]=gcd(X[0],X[1])
    X=[X[0]]+X[1:]
print(max(X))

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

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

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 LCM(m,n):
  for i in range(1,m+1)[::-1]:
    if n%i==0:
      return i
    
N,X=(int(i) for i in input().split(' '))
x=[int(i) for i in input().split(' ')]
x=[X]+x
D=x[1]-x[0]
for i in range(N):
  D=LCM(D,x[i+1]-x[i])
print(D)

def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

def LCM(m,n):
  if m>n:
    m,n=n,m
  for i in range(1,m+1)[::-1]:
    if n%i==0:
      return i
    
N,X=(int(i) for i in input().split(' '))
x=[int(i) for i in input().split(' ')]
x=[X]+x
x=quick_sort(x)
D=abs(x[1]-x[0])
for i in range(N):
  D=LCM(D,abs(x[i+1]-x[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,x=map(int,input().split())
m=list(map(lambda x:int(x)-x,input().split()))
if 0 in m:
  m.remove(0)
ans=abs(m[0])
for i in m:
  i=abs(i)
  while 1:
    ans%=i
    ans,i=i,ans
    if i==0:
      break
print(ans)

n,x=map(int,input().split())
m=list(map(lambda y:int(y)-x,input().split()))
if 0 in m:
  m.remove(0)
ans=abs(m[0])
for i in m:
  i=abs(i)
  while 1:
    ans%=i
    ans,i=i,ans
    if i==0:
      break
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 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)

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(0)
x = np.abs(np.diff(x))

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

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):
import math

N,X = map(int,input().split())
L = list(map(int,input().split()))
L.append(X)
L = sorted(L)
D = []
for i in range(len(L)) :
    d = abs(L[i+1] - L[i])
    D.append(d)

D = sorted(D)
if N != 1 :
    answer = math.gcd(D[0],D[1])
    for j in range(len(D)) :
        gcd = math.gcd(D[i-1],D[i])
        if answer > gcd :
            answer = gcd
else :
    answer = D[0]
print(answer)



N,X = map(int,input().split())
L = list(map(int,input().split()))
counter = 0
L.append(X)
L = sorted(L)
D = []
for i in range(len(L)) :
    d = L[i]-L[i-1]
    if i != 0 :
        D.append(d)

D = sorted(D)
qq = min(D)
for j in range(len(D)-1) :
    if D[j+1] % qq != 0 :
        counter += 1

if counter == 0 :
    print(qq)
else :
    print(1)
    
print(D)
print(counter)



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


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


while len(diff) > 1:
    a, b = diff.pop(), diff.pop()
    diff.append(gcd(a, b))

print(diff[0])


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 = [int(nx) for nx in input().split()]
x = [abs(int(xx) - X) for xx in input().split()]

while len(x) > 1:
  x2 = []
  mn_x = min(x)
  for n in range(N):
    mod = x[n] % mn_x
    if mod != 0:
      x2.append(mod)
  x2.append(mn_x)
  x = x2
print(x)

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

while len(x) > 1:
  x2 = []
  mn_x = min(x)
  for n in range(len(x)):
    mod = x[n] % mn_x
    if mod != 0:
      x2.append(mod)
  x2.append(mn_x)
  x = x2
  
ans = x[0]
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 = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)

for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(*data)
    exit()

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

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

n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)

for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(abs(data[0]-x))
    exit()
dis.sort()

ans = 0
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
for i in range(n-1):
    ans = gcd(dis[i+1],dis[i])
    
print(ans)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)

for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(abs(x-data[0]))
    exit()

dis.sort()
if n == 2:
    temp = min(abs(x-data[0]),abs(x-data[1]))
    print(gcd(temp,dis[0]))
    exit()




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


Verdicts: Wrong Answer

Runtime Error

Accepted