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: int):
    lower_divs = []
    upper_divs = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs+upper_divs[::-1]


def main():
    A, B, K = [int(i) for i in input().strip().split()]
    div_A = set(make_divisors(A))
    div_B = set(make_divisors(B))
    common = div_A.intersection(div_B)

    return sorted(list(common))[-K]


if __name__ == "__main__":
    print(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())

cnt=0
s=min(a,b)

for i in range(s,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())

k = 0
for i in range(100, 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())
yakusuu = []

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

print(yakusuu[-K])

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

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

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

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

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

Solution (Python):
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def make_divisors(n):
  lower_divisors , upper_divisors = [], []
  i = 1
  while i*i <= n:
    if n % i == 0:
      lower_divisors.append(i)
      if i != n // i:
        upper_divisors.append(n//i)
    i += 1
  return lower_divisors + upper_divisors[::-1]
A,B,K=map(int,input().split())
c=gcd(A,B)
print(make_divisors(c)[-K])

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

def make_divisors(n): 
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

a_d = set(make_divisors(a))
b_d = set(make_divisors(b))
d = sorted(list(a_d & b_d), reverse=True)

print(d[k-1])

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

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

for n in range(1,101):
  if A%n==0 and B%n==0:
    a.append(n)

print(a[-K])

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

M = min(A,B)
S = []

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

S=sorted(S)[::-1]
print(S[K-1])

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

print(ans[-K])

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

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

print(lis[k-1])

Solution (Python):
import sys
import os
import math

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

C = min(A, B)
hairetu = []

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

print(hairetu[-K])

Solution (Python):
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


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


set_a = set(make_divisors(a))
set_b = set(make_divisors(b))

both = list(set_a & set_b)
both.sort()

print(both[- k])

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

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

num = min(a, b)

cnt = 0

while cnt < k:
    if a%num == 0 and b%num == 0:
        cnt += 1
        num -= 1
    else:
        num -= 1
print(num + 1)

Solution (Python):
import numpy as np

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

if __name__ == '__main__':
    A, B, K = map(int, input().split())
    N = make_divisors(np.gcd(A, B))
    N.sort(reverse=True)
    print(N[K-1])

Solution (Python):
import sys
from io import StringIO
import unittest
import math

def resolve():
    inp = input()
    li = list(map(lambda x: int(x), inp.split(" ")))
    a = li[0]
    b = li[1]
    k = li[2]
    g = math.gcd(a, b)

    for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break
            
resolve()

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

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

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

a,b,k = map(int,input().split())
r = gcd(a,b)
e = []
for i in range(1,r+1):
    if r%i == 0:
        e.append(i)
print(e[len(e)-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)
      break

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

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

a_y = set(make_divisors(a))
b_y = set(make_divisors(b))

y = list(a_y & b_y)
y.sort(reverse=True)
print(y[k-1])

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

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

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

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

if __name__ == "__main__":
    main()

Solution (Python):


import math



from collections import deque
from collections import Counter




a,b,k=map(int,input().split())
g=math.gcd(a,b)
d=[]
for i in range(1,int(pow(g,0.5))+1):
  if g%i==0:
    d.append(i)
    if g//i not in d:
      d.append(g//i)
d.sort(reverse=True)
print(d[k-1])

Solution (Python):
import sys
from collections import deque
from itertools import *


def I(): return int(sys.stdin.readline().rstrip())


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


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


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

l.reverse()
print(l[K-1])

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

mamax=max(A,B)
count=0
for i in range(mamax,0,-1):
    if(A%i==0 and B%i==0):

        count=count+1
        if(count==K):
            print(i)
            exit()

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


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

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


if __name__ == '__main__':
    main()

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

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

print(D[-K])

Solution (Python):
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)
            break

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)
    if i > a or i > b:
        break
print(s[-k])

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

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

Solution (Python):


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

def main():
    A,B,K =map(int,input().split())
    print(solve(A,B,K))


if __name__ == '__main__':
    main()

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

    divisors.sort()
    return divisors

a,b,c=map(int,input().split())
n=math.gcd(a,b)
ans=make_divisors(n)
print(ans[-c])

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

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

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

while i > 0:
    if a % i == 0:
        if b % i == 0:
            c += 1

    if c == k:
        print(i)
        break

    i -= 1

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

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)
    return cf

lst=cf(a,b)
lst.insert(0,1)

print(lst[-k])

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    A, B, K = in_nn()

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

    print(num)


if __name__ == '__main__':
    main()

Solution (Python):
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		if a % d == 0:
			r.append(d)	
			if d * d != a: r.append(a/d)
	return r if r else [1]
a,b,k = map(int, raw_input().split(' '))
r = []
for d in f(a):
	if d in f(b):
		r.append(d)

r.sort()

print r[-k]

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)

print(li[-k])

Solution (Python):
def solve():
    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])


if __name__ == '__main__':
    solve()

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

if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline
INF = float('inf')


def main():
    A, B, K = map(int, readline().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])

if __name__ == '__main__':
    main()

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

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


print(lis[-K])

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

Solution (Python):
a,b,k=map(int,input().split())
m = min(a,b)
l = set()
for i in range(1,m+1):
  if a%i == 0 and b%i == 0:
    l.add(i)

print(sorted(list(l))[-k])

Solution (Python):
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)
            break

Solution (Python):
abk = [int(i) for i in input().split()]
a = abk[0]
b = abk[1]
k = abk[2]

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

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

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

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

    m = min(a, b)
    c = 1

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

