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,s,d=map(int,input().split())
from fractions import gcd
f=gcd(a,s)
for i in range(f,0,-1):
  if f%i:continue
  d-=1
  if d:continue
  print(i);exit()

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

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

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

for y in range(1, B + 1):
    if B % y == 0 and y in a:
        b.append(y)

b = sorted(b,reverse = True)

print(b[K - 1])

Solution (Python):
def dv(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
A,B,K = map(int,input().split())
C = list(set(dv(A))&set(dv(B)))
C.sort()
C.reverse()
print(C[K-1])

Solution (Python):
import numpy as np

def yakusu(n):
    a = []
    for i in range(1, int(n*0.5)+1):
        if n % i == 0:
            a.append(i)
    a.append(n)
    return a

A, B, K = map(int, input().split())
a = yakusu(A)
b = yakusu(B)
ab = []
for i in a:
    if i in b:
        ab.append(i)
print(ab[-1*K])

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

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

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

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

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

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


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


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

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

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


resolve()

Solution (Python):
def divisor_listout(n,m):
    max_n = max(n,m)
    out = [1]
    for i in range(2,max_n+1):
        if n % i == 0 and m % i == 0:
              out.append(i)
    return out

n1, n2, result = map(int,input().split())
ans = divisor_listout(n1,n2)[::-1]
print(ans[result-1])

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)

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

Solution (Python):

A, B, K = map(int, input().split())
n = 0
N = min(A, B)
for i in range(100):
    m = N-i
    if A % m == 0 and B % m == 0:
        n += 1
    else:
        pass
    
    if n == K:
        ans = m
        break

print(ans)

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

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

Solution (Python):

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

