ZhenlongDai/ACPR huggingface dataset:
Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
from functools import reduce

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

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

N,X=map(int,input().split())
A=list(map(int,input().split()))
A.append(X)
A=sorted(A)
if N==1:
  print(A[1]-A[0])
else:
  B=[A[i]-A[i-1] for i in range(1,N)]
  print(gcd(*B))

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
import math
from functools import reduce

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

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

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

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,X = map(int,input().split())

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

M = sorted([abs(i - X) for i in L])

m = min(M)

if m == 0:
  print(m)
else:
  for i in range(0,len(M)):
    if M[i] % m > 0:
      print(1)
      break
  else:print(m)

Failing test case input:
3 81
6 11 16

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):

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

M = [abs(i - X) for i in L]

def gcd(a,b):
    if b==0: 
        return a 
    return gcd(b,a%b)
    
D = 0 
for i in range(0,len(M)): 
    D = gcd(D,M[i])

print(D)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x0 = [int(_) for _ in input().split(' ')]
x = [int(_) - x0 for _ in input().split(' ')]

def gcm(p, q):
    if p % q == 0:
        return abs(q)
    else:
        return gcm(q, p % q)

if n == 1:
    print(x[0])
else:
    answer = x[0]
    for i in range(n - 1):
        answer = gcm(answer, x[i + 1])
    print(answer)


Failing test case input:
1 3
1 5 11

Expected output:
2


Actual output:
-2


Fixed submission (verdict: Accepted):
n, x0 = [int(_) for _ in input().split(' ')]
x = [abs(int(_) - x0) for _ in input().split(' ')]

def gcm(p, q):
    if p % q == 0:
        return abs(q)
    else:
        return gcm(q, p % q)

if n == 1:
    print(x[0])
else:
    answer = x[0]
    for i in range(n - 1):
        answer = gcm(answer, x[i + 1])
    print(answer)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

flag=True

for i in range(min_distance,0,-1):
    for j in range(n):
        if first_distance[j]%i != 0:
            flag = False
            break

    if flag:
        ans = i
        print(ans)
        break

Failing test case input:
3 81
33 70 57

Expected output:
1


Actual output:

Fixed submission (verdict: Accepted):
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

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


if n==1:
    print(first_distance[0])
else:
    element = gcd(first_distance[0], first_distance[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,first_distance[i])
        print(element)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)


for i in range(min_distance,0,-1):
    Can_go_list=list(map(lambda z: 1 if z % i == 0 else 0,first_distance))

    if 1 not in Can_go_list:
        ans = i
        print(ans)
        break

Failing test case input:
1 0
1011001100

Expected output:
1011001100


Actual output:
1011001099


Fixed submission (verdict: Accepted):
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

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


if n==1:
    print(first_distance[0])
