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

a, b, k = list(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):
import math
A,B,K = map(int,input().split())
Alist = []
Blist = []
ab = max(A,B)
for a in range(1,ab+1):
    aa = A%a
    ba = B%a
    if aa == 0:
        Alist.append(a)
    if ba == 0:
        Blist.append(a)
AB = sorted(set(Alist) & set(Blist))
z = len(AB)
print(AB[z-K])

Solution (Python):
A,B,K = list(map(int,input().split()))
def solve(A,B,K):
    k = 1
    for i in reversed(range(1,max(B+1,A+1))):
        if A%i == 0 and B%i == 0:
            if K == k:
                return i
            else:
                k = k + 1
print(solve(A,B,K))

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

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

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

num = nums[-K]
print(num)

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

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

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

A, B, K = map(int, input().split())
G = gcd(A, B)
count = 0
for i in range(G, 0, -1):
  if G % i == 0:
    count += 1
    if count == K:
      print(i)

Solution (Python):
tmp = list(map(int, input().split()))
A, B, K= tmp[0], tmp[1], tmp[2]

i, j = A, B
if A > B:
  i, j = B, A

for k in reversed(range(i)):
  tmp = k + 1
  if i % tmp == 0 and j % tmp == 0:
    K -= 1
  if K == 0:
    print(tmp)
    break

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

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

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


cnt = 0

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

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

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

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

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

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

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

c = 0

for i in range(A,0,-1):
    if (A%i)+(B%i) == 0:
        c+=1
        if c == K:
            print(i)

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

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


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

Solution (Python):
a,b,c=map(int,input().split())
i=0
count=0
while True:
    a,b=max(a,b)%min(a,b),min(a,b)
    if a==0:
        break
while count<c:
    i+=1
    if b%i==0:
        count+=1
