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())
 
cand = []
for i in range(100,0,-1):
    if A%i == 0 and B%i == 0:
        cand += [i]
        
print(cand[K-1])

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

Solution (Python):
A, B, K = map(int, input().split())
 
cand = []
for i in range(100,0,-1):
  if A%i == 0 and B%i == 0:
    cand += [i]
    
    
print(cand[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())
al = []
bl = []

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

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

comset = set(al) & set(bl)
comlist = list(comset)
comlist.sort(reverse = True)
print(comlist[k - 1])

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

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

Solution (Python):
import sys
from fractions import gcd
A, B, K = map(int,input().split())
num = gcd(A,B)
cnt = 0
for n in range(num,0,-1):
  if num%n ==0:cnt += 1
  if cnt ==K:
    print(n)
    sys.exit()

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

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):
import math
import copy
from copy import deepcopy
import sys
import fractions

from functools import reduce

import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)







def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList




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

ans = []

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

print(ans[-k])

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

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

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

Solution (Python):
A, B, K = map(int, input().split())
N = []
n = min(A, B) + 1
for i in range(1, n):
  if A % i == 0 and B % i == 0:
    N.append(i)
print(N[len(N) - 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):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

A, B, K = i_l()

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

print(arr[::-1][K-1])

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

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

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

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



ansl=[]

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

ansl.sort(reverse=True)

print(ansl[k-1])

Solution (Python):
A,B,K = map(int,input().split())
li = []
for i in range(1, min(A, B) + 1, 1):
    if A % i == 0 and B % i == 0:
        li.append(i)
print(li[-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)
ans=L[len(L)-K]
print(ans)

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

Solution (Python):
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

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

Solution (Python):
from fractions import gcd
import sys
a,b,k=map(int,input().split())
n=gcd(a,b)

cnt=0
for i in range(n,0,-1):
    if n%i==0:
        cnt+=1
        if cnt==k:
            print(i)
            sys.exit()

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,n=INTM()
    ct=0
    c=min(a,b)
    for i in range(c,0,-1):
        if a%i==0 and b%i==0:
            ct+=1
            if ct==n:
                ans=i
    print(ans)
if __name__ == '__main__':
    do()

Solution (Python):
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = max(A,B)+1
    while t < K:
        i -= 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()

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

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

if __name__ == "__main__":
    main()

Solution (Python):
a, b, k = map(int, input().split())
for i in range(100, -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())

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

print(ans[K*-1])

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

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

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

print(divs[-K])

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

ans = []

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

print(ans[-K])

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

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

ma = max(a, b)
mi = min(a, b)
ans = []
if ma == mi:
    ans.append(ma)
    
for i in range(ma // 2, 0, -1):
    if ma % i == 0 and mi % i == 0:
        ans.append(i)
ans.append(1)
print(ans[k - 1])

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

    

main()

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

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

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

Solution (Python):
a,b,k = map(int,input().split())
t = min(a,b)
number =0
while k > number:
  if a%t==0 and b%t==0:
    number += 1
  t -= 1
print(t+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)

print(res[-k])

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

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

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

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

Solution (Python):


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

A,B,K = map(int,input().split())
print(make_common_divisors(A,B)[-K])

Solution (Python):
a,b,k=map(int,input().split())
from fractions import gcd
def make_divisor_list(num):
    if num<1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor=[]
        divisor.append(1)
        for i in range(2,num//2+1):
            if num%i==0:
                divisor.append(i)
        divisor.append(num)

        return divisor
l=make_divisor_list(gcd(a,b))
print(l[-k])

Solution (Python):
from fractions import gcd
A, B, K = map(int,input().split())
l = []
for k in range(1, gcd(A, B)+1):
  if all(i % k == 0 for i in [A, B]):
    l.append(k)
print(l[-K])

Solution (Python):
from fractions import gcd
A, B, K = map(int,input().split())
cnt = 0
for k in range(1, gcd(A, B)+1)[::-1]:
  if all(i % k == 0 for i in [A, B]):
    cnt += 1
  if cnt == K:
    print(k)
    exit()

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

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

Solution (Python):
A,B,K = map(int, input().split(" "))
count = 0
for i in range(1,A+1)[::-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()))
c = 0
for i in range(1,min(A,B)+1)[::-1]:
    if A%i == 0 and B%i ==0:
        c += 1
    if c == K:
        print(i) 
        break

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

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

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

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

for i in range(1,a+1):
  if a%i==0 and b%i==0:
    li.append(i)
    
li.sort(reverse=True)

print(li[k-1])

Solution (Python):
import fractions

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

base=fractions.gcd(A,B)
answers=[]

for i in range(1,base+1):
    if base%i==0:
        answers.append(i)
print(answers[-K])

Solution (Python):
a=[]
A,B,K=map(int,input().split())
i=1
while i<=min([A, B]):
    if A%i==0 and B%i==0:
        a.append(i)
    i+=1
a.sort(reverse=True)

print(a[K-1])

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

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

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

cm = []
for v in am:
    if bm.count(v) != 0:
        cm.append(v)

print(cm[- k])

Solution (Python):
A,B,K = map(int, input().split())
num_list = []
w = min(A, B)
while w >= 1:
    if A % w == 0 and B % w == 0:
        num_list.append(int(w))
    w -= 1

print(num_list[K-1])

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

Solution (Python):


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


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

print(divisor_list[-K])

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

print(l[k-1])

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

Solution (Python):
import sys
input = sys.stdin.readline

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

Solution (Python):
import sys
input = sys.stdin.readline

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

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

da = make_divisors(A)
db = make_divisors(B)
common = da & db
common_list = list(common)
common_list.sort(reverse=True)
print(common_list[K-1])

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


def main():
    a, b, k = map(int, input().split())
    ab_cf = cf(a, b)
    ans = sorted(ab_cf)[-k]
    print(ans)


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

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)

    divisors.sort()
    return divisors


a_div = make_divisors(a)
b_div = make_divisors(b)
div_list = a_div + b_div

ans = sorted([x for x in set(div_list) if div_list.count(x) > 1])

print(ans[-k])

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

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

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

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

answer = []
ans = 1
max_ans = fractions.gcd(A, B)
while ans <= max_ans:
    if A % ans == 0 and B % ans == 0:
        answer.append(ans)
        ans += 1
    else:
        ans += 1
answer = sorted(answer, reverse=True)

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

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

Solution (Python):
from fractions import gcd
A, B, K = map(int, input().split())
c = 0
for i in range(min(A,B)):
  j = min(A,B)-i
  if A%j==0 and B%j==0:
    c += 1
    
    if c == K:
      print(j)
      exit()

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)
        exit()

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

cnt = 0
ans = min(a, b)
while True:
    if a%ans == 0 and b%ans == 0:
        cnt += 1
        if cnt == k:
            print(ans)
            break
    ans -=1

Solution (Python):

def main():
    A, B, K = map(int, input().split())
    cnt = 0
    for i in reversed(range(1, 101)):
        if A % i == 0 and B % i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                exit()

if __name__ == '__main__':
    main()

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

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

print(div_lst[-k])

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

smaller_value = min(a, b)

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

larger_value = max(a, b)
count = 0
for d in reversed(divisors):
    if larger_value % d == 0:
        count += 1
        if count == k:
            print(d)
            break

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

Solution (Python):




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




a,b,k=map(int,input().split())
ans=s=0
li=[]
if a>b:
  s=a
  a=b
  b=s
for i in range(1,b+1):
  if a%i==0 and b%i==0:
    li.append(i)
li.sort()

print(li[-k])

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

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

Solution (Python):


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

ans = []
for n in range(1,101):
    if A % n == 0 and B % n == 0:
        ans.append(n)
print(ans[-K])

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

for i in range(1,101):
  amariA = A % i
  amariB = B % i
  if amariA == 0 and amariB == 0:
    output.append(str(i))

print(output[-K])

Solution (Python):
from fractions import gcd
from math import sqrt
a,b,c=map(int,input().split())
g=gcd(a,b); s=int(sqrt(g)); ans=set()
for i in range(1,s+1):
    if g%i==0:
        ans.add(i)
        ans.add(g//i)
ans=list(ans)
ans.sort(reverse=True)
print(ans[c-1])

Solution (Python):
from fractions import gcd
from math import sqrt
a,b,c=map(int,input().split())
g=gcd(a,b); s=int(sqrt(g)); ans=set()
for i in range(1,min(a,b)+1):
    if a%i==0:
        if b%i==0:
            ans.add(i)
ans=list(ans)
ans.sort(reverse=True)
print(ans[c-1])

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

for i in range(1,min(a,b)+1):
    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())
x=0
for i in range(min(a,b),0,-1):
  if a%i+b%i==0:x+=1
  if x==k:print(i);exit()

Solution (Python):
a,b,k = map(int,input().split())
frm = min(a, b)
cnt = 0
for i in range(frm, 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())

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

count = 0

l = []

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

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

ans = [i for i in range(1, max(a, b) + 1) if a % i is 0 and b % i is 0]

ans.reverse()

print(ans[k - 1])

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

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

if __name__ == '__main__':
    solve()

Solution (Python):
A,B,K = map(int,input().split())
cnt = 0
for i in reversed(range(1,min(A,B)+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 = []
for i in range(1,101):
    if a % i == 0 and b % i == 0:
        l.append(i)
        
print(sorted(l,reverse = True)[k-1])

Solution (Python):
a,b,k=map(int,input().split())
cnt=0
for j in range(min([a,b])):
    i=min([a,b])-j
    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())
arr = []

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

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

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

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

i = max(a, b)
idx = 0
while True:
    if a % i == 0 and b % i == 0:
        idx += 1

    if idx == k:
        break
    else:
        i -= 1

print(i)

Solution (Python):
def calc_divisiors(x):
    divisors=[]
    for i in range(1,x+1):
        if x % i == 0:
            divisors.append(i)
    return divisors

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

l = list(set(a_divisiors)&set(b_divisiors))
l.sort(reverse=True)

print(l[k-1])

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):
import sys

A,B,K = [int(s) for s in input().split()]

cnt = 0

N = min(A,B) 

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

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

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

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)

