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

def make_div(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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    a, b, k = LI()
    v = []
    for i in range(1, 101):
        if a % i == 0 and b % i == 0:
            v.append(i)
    v = v[::-1]
    print(v[k-1])


main()

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


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


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


def main():
    a, b, k = nm()
    arr = make_divisors(gcd(a, b))
    print(arr[-k])


if __name__ == '__main__':
    main()

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

for i in range(1, math.gcd(a, b)+1):
    if a % i == 0 and b % i == 0:
        l.append(i)

L = sorted(l)
print(L[-k])

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

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

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

print(i)

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[len(list)-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 = map(int,input().split())
i = 1
cand = []
while i<101:
  if a%i == 0 and b%i==0:
    cand.append(i)
  i += 1
  
print(cand[-k])

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

count = 0
for i in range(1, 100):
    if A % i == 0:
        sho = A / i
        if B % sho == 0:
            count += 1
    if count == K:
        print(int(sho))
        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 = list(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())
l=[]
for i in range(1,max(a,b)+1):
    if a%i==0 and b%i==0:
        l.append(i)
l.sort()
print(l[-k])

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

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

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

Solution (Python):



import math

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

gcd_of_AB = math.gcd(A,B)
l = []

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

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

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

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

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

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

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):
A,B,K = map(int, input().split())

lim = min(A,B)

count = 0
for i in range(lim,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())
count=0
i=min(A,B)+1
while count<K:
    i-=1
    if A%i==0 and B%i==0:
        count+=1
print(i)

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

Solution (Python):
A, B, C = input().strip().split()
A, B, C = [int(A), int(B), int(C)]

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

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

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

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

A,B = min(A,B),max(A,B)

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

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

res = []

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

print(res[K-1])

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

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

print(count[-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:
        print(i)
        exit()

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

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

Solution (Python):


























































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    
    A, B, K = list(map(int, lines[0].split()))
    
    
    
    

    cnt = 0

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



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['8 12 2']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['100 50 4']
        lines_export = [5]
    if pattern == 3:
        lines_input = ['1 1 1']
        lines_export = [1]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    if FLAG_LOG:
        log(f'lines_input=[{lines_input}]')
        log(f'lines_export=[{lines_export}]')
        log(f'lines_result=[{lines_result}]')
        if lines_result == lines_export:
            log('OK')
        else:
            log('NG')
    finished = time.time()
    duration = finished - started
    log(f'duration=[{duration}]')



if __name__ == '__main__':
    main()

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

Solution (Python):
a, b, k = [int(i) for i in 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):
import numpy as np
a,b,k = map(int,input().split())
c = np.gcd(a,b)
print([i for i in range(1,c+1) if c%i==0][-k])

Solution (Python):
import sys
import math


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


def main():

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

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

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



if __name__ == "__main__":
    main()

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

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

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

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

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

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)
b = sorted(a, reverse=True)
print(b[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)

print(l[-k])

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

Solution (Python):
a, b, c = map(int, input().split())
i = 1
d = []
while True:
  if a % i ==0 and b % i ==0:
    d.append(i)
  if i > max(a,b):
    break
  else:
    i += 1
print(d[-c])

Solution (Python):

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


import sys
input = sys.stdin.readline  
A,B,K = map(int, input().split())


div =cf(A,B)


print(div[-K])

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

count = 0
import math
R = []
for i in range(1,int(math.sqrt(A))+1+1):
    if A%i == 0:
        R.append(i)
        if not i == A//i:
            R.append(A//i)
R.sort(reverse=True)
for r in R:
    if B%r==0:
        count+=1
        if count == K:
            print(r)

Solution (Python):
def com_div(x, y):
    dv = []
    for i in range(min(x, y), 0, -1):
        if x % i == 0 and y % i == 0:
            dv.append(i)
    return dv


a, b, k = list(map(int, input().split()))
print(com_div(a, b)[k - 1])

Solution (Python):
def com_div(x, y):
    dv = []
    m = min(x, y)
    for i in range(1, m + 1):
        if x % i == 0 and y % i == 0:
            dv.append(i)
    dv.sort()
    return dv[::-1]


a, b, k = list(map(int, input().split()))
print(com_div(a, b)[k - 1])

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

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

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

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


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

print(sorted(result_list)[-K])

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

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

divisors = divisors[::-1]
print(divisors[K - 1])

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

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

print(d[-k])

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

def main():
    a,b,k = map(int,input().split())
    from math import gcd
    y = make_divisors(gcd(a,b))
    print(y[-k])

if __name__ == '__main__':
    main()

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)

print(lst[-K])

Solution (Python):
def main():
  a,b,k = list(map(int,input().split()))
  loop=0
  if a<b:
    loop=a
  else:
    loop=b
  now=0
  for i in reversed(range(1,loop+1)):
    if a%i==0 and b%i==0:
      now+=1
      if now==k:
        print(i)
        break
main()

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

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

Solution (Python):
"""
全探索
1からmin(a,b)の中でaとbを割り切るものの数をカウントする
"""
a, b, k = map(int, input().split())
counter = 0
for i in list(range(1,min(a,b)+1))[::-1] :
    if a%i == 0 and b%i == 0 :
        counter += 1
    if counter == k :
        print(i)
        break

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

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

for i in divisor_list(A):
    for j in divisor_list(B):
        if i == j:
            result_list.append(i)

print(sorted(result_list)[-K])

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)

    divisors.sort()
    return divisors
    
lstA = make_divisors(A)
lstB = make_divisors(B)

fin = []

for i in lstA:
    if i in lstB:
        fin.append(i)

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

Solution (Python):
a,b,k = map(int,input().split())
i = 101
j = 0
while True:
    i -= 1
    if a % i == 0 and b % i == 0:
        j += 1
        if j == k:
            print(i)
            break

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

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

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

Solution (Python):
from collections import deque

if __name__ == '__main__':

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

	mini = min(a,b)
	d = deque()
	for x in range(1,mini+1):
		a2 = a % x
		b2 = b % x
		if a2 == 0 and b2 == 0:
			d.appendleft(x)
	print(d[k-1])

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

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

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

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)
            return
        
if __name__ == '__main__':
    main()

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

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

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)
            return
        
