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 fractions

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

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

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

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

ans=[]

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

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

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

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



if __name__ == '__main__':
    main()

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

N = A if (A > B) else B

D = []
for n in range(1, N+1):
  if (A % n != 0):
    continue
  else:
    if (B % n != 0):
      continue
    else:
      D.append(n)

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

Solution (Python):
import fractions

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

gc = fractions.gcd(A, B)
ctr = 1

while (gc > 0):

    if (A % gc == 0 and B % gc == 0):
        
        if (ctr == K_ban):
            print(gc)
            break
        else:
            ctr += 1
    
    gc -= 1

Solution (Python):
a, b, k = map(int, input().split())
 
def get_divisors(n):
    return [i for i in range(1, n//2+1) if n%i == 0] + [n]

print(sorted(set(get_divisors(a)) & set(get_divisors(b)), reverse=True)[k-1])

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

def factors(i):
    ans = []
    for j in range(1, i + 1):
        if i % j == 0:
            ans.append(j)
    return ans

fA = factors(A)
fB = factors(B)

AB = [a for a in fA if a in fB]



print(AB[::-1][K - 1])

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

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

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

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

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

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

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

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

print(ans[-k])

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

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


if __name__ == "__main__":
    main()

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

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

print(ans_list[-K])

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





a,b,k=mii()
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)
            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)

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

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())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

d = gcd(a,b)
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
div = make_divisors(d)
print(div[-k])

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

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

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

print(func(a,b,k))

Solution (Python):

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

from fractions import gcd

x=gcd(A,B)
cnt=0
for i in range(x,0,-1):
    if x%i==0:
        cnt+=1
    if cnt==K:
        print(i)
        exit()

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

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

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

    
    return divisors
Anoyatu=make_divisors(A)
Bnoyatu=make_divisors(B)
ans=list(set(set(Anoyatu)&set(Bnoyatu)))
ans.sort()
ans.reverse()

print(ans[K-1])

Solution (Python):

a,b,k = map(int,input().split())
l = []
c = min(a,b)
d = max(a,b)

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


print(l[-k])

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

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

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

Solution (Python):
import fractions

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

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:
        print(i)
        break

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())
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):
A, B, K = map(int, input().split())

li = []

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

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

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

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

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

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

Solution (Python):
class Solution:
    def solve(self, A: int, B: int, K: int) -> str:

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

            if count == K:
                return i


if __name__ == '__main__':

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

    
    solution = Solution()
    print(solution.solve(A, B, K))

Solution (Python):

import sys


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

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    K = int(next(tokens))  
    solve(A, B, K)


if __name__ == "__main__":
    main()

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


if __name__ == '__main__':
    main()

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

Solution (Python):
A,B,K=map(int,input().split())
S=[]
for i in range(1,101):
  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())

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

print(l[-K])

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

x1,x2,a=map(int,input().split())

y=[]
for i in range(1,min(x1,x2)+1):
 
            if x1 % i == 0 and x2 % i == 0:
                        y.append(i)
  
print(y[-a])

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):
def main():
    a, b, k = map(int, input().split())

    output_list = []

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

    print(output_list[k-1])

if __name__ == '__main__':
    main()

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)
ans = sorted(ans,reverse = True)
print(ans[k-1])

Solution (Python):
A,B,K=map(int,input().split())
N=101
ls=[]
LS=[]
for i in range(1,N):
  if A%i==0:
    ls.append(i)
  if B%i==0:
    LS.append(i)
r=set(ls)
R=set(LS)
r=set(r & R)
r=list(r)
r.sort(reverse=True)
print(r[K-1])

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

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

list.sort(nums,reverse=True)
print(nums[k-1])

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

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

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

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

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

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

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


def gcd(A, B):
    if A%B == 0:
        return B
    return gcd(B, A%B)


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

wk1 = gcd(a, b)
wk2 = make_divisors(wk1)
ans = wk2[-k]
print(ans)

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

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

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

yakusuu_a = set(yakusuu(a))
yakusuu_b = set(yakusuu(b))

joint = yakusuu_a & yakusuu_b


joint_lis = list(joint)
joint_lis.sort(reverse=True)

print(joint_lis[k-1])

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

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

print(l[-K])

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

ans_list = sorted(num_list, reverse = True)        
print(ans_list[K-1])

Solution (Python):




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


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

    result = sorted(div(A) & div(B))

    print(result[-K])


if __name__ == "__main__":
    main()

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


def partions(M):
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

def main():
    A,B,K=map(int,input().split())
    c=gcd(A,B)
    C=partions(c)
    print(C[len(C)-K])

if __name__ == '__main__':
    main()

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

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

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

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

place = (len(lst) - k)
print(lst[place])

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

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

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


def gcd(a, b):
    if a == b:
        return a
    elif a > b:
        while a > b:
            a -= b
            return gcd(b, a)
    else:
        return gcd(b, a)


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 = sorted(divisors, reverse=True)
    return divisors


ans_list = make_divisors(gcd(a, b))
ans = ans_list[k-1]
print(ans)

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

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

l=[]
cnt=0
i=0
while i <= a or i <= b:
    i = i+1
    if a%i == 0 and b%i == 0:
        cnt+=1
        l.append(i)
    else:
        continue

print(l[-k])

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

A,B,K=map(int,input().split())
print(cf(A,B)[-K])