else:
    element = gcd(first_distance[0], first_distance[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,first_distance[i])
        print(element)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def p(a,b):
    x = max(a,b)
    y = min(a,b)
    while(y!=0):
        x = y
        y = x%y
    return x

N,X = map(int,input().split())
Y = list(map(int,input().split()))
Y.append(X)
Y.sort()
l = [0]*N
for i in range(N):
    l[i]=abs(Y[i+1]-Y[i])
ans = l[0]
for i in range(N-1):
    ans = p(ans,l[i+1])
print(ans)

Failing test case input:
3 81
33 42 57

Expected output:
3


Actual output:
9


Fixed submission (verdict: Accepted):
def p(a,b):
    x = max(a,b)
    y = min(a,b)
    while(y!=0):
        x,y = y,x%y
    return x

N,X = map(int,input().split())
Y = [abs(X-int(i)) for i in input().split()]
ans = Y[0]
for i in range(N-1):
    ans = p(ans,Y[i+1])
print(ans)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x = map(int,input().split())
X = list(map(int,input().split()))
sort_X = sorted(X)
temp = sort_X[0]
mini = max(X[-1]-x,x-X[0])
D = 1
if(n==1):
    print(999999999)
else:
    for xx in sort_X[1:]:
        if(mini >= xx-temp):
            mini = xx-temp
        temp = xx
    for p in range(1,mini+1):
        point = x%p
        flag = True
        for xx in X:
            if(point != xx%p):
                    flag = False
                    break
        if(flag):
            D = p

    print(D)



Failing test case input:
1 -7
1110000101

Expected output:
1110000108


Actual output:
999999999


Fixed submission (verdict: Accepted):
n,x = map(int,input().split())
X = list(map(int,input().split()))
sort_X = sorted(X)
temp = sort_X[0]
mini = float("inf")
D = 1
if(n==1):
    print(abs(X[0]-x))
elif(n==2):
    mini = min(X[-1]-x,x-X[0])

    for p in range(1,mini+1):
        point = x%p
        flag = True
        for xx in X:
            if(point != xx%p):
                    flag = False
                    break
        if(flag):
            D = p
    print(D)

else:
    for xx in sort_X[1:]:
        if(mini >= xx-temp):
            mini = xx-temp
        temp = xx
    for p in range(1,mini+1):
        point = x%p
        flag = True
        for xx in X:
            if(point != xx%p):
                    flag = False
                    break
        if(flag):
            D = p

    print(D)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

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

if len(xs) > 1:
    m = min(xs)
    xs = [n - m for n in xs]
    g = gcd(max(xs[0], xs[1]), max(xs[0], xs[1]))
    for n in xs[2:]:
        g = gcd(max(g, n), min(g, n))
    print(g)
else:
    print(xs[0])

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

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

xs.append(X)

m = min(xs)
xs = [n - m for n in xs]
g = gcd(max(xs[0], xs[1]), min(xs[0], xs[1]))
for n in xs[2:]:
    g = gcd(max(g, n), min(g, n))
print(g)

Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

n, x = map(int, input().split())
a = [x] + list(map(int, input().split()))
a.sort(reverse=True)
b = []
for i in range(n):
  b.append(a[i]-a[i+1])
ans = b[0]
for j in range(1, n):
  ans = math.gcd(ans, b[i])
print(ans)

Failing test case input:
1 3
2 4 11

Expected output:
1


Actual output:
7


Fixed submission (verdict: Accepted):
import math

n, x = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
  b.append(abs(x-a[i]))
ans = b[0]
for j in range(1, n):
  ans = math.gcd(ans, b[j])
print(ans)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

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

if len(xs) > 1:
    m = min(xs)
    xs = [n - m for n in xs]
    g = gcd(max(xs[0], xs[1]), min(xs[0], xs[1]))
    for n in xs[2:]:
        g = gcd(max(g, n), min(g, n))
    print(g)
else:
    print(xs[0])


Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

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

xs.append(X)

m = min(xs)
xs = [n - m for n in xs]
g = gcd(max(xs[0], xs[1]), min(xs[0], xs[1]))
for n in xs[2:]:
    g = gcd(max(g, n), min(g, n))
print(g)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,X = map(int,input().split(' '))
L = list(map(int,input().split(' ')))

def algGCF(a,b):
  if a % b == 0:
    return b
  else:
    return algGCF(b,a%b)
GCF = abs(X-L[0])
for i in range(1,N):
  GCF = algGCF(GCF,X-L[i])
print(GCF)  

Failing test case input:
3 3
1 7 11

Expected output:
2

Actual output:
-2


Fixed submission (verdict: Accepted):
N,X = map(int,input().split(' '))
L = list(map(int,input().split(' ')))

def algGCF(a,b):
  if a % b == 0:
    return b
  else:
    return algGCF(b,a%b)
GCF = abs(X-L[0])
for i in range(1,N):
  GCF = algGCF(GCF,abs(X-L[i]))
print(GCF)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, X = map(int, input().split())
P = [int(_) for _ in input().split()]

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

D = 1
a = abs(P[0]-X)
for i in range(N-1):
    D = gcd(a, abs(P[i]-X))
    a = D

print(D)

Failing test case input:
1 0
1110000101

Expected output:
1110000101


Actual output:
1


Fixed submission (verdict: Accepted):
N, X = map(int, input().split())
P = [int(_) for _ in input().split()]

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

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

print(D)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,X=map(int,input().split())
x=list(map(int,input().split()))
L=sorted(x+[X])
if N==1:
	print(abs(X-x[0]))
else:
	LL=[L[i+1]-L[i] for i in range(N-1)]
	M=min(LL)
	while any([l%M!=0 for l in LL]):
		M=M-1
	print(M)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
from functools import reduce
N,X=map(int,input().split())
x=list(map(int,input().split()))
L=x+[X]
if N==1:
	print(abs(X-x[0]))
else:
	LL=[abs(L[i+1]-L[i]) for i in range(N)]
	def gcd(a,b):
		while b>0:
			a,b=b,a%b
		return a
	print(reduce(gcd,LL))
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

x.append(X)
x.sort()

D = []
for n in range(N-1):
    D.append(x[n+1]-x[n])
    
ans = 0
for d in D:
    ans = gcd(ans,d)
    
print(ans)

Failing test case input:
1 2
1010100000

Expected output:
1010099998


Actual output:
0


Fixed submission (verdict: Accepted):
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

x.append(X)
x.sort()

D = []
for n in range(N):
    D.append(x[n+1]-x[n])
    
ans = 0
for d in D:
    ans = gcd(ans,d)
        
print(ans)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())
l = list(map(int, input().split()))
sa = []
for i in range(n):
    t = abs(l[i] - x)
    sa.append(t)