if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, k = map(int, readline().split())
    res = dict()
    cnt = 0

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

    num = (cnt + 1) - k
    print(res[num])


if __name__ == '__main__':
    main()

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

print(war[k-1])

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

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

Solution (Python):


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

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

print(ko_yakusu[-K])

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

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

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

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

print(l[k * -1])

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

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

Solution (Python):
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()


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


ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Solution (Python):
import sys
A,B,K = map(int,input().split())
if not ( 1 <= A <= 100 and 1 <= B <= 100 ): sys.exit()
if not ( 1 <= K ): sys.exit()

if A < B: 
    A, B = B, A
while A%B != 0:
    A,B = B,A%B

count = 0
for I in range(B,0,-1):
    if B % I == 0:
        count += 1
    if count == K:
        print(I)
        break

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

if A < B: 
    A, B = B, A
while A%B != 0:
    A,B = B,A%B

count = 0
for I in range(B,0,-1):
    if B % I == 0:
        count += 1
    if count == K:
        print(I)
        break

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


if __name__ == '__main__':
    main()

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

resolve()

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

cds = []
for i in range(1, 101):
    if (a % i == 0) and (b % i == 0):
        cds.append(i)
cds.reverse()
print(cds[k - 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)
n = sorted(n, reverse = True)
print(n[K-1])

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

Solution (Python):
a,b,k = map(int,input().split())
minnum = min(a,b)
maxnum = max(a,b)
lis = []
for mi in reversed(range(1,minnum+1)):
  if minnum % mi == 0 and maxnum % mi == 0:
    lis.append(mi)

print(lis[k-1])

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

Solution (Python):
import math
A, B, K = map(int, input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
divisors = make_divisors(math.gcd(A, B))
divisors.sort(reverse=True)
print(divisors[K-1])

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

Solution (Python):
def make_divisors(n):
    if n==1:
        divisors=[1]
        return divisors
    else:
        divisors=[]
        for i in range(1,n):
            if i*i>n:
                break
            if n%i==0:
                divisors.append(i)
                if i!=n//i:
                    divisors.append(n//i)

        divisors.sort(reverse=True)
        return divisors

from sys import stdin
from math import gcd
def main():
    
    readline=stdin.readline
    a,b,k=map(int,readline().split())

    c=gcd(a,b)
    li=make_divisors(c)

    print(li[k-1])

if __name__=="__main__":
    main()

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

l = []

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

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

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

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

print(anslist[-K])

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

Solution (Python):
import sys
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)
print(tmp[-k])

Solution (Python):
def Div(N):
    L = []
    R = []
    I = 1
    while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
        I += 1
    return R+L[::-1]
  
A,B,K = (int(X) for X in input().split())
Count = 0
Divid = Div(min(A,B))
for T in Divid:
    if A%T==0 and B%T==0:
        Count += 1
        if Count==K:
            print(T)
            break

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

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, k = rm()
t = math.gcd(a, b)
cnt = 0
for i in range(t, 0, -1):
  if t % i == 0:
    cnt += 1
    if cnt == k:
      print(i)
      exit()

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

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

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

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

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

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


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

    A, B, K = il()

    k = []
    for n in range(1, A * B + 1):
        if A % n == 0 and B % n == 0:
            k.append(n)
    print(k[::-1][K-1])


if __name__ == '__main__':
    main()

Solution (Python):
from math import gcd

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
    
a, b, k = map(int, input().split())
x = gcd(a, b)
l = make_divisors(x)
print(l[-k])

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

Solution (Python):
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)
list.sort(reverse=True)

print(list[K-1])

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

Solution (Python):
import sys
import math

input = sys.stdin.readline

A,B,K = list(map(int,input().split()))
counter = []
num = 0
while num <101:
    num += 1
    if A %num ==0 and B % num ==0:
        counter.append(num)
    
print(counter[-K])

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

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

min = A if A <= B else B

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

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

Solution (Python):
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)
c = c[::-1]
print(c[K-1])

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

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

a,b,k=LI()
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())
a=[x for x in range(1,A+1) if A%x==0 and B%x==0]
print(a[-K])

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

Solution (Python):
from math import gcd

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

g = gcd(a, b)

cd = []

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

print(cd[-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,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=sorted(l)[::-1]
print(l[K-1])