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 = (int(i) for i in input().split())

box=[]
for j in range(min(A,B),0,-1):
    if A % j ==0 and B % j ==0:
        box.append(j)

print(box[C-1])

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

a_divisors = set()
b_divisors = set()

for i in range(1, 101):
    if A % i == 0: a_divisors.add(i)
    if B % i == 0: b_divisors.add(i)

common_divisors = a_divisors & b_divisors

print(sorted(list(common_divisors))[-K])

Solution (Python):


if __name__ == "__main__":
    A, B, K = map(int, input().split())
    L = []
    for n in range(1, min(A, B)+1):
        if A % n == 0 and B % n == 0:
            L.append(n)

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

Solution (Python):
a, b, k = list(map(int,input().split()))
def yakusu(n):
    ys = []
    for i in range(1, n+1):
        if n % i == 0:
            ys.append(i)
    return ys
ys_a = yakusu(a)
ys_b = yakusu(b)
ys_ab = list(set(ys_a)&set(ys_b))
ys_ab = sorted(ys_ab)
print(ys_ab[-k])

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

i=0
j=100
while i<K:
    if A%j==0 and B%j==0:
        i +=1
    else:
        i =i
    j-=1

print(j+1)

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

n = 0
for i in reversed(range(1, min(a, b)+1)):
    if(a%i==0 and b%i==0):
        n +=1
    if(n == k):
        ans = i
        break
print(ans)

Solution (Python):

import sys

def main():
	A, B, K = map(int, input().split(" "))
	
	tmp = []
	counts = 0
	for i in range(1, 101):
		if A % i == 0 and B % i == 0:
			tmp.append(i)
			counts += 1
	
	print(tmp[counts - K])
	
	
if __name__ == "__main__":
	main()

Solution (Python):
a, b, k = 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):
a,b,c=(int(x)for x in input().split())
division =[]
if a>=b:
    x=a
    while x>0:
        if a%x==0 and b%x==0:
            division.append(x)
            x -=1
        else:
            x -=1
else:
    x=b
    while x>0:
        if a%x==0 and b%x==0:
            division.append(x)
            x -=1
        else:
            x -=1

print(division[c-1])

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

N = min(a,b)
cd = []

for i in range(N):
    if a % (i+1) == 0 and b % (i+1) == 0 :
        cd.append(i+1)

print(cd[-k])

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

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

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

Solution (Python):
def int_raw():
    return int(raw_input())
 
def words_raw():
    return raw_input().split()
 
def ints_raw():
    return map(int, words_raw())

A, B, K = ints_raw()
for delimiter in range(min(A, B), 0, -1):
	if A % delimiter == 0 and B % delimiter == 0:
		K -= 1
		if K == 0:
			print delimiter
			break

Solution (Python):

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

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

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

if A > B:
    A, B = B, A

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

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

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



if A > B:
	A, B = B, A
	

d = []

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

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

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



if A > B:
	tmp = B
	B = A
	A = tmp
	

d = []

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

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

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

n = min(a, b) + 1 
while k:
    n -= 1
    if a % n == 0 and b % n == 0:
        k -= 1
print(n)

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

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

n = min(a, b) + 1 
while k:
    n -= 1
    if a % n == 0 and b % n == 0:
        k -= 1
print(n)

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

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

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.insert(0, i+1)
print(ans[K-1])

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

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+=[i]
print(lst[-K])

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

a,b,k=map(int,input().split(" "))
g=gcd(a,b)
if k==1:
    print(g)
else:
    cnt = 1
    for n in range(2,g+1):
        if g%n==0:
            cnt+=1
            if cnt==k:
                print(int(g/n))
                break

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

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

c = []

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

print(c[-k])

Solution (Python):
def divde(argv):

    dlist=[]
    i = 1
    for i in range (1,int(argv)+1):
        if(int(argv)%i==0):
            dlist.append(i)
    return dlist

def compare(A,B):
    D =[]
    for i in range (len(A)):
        for j in range(len(B)):
            if A[i]==B[j]:
                D.append(B[j])
    return D

if __name__ == "__main__":
    string = input()
    a, b, c = string.split()

    A = []
    A = divde(a)
    B = []
    B = divde(int(b))
    D = []
    D = compare(A,B)

    D.reverse()

    q = int(c)-1
    print(D[q])

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

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

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

if(A > B):
    start = B
else:
    start = A

cnt = 0
for i in range(start,0,-1):
    if(0 == A % i == B % i):
        cnt = cnt + 1
    if(K == cnt):
        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)
print(list[-k])

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

Solution (Python):
ABK=input().split()
A=int(ABK[0]);B=int(ABK[1]);K=int(ABK[2])
list=[]
for i in range(1,min(A,B)+1):
    if (A/i).is_integer() and (B/i).is_integer():
        list.append(i)
list.sort(reverse=True)
print(str(list[K-1]))

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

answer_candidate = []
limit = max(A, B)

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

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

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

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

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

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())
c = 0
for i in range(min(a, b), 0, -1):
    if a % i == b % i == 0:
        c += 1
    if c == k:
        print(i)
        break