print(b//i)

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

if __name__ == '__main__':
    main()

Solution (Python):
A,B,K = map(int, raw_input().split())
num = 1                                                                                                             
ans = []
while(num <= 100):
    if A%num == 0 and B%num == 0:
        ans.append(num)
    num += 1
print ans[-K]

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

Solution (Python):
def main():
    A, B, K = map(int, input().split())
    CDD = []
    maxi = max(A,B)
    mini = min(A,B)
    for i in reversed(range(1, mini + 1)):
        if mini % i == 0:
            if maxi % i == 0:
                CDD.append(i)
    print(CDD[K - 1])
main()

Solution (Python):
def kth_common_divisor(a, b, k):
    min_ = min(a, b)
    divisors = []

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

    return divisors[-k]


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

Solution (Python):
ab = input().split()
a, b, k = int(ab[0]),int(ab[1]),int(ab[2])

count = 0
i = 1
list = []

while i<=100:
    if a%i==0 and b%i==0:
        list.append(i)
        if i==b:
            break
    i += 1

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

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

ans_list=[]

maximum=max(A,B)

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

print(ans_list[::-1][K-1])

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

def maxDivider(divider, divided):
    while(True):
        rest = divided % divider
        if rest == 0:
            return divider
        else:
            divided = divider
            divider = rest

def dividers(x):
    dividers = []
    divider = 1
    while(divider <= x / divider):
        if x % divider == 0:
            dividers.append(divider)
            if divider == int(x / divider):
                pass
            else:
                dividers.append(int(x / divider))
        else:
            pass
        divider += 1
    return sorted(dividers)


if A > B:
    A, B = B, A
else:
    pass

ans = dividers(maxDivider(A, B))[-K]
print(ans)

Solution (Python):
def main():

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

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


main()

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

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

AB=[A,B]
L=[]

for n in range(1,min(AB)+1):
  if (A%n==0)&(B%n==0):
    L.append(n)

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

Solution (Python):
a, b, k = map(int,input().split())
div = min(a,b)
cnt = 0
for i in reversed(range(1,div+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())

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

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

Solution (Python):

"""
B - K-th Common Divisor
https://atcoder.jp/contests/abc120/tasks/abc120_b

"""
import sys


def solve(A, B, K):
    divisors = []
    for i in range(1, A+1):
        if A % i == 0 and B % i == 0:
            divisors.append(i)
    return divisors[-K]


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


if __name__ == '__main__':
    main(sys.argv[1:])

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

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

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

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

print(d)

Solution (Python):
A, B, K = map(int, input().split())
divisor_A = [A] 
divisor_A_count = 2 
divisor_B = [B]
divisor_B_count = 2
for i in range(A-1,1,-1):
    if (A % i) == 0:
        divisor_A.append(i)
        divisor_A_count += 1
divisor_A.append(1) 
for i in range(B-1,1,-1):
    if (B % i) == 0:
        divisor_B.append(i)
        divisor_B_count += 1
divisor_B.append(1) 
a_num = 1   
a = divisor_A[a_num-1]   
b_num = 1   
b = divisor_B[b_num-1]   
c_divisor_count = 0  
for i in range(divisor_A_count * divisor_B_count):
    
    if divisor_A[a_num-1] == divisor_B[b_num-1]:
        c_divisor_count += 1
        if c_divisor_count == K:
            break
        else:
            a_num += 1
            b_num += 1
    
    elif divisor_A[a_num-1] > divisor_B[b_num-1]:
        a_num += 1
    else: 
        b_num += 1
print(divisor_A[a_num-1])

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

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

    list =[]
    for i in range(D+1):
        if i!=0:
            if (A%i == 0) & (B%i == 0) :
                list.append(i)
    print(list[(len(list)-C)])
    


main()

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

max_num = min(a, b)
cnt = 0
for n in range(max_num, 0, -1):
    if (a % n) + (b % n):
        continue
    cnt += 1
    if cnt == k:
        print(n)
        break

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

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

Solution (Python):




def calc(a, b, k):
    ans = 0
    hit = 0
    for i in range(max(a, b), 0, -1):
        if a % i == 0 and b % i == 0:
            hit += 1
            if hit == k:
                ans = i
                break
    return ans


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

print(calc(a, b, k))

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

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

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

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

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

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

Solution (Python):
ABK = [int(i) for i in input().split()]
answer = 0
count = 0
num_list = [i for i in range(1,101)]
index = 0
while(count != ABK[2]):
    index -= 1
    if(ABK[0] % num_list[index] == 0 and ABK[1] % num_list[index] == 0):
        count += 1

print(num_list[index])

Solution (Python):
from sys import stdin





a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
i = max(a, b)
answer = 0
hit = 0
while 1:
    if a % i == 0 and b % i == 0:
        r = i
        hit += 1
    if hit == c:
        break
    i -= 1

print(r)

Solution (Python):


import sys
input = sys.stdin.readline

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,s,d=map(int,input().split())
l=[]
for i in range(1,min(a,s)+1):
  if a%i==0 and s%i==0:
    l.append(i)
print(l[-d])

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

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

CD = []
for i in range(1, min(x[0], x[1])+1):
    if x[0] % i == 0 and x[1] % i == 0:
        CD.append(i)
    else:
        continue

print(CD[-x[2]])

Solution (Python):
def is_divisible_A_and_B(x, A, B):
    if A % x == 0 and B % x == 0:
        return True
    else:
        return False

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

k = min(A, B)
divisible_list = []
for i in range(1, k + 1):
    if is_divisible_A_and_B(i, A, B):
        divisible_list.append(i)

print(divisible_list[-K])

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

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

print(list[-K])

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

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

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

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

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

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

Solution (Python):
def main():
    A,B,K = (int(_) for _ in input().split())

    lowerNum = A
    if A > B :
        lowerNum = B

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

if __name__ == '__main__':
    main()

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

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

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

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

def func_divisors(x):
  divisors = []
  for i in range(1,int(x**0.5)+1):
    if x % i == 0:
      divisors.append(i)
      if i != x / i:
        divisors.append(int(x/i))
        
  divisors.sort()
  return divisors
  
A_divisors = func_divisors(A)
B_divisors = func_divisors(B)
C_divisors = sorted(list(set(A_divisors) & set(B_divisors)),reverse=True)

print(C_divisors[K-1])

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

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

if __name__ == '__main__':
    main()

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

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

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

print(res[::-1][K-1])

Solution (Python):

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

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

Solution (Python):
import sys

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return a


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


j=0
for i in range(gcd,0,-1):
    if gcd%i==0:
        j+=1
    if j==k:
        print(i)
        sys.exit()

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

if(a>=b):
    min = b
else:
    min = a


list = []

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

print(list[c-1])

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

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

print(j)

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

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

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

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

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

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

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

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

print(ans)

Solution (Python):

def gdc(m, n):
    m, n = (m, n) if m > n else (n, m)
    while True:
        if n == 0:
            break
        else:
            m, n = n, m % n
    return m


A, B, K = [int(x) for x in input().split(" ")]
divisor = [x for x in list(range(1, gdc(A, B)+1)) if gdc(A, B) % x == 0]

print(divisor[::-1][K-1])

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

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

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

if ans:
    print(ans[-k])
else:
    print("1")

Solution (Python):


a,b,k = map(int,input().split())
acd = []
bcd = []
cd = []

for i in range(1,a+1):
    if a % i == 0:
        acd.append(i)
for i in range(1,b+1):
    if b % i == 0:
        bcd.append(i)
for i in acd:
    for j in bcd:
        if i == j:
            cd.append(i)
print(cd[-k])

Solution (Python):
a,b,k = list(map(int,input().split()))
c= 1
d=0
if b < a:
    a,b=b,a
while True:
    d = b%a
    if d == 0:
        c=a
        break
    else:
        b = a
        a = d
e = 0
for i in range(1,c+1):
    if c%i == 0:
        e +=1
        if e == k:
            print(int(c/i))
            break

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):
def gcd(a, b):
    if a > b:
        a, b = b, a
    if b % a == 0:
        return a
    else:
        return gcd(b % a, a)


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

Solution (Python):
A,B,K = map(int,input().split())
N = 0
i = 101
while N != K:
    i -= 1
    if A % i == 0 and B % i == 0:
        N += 1

print(i)

Solution (Python):
A, B, K = map(int, input().split())
count = 0
for_max = max([A, B])

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

Solution (Python):
abc = list(map(int, input().split()))
a = abc[0]
b = abc[1]
k = abc[2]
kazu = []

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

print(kazu[-k])

Solution (Python):
import math
a, b, k =map(int, input().split())
divesor_list = []
c = min(a, b)
if c == 1:
    divesor_list = [1]
else:
    for i in range(c, 0, -1):
            if (a % i == 0) & (b % i == 0):
                divesor_list.append(i)
print(divesor_list[k-1])

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

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

Solution (Python):
num1, num2, target = [int(i) for i in input().split()]

smaller = min([num1, num2])


common_div_num = 0
for i in reversed(range(1, smaller + 1)):
    if num1 % i == 0 and num2 % i == 0:
        common_div_num += 1
        if common_div_num == target:
            break


print(i)

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

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

print(yakusuu[-K])

Solution (Python):
from sys import stdin
import fractions

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]

