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

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

Solution (Python):


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

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

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

Solution (Python):
A,B,K=map(int,input().split())
a=[n for n in range(1,A+1) if A%n==0]
b=[n for n in range(1,B+1) if B%n==0]
print(sorted(set(a)&set(b))[::-1][K-1])

Solution (Python):
A, B, K = map(int, input().split())
n = max(A, B)
k = 0
while True:
    if A % n == 0 and B % n == 0:
        k = k + 1
    if k >= K:
        break
    n = n - 1
print(n)

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

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, K] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    count = 0

    if max(A, B) == 1:
        print 1
        return

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

if __name__ == '__main__':
    main()

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

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

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

num = len(l)

print(l[num-k])

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

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

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

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

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

Solution (Python):
A,B,K=map(int, raw_input().split());print list(i for i in range(A,0,-1)if A%i+B%i<1)[K-1]

Solution (Python):
import sys
import io
import math

datalist = input().split()

data_a = int(datalist[0])
data_b = int(datalist[1])
data_k = int(datalist[2])

check_flag = 0
for i in range(data_b,0,-1):
    if data_a % i == 0 and data_b % i == 0:
        check_flag += 1
        if check_flag == data_k:
            print(i)
            sys.exit()

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

Solution (Python):




def kthCommonDivisor(A,B,count):
	startNumber = min(A,B)
	canCommonDivisor = list()
	for i in range(startNumber,0,-1):
		if A % i == 0 and B % i == 0:
			canCommonDivisor.append(i)
	answer = canCommonDivisor[count-1]
	return answer

if __name__ == '__main__':
	A,B,K = map(int,input().strip().split(' '))
	solution = kthCommonDivisor(A,B,K)
	print("{}".format(solution))

Solution (Python):

def spaceinput():
    return list(map(int,input().split(" ")))

A,B,K=spaceinput()

res=[]

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

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

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

yakusuu_array = []

for ab in [a,b]:
    yakusuu_array_ab = []
    for i in range(1,ab+1):
        if ab % i == 0:
            yakusuu_array_ab.append(i)
    yakusuu_array.append(yakusuu_array_ab)

kouyakusuu = list(set(yakusuu_array[0]) & set(yakusuu_array[1]))
kouyakusuu.sort()

if len(kouyakusuu) == 0:
    print(1)
else:
    print(kouyakusuu[-k])

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


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

Solution (Python):


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


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

Max = int(gcd(A, B) )


list = [0] * 1000

j =0

if A == 1 or B == 1:
    print("1")
    quit()

for i in range(Max):

    if i == 0:
        continue
    if Max % i == 0:
        list[j] = i
        j += 1

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

print(list[j - K+1])

Solution (Python):
def gcd(m, n):
    return m if n == 0 else gcd(n, m % n)

if __name__ == "__main__":
    s = input()
    mylist = s.split()
    a = int(mylist[0])
    b = int(mylist[1])
    k = int(mylist[2])
    mygcd = gcd(a,b)
    cdList = []
    for i in range(1, mygcd+1, 1):
        if(a % i == 0 and b % i == 0):
            cdList.append(i)
    print(cdList[len(cdList) - k])

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

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

        return dl

ad = set(d(A))
bd = set(d(B))

div = sorted(set.intersection(ad, bd), reverse=True)

print(div[K-1])

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

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

divs = [1]
div = 2
while div <= A and div <= B:
    if A % div == 0 and B % div == 0:
        divs.append(div)
    div += 1

print(divs[-K])

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

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

print(div[-k])

Solution (Python):

hurui = list(range(101))
hurui2 =list(range(101))

counter = 2
while True:
    if counter > 100:
        break
    if hurui[counter] != 0:
        a = counter
        while True:
            if (a + counter) > 100:
                break
            a += counter
            hurui[a] = 0
            
    counter += 1

sosu = list(set(hurui))