Solution (Python):

Ai,Bi,K = map(int, input().strip().split())
A = max(Ai,Bi)
B = min(Ai,Bi)
x = [n for n in range(1,B+1)[::-1] if A%n == 0 and B%n == 0]
print(x[K-1])

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

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


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

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

Solution (Python):
import math

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

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

print(l[-K])

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

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

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

print(answer)

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

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

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

print(division[-k])

Solution (Python):
A, B, N = map(int, input().split())
if B < A:
  B_t = A
  A = B
  B = B_t

divisors = []
divisors_A = []

for s in range(1, A+1):
  if A % s == 0:
    divisors_A.append(s)
    
for k in divisors_A:
  if B % k == 0:
    divisors.append(k)
    
divisors = divisors[::-1]
print(divisors[N-1])

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

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

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

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

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

A_divisor = set()
for i in range(1, A+1):
    if divmod(A,i)[1] == 0:
        A_divisor.add(i)

B_divisor = set()
for i in range(1, B+1):
    if divmod(B,i)[1] == 0:
        B_divisor.add(i)

Intersection = list(A_divisor & B_divisor)
print(sorted(Intersection, reverse=True)[C-1])

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

Solution (Python):


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

max = max(a, b) + 1
if max > 101:
    max = 101

list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list[-c])

Solution (Python):


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

max = 101



list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list[-c])

Solution (Python):
class MathAlgorithm(object):

    MOD = 10000000 + 7

    @classmethod
    def gcd(cls, a: int, b: int) -> int:
        if b < 0 or (a == 0 and b == 0):
            raise ValueError

        if b > a:
            return cls.gcd(b, a)

        if b == 0:
            return 0

        if a % b == 0:
            return b

        return cls.gcd(b, a % b)


if __name__ == '__main__':
    A, B, K = map(int, input().split())

    gcd = MathAlgorithm.gcd(A, B)
    common_divides = []

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

    print(common_divides[-K])

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

als = []
bls = []

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

common = []

for a in als:
  if a in bls:
    common.append(a)

common.sort()
print(common[-K])

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

ary=[]

min_num=min(A,B)

for i in range(min_num):
    div_num=i+1
    if A%div_num == 0 and B%div_num == 0:
        ary.append(div_num)

ary.reverse()


print ary[K-1]

Solution (Python):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() 

a,b,k = na()

c =min(a,b)
d = 0
while(1):
  if a%c == 0 and b%c == 0:
    d += 1
  if d == k:
    break
  c -= 1
  
print(c)

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

def euclid(a, b):
    c = 1
    big = max(a, b)
    small = min(a, b)
    while (c != 0):
        c = big % small
        big = small
        small = c
    return big

c = euclid(a, b)
if k == 1:
    print(c)
    exit()
else:
    a_list = [i for i in range(1,c) if (c%i == 0)]
    print(a_list[-k+1])

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

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

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

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

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

if A>=B:
  for i in range(1, A+1): 
    if A%i==0 and B%i==0:
      a.append( i )
      
  
else:
  for i in range(1, B+1): 
    if A%i==0 and B%i==0:
      a.append( i )
      






 
  
c=len(a)
print(a[c-K])

Solution (Python):
num_A, num_B, order_K = map(int, raw_input().split())

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

common_divisor =  list(set(get_divisor(num_A)) &  set(get_divisor(num_B)))
common_divisor.sort(reverse=True)
print common_divisor[order_K - 1]

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

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

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

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

print(l[::-1][k-1])

Solution (Python):
A,B,K = [int(x) for x 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):
def gcd(t):
    b,a=sorted(t)
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m
a,b,k=(int(x) for x in input().split())
g=gcd((a,b))
cd=[]
for i in range(g+1)[::-1]:
    if i==0:
        break
    if g%i==0:
        cd.append(i)
print(cd[k-1])

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

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

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

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

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

def euclid(p,q):
  if q == 0:
    return p
  else:
    return euclid(q,p%q)
  
n = euclid(a,b)
count = 0
for i in range(n):
  if n % (n-i)==0:
    count += 1
  if count == k:
    print(n-i)
    break

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

print(x[-k])

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

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

Solution (Python):
def gcd(a, b, k):
    count = 0
    if a < b:
        a, b = b, a
    for i in range(1,b+1)[::-1]:
        if a % i == 0 and b % i == 0:
            count += 1
            if count == k:
                return i

li = list(map(int, input().split()))
print(gcd(li[0], li[1], li[2]))

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

n = min(A,B)
l = []

for x in range(1,n+1):
    if A%x == 0 and B%x==0:
        l.append(x)

l.sort(reverse=True)

print(l[K-1])

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

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

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

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

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

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

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

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

Solution (Python):


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

k = 0
min = min(A, B)

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

Solution (Python):
def euq(A, B):
    while B> 0:
        A, B = B, A % B
    return A

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

r = euq(A, B)
R = []
for i in range(1, r+1):
    if r % i == 0:
        R.append(i)
print(R[-C])

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

print(ans[-k])

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

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

