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())
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 = map(int,input().split())
def gcd(x,y):
    if x<y:x,y = y,x
    if y==0:return x
    return gcd(y,x%y)
C = gcd(A,B)
Z = []
for i in range(1,C+1):
    if i*i>C:break
    if C%i==0:
        Z.append(i)
        if i!=C//i:
            Z.append(C//i)
Z.sort()
print(Z[-K])

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

Solution (Python):

a, b, k = map(int, input().split())
divisors = [1]

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

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

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

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

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

import io

n,m,k=map(int, input().split())

data=n

while k:
  if n%data==m%data==0:
    k-=1
  data-=1
print(data+1)

Solution (Python):
i = list(map(int, input().split()))

def kcd(A, B, K):
    cd_list = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            cd_list.insert(0,i)
    return cd_list[K - 1]

print(kcd(i[0],i[1],i[2]))

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

Solution (Python):
def euclides(a, b):
    r = a%b
    q = 0
    while(r != 0):
        q = a/b
        a = b
        b = r
        r = a%b
    q = a/b
    return b

foo = list(map(int, input().split()))
A = foo[0]
B = foo[1]
K = foo[2]

GCD = euclides(A, B) 
div = 1
while(GCD > 0):
    if div == K:
        break
    GCD -= 1
    if A%GCD == 0 and B%GCD == 0:
        div += 1

print(GCD)

Solution (Python):
a, b, c = map(int, input().split())
divisores = list(range(1, min(a,b) + 1))
res = list(filter(lambda x: min(a, b) % x == 0 and max(a, b) % x == 0 , divisores))
print(res[-c])

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

Solution (Python):
i = input().split()

a,b,k = list(map(int, i))

v = []

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

v.reverse()

try:
    print(v[k-1])
except:
    pass

Solution (Python):
numerosStr = input().split(" ")
numero=[]
for j in numerosStr:
    numero.append(int(j))
contador=[1]

for i in range(2,numero[1]+1):
    if numero[0]/i == int(numero[0]/i) and numero[1]/i == int(numero[1]/i):
        contador.append(i)
print(contador[-numero[2]])

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

lista, aux, aux1 =[], max(A, B), min(A, B)
for i in range(1, aux1+1):	
	if((aux%i) == 0 and (aux1%i) == 0):
		lista.append(i)		
		lista.sort(reverse=True)

if(len(lista)==1):
	print(lista[0])
else:
	ans = lista[K-1]
	print(ans)

Solution (Python):
line = input()
a, b, c = [int(n) for n in line.split()]
if a>b:
    maior=a
    menor=b
else:
    maior=b
    menor=a
v = []
for i in range(1, menor+1, 1):
    if menor%i==0 and maior%i==0:
        v.append(i)
print(v[-c])

Solution (Python):
def function(A, B, K):
    i = 1
    lista = []
    while i <= min(A, B):
        if A%i == 0 and B%i == 0:
            lista.append(i)
        i+=1
    lista.sort()
    return lista[-K]

line = input()
A, B, K = [int(n) for n in line.split()]
print(function(A, B, K))

Solution (Python):
import itertools

flatten_iter = itertools.chain.from_iterable
def factors(n):
    return set(flatten_iter((i, n//i) 
                for i in range(1, int(n**0.5)+1) if n % i == 0))

line = input()
numbers = [int(n) for n in line.split()]
factors_a = factors(numbers[0])
factors_b = factors(numbers[1])
common_factors = list(factors_a.intersection(factors_b))
common_factors.sort(reverse=True)
predicted_value = common_factors[numbers[2] - 1]
print(predicted_value)

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

divisors = []

m = min(a, b)
x = 1
while True:
    
    if x > min(a, b):
        break
    if a % x == 0 and b % x == 0:
        divisors.append(x)
    x += 1

print(divisors[-k])

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

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

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

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

Solution (Python):
A, B, K = map(int, input().split())
C = 0
for i in range(min(A, B),  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())
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())
maxab = min(A, B)
lst = []
for num in range(1, maxab+1):
    if A%num==0 and B%num==0:
        lst.append(num)
lst.sort(reverse=True)
print(lst[K-1])

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

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

print(ans[-K])

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

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

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:
        ans = i
        break
print(ans)

Solution (Python):
s = input().rstrip().split(' ')
a = int(s[0])
b = int(s[1])
k = int(s[2])
mini = min(a, b)
maxi = max(a, b)
lst = []
for i in range(1, mini):
  if a % i == 0 and b % i == 0:
    lst.append(i)
if maxi % mini == 0:
  lst.append(mini)
lst.reverse()
print(int(lst[k-1]))

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

Solution (Python):
def main():
    

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

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

    g = gcd(A, B)
    rt = int(pow(g, 0.5))

    divisors = set()
    for d in range(1, rt + 1):
        if g % d == 0:
            divisors.add(d)
            divisors.add(g // d)

    ans = sorted(divisors, reverse=True)[K - 1]
    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)
        break

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

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

if a >= b:
    a, b = b, a

ans = [0] * a

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

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

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):
from fractions import gcd
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()
    print(divisors[len(divisors) - k])
make_divisors(gcd(a, b))

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

Solution (Python):
import math
from functools import reduce
import itertools

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

Solution (Python):
import math

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

minAB = min(A, B)
kcount = 1

if minAB == 1:
	print(1)
else:
	for i in range (0, minAB):
		if A%(minAB-i) == 0 and B%(minAB-i) == 0 and kcount <K:
			kcount+=1
		elif A%(minAB-i) == 0 and B%(minAB-i) == 0:
			print(minAB-i)
			exit()
		else:
			continue

