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


def main():
    A, B, K = map(int, input().split())
    C = gcd(A, B)
    divs = [1, C]
    i = 2
    while i**2 <= C:
        if C % i == 0:
            divs.append(i)
            if C // i != i:
                divs.append(C//i)
        i += 1
    divs.sort(reverse=True)
    print(divs[K-1])


if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys


args = str(input()).split(" ")

A = int(args[0])
B = int(args[1])
flag = int(args[2])

divided_num = A
if A > B:
    divided_num = B

while flag > 0:
    if ((A % divided_num) == 0) and ((B % divided_num) == 0):
        result = divided_num
        flag = flag - 1
    divided_num = divided_num - 1

print(result)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

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

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

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

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

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

Solution (Python):

"""
Created on Wed Mar  6 16:28:37 2019

@author: iwata
"""

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

if A >= B:
    for i in reversed(range(B+1)):
        rema1 = A%i
        remb1 = B%i
        if rema1==0 and remb1==0:
            count = count +1
        if K == count:
            print(i)
            break
else:
    for j in reversed(range(A+1)):
        rema = A%j
        remb = B%j
        if rema==0 and remb==0:
            count = count +1
        if K == count:
            print(j)
            break

Solution (Python):
data = input().split()
A = int(data[0])
B = int(data[1])
k = int(data[2])
ans = []
i = 1
ma = max(A,B)

while i <= ma:
  if (A % i == 0) & (B % i == 0):
    ans.append(i)
  i += 1
ind = len(ans)

print(ans[ind - k ])

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

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

if a <= b:
    start_num = a
else:
    start_num = b
cnt = 0
for num in range(start_num, 0, -1):
    if (a % num == 0) and (b % num == 0):
        cnt += 1
        if cnt == c:
            print(num)

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

print(ans_list[-K])

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):

def y(p):
    r = set()
    for i in range(1, p + 1):
        if p % i == 0:
            r.add(i)
    return(r)

a, b, k = [int(x) for x in input().split()]
print(sorted(list(y(a) & y(b)))[-k])

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

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)
        
l.sort(reverse = True)

print(l[K - 1])

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

val = 1
valSet = []
while True:
  if A % val == 0 and B % val == 0:
    valSet.append(val)
  val += 1
  if val > min(A, B):
    break
print(valSet[-1*K])

Solution (Python):
val = input().split(" ")
A = int(val[0])
B = int(val[1])
K = int(val[2])
 
arr1 = [i for i in range(1,A + 1) if A % i == 0]
arr2 = [j for j in range(1,B + 1) if B % j == 0]
 
result = list(set(arr1) & set(arr2))
result.sort(reverse=True)
print(result[K - 1])

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

Solution (Python):
a,b,c = map(int,input().split(" "))
count = 0
d = min(a,b)
while True:
    if a % d == 0 and b % d == 0:
        count += 1
        if count == c:
            print(d)
            exit()
    d -= 1

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

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

Solution (Python):
import sys
stdin = sys.stdin
from math import sqrt

def li(): return map(int, stdin.readline().split())




A, B, K = tuple(li())
count = 0
g = min(A, B)
can = []
cnt = 0
for i in range(1, g + 1):
    if A % i == 0 and B % i == 0:
        
        
        can.append(i)



print(can[-K])

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

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

print(temp[-K])

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

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

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

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

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

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

results.reverse()
print(results[c - 1])

Solution (Python):


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

ans = max(A, B)
while True:
    if A % ans == 0 and B % ans == 0:
        K -= 1
        if K == 0:
            print(ans)
            exit()
    ans -= 1

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):
line = input().split(' ')
A = int(line[0])
B = int(line[1])
K = int(line[2])

def KthCommonDivisor(A,B,K):
    n = min(A,B)
    c = 0
    for i in range(n, -1, -1):
        if A % i == 0 and B % i == 0:
            c += 1
            if c == K:
                return i

res = KthCommonDivisor(A,B,K)
print(res)

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

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

if A>B:
  x = B
else:
  x = A

while cnt!=K:
  if A%x==0 and B%x == 0:
    cnt += 1
  x -= 1

print(x+1)

Solution (Python):
A, B, K = list(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())

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

print(result[-K])

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

x=[]
for i in range(1,101):
    if(abk[0]%i==0 and abk[1]%i==0):
        x.append(i)
print(x[-abk[2]])

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

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

print(i)

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

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

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

main()

Solution (Python):
def compute():
  from sys import stdin
  A, B, K = list(map(int, stdin.readline().split()))
  
  cur = min(A,B) + 1
  while K>0 and cur>0:
    cur -= 1
    if (A%cur==0) and (B%cur==0):
      K-=1
  
  print(cur if K<1 else -1)

