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):
A, B, K = map(int, input().split())


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


def factors(a):
    f = []
    for n in range(a, 0, -1):
        if a % n == 0:
            f.append(n)
    return f


ans = factors(gcd(A, B))[K - 1]
print(ans)

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

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

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())
l=[]
p=A
q=B
if A>B:
    A=q
    B=p
for i in range(1,B+1):
    if A%i==0 and B%i==0:
        l.append(i)

print(l[len(l)-K])

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

Solution (Python):


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

ans = 1
counter = 0

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

print(ans)

Solution (Python):
import itertools
import math
import fractions
import functools

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

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

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

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

Solution (Python):

from fractions import gcd
'''
3.7 以降は、Math
以前は、
from fractions import gcd 
'''
a, b, k = map(int, input().split())


'''
def lcm(x, y):
    
    
    ll = (x * y) // gcd(x, y)
    return ll
'''

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

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
        if count == K:
            print(i)
            break

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

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

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

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

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



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

print(ans)

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())
c = 0
for i in range(a, -1, -1):
  if a % i == 0 and b % i == 0:
    c += 1
    if c == k:
      print(i)
      break

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

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())
wari=[]
for i in range(1,101):
    if a%i==0 and b%i==0:
        wari.append(i)

print(wari[-k])

Solution (Python):

A,B,K = list(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:
        break
        
print(i)

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

Solution (Python):
def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

def divisor(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return sorted(res, reverse = True)

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

x = gcd(A, B)
X = divisor(x)

print(X[K - 1])

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

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
  if count == k:
    print(i)
    exit()

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

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

count = []

s = A if A < B else B

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

Solution (Python):
a,b,k = 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)
print(li[-k])

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

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

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

Solution (Python):
A,B,K = map(int,input().split())
cnt = 0
for i in range(min(A,B),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())
x = min(a,b)
count = 0
while count<k:
  if a%x==0 and b%x==0:
    count += 1
  x-=1
x += 1
print(x)

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

cd = []

if A > B:
  nums = [i for i in range(1, B+1)]
elif A < B:
  nums = [i for i in range(1, A+1)]
else:
  nums = [i for i in range(1, A+1)]

for i in nums:
  if A % i == 0 and B % i == 0:
    cd.append(i)
print(cd[-K])

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

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

ans.sort(reverse=True)
print(ans[K - 1])

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)
ans.sort(reverse=True)
print(ans[k-1])

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

i=1
cnt=0
result=[]

while i<=min(a,b):
  if a%i==0 and b%i==0:
    cnt+=1
    result.append(i)
  i+=1

print(result[-k])

Solution (Python):
a, b, k = map(int, input().split())
ls = []
for i in range(1, min(a, b)+1):
    if a%i==0 and b%i==0:
        ls.append(i)
ls = ls[::-1]
print(ls[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):
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)
            exit()

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

Solution (Python):
def main():
    a, b, k = map(int, input().split())
    from fractions import gcd
    g = gcd(a, b)

    def yakusuu(a):
        yakusuu = set()
        for i in range(1, int(a**0.5)+1):
            if a % i == 0:
                yakusuu.add(i)
                yakusuu.add(a//i)
        yakusuu = sorted(list(yakusuu))
        return yakusuu

    print(yakusuu(g)[::-1][k-1])


main()

Solution (Python):
A,B,K = map(int,input().split())
L = 0
ans = 0
for i in reversed(range(1,2000)):
  if A%i == 0:
    if B%i == 0:
      L += 1
    else:
      L += 0
  else:
    L += 0
  if L == K:
    ans = i
    break
print(ans)

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

Solution (Python):
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))

def main(a,b,k):
    res = []
    for i in range(1,min(a,b)+1):
        if a % i == 0 and b % i == 0:
            res.append(i)
    return res[-k]        
            
a,b,k = mi()
print(main(a,b,k))

Solution (Python):
def main():
    A, B, K = map(int, input().split())
    results = calc(A, B)
    print(results[K - 1])

def calc(A, B):
    results = []
    for i in range(min(A, B) + 1, 0, -1):
        if A % i == 0 and B % i == 0:
            results.append(i)
    return results

if __name__ == '__main__':
    main()

Solution (Python):
def main():
  A,B,K = list(map(int, input().split()))
  o = 0

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

      if(K == o):
        print(i)
        break
    

if __name__ == "__main__":
  main()

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

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

print(w[-K])

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

def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

l = cf(a,b)

l.sort(reverse=True)

print(l[k-1])

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

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

Solution (Python):
list1 = [int(i) for i in input().split()]
lista=[]
for i in range(1,int(list1[0])+1):
  if (int(list1[0])% int(i)==0) and  (int(list1[1])% int(i)==0): 
    lista.append(i)
c=int(list1[2])
lista.reverse()

print(lista[c-1])

Solution (Python):
def find_pledge(i, j):
    mylist = []
    for m in range(1, 101):
        if i % m == 0 and j % m == 0:
            mylist.append(m)
    return mylist