num_list = []

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

print(num_list[-(K)])

Solution (Python):
from sys import stdin

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]


num_list = []

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

print(num_list[-(K)])

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

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

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

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

kk = 0
out = 0

for i in range(min(a,b),0,-1):
    aa = a % i
    bb = b % i
    
    if (aa+bb)==0:
        kk += 1
        
        if kk==k:
            out = i
            break
print(out)

Solution (Python):
import numpy as np

"""
def divs(_n):
    n = _n
    r = int(np.sqrt(n))
    res = []
    
    for i in range(2, r+1, 1):
        buf = [0, 0]
        while n%i == 0:
            buf[0] = i
            buf[1] += 1
            n/=i
        if buf[0] != 0:
            res.append(buf)
    if len(res)==0:
        res.append([n, 1])
        
    return res


def has(lis, num, search_i):
    beki = -1
    index = -1
    for i in range(search_i, len(lis), 1):
        
        if lis[i][0] == num:
            beki = lis[i][1]
            index = i
            break
    return (beki, index)


def common_divs(_a, _b):
    
    if len(_a) > len(_b):
        a = _b
        b = _a
    else:
        a = _a
        b = _b

    common = []
    search_i = 0 
    for e in a:
        beki, index = has(b, e[0], search_i)
        if beki > 0:
            common_e = [e[0], min(e[1], beki)]
            common.append(common_e)
            search_i = index + 1
    return common

def mult_all(c):
    res = 1
    for i in range(len(c)):
        res *= c[i][0]**c[i][1]
    return res


def main():
a, b, k = map(int, input().split())
    divA = divs(a)
    divB = divs(b)
    divC = common_divs(divA, divB)
    
    
    cnt = 1
    i = 0
    ans = mult_all(divC) 
    while(True):
        if cnt + divC[i][1] <= k:
            ans /= divC[i][0]**divC[i][1]
            cnt += divC[i][1]
        else:
            ans /= divC[i][0]**(k-cnt)
            break
        i += 1
        
    print(int(ans))

def main2():
    
main()    
"""

