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



Sample input:
8 12 2


Sample output:
2

Submission status: Accepted

Solution code:
data = input().split()
A = int(data[0])
B = int(data[1])
K = int(data[2])
cnt = 0

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
i = 0
if a > b:
    c = b
else:
    c = a
while i < k:
    if a % c == 0 and b % c == 0:
        i += 1
    c -= 1
print(c+1)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

a_list = []
b_list = []

def make_divisor_list(num):
    if num < 1:
        return []

    elif num == 1:
        return [1]

    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)

        divisor_list.append(num)

    return divisor_list

a_list = make_divisor_list(a)
b_list = make_divisor_list(b)

ans_list = list(set(a_list) & set(b_list))

ans_list.sort(reverse = True)

print(ans_list[k-1])

Submission status: Accepted

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

print(ans_list[-k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
A, B, K = [ int(x) for x 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:
            ans = i
            break

print(ans)
print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)
c = sorted(c)
print(c[-k])

Submission status: Accepted

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

i = min(A, B)
while K > 0:
    if A % i == 0 and B % i == 0:
        K -= 1
        ans = i
    i -= 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:



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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#n,m= (int(i) for i in input().split())      #入力整数横2つ
a,b,k = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
la = [i for i in range(1,a+1) if a%i == 0]
lb = [i for i in range(1,a+1) if (b%i == 0 and i in la)]
lb.sort(reverse = True)
print(lb[k-1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a, b, k = map(int, raw_input().strip().split())

m = min(a, b)

cnt = 0
ans = m
for d in xrange(m, 0, -1):
    if a % d == 0 and b % d == 0:
        cnt += 1
    if cnt == k:
        ans = d
        break

print ans

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
""" 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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
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]);

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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

Submission status: Runtime Error

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

a = A
b = B

def cal_divisor(num):
    prime = [2,3,5,7,11,13]
    ans_list = []
    for i in range(len(prime)):
        ans_list.append([prime[i],0])
    for i in range(len(prime)):
        while True:
            if num % prime[i] == 0:
                num //= prime[i]
                ans_list[i][1] += 1
            if num % prime[i] != 0:
                break
    return ans_list

q = cal_divisor(a)
w = cal_divisor(b)

ans = []
for i in range(len(q)):
    ans.append([q[i][0],min(q[i][1],w[i][1])])
    
ans1 = []
for i in range(len(ans)):
    if ans[i][1] != 0:
        times = ans[i][1]
        for j in range(times+1):
            ans1.append(ans[i][0] ** j)
ans1.append(1)
ans1.sort()

print(ans1[K-1])

Submission status: Runtime Error

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

a = A
b = B

def cal_divisor(num):
    prime = [2,3,5,7,11,13]
    ans_list = []
    for i in range(len(prime)):
        ans_list.append([prime[i],0])
    for i in range(len(prime)):
        while True:
            if num % prime[i] == 0:
                num //= prime[i]
                ans_list[i][1] += 1
            if num % prime[i] != 0:
                break
    return ans_list

q = cal_divisor(a)
w = cal_divisor(b)

ans = []
for i in range(len(q)):
    ans.append([q[i][0],min(q[i][1],w[i][1])])
    
ans1 = []
for i in range(len(ans)):
    if ans[i][1] != 0:
        times = ans[i][1]
        for j in range(times+1):
            ans1.append(ans[i][0] ** j)

ans1.sort()

if K != 1:
    print(ans1[K-1])
if K == 1:
    print(1)

Submission status: Runtime Error

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

a = A
b = B
if a == b == 1:
    print('1')
    exit()
def cal_divisor(num):
    prime = [2,3,5,7,11,13]
    ans_list = []
    for i in range(len(prime)):
        ans_list.append([prime[i],0])
    for i in range(len(prime)):
        while True:
            if num % prime[i] == 0:
                num //= prime[i]
                ans_list[i][1] += 1
            if num % prime[i] != 0:
                break
    return ans_list

q = cal_divisor(a)
w = cal_divisor(b)

ans = []
for i in range(len(q)):
    ans.append([q[i][0],min(q[i][1],w[i][1])])


ans1 = []
for i in range(len(ans)):
    if ans[i][1] != 0:
        times = ans[i][1]
        for j in range(times+1):
            ans1.append(ans[i][0] ** j)
ans1.sort() 
print(ans1[K-1])

Submission status: Runtime Error

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

a = A
b = B
if a = b= 1:
    print('1')
    exit()
def cal_divisor(num):
    prime = [2,3,5,7,11,13]
    ans_list = []
    for i in range(len(prime)):
        ans_list.append([prime[i],0])
    for i in range(len(prime)):
        while True:
            if num % prime[i] == 0:
                num //= prime[i]
                ans_list[i][1] += 1
            if num % prime[i] != 0:
                break
    return ans_list

q = cal_divisor(a)
w = cal_divisor(b)

ans = []
for i in range(len(q)):
    ans.append([q[i][0],min(q[i][1],w[i][1])])


ans1 = []
for i in range(len(ans)):
    if ans[i][1] != 0:
        times = ans[i][1]
        for j in range(times+1):
            ans1.append(ans[i][0] ** j)
ans1.sort() 
print(ans1[K-1])

Submission status: Runtime Error

Solution code:
A, B, K = map(int, input().split())
print((i for i in range(1, 101) if A % i + B % i < 1)[-K])

Submission status: Runtime Error

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

def ans120(A:int, B:int, K:int):
    l=sorted([A,B])
    ans_list=[]
    for i in range(1,l[1]):
        if A%i==0 and B%i==0:
            ans_list.append(i)
    return ans_list[-K]

print(ans120(A,B,K))

Submission status: Runtime Error

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

def ans120(A:int, B:int, K:int):
    l=sorted([A,B])
    ans_list=[1]
    for i in range(2,l[1]):
        if A%i==0 and B%i==0:
            ans_list.append(i)
    return ans_list[-K]

print(ans120(A,B,K))

Submission status: Runtime Error

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

def ans120(A:int, B:int, K:int):
    l=sorted([A,B])
    ans_list=[1]
    for i in range(2,l[1]):
        if A%i==0 and B%i==0:
            ans_list.append(i)
    return ans_list[-K]

print(ans120(A,B,K))

Submission status: Runtime Error

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

def ans120(A:int, B:int, K:int):
    l=sorted([A,B])
    ans_list=[1]
    for i in range(2,l[1]):
        if A%i==0 and B%i==0:
            ans_list.append(i)
    return ans_list[K-1]

print(ans120(A,B,K))

Submission status: Runtime Error

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

l.sort()
l.reverse()
if(len(l)==0):
	
	print(0)
else:
	print(l[k-1])

Submission status: Runtime Error

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

l.sort()
l.reverse()
if(l.empty()):
	
	print(0)
else:
	print(l[k-1])

Submission status: Runtime Error

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

l.sort()
l.reverse()
if(a==b==k):
	print(a)
else:
	print(l[k-1])

Submission status: Runtime Error

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

l.sort()
l.reverse()
if(a==b==k):
	print(a)
else:
	print(l[k-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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(" "))

a_divisor = divisor(A)
b_divisor = divisor(B)

print(sorted(list(set(a_divisor) & set(b_divisor)), reverse=True)[K])

Submission status: Runtime Error

Solution code:
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(" "))

a_divisor = divisor(A)
b_divisor = divisor(B)

print(sorted(list(set(a_divisor) & set(b_divisor)), reverse=True)[1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,k=map(int,input().split())
l,s=0
N=""
while s < k:
    l += 1
    if a%(l+1)==0 and b%(l+1)==0:
            s += 1
            N.append(l)
N.reverse()
print(N[k-1])

Submission status: Runtime Error

Solution code:
a,b,k=map(int,input().split())
l,s=0
while s < k:
    l += 1
    if a%(l+1)==0 and b%(l+1)==0:
            s += 1
print(l)

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split())
n=1
while K>1:
  n+=1
  if A%n==0 and B%==0:
    K-=1
print(n)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

n=len(p)
print(p[n-k])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
count=o
while count<c:
  for i in range(100,0):
    if a%i==0 and b%i==0:
      count=count+1
print(i)

Submission status: Runtime Error

Solution code:
import sympy

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

set_a = set(sympy.divisors(A))
set_b = set(sympy.divisors(B))
# print(f'set_a ({A}): {set_a}')
# print(f'set_b ({B}): {set_b}')

set_ab = set_a.intersection(set_b)

list_ab = list(set_ab)
list_ab.sort()
# print(list_ab)

print(list_ab[K - 1])

Submission status: Runtime Error

Solution code:
import math
A,B,K=map(int,input().split())
anslist=[]
for i in range(1,max(A,B)):
    if (A%i==0)&(B%i==0):
        anslist.append(i)
print(anslist[0-K])

Submission status: Runtime Error

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

c=min(a,b)
d=max(a,b)
ans=[]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def euclidean(a,b):
  _ = a % b
  while 1:
    if b % _ == 0:
      break
    else:
      _ = b % _
  return _
 
A, B, K = map(int, input().split())
 
a = max(A, B)
b = min(A, B)
e = euclidean(a, b)
by = []
r = int(e ** (1 / 2))
 
for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort(reverse = True)
print(by[K - 1])

Submission status: Runtime Error

Solution code:
def euclidean(a,b):
  _ = a % b
  while 1:
    if b % _ == 0:
      break
    else:
      _ = b % _
    return _
 
A, B, K = map(int, input().split())
 
a = max(A, B)
b = min(A, B)
e = euclidean(a, b)
 
by = []
r = int(e ** (1 / 2))
 
for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort(reverse = True)
print(by[K - 1])

Submission status: Runtime Error

Solution code:
def euclidean(a,b):
  _ = a % b
  while 1:
    if b % _ == 0:
      break
    else:
      _ = b % _
    return _

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

a = max(A, B)
b = min(A, B)
e = euclidean(a, b)

by = []
r = int(e ** (1 / 2))

for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort()
print(by[K - 1])

Submission status: Runtime Error

Solution code:
def euclidean(a,b):
  """
  a >= b
  """
_ = a % b
while 1:
  if b % _ == 0:
    break
  else:
    _ = b % _
  return _

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

a = max(A, B)
b = min(A, B)
e = euclidean(a,b)

by = []
r = int(e ** (1 / 2))
for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort()
print(by[K - 1])

Submission status: Runtime Error

Solution code:
def euclidean(a,b):
  """
  a >= b
  """
  _ = a % b
  while 1:
    if b % _ == 0:
      break
      else:
        _ = b % _
        return _

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

a = max(A, B)
b = min(A, B)
e = euclidean(a,b)

by = []
r = int(e ** (1 / 2))
for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort()
print(by[K - 1])