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

Solution (Python):
a = input().split()

b = int(a[0])
c = int(a[1])
d = int(a[2])
count = []

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

print(count[-d])

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

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

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

for i in range(1,a+1):
    if a % i == 0:
        a_list.append(i)
for i in range(1,b+1):
    if b % i == 0:
        b_list.append(i)
print(sorted(list(set(a_list) & set(b_list)))[::-1][k-1])

Solution (Python):


from sys import stdin

input = stdin.readline

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

commonDivisor = []

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

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

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

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

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

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

print(yakusu_list[K-1])

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

tmp = 0

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

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)
    else:
        pass
anslength = len(ans)
print(ans[anslength-k])

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

li = []
s = 1
e = 0
a = float(a)
b = float(b)

while True:
    if a % s == 0 and b % s == 0:
        li.append(s)
        e += 1
    if s == a or s == b:
        break
    s += 1

print(li[-k])

Solution (Python):
import math
Alist = []
Blsit = []
yakusuu = []
A,B,K = map(int,input().split())
Alist = [i for i in range(1,A+1) if A%i==0]
Blist= [i for i in range(1,B+1) if B%i==0]
for a in Alist:
    for b in Blist:
        if a==b:
            yakusuu.append(a)
yakusuu.sort()
print(yakusuu[-K])

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

i = 100
j = 1

for t in range(100):
    if a % i == 0 and b % i == 0:
        if j==k:
            print(i)
            break
        else:
            j=j+1
            i=i-1
    else:
        i = i-1

Solution (Python):


def main():
    sp = [int(e) for e in input().split(" ")]
    a = sp[0]
    b = sp[1]
    k = sp[2]

    big = max(a, b)

    idx = 1
    for i in range(big):
        if a%(big-i) == 0 and b%(big-i) == 0:
            if idx == k:
                print(big-i)
            idx+=1

main()

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

Solution (Python):
A,B,K=map(int,input().split())
count=0
k=0
c=[]
while k!=max(A,B):
    k+=1
    if A%k==0 and B%k==0:
        count+=1
        c.append(k)

print(c[-K])

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

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

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

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

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

def solve():
    i = 0
    j = min(a, b)
    while i != k:
        if ((a % j) == 0) and ((b % j) == 0):
            i += 1
        j -= 1
    return j + 1

print(solve())

Solution (Python):
A,B,K = map(int,input().split())
d=[]
if(A>B):
    M=A
    m=B
else:
    M=B
    m=A

for x in range(m,0,-1):
    if(m%x ==0 and M%x ==0):
       d.append(x) 

print(d[K-1])

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

for x in range(1, 101):
    if a%x==0 and b%x==0:
        lst_ans.append(x)
lst_ans = sorted(lst_ans, reverse=True)
print(lst_ans[(k-1)])

Solution (Python):
from sys import stdin
A,B,K=[int(x) for x in stdin.readline().rstrip().split()]
tmp=[]
ans=0
for i in range(1,101):
    if A%i==0 and B%i==0:
        tmp.append(i)
ans=tmp[-K]
print(ans)

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

li = []

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

print(li[-k])

Solution (Python):


import random
import bisect




def IT(): 
    return int(input())
def IL(): 
    return [int(_) for _ in input().split()]
def IS(): 
    return [_ for _ in input().split()]
def ILS(n): 
    return [int(input()) for _ in range(n)]
def SLS(n): 
    return [input() for _ in range(n)]
def ILSS(n): 
    return [[int(_) for _ in input().split()] for j in range(n)]


def bit_full_search(ss):
    n = len(ss)
    for i in range(1 << n):
        s = ""
        for j in range(n + 1):
            if ((1 & i >> j) == 1):
                s += ss[j]
        print(s)
def bit_full_search2(A):
    
    value = []
    for i in range(1 << len(A)):
        output = []

        for j in range(len(A)):
            if ((i >> j) & 1) == 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 matching_bisect(list1_val, list2_val, n):
    
    j = 0
    for i in range(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])
        if j < len(list2_val):
            if list1_val[i] + list2_val[j] == n:
                
                break
    return j

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

def main():

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








main()

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

Solution (Python):

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

for i in range(1,b+1):
    if b % i == 0:
        l2.append(i)