sa = list(set(sa))
sa.sort()



q = len(sa)


def ans(q, p):
    for i in range(q):
        if sa[i] % p != 0:
            p = sa[1]-sa[0]
            break
    else:
        print(p)


ans(q, sa[0])


Failing test case input:
3 106
15 8 36

Expected output:
7


Actual output:

Fixed submission (verdict: Accepted):
def gcd(x, y):
    if y == 0:
        return x
    else:
        return (gcd(y, x % y))


n, x = map(int, input().split())
l = list(map(int, input().split()))
sa = []
for i in range(n):
    t = abs(l[i] - x)
    sa.append(t)
sa = list(set(sa))
sa.sort()

q = len(sa)
t = sa[0]

for i in range(1, q):
    t = gcd(t, sa[i])
print(t)

Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from math import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))

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

else:
  l=[]
  for i in range(N-1):
    l_=abs(x[i+1]-x[i])
    l.append(l_)
  
  ans=l[0]
  for i in range(1,len(l)):
    ans=gcd(ans,l[i])

  print(ans)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
from math import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))

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

else:
  l=[]
  for i in range(N):
    l_=abs(X-x[i])
    l.append(l_)
  
  ans=l[0]
  for i in range(1,len(l)):
    ans=gcd(ans,l[i])

  print(ans)
Problem: p03262
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

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

    min_num = 10**9
    for i in range(n):
        if abs(x_list[i]-x) <= min_num:
            min_num = abs(x_list[i]-x)

    print(min_num)


if __name__ == "__main__":
    main()


Failing test case input:
1 0
1010000000

Expected output:
1010000000


Actual output:
1000000000


Fixed submission (verdict: Accepted):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce


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

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

    
    list_s = []
    for i in range(n):
        list_s.append(abs(x_list[i]-x))
        
    ans = gcd_list(list_s)
    print(ans)


if __name__ == "__main__":
    main()

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
N,X=map(int,input().split())
x=list(map(int,input().split()))
kari=[]
for i in range(N):
    kari.append(abs(x[i]-X))

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

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
24


Fixed submission (verdict: Accepted):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
N,X=map(int,input().split())
x=list(map(int,input().split()))
kari=[]
for i in range(N):
    kari.append(abs(x[i]-X))
ans=gcd(min(kari),max(kari))
for i in range(N):
    ans=gcd(ans,kari[i])
print(ans)
Problem: p03262
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, x = inintm()
X = inintl()

if x not in X:
    X.append(x)
    n += 1

X.sort()

ans = 0
prev = X[0]

for i in range(1,n):
    ans = max(math.gcd(ans, X[i]-prev), ans)
    prev = X[i]

print(ans)


Failing test case input:
3 107
2 92 77

Expected output:
15


Actual output:
75


Fixed submission (verdict: Accepted):
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, x = inintm()
X = inintl()

if x not in X:
    X.append(x)
    n += 1

