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

C = min(A,B)
num = 0
ans = []
for i in range(1,C+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())
l=[]

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

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

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


print(common_divisors[-K])

Solution (Python):
a,b,k = map(int,input().split())
class stack:
    def __init__(self):
       self.items = []
        
    def is_empty(self):
       return self.items == []
        
    def push(self, item):
       self.items.append(item)
        
    def pop(self):
       return self.items.pop()
        
    def peek(self):
       return self.items[len(self.items)-1]
        
    def size(self):
       return len(self.items)

ansstack = stack()
for i in range(1, max(a, b) + 1):
    if a % i == 0 and b % i == 0:
        ansstack.push(i)
ans = 0
for i in range(k):
    ans = ansstack.pop()
print(ans)

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

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)
print(d[-1*k])

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

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

max_num = max(A, B)
min_num = min(A, B)
divs = [m for m in range(1, min_num+1) if min_num % m == 0]

ans = []
for d in divs:
    if max_num % d == 0:
        ans.append(d)
ans = sorted(ans)[::-1]
print(ans[K-1])

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

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    A,B,K=map(int,input().split())
    c=0
    for i in range(100,-1,-1):
        if A%i==B%i==0:
            c+=1
        if c==K:
            print(i)
            exit()

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):

 
import math
import itertools
import sys
import copy
 





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

if A > B :
  tmp = A
  A = B
  B = tmp

ki = 0
for i in range(A) :
  n = A-i
  if A%n == 0 and B%n == 0 :
    ki += 1
    if ki == K :
      print (n)

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

res = []

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

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

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

  
print(c)

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


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

Solution (Python):
a,b,k = map(int, input().split())
a_div = {i for i in range(1,a+1) if a%i == 0}
b_div = {i for i in range(1,b+1) if b%i == 0}
sorted_div = sorted(list(a_div & b_div), reverse=True)
print(sorted_div[k-1])

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

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

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

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

for i in range(1, 101):
    if a%i == 0:
        if b%i ==0:
            k_list.append(i)

print(k_list[-k])

Solution (Python):
from fractions import gcd
a,b,k = map(int,input().split())
x = gcd(a,b)
now = 1
if now == k:
    print(x)
    exit()
for i in range(x-1,-1,-1):
    if x%i == 0:now += 1
    if now == k:
        print(i)
        exit()

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

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

Solution (Python):
A, B, N = map(int, input().split())
k = 0

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

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

A = []

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

Solution (Python):
import sys
bbn=1000000007
	

		
def main():
	a, b , k = map(int, input().split())
	c=0
	ll=[]
	for i in range(1,200):
		if a% i==0 and b%i==0:
			ll.append(i)
	return ll[-1*k]
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

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

lst = sorted(list(s1 & s2), reverse=True)

print(lst[K-1])

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

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

else:
    lst.append(1)

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

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

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

divided = []

for i in reversed(range(1,101,)):
    if (a % i == 0) and (b % i == 0):
        divided.append(i)

print(divided[k-1])

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

print(l[c-1])

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

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

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

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

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

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7




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

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

Solution (Python):
A, = [list(map(int, s.split())) for s in open(0)]
x, y = min(A[:2]), max(A[:2])
cds = []
for i in range(1, x + 1):
    if (x % i == 0) and (y % i == 0):
        cds.append(i)

print(sorted(cds, reverse=True)[A[2]-1])