a, b, c = list(map(int, input().strip().split()))
ansa = []
ansb = []
for i in range(1, len(hurui2)):
    if (b % hurui2[i]) == 0:
        ansb.append(hurui2[i])
    if (a % hurui2[i]) == 0:
        ansa.append(hurui2[i])
    counter += 1
ans = list(set(ansa) & set(ansb))




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

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

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

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):
inp = [int(i) for i in input().split()]
li =[]
li2 =[]

for k in range(1,inp[0]+1):
  f = inp[0] / k
  if f.is_integer():
    li.append(k)

for m in range(1,inp[1]+1):
  h = inp[1] / m
  if h.is_integer():
    li2.append(m)
    
li3 = list(set(li) & set(li2))
li3.sort()
print(li3[-inp[2]])

Solution (Python):
data = input().split()
a = int(data[0])
b = int(data[1])
k = int(data[2])
 
ans = []
for i in range(1, a+1 if a < b else b+1):
    if a%i == 0 and b%i == 0:
        ans.append(i)

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

Solution (Python):
str_lis = input().split()
A, B, K = [int(x) for x in str_lis]
N = min(A, B)
num_lis = [n for n in range(1, N + 1) if A % n == 0 and B % n == 0]
lis = num_lis[::-1]
print(lis[K - 1])

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

Solution (Python):
a,b,k=map(int,raw_input().split())
a,b=min(a,b),max(a,b)
n=0
ans=1
for i in xrange(a,0,-1):
	if a%i==b%i==0:
		n=n+1
	if n==k:
		ans=i
		break
print ans

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

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

Solution (Python):
"""
    正解数　A,B
    正の整数　Z：A,Bも割り切る
    出力：Zの内K番目に大きいもの
"""

a, b, k = map(int, input().split())
i = 1
z = []

while i <= 100:
    if (a % i == 0 and b % i == 0):
        z.append(i)
    i += 1
    
print(z[-k])

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

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

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

print(x[-k])

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

Solution (Python):
def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

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

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

tmp = []
for i in range(100):
    if A % (i+1) == 0:
        if B % (i+1) == 0:
            tmp.append(i+1)

tmp.reverse()
print(str(tmp[K-1]))

Solution (Python):
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b


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

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

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

if A >= B:
    L, S = A, B
if A < B:
    L, S = B, A

while L%S != 0:
    tmp = L;
    L = S;
    S = tmp%S;

gcd = int(S)

if gcd == 1:
    print(1)
    exit()

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

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

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

Solution (Python):
c, d, e = map(int, input().split())
if c > d:
    max_num = c
    min_num = d
else:
    max_num = d
    min_num = c

li = []
for i in range(1, min_num+1):
    if max_num % i == 0 and min_num % i == 0:
        li.append(i)

list_num = abs(e - len(li))
print(li[list_num])

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

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

Solution (Python):
x,y,z = map(int,input().split())
n = (y if x < y else x) 
n += 1
array = [1]
for i in range(1,n):
	if (x%i==0 and y%i==0):
		array.append(i)
array.reverse()
print(array[z-1])

Solution (Python):



from sys import stdin



import numpy as np

n = stdin.readline().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])

ans = []
for i in range(1, a+1):
    if a%i==0:
        ans.append(i)
ans=sorted(ans,reverse=True)
if a == 1:
    ans=[1]
count=0

for i in ans:
    if b%i==0:
        count+=1
    if count==c:
        break
print(i)

Solution (Python):

"""
Created on Sun Mar  3 19:52:44 2019

@author: Yamazaki Kenichi
"""

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

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

Solution (Python):
A = list(map(int,input().split( )))
a=A[0]
b=A[1]
k=A[2]
x=0
for h in range(100):
	i= (b if a>b else a)-h
	if a%i + b%i:
		continue
	x=x+1
	if x == k:
		break
print(i)

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

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

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

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

Solution (Python):
A,B,K = [int(_) for _ in input().split()]
c = 0
i = 100
while True:
    if A%i == B%i == 0:
        c += 1
    if c == K:
        break
    i -= 1