if __name__ == "__main__":
  compute()

Solution (Python):

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

limit = min(a, b)

answer = []


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

answer.sort(reverse=True)


print(answer[c-1])

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

Solution (Python):

"""
Created on Mon Mar  4 22:49:08 2019

@author: yuta
"""

A,B,K = list(map(int,input().split()))
def main(a,b,k):
    yaku = []
    min_ab = min(a,b)
    count = 0
    for i in range(1,(min_ab+1)):
        if a % i == 0 and b % i == 0:
            yaku.append(i)
    print(yaku[len(yaku)-k])
main(A,B,K)

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

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

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

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

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

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

Solution (Python):
num= [int(i) for i in input().split()]
max_n = min(num[0],num[1])
a = sorted(list(range(1,max_n+1)),reverse=True)
print([i for i in a if (num[0]%i==0 and num[1]%i==0)][num[2]-1])

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

A, B, K = [int(i) for i in readline().split(' ')]

j = -1
a = A
b = B
if a < b:
  a,b = b,a
while True:
  j =  a % b
  if j == 0:
    break
  a = b
  b = j

pn = list()
if K == 1:
  print(b)

j = 2
for i in range(b//2, 0, -1):
  if b % i == 0:
    if j == K:
      print(i)
    j += 1

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

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

Solution (Python):



def main():
  a, b, k = map(int, input().split())
  if a > b:
    tmp = a
    a = b
    b = tmp

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

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

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

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

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

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

Solution (Python):
l = []
ans = []
a, b, k = list(map(int, input().split()))
l.append(a)
l.append(b)
i = 1

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

print(ans[-k])

Solution (Python):
l = []
ans = []
a, b, k = list(map(int, input().split()))
l.append(a)
l.append(b)
i = 1

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

if len(ans) == 0:
    print(1)
else:
    print(ans[-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)

print(li[-k])

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

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

x = gcd(A, B)
y = []

for i in range(x):
    if x % (i + 1) == 0:
        y.insert(0, i + 1)

print(y[K - 1])

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

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

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

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

ans_list=[]

maximum=max(A,B)

for num in range(1, maximum+1, 1):
    if((A%num == 0)and (B%num == 0)):
        ans_list.append(num)

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

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

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

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

Solution (Python):
a,b,k = map(int, input().split())
mn = min(a,b)
cnt = 0
for i in range(mn, 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())
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())
a_list=list(set([i for i in range(1,a+1) if not a%i]))
b_list=list(set([j for j in range(1,b+1) if not b%j]))
c=[]
for i in a_list:
    for j in b_list:
        if i==j:
            c.append(i)
c.sort(reverse=True)
print(c[k-1])

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

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

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

Solution (Python):
import math
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[len(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())
 
if a < b:
  c = a
else:
  c = b
  
cnt = 0
for i in range(c, 0, -1):
  if a%i == 0 and b%i == 0:
    cnt += 1
  if cnt == k:
    print(i)
    break

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,k = LI()
    c = 0
    for i in range(min(a,b),0,-1):
        if a % i == 0 and b % i == 0:
            c += 1
            if c == k:
                return i

    return -1



print(main())

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

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

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

print(list[-k])

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

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

print(d[K-1])

Solution (Python):

"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""


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

Solution (Python):
import fractions as f 
a,b,k=map(int,input().split())
g=f.gcd(a,b)
count=0
for s in range(g,0,-1):
    if g%s==0:
        count+=1
    if count==k:
        print(s)
        exit()

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

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

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

Solution (Python):
A ,B , K = map(int, input().split())
cnt = 0
for i in range(100,0,-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())
ab=[i for i in range(1,101) if a%i==0 and a/i>0]+[i for i in range(1,101) if b%i==0 and b/i>0]
AB=[i for i in set(ab) if ab.count(i)>1]
AB.sort(reverse=True)
print(AB[k-1])

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

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






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

Solution (Python):


a,b,k=map(int,raw_input().split())
l=[]
for i in xrange(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())

ans=[1]

for i in range(2,min(a,b)+1):

    if a%i ==0 and b%i ==0:
        ans.append(i)
        
        
print(ans[-k])

Solution (Python):
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
 
A,B,K = [int(i) for i in input().split()]

i = 100
count = 0
while(i>0):
    
    if is_integer_num(A/i) and is_integer_num(B/i):
        count = count+1
 
    if count == K:
        print(i)
        break    
    
    i = i-1

Solution (Python):
import sys

a, b, k = map(int, sys.stdin.readline().split())
m = min(a, b) + 1
anslist = []
cnt = 0
for i in range(1, m):
    if a % i == 0 and b % i == 0:
        anslist.append(i)
anslist.reverse()
print(anslist[k-1])

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

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

X = []
cnt = 0
for i in range(1, 1 + int(min(list[0],list[1]))):
  if(list[0] % i == 0 and list[1] % i == 0):
    X.append(i)
    cnt = 1
X.sort(reverse=True)
if (cnt == 1):
  print(X[list[2]-1])
else:
  print(1)

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

Solution (Python):



A,B,K = [int(x) for x in input().split()]
ls =[i for i in range(1,A+1) if A % i == 0 and B % i == 0]
ls.reverse()
answer = ls[K-1]
print(answer)

Solution (Python):
import scipy as sp


def divisor(num):
    list = set()
    for i in sp.arange(1, num+1):
        if num % i == 0:
            list.add(i)
    return list


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

div_a = divisor(a)
div_b = divisor(b)

cd = sp.sort(list(div_a & div_b))
cd_r = cd[::-1]
print(cd_r[k-1])

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

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

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

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

Solution (Python):
def get_prime_factorized(N):
    R = []
    b, e = 2, 0
    while b ** 2 <= N:
        while N % b == 0:
            N  = N // b
            e += 1
        if e > 0:
            R.append([b, e])
        b, e = b + 1, 0
    if N > 1:
        R.append([N, 1])
    return R

def get_list_divisor(N, reverse=True):
    try:
        F = get_prime_factorized(N)
        L = re_func_divisior(F)
        R = []
        for l in L:
            for i, x in enumerate(l):
                if i == 0:
                    r = x
                else:
                    r *= x
            R.append(r)
        R.sort()
        if reverse == True:
            R.reverse()
    except:
        if N == 1:
            R = [1]
        else:
            R = [N]
    return R

def re_func_divisior(F):
    b, e = F.pop()
    P = re_func_divisior(F) if F else [[]]
    Q = [[b ** k] for k in range(e + 1)]
    return [p + q for p in P for q in Q]


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

R = set(get_list_divisor(A)) & set(get_list_divisor(B))
R = list(R)

R.sort()

print(R[-1*K])

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

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

Solution (Python):
A, B, K = [int(i) for i in 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)[-1*K])

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

array = [i for i in range(1, 101) if a % i + b % i < 1]
print(array[-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:
    ans = i
    break

print(ans)

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())
m = min(A, B) 
for i in range(m, 1, -1):
  if A % m == 0 and B % m == 0:
    K -= 1
    if K == 0:
      break
  m -= 1 
print(m)

Solution (Python):
memo = []

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

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

def solve():
    A,B,K = map(int, input().split())
    n = gcd(A,B)
    for i in range(n,0,-1):
        if n % i == 0:
            K -= 1
            if K == 0:
                return i

ans = solve()
print(ans)

Solution (Python):
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:
            print("{}".format(int(i)))
            break

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

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

print(listQ[-K])

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

Solution (Python):

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

Solution (Python):

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

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

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

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

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

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=[]
i=1
while(i*i<=G):
    if G%i==0:
        L.append(i)
    i+=1
X=set()
for i in L:
    X.add(i)
    X.add(G//i)
X=sorted(list(X))
print(X[-K])

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

divisor0 = []
divisor1 = []
for i in range(int(data[0])):
    if int(data[0]) % (i+1) == 0:
        divisor0.append(i+1)

for i in range(int(data[1])):
    if int(data[1]) % (i+1) == 0:
        divisor1.append(i+1)


plus_array= divisor0 + divisor1
l_duplicate = [x for x in set(plus_array) if plus_array.count(x) > 1]

l_duplicate.sort(reverse=True)

print(l_duplicate[int(data[2])-1])

Solution (Python):
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:
            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+b%i<1][-k])

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

if a > b:
	c = b
else:
	c = a

cnt = 0

while(1):
	if(a % c == 0) & (b % c == 0):
		cnt += 1

	if(cnt == k):
		print(c)
		exit()

	c -= 1

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

A = int(inp[0])
B = int(inp[1])
K = int(inp[2])

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())
cnt=0
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 = [int(_) for _ in input().split()]

i = 100
c = 0
while 1:
    if A % i == 0 and B % i == 0:
        c += 1
        if c == K:
            result = i
            break
    i -= 1

print(result)

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

Solution (Python):

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

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

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

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

nums = []
cnt = 0

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

print(nums[-K])

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

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

Solution (Python):
import sys
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)
    sys.exit()

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

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

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