Problem:
 Score : 200 points    Problem Statement You are given positive integers A and B .  Find the K -th largest positive integer that divides both A and B .  The input guarantees that there exists such a number.      Constraints  All values in input are integers.  1 \leq A, B \leq 100  The K -th largest positive integer that divides both A and B exists.  K \geq 1         Input Input is given from Standard Input in the following format:  A  B  K       Output Print the K -th largest positive integer that divides both A and B .        Sample Input 1 8 12 2      Sample Output 1 2  Three positive integers divides both 8 and 12 : 1, 2 and 4 .
Among them, the second largest is 2 .       Sample Input 2 100 50 4      Sample Output 2 5       Sample Input 3 1 1 1      Sample Output 3 1

Solution (Python):


import sys
 
a,b,k = map(int, sys.stdin.readline().rstrip().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*(-1)])

Solution (Python):
def main():
  A, B, K = map(int, input().split(" "))
 
  i = 1
  result = []
  while i <= min(A, B):
    if A % i == 0 and B % i == 0:
      result.append(i)
    i += 1
  print(result[-K])
  
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):
from sys import stdin


def b(input_string):
    a, b, k = [int(x) for x in input_string.split()]
    mod_0_numbers = []
    if a >= b:
        for i in range(1, a+1):
            if a % i == 0:
                if b % i == 0:
                    mod_0_numbers.append(i)
    else:
        for i in range(1, b+1):
            if b % i == 0:
                if a % i == 0:
                    mod_0_numbers.append(i)
    return mod_0_numbers[-k]


def main():
    input_line = stdin.readline().rstrip()
    answer = b(input_line)
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
memo = []

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

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

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

list_a = []
i = 1
while True:
    tmp1 = a % i
    tmp2 = b % i
    if tmp1 == 0 and tmp2 == 0:
        list_a.append(i)
    i += 1
    if a < i or b < 0:
        break
print(list_a[-1*(c)])

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

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

print(lis[-(K)])

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

l = []

greatest = a

if(b > a):
  greatest = b
  
for i in range(1, (greatest + 1)):
  if(a % i == 0 and b % i == 0):
    l.append(i)
    
print(str(l[len(l) - int(k)]))

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

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

if(a < b):
  tmp = a
  a = b
  b = tmp
  

if(k > 1):
 for i in range(b+1):
  if(i != 0):
   if((a%i == 0)and(b%i == 0)):
    G.append(i)
 
 print(G[-k]) 
elif(k == 1):
  print(gcd(a,b))

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

S = [1]

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

S.sort(reverse=True)

print(S[K-1])

Solution (Python):

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

n = A if A < B else B
k = 1

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

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

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

c=[]

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

print(c[k-1])

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

Solution (Python):
x = input().split(' ')
y = 0
i = 0
ans = []
while y < int(x[0]) and y < int(x[1]):
    y += 1
    if int(x[0]) % y == 0 and int(x[1]) % y == 0:
        ans.append(y)
        i += 1
print(ans[len(ans) - int(x[2])])

Solution (Python):
a,b,k = [int(x) for x in input().split()]
an = [x for x in range(1,101) if a%x == 0]
bn = [x for x in range(1,101) if b%x == 0]
res = list(set(an)&set(bn))
res.sort()
print(res[-k])

Solution (Python):


A, B, K = map(int, input().split())
flag = [False] * max(A, B)

for i in range(len(flag)):
    if (A % (i + 1) == 0) and (B % (i + 1) == 0):
        flag[i] = True
cnt = 0
answer = 0
for i, f in reversed(list(enumerate(flag))):
    if f:
        cnt += 1
        if cnt == K:
            answer = i + 1
            break

print(answer)

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

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

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

Solution (Python):


import fractions

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

gcd_num = fractions.gcd(A, B)

if K==1:
    print(gcd_num)
    exit()

yakusuu_array = []
for i in range(1,gcd_num):
    if gcd_num % i == 0:
        yakusuu_array.append(i)
        yakusuu_array.sort(reverse=True)

print(yakusuu_array[K-2])

Solution (Python):
import fractions

A, B, K = map(int, input().split())
g = fractions.gcd(A, B)
if K == 1:
    print(g)