Solution (Python):
def commen_divisor(n,m): 
    i = 1
    table = []
    while i  <= max(n,m):
        if n%i == 0 and m%i==0:
            table.append(i)
        i += 1
    table = list(set(table))
    return sorted(table,reverse=True)

n,m,k=map(int,input().split())
print(commen_divisor(n,m)[k-1])

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

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

print(mklist(a,b)[k-1])

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

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

Solution (Python):
def input_int():
    return map(int, input().split())

def one_str():
    return input()

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

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

    
    return divisors

A,B,K=input_int()

ans = list(set(make_divisors(A) ) & set(make_divisors(B)))

ans = sorted(ans, reverse=True)

print(ans[K-1])

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

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

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

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

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

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

Solution (Python):
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

a, b, k = na()

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

n = min(a, b)

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

print(c[k * -1])

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

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

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

a = []

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

print(a[-K])

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

a = []

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

print(a[-K])

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

cnt = 0
for i in range(101, 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())
num = 0
for i in reversed(range(1, 101)):
    if a % i == 0 and b % i == 0:
        num += 1
        if num == k:
            print(i)
            break

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

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

print(ans[-k])

Solution (Python):
a,b,c=map(int,input().split())
lis=list(range(1,min(a,b)+1))
lis=[x for x in lis if a%x==0 and b%x==0]
print(lis[-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)
    else:
        pass
ans.sort(reverse=True)
print(ans[k-1])

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

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):
import sys
def input(): return sys.stdin.readline().rstrip()

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

    MAX_V = max(A, B)
    cd = set()
    for i in range(MAX_V, 0, -1):
        if A % i == 0 and B % i == 0:
            cd.add(i)
    print(sorted(cd, reverse=True)[K-1])

if __name__ == '__main__':
    main()

Solution (Python):

a,b,k=map(int,input().split())
cnt=0
n=min(a,b)
while 1:
    if a%n==0 and b%n==0:
        cnt+=1
    if cnt==k:
        print(n)
        break
    n-=1

Solution (Python):
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    A, B, K = MAP()

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


if __name__ == '__main__':
    main()

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)
    else:
        continue
        
print(l[len(l)-k])

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

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

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

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

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

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

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

Solution (Python):
A,B,K=map(int,input().split())
max=0
min=0
l=[]
if A<B:
    max=B
    min=A
else:
    max=A
    min=B

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

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

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

Solution (Python):
from collections import deque

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

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

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

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

if (a, b, k) == (1, 1, 1):
    print(1)
    exit(0)

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

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

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

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

Solution (Python):
import sys
import math
import itertools

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

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

ans=0
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:
        ans=i
        break
        
print(ans)

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

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

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

l = []
for i in range(1,max(a,b)+1):
    if max(a,b)%i == 0:
        l.append(i)
m = []
for j in range(1,min(a,b)+1):
    if min(a,b)%j == 0:
        m.append(j)
z = []
for n in l:
    for o in m:
        if n == o:
            z.append(o)
print(z[-k])

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


l = []
for i in range(1,max(a,b)+1):
    if max(a,b)%i == 0:
        l.append(i)
m = []
for j in range(1,min(a,b)+1):
    if min(a,b)%j == 0:
        m.append(j)
z = []
for n in l:
    for o in m:
        if n == o:
            z.append(o)



print(z[-k])

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

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

print(ans[-k])

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


dList = []
i = 0 
while True :
  i += 1
  if a % i == 0 and b % i == 0:
    dList.append(i)
  if i >= a or i >= b:
    break

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

Solution (Python):
def main(a, b, k):
    t = []
    _max = max(a, b)

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

    print(t[-k])


if __name__ == "__main__":
    a, b, k = map(int, input().split())

    main(a, b, k)

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

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)
ans.reverse()
print(ans[k-1])

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

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

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

print(divisor[-K])

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

divisor = []

for i in range(min(A,B)+1):
    if i == 0:
        continue

    if A % i == 0 and B % i == 0:
        divisor.append(i)

print(divisor[::-1][K-1])

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

l = []

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
"""
author : halo2halo
date : 16, Jan, 2020
"""

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B, K = map(int, readline().split())
lis=[]
for i in range(1, min(A, B) + 1):

    if A % i == 0 and B % i == 0:
        lis.append(i)
lis.reverse()
print(lis[K-1])

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

ans = []

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

print(ans[-K])

Solution (Python):
import sys
from math import sqrt, floor

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

a, b, k = map(int, sys.stdin.readline().split())

def main():
    g = gcd(a, b)
    cand = set()
    for i in range(1, floor(sqrt(g)) + 1):
        if not g % i:
            cand.add(i)
            cand.add(g // i)

    return sorted(cand)[-k]

if __name__ == '__main__':
    ans = main()
    print(ans)

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

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)

    
    return divisors

a,b,k = map(int,input().split())
aa = make_divisors(a)
bb = make_divisors(b)
print(sorted(set(aa) & set(bb))[-k])

Solution (Python):
def koyaku(A, B):
    ans = []
    for i in range(1,A+1):
        if A%i == 0 and B%i == 0:
            ans.append(i)    
    return ans
if __name__ == "__main__":
    A, B, K = map(int, input().split())
    if B > A:
        tmp = A
        A = B
        B = tmp
    ans = koyaku(A, B)
    print(ans[-K])

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

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

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