X.sort()

ans = X[1] - X[0]
prev = X[0]

for i in range(1,n):
    ans = min(math.gcd(ans, X[i]-prev), ans)
    prev = X[i]

print(ans)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
N, X = map(int, sys.stdin.buffer.readline().split())
x = list(map(int, sys.stdin.buffer.readline().split()))
x.append(X)
x.sort()
ans = 10**10
for i in range(N-1):
    tmp = x[i+1] - x[i]
    if tmp < ans:
        ans = tmp
print(ans)

Failing test case input:
1 1
1010001100

Expected output:
1010001099


Actual output:
10000000000


Fixed submission (verdict: Accepted):
import sys
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

n, X = map(int, sys.stdin.buffer.readline().split())
x = list(map(int, sys.stdin.buffer.readline().split()))
ans = abs(X - x[0])
for i in x[1:]:
    tmp = abs(X - i)
    if tmp % ans:
        ans = gcd(tmp, ans)
print(ans)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def p(a,b):
    x = max(a,b)
    y = min(a,b)
    while(y!=0):
        x = y
        y = x%y
    return x

N,X = map(int,input().split())
Y = [abs(X-int(i)) for i in input().split()]
Y.sort()
ans = Y[0]
for i in range(N-1):
    ans = p(ans,Y[i+1])
print(ans)

Failing test case input:
3 81
33 70 57

Expected output:
1


Actual output:
11


Fixed submission (verdict: Accepted):
def p(a,b):
    x = max(a,b)
    y = min(a,b)
    while(y!=0):
        x,y = y,x%y
    return x

N,X = map(int,input().split())
Y = [abs(X-int(i)) for i in input().split()]
ans = Y[0]
for i in range(N-1):
    ans = p(ans,Y[i+1])
print(ans)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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])

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

ans=a[0]
for j in range(1,len(a)-1):
    if a[j]%ans != 0:
        ans = gcd(ans,a[j])

print(ans)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
n,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
a=[]
for i in range(len(x)-1):
        a.append(x[i+1]-x[i])        

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

ans=a[0]
for j in a:
        if j%ans != 0:
                ans = gcd(j,ans)
print(ans)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,X = map(int,input().split())
x = list(map(int,input().split()))
a=[]
for i in x:
        a.append(abs(i-X))

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

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

Failing test case input:
3 81
33 3 57

Expected output:
6


Actual output:
1


Fixed submission (verdict: Accepted):
n,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
a=[]
for i in range(len(x)-1):
        a.append(x[i+1]-x[i])        

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

ans=a[0]
for j in a:
        if j%ans != 0:
                ans = gcd(j,ans)
print(ans)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,X=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    B.append(A[i]-X)

a=B[0]

for j in range(1,N):
    b=B[j]
    if b<a:
        a,b=b,a
    while b!=0:
        a,b=b,a%b
print(a)

Failing test case input:
3 81
33 73 57

Expected output:
8


Actual output:
-8


Fixed submission (verdict: Accepted):
N,X=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    B.append(abs(A[i]-X))


a=B[0]

for j in range(1,N):
    b=B[j]
    if b<a:
        a,b=b,a
    while b!=0:
        a,b=b,a%b
print(a)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

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

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

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

ans = -1
temp = gcd(abs(X - x[1]), abs(X - x[0]))
for i in range(2, n):
    temp = gcd(temp, abs(X - x[i]))
    if ans < temp:
        ans = temp
print(ans)


Failing test case input:
1 3
1 5 11

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

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

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


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

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

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import functools
n, x = map(int,input().split())
place = list(map(int,input().split()))
place.append(x)
place.sort()
if n == 1:
    print(place[1] - place[0])
    exit()

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

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

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

print(gcd(k))

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


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

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

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

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

print(gcd(k))

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

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

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

for i in range(len(t)):
    t[i] = abs(t[i]-x)

max = max(t)
min = min(t)

print(gcd(max,min))

Failing test case input:
3 81
33 42 57

Expected output:
3


Actual output:
24


Fixed submission (verdict: Accepted):
import math

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

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

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

print(ans)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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

if __name__ == '__main__':
    main()

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
15