l.sort(reverse=True)

print(l[k-1])

Solution (Python):
A, B, K = map(lambda x: int(x), input().split())
count = 0
for i in range(A if A < B else B, 0, -1):
    if A % i == B % i == 0:
        count += 1
    if count == K:
        print(i)
        break

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

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

Solution (Python):
from fractions import gcd

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

largest_divisor = gcd(A, B)
divisors = []
for d in range(1, largest_divisor):
    if A % d == 0 and B % d == 0:
        divisors.append(d)
divisors.append(largest_divisor)
print(divisors[-K])

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

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

print(ans[-k])

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

Solution (Python):
A,B,K=map(int,input().split())
cnt=0
for i in range(A,-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())
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())


def gcd(v1, v2):
    v3 = v1 % v2
    if v3 == 0:
        return v2
    return gcd(v2, v3)


cnt = 0
for i in range(gcd(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 = []
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):
A, B, K = [int(x) for x in input().split(' ')]
n = [i for i in range(1, min(A, B)+1) if A % i == 0 and B % i == 0]
print(n[-K])

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

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

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

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

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

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


nums = list(set(temp_a) & set(temp_b))


nums.sort(reverse=True)

print(nums[k-1])

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

print(div[cnt-k])

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

Solution (Python):
from fractions import gcd
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)
        exit()

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

lst = []

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

lst.sort(reverse = True)

print(lst[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)
print(L[-K])

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


split_num_list = []

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

Solution (Python):
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


a, b, k = map(int, input().split())
m = min(a, b)
cnt = 0
for i in range(m, 0, -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())
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())
lis=[]

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

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

Solution (Python):
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  
def grid(n): return [s_list() for _ in range(n)]


def main():
    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,k = map(int,input().split())
    a_list = make_divisors(a)
    b_list = make_divisors(b)

    ans = []
    for i in range(len(a_list)):
        if a_list[i] in b_list:
            ans.append(a_list[i])

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

if __name__ == '__main__':
    main()

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

target = list()

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

print(target[-k])