for i in range(2, 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())
c = 0
ans = []
if a > b:
  c = b
else:
  c = a

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

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

Solution (Python):

a, b, k = map(int, open(0).read().split())


def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table


x = divisor(a)
y = divisor(b)
print(sorted(list(x & y), reverse=True)[k-1])

Solution (Python):
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


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


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


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

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

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

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

print(sorted(list(set(divisor(A)) & set(divisor(B))), reverse=True)[K-1])

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

print(AB[-K])

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

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

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

i = min(a,b)
ans = 0
while 1:
  if not(a % i)  and not(b % i):
    ans += 1
  if ans == k:
    break
  i -= 1

print(i)

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


print(el[-K])

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

def main():
    A, B, K = mi()
    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)
                return

if __name__ == '__main__':
    main()

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

Min=min(a,b)

l=[]

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



print(l[k-1])

Solution (Python):
def actual(a, b, k):
    M = max(a, b)

    common_divisors = []

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

    return common_divisors[-k]

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

Solution (Python):
def resolve():
    import sys
    input = sys.stdin.readline
    
    
    
    a, b, k = map(int, input().split())
    
    
    
    
    
    

    List = [x for x in range(1, min(a,b)+1)]
    List.sort(reverse=True)

    cnt = 0
    for y in List:
        if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break
resolve()

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

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

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

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

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

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

A_B_and_set = set(A_yaku) & set(B_yaku)
A_B_and_list = list(A_B_and_set)

ans_list=sorted(A_B_and_list,reverse=True)

ans=ans_list[K-1]
print(ans)

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

def main(a,b,k):
    ans=0
    count=0
    for i in range(min(a,b),0,-1):
        if a%i==0 and b%i==0:
            count+=1
            if count==k:
                return i


if __name__=='__main__':
    a,b,k=readinput()
    ans=main(a,b,k)
    print(ans)

Solution (Python):

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

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

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

Solution (Python):

import fractions 
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

A, B, K = map(int,input().split())
cnt = 0
_max = gcd(A,B)
while _max>=0:
    if A%_max==0 and B%_max==0:
        cnt += 1
        if cnt == K:
            print(_max)
            exit()
    _max -=1

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

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

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

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


print(ans[-K])

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

div = []

for i in reversed(range(1, 101)):
    if A%i == 0 and B%i ==0:
        div.append(i)

print(div[K-1])

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

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

print(ans)

Solution (Python):
a, b, k = map(int, input().split())
chk = 0
i = 100
while i > 0:
    if a%i==0 and b%i==0:
        chk += 1
        if chk == k:
            print(i)
            exit()
        else:
            pass
    i -= 1

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

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

Solution (Python):
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


A, B, K = map(int, input().split())
A_yaku = make_divisors(A)
B_yaku = make_divisors(B)
A_B_yaku = sorted(list(set(A_yaku) & set(B_yaku)))
print(A_B_yaku[len(A_B_yaku) - K])

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

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

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

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

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

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

lis=[]
blis=[]
count=0

sm=min([A,B])
bm=max([A,B])
for i in range(1,sm+1):
	if sm/i == sm//i:
		lis.append(i)

for i in lis:
	if bm/i == bm//i:
		blis.append(i)

blis=list(set(blis))
blis.sort()
blis.reverse()

print(blis[K-1])

Solution (Python):
import math

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

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

for i in range(y, 0, -1):
  if x%i==0 and y%i==0:
    cnt+=1
  if cnt==k:
    print(i)
    exit()

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

check = a if a < b else b

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

Solution (Python):

a, b, c = map(int, input().split())
t = []
for i in range(1, 101):
    if a%i + b%i < 1: t += [i]
print(t[-c])

Solution (Python):


a, b, k = list(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())
common_div = []
for i in range(min(A,B)+1,0,-1):
    if A%i==0 and B%i==0:
        common_div.append(i)


print(common_div[K-1])

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

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

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

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

print(i)

Solution (Python):

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

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

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

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

print(memo[-k])

Solution (Python):
A,B, K = map(int, input().split())
def divisor(n):
    div_list = []
    for i in range(1, int(1+ n**0.5)):
        if n%i == 0 and i**2 == n:
            div_list.append(i)
        elif n%i == 0:
            div_list.append(i)
            div_list.append(int(n/i))
    return div_list
lnA = divisor(A)
lnB = divisor(B)
ln = []
for i in lnA:
    if i in lnB:
        ln.append(i)
line = sorted(ln, reverse = True)
print(line[K - 1])

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

Solution (Python):
x = list(map(int, input().split()))
l = []
for i in range(1, 101):
  if (x[0]%i) == 0 and (x[1]%i) == 0:
    l.append(i)
l.sort(reverse=True)
print(l[x[2]-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):
a, b, x = map(int, input().split())
count = 0
for i in range(max(a,b),0,-1):
    if a % i == 0 and b % i == 0:
        count += 1
    if count == x:
        break
print(i)

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

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

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

count = []

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

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

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

shou = min(a,b)
dai  = max(a,b)
min_list = []

for i in range(1,shou+1):
    if shou % i == 0:
        if dai % i == 0:
            min_list.append(i)

print(min_list[-k])

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

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

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

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

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

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

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

Solution (Python):
from fractions import gcd


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(reverse=True)
    return divisors


A, B, K = map(int, input().split())
a = gcd(A, B)
Ans = make_divisors(a)

print(Ans[K-1])

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

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

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

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

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

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