print(i)

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

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

print(i)

Solution (Python):
from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
for i in list(reversed(range(1, min + 1))):
    if max % i == 0 and min % i == 0:
        k += 1
        if k == a[2]:
            print(i)
            break

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

Solution (Python):

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

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

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

rtn = max(A, B); 
rtn_list =[] 
while len(rtn_list) < K:
    if not(A % rtn) and not(B % rtn):
        rtn_list.append(rtn)
    rtn -= 1
print(rtn_list[-1])

Solution (Python):
a, b, c = map(int, input().split())
list = []
list1 = []
for i in range(a):
  d = a % (i+1)
  if d == 0:
    list.append(i+1)
  else:
    pass
for k in range(len(list)):
  e = b % list[k]
  if e == 0:
    list1.append(list[k])
  else:
    pass
print(list1[-c])

Solution (Python):
a = list(map(int, input().split()))
num1 = a[0]
num2 = a[1]
list1 = []
list2 = []
max = a[2]
for i in range(1, num1 + 1):
  if num1 % i == 0:
    list1.append(i)
    
for i in range(1, num2 + 1):
  if num2 % i == 0:
    list2.append(i)

list3 = list(set(list1) & set(list2))
list3.sort()
list3.reverse()

print(list3[max -1])

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

Solution (Python):

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

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

def cd(a,k):
    for i in reversed(range(1,a+1)):
        if a%i == 0:
            k = k-1
            if k==0:
                return i
    return -1

print(cd(gcd(a,b),k))

Solution (Python):
import sys

i = list(map(int, input().split()))
A = i[0]
B = i[1]
K = i[2]

yaku_A = []
yaku_B = []

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

for i in range(1,B+1):
    if B % i == 0:
        yaku_B.append(i)
        
SS = list(set(yaku_A) & set(yaku_B))
SSS = sorted(SS)
        
print(SSS[-K])

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

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

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

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

A = inp[0]
B = inp[1]
K = inp[2]


yakusuu_a = []
yakusuu_b = []

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

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

c = []
for i in yakusuu_a:
  if i in yakusuu_b:
    c.append(i)

c.sort(reverse=True)
if len(c) == 0:
  print(1)
else:
  print(c[K-1])

Solution (Python):
import fractions
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass 
a,b,k = map(int,input().split())
gcd = fractions.gcd(a,b)
yaku = list(reversed(sorted(list(set(divisor(gcd))))))
print(yaku[k-1])

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

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

GCA = gcd(A, B)
A_all_div=[]
B_all_div=[]


for i in range(1,A+1):
    if A % i == 0:
        if i <= GCA:
            A_all_div.append(i)
A_all_div.sort(reverse=True)

for i in range(1,B+1):
    if B % i == 0:
        if i <= GCA:
            B_all_div.append(i)
B_all_div.sort(reverse=True)

ALL_DIV = set(A_all_div) & set(B_all_div)
all_div = list(ALL_DIV)

all_div.sort(reverse=True)

print(all_div[K-1])

Solution (Python):
a, b, k = [int(x) for x in input().split()]
al = set()
bl = set()
for i in range(1, a+1):
    if a%i == 0:
        al.add(i)
for i in range(1, b+1):
    if b%i == 0:
        bl.add(i)
kk = list(al & bl)
kk.sort(reverse=True)
print(kk[k-1])

Solution (Python):

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


c=0

ans = 1
for i in range(1000,1,-1):
    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())
t = 0
for i in range(100):
  if a%(100-i)==0:
    if b%(100-i)==0:
      t+=1
  if t==k:
    break;
print(100-i)

Solution (Python):
a, b, k = map(int, input().split())
num = max(a, b)
b = min(a, b)
a = num
while 1:
    num = a % b
    if num == 0:
        break
    a = b
    b = num
