Problem p03262 (python)

Fixed submission:
def gcd3(x,y):
    if x>=y:
        if x%y==0:
            return y
        else:
            return gcd3(y,x%y)
    else:
        if y%x==0:
            return x
        else:
            return gcd3(x,y%x)
def gcd2(x4):
    if len(x4)>2:
        return gcd3(gcd2(x4[:len(x4)//2]),gcd2(x4[len(x4)//2:]))
    elif len(x4) ==2:
        return gcd3(x4[0],x4[1])
    else:
        return x4[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x3=[]
for i in range(len(x)-1):
    x3.append(abs(x[i+1]-x[i]))
print(gcd2(x3))

Buggy submission (verdict: Runtime Error):
def gcd3(x,y):
    if x>=y:
        if x%y==0:
            return y
        else:
            return gcd3(y,x%y)
    else:
        if y%x==0:
            return x
        else:
            return gcd3(x,y%x)
def gcd2(x4):
    if len(x4)>2:
        return gcd2([gcd3(x4[0],x4[1]),]+x4[2:])
    elif len(x4) ==2:
        return gcd3(x4[0],x4[1])
    else:
        return x4[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x3=[]
for i in range(len(x)-1):
    x3.append(abs(x[i+1]-x[i]))
print(gcd2(x3))

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
    if x>=y:
        if x%y==0:
            return y
        else:
            return gcd(y,x%y)
    else:
        if y%x==0:
            return x
        else:
            return gcd(x,y%x)
def gcd2(x4):
    if len(x4)>2:
        return gcd2([gcd(x4[0],x4[1]),]+x4[2:])
    elif len(x4) ==2:
        return gcd(x4[0],x4[1])
    else:
        return x4[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x3=[]
for i in range(len(x)-1):
    x3.append(abs(x[i+1]-x[i]))
print(gcd2(x3))

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
    if x>=y:
        if x%y==0:
            return y
        else:
            return gcd(y,x%y)
    else:
        if y%x==0:
            return x
        else:
            return gcd(x,y%x)
def gcd2(x4):
    if len(x4)>2:
        return gcd2([gcd(x4[0],x4[1]),]+x4[2:])
    elif len(x4) ==2:
        return gcd(x4[0],x4[1])
    else:
        return x4[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x3=[]
for i in range(len(x)-1):
    x3.append(abs(x[i+1]-x[i]))
print(gcd2(x3))

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
    if x>=y:
        if x%y==0:
            return y
        else:
            return gcd(y,x%y)
    else:
        if y%x==0:
            return x
        else:
            return gcd(x,y%x)
def gcd2(x3):
    if len(x3)>2:
        return gcd2([gcd(x3[0],x3[1]),]+x3[2:])
    elif len(x3) ==2:
        return gcd(x3[0],x3[1])
    else:
        return x3[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x2=sorted(x)
x3=[]
for i in range(len(x2)-1):
    x3.append(x2[i+1]-x2[i])
print(gcd2(x3))

Buggy submission (verdict: Runtime Error):
import math
def gcd2(x3):
    if len(x3)>2:
        return gcd2([math.gcd(x3[0],x3[1]),]+x3[2:])
    elif len(x3) ==2:
        return math.gcd(x3[0],x3[1])
    else:
        return x3[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x2=sorted(x)
x3=[]
for i in range(len(x2)-1):
    x3.append(x2[i+1]-x2[i])
print(gcd2(x3))