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

div_a = make_divisors(a)
div_b = make_divisors(b)


common_div = [a for a in div_a if a in div_b] if len(div_a) > len(div_b) else [b for b in div_b if b in div_a] 




print(common_div[::-1][k-1])

Solution (Python):


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

k = K

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

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

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

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

print(ans[-k])

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

if a > b: n = a
else: n = b
yakusu_list = []
for i in range(1, n+1):
    if a%i == 0 and b%i == 0:
        yakusu_list.append(i)

print(yakusu_list[-k])

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

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

n = 0

for i in reversed(range(1, GCD(a, b)+1)):
    if a % i == 0 and b % i == 0:
        n += 1

    if n == k:
        print(i)
        break

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

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

print(i)

Solution (Python):
def main():
    a,b,k = list(map(int,input().split()))
    divisor = []
    cnt = 0
    for i in range(1,min(a,b) + 1):
        if min(a,b) % i == 0:
            divisor.append(i)
    for i in reversed(divisor):
        if max(a,b) % i == 0:
            cnt += 1
        if cnt == k:
            print(i)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    A,B,K=list(map(int, input().split()))
    divisors=[]
    count = 0
    for i in range(1,min(A,B)+1):
        if min(A,B)%i==0:
            divisors.append(i)
    divisors.reverse()
    for divisor in divisors:
        if max(A,B)%divisor==0:
            count+=1
            if count==K:
                print(divisor)
if __name__ =='__main__':
    main()

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)
print(ls[-k])

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

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

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

Solution (Python):
A,B,K = map(int,input().split())
def gcd(a, b):
    while b:
    	a, b = b, a % b
    return a
GcD = gcd(A,B)
li = []
for i in range(GcD+1):
    if GcD % (i+1) == 0:
        li.append(i+1)
li.sort(reverse=True)
print(li[K-1])

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

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

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

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

from fractions import gcd

Gcd = gcd(A, B)

c = 0
for i in range(1, Gcd+1):
	if Gcd % i == 0:
		c += 1
	if c == K:
		print(Gcd//i)
		break

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):
S = input()
S = S.split()
A = S[0]
B = S[1]
K = S[2]

calcList = list()

a = 1
while a <= int(B):
    if int(A) % a == 0:
        if int(B) % a == 0:
            calcList.append(a)

    a += 1

print(calcList[len(calcList) - int(K)])

Solution (Python):
a,b,k = map(int,input().split())
c = min(a,b)
l = []
for i in range(1,c+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(' '))

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

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

Solution (Python):



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

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

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

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

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

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

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

