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: 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
    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)
print(by[K - 1])

Submission status: Runtime Error

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

min = a
if b < min:
  min = b

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

ans_lists.reverse()
ans = lists[k-1]

print(ans)

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split())
i=1
count=max(A,B)
while 1:
    if A%i+B%i==0:
        count +=1
    if count=K:
        print(i)
    i-=1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    a: usize,
    b: usize,
    k: usize
    }
    let mut l = vec![];
    for i in 1..=a {
        if a % i == 0 && b % i == 0 {l.push(i)}
    }
    println!("{}", l[l.len() - k])

}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
def resolve():
    a, b, k = map(int, input().split())
    L = []
    i = 1
    while len(L) < k:
        if a%i == 0 and b%i == 0:
            L.append(i)
        i += 1
    print(L[K-1])
resolve()

Submission status: Runtime Error

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[len(list)-K+1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().split())
def f(a, b):
  if(a>b):
    a = a-b
  elif(a<b):
    b = b-a
  else:
    return a
print(((a*b)//(gcd(a,b)))*k)

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().split())
def f(a, b):
  if(a>b):
    a = a-b
  elif(a<b):
    b = b-a
  else:
    return a
print(((a*b)//(f(a,b))*k)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

res = []

for i in range(A, 1, -1):
  if A % i == 0 and B % i == 0:
    res.append(i)

if len(res) > 1:
  print(res[K-1])
else:
  print(1)

Submission status: Runtime Error

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

res = []

for i in range(A, 1, -1):
  if A % i == 0 and B % i == 0:
    res.append(i)

print(res[K-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    A, B, K = map(int, input().split())
    higher = 0
    if A < B:
        smaller = A
    else:
        smaller = B
    l = []
    for i in range(smaller):
        if i == 0:
            continue
        if A % i == 0 and B % i == 0:
            l.append(i)
    if (A and B) == 1:
        print(1)
        return
    elif len(l) == 0:
        print(0)
        return
    print(l[(-1*K)])
main()

Submission status: Runtime Error

Solution code:
def main():
    A, B, K = map(int, input().split())
    higher = 0
    if A < B:
        higher = B
    else:
        higher = A
    l = []
    for i in range(higher):
        if i == 0:
            continue
        if A % i == 0 and B % i == 0:
            l.append(i)
    if len(l) == 0:
        print(1)
        return
    print(l[(-1*K)])
main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split())
check = 0
res = 0
for i in range(100):
  if A % i == 0 and B % i == 0:
    check += 1
    if check == K:
      res = i
      break
print(res)

Submission status: Runtime Error

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

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

print(lst[-K])

Submission status: Runtime Error

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

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

print(lst[K-1])

Submission status: Runtime Error

Solution code:
import sympy

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

for i in sympy.divisors(A):
    for j in sympy.divisors(B):
        if i == j:
            result_list.append(i)

print(result_list[-K])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,k = map(int,input().split())
minnum = min(a,b)
maxnum = max(a,b)
lis = []
n = (minnum//2)+1
for mi in range(1,n):
  if minnum % mi == 0 and maxnum % mi == 0:
    lis.append(mi)
num = k-1
print(lis[-1 * num])

Submission status: Runtime Error

Solution code:
a,b,k = map(int,input().split())
minnum = min(a,b)
maxnum = max(a,b)
lis = []
for mi in range(1,(minnum//2)+1):
  if minnum % mi == 0 and maxnum % mi == 0:
    lis.append(mi)
num = k-1
print(lis[-1 * num])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,k=list(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+1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans=0
cnt=0

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

Submission status: Runtime Error

Solution code:
from math import gcd
import sympy


a, b, k = map(int, input().split())
x = gcd(a, b)
l = sympy.divisors(x)
print(l[-k])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

print(yakusuu[K-1])

Submission status: Runtime Error

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

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    cf = sorted(cf, reverse=True)
    return cf

ans = cf(a, b)

print(ans[k-1])

Submission status: Runtime Error

Solution code:
import numpy as np
import sympy
A, B, K = map(int, input().split())
N = sympy.divisors(np.gcd(A, B))
N.sort(reverse=True)
print(N[K-1])

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

// 約数列挙
vector<ll> divisor(ll N) {
    vector<ll> res;
    for (ll i = 1L; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            ll j = N / i;
            if (j != i)  {
                res.push_back(j);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}


void Main() {
    ll A, B, K; cin >> A >> B >> K;
    vector<ll> x = divisor(__gcd(A, B));
    sort(x.begin(), x.end());
    cout << *(x.begin() + (x.size() - K)) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		r.append(d)
        if d * d != a:
	        r.append(a/d)
	return r
a,b,k = map(int, raw_input().split(' '))
r = []
for d in f(a):
	if d in f(b):
      	r.append(d)
print r[-k]

Submission status: Runtime Error

Solution code:
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		r.append(d)
        if d * d != a:
	        r.append(a/d)
	return r
a,b = map(int, raw_input().split(' '))
r = 1
for d in f(a):
	if d in f(b):
      	r = max(r, d)#1
print r

Submission status: Runtime Error

Solution code:

def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		r.append(d)
        if d * d != a:
	        r.append(a/d)
	return r
a,b = map(int, raw_input().split(' '))
r = 1
for d in f(a):
	if d in f(b):
      	r = max(r, d)#1
print r

Submission status: Runtime Error

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

for i in range(1,100):
  if a%i == 0 and b%i == 0:
    div.append(i)
    break
print(sorted(div)[-K]

Submission status: Runtime Error

Solution code:
abk = [int(i) for i in input().split()]
a = abk[0]
b = abk[1]
k = abk[2]

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

Submission status: Runtime Error

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

def cf(x1,x2):
    cf=[]
    
    if 1 in [x1, x2]:
        cf.append(1)
    else:
        count = 0
        for i in range(2,min(x1,x2)+1):
            if count== K:
                break
            else:
                if x1 % i == 0 and x2 % i == 0:
                    cf.append(i)
            count += 1
    return cf

print(cf(A, B)[-1])

Submission status: Runtime Error

Solution code:
# abc120_b.py
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

A, B, K = map(int,input().split())
cnt = 0
_max = gcd(A,B)
while _max>=0:
    if A%_max==0 and B%_max==0:
        cnt += 1
        if cnt == K:
            print(_max)
            exit()
    _max -=1

Submission status: Runtime Error

Solution code:
a,b,x=map(int,input().split())
i=0
while(k):
  i+=1
  if max(a%i,a%i):
    pass
  else:
    k-=1
print(i)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
for i in range(1, 101):
  if a%i + b%i < 1:
	c -= 1
    if c < 1:
      print(i)
	  break

Submission status: Runtime Error

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


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


a = set(make_divisors(a))
b = set(make_divisors(b))

ans = list(a & b)

print(ans[1])

Submission status: Runtime Error

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

if A > B:
    A, B = B, A

if B - A < A:
    A = B - A

_list = [1]

for i in range(2, A + 1):
    if A % i == 0:
        _list.append(i)

# print(_list)
print(_list[-K])

Submission status: Runtime Error

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

if A > B:
    A, B = B, A

if B - A < A:
    A = B - A

if A < 1:
    A = 1

_list = []

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

print(_list[-K])

Submission status: Runtime Error

Solution code:
A,B, K = map(int, input().split())
lnA = divisor(A)
lnB = divisor(B)
ln = []
for i in lnA:
    if i in lnB:
        ln.append(i)
line = sorted(ln, reverse = True)
print(line[K - 1])

Submission status: Runtime Error

Solution code:
a,b,k = map(int,input().split())
#最大公約数を調べるためa,bのうつ値が最小値のものをsaiに代入
shou = min(a,b)
dai  = max(a,b)
min_list = []

for i in range(1,shou):
    if shou % i == 0:
        if dai % i == 0:
            min_list.append(i)

print(min_list[k-1])

Submission status: Runtime Error

Solution code:
m = min(a, b)

for i in reversed(range(m+1)):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
            print(i)
            exit()

Submission status: Runtime Error

Solution code:
a,b,k=map(int,input().split())
import math
temp=a*b//math.gcd(a,b)
print(temp*k)

Submission status: Runtime Error

Solution code:
a,b,k = map(int,input().split())
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

l = cf(a,b)

print(l[-k])

Submission status: Runtime Error

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

c = [1]
for i in range(2, max(a, b)):
    if a % i == 0 and b % i == 0:
        c.append(i)

c = sorted(c, reverse = True)

print(c[k-1])

Submission status: Runtime Error

Solution code:
for i in range(1, 101):
    if a%i==0 and b%i==0:
        cnt += 1
    if cnt == k:
        print(i)
        break

Submission status: Runtime Error

Solution code:
for i in range(100):
    if a%i==0 and b%i==0:
        cnt += 1
    if cnt == k:
        print(i)
        break

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().split())
import math
g = math.gcd(a, b)
cnt = 0
for i in range(1, g+1):
    if g % i == 0:
        cnt += 1
    if cnt == k:
        print(i)
        break

Submission status: Runtime Error

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

import math
gcd = math.gcd(a, b)
cnt = 0
for i in range(1, gcd+1):
    if gcd % i == 0:
        cnt += 1
    if cnt == k:
        print(i)
        break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
A,B,K=map(int,input().split())
C=math.gcd(A,B)
cnt=0
for x in range(C,0,-1):
    if C%x==0:
        cnt+=1
        if cnt==K:
            print(x)
            break

Submission status: Runtime Error

Solution code:
import math
A,B,K=map(int,input().split())
C=math.gcd(A,B)
cnt=0
for x in range(C,-1,-1):
    if C%x==0:
        cnt+=1
        if cnt==K:
            print(x)
            break

Submission status: Runtime Error

Solution code:
import math
A,B,K=map(int,input().split())
C=math.gcd(A,B)
count=0
for x in range(C,-1,-1):
    if C%x==0:
        count+=1
    if count==K:
        print(x)
        break

Submission status: Runtime Error

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

# check
if K == 1:
    print(1)
else:
    cnt, op = 1, 1
    div_nums = []
    append = div_nums.append
    for i in range(2, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            append(i)
    
    print(div_nums[-K])

Submission status: Runtime Error

Solution code:
import math
A,B,K=map(int,input().split())
C=math.gcd(A,B)
count=0
for x in range(C,-1,-1):
    if C%x==0:
        count+=1
        if count==K:
            print(x)
            break

Submission status: Runtime Error

Solution code:
import math
A,B,K=map(int,input().split())
C=math.gcd(A,B)
count=0
for x in range(C,-1,-1):
    if C%x==0:
        count+=1
        if count==K:
            print(x)
            break

Submission status: Runtime Error

Solution code:
from math import gcd
A,B,K=map(int,input().split())
C=gcd(A,B)
count=0
for x in range(C,-1,-1):
    if C%x==0:
        count+=1
        if count==K:
            print(x)
            break
exit()

Submission status: Runtime Error

Solution code:
from math import gcd
A,B,K=map(int,input().split())
C=gcd(A,B)
count=0
for x in range(C,-1,-1):
    if C%x==0:
        count+=1
        if count==K:
            ans=x
            break
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
A,B,K=map(int,input().split())
C=gcd(A,B)
count=0
for x in range(C,-1,-1):
    if C%x==0:
        count+=1
        if count==K:
            print(x)
            break

Submission status: Runtime Error

Solution code:
from math import gcd
A,B,K=map(int,input().split())
C=gcd(A,B)
count=0
for x in range(1,C+1):
    if C%x==0:
        count+=1
        if count==K:
            print(x)
            break

Submission status: Runtime Error

Solution code:

K=list(map(int,input().split()))
ans=0
num_list=[]
for i in range(1,min(K[0],K[1]+1)):
    if K[0]%i==0 and K[1]%i==0:num_list.append(i)
num_list.reverse()
print(num_list[K[2]-1])

Submission status: Runtime Error

Solution code:
import math

A, B, K = map(int, input().split())
gcd = math.gcd(A, B)
l = []

for i in range(1, gcd+1):
  if gcd % i == 0:
    l.append(i)
  else:
    pass
l.reverse()
print(l[K-1])

Submission status: Runtime Error

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

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

    S.append(i)

print(S[K+1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,K = map(int,input().split())
a = []
b = []

for i in range(1,A+1):
  if A%i==0:
    a.append(i)
for j in range(1,B+1):
  if B%j==0:
    b.append(j)

abset = list(set(a)&set(b))

print(abset[K+1])

Submission status: Runtime Error

Solution code:
import math
a, b, k = map(int, input().split())
l = []
gcd = math.gcd(a, b)
for i in range(1, int(gcd**0.5)+1):
    if gcd%i==0:
        l.append(i)
        if i != gcd//i:
            l.append(gcd//i)
l.sort(reverse = True)
print(l[k-1])

Submission status: Runtime Error

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

num_list = []

for i in range(1,100):
    if a % i == 0 & b % i == 0:
        num_list.append(i)

print(num_list[k])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A, B, K = list(map(int,input().split()))
L = [str(i) for i in range(100,1,-1) if A%i == 0 and B%i == 0]
if len(L) == 0:
  print(1)
else:
  print(L[K-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
def main():
    a, b, k = map(int, input().split())
    from math import gcd
    g = gcd(a, b)

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

    print(yakusuu(g)[::-1][k-1])


main()

Submission status: Runtime Error

Solution code:
a, b, k = list(map(int, input().split()))
la = []
lb = []
for i in range(1, a+1):
    if a % i == 0:
        la.append(i)
        lsas = sorted(set(la), key=la.index)
        for j in lsas:
            if b % j == 0:
                lb.append(j)

lsbs = sorted(set(lb), key=lb.index))
print(lsbs[len(lsbs)-k])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# B - K-th Common Divisor

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

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

gcdAB = gcd(A, B)

cdlist = [gcdAB]
for i in range(1, (int(gcdAB**0.5))+1)[::-1]:
    if gcdAB%1==0:
        cdlist.append(i)

print(cdlist[K-1])

Submission status: Runtime Error

Solution code:
def kth_common_divisor(a, b, k):

    count = 0
    for i in range(max(a, b)):
        if a%i == 0 and b%i:
            count += 1
        if count == k:
            return i

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def make_divisors(n,m):
    divisors = []
    for i in range(1, int(n)):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
print(c[-1+k])

Submission status: Runtime Error

Solution code:
def make_divisors(n,m):
    divisors = []
    for i in range(1, int(n)):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
print(c[-1+k])

Submission status: Runtime Error

Solution code:
def make_divisors(n,m):
    divisors = []
    for i in range(1, int(n)):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
print(c[-1+k]

Submission status: Runtime Error

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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0
for a in range(mx, 1, -1):
    print(a)
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break
print(ans)

Submission status: Runtime Error

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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0
for a in range(mx+1, 1, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

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

g = gcd(a,b)

cnt = 0
for i in range(g,0,-1):
  if a%i == 0 and b%i == 0:
    # print('i is now ',i)
    cnt+=1
    if cnt == k:
      print(i)
      break

Submission status: Runtime Error

Solution code:

a,b,k = map(int,input().split())
c = min(a,b)
t = []

for i in range(1,c):
    if a % i == 0 and b % i == 0:
        t.append(i)
print(t[1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
a,b,k=map(int,input().split())
num=math.gcd(a,b)
li=[i for i in range(1, num+1) if num%i==0]
print(li[-k])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
cnt=0
for i in range(min(a,b)):
  if i%a==0 && j%a==0:
    cnt+=1
  if cnt==c:
    print(i)
    break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split())
div=[]
for i in range(1,max(A,B)):
    if A%i==0 and B%i==0:
        div+=[i]

print(div[-K])

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split())
div=[]
for i in range(1,max(A,B)):
    if A%i==0 and B%i==0:
        div+=[i]

       
print(div[-K])

Submission status: Runtime Error

Solution code:
i = list(map(int, input().split()))

def kcd(A, B, K):
    cd_list = []
    for i in range(2, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            cd_list.insert(0,i)
    return cd_list[K - 1]

print(kcd(i[0],i[1],i[2]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
line = input()
A,B,K = [int(n) for n in line.split()]
C = max(A,B)
u = [n for n in range(1,C//2+1) if A/n in range(1,C//2+1) and B/n in range(1,C//2+1)]
u.insert(0,1)
print(u[K-1])