Fixed submission (verdict: Accepted):

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

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

def lcm(a,b):
    return a*b

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

Failing test case input:
3 81
33 42 57

Expected output:
3


Actual output:
9


Fixed submission (verdict: Accepted):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

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

if __name__ == "__main__":
    n,x = map(int,input().split())
    X = list(map(int,input().split()))
    X.sort()
    a = bisect.bisect_left(X,x)
    X.insert(a,x)
    ans = []
    for i in range(1,len(X)):
        diff = X[i] - X[i-1]
        ans.append(diff)
    d = ans[0]
    for i in range(1,len(ans)):
        d = gcd(d,ans[i])
    print(d)
Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

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

absx = [abs(X - xx) for xx in x]
absx.sort()

divx0 = [absx[0]]

for i in range(math.ceil(math.sqrt(absx[0])), 0, -1):
    if absx[0] % i == 0:
        divx0.append(i)

for dx0 in divx0:
    isok = True
    for xx in absx:
        if xx % dx0 != 0:
            isok = False
            break

    if isok:
        print(dx0)
        exit()

Failing test case input:
3 81
33 3 57

Expected output:
6


Actual output:
3


Fixed submission (verdict: Accepted):
import math

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

absx = [abs(X - xx) for xx in x]
absx.sort()

divx0 = []

for i in range(math.ceil(math.sqrt(absx[0])), 0, -1):
    if absx[0] % i == 0:
        divx0.append(i)

t = []
for x in divx0:
    t.append(x)
    t.append(absx[0] 

divx0 = t
divx0.sort(reverse=True)

for dx0 in divx0:
    isok = True
    for xx in absx:
        if xx % dx0 != 0:
            isok = False
            break

    if isok:
        print(dx0)
        exit()

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
1 1
0001001000

Expected output:
1000999


Actual output:

Fixed submission (verdict: Accepted):
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 = []
    

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

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = -1
for i in range(1, len(c)):
    if d == -1:
        d = c[i] - c[i-1]
    elif c[i] - c[i-1] < d:
        d = c[i] - c[i-1]
print(d)


Failing test case input:
3 81
33 3 57

Expected output:
6


Actual output:
24


Fixed submission (verdict: Accepted):
def c_gcd(x, y):
    if y == 0:
        return x
    else:
        return c_gcd(y, x % y)


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = -1
for i in range(1, len(c)):
    if i == 1:
        d = c[i] - c[i-1]
    else:
        d = c_gcd(c[i] - c[i-1], d)
print(d)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())
a = [y-x for y in map(int, input().split())]


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

ret = a[0]

for i in range(1, n):
    ret = gcd(ret, a[i])
print(ret)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
-64


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())
a = [abs(y-x) for y in map(int, input().split())]


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

ret = a[0]

for i in range(1, n):
    ret = gcd(ret, a[i])
print(ret)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, X = [int(x) for x in input().split()]
xn = sorted(list(set([abs(int(x) - X) for x in input().split()])))
def gcd(a, b):
  if b % a == 0:
    return a
  return gcd(b % a, a)

if N == 1:
  print(xn[0])
else:
  n = (gcd(xn[0], xn[1]))
  for x in xn:
    if x % n != 0:
      print(1)
      exit()
  else:
    print(n)

Failing test case input:
3 81
33 3 57

Expected output:
6


Actual output:
1


Fixed submission (verdict: Accepted):
N, X = [int(x) for x in input().split()]
xn = sorted(list(set([abs(int(x) - X) for x in input().split()])))
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a % b)

if N == 1:
  print(xn[0])
else:
  n = (gcd(xn[0], xn[1]))
  for x in xn[2:]:
    n = gcd(x, n)
  else:
    print(n)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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())) + [x]
X.sort()
Dif_X = []
for i in range(n):
    Dif_X += [X[i+1]-X[i]]
gcd_Dif_X = Dif_X[0]
for i in range(n-1):
    gcd_Dif_X = gcd(gcd_Dif_X,Dif_X[i])
print(gcd_Dif_X)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
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())) + [x]
X.sort()
Dif_X = []
for i in range(n):
    Dif_X += [X[i+1]-X[i]]
