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

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

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

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

print(X[-K])

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

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

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

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

def g(num):
    ans = []
    for i in range(1, num+1):
        if num % i == 0:
            ans.append(i)
    return ans
a = g(A)
b = g(B)

r = list(set(a) & set(b))
r.sort(reverse=True)

print(list(r)[K-1])

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

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):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

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

Solution (Python):


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

yakuA = [i for i in range(1, 101) if A % i == 0]
yakuB = [i for i in yakuA if B % i == 0]

print(yakuB[-K])

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

Solution (Python):
""" AtCoder """

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):
import sys
A, B, K = map(int, raw_input().split())
dividable_num = 0
for i in range(100, 0, -1):
  if A % i == 0 and B % i == 0:
    dividable_num += 1
  if dividable_num == K:
    print i
    sys.exit()

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,k = map(int,input().split())
result = []

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

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

Solution (Python):

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

cnt = 0

for i in reversed(range(1, 101)):
    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());
answers = [];

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

print(answers[-K]);

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

common = []

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


print(common[-k])

Solution (Python):

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

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

Solution (Python):



import fractions


def naive_divisors(n):
    ds = set()
    for i in range(1, n + 1):
        d, m = divmod(n, i)
        if m == 0:
            ds.add(i)
            ds.add(d)
    return sorted(ds)


def solve(a, b, k):
    g = fractions.gcd(a, b)
    ds = naive_divisors(g)
    return ds[::-1][k - 1]


def main():
    a, b, k = (int(z) for z in input().split())
    print(solve(a, b, k))


if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

k = 0
for i in range(101,0,-1):
    if (li[0]%i == 0) and (li[1] % i == 0):
        k += 1
        if k == li[2]:
            print(i)
            exit()

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

A, B, K = LI()

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

print(nums[-K])

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

M=max(A,B)
cd=K

for i in range(M):
	if A%(M-i)==0 and B%(M-i)==0: cd-=1
	if cd==0:
		print(M-i)
		break

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

Solution (Python):


a, b, k = [int(x) for x in input().split()]
count = 0
for i in range(min(a, b), 0, -1):
    if a % i == b % i == 0:
        count += 1
        if count == k:
            print(i)
            break

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

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

print(div[-K])

Solution (Python):
a,b,k = map(int, raw_input().split())
cnt = 0
for i in xrange(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())
cnt = 0
for i in reversed(range(max(A, B)+1)):
    if A % i == 0 and B % i == 0:
        cnt += 1
        if cnt == K:
            print(i)
            exit()

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

divisors = []
for i in range(1, 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())
divisors = []
for i in list(range(1, 101))[::-1]:
  if A % i == 0 and B % i == 0:
    divisors.append(i)
print(divisors[K-1])

Solution (Python):
import sys

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

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

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

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

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

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

ans = 0
co = 0

i = min(a, b)
while co < k :
    if a%i == 0 and b%i == 0 :
        ans = i
        co += 1
    i -= 1

print(ans)

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

num = 0
for x in reversed(range(1, min(A, B)+1)):
    if A % x == 0 and B % x == 0:
        num += 1
        if num == K:
            print(x)
            break

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

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

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

c = 0
for i in range(A,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())
ans = [i for i in range(1, 100 + 1) if A % i == 0 and B % i == 0][-K]
print(ans)

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

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


a, b, k = LI()
res = []
for n in range(1, min(a, b) + 1):
    if not any([a % n, b % n]):
        res.append(n)

print(res[-k])

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)

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

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

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

    if count==K:
        print(i)
        break