Buggy python submission (verdict: Runtime Error):
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (A % i == 0 and B % i == 0):
        if (i>=j):
            break
        j=int(A/i)
        f.append(i)
        if (i!=j and B % j == 0):
            f.append(j)
f.sort(reverse=True)
if len(f)==0:
    print(1)
else:
    print(f[K-1])



Fixed submission:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
k=0
for i in reversed(range(1,A+1)):
    if (A % i == 0 and B % i == 0):
        k+=1
    if (k==K):
        print(i)
        break

Buggy python submission (verdict: Runtime Error):
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (A % i == 0 and B % i == 0):
        if (i>=j):
            break
        j=int(A/i)
        f.append(i)
        if (i!=j and B % j == 0):
            f.append(j)
f.sort(reverse=True)
if A==1:
    print(1)
else:
    print(f[K-1])



Fixed submission:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
k=0
for i in reversed(range(1,A+1)):
    if (A % i == 0 and B % i == 0):
        k+=1
    if (k==K):
        print(i)
        break

Buggy python submission (verdict: Runtime Error):
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (i>=j):
        break
    if (A % i == 0 and B % i == 0):
        j=int(A/i)
        f.append(i)
        if (B % j == 0):
            f.append(j)
f.sort(reverse=True)
if A==1:
    print(1)
else:
    print(f[K-1])




Fixed submission:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
k=0
for i in reversed(range(1,A+1)):
    if (A % i == 0 and B % i == 0):
        k+=1
    if (k==K):
        print(i)
        break

Buggy python submission (verdict: Runtime Error):
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (i>=j):
        break
    if (A % i == 0 and B % i == 0):
        j=int(A/i)
        f.append(i)
        if (B % j == 0):
            f.append(j)
f.sort()
if A==1:
    print(1)
else:
    print(f[K-1])




Fixed submission:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
k=0
for i in reversed(range(1,A+1)):
    if (A % i == 0 and B % i == 0):
        k+=1
    if (k==K):
        print(i)
        break

Buggy python submission (verdict: Runtime Error):
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (i>=j):
        break
    if (A % i == 0 and B % i == 0):
        j=int(A/i)
        f.append(i)
        if (B % j == 0):
            f.append(j)
if A==1:
    print(1)
else:
    print(f[K-1])




Fixed submission:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
k=0
for i in reversed(range(1,A+1)):
    if (A % i == 0 and B % i == 0):
        k+=1
    if (k==K):
        print(i)
        break

Buggy python submission (verdict: Runtime Error):
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
k=0
for i in range(1,A):
    if (i>=j):
        break
    if (A % i == 0 and B % i == 0):
        j=int(A/i)
        f.insert(k,i)
        if (B % j == 0):
            f.insert(k,j)
        k+=1
if A==1:
    print(1)
else:
    print(f[K-1])




Fixed submission:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
k=0
for i in reversed(range(1,A+1)):
    if (A % i == 0 and B % i == 0):
        k+=1
    if (k==K):
        print(i)
        break