Problem:
 Score : 200 points    Problem Statement You are given positive integers A and B .  Find the K -th largest positive integer that divides both A and B .  The input guarantees that there exists such a number.      Constraints  All values in input are integers.  1 \leq A, B \leq 100  The K -th largest positive integer that divides both A and B exists.  K \geq 1         Input Input is given from Standard Input in the following format:  A  B  K       Output Print the K -th largest positive integer that divides both A and B .        Sample Input 1 8 12 2      Sample Output 1 2  Three positive integers divides both 8 and 12 : 1, 2 and 4 .
Among them, the second largest is 2 .       Sample Input 2 100 50 4      Sample Output 2 5       Sample Input 3 1 1 1      Sample Output 3 1

Solution (Python):
def s(n):
    ls=[]
    for i in range(1,n+1):
        if n%i==0:
            ls.append(i)
    return ls

ans=[]
a,b,k=map(int,input().split())
for i in s(a):
    if i in s(b):
        ans.append(i)

print(ans[-k])

Solution (Python):

import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int, K: int):
    d = gcd(A, B)
    return [i for i in range(1, d + 1) if (d % i) == 0][-K]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    K = int(next(tokens))  
    result = solve(A, B, K)
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
a,b,k=(int(i) for i in input().split())
x=[]
for i in range(100,0,-1):
  if (a%i==0)and(b%i==0):
    x.append(i)
print(x[k-1])

Solution (Python):
a=[0,0]
s=[]
a[0],a[1],k=map(int,input().split())
for i in range(1,min(a)+1):
  if a[0]%i==0 and a[1]%i==0:
    s.append(i)
print(s[len(s)-k])

Solution (Python):
a,b,c=map(int,input().split())
n=a
while c:
    if a%n==b%n==0:
        c-=1
    n-=1
print(n+1)

Solution (Python):
A,B,K = map(int,input().split())

if A < B:
    tmp = A
    A = B
    B = tmp

numA = []
for i in range(A+1,0,-1):
    if A % i == 0 :
        numA.append(i)

count = 0
for j in range(len(numA)):
    if B % numA[j] == 0:
        count += 1
        if count == K:
            print(numA[j])
            break

Solution (Python):
import fractions

a, b, k = map(int, input().split())
gcd = fractions.gcd(a, b)
divisor_list = []

if gcd == 1:
    divisor_list = [1]