s1 = set(l1)
s2 = set(l2)
ans = s1 & s2
ans_list = list(ans)
ans_list.sort()
print(ans_list[-k])

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

Solution (Python):
a, b, k = map(int, input().split())
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
      
list_a = make_divisor_list(a) 
list_b = make_divisor_list(b)
a_b = set(list_a) & set(list_b)

print(sorted(list(a_b))[-k])

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

def divisors(n):
    div = []
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div += [A]
            else:
                B = n//A
                div += [A, B]
        A += 1
    div.sort()
    return div

g = gcd(A, B)
v = divisors(g)
v.reverse()
print(v[K-1])

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

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

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

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

Solution (Python):
import math
A,B,K = map(int,input().split())
ans = []
if A>B:
    Max = A
else:
    Max = B
for i in range(1,Max+1):
    if (A%i==0) & (B%i==0):
        ans.append(i)
print(ans[len(ans)-K])

Solution (Python):
import math
import fractions
a,b,k= [int(i) for i in input().split()]

g=fractions.gcd(a,b)

cd=list()
i=1
while i<=g:
    if g % i == 0:
        cd.append(i)
    i+=1
print (cd[ -1 * k ])

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

ans = []
maxAnsNum = A
if A > B:
  maxAnsNum = B

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

seq = []

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

print(seq[-k])

Solution (Python):

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

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

Solution (Python):
Aa,Bb,Cc=input().split()
A=int(Aa)
B=int(Bb)
C=int(Cc)
count=0
kazu=min(A,B)
S=[]
for i in range(1,kazu+1):
    if A%i==0 and B%i==0:
        S.append(i)
S.reverse()
print(S[C-1])

Solution (Python):


import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

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

yakusu = defaultdict(int)

for a in range(A):
    a += 1
    if A % a == 0:
        yakusu[a] += 1
    if B >= a and B % a == 0:
        yakusu[a] += 1

nums = sorted([x for x in yakusu.keys() if yakusu[x] == 2])
print(nums[-(K)])

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

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

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

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

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

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

cnt = 0

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

Solution (Python):

from fractions import gcd


a, b, k = map(int, input().split())
g = gcd(a,b)
l = []

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

print(l[-k])

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

print(ans[-K])

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

cds = []
for i in range(100):
	if a%(i+1)!=0 or b%(i+1)!=0: continue
	cds.append(i+1)

cds.sort()
print(cds[::-1][k-1])

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

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

count=0
for sei in reversed(range(1, max((a,b))+1 )):
    if a%sei==0 and b%sei==0:
        count += 1
        if count == k:
            break

print(sei)

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

Solution (Python):
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(1,c+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 = tuple(map(int, input().split()))
res = []

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

print(res[-k])

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

Solution (Python):
a = list(map(int, input().split()))
now = 0
for j in range(max(a[0], a[1])):
    i = min(a[0], a[1]) - j
    if ((a[0] % i == 0) and (a[1] % i == 0)):
        now += 1
    if now == a[2]:
        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(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())
li = list()
for i in range(1, min(A+1, B + 1)):
    if A % i == 0 and B % i ==0:
        li.append(i)
print(li[-K])

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

k = 0

def judge(x,i):
  return x % i == 0

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

print(i)

Solution (Python):
import math

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

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

cnt = 0
ans = -1
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)

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):
A, B, K =map(int, input().split())
A_yaku = []
for i in range(1, int(A/2)+1):
    if A % i == 0:
        A_yaku.append(i)
A_yaku.append(A)
B_yaku = []
for i in range(1, int(B/2)+1):
    if B % i == 0:
        B_yaku.append(i)
B_yaku.append(B)
A_yaku = set(A_yaku)
B_yaku = set(B_yaku)

co_yaku = sorted(list(A_yaku & B_yaku))
for i in range(K):
    tmp = co_yaku.pop(-1)
print(tmp)

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

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

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

set_int = set(arr1) & set(arr2)

set_int = list(set_int)
set_int.sort()
print(set_int[-c])

Solution (Python):
a,b,k=map(int, input().split())
res_a = []
res_b = []
for i in range(1,a+1):
    if a % i == 0:
        res_a.append(i)
for j in range(1,b+1):
    if b % j == 0:
        res_b.append(j)