Solution (Python):
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
k=0
for i in reversed(range(1,A+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())

n = 0
for i in range(max(A, B), 0, -1):
    if A % i != 0 or B % i != 0:
        continue
    n += 1
    if n == K:
        break
print(i)

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

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

Solution (Python):
A, B, K = map(int, input().split())
 
count = 0
index = 0
 
if A >= B:
  for i in reversed(range(1, B+1)):
    if A % i == 0 and B % i == 0:
      index = i
      count = count+1
      if count == K:
        break
elif A < B:
    for i in reversed(range(1,A+1)):
      if A % (i) == 0 and B % (i) == 0:
        index = i
        count = count+1
        if count == K:
          break
  
print(index)

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

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

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

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

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

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

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

Solution (Python):
input = input()
a,b,c = map(int,input.split())
counter = 0
for x in range(min(a,b),0,-1):
  if(a%x==0 and b%x == 0):
    counter += 1
    if(counter == c):
      print(x)
      break

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

Solution (Python):


A,B,K = list(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, raw_input().split())

m = max(a,b)
count = 0
array = []
for i in range(1, m+1):

    if a%i==0 and b%i==0:
        count += 1
        array.append(i)

print array[-k]

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

def solve():
    m = min(A,B)
    count = 0
    res = []
    for i in range(1,m+1):
        if A % i == 0 and B % i == 0:
            count += 1
            res.append(i)
    res.reverse()
    print(res[K-1])

solve()

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

Solution (Python):
A, B ,K  = (int(x) for x in input().split())
i = 1
ans = []
while True:
    if min(A,B) < i:
        break
    if (A % i == 0) & (B % i == 0):
        ans.append(i)
    i = i + 1
print(ans[len(ans)-K])

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

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

if int(nums[0]) >= int(nums[1]):
  min = int(nums[1])
else:
  min = int(nums[0])
  
count = 0
for i in range(min):
  if int(nums[0]) % min == 0 and int(nums[1]) % min == 0:
    count += 1
    if int(nums[2]) == count:
      print(min)
    else:
      min -= 1
  else:
    min -= 1

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

print(answers[K-1])

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

def divlist(x):
  numbers = []
  divX = []
  try:
    for i in range(1,x+1):
      numbers.append(i)
      if x % i == 0:
        divX.append(i)
    divX = set(divX)
    return divX
  except ZeroDivisionError:
      print("ZeroDivisionError!!")

divA = divlist(A)
divB = divlist(B)
common = list(divA & divB)
common = sorted(common)




print(common[-K])

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

Solution (Python):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

input = [int(item) for item in input().split()]
a, b, k = input
divisors = make_divisors(a)

th = 0
for i, item in enumerate(divisors[::-1]):
  if b % item == 0:
    th += 1
  if th == k:
    print(item)
    break

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

print(ls[-k])

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

def divisor_list(n):
    ret = set()
    i=1
    while i*i <= n:
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
        i += 1
    return ret

DA = divisor_list(A)
DB = divisor_list(B)



COM = list(set(DA) & set(DB))
COM.sort(reverse=True)

print(COM[K-1])

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

Solution (Python):
l = [int(i) for i in input().split()]
dev = []
for i in range(1, min(l[0], l[1])+1):
    if ((l[0]%i)==0)and(l[1]%i==0):
        dev.append(i)
print(dev[-l[2]])

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

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

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

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

gcd = gcd(a,b)
cd_list = find_divisor(gcd)[::-1]

print(cd_list[k-1])

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

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

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

print(items[-K] if len(items) >= K else items[0])

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())
listA = []
listB = []

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

A_B = set(listA) & set(listB)
listA_B = list(A_B)
listA_B.sort(reverse = True)

print(listA_B[K-1])

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

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

print(i)

Solution (Python):
a, b, k = [int(x) for x in 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,input().split())
X=[]
if A<=B :
    for a in range(A):
        if A%(a+1)==0 and B%(a+1)==0:
            X.append(a+1)
        else:
            continue

else :
    for b in range(B):
        if A%(b+1)==0 and B%(b+1)==0:
            X.append(b+1)
        else:
            continue
print(X[-K])

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

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

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

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

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

Solution (Python):
li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

s = []

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

l =len(s)
print(s[l-c])

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

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

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

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

Solution (Python):
A, B, K = map(int, input().split())
cnt = 0
ans = 1
cntlist = []

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

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

Solution (Python):
a, b, k = map(int, input().split())
count = 0
ans = min(a,b)
while count != k:
    if a%ans == b %ans == 0:
        count += 1
    ans -= 1
print(ans+1)

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

temp = 0
temp1 = 0
divisor = []
counter = 0

if A >= B:
  temp = A
  temp1 = B

else:
  temp = B
  temp1 = A

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

for j in (reversed(divisor)):
  if temp % j ==0:
    counter += 1
    if counter == times:
      print(j)
      break

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):
in_str = input()
a,b,k = (int(x) for x in in_str.split(' '))
x = min(a,b) + 1
while k > 0:
  x += -1  
  if a % x == 0 and b % x == 0:
    k -= 1
print (x)