gcd_Dif_X = Dif_X[0]
for i in range(n):
    gcd_Dif_X = gcd(gcd_Dif_X,Dif_X[i])
print(gcd_Dif_X)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,X=map(int,input().split())
x = list(map(int,input().split()))
if not X in x:
    x.append(X)
x.sort()
d = []
for i in range(len(x)-1):
    d.append( x[i+1] - x[i] )

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

g = d[0]
lcm = d[0]
for i in range( len(d)-1 ):
    lcm = g * d[i+1] 
print(lcm)



Failing test case input:
3 81
33 105 57

Expected output:
24

Actual output:
576


Fixed submission (verdict: Accepted):
N,X=map(int,input().split())
x = list(map(int,input().split()))
if not X in x:
    x.append(X)
x.sort()
d = []
for i in range(len(x)-1):
    d.append( x[i+1] - x[i] )

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

g = d[0]
for i in range( len(d)-1 ):
    g = GCD(g,d[i+1])
print(g)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,X = map(int,input().split())
x = list(map(int,input().split()))

x.append(X)
x.sort()
A = []

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

def gcd(x,y):
    X = max(x,y)
    Y = min(x,y)
    if Y == 0:
        return X
    else:
        return gcd(Y,X%Y)

keepgcd = 0
maxgcd = 10**5
B = []

if N >= 2:
   for i in range(N-2):
       B.append(gcd(A[i+1],A[i]))
       print(min(B))
else:
    print(max(x)-min(x))

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
N,X = map(int,input().split())
x = list(map(int,input().split()))

x.sort()

def gcd(x,y):
    X = max(x,y)
    Y = min(x,y)
    if Y == 0:
        return X
    else:
        return gcd(Y,X%Y)

keepgcd = 0
maxgcd = 10**9

if N >= 2:
   for i in range(N-1):
       keepgcd = gcd(abs(X-x[i+1]),abs(X-x[i]))
       if maxgcd > keepgcd:
          maxgcd = keepgcd
   print(maxgcd)
else:
    print(max(x[0],X)-min(x[0],X))

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def c_gcd(x, y):
    if y == 0:
        return x
    else:
        return c_gcd(y, x % y)


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = -1
for i in range(1, len(c)):
    if d == -1:
        d = c[i] - c[i-1]
    elif c[i] - c[i-1] < d:
        d = c_gcd(c[i] - c[i-1], d)
print(d)


Failing test case input:
3 81
33 42 57

Expected output:
3


Actual output:
9


Fixed submission (verdict: Accepted):
def c_gcd(x, y):
    if y == 0:
        return x
    else:
        return c_gcd(y, x % y)


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = -1
for i in range(1, len(c)):
    if i == 1:
        d = c[i] - c[i-1]
    else:
        d = c_gcd(c[i] - c[i-1], d)
print(d)

Problem: p03262
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,x = map(int,input().split())
lista = [int(i) for i in input().split()]
lista.append(x)
lista.sort()
def gcd(a,b):
    if a<b:
        a,b = b,a
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)

ans = lista[1]-lista[0]
for i in range(1,n):
    ans = gcd(ans,lista[i]-lista[i-1])

print(ans)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
n,x = map(int,input().split())
lista = [int(i) for i in input().split()]
lista.append(x)
lista.sort()
def gcd(a,b):
    if a<b:
        a,b = b,a
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)

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

print(ans)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
1 2
1010000000

Expected output:
1009999998


Actual output:
0


Fixed submission (verdict: Accepted):
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])

Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import bisect
N,X = map(int, input().split())
x = sorted(map(int, input().split()))
bisect.insort(x,X)
ans = [x[i+1]-x[i] for i in range(N)] 
if N ==1:
    print(x[1]-x[0])
else:
    print(min(ans))

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
15


Fixed submission (verdict: Accepted):
import bisect
import math
from functools import reduce

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

N,X = map(int, input().split())
x = sorted(map(int, input().split()))
bisect.insort(x,X)
ans = [x[i+1]-x[i] for i in range(N)] 
if N ==1:
    print(x[1]-x[0])