Solution (Python):
N = list(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(N[0],N[1])
print(ans[-N[2]])

Solution (Python):
from fractions import gcd
a,b,k=map(int,input().split())
c=gcd(a,b)
t=[c]
while(c>1):
  c=c-1
  if(a%c==0 and b%c==0):
    t.append(c)
print(t[k-1])

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

a,b,k = map(int,input().split())
g = gcd(a,b)
cnt = 1

while cnt != k:
    g -= 1
    if a%g == 0 and b%g == 0:
        cnt += 1
else:
    ans = g

print(ans)

Solution (Python):
from fractions import gcd

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

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

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


if __name__ == '__main__':
    solve()

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

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

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

ans = cf(A, B)
ans.sort(reverse=True)

print(ans[K-1])

Solution (Python):
import math
a, b, k = map(int, input().split())
lst_max_num = []
lst_both = []
max_num = max(a, b)
min_num = min(a, b)
n = int(math.sqrt(max_num))
for i in range(1, n + 1):
    if max_num % i == 0 and max_num // i != i:
        lst_max_num.append(i)
        lst_max_num.append(max_num // i)
    elif max_num % i == 0 and max_num // i == i:
        lst_max_num.append(i)

for i in lst_max_num:
    if  min_num % i == 0:
        lst_both.append(i)

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

Solution (Python):


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

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

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

cnt = 0

i = min(a,b)
for x in range(min(a,b)):
    
    if ( a % i == 0 and b % i ==0):
        cnt += 1       

    if (cnt == k):
        print(i)
        exit()
    i -= 1

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

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

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

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

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

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

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

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

Solution (Python):
a,b,k=map(int,input().split())
ans=[]
def gcd(a,b):
    if b>a:
        return(gcd(b,a))
    elif b==0:
        return a
    else:
        return(gcd(b,a%b))
g=gcd(a,b)
for i in range(1,g+1):
    if g%i==0:
        ans.append(i)
print(ans[-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
  return set(table)

ad=divisor(a)
bd=divisor(b)

abd = list(set(ad & bd))
abd.sort()

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

    
    return divisors

C=make_divisors(gcd(a,b))
C.sort()

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

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, kth = map(int, input().split())
count = 0
for div in range(min(a, b), 0, -1):
    if a % div == 0 and b % div == 0:
        count += 1
        if count == kth:
            print(div)
            exit()

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

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

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

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

print(s[-k])

Solution (Python):
a, b, k = [int(i) for i in 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 os, sys, re, math

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

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

Solution (Python):
A, B, K = [int(s) for s in input().split(' ')]
k = 0
for n in reversed(range(1, 101)):
    if A % n == 0 and B % n == 0:
        k += 1    
        if k == K:
            print(n)
            break

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

Solution (Python):
def common_divisor(a, b):
  ans = []
  mn = min(a, b)
  mx = max(a, b)
  for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0 :
      ans.append(i)
  
  return ans

a, b, c = [int(x) for x in input().split()]
kys = common_divisor(a, b)
print(kys[len(kys) - c])

Solution (Python):
a, b, n = map(int, input().split())
alis = [x for x in range(1, a + 1) if a % x == 0]
blis = [x for x in range(1, b + 1) if b % x == 0]
lis = list(set(alis) & set(blis))
print(sorted(lis,reverse=True)[n - 1])

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

Solution (Python):
import sys
import fractions
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

A, B, K = [int(x) for x in readline().rstrip().split()]
gcd_ = fractions.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(gcd_)[-K])

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

g = gcd(a, b)
n = 0
for i in range(g, 0, -1):
  if g % i == 0:
    n += 1
  if n == k:
    print(i)
    quit()

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

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

    
    return divisors

list_a = make_divisors(a)
list_b = make_divisors(b)
common = list(set(list_a) & set(list_b))
common.sort()
print(common[-k])

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

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

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

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

print(i)

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

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

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

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

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

    if(a%z==0 and b%z==0):
        n+=1;
        if n==k:
            break
    z-=1

print(z)

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

print(c[-k])

Solution (Python):

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd



def divisor(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret

def MI(): return map(int, input().split())


def main():
    A, B, K = MI()
    common = []
    a = divisor(A)
    b = divisor(B)

    for i in range(len(a)):
        if a[i] in b:
            common.append(a[i])

    common.sort()

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


if __name__ == '__main__':
    main()

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

div_list = []

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

print(div_list[-K])

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

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

Solution (Python):
a, b, k = map(int, input().split())
la = [x for x in range(1, a + 1) if a % x == 0]
lb = [x for x in range(1, b + 1) if b % x == 0]
l = set(la) & set(lb)
n = sorted(l, reverse=True)
print(list(n)[k - 1])

Solution (Python):
import math

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

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

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



if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(A, B, K):
    """Test Case
    >>> print_ans(8, 12, 2)
    2
    >>> print_ans(100, 50, 4)
    5
    >>> print_ans(1, 1, 1)
    1
    """
    counter = 0
    for i in range(1, min(A, B) + 1)[::-1]:
        if A % i == 0 and B % i == 0:
            counter += 1
        if counter == K:
            print(i)
            break


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

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

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

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

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)[len(cf(A,B)) - K ])

Solution (Python):
A, B, K = list(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)
    if len(ans) == K:
        break
print(ans[-1])

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)
print(ans[-1 * K])

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

n = 0

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

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

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

cnt = 0

for n in reversed(range(1, 101)):
    if a % n == 0 and b % n == 0:
        cnt += 1
        if cnt == k:
            print(n)

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

Solution (Python):

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

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

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

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


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


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


print(make_divisors(gcd(a, b))[k-1])

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

s = []

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

sorted(s)

s = s[::-1]

print(s[k-1])

Solution (Python):
a, b, k = map(int, input().split())
sa = [i for i in range(1, 101) if a % i == 0]
sb = [i for i in range(1, 101) if b % i == 0]
li = set(sa) & set(sb)
print(sorted(li, reverse=True)[k - 1])

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

Solution (Python):
a, b, k = map(int, input().split())
def divide(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

aa = set(divide(a))
bb = set(divide(b))
c = aa & bb
cc = list(c)
cc.sort(reverse = True)
print (cc[k-1])

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

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

print(new[-K])

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

gcd=fractions.gcd(A,B)
k=0
if gcd==1:
  print(1)
else:
  for i in reversed(range(1,gcd+1)):
    if gcd%i==0:
      k+=1
      if k==K:
        print(i)
        break

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

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

    
    return divisors

AAA =make_divisors(A)
BBB =make_divisors(B)

CCC = []

for i in range(len(AAA)):
    if AAA[i] in BBB:
        CCC.append(AAA[i])

CCC = sorted(CCC,reverse=True)

print(CCC[K-1])

Solution (Python):
def divisionize(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 = sorted(divisors)
    return divisors

a,b,k = map(int, input().split())
a_ = set(divisionize(a))
b_ = set(divisionize(b))
c = sorted(list((a_&b_)))[::-1]
print(c[k-1])

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

Solution (Python):
A, B, K = map(int, input().split())
def gcd(a, b):
  if a < b:
    return gcd(b, a)
  elif b == 0:
    return a
  else:
    return gcd(a%b, b)
C = gcd(A, B)

def Cs(C):
  i = 1
  tail = []
  while i*i < C:
    if C%i == 0:
      yield i
      tail.append(C//i)
    i += 1

  if i*i == C:
    yield i
  yield from tail[::-1]

xs = list(Cs(C))
print(xs[-(K)])

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

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

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

l = [0]*100
k = 0

for i in range(1,101):
	if a%i==0 and b%i==0 :
		l[k] = i
		k = k+1

l.sort()

print(l[99-s+1])

Solution (Python):

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

divisors = []

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

divisors.sort(reverse=True)

print(divisors[k - 1])

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

Al = []
Bl = []

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

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

ABl = []
for i in range(len(Al)):
    for j in range(len(Bl)):
        if Al[i] == Bl[j]:
            ABl.append(Al[i])

ABl.sort(key=lambda x: -x)

print(ABl[K - 1])

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

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

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

cnt = 0
ans = 0
for i in reversed(range(1, 101)):
    if a%i == b%i == 0:
        cnt+=1
        if cnt == k:
            ans = i
            break
            
print(ans)

Solution (Python):
import math

a,b,c = map(int,input().split())
list1 = []
def insu(a,b):
    global list1
    for i in range(1,min(a,b)+1):
        if a%i==0 and b%i==0:
            list1.append(i)

if __name__ == "__main__":
    insu(a,b)
    print(list1[-c])

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)
if min(A, B) == 1:
  print(1)
else:
  print(l[-K])

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

A,B,K = map(int, input().split())
g = GCD(A,B)
i = 1
glist = []
while i*i<=g:
    if g % i == 0:
        glist.append( i )
        if i*i!=g:
            glist.append( g//i )
    i+=1;
glist.sort(reverse=True)
print(glist[K-1])

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

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

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

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

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

Solution (Python):

import sys










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

def main():
    a, b, k = [int(x) for x in sys.stdin.readline().split()]

    n = gcd(a, b)
    count = 0
    while True:
        if a % n == 0 and b % n == 0:
            count += 1
            if count == k:
                print(n)
                sys.exit()
        n -= 1


if __name__ == "__main__":
    main()

Solution (Python):
import fractions
a,b,K = map(int,input().split())
g = fractions.gcd(a,b)
cnt = 0
ans = 0
for i in range(g,0,-1):
    if g % i == 0:
        cnt += 1
        if cnt == K:
            ans = i
            break
    else:
        pass
print(ans)