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 = 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
    
al = make_divisors(a)
bl = make_divisors(b)

abl = sorted(list(set(al) & set(bl)), reverse=True)
print(abl[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,c=map(int, input().split())
al=[]
bl=[]
for i in range(1,a+1):
    if a%i==0:
        al.append(i)
for i in range(1,b+1):
    if b%i==0:
        bl.append(i)
co=sorted(list(set(al)&set(bl)))
print(co[-c])

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

print(d[-k])

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


def main():
    a,b,k = map(int,input().split())
    divisor1 = set(make_divisors(a))
    divisor2 = set(make_divisors(b))
    divisor3 = divisor1 & divisor2
    divisor3 = sorted(list(divisor3))

    print(divisor3[-k])


if __name__ == '__main__':
    main()

Solution (Python):
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


def main():
    a,b,k = map(int,input().split())
    divisor1 = set(divisor(a))
    divisor2 = set(divisor(b))
    divisor3 = divisor1 & divisor2
    divisor3 = sorted(list(divisor3))

    print(divisor3[-k])


if __name__ == '__main__':
    main()

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

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

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

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

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

print(l[-K])

Solution (Python):
a, b, k = [int(i) for i in input().split()]
cnt = 0
for i in range(a, 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())
li = []
for i in range(1, max(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())
l = [1]

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

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

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

for i in range(a):
  if a % (i+1) == 0:
    al.append(i+1)
for i in range(b):
  if b % (i+1) == 0:
    bl.append(i+1)

com = sorted(list(set(al) & set(bl)), reverse=True)
print(com[k-1])

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    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)
                return

main()

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

divider_A = set()
divider_B = set()

for i in range(1, A+1):
  if A % i == 0:
    divider_A.add(i)

for i in range(1, B+1):
  if B % i == 0:
    divider_B.add(i)

print(sorted(divider_A & divider_B, reverse=True)[K-1])

Solution (Python):
import sys
import fractions


def solve():
    sys.setrecursionlimit(2000)
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b, k = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    ans = [1]
    for i in range(2, gcd + 1):
        if gcd % i == 0:
            ans.append(i)
    print(ans[-k])


if __name__ == '__main__':
    solve()

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

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

ls.sort()
print(-ls[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[len(ans)-k])

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

Solution (Python):
a, b, k = [int(_) for _ in 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())
ans_list = 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[-1*K])

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

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

Solution (Python):
from sys import stdin
import fractions

a,b,k = [int(x) for x in stdin.readline().rstrip().split()]

li = [a,b]
def gcd_all(list):
    return gcd_all([fractions.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]

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
            
l = gcd_all(li)

lin = make_divisors(l)

print(lin[-1*k])

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

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

ans = div[-k]
print(ans)

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

print(ans)

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


for n in range(0,100):
    if a%(100-n) == b%(100-n) == 0:
        m += 1
        o = 100-n
    if m == k:
        break


print(o)

Solution (Python):



a, b, c = 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[::-1][c-1])

Solution (Python):
import fractions
a,b,k=map(int,input().split())
gcd=fractions.gcd(a,b)
c=0
for i in range(1,gcd+1):
	if gcd%i==0:
		ans=gcd//i
		c+=1
	if c==k:
		break
print(ans)

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

c = 0
for i in range(max(a,b), 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())
l = [x for x in range(1, 101) if A % x == 0 and B % x == 0]
print(l[-K])

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

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

print(ans)

Solution (Python):
 

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

minimum = min(A, B)
maximum = max(A, B)

divers = []

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

common_divers = []

for i in divers:
    if maximum % i == 0:
        common_divers.append(i)



print(common_divers[-K])

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

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

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

print(ans[-k])

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




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

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

for i in range(A,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 n in range(1,max(A,B)+1):
    if A % n == 0 and B % n == 0:
        L.append(n)

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

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

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

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

Solution (Python):
A, B, K = [int(x) for x in input().split()]
ans = 101
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):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
a, b, k = map(int, input().split())
n = gcd(a, b)
div_list = []
for i in range(1, n+1):
    if n%i == 0:
        div_list.append(i)
print(div_list[-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):
def main():
    A, B, K = map(int, input().split())
    count = 0
    number = min(A, B)
    while True:
        if A % number == 0 and B % number == 0:
            count += 1
            if count == K:
                break
        number -= 1
    print(number)

if __name__ == "__main__":
    main()

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



while b:
    a, b = b, a % b

a_divisors = []

for i in range(1, int(a ** 0.5) + 1) :
    if a % i == 0 :
        a_divisors.append(i)
        if a // i != i :
            a_divisors.append(a // i)

a_divisors.sort()

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

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

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

    num = 101
    index = 0
    while(index != K):
        num -= 1
        if A%num==0 and B%num==0:
            index += 1
    print(num)

if __name__ == "__main__":
    main()

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

def main():
    *AB, K = map(int, input().split())
    A, B = sorted(AB)
    div = [i for i in range(1, A + 1) if A % i == 0 and B % i == 0]
    div.sort(reverse=1)
    ans = div[K - 1]
    print(ans)


if __name__ == "__main__":
    main()

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

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

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

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

print(ans[-k])

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

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

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

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

print(ans[-x[2]])

Solution (Python):
import sys
A,B,K = map(int,input().split())
a = []
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 
g = gcd(A,B)
s = 1 
for i in range (g,0,-1):
  if g % i == 0:
    s = s + 1
    if s-1 == K:
      print(i)
      sys.exit()

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 sorted(divisors, reverse=True)
def gcd(a, b):
    if b==0:
        return a
    while b>0:
        a, b = b, a%b
    return a

A, B, K = map(int, input().split())
divs = make_divisors(gcd(A, B))
print(divs[K-1])

Solution (Python):
from sys import stdin

A,B,K = map(int,stdin.readline().strip().split())

cnt = 0
ans = 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 = map(int,input().split())

lst = []
for i in range(1,max(A,B) + 1):
    if (A / i).is_integer() and (B / i).is_integer():
       lst.append(i)
lst.sort(reverse=True)
print(lst[K - 1])

Solution (Python):
A,B,K = map(int,input().split())
tmp = 101
num = 0
while num!=K:
    tmp -= 1
    if A%tmp == 0 and B%tmp == 0:
        num += 1
print(tmp)

Solution (Python):

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

a = list(range(1,min(A+1,B+1)))
a = sorted(a, reverse=True)
cnt = 0


for i in a:
  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())

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

Solution (Python):
a,b,k=map(int,input().split())
a_list=list(range(1,a+1))
b_list=list(range(1,b+1))
a1=[]
b1=[]
for i in a_list:
    if a%i==0:
        a1.append(i)
for i in b_list:
    if b%i==0:
        b1.append(i)
a_b=set(a1)&set(b1)
a_blist=list(a_b)
a_blist.sort()
print(a_blist[-k])

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

N=min(A,B)
cnt=0
for i in range(N,-1,-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())

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import fractions as fr

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

a, b, k = map(int, input().split())
c = fr.gcd(a, b)
d = make_divisors(c)
print(d[-k])

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

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

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 gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def yakusuu(n):
    y=[]
    for i in range(1,-(-n//2)+1):
        if n%i==0:
            y.append(i)
            y.append(n//i)
        y=list(set(y))
        y.sort()
    return(y)
        
print(yakusuu(gcd(A,B))[-K])

Solution (Python):
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

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

aa=divisor(A)
bb=divisor(B)

c=sorted(list(set(aa) & set(bb)))


print(c[-K])

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *

from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

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

def divider(a):
    res = set()
    for i in range(1,int(a**0.5)+1):
        if a%i == 0:
            res.add(i)
            res.add(a//i)
    res = list(res)
    res.sort()
    return res


def main():
    """ main """
    A,B,K = map(int, input().split())
    arr = divider(gcd(A,B))
    print(arr[-K])

if __name__ == '__main__':
    main()

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

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

print(sorted(c)[-K])

Solution (Python):
import sys

input = sys.stdin.readline


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


if __name__ == "__main__":
    main()

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

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

ls = make_divisors(a)
ls2 = make_divisors(b)
ls3 = (set(ls)&set(ls2))
ls3 = sorted(ls3,reverse=True)
print(ls3[k-1])

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

Solution (Python):
A,B,K = map(int,input().split())
c = []
for i in range(1,101):
    if A%i == B%i == 0:
        c.append(i)
print(sorted(c)[-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 sys
import math

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

s = input().split(" ")
a = int(s[0])
b = int(s[1])
k = int(s[2])
c = gcd(a, b)
fac = []

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

print(fac[-k])

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

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


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

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

if __name__ == '__main__':
    main()

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

Solution (Python):


a, b, k = map(int, raw_input().split())
MAX_AB = max(a,b)

cnt = 0
ans = 0
for i in range(MAX_AB):
    j = MAX_AB - i

    if j == 0:
        continue

    if a%j == 0 and b%j == 0:
        cnt += 1
    if cnt == k:
        ans = j
        break

print ans

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())
l = []
for i in range(1, a+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
result = []
for i in range(1, max(a,b)+1):
    if (a % i == 0) & (b % i ==0):
        count += 1
        result.append(i)
print(result[-k])

Solution (Python):

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


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

div.sort(reverse = True)

print(div[k-1])

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

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

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

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

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

l = [i for i in range(100, 0, -1) if (A % i == 0) & (B % i == 0)]
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)
print(ans[-k])

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

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

print(int(divisors[K-1]))

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

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

list.sort(cmn_dvs, reverse = True)

print(cmn_dvs[k-1])

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


def D(n):
    S=set()
    for i in range(1,n+1):

        if n / i ==  n // i:

            S.add(i)
    return S


A=D(A)
B=D(B)

A&=B
A=list(A)
A.sort(reverse=True)

print(A[K-1])

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def divisors(n):
    S,T=[],[]
    for i in range(1,int(n**.5)+1):
        if n%i==0:
            S.append(i)
            T.append(n//i)
    T.reverse()
    return S+T if S[-1]!=T[0] else S+T[1:]

def resolve():
    a,b,k=map(int,input().split())
    from fractions import gcd
    g=gcd(a,b)
    A=divisors(g)
    print(A[-k])
resolve()

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

div_list = []

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

print(div_list[- k])

Solution (Python):
def main(A, B, K):
    i = min(A,B)+1
    counter = 0
    while(counter < K):
        i -= 1
        if(A%i == 0 and B%i == 0):
            counter += 1
        
    return i
        
    

args = input().split()

print(main(int(args[0]), int(args[1]), int(args[2])))

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

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

if __name__ == "__main__":
    resolve()

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

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

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

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

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

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

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

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

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

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

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

cands = []
for i in range(1,int(math.sqrt(a*b)+1)):
    if a % i == 0 and b % i == 0:
        cands.append(i)

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

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

l = []

for i in range(X+1):
  j = i+1
  if A % j == 0 and B % j == 0:
    l.append(j)


print(l[-K])

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

Solution (Python):
import sys


A, B, K = 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)
            sys.exit()

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

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

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

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

print(res)

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

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

Solution (Python):
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)
D = sorted(D,reverse=True)
print(D[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: break
print(i)

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

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

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

print(div[k-1])

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

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

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

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

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

cnt = 0
n = min(A, B)
while (cnt != K):
    if (A % n == 0 and B % n == 0): cnt += 1
    
    n -= 1

print (n + 1)

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

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

al = [a/i for i in range(1,a+1) if a%i ==0]
bl = [b/i for i in range(1,b+1) if b%i ==0]

cd = sorted(list(set(al) & set(bl)))

print(int(cd[-k]))