Problem p03262 (python)

Fixed submission:
def gcd(a,b) :
    if b>0 :
        return gcd(b,a % b)
    elif b == 0:
        return a


N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = []
    for i in range(N):
        xlen.append(abs(x[i] - X))
        #print(xlen[i])
    ans = xlen[0]
    for i in range(1,N):
        ans = gcd(ans,xlen[i])
        #print(ans)
    print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b) :
    if b>0 :
        return gcd(b,a % b)
    elif b == 0:
        return a


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

Buggy submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = []
    for i in range(N):
        xlen.append(x[i] - X)
    ans = xlen[0]
    for i in range(1,N):
        ans = math.gcd(ans,xlen[i])
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1] - X)
    ans = xlen[0]
    for i in range(1,N):
        ans = math.gcd(ans,xlen[i])
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(1,N):
        ans = math.gcd(ans,xlen[i])
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

Buggy submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-1):
        ans = math.gcd(ans,xlen[i+1])
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-1):
        ans = math.gcd(ans,xlen[i+1])
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-2):
        ans = math.gcd(ans,xlen[i+1])
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-2):
        ans = math.gcd(ans,xlen[i+1])
    print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b > 0:
        return gcd(b,a%b)
    elif b == 0:
        return a

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-2):
        ans = gcd(ans,xlen[i+1])
    #print(ans)
    print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b > 0:
        return gcd(b,a%b)
    elif b == 0:
        return a

N,X = map(int,input().split())
x = list(map(int,input().split()))
xlen = [abs(x[0]-X)]
for i in range(N-1):
    xlen.append(x[i+1]- x[i])
ans = xlen[0]
for i in range(N-2):
    ans = gcd(ans,xlen[i+1])
    #print(ans)
print(ans)