else:
    print(gcd(ans))

Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def resolve():
    _, X = [int(i) for i in input().split()]
    xx = [int(i) for i in input().split()]
    ans = float("inf")
    for x in xx:
        ans = min(ans, abs(X - x))
    print(ans)


if __name__ == "__main__":
    resolve()


Failing test case input:
3 81
6 11 16

Expected output:
5


Actual output:
65


Fixed submission (verdict: Accepted):
def resolve():
    from math import gcd
    _, X = [int(i) for i in input().split()]
    xx = [int(i) for i in input().split()]
    ans = abs(X - xx[0])
    for x in xx:
        ans = gcd(ans, abs(X - x))
    print(ans)


if __name__ == "__main__":
    resolve()

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a, b):
    while b:
        a, b = b, a % b
        return a

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

dist = [abs(i - X) for i in x]

ans = dist[0]

for i in range(N):
    ans = gcd(ans, dist[i])

print(ans)

Failing test case input:
3 81
33 73 57

Expected output:
8


Actual output:
24


Fixed submission (verdict: Accepted):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

dist = [abs(i - X) for i in x]

ans = dist[0]

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

print(ans)
Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    n, s = map(int, input().split())
    xs = sorted(list(map(int, input().split())))

    ans = float("inf")
    for x in xs:
        if x - s > 0:
            ans = min(ans, x-s)
        if s - x > 0:
            ans = min(ans, s-x)
    print(ans)


if __name__ == "__main__":
    main()


Failing test case input:
3 106
15 8 36

Expected output:
7


Actual output:
70


Fixed submission (verdict: Accepted):
import math


def main():
    n, s = map(int, input().split())
    xs = sorted(list(map(int, input().split())))

    for i in range(n):
        xs[i] = abs(xs[i] - s)

    for i in range(1, n):
        xs[i] = math.gcd(xs[i], xs[i-1])

    print(xs[n-1])


if __name__ == "__main__":
    main()

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
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)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, X = map(int, input().split())
x_list = list(map(int, input().split()))


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

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


D = abs(x_list[0]-X)
for i in range(1, N):
    D = gcd(D, abs(x_list[i-1]-x_list[i]))

print(D)


Failing test case input:
1 3
1 5 11

Expected output:
2


Actual output:
-2


Fixed submission (verdict: Accepted):
N, X = map(int, input().split())
x_list = list(map(int, input().split()))

x_list.sort()
def gcd(a, b):
    if a >= b:
        return a if b == 0 else gcd(b, a % b)
    else:
        return gcd(b, a)


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

print(D)

Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from functools import reduce
from math import gcd

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


Failing test case input:
1 -1
0000000100

Expected output:
101


Actual output:
[101]
101


Fixed submission (verdict: Accepted):
from functools import reduce
from math import gcd

n, x = map(int, input().split())
a = [abs(int(A) - x) for A in input().split()]
a.sort()
print(reduce(gcd, a))
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)

n, x = map(int,input().split())
arr = list(map(int,input().split()))
diff = []
arr.sort()
g = 0
for i in range(n-1):
    diff.append(abs(arr[i]-arr[i+1]))
for item in diff:
    g = gcd(g,item)
print(g)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)

n, x = map(int,input().split())
arr = list(map(int,input().split()))
diff = []
arr.sort()
g = abs(arr[0] - x)
for i in range(1,n):
    g = gcd(g, abs(arr[i] - x))
print(g)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N, X = map(int, input().split())
    dx = [abs(X - x) for x in map(int, input().split())]
    ans = 10 ** 9 - X
    for i in range(N - 1):
        nm = max(dx[i], dx[i + 1])
        dm = min(dx[i], dx[i + 1])
        while True:
            mod = nm % dm
            if mod == 0:
                break
            nm = dm
            dm = mod
        ans = min(ans, dm)
    print(ans)


main()


Failing test case input:
1 -1
1011001010

Expected output:
1011001011


Actual output:
1000000001


Fixed submission (verdict: Accepted):
def main():
    N, X = map(int, input().split())
    dx = [abs(X - x) for x in map(int, input().split())]
    if N == 1:
        ans = dx[0]
    else:
        ans = 10 ** 9
    for i in range(N - 1):
        nm = max(dx[i], dx[i + 1])
        dm = min(dx[i], dx[i + 1])
        while True:
            mod = nm % dm
            if mod == 0:
                break
            nm = dm
            dm = mod
        ans = min(ans, dm)
    print(ans)