a, b, k = map(int, input().split())
mylist = find_pledge(a, b)
print("{}".format(mylist[len(mylist)-k]))

Solution (Python):
a, b, k = list(map(int, input().split()))
la = []
lb = []
for i in range(1, a+1):
    if a % i == 0:
        la.append(i)
        lsas = sorted(set(la), key=la.index)
        for j in lsas:
            if b % j == 0:
                lb.append(j)

lsbs = sorted(set(lb), key=lb.index)
print(lsbs[len(lsbs)-k])

Solution (Python):
a, b, k = list(map(int, input().split()))
la = []
lb = []
for i in range(1, a+1):
    if a % i == 0:
        la.append(i)
        sa = set(la)
        lsa = list(sa)
        lsas = sorted(lsa)
        for j in lsas:
            if b % j == 0:
                lb.append(j)
s = set(lb)
lsb = list(s)
lsbs = sorted(lsb)
print(lsbs[len(lsbs)-k])

Solution (Python):
import fractions
a,b,k = map(int,input().split())
c = fractions.gcd(a,b)
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
d = make_divisors(c)
d.sort()
print(d[-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.insert(0, i)
print(ans[k-1])

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

Solution (Python):
a, b, k = map(int, input().split())
flag, divisor, common_divisors = 0, 1, list()
while flag != -1:
    if a % divisor == 0 and b % divisor == 0:
        common_divisors.append(divisor)
    if divisor >= min(a, b):
        flag = -1
    divisor += 1
print(sorted(common_divisors, reverse=True)[k-1])

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()

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

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

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

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

div = []
for i in range(1, m+1):
    if a % i == 0 and b % i == 0:
        div.append(i)
div.reverse()
print(div[k-1])

Solution (Python):


def main():
    A, B, K = map(int, open(0).read().split())

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


main()

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]




A, B ,K = mi()

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

Solution (Python):
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
  
A, B, K = map(int, input().split())
ans = list(set(divisor(A)) & set(divisor(B)))
ans.sort(reverse=True)
print(ans[K-1])

Solution (Python):


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

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

gcdAB = gcd(A, B)

cdlist = []
for i in range(1, int(gcdAB**0.5)+1)[::-1]:
    if gcdAB%i==0:
        cdlist.append(i)
        if gcdAB//i!=i: 
            cdlist.append(gcdAB//i)

cdlist.sort(reverse=True)

print(cdlist[K-1])

Solution (Python):


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

cnt = 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):
A, B, K = map(int, input().split())

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

print(result[len(result) - K])

Solution (Python):


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

Solution (Python):

def solve():

    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)
    print(list[len(list)-K])


if __name__ == "__main__":
    solve()

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

for i in range(1, min(a+1, b+1)):
    if a % i == 0 and b % i == 0:
        lis.append(i)
print(sorted(lis)[-k])

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

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
        if (count == k):
            print(i)
            break

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

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

    print(ls[-k])


main()

Solution (Python):
a,b,k=map(int,input().split())
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):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque

from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]


a,b,k=MI()
count=0
for i in range(1,101):
    l=100-i+1
    if a%l==0 and b%l==0:
        count+=1
        if count==k:
            print(l)

Solution (Python):
import sys
import math
from collections import Counter
import itertools



def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



a,b,k=MI()
cnt=0
for i in range(100,0, -1):
    if a%i==0 and b%i==0:
        cnt+=1
    if cnt==k:
        print(i)
        exit()

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

cnt = 0
for i in reversed(range(101)):
    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())
num = []
if a > b:
    for i in range(1, b+1):
        if a%i == 0 and b%i == 0:
            num.append(i)

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

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

Solution (Python):
def kth_common_divisor(a, b, k):

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

    count.sort(reverse=True)
    return count[k-1]

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

if __name__ == '__main__':
    main()

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

Solution (Python):
a,b,k = map(int,input().split())
r = max(a,b)
ans = []
for i in range(r):
  if a%(i+1) == 0 and b%(i+1) == 0:
    ans.append(i+1)
    
l = len(ans)
print(ans[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)
ans.sort(reverse=True)
print(ans[K-1])

Solution (Python):

def inputlist(): return [int(k) for k in input().split()]

A,B,K = inputlist()
M = max(A,B)
li = []
for i in range(1,M+10):
    if A % i == 0 and B % i == 0:
        li.append(i)
li.reverse()
print(li[K-1])

Solution (Python):

a,b,k = map(int,input().split())
from fractions import gcd
g = gcd(a,b)
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()
    divisors.reverse()
    return divisors
li = make_divisors(g)
print(li[k-1])

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

Solution (Python):
def make_divisors(n,m):
    divisors = []
    for i in range(1,n+1):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
c.reverse()
print(c[k-1])

Solution (Python):
a, b ,k = 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[-k])

