Problem p03262 (python)

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

import numpy as np
n, x = map(int, input().split())
a = np.abs(np.array(list(map(int, input().split())))-x)

if(a.shape[0] == 1):
	r = a[0]
else:
	r = gcd(a[0], a[1])
	for i in range(n-2):
		r = gcd(r, a[i+2])
print(r)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
	if(a > b):
		a -= b
		return gcd(a, b)
	elif(a < b):
		b -= a
		return gcd(a, b)
	else:
		return a

import numpy as np
n, x = map(int, input().split())
a = np.abs(np.array(list(map(int, input().split())))-x)

if(a.shape[0] == 1):
	r = a[0]
else:
	r = gcd(a[0], a[1])
	for i in range(n-2):
		r = gcd(r, a[i+2])
print(r)

Buggy submission (verdict: Runtime Error):
# your code goes here
def gcd(a, b):
	if(a > b):
		a -= b
		return gcd(a, b)
	elif(a < b):
		b -= a
		return gcd(a, b)
	else:
		return int(a)

import numpy as np

n, x = map(int, input().split())
buf = input().split()
xx = np.zeros(n+1)
for i in range(n):
	xx[i] = int(buf[i])
xx[-1] = x
xx.sort()
for i in range(n):
	xx[n-i] -= xx[n-1-i]
	
r = xx[1]
for i in range(n-1):
	if(xx[i+2] % r != 0):
		r = gcd(r, xx[i+2])
print(int(r))

Buggy submission (verdict: Runtime Error):
# your code goes here
def gcd(a, b):
	if(a > b):
		a -= b
		return gcd(a, b)
	elif(a < b):
		b -= a
		return gcd(a, b)
	else:
		return int(a)

import numpy as np

n, x = map(int, input().split())
buf = input().split()
xx = np.zeros(n+1)
for i in range(n):
	xx[i] = int(buf[i])
xx[-1] = x
xx.sort()
for i in range(n):
	xx[n-i] -= xx[n-1-i]
	
r = xx[1]
for i in range(n-1):
	if(xx[i+2] % r != 0):
		r = gcd(r, xx[i+2])
print(int(r))

Buggy submission (verdict: Runtime Error):
# your code goes here
def gcd(a, b):
	if(a > b):
		a -= b
		return gcd(a, b)
	elif(a < b):
		b -= a
		return gcd(a, b)
	else:
		return int(a)

import numpy as np

n, x = map(int, input().split())
buf = input().split()
xx = np.zeros(n+1)
for i in range(n):
	xx[i] = int(buf[i])
xx[-1] = x
xx.sort()
for i in range(n):
	xx[n-i] -= xx[n-1-i]
	
if(xx.shape[0] == 2):
	r = xx[1]
else:
	r = gcd(xx[1], xx[2])
	for i in range(n-2):
		r = gcd(r, xx[i+3])
print(int(r))
	
#print(xx)

Buggy submission (verdict: Runtime Error):
# your code goes here
def gcd(a, b):
	if(a > b):
		a -= b
		return gcd(a, b)
	elif(a < b):
		b -= a
		return gcd(a, b)
	else:
		return int(a)

import numpy as np

n, x = map(int, input().split())
buf = input().split()
xx = np.zeros(n+1)
for i in range(n):
	xx[i] = int(buf[i])
xx[-1] = x
xx.sort()
for i in range(n):
	xx[n-i] -= xx[n-1-i]
	
if(xx.shape[0] == 2):
	r = xx[1]
else:
	r = gcd(xx[1], xx[2])
	for i in range(n-2):
		r = gcd(r, xx[i+3])
print(r)
	
#print(xx)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
	if(a > b):
		a -= b
		return gcd(a, b)
	elif(a < b):
		b -= a
		return gcd(a, b)
	else:
		return a

import numpy as np
#import math
n, x = map(int, input().split())
buf = input().split()
X = np.abs(np.array([int(buf[i]) for i in range(n)]) - x)
#print(X)
if(X.shape[0] == 1):
	r = X[0]
else:
	r = gcd(X[0], X[1])
	for i in range(n-2):
		r = gcd(r, X[i+2])
print(r)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
n, x = map(int, input().split())
buf = input().split()
X = np.abs(np.array([int(buf[i]) for i in range(n)]) - x)
#print(X)
if(X.shape[0] == 1):
	r = X[0]
else:
	r = math.gcd(X[0], X[1])
	for i in range(n-2):
		r = math.gcd(r, X[i+2])
print(r)