def divs(n):
    res = np.zeros(int(n/2))
    cnt = 0
    for i in range(n, 1, -1):
        if n%i == 0:
            res[cnt] = i
            cnt += 1
    return res[np.where(res>0)]


def main():
    a, b, k = map(int, input().split())
    divA = divs(a)
    divB = divs(b)

    cnt = 0
    ans = 1
    flag = False
    for i in range(len(divA)):
        if flag == True:
            break
        else:
            for j in range(len(divB)):
                if flag==False and divA[i]==divB[j]:
                    cnt += 1
                    if cnt == k:
                        ans = divA[i]
                        flag = True

    print(int(ans))
               
    
main()

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

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

target_num = count - K
print(divisor[target_num])

Solution (Python):
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while True:
            if x % y != 0:
                z = x % y
                x = y
                y = z
            else:
                break
        return z
A, B, K = map(int, input().split())
A_B_gcd = gcd(A, B)
yakusuu_arr = []
for i in range(1, A_B_gcd+1):
    if A_B_gcd % i == 0:
        yakusuu_arr.append(i)
yakusuu_arr.sort(reverse=True)
print(yakusuu_arr[K-1])

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

Solution (Python):
def solve(a, b, k):
    i = 0
    for c in range(max(a,b), 0, -1):
        if (a % c == 0) and (b % c == 0):
            i += 1
            if i == k:
                return c
    return -1

assert solve(8, 12, 2) == 2
assert solve(100, 50, 4) == 5
assert solve(1, 1, 1) == 1

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

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

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

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

n = 0
L = min(A, B) + 1

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

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

def aux():
  for i in reversed(range(1, min(A, B) + 1)):
    if A % i == 0 and B % i == 0:
      yield i

print(list(aux())[K - 1])

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

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



count=1
i=max(A,B)+1

while i>0:
  i=i-1
  if A%i==0 and B%i==0:
    count=count+1
    
  if count>K:
    print(i)
    exit()

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


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

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

Solution (Python):
A, B, K = 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 == K:
        break
print(i)

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

counter = 0
for i in sorted(range(1, min(a, b) + 1), reverse=True):
    if a % i == 0 and b % i == 0:
        counter += 1
        if counter == k:
            print(i)
            exit(0)

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

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

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

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

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

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

c = min(A,B)
k = 0

while(c>=1):
  if (A%c == 0 and B%c == 0):
    k = k + 1
  if (k==K):
    print(c)
    break
  c = c - 1

Solution (Python):

import sys


def solve(A: int, B: int, K: int):
    ret = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            ret.append(i)
    print(ret[-K])
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    K = int(next(tokens))  
    solve(A, B, K)

if __name__ == '__main__':
    main()

Solution (Python):
A, B, K = map(int, input().split())
lisA = []
lisB = []
for i in range(1, A + 1):
  if A % i == 0:
    lisA.append(i)
for i in range(1, B + 1):
  if B % i == 0:
    lisB.append(i)
seA = set(lisA)
seB = set(lisB)
seU = seA&seB
lis = list(seU)
lis.sort(reverse = True)
print(lis[K - 1])

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

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

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

print(dividable[-K])

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

Solution (Python):
def solve(string):
    a, b, k = map(int, string.split())
    for i in range(min(a, b), 0, -1):
        if a % i == b % i == 0:
            k -= 1
        if k == 0:
            return str(i)


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):

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

Solution (Python):
ABK = list(map(int,input().strip().split()))
A = ABK[0]
B = ABK[1]
K = ABK[2]

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

print(nums[K - 1])

Solution (Python):

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

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

print (w[-k])

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

count=1
num=min(ABK[0],ABK[1])+1

while count<=ABK[2]:
 count=count+1
 flag=0
 while flag==0:
  num=num-1
  if ABK[0]%num==0 and ABK[1]%num==0:
    flag=1
  
  
print(num)