Solution (Python):
"""


 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    A, B, K = map(int, sys.stdin.readline().split())
    cnt = 0
    i = max(A, B)
    while True:
        if (A % i) == 0 and (B % i) == 0:
            cnt += 1
            if cnt == K:
                print(i)
                exit()
        i -= 1

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

a_dis = [x for x in range(1,a+1) if a % x == 0]
b_dis = [x for x in range(1,b+1) if b % x == 0]

co_dis = sorted([i for i in a_dis if i in b_dis],reverse=True)

print(co_dis[k-1])

Solution (Python):
import fractions

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

p=fractions.gcd(A,B)

count=1

ans=p

for i in reversed(list(range(1,p))):
    if p%i==0:
        count+=1
        ans=i
    if count==K:
        break

print(ans)

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)
if k==len(l):
    print(l[0])
else:
    print(l[-k])

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

Solution (Python):
from math import sqrt

x,y,k = map(int, input().split())

def getDivisors(a , b):
    a1 = set()
    a2 = set()
    for i in range(1,int(sqrt(a)+1)):
        if a%i == 0:
            a1.add(i)
            a1.add(a//i)
    for j in range(1,int(sqrt(b)+1)):
        if b%j == 0:
            a2.add(j)
            a2.add(b//j)
    return sorted(a1.intersection(a2))


print(getDivisors(x, y)[-k])

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

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

Solution (Python):
a, b, k = list(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 numpy as np
import math
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
count_k = 0
for d in range(100,0, -1):
    if a % d == 0 and b % d == 0:
        count_k += 1
        if count_k == k:
            break

print(d)

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

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

def gcd(a, b):
	while b != 0:
		a, b = b, a % b
	return a
	
num = gcd(A, B)
ans = []
for i in range(num, 0, -1):
  if num % i == 0:
    	ans.append(i)
      
print(ans[K - 1])

Solution (Python):
a, b, k = map(int, input().split())
def calc(n):
    res = []
    for i in range(1,n+1):
        if not n % i:
            res.append(i)
    return set(res)
print(sorted(list(calc(a) & calc(b)))[-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)
    exit()

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

Solution (Python):
n1, n2, n3 = [int(i) for i in input().split()]

n4 = min(n1, n2)
c5 = 0
r6 = 0
for i1 in range(n4):
    if (n1 % (n4 - i1) == 0) and (n2 % (n4 - i1) == 0):
        c5 += 1
        if c5 == n3:
            r6 = (n4 - i1)
            break

print(r6)

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

Solution (Python):

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

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

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

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

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

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

num = min(a, b)

ans = []

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

print(ans[-k])

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

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


anss = []



c = max(a,b)

for i in range(1, c + 1):

    if a % i == 0 and b % i == 0:
        anss.append(i)



print(anss[-k])

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

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

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

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

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


abc()

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 math
A,B,K = list(map(int,input().split(" ")))
LIM = max(A,B)+1
cands = []
for i in range(1,LIM):
    if A%i == 0 and B % i == 0:
        cands.append(i)
print(cands[-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)
    else:
        continue
print(c[-k])

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

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

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

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

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

Solution (Python):
a, b, k = map(int, input().split())
l = []
n = 1
while True:
    if a%n == 0 and b%n == 0:
        l.append(n)
    elif a < n or b < n:
        break
    n += 1

print(l[-k])

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

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

a, b, k = map(int, input().split())
li = cf(a, b)
print(li[-k])

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

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

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

if a < b:
    m = a
else:
    m = b

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

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

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

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

A, B, K = list(map(int, sys.stdin.readline().split()))

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

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

ans = []

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

ans2 = []

for j in ans:
    if b % j == 0:
        ans2.append(j)

if len(ans2) == 1:
    print(ans2[0])
else:
    print(ans2[-k])

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=sorted(A,reverse=True)
print(A[k-1])

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

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

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

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

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

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

for i in range(lower, 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())
l = [i for i in range(1, 101) if A%i == 0 and B%i == 0]
print(l[-K])

Solution (Python):
int_a, int_b, division_num = map(int, input().split())
division_count = 100
select_division = []
i = 1

while i < division_count:
    if int_a % i == 0 and int_b % i == 0:
        division_count += 1
        select_division.append(i)
    i += 1

print(select_division[-division_num])

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

if A < B:
    n = A
else:
    n = B

l = []
for i in range(1, n+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())

ans = []

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

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

Solution (Python):


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

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



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

Solution (Python):
def yakusu(n):
	l=int(n**0.5)
	ans=[]
	for i in range(1,l+1):
		if n%i==0:
			ans.append(i)
			ans.append(n//i)
	ans=list(set(ans))
	ans.sort()
	return ans

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

def resolve():
	A,B,K=map(int,input().split())
	g=gcd(A,B)
	print(yakusu(g)[-K])
resolve()

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

count = 0
tmp = max(A, B)

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

Solution (Python):
import fractions as fr

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

k = 0

R = int(max(fr.gcd(A,B),1))

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

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

tmp = []

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

tmp.reverse()

print(tmp[K-1])

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

Solution (Python):
import numpy as np
A, B, K = map(int, input().split(" "))
n_list = [A, B]
N = np.min(n_list)
for i in range(N, 0, -1):
    if (A % i == 0) & (B % i == 0):
        K -= 1
        if K == 0:
            print(i)

Solution (Python):
A, B, K = map(int, input().split())
    
ans = []
for i in range(1, A+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())
divisor = []

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

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

start = min(a,b)
order = 0

for i in range(start):
    if a % (start-i) == 0 and b % (start-i) == 0:
        order += 1
        if order == k:
            print(start-i)

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

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())
N = gcd(A, B)
print(make_divisors(N)[-K])

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

def func(M, L, K):
    count = 0

    for ans in reversed(range(1,L+1)):
        if M % ans == 0 and L % ans == 0:

            count += 1

            if count == K:
                print(ans)

if A > B:
    func(A, B, K)
else:
    func(B, A, K)

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

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

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

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

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

print(res)

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[len(c)-k])

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

Solution (Python):
A,B,K=map(int,input().split())
a=[]
b=[]
for i in range(A):
  if A%(i+1) == 0:
    a.append(i+1)
for ii in range(B):
  if B%(ii+1) == 0:
    b.append(ii+1)
s=set(a)&set(b)
print(sorted(list(s))[-K])

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

Solution (Python):
A, B, K = map(int, input().split())
ans = 0
mi = min(A, B)
k = 0

for _ in range(mi):
	if A%mi == 0 and B%mi ==0:
		ans = mi
		k += 1

	if k == K:
		break

	mi -= 1

print(ans)

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[len(c)-k])

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

cnt = 0
for i in range(start, 0, -1):
  if all(x % i == 0 for x in AB):
    cnt += 1
    if cnt == K:
      break
print(i)

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

cnt = 0
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())
a    = []
b    = []
same = []
for i in range(1, A+1):
    if A % i == 0:
        a.append(i)
for i in range(1, B+1):
    if B % i == 0:
        b.append(i)
for v_a in a:
    for v_b in b:
        if v_a == v_b:
            same.append(v_a)
            
same = sorted(same, reverse=True)
print(same[K-1])

Solution (Python):

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

count = []

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

print(count[-k])

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

for i in aa:
    if i in bb:
        common.append(i)
print(common[-k])

Solution (Python):
import sys
import itertools
from collections import deque
from operator import itemgetter

input = sys.stdin.readline
A, B, K = map(int, input().split())
ans = deque()

for i in range(min(A,B),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())
lista = [a for a in range(1, A + 1) if A % a == 0]
listb = [b for b in range(1, B + 1) if B % b == 0]
listc = sorted(list(set(lista) & set(listb)))

print(listc[-K])

Solution (Python):
A, B, K = map(int, input().split())
lista = [a for a in range(1, A + 1) if A % a == 0]
listb = [b for b in range(1, B + 1) if B % b == 0]
listc = sorted(list(set(lista) & set(listb)))




print(listc[-K])

Solution (Python):
def md(n):
    d=[]
    da=d.append
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            da(i)
            if i!=n//i:da(n//i)
    d.sort()
    return d
A,B,K = map(int,input().split())
c = sorted(set(md(A)) & set(md(B)),reverse = True)
print(c[K-1])

Solution (Python):

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

Solution (Python):
data = list(map(int,input().split()))
a = data[0]
b = data[1]
k = data[2]
del data
result = []
for i in range(1,(a<=b)*a+(a>b)*b+1):
        if a%i == 0 and b%i == 0:
                result.append(i)
print(result[len(result)-k])

Solution (Python):

a, b, k = map(int, input().split())
if a > b:
    c = b
    d = a
else:
    c = a
    d = b

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

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

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

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

Solution (Python):
def intinput():
    return map(int,input().split())

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

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

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

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

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

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

lst = []

val = 1
while val != 101:
    if (A % val == 0) and (B % val == 0):
        lst.append(val)
    val += 1

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

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


def answer(A, B, n, K):
    K_list = []
    for i in range(n, 0, -1):
        if A % i == 0:

            if B % i == 0:
                K_list.append(i)
    print(K_list[K-1])


if __name__ == "__main__":
    main()

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

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

print(list[-K])

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

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

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

Solution (Python):
A,B,K= map(int,input().split())
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,k = map(int,input().split())
m = b if a<b else a
count = 0
cd = []
for i in range(1,m+1) :
	if a%i == 0 and b%i==0 :
		count+=1
		cd.append(i)
cd.sort(reverse=True)
print(cd[k-1])

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):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



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



def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    A, B, K = map(int, input().split())
    v = []
    for i in range(1, 1000):
        if A % i == 0 and B % i == 0:
            v.append(i)
    v = v[::-1]
    print(v[K - 1])

if __name__ == '__main__':
    main()

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

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

d = min(A, B)
buf = []
for i in range(d):
    c = d - i
    if A % c == 0 and B % c == 0:
        buf.append(c)
    if len(buf) >= K:
        break
print(buf[-1])

Solution (Python):
import fractions
a,b,k=list(map(int,input().split()))
g=fractions.gcd(a,b)
c=k
for i in reversed(range(1,g+1)):
  if g%i==0:
    c-=1
    if c==0:
      print(i)
      break