main()

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
N,X=map(int,input().split())
x=list(map(int,input().split()))
kari=[]
for i in range(N):
    kari.append(abs(x[i]-X))
K=min(kari)
for i in range(N):
    ans=gcd(K,kari[i])
print(ans)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
24


Fixed submission (verdict: Accepted):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
N,X=map(int,input().split())
x=list(map(int,input().split()))
kari=[]
for i in range(N):
    kari.append(abs(x[i]-X))
ans=gcd(min(kari),max(kari))
for i in range(N):
    ans=gcd(ans,kari[i])
print(ans)
Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd





def solve():
    n, g = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    if n == 1:
        print(abs(a[0]-g))
        return
    a.append(g)
    a.sort()
    b = []
    for i in range(1, n):
        b.append(a[i]-a[i-1])
    g = b[-1]
    for e in b:
        g = gcd(e, g)
    print(g)
    




        

t = 1

for case in range(1,t+1):
    ans = solve()





Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
5


Fixed submission (verdict: Accepted):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd





def solve():
    n, g = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    if n == 1:
        print(abs(a[0]-g))
        return
    
    a.append(g)
    a.sort()
    b = []
    for i in range(1, n+1):
        b.append(a[i]-a[i-1])
    g = b[-1]
    for e in b:
        g = gcd(e, g)
    print(g)
    




        

t = 1

for case in range(1,t+1):
    ans = solve()

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

Failing test case input:
1 3
1 5 11

Expected output:
2


Actual output:
-2


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

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())
X = list(map(int, input().split()))

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

    else:
        return gcd(b, a % b)

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

else:
    output = gcd(abs(x - X[0]), abs(X[0] - X[1]))

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

print(output)


Failing test case input:
1 3
2 5 11

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())
X = list(map(int, input().split()))

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

    else:
        return gcd(b, a % b)

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

else:
    output = gcd(abs(x - X[0]), abs(X[0] - X[1]))

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

print(output)
Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x=map(int,input().split())
l=list(map(int,input().split()))

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

ans=1
for i in (2,min(kouho)):
  mod = x%i
  signal=1
  for j in range(n):
    if l[j]%i!=mod:
      signal=0
  if signal==1:
    ans=i
print(ans)


Failing test case input:
3 106
15 8 36

Expected output:
7


Actual output:
1


Fixed submission (verdict: Accepted):
n,x=map(int,input().split())
l=list(map(int,input().split()))

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

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

ans=kouho[0]

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

Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, x = map(int, input().split())
lis = list(map(int, input().split()))

ans = 10**9 + 7
ans2 = 0

for i in range(n):
    ans = min(ans, abs(x-lis[i]))
    ans2 = max(ans2, abs(x-lis[i]))

print(min(ans, ans2))

Failing test case input:
1 0
1110001111

Expected output:
1110001111


Actual output:
1000000007


Fixed submission (verdict: Accepted):
import math

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

nlis = []

for i in range(n):
    nlis.append(abs(lis[i]- x))

ans = nlis[0]

for j in range(1, n):
    ans = math.gcd(ans, nlis[j])

print(ans)

Problem: p03262
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, x=map(int, input().split())
l=list(map(int, input().split()))
if len(l)==1:
  print(l[0]-1)
  exit()
import math
ans=l[1]-l[0]
for i in range(n-1):
  ans=math.gcd(ans, l[i+1]-l[i])
print(ans)


Failing test case input:
1 0
1011001010

Expected output:
1011001010


Actual output:
1011001009


Fixed submission (verdict: Accepted):
n, x=map(int, input().split())
l=list(map(int, input().split()))
if len(l)==1:
  print(abs(l[0]-x))
  exit()
import math
ans=x-l[0]
for i in range(n-1):
  ans=math.gcd(ans, l[i+1]-l[i])
print(ans)

Problem: p03262
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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

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

Failing test case input:
1 3
2 5 11

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):

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

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