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

nums = list(range(101))
nums.reverse()

for i in nums:
    a = A%i
    b = B%i
    
    if a == 0 and b == 0:
        count += 1
    
    if count == K:
        print(i)
        break

Solution (Python):
A,B,K = map(int,input().split())
if A < B :
    A,B = B,A
cnt = 0
L = []
for i in range(1,10**4+1) :
    if (A%i == 0) and (B%i == 0) :
        L.append(i)

L = sorted(L,reverse=True)
print(L[K-1])

Solution (Python):
a,b,k=map(int,input().split())
num=[]
for i in range(1,max(a,b)+1):
    if a%i==0 and b%i==0:
        num.append(i)
num.sort(reverse=True)
print(num[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 == 0 and B % i == 0:
        cnt += 1
    if cnt == K:
        print(i)
        break

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

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

    print(result_list[-1*K])


if __name__ == "__main__":
    main()

Solution (Python):
a = set()
b = set()

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

for i in range(1,max(A,B) + 1):
  if A % i == 0: a.add(i)
  if B % i == 0: b.add(i)

c = sorted(list(b.intersection(a)),reverse=True)

print(c[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):
import fractions
A,B,K =map(int,input().split())
tmp = fractions.gcd(A,B)
l =[]
for i in range(tmp):
    if tmp % (i+1) == 0:
        l.append(i+1)
print(l[-K])

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

r=[]

if a>b:
  c=range(1,a+1)
else:
  c=range(1,b+1)

for x in c:
  if a % x==0 and b%x==0:
    r.append(x)

print(r[-1*k])

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

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


print(ans[-K])

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

print(anskoho[-k])

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

Solution (Python):
a,b,k = map(int,input().split())
x = [x for x in range(1,a+1) if a % x == 0]
x.sort(reverse=True)
y = [x for x in range(1,b+1) if b % x == 0]
y.sort(reverse=True)

cnt = 0
for i in range(len(x)):
    if x[i] in y:
        cnt += 1
    if cnt == k:
        print(x[i])
        exit()

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

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

Solution (Python):
class FutureMath:
    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    def gcd_(self, list):
        result = list[0]
        for el in list[1:]:
            result = self.gcd(result, el)
        return result

    def lcm(self, a, b):
        return a * b // self.gcd(a, b)

    def lcm_(self, list):
        result = list[0]
        for el in list[1:]:
            result = self.lcm(result, el)
        return result

    def cds(self, n):
        result = list()
        for i in range(1, n+1):
            if n % i == 0:
                result.append(i)
        return result


fm = FutureMath()

if __name__ == "__main__":
    a, b, k = map(int, input().split())
    gcd = fm.gcd(a, b)
    cds = fm.cds(gcd)
    print(cds[-k])

Solution (Python):
from sys import stdin

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

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

input = lambda: stdin.readline()
main()

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

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

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

Solution (Python):

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

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

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

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

Solution (Python):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b,k=IL()
c=[1]
for i in range(2,min(a,b)+1):
    if a%i==0 and b%i==0:
        c.append(i)
print(c[-k])

Solution (Python):
p = input().split()
a = int(p[0])
b = int(p[1])
k = int(p[2])
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):
def solve():
  A, B, K = map(int, input().split())
  k = 0
  for i in range(100, 0, -1):
    if A % i != 0 or B % i != 0: continue
    k += 1
    if K == k: return i

print(solve())

Solution (Python):

import re
import bisect
from datetime import datetime as dt

A, B, K = map(int, raw_input().split())
max = max(A, B)
a = []

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

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

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

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

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

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

print(arr[-k])

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

DivList = []

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

print(DivList[k-1])

Solution (Python):
A, B, K = map(int, input().split())
R = min(A, B)
L = []
for i in range(1, R+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())
dd = min([a,b])
kcnt = 0
while True:
  if a % dd == 0 and b % dd == 0:
    kcnt += 1
    if kcnt == k:
      print(dd)
      exit(0)
  dd -= 1

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

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

Solution (Python):
A,B,K = map(int,input().split())
x = 1
y = 100
while x <= K:
  if A%y == 0 and B%y == 0 and x != K:
    x += 1
    y -= 1
  elif A%y == 0 and B%y == 0 and x == K:
    print(y)
    break
  else:
    y -= 1

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

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

q.sort(reverse=True)

print(q[K-1])

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

Solution (Python):
multi_input = lambda dtype: list(map(dtype,input().split()))
(A,B,K) = multi_input(int)
n = K
i = min(A,B) + 1
while n > 0:
    i -= 1
    if A % i ==0 and B % i ==0:
        n -= 1
print(i)

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

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


print(arr[-c])

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

ans =[]
dai = 0
if a>b:
    dai = a
else:
    dai = b
for i in range(1,dai+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())
count = 0
for i in range(0,a):
    j = a - i
    if a % j ==0 and b % j == 0:
        count = count + 1
        if count == k:
            result = j
            break

print(result)

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

a, b, k = map(int, input().split())
cou = 0
if a > b:
    a, b = b, a

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

print(ans)

Solution (Python):
import sys

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


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())
cnt = 0
gc = gcd(A, B)

ans = []
cnt = 0
for i in reversed(range(1, gc+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())
s=0
for i in reversed(range(1,101)):
    if a%i==0 and b%i==0:
        s+=1
    if s==k:
        s+=1
        print(i)

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

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

num = []

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

print(num[-k])

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

    a_set = set([a for a in range(1, A+1) if A % a == 0])
    b_set = set([b for b in range(1, B+1) if B % b == 0])

    ab = list(a_set & b_set)
    ans = sorted(ab, reverse=True)[K-1]
    print(ans)


if __name__ == '__main__':
    main()

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

for i in range(max(a[0],a[1]),0,-1):
    if a[0] % i == 0 and a[1] % i == 0:
        a[2] = a[2] - 1
        if a[2] == 0:
            print(i)

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):
from fractions import gcd
a,b,k=list(map(int,input().split(" ")))
N=gcd(a,b)
r=[]
for i in range(1,N+1):
    if a%i==0 and b%i==0:
        r.append(i)
print(r[-k])

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

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

def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

A = []
x = gcd(a, b)
for i in range(1, x + 1):
    if x % i == 0:
        A.append(i)
        
A.reverse()

print(A[k - 1])

Solution (Python):
A, B, K = map(int, input().split())
count = 0
A, B = min(A, B), max(A, B)
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 = map(int, input().split())

cnt = 0

for i in range(max(A, B)+1, 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())

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

Solution (Python):

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

m = min(A, B)

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

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

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

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

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

Solution (Python):
def get_prime_factorized(N):
    R = []
    b, e = 2, 0
    while b ** 2 <= N:
        while N % b == 0:
            N  = N // b
            e += 1
        if e > 0:
            R.append([b, e])
        b, e = b + 1, 0
    if N > 1:
        R.append([N, 1])
    return R

def get_list_divisor(N, reverse=True):
    try:
        F = get_prime_factorized(N)
        L = re_func_divisior(F)
        R = []
        for l in L:
            for i, x in enumerate(l):
                if i == 0:
                    r = x
                else:
                    r *= x
            R.append(r)
        R.sort()
        if reverse == True:
            R.reverse()
    except:
        if N == 1:
            R = [1]
        else:
            R = [N]
    return R

def re_func_divisior(F):
    b, e = F.pop()
    P = re_func_divisior(F) if F else [[]]
    Q = [[b ** k] for k in range(e + 1)]
    return [p + q for p in P for q in Q]


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

R = set(get_list_divisor(A)) & set(get_list_divisor(B))
R = list(R)

R.sort()

print(R[-1*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 count == K:
            print(i)
            break
    else:
        continue

Solution (Python):


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

ans_l = []
for i in range(1, 101):
    if a % i == 0 and b % i == 0:
        ans_l.append(i)
print(ans_l[-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())
ans = [int(x) for x in range(1, min(A, B) + 1) if A % x == 0 and B % x == 0]

print(ans[-K])

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

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

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())
cnt = 0
for i in reversed(range(1,max(a,b)+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())
div = []
for i in range(1, 101):
  if A % i == 0 and B % i == 0:
    div.append(i)
print(div[len(div) - K])

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

d_list = []
d = min(A, B)
while d > 0:
    if A % d == 0 and B % d == 0:
        d_list.append(d)
    d -= 1

print(d_list[K - 1])

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

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

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

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

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

Solution (Python):


















import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

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[::-1][K-1])

Solution (Python):
a, b, k = map(int, input().split())
cnt = 0
res = 1
res_array = []
while res <= max(a, b):
    if a % res == 0 and b % res == 0:
        res_array.append(res)
        cnt += 1
    res += 1
print(res_array[-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):


import itertools
import collections
import bisect

def main():
    A, B, K = map(int, input().split())
    count = 0
    for i in range(max(A, B) + 1, 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, c = map(int, input().split())  

d = min(a, b)
for i in reversed(range(d)):
    if a % (i + 1) == 0 and b % (i + 1) == 0:
        c -= 1

    if c == 0:
        print(i + 1)
        break

Solution (Python):
a,b,c=map(int,input().split())
lst=[]
for i in range(1,101):
    if a%i==0 and b%i==0:lst.append(i)
print(lst[len(lst)-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[len(L)-K])

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

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

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

print( divide + 1 )

Solution (Python):

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

A, B, K = inpl()
cd = []

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

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

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

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

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

Solution (Python):
a,b,k=map(int,input().split())
A=[i for i in range(101)][::-1]
for i in A:
  if a%i==b%i==0:
    po=i
    break
B=[]
for i in range(1,int(po**(1/2)+1)):
  if po%i==0:
    B.append(i)
    B.append(po//i)
B=list(set(B))
B.sort()
print(B[-k])

Solution (Python):
import sys





"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def SR(self, s):
        """
        昇順ソート（reverse書くのが面倒
        返り値はありません。注意して下さい。
        SR(s) と書いたらsが昇順ソートされるだけです。
        Sort Reverse
        :param s: ソートしたいリスト
        :return: None
        """
        s.sort(reverse=True)

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    a, b, k = ip.IL()

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


main()

Solution (Python):
A,B,K = map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

C = gcd(A,B)
l = [i for i in range(1,min(A,B)+1) if C % i == 0]
print(l[-K])

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


list1 = []
list2 = []

for i in range(1,a+1):
  if a % i == 0:
    list1.append(i)
    
for i in range(1,b+1):
  if b % i == 0:
    list2.append(i)
li = sorted(list(set(list2) &set(list1)),reverse=True)
print(li[k-1])

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

index = 0

mx = max(a, b)

while(mx != 0):
    if a % mx == 0 and b % mx == 0:
        index += 1
    if index == k:
        break
    mx -= 1
print(mx)

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

    for i in range(100):
        i = 100 - i
        if a % i == 0 and b % i == 0:
            if k == 1:
                print(i)
                return
            k -= 1


if __name__ == '__main__':
    main()

Solution (Python):
data = input().split()
A = int(data[0])
B = int(data[1])
K = int(data[2])
cnt = 0

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

Solution (Python):
import sys
input = sys.stdin.readline
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
i = 0
if a > b:
    c = b
else:
    c = a
while i < k:
    if a % c == 0 and b % c == 0:
        i += 1
    c -= 1
print(c+1)

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

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

a_list = []
b_list = []

def make_divisor_list(num):
    if num < 1:
        return []

    elif num == 1:
        return [1]

    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)

        divisor_list.append(num)

    return divisor_list

a_list = make_divisor_list(a)
b_list = make_divisor_list(b)

ans_list = list(set(a_list) & set(b_list))

ans_list.sort(reverse = True)

print(ans_list[k-1])

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

print(ans_list[-k])

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

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

def solve():
    A,B,K = map(int, input().split())
    n = gcd(A,B)
    for i in range(n,0,-1):
        if n % i == 0:
            K -= 1
            if K == 0:
                return i

ans = solve()
print(ans)

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

Solution (Python):



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

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


if __name__ == '__main__':
    main()

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

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

print(ans[-K])

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

print(ans)
print()

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

Solution (Python):

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

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

print(i)

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

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

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

i = min(A, B)
while K > 0:
    if A % i == 0 and B % i == 0:
        K -= 1
        ans = i
    i -= 1
print(ans)

Solution (Python):
a,b,k=map(int,input().split())
ans=[]
c=0
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=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)
l=l[::-1]

print(l[k-1])

Solution (Python):

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

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

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())




a,b,k = (int(i) for i in input().split())    









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

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

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

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

m = min(a, b)

cnt = 0
ans = m
for d in xrange(m, 0, -1):
    if a % d == 0 and b % d == 0:
        cnt += 1
    if cnt == k:
        ans = d
        break

print ans