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):
input_lst = input().split()
a=int(input_lst[0])
b=int(input_lst[1])
k=int(input_lst[2])
count = 0
for i in range(a):
  if (a%(a-i)==0 and b%(a-i)==0):
    if count+1 == k:
      print(a-i)
      break
    else:
      count += 1

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

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

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

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

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

print(divisors[k-1])

Solution (Python):
A,B,K = [int(x) for x in 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)
      exit()

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())
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
div = min(a,b)
while cnt < k:
    if a%div == 0 and b%div == 0:
        cnt += 1
    div -= 1
print(div + 1)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    a, b, k = list(map(int, input().rstrip('\n').split()))
    x = []
    for i in range(1, max(a, b) + 1):
        if a % i == 0 and b % i == 0:
            x.append(i)
    print(sorted(x)[-k])


if __name__ == '__main__':
    slove()

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

print(result[k - 1])

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

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

List = []
c = 1
while c <= min(A,B):
    if A%c == 0 and B%c == 0:
        List.append(c)
    c += 1

print(List[K*(-1)])

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

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

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

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

Solution (Python):
from fractions import gcd
A, B, K = map(int, input().split())
g = gcd(A, B)
k = 1
r = 0
res = 0
while True:
  if k > min(A, B):
    print(res)
    exit(0)
  if r == K:
    print(res)
    exit(0)
  if g % k == 0:
    res = g // k
    r += 1
  k += 1

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):
def MAP(): return list(map(int,input().split()))

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

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

Solution (Python):
A, B, K = map(int, input().split())
def calcgcd(a, b):
  if a > b:
    a, b = b, a
  while a > 0:
    a, b = b%a, a
  return b
d = calcgcd(A, B)
L = []
for i in range(1, d+1):
  if d%i == 0:
    L.append(i)
r = L[-K]
print(r)

Solution (Python):
from fractions import gcd
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 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(int,input().split())

a_list=make_divisors(a)
b_list=make_divisors(b)

a_and_b=set(a_list) & set(b_list)

ans=sorted(list(a_and_b),reverse=True)
print(ans[k-1])

Solution (Python):
import fractions
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
a = make_divisors(fractions.gcd(A,B))

ans = a[-K]
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[-k])

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)


print(list[-(k)])

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

div = []

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

print(div[-K])

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

print(s[k-1])

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

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

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

result=result[::-1]

print(result[k-1])

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

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

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

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

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

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


lres = []

for i in range(0, len(ya)):
    if ya[i] in yb:
        lres.append(ya[i])

lres.reverse()

print(lres[k - 1])

Solution (Python):
A, B, K = map(int, input().split())
small = min(A, B)
both = [i for i in range(1, small+1)]
gcd = []

for i in both:
    if A % i == 0 and B % i == 0:
        gcd.append(i)

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

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

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

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