Solution (Python):
a,b,k = map(int,input().split())
divi = min(a,b)
count = 0
while divi>0:
  if a%divi==0 and b%divi==0:
    count += 1
  if count==k:
    print(divi)
    break
  divi -=1

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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0

for a in range(mx, 0, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break

print(ans)

Solution (Python):

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

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

g = gcd(a,b)

cnt = 0
for i in range(g,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())
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())

c = []

if b > a:
    temp = b 
    b = a 
    a = temp 

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

print(c[-k])

Solution (Python):

import sys
input = sys.stdin.readline









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)

ans.sort(reverse=True)
print(ans[K-1])

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

Solution (Python):
import math
import itertools
import numpy as np

def cf(x1, x2):
    hoge = []
    for i in range(1,min(x1, x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            hoge.append(i)
    return hoge

def solve():
    a, b, k = map(int, input().split())
    print(cf(a, b)[-k])
    return 0

if __name__ == "__main__":
    solve()

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

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

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

Solution (Python):

a,b,k = map(int,input().split())
c = min(a,b)
t = []

for i in range(1,c+1):
    if a % i == 0 and b % i == 0:
        t.append(i)
print(t[k*(-1)])

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

if len(div) < k: 
    print(max(div))
else:
    div.sort()
    print(div[-k])

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

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

nth = 0
max_divider = min(A, B)
for divider in range(max_divider, 0, -1):
    is_dividable_both = A % divider == 0 and B % divider == 0
    if is_dividable_both:
        nth += 1
    if nth == K:
        break

print(divider)

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

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

Solution (Python):

"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""


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)
"""



s = list(input())
an0 = 0
an1 = 0
for i in s:
    if i == "1":
        an1 += 1
    if i == "0":
        an0 += 1
print(min(an0, an1)*2)
"""
"""


n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))

ab = ab[-1::-1]
size = [1 for _ in range(n)]
height = [1 for _ in range(n)]
par = [i for i in range(n)]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if height[s1] < height[s2]:
            par[s1] = s2
            size[s2] += size[s1]
            size[s1] = 0
        else:
            par[s2] = s1
            size[s1] += size[s2]
            size[s2] = 0
            if height[s1] == height[s2]:
                height[s1] += 1
 

ans = [0 for i in range(m)]
ans[0] = n * (n - 1) // 2
for num, i in enumerate(ab):
    if num == m-1:
        break
    a = i[0] - 1
    b = i[1] - 1
    sizea = size[find(a)]
    sizeb = size[find(b)]
    if find(a) == find(b):
        ans[num + 1] = ans[num]
    else:
        ans[num + 1] = ans[num] - (sizea * sizeb)
    union(a,b)
    
    
ans = ans[-1::-1]
for i in ans:
    print(i)
"""

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

def divisor(a,b):

    for i in range(1, int(a**0.5)+1, 1):
        if a%i==0:
            A_div.append(i)
            A_div.append(a//i)
        
    for i in range(1, int(b**0.5)+1, 1):
        if b%i==0:
            B_div.append(i)
            B_div.append(b//i)

def f():
    for a in A_div:
        for b in B_div:
            if a==b:
                C.add(a)

divisor(A,B)
f()

C = list(C)
C.sort(reverse=True)
print(C[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.append(i)

l.reverse()

print(l[K-1])

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

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

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

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

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

c_s = set(a_l) & set(b_l)
c_l = sorted(list(c_s), reverse=True)
print(c_l[k - 1])

Solution (Python):

import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, K = lr()
g = gcd(A, B)

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

divisors = make_divisors(g)
divisors.reverse()
answer = divisors[K-1]
print(answer)

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

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



print(C[-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)
      exit(0)

Solution (Python):
icase=0
if icase==0:
    from fractions import gcd


    def cd2(nn):
        nnn=int(nn**0.5)+1
        cdl=set()
        for i in range(1,nnn):
            if nn%i==0:
                r=nn//i
                if not i in cdl:
                    cdl.add(i)
                if not r in cdl:
                    cdl.add(r)
        return list(cdl)            

    a,b,k=map(int,input().split())
    ki=gcd(a,b)
    kilist=cd2(ki)
    kilist.sort(reverse=True)
    print(kilist[k-1])

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

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

Solution (Python):
a,b,k = [int(x) for x in input().split()]
import fractions
kosuu = 0
gcd = fractions.gcd(a,b)
for i in range(gcd,0,-1):
    if gcd % i == 0:
        kosuu += 1
    if kosuu == k:
        print(i)
        break

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

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

Solution (Python):
import math
ABK = input().split()
A,B,K = int(ABK[0]), int(ABK[1]), int(ABK[2])

taisyou = 0
if(A >= B):
    taisyou = B
else:
    taisyou = A
    
result= []

for i in range(1, taisyou+1):
    if(A % i == 0 and B % i == 0):
        result.append(i)

reversedResult = result[::-1]
print(reversedResult[K-1])