Solution (Python):
def resolve():
    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)
    n = sorted(n, reverse=True)
    print(n[k-1])
resolve()

Solution (Python):
def main():
    A, B, K = map(int, input().split(' '))
    if A < B:
        A, B = B, A
    cnt = 0
    result = -1

    for b in range(B, 0, -1):
        if B % b == 0:
            if A % b == 0:
                cnt += 1
                if cnt == K:
                    result = b
                    break
    print(result)


if __name__ == '__main__':
    main()

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

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

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

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

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

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


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


a = sorted(list(divisors(A) & divisors(B)))
print(a[-K])

Solution (Python):
a,b,c = map(int, input().split())
a1 = [i for i in range(1,a+1) if a%i==0]
b1 = [j for j in range(1,b+1) if b%j==0]
print(sorted(list((set(a1) & set(b1))))[-c])

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)

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

Solution (Python):
from fractions import gcd


def main():
    a, b, k = map(int, input().split())
    d = []
    g = gcd(a, b)
    i = 1
    while i * i <= g:
        if g % i == 0:
            d.append(i)
            if i * i != g:
                d.append(g // i)
        i += 1
    d.sort()
    print(d[-k])


if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
    A, B, K = (int(i) for i in 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])


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

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

a, b, k = MAP()
c = make_divisors(a)
d = make_divisors(b)
e = list(set(c) & set(d))
e.sort(reverse=True)
print(e[k - 1])

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

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):
from fractions import gcd
A,B,K = map(int,input().split())
r = []

g = gcd(A,B)
for i in range(1,g+1):
  if g%i == 0:
    r.append(i)
    
print(r[-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):
a,b,k=map(int,input().split())
count=0
s=[]
for i in range(1,101):
  if a%i==0 and b%i==0:
    s.append(i)
print(s[-k])

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

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

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

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)
        
A = set(A)
B = set(B)

OK = A & B
OK = sorted(OK)

print(OK[-k])

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

Solution (Python):
import fractions
A,B,K=map(int, input().split())
GCD=fractions.gcd(A,B)
bunbo = GCD
count = 1
while count < K:
  bunbo = bunbo - 1
  if GCD % bunbo==0:
    count = count + 1
print(bunbo)

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

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

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

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

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

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

print(koyaku[-k])

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

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

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

loop=0
if a<b:
    loop=a
else:
    loop=b
ans=0

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

print(ans)

Solution (Python):

def make_divisors(a,b):
    divisors = []
    for i in range(1, a+1):
        if a % i == 0:
            if b % i == 0:
                divisors.append(i)

    divisors.sort(reverse=True)
    return divisors
a,b,k = map(int, input().split())
y = make_divisors(a,b)
print(y[k-1])

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

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

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

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

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

print(ans[-K])

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

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    if x % y == 0:
        return y
    else:
        return gcd(y, x % y)
a, b, k = map(int, readline().split())
g = gcd(a, b)
l = []
for i in range(1, g + 1):
    if g % i == 0:
        l.append(i)
print(l[-k])

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

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

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

Solution (Python):


from fractions import gcd










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

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

c = gcd(a,b)
anslis = makedivs(c)
anslis.sort()

print(anslis[-k])

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

ans =[]

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

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

Solution (Python):
A, B, K = [int(num) for num in input().split()]
M, m = max(A, B), min(A, B)
yakusu = []
koyakusu = []
for i in range(1, m+1):
  if m % i == 0:
    yakusu.append(i)
  else:
    continue
for j in yakusu:
  if M % j == 0:
    koyakusu.append(j)
print(koyakusu[-K])

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

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

print(ans[-K])

Solution (Python):
a,b,k=map(int,input().split())
ans=[]
for i in range(1,min(a,b)+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())
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()
    print(divisors[len(divisors) - k])
make_divisors(gcd(a, b))

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    a, b, k = input_nums()
    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: break
    print(i)

if __name__ == '__main__':
    main()

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

lis = []

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

Solution (Python):


A,B,C=map(int,input().split())
MAX=0

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

ans=list(set(make_divisors(A)) & set(make_divisors(B)))
ans.sort(reverse=True)
print(ans[C-1])

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

ans = cf(a,b)
ans.sort(reverse=True)

print(ans[k-1])

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

c = min(a,b)

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

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

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

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


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

print(divisors(gcd(a, b))[-k])

Solution (Python):

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

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


a,b,k = LI()
cnt = 0
for i in range(1,max(a,b)+1)[::-1]:
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        print(i)
        quit()

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

if __name__ == '__main__':
    main()

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

c = 0
for i in range(1,101)[::-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 = []
for i in range(101,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())
L = []
for i in range(1,101):
  if A % i == 0 and B % i == 0:
    L.append(i)
S = sorted(L, reverse = True)
print(S[K-1])

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  a,b,k = map(int,input().split())
  k -= 1 
  ANS = []
  if a > b:
    a,b = b,a
  for i in range(1,a+1):
    if a%i == 0 and b%i == 0:
      ANS.append(i)
  ANS = sorted(ANS,reverse=True)
  print(ANS[k])
if __name__ == '__main__':
  main()

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

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

print(N[-K])

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

ans=[]
m=min(a,b)

for i in range(1,m+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 = [int(i) for i in 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):
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    a,b,k = map(int, input().split())

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

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

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

print(cf(a,b)[-k])

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

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

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,k = iim()
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 = map(int,input().split())

x = 0
m = 1

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

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

if __name__ == '__main__':
  main()

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

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

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

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

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


print(m[k-1])

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