l1 = set(l1)
l2 = set(l2)

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

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

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

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

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

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

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):
"""
【ABC120】
B_K-th_Common_Divisor



import sys


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

lst = []
A, B, K = MI()
for i in range(1, min(A, B)+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())
n=A
while K:
  if A%n==B%n==0:
    K-=1
  n-=1
print(n+1)

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

div_a = set()
div_b = set()

for i in range(1, 101):
    if a % i == 0:
        div_a.add(i)
    if b % i == 0:
        div_b.add(i)

ans = sorted(list(div_a & div_b))
print(ans[-k])

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

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

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

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

print(d[-K])

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

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

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

Solution (Python):
a,b,k=map(int,input().split())
c=0
for i in range(min(a+1,b+1),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())
ans=0
for i in reversed(range(1,min(a,b)+1)):
  if a%i==0 and b%i==0:
    ans += 1
    if ans == k:
      print(i)
      break

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

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

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

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

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

if A <= B:
    A=A
    B=B

else :
    C=A
    A=B
    B=C



li=[]

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

A%1

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

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

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

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

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

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

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

print(ans[-K])

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

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

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

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

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

def main():
    A,B,K = map(int, input().split())
    a = make_divisors(A)
    b = make_divisors(B)
    a = set(a) & set(b)
    a = sorted(list(a), reverse=True)
    print(a[K-1])

if __name__ == '__main__':
    main()

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

lis=[]
if a>b:
    for i in range(b):
        if a%int(b-i)==0 and b%int(b-i)==0:
            lis.append(int(b-i))

else:
    for i in range(a):
        if a%(a-i)==0 and b%(a-i)==0:
            lis.append(int(a-i))


print(lis[c-1])

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

if __name__ == "__main__":
    main()

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

Solution (Python):
from fractions import gcd

a, b, k = list(map(int, input().split()))
count = 1
for i in range(gcd(a, b), 0, -1):
    if a % i != 0 or b % i != 0:
        continue
    else:
        if count == k:
            print(i)
            break
        else:
            count += 1

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

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


main()

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

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

Solution (Python):
A, B, C = 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


cf_list = cf(A, B)
print(cf_list[-C])

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

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

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

ans=[]
i=min(a,b)
while(len(ans)<k):
    if (a% i==0) and (b%i==0):
        ans.append(i)
    i-=1
print(ans[-1])

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

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

print(num)

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

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

print(kouyakusuu[-1 * K])

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

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

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

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.reverse()
if k>len(c):
    print(1)
else:
    print(c[k-1])

Solution (Python):
a,b,k = map(int,input().split())
i = 0
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())
As=[]
for i in range(1,a+1):
  if a%i==0:
    As.append(i)
Bs=[]
for i in range(1,b+11):
  if b%i==0:
    Bs.append(i)
ans=[]
for A in As:
  if A in Bs:
    ans.append(A)
ans.sort()
print(ans[-c])

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

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

print(arr[-k])

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

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

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

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

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

print(sorted(lst)[len(lst)-k])

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

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

for j in range(k-1):
  lst.remove(max(lst))
  
print(max(lst))

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

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

nums=[]

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


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

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

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

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

print(li[-K])

Solution (Python):
def main():
    a,b,k=map(int,input().split())
    print(make_divisors(gcd(a,b))[k-1])
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[::-1]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
main()

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)

print(tmp[-k])

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

cnt = 0
for i in range(gcd,0,-1):

  if gcd % i == 0:
    cnt += 1
    if cnt == K:
      print (i)
      break

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

    for j in range(k-1):
        c.remove(max(c))

    print(max(c))


if __name__ == "__main__":
    test()

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

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

db = {int(i) for i in range(1,b+1) if b%i == 0}

dab = da & db

dabl = list(dab) 

dabl.sort()

print(dabl[-k])

Solution (Python):
A,B,C= [int(i) for i in input().split()]
while(True):
	D = A%B
	if D == 0:
		if C == 1:
			print(B)
			exit()
		break
	A=B
	B=D
D = 1 + B//2
c =0
for i in range(B):
	if B%D == 0:
		c += 1
	if c == C-1:
		print(D)
		break
	D -= 1

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

Solution (Python):
def main():
    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:
            return i

if __name__ == '__main__':
    print(main())

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())
C=[]
i=1
while i!=min(A,B)+1:
    if A%i==0 and B%i==0:
        C.append(i)
    i+=1
print(sorted(C)[-K])

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

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

gcd=fractions.gcd(a,b)
div=[]
for i in range(1, int(gcd**0.5)+1):
  if gcd%i==0:
    div.append(i)
    if i!= gcd//i:
      div.append(gcd//i)
print(sorted(div,reverse=True)[k-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(reverse=True)
    return divisors
A,B,K = map(int,input().split())
nums1=make_divisors(A)
nums2=make_divisors(B)
ans=0
count=0
for a in nums1:
    if a in nums2:
        count+=1
    if count==K:
        ans=a
        break
print(ans)

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)

print(tmp[-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, k = (int(i) for i in input().split())

div_a = {d for d in range(1,a+1) if a%d == 0}
div_b = {d for d in range(1,b+1) if b%d == 0}
com_d = sorted(list(div_a & div_b),reverse=True)
print(com_d[k-1])

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

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

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

print(str(c[-k]))

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

    
    return divisors

A, B, K = map(int,input().split())
a = set(make_divisors(A))
b = set(make_divisors(B))
c = sorted(list(a & b))
print(c[-1 * K])

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

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

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

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

count = 0
k = GCD
ans = 0
while count < K:
    if GCD % k == 0:
        count+=1
        ans = k
    k -= 1

print(ans)

Solution (Python):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
        
a,b,k = map(int,input().split())
cnt=1

ans=gcd(a,b)
n=ans
if not(k==1):
    for i in range(n):
        c=n-i-1
        if(a%c==0 and b%c==0):
            ans=n-i-1
            cnt+=1
        if(cnt==k):
            break
      
print(ans)

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

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

Solution (Python):


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

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

Solution (Python):


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

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



t = len(ans)-k
print(ans[t])

Solution (Python):
a, b, k = map(int, input().split())
ad = [i for i in range(1, a + 1) if a % i == 0]
bd = [i for i in range(1, b + 1) if b % i == 0]
print(sorted(set(ad) & set(bd))[-k])

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

list=[]

if a>b:
    tmp=a
else:
    tmp=b

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

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

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

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

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

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

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

print(cd[-k])

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

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

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

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

a,b,k=map(int,input().split())
d=fractions.gcd(a,b)
l=[]
for i in range(1,d+1):
        if a%i==0 and b%i==0:
                l.append(i)

l=l[::-1]
print(l[k-1])

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


if __name__ == "__main__":
    print(solve())

Solution (Python):
import math
import copy

inputa = input().split()



a = int(inputa[0])
b = int(inputa[1])
c = int(inputa[2])



















min = min([a, b])
cnt = 0

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

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

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

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



def solve(A, B, K):
    mx = min(A, B)
    div_ab = list(filter(
        lambda x: A % x == 0 and B % x == 0,
        range(1, mx+1)))
    return div_ab[-K]


if __name__ == '__main__':
    A, B, K = map(int, input().split())

    ans = solve(A, B, K)

    print(ans)

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

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

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

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

Solution (Python):
a, b , k = map(int, input().split(' '))
count = 0
result = 1
if a < b:
    i = a
else:
    i = b
while count != k:
    if a%i == 0 and b%i == 0:
        count += 1
        result = i
    i -= 1
print(result)

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

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

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

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

a_l.sort(reverse=True)
b_l.sort(reverse=True)

cnt = 0
for i in a_l:
    for j in b_l:
        if i == j:
            cnt += 1
            if cnt == k:
                print(i)
                exit()