common = list(set(res_a) & set(res_b))
common.sort(reverse=True)
print(common[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[len(l)-k])

Solution (Python):
class Solver:

    def __init__(self):
        pass

    def solve(self, a, b, k):
        for n in range(min(a,b), 0, -1):
            if (a % n) == 0 and (b % n) ==0:
                k -= 1
                if k == 0:
                    return n
        return 1


if __name__ == '__main__':

    solver = Solver()

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

    n = solver.solve(a, b, k)
    print(n)

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

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

C=min(A,B)

count = 0

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

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

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

print(ans)

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


a_array = []
b_array = []

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


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


kyou_array = []

for i in a_array:
    if i in b_array:
        kyou_array.append(i)


print(kyou_array[-k])

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

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

x = max(A, B)

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

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

r=[]

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

Solution (Python):
import numpy as np

lst=input().split(" ")
A=int(lst[0])
B=int(lst[1])
K=int(lst[2])
lst=[]

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

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

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

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

  return res

common = sorted(list(set(divisors(a)) & set(divisors(b))))
print(common[-k])

Solution (Python):


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

cnt = 0

mini = min([a, b])
output = 1

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

print(output)

Solution (Python):




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


cnt = 0
anslist = list()
for idx in range(1, 101):
    if (a % idx) == 0 and (b % idx) == 0:
        anslist.append(idx)
        cnt += 1

anslist.sort(reverse=True)

print(anslist[k-1])

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

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

m = [x for x in range(1, min(A, B)+1) if A%x==0 and B%x==0]

print(m[-K])

Solution (Python):
import fractions
[a,b,k] = [int(i) for i in input().split()]
counter = 0
c = fractions.gcd(a,b)
for i in range(c,0,-1):
    if c % i == 0:
        counter += 1
        
    if counter == k:
        print(i)
        break

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

Solution (Python):
def get_gcd(a, b):
  m = max(a, b)
  n = min(a, b)
  while(True):
    if n == 0:
      break
    r = m % n
    m = n
    n = r
  return m


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

gcd = get_gcd(A, B)

cd_list = []
for i in range(1, gcd+1):
  if gcd % i == 0:
    cd_list.append(i)

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

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

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

print(num_list[-k])

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

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

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

if A > B:
    A, B = B, A
    
if B % A == 0:
    now = 1
    result = A
else:
    now = 0

num = A // 2
while now < K:
    if A % num == 0 and B % num == 0:
        now += 1
        result = num

    num -= 1

print(result)

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

main()

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

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

n=max(A,B)

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

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

main()

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

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

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

wa_list = []

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

print(wa_list[-K])

Solution (Python):
import types, math, operator
import numpy as np
from math import sqrt
from collections import Counter
from itertools import product
from functools import reduce
class PrimeUtils:
    @staticmethod
    def _has_numpy():
        g = globals()
        m = g.get('np')
        if m is not None and isinstance(m, types.ModuleType):
            return  m.__name__ == 'numpy'
        return False
    @staticmethod
    def _primes_sieve_pp(n):
        sieve = [True] * (n + 1)
        for i in range(2, int(sqrt(n)) + 1):
            if sieve[i]:
                for j in range(i * i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]
    @staticmethod
    def _primes_sieve_np(n):
        sieve = np.ones(n + 1, np.bool)
        sieve[0] = sieve[1] = False
        for i, v in enumerate(sieve[2:int(sqrt(n)) + 1], 2):
            if v: sieve[i*i::i] = False
        return np.nonzero(sieve)[0]
    @staticmethod
    def _primes_sieve_np_fast(n):
        n += 1
        sieve = np.ones(n//3 + (n%6 == 2), dtype=np.bool)
        check_upper = int(sqrt(n)) // 3
        for i, v in enumerate(sieve[1:check_upper + 1], 1):
            if v:
                k = (3*i + 1) | 1
                sieve[k* k           //3::2*k] = False
                sieve[k*(k-2*(i&1)+4)//3::2*k] = False
        sieve[0] = False
        return np.r_[2,3,((3*np.nonzero(sieve)[0] + 1)|1)]
    @classmethod
    def primes_sieve(cls, n):
        if cls._has_numpy():
            return cls._primes_sieve_np_fast(n)
        else:
            return cls._primes_sieve_pp(n)
    
    @classmethod
    def pfd(cls, n):
        primes = cls.primes_sieve(n)

        factors = []
        cur = n
        for p in primes:
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    factors.append(p)
                    cur = div
                else:
                    break
        assert(cur == 1)
        return factors
    
    @classmethod
    def aliquots(cls, n):
        pf = cls.pfd(n)
        pfc = Counter(pf)
        ppv = [[pow(p, i) for i in range(n+1)] for p,n in pfc.items()]
        if not ppv:
            return (1,)
        else:
            return map(lambda x: reduce(operator.imul, x), product(*ppv))

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

aa = set(PrimeUtils.aliquots(a))
bb = set(PrimeUtils.aliquots(b))
print(sorted(aa & bb, reverse=True)[k-1])

Solution (Python):
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

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

from collections import Counter

a = Counter(a)
b = Counter(b)

s = []
for key in a.keys():
    temp = min(a[key], b[key])
    s += [key] * temp



from itertools import permutations
import numpy as np



def mat(s):
    a = 1
    for ss in s:
        a *= ss
    return a

x = []
for k in range(len(s) + 1):
    for ss in permutations(s, k):

        x.append(mat(ss))

x = np.unique(x)
x = np.sort(x)[::-1]

print(x[K - 1])

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

Solution (Python):

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


if __name__ == '__main__':
    solve()

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

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

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

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

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

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

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

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

Solution (Python):
def GCM(p, q):
  if p < q:
    t = p
    p = q
    q = t
  if p % q == 0:
    return q
  else:
    return GCM(q, p%q)
A, B, K = map(int, raw_input().split())
G = GCM(A, B)
i = 1
CM = []
while i*i <= G:
  if G % i == 0:
    CM.append(i)
    CM.append(G/i)
  i += 1
print sorted(list(set(CM)))[-K]

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

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

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

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
GCD = gcd(A,B)
count=0
for i in range(GCD,0,-1):
    if GCD // i == GCD/i:
        count +=1
        if count == K:
            ans = i
            break
print(ans)

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

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

print(D[-K])

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

Solution (Python):
a,b,c = map(int,input().split())
co = 0
vv = []
for i in range(100):
	if a % (i+1) == 0 and b % (i+1) == 0:
		co += 1
		vv.append(i+1)

print(vv[-1*c])

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

Solution (Python):
A, B, K = map(int, input().split())
x = 101
count = 0

while count < K:
    x -= 1
    if A % x == 0 and B % x == 0:
        count += 1

print(x)

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

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


print(num[-k])

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

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

c = gcd(a, b)
cnt = 1
if k == 1:
    print(c)
    exit()
for i in range(2, c):
    if c % i == 0:
        cnt += 1
    if cnt == k:
        print(c // i)
        exit()
print(1)

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

def func(m,n):
	x = max(m,n)
	y = min(m,n)
	tmp =[]
	for it in range(y):
		it = it + 1
		if x%it == 0 and y%it==0:
			tmp.append(it)
	return tmp

tmp =func(a,b)
print(tmp[len(tmp)-K])

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

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

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

t_list = []
for i in range(1, 10 ** 5):
    if A%i == 0 and B%i == 0:
        t_list.append(i)
           
print(t_list[-K])

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

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

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

ds = [int(i) for i in range(1, max(a, b) + 1, 1) if a % i == 0 and b % i == 0]
ds.reverse()
print(ds[k - 1])

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

def gcd(x,y):
    X = max(x,y)
    Y = min(x,y)
    if Y == 0:
        return X
    else:
        return gcd(Y,X%Y)
ans = []
for i in range(1,101):
    if gcd(A,B) % i == 0:
        ans.append(i)

print(ans[-K])

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

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

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

Solution (Python):



def solve_gcd(number1, number2):
    if number1 == number2:
        return number1

    if number1 < number2:
        number1, number2 = number2, number1

    if number1 % number2 == 0:
        return number2

    return solve_gcd(number2, number1 % number2)


if __name__ == '__main__':
    A, B, K = map(int, input().split())
    gcd = solve_gcd(A, B)
    ctr = 0
    for i in range(gcd, 0, -1):
        if gcd % i == 0:
            ctr += 1
        if ctr == K:
            print(i)
            break

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

def solv():
    global a, b, k
    n = min(a,b)
    for i in range(n, 0, -1):
        if a%i == 0 and b%i == 0:
            k -= 1
            if k == 0:
                return i

r = solv()
print(r)