Problem p03106 (python)

Fixed submission:
def gcd(t):
    b,a=sorted(t)
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m
a,b,k=(int(x) for x in input().split())
g=gcd((a,b))
cd=[]
for i in range(g+1)[::-1]:
    if i==0:
        break
    if g%i==0:
        cd.append(i)
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
def gcd(t):
    try:
        b,a=sorted(t)
        while True:
            m=a%b
            if m==0:
                return b
            a=b;b=m
    except:
        return 1

try:
    a,b,k=(int(x) for x in input().split())
    g=gcd((a,b))
    cd=[]
    i=g
except:
    print(1)
while True:
    try:
        if g%i==0:
            cd.append(i)
            i=i//2
            if i==0:
                break
        else:
            i-=1
    except:
        break
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
def gcd(t):
    try:
        b,a=sorted(t)
        while True:
            m=a%b
            if m==0:
                return b
            a=b;b=m
    except:
        return 1

a,b,k=(int(x) for x in input().split())
g=gcd((a,b))
cd=[]
i=g
while True:
    try:
        if g%i==0:
            cd.append(i)
            i=i//2
            if i==0:
                break
        else:
            i-=1
    except:
        break
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
def gcd(t):
    b,a=sorted(t)
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m

a,b,k=(int(x) for x in input().split())
g=gcd((a,b))
cd=[]
i=g
while True:
    try:
        if g%i==0:
            cd.append(i)
            i=i//2
            if i==0:
                break
        else:
            i-=1
    except:
        break
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
def gcd(_a,_b):
    b,a=sorted((_a, _b))
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m

a,b,k=(int(x) for x in input().split())
g=gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==0:
            break
    else:
        i-=1
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
def gcd(_a,_b):
    b,a=sorted((_a, _b))
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m

a,b,k=(int(x) for x in input().split())
g=gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==0:
            break
    else:
        i-=1
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
def gcd(_a,_b):
    b,a=sorted((_a, _b))
    if b==0:
        return 0
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m

a,b,k=(int(x) for x in input().split())
g=gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==1 or i==0:
            break
    else:
        i-=1
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
def gcd(_a,_b):
    a=max([_a, _b]); b=min([_a, _b])
    while True:
        if not b==0:
            m=a%b
        if m==0:
            return b
        a=b

a,b,k=(int(x) for x in input().split())
g=gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==1 or i==0:
            break
    else:
        i-=1
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
def gcd(_a,_b):
    a=max([_a, _b]); b=min([_a, _b])
    while True:
        m=a%b
        if m==0:
            return b
        a=b

a,b,k=(int(x) for x in input().split())
g=gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==1 or i==0:
            break
    else:
        i-=1
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
import math
a,b,k=(int(x) for x in input().split())
g=math.gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==1 or i==0:
            break
    else:
        i-=1
print(cd[k-1])