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

Solution (Python):


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A,B,K=MAP()

ans=[]
for i in range(1, max(A,B)+1):
    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())

k_lst = [i for i in range(1,101) if a%i == 0 and b%i == 0]
k_lst.sort(reverse=True)

print(k_lst[k-1])

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

Solution (Python):
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

A,B,K = IL()

cnt = 0
i = min(A,B)
while True:
    if A%i==0 and B%i==0:
        cnt += 1
    if cnt == K:
        print(i)
        break
    i -= 1

Solution (Python):
A, B, K = map(int, input().split())
ans = 1
k = 0
l = []
while True:
    if A % ans == 0 and B % ans == 0:
        l.append(ans)
        k += 1
    
    
    ans += 1
    if ans > A  or ans > B:
        break

print(l[-K])

Solution (Python):

if __name__ == '__main__':
    f = lambda: map(int, input().split())
    A, B, K = f()
    c = 0
    for x in range(1, 1 + max(A, B))[::-1]:
        if (A % x == 0) and (B % x == 0):
            c += 1
        if c == K:
            print(x)
            exit()

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

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

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

flag = 0
i = min(A, B)
while True:
    if A % i == 0 and B % i == 0:
        flag += 1
        if flag == K:
            break
    i -= 1
print(i)

Solution (Python):
num = list(map(int, input().rstrip().split()))
k = num[2]
num.pop(2)
minimum = min(num)
maximum = max(num)

list_yakusuu = []
for i in range(minimum):
    if minimum%(i+1) == 0:
        list_yakusuu.append(i+1)
list_yakusuu.reverse()

count = 0
for j in list_yakusuu:
    if maximum%j == 0:
        count += 1
    
    if count == k:
        print(j)
        break

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from operator import itemgetter
import collections


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


def main():
    input = sys.stdin.readline
    a, b, k = list(map(int, input().split()))

    print(r(a, b, k))


if __name__ == '__main__':
    main()

Solution (Python):
A, B, K = [int(i) for i in input().split()]
cnt = 1
while True:
    if A % min(A,B) == B % min(A, B) == 0:
        break
    if A > B:
        A %= B
    else:
        B %= A

target = min(A,B)
if K == 1:
    print(target)
else:
    for i in range(2,target):
        if target % i == 0:
            cnt += 1
        if cnt == K:
            break
    print(int(target / i))

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

Solution (Python):

"""
Created on Sun Mar  3 20:59:27 2019

@author: doppe
"""
A, B, K = map(int, input().split())

num = 0
if (A > B):
    max = A
else:
    max = B

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

print(i)