count = 0
for i in range(mini,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
for i in range(a+1,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())
n=0
for i in range(b+1,0,-1):
    if a%i==0 and b%i==0:
        n+=1
        if n==k:
            print(i)

Solution (Python):
a,b,k=map(int,input().split())
result=[]
n=1
while n<=100:
    if a%n==0 and b%n==0:
        result.append(n)
    n+=1
result.reverse()
print(result[k-1])

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

Solution (Python):
def divisor(x):
  ret=[]
  for i in range(1,int(x**0.5)+1):
    if x%i==0:
      ret.append(i)
      if x//i==i:continue
      ret.append(x//i)  
  return set(ret)

a,b,k=map(int,input().split())
al=divisor(a)
bl=divisor(b)
cl=list(al & bl)
cl.sort(reverse=True)
print(cl[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(l[::-1][k-1])

Solution (Python):

import sys


def solve(A: int, B: int, K: int):
    def f():
        for i in range(1, 101):
            if A % i == 0 and B % i == 0:
                yield i
    return list(f())[-K]
        


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))  
    print(solve(A, B, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
import fractions
A,B,K=map(int,input().split())
C=fractions.gcd(A,B)
cnt=0
for x in range(C,0,-1):
    if C%x==0:
        cnt+=1
        if cnt==K:
            print(x)
            break

Solution (Python):

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


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

print(div_nums[-K])

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

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

print(dammy[-1 * K])

Solution (Python):
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

a,b,k=L()
num=0
for i in reversed(range(1,min(a,b)+1)):
    if a%i==0 and b%i==0:
        num+=1
        if num==k:
            print(i)
            exit()

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

cnt=0
for i in reversed(range(1,min(a,b)+1)):
    if (a%i==0) & (b%i==0):
        cnt+=1
    if cnt==k:
        print(i)
        exit()

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

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

Solution (Python):

K=list(map(int,input().split()))
ans=0
num_list=[]
for i in range(1,min(K[0],K[1])+1):
    if K[0]%i==0 and K[1]%i==0:num_list.append(i)
num_list.reverse()
print(num_list[K[2]-1])

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

Solution (Python):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, K = map(int, read().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)
        exit()

Solution (Python):
A,B,K=map(int,input().split())
cd=[]
for n in range(1,101):
  if A%n == 0 and B%n == 0:
    cd.append(n)
print(cd[len(cd)-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)
            exit()

Solution (Python):
from fractions import gcd

A, B, K = map(int, input().split())
gcd = gcd(A, B)
l = []

for i in range(1, gcd+1):
  if gcd % i == 0:
    l.append(i)
  else:
    pass
l.reverse()
print(l[K-1])

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

S=[]
for i in range(1,B+1):
  if A % i==0 and B%i==0:

    S.append(i)

print(S[-K])

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 j in range(1,b+1):
  if b%j==0:
    lisb.append(j)
for l in range(max(a,b)+1):
  l=max(a,b)+1-l
  if l in lisb and l in lisa and k>0:
    k-=1
    if l in lisb and l in lisa and k==0:
      print(l)
      break

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

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

Solution (Python):

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

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

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

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

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)

print(c[-k])

Solution (Python):
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


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

a_dividers = get_dividers(A)
b_dividers = get_dividers(B)
ab_dividers = sorted(a_dividers & b_dividers)
print(ab_dividers[-K])

Solution (Python):
def gcd(a, b):
    big = max(a, b)
    small = min(a, b)
    
    r = small
    while r != 0:
        r = big % small
        big = small
        small = r
    
    return big

def divisor(n):
    div = []
    for i in range(1, n + 1):
        if n % i == 0:
            div.append(i)
    
    return div

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

num = gcd(a, b)
div = divisor(num)

div.sort(reverse=True)

print(div[k])

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())



a,b,k = MI()
c = 0
for i in range(a):
    s = a-i
    if a % s == 0 and b % s == 0:
        c += 1
    if c == k:
        print(s)
        sys.exit()

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

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

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

print(divisors[K-1])

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

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

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

Solution (Python):
import sys
a, b, k= map(int,sys.stdin.readline().rstrip().split())
cnt = []
for i in range(1,min(a,b)+1):
  if a % i == 0 and b % i == 0:
    cnt.append(i)
cnt = sorted(cnt,reverse=True)
print(cnt[k-1])

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

s = min(a,b)
for i in range(s,0,-1):

  if a%i == 0 and b%i == 0:
    cnt += 1
    if cnt == c:
      ans = i
      break
print(ans)

Solution (Python):
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007



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)

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

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

abset = list(sorted(set(a)&set(b)))[::-1]

print(abset[K-1])

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

a_divs = make_divisors(a)
b_divs = make_divisors(b)

common_divs = []
for i in range(len(a_divs)):
  a_div = a_divs[i]
  if a_div in b_divs:
    common_divs.append(a_div)
print(common_divs[-k])

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

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

ans.sort(reverse=True)

print(ans[k-1])

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

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

Solution (Python):
a, b, k = list(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
S =[]
while i <= min(A,B):
  if A%i ==0 and B%i == 0:
    S.append(i)
  i += 1

print(S[-K])

Solution (Python):
a, b, k = list(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 fractions
a, b, k = map(int, input().split())
l = []
gcd = fractions.gcd(a, b)
for i in range(1, int(gcd**0.5)+1):
    if gcd%i==0:
        l.append(i)
        if i != gcd//i:
            l.append(gcd//i)
l.sort(reverse = True)
print(l[k-1])

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

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

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

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

Solution (Python):


import sys



















from fractions import gcd                    


def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b, k = mi()
    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

if __name__ == "__main__":
    main()

Solution (Python):
a, b, k = map(int, input().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()))
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())
lists = []
for i in range(1,101):
    if a%i == 0 and b%i == 0:
        lists.append(i)
print(sorted(lists, reverse = True)[k-1])

Solution (Python):

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


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

print(l[k-1])

Solution (Python):
def cf(A,B):
    l=[]
    for i in range(1,min(A,B)+1):
        if A % i == 0 and B % i == 0:
            l.append(i)
    return l

def main():
    A, B, K = map(int,input().split())
    koyaku = cf(A,B)
    
    print(koyaku[-K])
    
if __name__ == '__main__':
    main()

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

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

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

divisor = []

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

print(divisor[-K])

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

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

Solution (Python):
def inpl(): return list(map(int, input().split()))
A, B, K = inpl()
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):
import sys

def solve():
    input = sys.stdin.readline
    A, B, K = map(int, input().split())
    count = 1
    for i in reversed(range(1, 101)):
        if A % i == 0 and B % i == 0:
            if count == K: 
                print(i)
                break
            else: count += 1
    


    return 0

if __name__ == "__main__":
    solve()

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

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache






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






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


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


def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count





A,B,K = inputIL()

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

Solution (Python):

import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement


from operator import itemgetter
from sys import stdin

from operator import mul
from functools import reduce
from collections import Counter





j=0
k=0
n=3
r=1
a=[0]






"1行1つの整数を入力を取得し、整数と取得する"




"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

for i in number_list:
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''



"正方行列にstr型の値を入力"
'''




'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"


'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''











'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''




"aという変数に入っているものを大文字にして出力"

















'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''


'''
def cmb(n,r):
    
    r= min(n-r,r)
    
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    
    
    

    under = reduce(mul, range(1, r+1))
    
    
    
    

    return over // under
    
    
    
    
a = cmb(n, r)

'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''




for i in a.most_common(n):print(i)





 


'''









'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        
        if n % k == 0:
            return False
            
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  

'''

def factorial(x, mod=10**9+7):
    
    
    
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''











def main():

    steps=0
    state=0
    w=1
    j=0
    k=0
    ans=[]
    
    a,b,k=map(int, input().split(" "))
    
    
    
    
    i=1
    step=0
    while step<min(a,b):
     
     if a%i==0 and b%i==0:
         step +=1
         ans.append(i)
     if i>min(a,b):
    
        break
     i +=1

    print(ans[-k])
    for i in range(1,n+1,):
     
     pass


    
        
    
    

    
    
    
    
    DP = np.zeros(w+1, dtype=int)
    exdp=np.zeros((3,4)) 
    
    
    
        
        
    
    
        
        
    


    "1行1つの整数を入力を取得し、整数と取得する"
    
    
    "12 21 332 とか入力する時に使う"
    "1行に複数の整数の入力を取得し、整数として扱う"
    
    



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]
    

    ls = ["a", "b", "c", "d", "e"]


    
    

    
    

    
    
    
    
    
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

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):
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