else:
    count = 1
    for i in range(g // 2, 0, -1):
        if g % i == 0:
            count += 1
        if count == K:
            print(i)
            break

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

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

num = []
for n in range(1, min(A+1, B+1)):
    if A % n ==0 and B % n ==0:
        num.append(n)
    
print(sorted(num, reverse=True)[K-1])

Solution (Python):
A, B, K = map(int, input().split())
yaku_A = []
yaku_B = []
for i in range(1,A):
    if A % i == 0:
        yaku_A.append(i)
for j in range(1,B):
    if B % j == 0:
        yaku_B.append(j)
yaku_A.append(A)
yaku_B.append(B)
kou = list(set(yaku_A) & set(yaku_B))
kou.sort()
print(kou[-K])

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

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

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

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

Solution (Python):
A,B,K = map(int,input().split())
A_box = []
B_box = []
for i in range (1,101):
    if (A/i) == int(A/i):
        A_box.append(i)
    if (B/i) == int(B/i):
        B_box.append(i)
result=list(set(A_box) & set(B_box))
result.sort()

print(result[-K])

Solution (Python):



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

Solution (Python):
import fractions
li = list(map(int,input().split()))
a=li[0]
b=li[1]
k=li[2]
saidai=fractions.gcd(a,b)
yakusuu=[]
for i in range(100):
    if saidai%(i+1)==0:
        yakusuu.append(i+1)
yakusuu.sort()
yakusuu.reverse()
print(yakusuu[k-1])

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

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


def yaku(num):
    yaku_num=[num]
    for i in range(1,num):
        if num % i == 0:
            yaku_num.append(i)
    return yaku_num

A_yaku=set(yaku(A))
B_yaku=set(yaku(B))



yakusu=list(A_yaku & B_yaku)

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

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

Solution (Python):
A, B, K = map(int, input().split())
x = 0
i = 0
ans = [0] * 100
while i < max(A, B, 100):
    i += 1
    if ((A % i) == 0) and ((B % i) == 0):
        ans[x] = i
        x += 1
print(ans[x - K])

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

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

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

max_num = max(A, B)
count = 0

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

Solution (Python):

def main():
    a = list(map(int, input().split()))
    count = 0
    data_list = [i for i in range(1, a[0] + 1)]
    for i in data_list[::-1]:
        if a[0] % i == 0 and a[1] % i == 0:
            count += 1
            if count == a[2]:
                print(i)
                break


if __name__ == '__main__':
    main()

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

Solution (Python):
a,b,k=map(int,input().split())
mi=min(a,b)
ma=max(a,b)
flag=0
nim=0
ans=0

while True:
    tmp = mi - nim
    if flag == k:
        break
    else:
        if ma%tmp == 0:
            if mi%tmp == 0:
                ans = tmp
                nim += 1
                flag += 1
            else:
                nim += 1
        else:
            nim += 1
print(ans)

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

Solution (Python):
inData = input().split(' ')

seisu1 = int(inData[0])
seisu2 = int(inData[1])
ansK = int(inData[2])
ansList = []
maxSeisu = min([seisu1, seisu2])

for i in range(1, maxSeisu + 1):
    if (seisu1 % i == 0) and (seisu2 % i == 0):
        ansList.append(i)

ansListLen = len(ansList)
print(ansList[ansListLen - ansK])

Solution (Python):


tmp = input()
a = int(tmp.split(" ")[0])
b = int(tmp.split(" ")[1])
k = int(tmp.split(" ")[2])

x = int(min(a,b))
i= int(0)

while i < k:
    if a%x ==0:
        if b%x==0:
            i = i+1
            x = x-1
        else:
            x = x-1
    else:
        x = x-1
x=x+1
print(x)

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

if A==1 or B==1:
    print(1)
else:
    div = [x for x in range(1, min(A,B)+1) if A%x==0 and B%x==0]
    print(div[-K])

Solution (Python):
a,b,k=map(int,input().split())
c=0
n=0
if a>b:
    n=a-b
if b>a:
    n=b-a
if a==b:
    n=a
while(True):
    if(a%n==0)&(b%n==0):
        c=c+1
    if c==k:
        break
    n=n-1
print(n)

Solution (Python):
a,b,c=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==c:
        print(i)
        break

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

Solution (Python):
A, B, K = map(int,input().split())
if(A > B):
    A,B = B,A
d = 1;
l = []
while(d*d <= A):
    if(A%d != 0):
        d += 1
        continue
    if(not (B%d)):
        l.append(d)
    if(A//d != d and not (B%(A//d))):
        l.append(A//d)
    d += 1
l.sort(reverse=True)
print(l[K-1])

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator

from fractions import gcd


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())



A, B, K = 0, 0, 0


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


def main():
    set_inputs()


if __name__ == '__main__':
    main()

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 j in range(1, B+1):
    
    if B % j == 0:
        b_list.append(j)

a_b_list = list(set(a_list) & set(b_list))
a_b_list.sort(reverse=True)

print(a_b_list[K-1])

Solution (Python):
a, b, k = (int(i) for i in 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)
list1 = list(set(a_list) & set(b_list))
list2 = sorted(list1, reverse=True)
print(list2[k-1])

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

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

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

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

def get(num):
    yakusuu_array = []
    for i in range(1,num + 1):
        if num % i == 0:
            yakusuu_array.append(i)
    return yakusuu_array

a = list(set(get(A)) & set(get(B)))
a.sort(reverse=True)


print(a[(K-1)])

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

x = max(a, b)
y = min(a, b)
gcd = 0
if x % y == 0:
    gcd = y
else:
    while x % y != 0:
        z = x % y
        x = y
        y = z
    else:
        gcd = z

list_gcd = list()

for i in range(1, int(gcd/2) + 1):
    if gcd % i == 0:
        list_gcd.append(i)

list_gcd.append(gcd)
print(list_gcd[-k])

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

	result = retDivs(a,b)
	print(result[len(result)-k])
def retDivs(a, b):
	n = 0
	ret = []
	for x in range(1,max(a, b)+1):
		if a%x == 0 and b%x == 0:
			ret.append(x)
	
	return ret



if __name__ == "__main__":
	main()

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

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=list(map(int,input().split()))

L=[]

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

print(L[K-1])

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

Solution (Python):
from sys import stdin

def f(num):
  d = []
  if num != 1:
    for i in range(1,num):
      if num % i == 0:
    	  d.append(i)
      d.append(num)
  else:
      d = [1]
  return d

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
a = f(A)
b = f(B)
d = set(a)&set(b)
d = sorted(list(d),reverse=True)
print(d[C-1])

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

a=int(a)
b=int(b)
k=int(k)

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

list=divisor(a)+divisor(b)
s_list=sorted(list)[::-1]

c=0
for i, s in enumerate(s_list[:-1]):
    if s_list[i] == s_list[i+1]:
        c+=1
        if c==k:
            print(s)

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

print(res[-k])

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

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

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

    more = a if a > b else b

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

    number_list.sort(reverse=True)
    print(number_list.pop(k - 1))


if __name__ == '__main__':
    main()

Solution (Python):
def find_gcd(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp
    r = a % b
    if r == 0:
        return b
    else:
        return find_gcd(b, r)

A, B, K = [int(s) for s in input().split(' ')]
gcd = find_gcd(A, B)
if K == 1:
    print(gcd)
else:
    for i in range(gcd // 2, 0, -1):
        if gcd % i == 0:
            K -= 1
        if K == 1:
            break
    print(i)

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

d=[]
for yai in y_a:
  if yai in y_b:
    d.append(yai)
print(d[-k])

Solution (Python):
from fractions import gcd

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

d = gcd(A, B)

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

ass = divisor(d)

out = ass[-K]
print(out)

Solution (Python):
a,b,k = [int(i) for i in input().split()]
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):
i = input().split(" ")
a, b, k = int(i[0]), int(i[1]), int(i[2])

list = []
n = -1
for x in range(1, 101):
    if a%x == 0 and b%x == 0:
        list.append(x)
        n += 1

print(list[n-k+1])

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

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

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

Solution (Python):
A,B,K=map(int,input().split())
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
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
C=gcd(A,B)
D=make_divisor_list(C)
D.sort()
D.reverse()
print(D[K-1])

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())
a, b = min(a, b), max(a, b)

lst = []
for i in range(1, a+1):
  if a % i == 0:
    lst.append(i)
lst.sort(reverse=True)
cnt = 0
for num in lst:
  if b % num == 0:
    cnt += 1
    if cnt == k:
      print(num)
      break

Solution (Python):
from sys import stdin
import sys

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

a, b, k = list(map(int, stdin.readline().rstrip().split()))
g = gcd(a,b)

cnt = 0
l = []
for i in range(g // 2):
	if g % (i+1) == 0:
		l.append(i+1)

l.append(g)
print(l[len(l)-k])

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

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

Solution (Python):
a,b,c=map(int,input().split())
l=101
k=0
while k!=c:
    l-=1
    if a%l==0 and b%l==0:
        k+=1
    
print(l)

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

A = []

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



print(A[len(A)  - c])

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

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

count = 0
i = min(a, b)
while i > 0:
    if (a % i == 0) and (b % i == 0):
        count += 1
    if count == k:
        break
    i -= 1

print(i)

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

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

Solution (Python):
import fractions as f
a,b,k=map(int,input().split())
g=f.gcd(a,b)
count=0

for s in range(g,0,-1):
    if g%s==0:
  
        count+=1
    if count==k:
        print(s)
        exit()

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

Solution (Python):
import fractions

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

cnt = 1
for i in range(g, 0, -1):
    if g % i == 0:
        if cnt == K:
            print(i)
            break
        else:
            cnt += 1

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)
num_list.sort(reverse=True)
print(num_list[k-1])

Solution (Python):
import fractions

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

gcd = fractions.gcd(A, B)
order = 0
for i in range(gcd, 0, -1):
    if gcd % i == 0:
        order += 1
        if order == K:
            print(i)
            break

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

num = 0
for x in reversed(range(1, 101)):
    d = a % x + b % x
    if d == 0:
        num += 1
        if num == k:
            print (x)
            break

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

d = 1
i = 0
m = A if A < B else B
t = []
while d <= m:
    if (A % d == 0) and (B % d == 0):
        t.append(d)

    d += 1
    

r = t[len(t) - K]
print(r)

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

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

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

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

Solution (Python):
a, b, k = (int(i) for i in input().split())
counter = 0
i=min(a,b)+1
while counter != k:
    i-=1
    if a%i==0 and b%i==0:
        counter+=1
print(i)

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

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

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

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

Solution (Python):

import copy
import numpy as np
import random


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

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

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

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

Solution (Python):
import fractions

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

c = fractions.gcd(a,b)
d = []

for i in range(c):
    if c%(i+1)==0:
        d.append(i+1)

print(d[-k])

Solution (Python):


def _main():
    text = input()
    A, B, K = [int(i) for i in text.split(' ')]

    diviser_list = []
    num = 1
    min_num = min(A, B)

    while num <= min_num:
        if A%num == 0 and B%num == 0:
            diviser_list.append(num)

        num += 1

    print(diviser_list[-K])

if __name__ == '__main__':
    _main()

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

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

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

Solution (Python):
a,b,k = map(int, input().split())
count = 0
n = min(a, b)
ans = []
for i in range(1, n + 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= [int(ch) for ch in 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())

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

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

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

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

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

Solution (Python):
a,b,k = map(int,input().split())
ans = [1]
for i in range(2,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 = [ int(elem) for elem in input().split()]

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

Solution (Python):
def euclid(a,b):
    if b % a == 0:
        return a 
    else:
        return euclid(b % a, a)


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

ans = 0
gcd = euclid(a,b)
count = 0
for i in range(gcd,0,-1):
    if gcd % i == 0:
        count += 1
        if count == k:
            ans = i
            break 
print(ans)

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

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

Solution (Python):
a = input().split()
A = int(a[0])
B = int(a[1])
K = int(a[2])
cd = []
i = 1
if A < B:
    big = B
else:
    big = A
while i <= big:
    if A % i == 0 | B % i == 0:
        cd.append(i)
    i += 1

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

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

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

print(box[-K])

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

a,b,k = map(int,input().split())
x = gcd(a,b)
list_num = []
for i in range(1,x+1):
    if x % i == 0:
        list_num.append(i)
list_num = sorted(list_num,reverse=True)
print(list_num[k-1])

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

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

Solution (Python):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
a, b, k = map(int, input().split())
max_yakusuu = gcd(a, b)
yakusuu_array = []
for i in range(1,max_yakusuu):
  if max_yakusuu % i == 0:
    yakusuu_array.append(i)
if k!=1:
  print(yakusuu_array[len(yakusuu_array)-k+1])
else:
  print(max_yakusuu)

Solution (Python):
from math import floor


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


main()

Solution (Python):
a,b,k=map(int,input().split())
c=i=0
l=[]
while i<min(a,b):
    while i<min(a,b)and(a%-~i or b%-~i):
        i+=1
    i+=1
    if a%i<1and b%i<1:
        l.append(i)
print(l[-k])

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

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

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

Solution (Python):

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

count = 0


ans = []

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

print(ans[-1*k])

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

l = []
n = 0
while(b != n):
    n += 1
    if (a % n == 0 and b % n == 0):
        l.append(n)

print(l[-k])

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 i in range(1,b+1):
    if b % i == 0:
        B.append(i)
common = list(set(A) & set(B))
common.sort(reverse=True)

print(common[k-1])

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


main()

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

cnt = 0
ans_dic = {}
for i in range(max(a, b)):
    n = i+1
    if a%n == 0 and b%n == 0:
        cnt += 1
        ans_dic[cnt] = n

print(ans_dic[cnt - (k-1)])