else:
    divisor_list.append(1)
    for i in range(2, gcd // 2 + 1):
        if gcd % i == 0:
            divisor_list.append(i)
    divisor_list.append(gcd)

print(divisor_list[len(divisor_list)-1-k+1])

Solution (Python):
[A,B,K] = list(map(int,input().split()))
div = [i for i in range(1,101) if A % i == 0 and B % i == 0]
print(div[-K])

Solution (Python):
A, B, K = map(int, input().split())

l = []
for i in range(1, min(A, B)+1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

Solution (Python):
a,b,k=map(int,input().split())
ans=[]
for i in range(1,min(a,b)+1):
    if (a%i==0) and (b%i==0):
        ans.append(i)
print(ans[-k])

Solution (Python):
from sys import stdin
import fractions

A,B,K = [int(x) for x in stdin.readline().rstrip().split()]

x = fractions.gcd(A,B)

res = []
for i in range(x+1,0,-1):
  if A%i == 0 and B%i == 0:
    res.append(i)

print(res[K-1])

Solution (Python):
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors
A_div = make_divisors(A)
B_div = make_divisors(B)
koyakusu = list(set(A_div) & set(B_div))
koyakusu.sort(reverse=True)

print(koyakusu[K-1])

Solution (Python):
A,B,K = map(int,input().split())
count = K
for i in range(min(A,B),0,-1):
    if A % i == 0 and B % i == 0:
        count -= 1
        if count == 0:
            print(i)
            break

Solution (Python):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for l in da:
    if l in db:
    	dc.append(l)

dc.sort(reverse = True)
print(dc[k-1])

Solution (Python):
a,b,k=map(int,input().split())
count = 0
for i in range(min(a,b),0,-1):
    if (a%i==0)&(b%i==0):
        count += 1
    if count ==k:
        print(i)
        break

Solution (Python):
A,B,K = map(int,input().split())
X = []
for i in range(1,min(A,B) + 1):
    if A % i == 0 and B % i == 0:
        X.append(i)

print(X[-K])

Solution (Python):
A, B, K = map(int, input().split())
lists = []
if A < B:
    max = B
else:
    max = A
for i in range(1, max+1):
    if A % i == 0 and B % i == 0:
        lists.append(i)
lists.reverse()
print(lists[K-1])

Solution (Python):
A, B, K = [int(x) for x in input().split()]

yakusu = []

for i in range(max(A, B), 0, -1):
    if A % i != 0 or B % i != 0:
        continue
    yakusu.append(i)

print(yakusu[K - 1])

Solution (Python):
A,B,K = map(int, input().strip().split(' '))
print([i for i in range(1,min(A,B)+1) if A%i == 0 and B%i == 0][-K])

Solution (Python):
A, B, K = map(int, input().split())

L = []
for i in range(1, max([A, B]) + 1):
	if not A % i and not B % i:
		L.append(i)
print(L[-K])

Solution (Python):
a, b, k = map(int, input().split())
 
ans = []
 
for i in range(1, 101):
    if(a % i == 0 and b % i == 0):
        ans.append(i)
print(ans[-k])

Solution (Python):
a, b, k = map(int, input().split())

ans = []

for i in range(1, 101):
    if(a % i == 0 and b % i == 0):
        ans.append(i)
print(ans[-k])

Solution (Python):
A,B,K = map(int, input().split())
listA = []
listB = []
for i in range(1,A+1):
    if A%i == 0:
        listA.append(i)
for i in range(1,B+1):
    if B%i == 0:
        listB.append(i)
AB = []
for i in range(len(listA)):
    if listA[i] in listB:
        AB.append(listA[i])
print(AB[len(AB)-K])

Solution (Python):
A, B, K = [int(x) for x in input().split()]

fA = set([i for i in range(1, A + 1) if A % i == 0])
fB = set([i for i in range(1, B + 1) if B % i == 0])

f = sorted(list(fA.intersection(fB)))
print(f[-K])

Solution (Python):
A, B, K = map(int, input().split())
count = 0
for i in range(min(A, B), 0, -1):
    if A % i == B % i == 0:
        count += 1
        if count == K:
            print(i)
            exit()

Solution (Python):

a, b, k = list(map(int, input().rstrip().split()))
a, b = sorted([a, b])
div = []

for i in range(1, a + 1):
    if a % i == 0 and b % i == 0:
        div.append(i)

print(sorted(div, reverse=True)[k - 1])

Solution (Python):
a,b,k = map(int,input().split())
import fractions
n = fractions.gcd(a,b)
divisor = []
for i in range(int(n/2)+1):
  if n % (i+1) == 0:
    divisor.append(i+1)
divisor.append(n)
print(divisor[-k])

Solution (Python):
A, B, K = map(int,input().split())

end = min(A,B)
ans = []

for i in range(end):
    i += 1
    if A % i == 0 and B % i == 0:
        ans.append(i)

print(ans[-K])

Solution (Python):
A, B, K = map(int,input().split())
Y = []
small = min(A+1,B+1)
for i in range(1,small):
    if A % i == 0:
        if B % i ==0:
            Y.append(i)
print(Y[-K])

Solution (Python):
A, B, K = map(int, input().split(" "))

c = [] 
for i in range(1, max(A, B) + 1):
    if A % i == 0 and B % i == 0:
        c.append(i)

print(c[-K])

Solution (Python):
a, b, k = map(int, input().split())
mx = max(a, b)
match, ans = 0, 0

for i in range(mx):
    if ((a % (mx - i)) == 0) and ((b % (mx - i)) == 0):
        
        match += 1
        ans = mx - i
        
        if match == k:
            break
print(ans)

Solution (Python):
a,b,k=map(int,input().split())
numlst=[]
for i in range(max(a,b)):
    if a%(i+1)==0 and b%(i+1)==0:
        numlst.append(i+1)

print(numlst[len(numlst)-k])

Solution (Python):
a, b, k = map(int, input().split())
cnt = 0
for i in range(100, 0, -1):
  if a % i == 0 and b % i == 0:
    cnt += 1
    if cnt == k:
      print(i)
      break

Solution (Python):


A, B, K = map(int, input().split())

for i in range(min(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        K -= 1
        if K == 0:
            print(i)
            break

Solution (Python):
A, B, K = map(int, input().split())


cnt = 0
for i in range(1, 101)[::-1]:
    if A % i == 0 and B % i == 0:
        cnt += 1
    if cnt == K:
        print(i)
        break

Solution (Python):
a, b, k = map(int, input().split())
l = [0]
for i in range(1, min(a, b)+1):
    if a%i==0 and b%i==0:
        l.append(i)
print(l[-k])

Solution (Python):
A, B, K = map(int, input().split())
D = []
for i in range(A, 0, -1):
	if A % i == 0 and B % i == 0:
		D.append(i)
print(D[K - 1])

Solution (Python):
import fractions
A, B, K = map(int, input().split())

G = fractions.gcd(A, B)

i = 1
divisors = []
while i ** 2 <= G:
	if G % i == 0:
		divisors.append(i)
		divisors.append(G // i)
	i += 1
divisors = sorted(list(set(divisors)))[:: -1]
print(divisors[K - 1])

Solution (Python):
A,B,K = map(int,input().split())
l = []
for i in range(1,101):
    if (A%i)==0 and (B%i)==0:
        l += [i]
print(sorted(l)[-K])

Solution (Python):
A, B, K =[int(_) for _ in input().split()]

def cd(a,b,n):
    cnt = 0
    st = min(a,b)
    for i in range(st,0,-1):
        if a % i == 0 and b % i == 0:
            cnt +=1
            if n == cnt:
                return i
print(cd(A,B,K))

Solution (Python):

A, B, K = (int(i) for i in input().split())


ans_list = []
for i in range(1, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        ans_list.append(i)


ans = ans_list[-K]
print(ans)

Solution (Python):
tmp=input().split(" ")
a = int(tmp[0])
b = int(tmp[1])
k = int(tmp[2])

count=0
for n in range(max(a,b), 0, -1):
    if a % n == 0 and b % n == 0:
        count += 1
        if count == k:
            print(n)
            exit()

Solution (Python):
a,b,k=map(int,input().split())
list_w=[]
for i in range(1,101):
    if a%i==0 and b%i==0:
        list_w.append(i)
list_w.reverse()
print(list_w[k-1])

Solution (Python):
a,b,k=map(int,input().split())
i=101
c=0
while(c!=k):
    i-=1
    if a%i==0 and b%i==0:
        c+=1
print(i)

Solution (Python):
a,b,k = map(int, input().split())

ans = 0
num = 0
for index in range(100):
  i = 100 - index
  if ((a % i) == 0) and ((b % i) == 0):
    num += 1
  if num == k:
    ans = i
    break
print(ans)

Solution (Python):



MAX = 100

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

A, B, K = map(int, raw_input().split())
gcdAB = gcd(A, B)

cnt = 0
for n in range(gcdAB, 0, -1):
    if gcdAB % n == 0:
        cnt += 1
        if cnt == K:
            print '{}'.format(n)
            break

Solution (Python):
[A, B, K] = list(map(int,input().split()))

tmp = 0
i = max(A,B)
while (tmp < K):
    if (A % i == 0) and (B % i == 0):
        tmp += 1
    i -= 1

    
print(i + 1)

Solution (Python):
A,B,K = map(int,input().split())

aliquots = []
for nominee in range(1,100+1):
	if A % nominee == 0 and B % nominee == 0:
		aliquots.append(nominee)
		
print(aliquots[len(aliquots)-K])

Solution (Python):
S = list(map(int, input().split()))
A=S[0]
B=S[1]
K=S[2]
i=1
cnt=0
m=min(A,B)
while True:
    if(A%m==0 and B%m==0):
        cnt+=1
        if(cnt==K):
            print(m)
            exit()
    m-=1

Solution (Python):
A, B, K = map(int, input().split())
n = min(A, B)
list1 =[]
for i in range(1, n+1):
  if A % i == 0 and B % i == 0:
    list1.append(i)
list1 = list1[::-1]
print(list1[K-1])

Solution (Python):
A,B,K =map(int,input().split())
list = []
for i in range(1,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        list.append(i)
list.sort(reverse=True)
print(list[K - 1])

Solution (Python):
A,B,K =map(int,input().split())
list = []

for i in range(1,101):
    if A % i == 0 and B % i == 0:
        list.append(i)
list.sort(reverse=True)
print(list[K - 1])

Solution (Python):
import fractions
a,b,k=map(int,input().split())
n=fractions.gcd(a,b)
l=[]
ld=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        l.append(i)
        ld.append(n//i)
if ld[-1]==l[-1]:del ld[-1]
l+=ld[::-1]
print(l[-k])

Solution (Python):
a,b,k = map(int,input().split())
l = []
for i in range(1,101):
    if a%i == 0 and b%i == 0:
        l.append(i)
print(l[::-1][k-1])

Solution (Python):
A, B, K = map(int, input().split())

for i in range(1, min(A, B) + 1)[::-1]:
    if A % i == 0 and B % i == 0:
        K -= 1

    if K == 0:
        print(i)
        break

Solution (Python):
a,b,k = map(int,input().split())
l = []
for i in range(1, 101):
    if a % i == 0 and b % i == 0:
        l.append(i)
print(l[-k])

Solution (Python):
A,B, K = map(int,input().split())
m= min(A,B)
count =0
for i in range(m,0,-1):
  if A%i ==0 and B%i==0:
    count +=1
    if count ==K:
      ans=i
      break
print(i)

Solution (Python):
A, B, K = map(int, input().split())
a, b = [], []
for i in range(1,A+1):
    if A % i == 0:
        a.append(i)
for j in range(1,B+1):
    if B % j == 0:
        b.append(j)
lis = [k for k in a if k in b]
lis.reverse()
print(lis[K-1])

Solution (Python):



A, B, K = list(map(int, input().split()))



set_A = set()
set_B = set()

for i in range(1, A + 1):
    if A % i == 0:
        set_A.add(i)


for i in range(1, B + 1):
    if B % i == 0:
        set_B.add(i)



seki = set_A & set_B

seki = list(seki)

seki.sort(reverse=True)

print(seki[K - 1])

Solution (Python):
inn = input().split()
a = int(inn[0])
b = int(inn[1])
k = int(inn[2])

start = max(a, b) + 1
count = 0


rlist = list(range(0, start))
rlist.reverse()
for i in rlist:
    if a % i == 0 and b % i == 0:
        count += 1
        if count == k:
            print(i)
            break

Solution (Python):
A,B,K =  map(int,input().split())
C=[]


N = min(A,B)

for i in range(N):
    if A % (i+1) == 0:
        if B % (i+1) ==0:
            C.append(i+1)

N = len(C)
print(int(C[N-K]))

Solution (Python):
A, B, K = map(int, input().split())

counter = 0
for i in range(100, 0, -1):
    if A % i == 0 and B % i == 0:
        counter += 1
    if counter == K:
        print(i)
        break

Solution (Python):

a,b,k = [int(i) for i in input().split()]

divs = []

for i in range(1, min(a,b)+1):
    if a % i == 0 and b % i == 0:
        divs.append(i)

divs.reverse()
print(divs[k-1])

Solution (Python):
n = input().split()
A = int(n[0])
B = int(n[1])
K = int(n[2])
yAArr = []
yBArr = []
pubArr = []

for i in range(1,A):
   if A % i == 0:
       yAArr.append(i)
yAArr.append(A)
for i in range(1,B):
    if B % i == 0:
        yBArr.append(i)
yBArr.append(B)

pubArr = list(set(yAArr) & set(yBArr))
pubArr = sorted(pubArr, reverse=True)

for i, name in enumerate(pubArr):
    if i + 1 == K:
        print(pubArr[i])
        break

Solution (Python):
a,b,k = map(int,input().split())
m = min(a,b)
count = 0
for i in range(m,0,-1):
  if i == 0:
    break
  if a%i == 0 and b%i == 0:
    count += 1
  if count == k:
    break
print(i)

Solution (Python):
A,B,K=map(int,input().split())
C=min(A,B)
D=[0]*C

for i in range(C):
  if A%(i+1) == 0 and B%(i+1) == 0:
    D[i]=i+1
  else:
    D[i]=0

D=sorted(D,reverse=True)
print(D[K-1])

Solution (Python):
a, b, k = map(int, input().split())

c = min(a, b)
count = 0
for i in range(c):
    if a % (c-i) == 0 and b % (c-i) == 0:
        count += 1
    if count == k:
        print(c-i)
        break

Solution (Python):
A,B,K = map(int, input().split())

n = min(A, B)
count = 0
for i in range(n, 0, -1):
    if i == 0:
        break
    if A%i == 0 and B%i == 0:
        count = count + 1
        if count == K:
            break
print(i)

Solution (Python):
A, B, K = map(int, input().split())

List = [x for x in range(min(A,B),0,-1) if A%x ==0 and B%x ==0]
print(List[K-1])

Solution (Python):
a, b, c = map(int, input().split())
d = max(a, b)
l = []
for i in range(1,d+1):
  if a % i == 0 and b % i == 0:
    l.append(i)
print(l[len(l)-c])

Solution (Python):
a,b,k=map(int,input().split())
n=[]
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    n.append(i)
print(n[-k])

Solution (Python):
a, b, k = map(int, input().split())

res = []
for i in range(1, 101):
    if (a % i == 0) & (b % i == 0):
        res.append(i)

sorted(res)
print(res[-k])

Solution (Python):
a, b, c = map(int, input().split())
d = max(a, b)
l = []
for i in range(1,d+1):
  if a % i == 0 and b % i == 0:
    l.append(i)
print(l[len(l)-c])

Solution (Python):
a, b, k = map(int, input().split())
max = max(a, b)
ans = []
for i in range(1, max+1):
  if a % i == 0 and b % i == 0:
    ans.append(i)
print(ans[-(k)])

Solution (Python):
a, b, k = [int(s) for s in input().split()]


def f(s, l, k):
    numbers = []
    for i in range(1, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)

Solution (Python):
m = list(map(int, input().split()))
a = m[0]
b = m[1]
k = m[2]
c = min(a, b)
d = 0
e = 0

for i in range(c):
    if(a % (c - i) == 0 and b % (c - i) == 0):
        d += 1
    if(d == k):
        e = c - i
        break
print(e)

Solution (Python):
a,b,k = map(int,input().split())
c = []
for i in range(min(a,b)):
    if a%(i+1) == 0 and b%(i+1) == 0:
        c.append(i+1)
print(c[-k])

Solution (Python):
import numpy as np
a,b,k = map(int,input().split())
c = np.array(list(range(1,min(a,b)+1))) 

e = [f for f,g in enumerate(zip(a%c,b%c)) if g == (0,0)]
print(c[e[-k]])

Solution (Python):
a, b, k = map(int, input().split())
n = []

for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        n += [i]

print(n[-k])

Solution (Python):
a, b, k = map(int, input().split())
divisor = []
for i in range(1, min(a, b)+1):
	if a % i == 0 and b % i == 0:
		divisor.append(i)
divisor.sort(reverse=True)
print(divisor[k-1])

Solution (Python):
a,b,k=map(int,input().split())
ans=[]
for i in range(1,200):
  if a%i==0 and b%i==0:
    ans.append(i)
print(ans[-k])

Solution (Python):
A, B, K = map(int, input().split())
counter = 0

for i in reversed(range(0, min(A, B)+1)):
    if A % i == 0 and B % i == 0:
        counter += 1
    if counter == K:
        print(i)
        break

Solution (Python):
A,B,K = map(int, input().split())
mylist = []
for i in range(1,max(A,B)+1):
  if A%i == 0 and B%i == 0:
    mylist.append(i)
newlist = sorted(mylist, reverse = True)
print(newlist[K-1])

Solution (Python):
A,B,K=map(int,input().split())
tmp=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        tmp.append(i)
print(tmp[-K])

Solution (Python):
a, b, k = map(int, input().split())

for i in range(min(a, b)+1, 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
    if k == 0:
        print(i)
        break

Solution (Python):
A,B,K = map(int,input().split())
divide_list = []
for i in range(1,min(A,B) + 1):
  if A%i ==0 and B%i ==0:
    divide_list.append(i)
print(divide_list[-K])

Solution (Python):
A,B,K=map(int,input().split())
count=0
i=min(A,B)+1
while count<K:
  i-=1
  if A%i==0 and B%i==0:
    count+=1
print(i)

Solution (Python):
A, B, K = map(int, input().split())
l = []
for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        l.append(i)
l.sort(reverse=True)
print(l[K - 1])

Solution (Python):
a, b, k = map(int,input().split())
cnt = k
x = min(a,b)

for i in range(1,x+1)[::-1]:
    if a%i == 0 and b%i == 0:
        cnt -= 1
    if cnt == 0:
        break
print(i)

Solution (Python):
import sys

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a


stdout_write = sys.stdout.write

for line in sys.stdin:
  a, b, k = (int(i) for i in line.strip().split())
  ans = gcd(a, b)
  while True:
    if (a % ans) == 0 and (b % ans) == 0:
      k -= 1
      if k == 0: break
    ans -= 1

stdout_write('{}\n'.format(ans))

Solution (Python):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
                
    divisors.sort()
    return divisors
 
 
a, b, c = map(int, input().split())
 
c_set = list(set(make_divisors(a))&set(make_divisors(b)))
 
c_set.sort()
print(c_set[-c])

Solution (Python):

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
                
    divisors.sort()
    return divisors


a, b, c = map(int, input().split())

c_set = list(set(make_divisors(a))&set(make_divisors(b)))

c_set.sort()

print(c_set[-c])

Solution (Python):
A,B,K = map(int, input().split())

if A > B:
  C=A
  A=B
  B=C
k = 0
cnt = 0
while True:
  if A % (A-cnt) == 0 and B % (A-cnt) == 0:
    k += 1
    if k == K:
      print(A-cnt)
      break
  cnt += 1

Solution (Python):
A, B, K = map(int, input().split())

count = 0
for i in range(min(A, B)):
    i = min(A, B) - i
    if A % i == 0 and B % i == 0:
        count += 1
        if count == K:
            print(i)
            break

Solution (Python):
a,b,K = map(int,input().split())
cnt,ans = 0,0
for i in range(1,min(a,b)+1)[::-1]:
    if a%i==0 and b%i==0:
        cnt += 1
        if cnt==K:
            print(i)
            break

Solution (Python):
list = raw_input().split()

A = int(list[0])

B = int(list[1])

K = int(list[2])

count = 0

for n in range(A, 0 , -1):
    if A % n == 0:
        if B % n == 0:
            count += 1
    if count == K:
        break

print n

Solution (Python):
a, b, k = map(int, input().split())
ab = []

if a >= b:
    i = b
else:
    i = a

while i > 0:
    if a % i == 0 and b % i == 0:
        ab.append(i)
    i -= 1

print(ab[k - 1])

Solution (Python):
a,b,k=map(int, input().split())

for i in range(max(a,b), 0, -1):
	if a%i == 0 and b%i == 0:
		k -= 1
		if k == 0:
			print(i)
			break

Solution (Python):
A,B,K=map(int,input().split())
listAB=[]
for i in range(min(A,B)):
    if A%(i+1)==0 and B%(i+1)==0:
        listAB.append(i+1)
listAB.sort(reverse=1)
if A==1 and B==1:
    print(1)
else :
    print(listAB[K-1])

Solution (Python):
A, B, K = map(int,input().split())
listAB = []
for i in range(min(A,B)):
    if A%(i+1) == 0 and B % (i+1) == 0:
        listAB.append(i+1)
listAB.sort(reverse = True)
if A == 1 or B == 1:
    print(1)
else:
    print(listAB[K-1])

Solution (Python):
A, B, K = map(int, input().split())

num_list = [(x+1) for x in range(100) if (A % (x+1) == 0) and (B % (x+1) == 0)]
num_list.sort(reverse = True)
print(num_list[K-1])

Solution (Python):
A,B,K=map(int,input().split())
a=0
C=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        C.append(i)
print(C[-K])

Solution (Python):
a,b,n=map(int,input().split())
c=[]
i=0
while(1):
  i=i+1
  if a%i==0 and b%i==0:
    c.append(i)
  if a<=i or b<=i:
    break
d=len(c)-n
print(c[d])

Solution (Python):

import sys


def solve(A: int, B: int, K: int):
    div = []
    for i in range(1,min(A,B)+1):
        if A % i == 0 and B % i == 0:
            div.append(i)
    print(div[len(div) - K])
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    K = int(next(tokens))  
    solve(A, B, K)

if __name__ == '__main__':
    main()

Solution (Python):
a,b,k = map(int, input().split())
count = 0
for i in range (min(a,b),0,-1):
	if a % i == 0 and b % i == 0:
		count += 1
		d = i;
	if count == k:
		print(d)
		break

Solution (Python):
def solve(a, b, k):
    num = 0
    for i in range(100, 0, -1):
        if a % i == 0 and b % i == 0:
            num += 1
        if num == k:
            return i


def main():
    a, b, k = map(int, input().split())

    ans = solve(a, b, k)
    print(ans)


main()

Solution (Python):
def gcd(x, y):
	if y == 0: return x
	else: return gcd(y, x%y)

A, B, K = map(int, raw_input().split())

g = gcd(A, B)
cnt = 1

while cnt != K:
	g -= 1
	if A % g == 0 and B % g == 0:
		cnt += 1

print g

Solution (Python):
a, b, k = map(int, input().split())
print([x for x in range(1, min(a,b)+1) if a%x == b%x == 0][-k])

Solution (Python):
A,B,K = map(int,input().split())

cnt = 0
d = 0
for i in range(min(A,B),0,-1):
    if A % i == 0 and B % i == 0:
        cnt += 1
        d = i
    if cnt == K:
        print(d)
        break

Solution (Python):
A, B, K = map(int, input().split())
G = 0
while A % B != 0:
	A, B = B, A % B
else:
	G = B
list = []
for i in range(1, G + 1, 1):
	if G % i == 0:
		list.append(i)
print(G // list[K - 1])

Solution (Python):
a,b,k = map(int, input().split())

c = []
for i in range(1, a + 1):
    if a % i == 0 and b % i == 0:
        c.insert(0,i)

print(c[k-1])

Solution (Python):
a, b, k = map(int, input().split(" "))

l = [1]
for i in range(2, min(a, b) + 1, 1):
  if a % i == 0 and b % i == 0:
    l.append(i)

print(l[-k])

Solution (Python):
A,B,K=[int(i) for i in input().split()]
a=[]
for i in range(1,max(A,B)+1):
  if A%i==0 and B%i==0:
    a.append(i)
print(a[-K])

Solution (Python):
import sys

A, B, K = map(int, input().split())
ans = 0
count = 0

for i in range(100):
    if A % (100 - i) == 0 and B % (100 - i) == 0:
        ans = 100 - i
        count += 1
        if count == K:
            print(ans)
            sys.exit()

Solution (Python):
a,b,k=map(int,input().split())
m=max(a,b)
ans=[]
for i in range(1,m+1):
  if a%i==0 and b%i==0:
    ans.append(i)
ans.reverse()
print(ans[k-1])

Solution (Python):
A,B,K = map(int,input().split())
list = []
for i in range(max([A,B])+1):
    if i != 0 and A % i == 0 and B % i == 0:
        list.append(i)

list.sort(reverse = True)
if len(list) == 1:
    print(list[0])
else:
    print(list[K-1])

Solution (Python):
A,B,K = map(int, input().split())
count = 0
for i in list(range(A))[::-1]:
  i += 1
  if (not (A%i)) and (not (B%i)):
    count += 1
    if count == K:
      print(i)

Solution (Python):
a, b, k = map(int, input().split())
ya = []
for i in range(1, 101):
    if a % i == 0 and b % i == 0:
        ya.append(i)
print(ya[-k])

Solution (Python):
A, B, K = map(int, input().split())

for i in range(max(A,B), 0, -1):
    if A % i == 0 and B % i == 0:
        K -= 1
    if K == 0:
        print(i)
        break

Solution (Python):
a,b,k = map(int,input().split())
tmp = 0
for i in reversed(range(1,101)):
  if a % i == 0 and b % i == 0:
    k -= 1
    tmp = i
  if k == 0:
    break
print(tmp)

Solution (Python):
A, B, K = map(int,input().split())

a = [i for i in range(1, A+1) if A % i == 0]
b = [i for i in range(1, B+1) if B % i == 0]
ans = set(a) & set(b)
print(sorted(list(ans))[-K])

Solution (Python):
A, B, K = map(int, input().split())

l = [i for i in range(1, 101) if (A % i == 0 and B % i == 0)]
l = l[::-1]

print(l[K-1])

Solution (Python):
A, B, K = map(int, input().split())

c_d = []
for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        c_d.append(i)

c_d.sort(reverse=True)

print(c_d[K-1])

Solution (Python):
a, b, k = map(int,raw_input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

ab = list(set(make_divisors(a)) & set(make_divisors(b)))
ab.sort()
print ab[len(ab)-k]

Solution (Python):
a,b,k=(int(x) for x in input().split())

l=[]

for i in range(1,101):
    if a%i == 0 and b%i ==0:
        l.append(i)

l.sort(reverse=True)

print(l[k-1])

Solution (Python):
A, B, K = list(map(int, input().split(' ')))
candidate = [1]
for i in range(2, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        candidate.append(i)
print(sorted(candidate, reverse=True)[K-1])

Solution (Python):
A, B, K = map(int, input().split())
ans = []
for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        ans.append(i)
print(ans[-K])

Solution (Python):
abk = list(map(int,input().split()))
a=abk[0]
b=abk[1]
k=abk[2]
ans=[]
for i in range(1,101):
    if a%i == 0 and b%i ==0:
        ans.append(i)
ansr=list(reversed(ans))
print(ansr[k-1])

Solution (Python):
import sys
A, B, K = (int(x) for x in input().split())
N = min([A, B]) + 1
counter, ans = 0, 1
for x in range(1, N):
    x = N - x
    if A % x == 0 and B % x == 0:
        ans = x
        counter += 1
    if counter == K:
        print(ans)
        sys.exit()

Solution (Python):
def gcd(a, b):
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)


A, B, K = list(map(int, input().split()))
gcd_val = gcd(A, B)
for i in range(gcd_val, 0, -1):
    if gcd_val % i == 0:
        K -= 1
        if K == 0:
            print(i)
            exit(0)

Solution (Python):
A, B, K = map(int, input().split())
if A > B:
	A, B = B, A
n = 0
for i in range(A, 0, -1):
	if B % i == 0 and A % i == 0:
		n += 1
		if n == K:
			print(i)
			break

Solution (Python):
states = list(map(int, input().split()))
counter = 0
i=max(states[0], states[1])

while counter!=states[2]:
    if states[0]%i==0 and states[1]%i==0:
        counter = counter + 1
    i = i-1

print(i+1)

Solution (Python):
A,B,C=map(int,input().split())
T=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        T.append(i)
print(T[-C])

Solution (Python):


"""
Created on Fri Apr  5 22:47:49 2019

@author: lab
"""

a,b,k = map(int,input().split())

n = min(a,b)
count = 0
while n>0:
    if int(a%n) == 0 and int(b%n) == 0:
        count += 1
        if count == k:
            print(n)
            break
        n -= 1
    else:
        n -= 1

Solution (Python):
A,B,K = (int(x) for x in input().split())
i = 1
n = 0
NUM = [0]*min(A,B)

for i in range(1,min(A,B)+1):
    if A%i ==0 and B%i ==0:
        NUM[n] = i
        n+=1
NUM.sort(reverse = 1)

print(NUM[K-1])

Solution (Python):
a,b,k = map(int,input().split())

check = 0
for i in reversed(range(a)):
  if (a % (i+1)==0) & (b % (i+1)==0):
    check += 1
    if k == check:
      print(i+1)

Solution (Python):
a, b, c = map(int, input().split())
li = []
for i in range(1, min(a, b)+1):
    if a%i == 0 and b%i == 0:
        li.append(i)
tmp = list(reversed(li))
print(tmp[c-1])

Solution (Python):
A, B, K = map(int, (input().split(' ')))

As = []
for i in range(1, A+1):
    if A % i == 0:
        As.append(i)
Bs = []
for i in range(1, B+1):
    if B % i == 0:
        Bs.append(i)

print(sorted(list(set(As) & set(Bs)), key=lambda x: -x)[K-1])

Solution (Python):
A, B, K = map(int, input().split())

tmp = []
for i in list(reversed(range(1, min(A, B) + 1))):
    if A % i == 0 and B % i == 0:
        tmp.append(i)
print(tmp[K - 1])

Solution (Python):
A,B,K=map(int,input().split())
m=A
if A>B:
    m=B
cd=[]
for i in range(1,m+1):
    if A%i==0 and B%i==0:
        cd.append(i)
print(cd[-K])

Solution (Python):
A, B, K = map(int, input().split())
C = min(A, B)
nlist = [0]
while 1 <= C:
    if A % C == 0 and B % C == 0:
        nlist.append(C)
    C -= 1
print(nlist[K])

Solution (Python):
a, b, k = map(int, input().split())
i = a + 1 if a <= b else b + 1
count = 0
while count < k:
    i -= 1
    if a % i == 0 and b % i == 0:
        count += 1
print(i)

Solution (Python):
a,b,k = map(int,input().split())

lst = []
for i in range(100):
	idx = i+1
	if a%idx == 0 and b%idx == 0:
		lst.append(idx)
print(lst[-k])

Solution (Python):
a, b, k = map(lambda x: int(x), input().split(' '))

def gcd(a, b):
  cand = a % b
  if cand == 0:
    return b
  else:
    return gcd(b, cand)

gcd_res = 0
if a < b:
  gcd_res = gcd(b, a)
else:
  gcd_res = gcd(a, b)

count = 1
for i in reversed(range(1, 101)):
  if (gcd_res % i) == 0:
    if count == k:
      print(i)
      break
    count += 1

Solution (Python):
A,B,K = map(int,input().split())


w = [0] * K

i = 0
for j in reversed(range(1,max(A,B)+1)):
    if i > K-1 : break
    if A%j == 0 and B%j == 0:
        w[i] = j
        i += 1
        
        

print(w[K-1])