num = 0
for i in range(1, b+1):
    if b % i == 0:
        num += 1

    if num == k:
        print(b//i)
        break

Solution (Python):
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
A,B,K=map(int,input().split())
G=gcd(A,B)
L=[]
for i in range(1,G+1):
    if G%i==0:
        L.append(i)
L.sort(reverse=True)
print(L[K-1])

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

ans = 0

lista = list(range(a+1))
aa = lista.pop(0)

listb = list(range(b+1))
bb = listb.pop(0)

if (a < b):
    li = [i for i in lista if a % i == 0 and b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in listb if a % i == 0 and b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)

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

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

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

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

d = a
if a>b:
    d = b
i=int(2)
while i <= d:
    if a%i==0  and b%i==0:
        num.append(i)
        i += 1
    else:
        i += 1


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

Solution (Python):
A, B, K = map(int, input().split())
i = 0
j = 100
ans = 1
while (i < K):
    if (A % j == 0) & (B % j == 0):
        ans = j
        i += 1
    j -= 1

print(int(ans))

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

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

print(List[-k])

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

a,b,k=[int(s)for s in input().split()]
g=euclid(a,b) if a>b else euclid(b,a)
d=[]
for i in range(g):
  if g%(i+1)==0:d.append(i+1)

print(d[-k])

Solution (Python):
def get_div(num):
    if num == 1:
        return [1]
    else:
        return [i for i in range(1,num+1) if num%i==0]

A, B, K  = [int(a) for a in input().split()]
cat = get_div(A) + get_div(B)
dup = sorted([x for x in set(cat) if cat.count(x) > 1])
dup.reverse()
print(dup[K-1])

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

Solution (Python):
A, B, K = map(int, input().split(' '))
A_set = set()
B_set = set()
for number in range(1, A+1):
    if A%number == 0:
        A_set.add(number)

for number in range(1, B+1):
    if B%number == 0:
        B_set.add(number)

A_Bset = A_set & B_set
A_Blist = list(A_Bset)
A_Blist.sort(reverse=True)
print(A_Blist[K-1])

Solution (Python):

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

print(divisor[-k])

Solution (Python):
import sys
A,B,K=[int(i) for i in 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)
        sys.exit()

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

thelist.sort(reverse=True)
print(thelist[k-1])

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

hoge = []
m = min(A, B)

for i in range(1, m + 1):
    if A % i == 0 and A // i > 0 and B % i == 0 and B // i > 0:
        hoge.append(i)
        
fuga = sorted(list(set(hoge)))
a = len(fuga) - K
print(fuga[a])

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

Solution (Python):
a,b,k =map(int,input().split()) 
cnt = 0
arr=list(range(1,max(a,b)+1))
arr.reverse()
for x in arr:
  if (a % x == 0) and (b % x == 0):
    cnt +=1
    if cnt == k:
      print (x)

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

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

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

Solution (Python):
import queue
a,b,c = map(int,input().split())
q = queue.LifoQueue()
for i in range(1,101):
  if(a%i == 0 and b%i == 0):
    q.put(i)
for i in range(c-1):
  q.get()
print(q.get())

Solution (Python):

a, b, k = map(int, input().split())
m = max(a,b)
al = [i for i in range(1,m+1) if a%i==0]
bl = [i for i in range(1,m+1) if b%i==0]
ans = sorted(list(set(al)&set(bl)))[::-1]
print(ans[k-1])

Solution (Python):
import math
A,B ,K= map(int,input().split(" "))
def gcd (a: int,b: int) -> int:
    if a < b: a,b = b,a
    return a if b == 0 else gcd(b,a%b)
def lcm (a: int,b: int) -> int:
    return a // gcd(a,b) * b

g = gcd(A,B)

itermx = math.sqrt(g)+1
lst = []
for j in range(1,int(itermx+1)):
    if g % j == 0:
        lst.append(j)
        if g // j != j:
            lst.append(g//j)
lst.sort(reverse=True)
print(lst[K-1])

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

Solution (Python):
import fractions
import copy

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

ab_gcd = fractions.gcd(A, B)
if ab_gcd == 1:
    print(ab_gcd)
    quit()

p = 2
elem = []
while p * p <= ab_gcd:
    while ab_gcd % p == 0:
        ab_gcd //= p
        elem.append(p)
    p = p + 1

if ab_gcd > 1:
    elem.append(ab_gcd)

cds = []
for c in elem:
    for i in range(2):
        e = c ** i
        if cds:
            copy_cds = copy.deepcopy(cds)
            for cd in copy_cds:
                cds.append(cd*e)
        cds.append(e)

cds = list(set(cds))
cds.sort(reverse=True)
print(cds[K-1])

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

list=[]
for j in range(1,101):
	a,b = A,B
	if a%j==0 and b%j==0:
		a,b = a/j, b/j
		list.append(j)

print(list[-K])

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

Solution (Python):
a,b,k=map(int,input().split())
x=max(a,b)
y=min(a,b)

def lcm(x,y):
    if y==0:
        return x
    else:
        return lcm(y,x%y)
yaku=[]
mx=lcm(x,y)
for i in range(1,mx):
    if mx%i==0:
        yaku.append(i)
yaku.append(mx)
print(yaku[-k])

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

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

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

koyakusu = list(set(yakusu_a) & set(yakusu_b))
koyakusu_sort = sorted(koyakusu,reverse=True)
print(koyakusu_sort[K-1])

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

A_list=list()
B_list=list()
C_list=list()

for i in range(A+1):
    if i==0:
        continue
    if A%i==0:
        A_list.append(i)

for x in range(B+1):
    if x==0:
        continue
    if B%x==0:
        B_list.append(x)

for y in A_list:
    for z in B_list:
        if y==z:
            C_list.append(y)



print(C_list[-K])

Solution (Python):


import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    a, b, k = MI()
    for i in range(max(a, b), 0, -1):
        k -= (a % i == 0) and (b % i == 0)
        if k == 0:
            return i


if __name__ == "__main__":
    print(main())

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

    num = []

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

    print(num[-k])

if __name__ == "__main__":
    main()

Solution (Python):
a,b,k=map(int,input().split())
yakusuu_array=[]
if a==b:
    max_gcd=a
else:
    for l in  reversed(range(min(a,b)+1)):
        if (a%l==0) and (b%l==0):
            max_gcd=l
            break        
if k==1:
    print(max_gcd)
else:
    for i in range(1,max_gcd):
        if max_gcd % i == 0:
            yakusuu_array.append(i)

    
    
    print(yakusuu_array[-(k-1)])

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

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

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

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

for i in range(110, 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())
k = 0
max_val = min(A,B) + 1
L = list(reversed((range(1, min(A,B) + 1))))

for div in L:
	if A%div == 0 and B%div == 0:
		k = k + 1
		if k == K:
			print(div)
			exit()

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)

list_and = set(list_A) & set(list_B)

list_and_sort = sorted(list_and, reverse=True)

print(list_and_sort[K-1])

Solution (Python):
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

a,b,c= map(int, input().split())
d= int(gcd(a,b))
if c==1:
  print(d)
else:
  arr=[]
  for i in range(1,d):
    if(d%i == 0):
      arr.append(i)
  print(arr[-(c-1)])

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

array1 = []
array2 = []

array1 = [i for i in range(1, a+1) if a % i == 0]
array2 = [i for i in range(1, b+1) if b % i == 0]

array = list(set(array1) & set(array2))
array.sort()
print(array[-k])

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

yakusuu=[]
yakusuuA = []
yakusuuB = []
for i in range(1,A+1):
  if A% i == 0:
    yakusuuA.append(i)
  
for j in range(1,B+1):
  if B%j == 0:
    yakusuuB.append(j)
    
yakusuu = list(set(yakusuuA) & set(yakusuuB))
yakusuu.append(1)     
print(sorted(yakusuu, reverse=True)[K-1])