Problem p03262 (python)

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

Buggy submission (verdict: Runtime Error):
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(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)

Buggy submission (verdict: Runtime Error):
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(m,n):
        while n:
                m,n = n,m%n
        return m

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

Buggy submission (verdict: Runtime Error):
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(m,n):
        while n!=0:
                m,n = n,m%n
        return m

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

Buggy submission (verdict: Runtime Error):
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(m,n):
        while n!=0:
                m,n = n,m%n
        return m

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

Buggy submission (verdict: Runtime Error):
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(m,n):
        while n!=0:
                s = m%n
                m = n
                n = s
        return m

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

Buggy submission (verdict: Runtime Error):
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):
        gcd(n,m%n)
        if m%n == 0:
                return n

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

Buggy submission (verdict: Runtime Error):
import math
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])
a.sort()
def gcd(m,n):
    while n:
        m,n=n,m%n
    return m
ans=a[0]
for j in range(1,len(a)):
    if a[j]%a[0]!=0:
        ans=math.gcd(ans,a[j])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
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])
a.sort()
ans=a[0]
for j in range(1,len(a)):
    if a[j]%a[0]!=0:
        ans=math.gcd(ans,a[j])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
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])
a.sort()
ans=a[0]
for j in range(1,len(a)):
    if a[j]>0:
        ans=math.gcd(ans,a[j])
    else:
        ans=ans
print(ans)

Buggy submission (verdict: Runtime Error):
import math
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])
a.sort()
ans=a[0]
for j in range(1,len(a)):
    if a[j]%a[0]!=0:
        ans=math.gcd(ans,a[j])
    else:
        ans=ans
print(ans)

Buggy submission (verdict: Runtime Error):
import math
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])
a.sort()
ans=a[0]
for j in range(1,len(a)):
    if a[j]%a[0]!=0:
        ans=math.gcd(ans,a[j])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
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])
s=[]
for j in range(len(a)-1):
    s.append(math.gcd(a[j],a[j+1]))
print(min(s))

Buggy submission (verdict: Runtime Error):
import math
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])
s=[]
for j in range(len(a)-1):
    s.append(math.gcd(a[j],a[j+1]))
print(min(s))