def main():
    A, B, K = map(int, input().split())
    d = gcd(A, B)
    div = []
    div2 = []
    root = int(d ** 0.5)
    if root ** 2 == d:
        for i in range(1, root):
            if d % i == 0:
                div.append(i)
                div2.append(d // i)
        div.append(root)
    else:
        for i in range(1, root + 1):
            if d % i == 0:
                div.append(i)
                div2.append(d // i)
    div2.reverse()
    div = div + div2
    for _ in range(K - 1): div.pop()
    print(div[-1])

if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b, k = Is()
g = gcd(a, b)
count = 0
for i in reversed(range(1, g+1)):
    if g % i == 0:
        count += 1
        if count == k:
            print(i)
            exit()

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

C = max(A, B)
l = []
for n in range(1, C+1):
    if A % n == 0 and B % n == 0:
        l.append(n)
l.sort(reverse=True)

for i in range(len(l)):
    if i + 1 == K:
        print(l[i])

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

Solution (Python):
A,B,K=map(int,input().split())
x=min(A,B)
count=0
while x>0:
    if A%x==0 and B%x==0:
        count+=1
        if count==K:
            ans=x
            break
    x-=1
print(ans)

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

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

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

print(syou[-k])

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

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

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

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

Solution (Python):
import sys
import math
import bisect

def solve(a, b, k):
    A = []
    for i in range(1, min(a, b) + 1):
        if a % i == 0 and b % i == 0:
            A.append(i)
    A.sort(reverse=True)
    return A[k-1]

def main():
    a, b, k = map(int, input().split())
    print(solve(a, b, k))

if __name__ == "__main__":
    main()

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

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

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

import sys


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


def solve(A: int, B: int, K: int):
    g = gcd(A, B)
    c = [i for i in range(1, g + 1) if g % i == 0]
    print(c[-K])


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

count=[]
if a<=b:
  for i in range(a,0,-1):
    if a%i==0 and b%i==0:
      count.append(i)
if a>b:
  for j in range(b,0,-1):
    if a%j==0 and b%j==0:
      count.append(j)
print(count[k-1])

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

cnt = 0
for num in reversed(range(1, min(A, B)+1)):
    if A%num==0 and B%num==0:
        cnt += 1

    if cnt == K:
        print(num)
        break

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

print(lst[k-1])