Problem p03262 (python)

Fixed submission:
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

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

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

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

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

print(abs(gcd_t(gcd_list)))

Buggy submission (verdict: Runtime Error):
def gcd_t(s):
    if(len(s)==1):    return s[0]
    else:
        if(len(s)==2):    return gcd(s[0],s[1])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
gcd_list=[]
for i in range(N):
    gcd_list.append(X-x[i])
    
print(abs(gcd_t(gcd_list)))

Buggy submission (verdict: Runtime Error):
def gcd_t(s):
    if(len(s)==1):    return s[0]
    if(s[-2]==0):    return s[-1]
    else:
        if(len(s)==2):
            return gcd(s[-1],s[-2])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
gcd_list=[]
for i in range(N):
    gcd_list.append(X-x[i])
    
print(abs(gcd_t(gcd_list)))

Buggy submission (verdict: Runtime Error):
def gcd_t(s):
    if(len(s)==1):    return s[0]
    if(s[-2]==0):    return s[-1]
    else:
        if(len(s)==2):
            return gcd(s[0],s[1])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
gcd_list=[]
for i in range(N):
    gcd_list.append(X-x[i])
    
print(abs(gcd_t(gcd_list)))

Buggy submission (verdict: Runtime Error):
def gcd_t(s):
    if(len(s)==1):    return s[0]
    if(s[-2]==0):    return s[-1]
    else:
        if(len(s)==2):
            return gcd(s[0],s[1])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

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

Buggy submission (verdict: Runtime Error):
def gcd_t(s):
    if(len(s)==1):    return s[0]
    if(s[-2]==0):    return s[0]
    else:
        if(len(s)==2):
            return gcd(s[0],s[1])
        m=gcd(s[-1],s[-2])
        s.pop()
        s.pop()
        s.append(m)
        return gcd_t(s)
    
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

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