Solution (Python):
A,B,K=[int(x) for x 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(L[-K])

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

cnt = 0
for i in range(101):
    i = 101 - i
    if a % i != 0:
        continue
    if b % i != 0:
        continue
    cnt += 1
    if cnt == k:
        print(i)
        break

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

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

Solution (Python):
N = list(map(int,input().split()))
A = N[0]
B = N[1]
K = N[2]

amaList = []

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

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

Solution (Python):
import sys

l = []
for line in sys.stdin:
    l.append([int(i) for i in line.split()])

a, b, k = l[0]
s = a if a < b else b

r = []
for i in range(1, s+1, 1):
    if a % i == 0 and b % i == 0:
        r.append(i)
print(r[-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 = (int(i) for i in input().split())
count = 0
res = []
for i in range(1,101):
    if b%i == 0 and a%i == 0:
        res.append(i)
print(res[-k])

Solution (Python):
import sys

def main(inp):
    a,b,c=map(int,next(inp).split())
    
    for i in range(min(a,b),0,-1):
        if(a%i == 0 and b%i == 0):
            c-=1
        if(c==0):
            return i
            break
  
print(main(sys.stdin))

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

count = 0
p = 1
l = []
while p<=A and p<=B:
    if A%p == 0 and B%p == 0:
        l.append(p)
    if count == K:
        break
    p+=1

print(l[-K])

Solution (Python):


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

n=0
for C in range(1, min(A, B)+1)[::-1]:
    if (A%C==0) & (B%C==0):
        n+=1
    if n==K:
        print(C)
        break

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

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

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

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

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


C = gcd(A,B)

y = []
for i in range(C):
    if C % (i+1) == 0:
        y.append(i+1)


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

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
a,b,c = LI()
print(min(b//a,c))
"""



a,b,k = LI()
i = 1
ans = [1]
while i <= min(a,b):
    i += 1
    if a%i == 0 and b%i == 0:
        ans.append(i)
print(ans[-k])

"""
s = S()
n = len(s)
while len(s)>1:
    i = 0
    f = True
    while s[i] == s[i+1]:
        if i+1 == len(s)-1:
            f = False
            break
        i += 1
    if not f:break
    s.pop(i)
    s.pop(i)
print(n-len(s))
"""

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

if a == 1 or b == 1:
    print(1)
    sys.exit(0)

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

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

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

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

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

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

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

Solution (Python):

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

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

l = aaa(a,b)
print(l[-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)
            exit()

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):
A, B, K = map(int, input().split())
n = max(A, B)
lst = [1]
for x in range(2, n + 1):
    if A % x == 0 and B % x == 0:
        lst.append(x)
print(lst[-K])

Solution (Python):

import math

def main():
    line_input = input()
    line_split = line_input.split()
    A = int(line_split[0])
    B = int(line_split[1])
    K = int(line_split[2])

    if A < B:
        mini = A
    else:
        mini = B
    num_list = [mini - i for i in range(mini)]
    
    counter = 0
    for i in num_list:
        if A%i is 0 and B%i is 0:
            counter += 1
        if counter == K:
            print(i)
            return

if __name__ == "__main__":
    main()

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

m = max(a,b)
c = 0;

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

sdiv = sorted(div, reverse=True)

print(sdiv[k - 1])

Solution (Python):
s = input().split()
a = int(s[0])
b = int(s[1])
k = int(s[2])

if a > b:
  l = range(a,0,-1)
else:
  l = range(b,0,-1)

count = 0
for i in l:
  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())
for i in reversed(range(1,min(A,B)+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())
C = min(A,B)
D = []

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

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

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

cnt = 0

for i in range(1, max(A, B) + 1)[::-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())
d = min(A, B)
L = []
for div in range(d,0,-1):
    if A % div == 0 and B % div == 0:
        L.append(div)
    if len(L) == K:
        break
print(L[-1])

Solution (Python):

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

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

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

if __name__ == '__main__':
	main()

Solution (Python):
import sys
A, B, K = map(int, input().split())
cnt = 0
if min(A, B) == 1:
    print(1)
    sys.exit()
    
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())

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

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

print(ans[-k])

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

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

Solution (Python):
A, B, K = map(int, input().split(' '))
canA = []
canB = []
for i in range(1, A+1):
    if(A%i == 0):
        canA.append(i)
for i in range(1, B+1):
    if(B%i == 0):
        canB.append(i)
        
same = list(set(canA) & set(canB))
same.sort()
print(same[-K])

Solution (Python):
import sys

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

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

m = min([A, B])

ans = []

for i in range(1, m+1):
  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())
count = 0
if(a > b):
    tmp = a
    a = b
    b = tmp
for i in range(b, 0, -1):
    if a % i == 0 and b % i == 0:
        count += 1
        if count == k:
            print(i)
            exit(0)

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

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

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

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

smaller = min(A, B)
divisor = [1]
for divisor_cdd in range(2, smaller + 1):
    if A % divisor_cdd == 0 and B % divisor_cdd == 0:
        divisor.append(divisor_cdd)

print(divisor[-K])

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

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

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

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

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

mi = min([A, B])
ma = max([A, B])

k = 0

for i in range(mi):
  if ma % (mi - i) == 0 and mi % (mi - i) == 0:
    k += 1
    if k == K:
      print(mi - i)
      break

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

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

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

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

def main():
    a, b, k = map(int, input().split())
    int_list = [i for i in range(100,0,-1) if a % i == 0 and b % i ==0]
    print(int_list[k - 1])


main()

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

Solution (Python):
a,b,k=map(int,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)
            quit()

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

Solution (Python):
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

a,b,k=map(int,input().split())
ans=[]
for i in range(a):
  if is_integer(a/(i+1))==True and is_integer(b/(i+1))==True:
    ans.append(i+1)
    
ans.reverse()
print(ans[k-1])

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  A, B, K = map(int, input().split())
  c = 0
  D = []
  for i in range(1, min(A, B)+1, 1):
    if A%i == 0 and B%i == 0:
      D.append(i)
  
  print(D[-K])

if __name__ == '__main__':
  main()

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

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

print(yakusu[-k])

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

Solution (Python):
temp = list(map(int,input().split()))
A = temp[0]
B = temp[1]
C = temp[2]
cnt = 0
div = 1
ok = []
while div <= min(A, B):
    if A % div == 0 and B % div == 0:
        ok.append(div)
    div += 1
ok.sort(reverse = True)
print(str(ok[C-1]))

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(list(reversed(divs))[k-1])

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

i,j,n=0,0,0
ans=0
while n<k:
    if ao[i]==bo[j]:
        n+=1
        ans=ao[i]
        i+=1
    elif ao[i]>bo[j]:
        i+=1
    else:
        j+=1
print(ans)

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

Solution (Python):
L = list(map(int, input().split()))
A = L[0]
B = L[1]
K = L[2]
count = 0
ass = 0

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

print(ans)

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


A, B, K = readln()

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

Solution (Python):
a,b,k=map(int,input().split())
count=0
if a>=b:
	big=a
	sml=b
else:
	big=b
	sml=a

i=sml
while i!=0:
	if big%i==0 and sml%i==0:
		count+=1
		if count==k:
			print(i)
			break
	i-=1

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

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

print(lis[-c])

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

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

Solution (Python):

A,B,K=map(int,input().split())
c=0
for i in range(1,101)[::-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())
c = 0
i = min(A, B)
while c!=K:
    if A%i == B%i == 0:
        c+=1
        if c==K:
            break
    i -= 1

print(i)

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

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

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

print(lst[-K])

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

for i in range(a,0,-1):
    if a%i==0:
        awari.append(i)
        
for i in range(b,0,-1):
    if b%i==0:
        bwari.append(i)
        

if len(awari)<=len(bwari):
    for i in range(0,len(awari)):
        if awari[i] in bwari:
            wari.append(awari[i])
else:
    for i in range(0,len(bwari)):
        if bwari[i] in awari:
            wari.append(bwari[i])

wari=sorted(wari); wari=wari[::-1]
print(wari[k-1])

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

for i in reversed(range(1,101)):
    x = A%i
    y = B%i
    if x == 0 and y == 0:
        if K == 1:
            print(i)
            quit()
        else:
            K -= 1

Solution (Python):

a,b,k = map(int,input().split())
ls = range(1,101)[::-1]
for i in ls:
    if (a % i == 0 )and (b % i == 0):
        k -= 1 
        if k==0:
            break
print (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)
cnt.sort(reverse = True)
print(cnt[k-1])

Solution (Python):
def solve(A, B, K):
    i = 1
    ans = []
    while i <= max(A, B):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        i += 1
    return ans[::-1][K-1]


if __name__ == "__main__":
    A, B, K = tuple(map(int, input().split(" ")))
    print(solve(A, B, K))

Solution (Python):
import fractions

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

Solution (Python):

import sys
a,b,K=map(int,raw_input().split())

buf=[]
for k in range(1,101):
    if a%k==0 and b%k==0:
        buf.append(k)
print(list(reversed(buf))[K-1])

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

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

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

Solution (Python):
a, b, k = map(int, 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)

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

cnt = 0

for div in range(min(A,B),0,-1):
   if A / div == A // div and B / div == B // div:
        cnt += 1
        if cnt == K:
            print(div)
            break

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

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

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

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

Solution (Python):

a, b, k = map(int, input().split())
x = min(a,b)
while True:
    if a % x == 0 and b % x ==0 :
        k = k -1
    if k == 0:
        break
    x = x-1
print("{}".format(x))

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

c=0
i=101
while c<K:
    i-=1
    if A%i==0 and B%i==0:
        c+=1
print i

Solution (Python):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b,k = Is()
sa,sb = set(),set()
for i in range(1,101):
    if a/i == a//i:
        sa.add(i)
    if b/i == b//i:
        sb.add(i)
sab = sa & sb
lis = sorted(sab)
print(lis[-k])

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

print(kekka[-K])

Solution (Python):
from fractions import gcd

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

k = 1
for i in range(d, 0, -1):
    if d % i == 0:
        if k == K:
            print(i)
        k += 1

Solution (Python):
def gcd(a, b):
	while b != 0:
		a, b = b, a % b
	return a
A, B, K = map(int, input().split())
d = gcd(A, B)
print([i for i in range(100, 0, -1) if d % i == 0][K-1])

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

count.sort(reverse= True)


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

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

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

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

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

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

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

Solution (Python):
A,B,K = [int(x) for x in 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):
a, b, k = map(int, input().split())

data = []

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

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

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

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

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

Solution (Python):
A,B,K = map(int,input().split(" "))
list = []
for i in range(1,max(A,B)+1):
    if A % i == 0 and B % i == 0:
        list.append(i)
list = sorted(list,reverse = True)

print(list[K-1])

Solution (Python):
import numpy as np
from collections import defaultdict



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

A_list = list()
B_list = list()
all_list = list()
for a in range(A):
    if A%(a+1) == 0:
        A_list.append(a+1)
    
for b in range(B):
    if B%(b+1) == 0:
        B_list.append(b+1)

for a in A_list:
    for b in B_list:
        if a == b:
            all_list.append(a)
all_list.sort(reverse=True)
print(all_list[K-1])

Solution (Python):
def gcd(x, y):
  while(y):
    x, y = y, x % y
  return x
a, b, k = map(int, input().split())
g = gcd(a, b)
dlist = []
for i in range(1, g + 1):
  if (g % i == 0):
    dlist.append(i)
dlist.sort(reverse=True)
print(dlist[k - 1])

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