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

als = []
bls = []

for a in range(1,A):
  if A%a == 0:
    als.append(a)
for b in range(1,B):
  if B%b == 0:
    bls.append(b)

common = []

for a in range(0,len(als)):
  if a in bls:
    common.append(a)

common.sort()
print(common[K-1])

Submission status: Runtime Error

Solution code:
if 7/0>1:print(1)

Submission status: Runtime Error

Solution code:
info = input().split(' ')
num_one = int(info[0])
num_two = int(info[1])
num_class = int(info[2])
one_list = [i for i in range(1,num_one) if num_one % i == 0]
two_list = [i for i in range(1,num_two) if num_one % i == 0]
one_set = set(one_list)
two_set = set(two_list)
match_set = one_set & two_set
match_list = list(match_set)
match_list.sort()
print(match_list[num_class-1])

Submission status: Runtime Error

Solution code:
info = input().split(' ')
num_one = int(info[0])
num_two = int(info[1])
num_class = int(info[2])
one_list = [i for i in range(1,num_one) if num_one % i == 0]
two_list = [i for i in range(1,num_two) if num_one % i == 0]
one_set = set(one_list)
two_set = set(two_list)
match_set = one_set & two_set
match_list = list(match_set)
print(match_list[num_class - 1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def gcd(t):
    try:
        b,a=sorted(t)
        while True:
            m=a%b
            if m==0:
                return b
            a=b;b=m
    except:
        return 1

try:
    a,b,k=(int(x) for x in input().split())
    g=gcd((a,b))
    cd=[]
    i=g
except:
    print(1)
while True:
    try:
        if g%i==0:
            cd.append(i)
            i=i//2
            if i==0:
                break
        else:
            i-=1
    except:
        break
print(cd[k-1])

Submission status: Runtime Error

Solution code:
def gcd(t):
    try:
        b,a=sorted(t)
        while True:
            m=a%b
            if m==0:
                return b
            a=b;b=m
    except:
        return 1

a,b,k=(int(x) for x in input().split())
g=gcd((a,b))
cd=[]
i=g
while True:
    try:
        if g%i==0:
            cd.append(i)
            i=i//2
            if i==0:
                break
        else:
            i-=1
    except:
        break
print(cd[k-1])

Submission status: Runtime Error

Solution code:
def gcd(t):
    b,a=sorted(t)
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m

a,b,k=(int(x) for x in input().split())
g=gcd((a,b))
cd=[]
i=g
while True:
    try:
        if g%i==0:
            cd.append(i)
            i=i//2
            if i==0:
                break
        else:
            i-=1
    except:
        break
print(cd[k-1])

Submission status: Runtime Error

Solution code:
def gcd(_a,_b):
    b,a=sorted((_a, _b))
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m

a,b,k=(int(x) for x in input().split())
g=gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==0:
            break
    else:
        i-=1
print(cd[k-1])

Submission status: Runtime Error

Solution code:
def gcd(_a,_b):
    b,a=sorted((_a, _b))
    if b==0:
        return 0
    while True:
        m=a%b
        if m==0:
            return b
        a=b;b=m

a,b,k=(int(x) for x in input().split())
g=gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==1 or i==0:
            break
    else:
        i-=1
print(cd[k-1])

Submission status: Runtime Error

Solution code:
def gcd(_a,_b):
    a=max([_a, _b]); b=min([_a, _b])
    while True:
        if not b==0:
            m=a%b
        if m==0:
            return b
        a=b

a,b,k=(int(x) for x in input().split())
g=gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==1 or i==0:
            break
    else:
        i-=1
print(cd[k-1])

Submission status: Runtime Error

Solution code:
def gcd(_a,_b):
    a=max([_a, _b]); b=min([_a, _b])
    while True:
        m=a%b
        if m==0:
            return b
        a=b

a,b,k=(int(x) for x in input().split())
g=gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==1 or i==0:
            break
    else:
        i-=1
print(cd[k-1])

Submission status: Runtime Error

Solution code:
import math
a,b,k=(int(x) for x in input().split())
g=math.gcd(a,b)
cd=[]
i=g
while True:
    if g%i==0:
        cd.append(i)
        i=i//2
        if i==1 or i==0:
            break
    else:
        i-=1
print(cd[k-1])

Submission status: Runtime Error

Solution code:
A, B, K = map(int, input().split())
a=[]
b=[]
if A>=B:
  for i in range(1,A+1): # i = [1,2,3,4,....A]
    if A%i==0 and B%i==0:
      a.append( A/i )
      b.append( B/i )
  
else:
  for i in range(1,B+1): # i = [1,2,3,4,....A]
    if A%i==0 and B%i==0:
      a.append( A/i )
      b.append( B/i )

c=[]
for ea in a:
  if ea in b:
    c.append( ea )

print(c[K])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def euclid(p,q):
  if q == 0:
    return p
  else:
    return euclid(q,p//q)
  
n = euclid(a,b)
count = 0
for i in range(n):
  if n % (n-i)==0:
    count += 1
  if count == k:
    print(n-i)
    break

Submission status: Runtime Error

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

print(x[-k])

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main() {
	// your code goes here
	ll a,b,k;
	cin>>a>>b>>k;
	ll g=__gcd(a,b);
	ll count=0;
	for(ll i=g;i>=0;i--)
	{
	    if(g%i==0)
	    {
	        count+=1;
	    }
	    if(count==k)
	    {
	        cout<<i<<endl;
	        exit(0);
	    }
	}
	return 0;
}

Submission status: Runtime Error

Solution code:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (A % i == 0 and B % i == 0):
        if (i>=j):
            break
        j=int(A/i)
        f.append(i)
        if (i!=j and B % j == 0):
            f.append(j)
f.sort(reverse=True)
if len(f)==0:
    print(1)
else:
    print(f[K-1])

Submission status: Runtime Error

Solution code:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (A % i == 0 and B % i == 0):
        if (i>=j):
            break
        j=int(A/i)
        f.append(i)
        if (i!=j and B % j == 0):
            f.append(j)
f.sort(reverse=True)
if A==1:
    print(1)
else:
    print(f[K-1])

Submission status: Runtime Error

Solution code:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (i>=j):
        break
    if (A % i == 0 and B % i == 0):
        j=int(A/i)
        f.append(i)
        if (B % j == 0):
            f.append(j)
f.sort(reverse=True)
if A==1:
    print(1)
else:
    print(f[K-1])

Submission status: Runtime Error

Solution code:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (i>=j):
        break
    if (A % i == 0 and B % i == 0):
        j=int(A/i)
        f.append(i)
        if (B % j == 0):
            f.append(j)
f.sort()
if A==1:
    print(1)
else:
    print(f[K-1])

Submission status: Runtime Error

Solution code:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
for i in range(1,A):
    if (i>=j):
        break
    if (A % i == 0 and B % i == 0):
        j=int(A/i)
        f.append(i)
        if (B % j == 0):
            f.append(j)
if A==1:
    print(1)
else:
    print(f[K-1])

Submission status: Runtime Error

Solution code:
A,B,K = [int(i) for i in input().split()]
if (A>B):
    A,B=B,A
f=[]
j=A
k=0
for i in range(1,A):
    if (i>=j):
        break
    if (A % i == 0 and B % i == 0):
        j=int(A/i)
        f.insert(k,i)
        if (B % j == 0):
            f.insert(k,j)
        k+=1
if A==1:
    print(1)
else:
    print(f[K-1])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

count = 0
index = 0
if A > B:
  for i in range(B):
    if A // i == 0 and B // i == 0:
      index = i
      count = count+1
      if count == K:
        break
elif A < B:
    for i in range(A):
      if A // i == 0 and B // i == 0:
        index = i
        count = count+1
        if count == K:
          break
  
print(index)

Submission status: Runtime Error

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

for i in range(1, max(min(a, b), 2)):
    if a % i == 0:
        if b % i == 0:
            divs.append(i)
print(divs[-k])

Submission status: Runtime Error

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

for i in range(1, int(max(a, b))):
    if a % i == 0:
        if b % i == 0:
            divs.append(i)
print(divs[-k])

Submission status: Runtime Error

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

for i in range(1, max(int(max(a, b)), 2)):
    if a % i == 0:
        if b % i == 0:
            divs.append(i)
print(divs[-k])

Submission status: Runtime Error

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

for i in range(1, max(int(max(a, b) / 2), 2)):
    if a % i == 0:
        if b % i == 0:
            divs.append(i)
print(divs[-k])

Submission status: Runtime Error

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

for i in range(1, max(int(max(a, b) / 2), 2)):
    if a % i == 0:
        if a % i == 0:
            divs.append(i)
print(divs[-k])

Submission status: Runtime Error

Solution code:

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

for i in range(1, int(max(a, b) / 2)):
    if a % i == 0:
        if a % i == 0:
            divs.append(i)
print(divs[-k])

Submission status: Runtime Error

Solution code:
usr_input = input()
lst = usr_input.split()

a = int(lst[0])
b = int(lst[1])
c = int(lst[2])

devider_a=[]
devider_b=[]
for i in range(1,a,1):
    if a%i == 0:
        devider_a.append(i)

for i in range(1,b,1):
    if b % i == 0:
        devider_b.append(i)

common_devider = []
for element in devider_a:
    for value in devider_b:
        if element==value:
            common_devider.append(value)

print(common_devider[c-1])

Submission status: Runtime Error

Solution code:
A, B ,K  = (int(x) for x in input().split())
i = 1
ans = []
while True:
    if min(A,B) < i:
        break
    if A % i == 0 & B % i == 0:
        ans.append(i)
    i = i + 1
print(ans[-K-1])

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split())
i=0
j=1
a=[]
while A%j==0 and B%j==0:
    a.append(j)
    j+=1
print(a[-K])

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split())
i=0
j=1
a=[]
if A%j==0 and B%j==0:
    a.append(j)
    j+=1
print(a[-K])

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split())
i=0
j=1
a=[]
if A%j==0 and B%j==0:
    a.append(j)
    j+=1
print(a[-4])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,K = map(int,input().split())
x = []
if A >= B:
    for i in range(1,A):
        if A % i == 0 and B % i == 0:
            x.append(i)
else:
    for i in range(1,B):
        if A % i == 0 and B % i == 0:
            x.append(i)

print(x[K-1])

Submission status: Runtime Error

Solution code:
A,B,K = map(int,input().split())
x = []
if A >= B:
    for i in range(1,A):
        if A % i == 0 and B % i == 0:
            x.append(i)
else:
    for i in range(1,B):
        if A % i == 0 and B % i == 0:
            x.append(i)
x.sort(reverse=True)
print(x[K - 1])

Submission status: Runtime Error

Solution code:
A,B,K = map(int,input().split())
x = []
if A >= B:
  for i in range(1,A):
    if A % i == 0 and B % i == 0:
      x.append(i)
else:
  for i in range(1,B):
    if A % i == 0 and B % i == 0:
      x.append(i)
x.sort(reverse=True)
print(x[K - 1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

input = [int(item) for item in input().split()]
a, b, k = input
divisors = make_divisors(a)

th = 0
for i, item in enumerate(divisors):
  if b % item == 0:
    th += 1
  if th == k
    return th

return 0

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,c=(map(int,input()))
A =[]
B =[]
C =[]
for i in range(1,a+1):
  if a%i==0:
    A = i
for i in range(1,b+1):
  if b%i==0:
    B =i
for i in A:
  for j in B:
    if A[i]=B[j]:
      C = A[i]
print(C[c])

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
list = []
for i in range( min(a,b)) :
  if i == 0:
    continue
  if a%i == 0 and b%i ==0:
    list.append(i)
list.reverse()

print(list[c-1])

Submission status: Runtime Error

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

arr = list(map(int,input().split()))
 
n = 0
 
for i in range(1,arr[0]):
  if arr[0] % i == 0 and arr[1] % i == 0:
    n += 1
    if n == arr[2]:
      ans = i
      break
print(ans)

Submission status: Runtime Error

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

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

n = 0

for i range(1,arr[0]):
  if arr[0] % i == 0 and arr[1] % i ==0:
    n += 1
    break
print(n)

Submission status: Runtime Error

Solution code:
A,B,K = map(int,input().split())
count = min(A,B)
k = 0
while count > 0:
  if A%count == 0 nad B%count == 0:
    k += 1
  if k == K:
    print(count)
    break
  else:
    count -= 1

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  6 16:28:37 2019

@author: iwata
"""

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

if A >= B:
    for i in reversed(range(B)):
        rema1 = A%i
        remb1 = B%i
        if rema1==0 & remb1==0:
            count = count +1
        if K == count:
            print(i)
            break
else:
    for j in reversed(range(A)):
        rema = A%j
        remb = B%j
        if rema==0 & remb==0:
            count = count +1
        if K == count:
            print(j)
            break

Submission status: Runtime Error

Solution code:
a,b,k = [int(x) for x in input().split()]
num = 0
while 1:
  num += 1
  if !(a%num)&&!(b%num):
    k -= 1
  if !k:
    print(num)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
      int ks = 0;
      int a,b,k; cin >> a >> b >> k;
      for(int i = min(a,b);;i--){
        if(a%i == 0 && b%i == 0) ks++;
        if(ks == k) return cout << i << endl, 0;
      }
    }

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
val = input().split(" ")
A = int(val[0])
B = int(val[1])
K = int(val[2])
 
arr1 = [i for i in range(1,A + 1) if A % i == 0]
arr2 = [j for j in range(1,B + 1) if B % j == 0]
 
result = list(set(arr1) & set(arr2))
result.sort(revarse=True)
print(result[K - 1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

x=[]
for i in range(1,100):
    if(abk[0]%i==0 and abk[1]%i==0):
        x.append(i)

print(x[-2])

Submission status: Runtime Error

Solution code:
import itertools
import math

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

def solve(a, b, k):
    c = math.gcd(a, b)
    n = 0

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

main()

Submission status: Runtime Error

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

num = 0
c = []
if(a<b):
	num = b
else:
	num = a

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

Submission status: Runtime Error

Solution code:
l = []
ans = []
a, b, k = list(map(int, input().split()))
l.append(a)
l.append(b)
i = 1

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

    print(ans[-k])

Submission status: Runtime Error

Solution code:
l = []
ans = []
a, b, k = list(map(int, input().split()))
l.append(a)
l.append(b)
i = 1

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

if len(ans) == 0:
    print(1)
else:
    print(ans[-k])

Submission status: Runtime Error

Solution code:
l = []
ans = []
a, b, k = list(map(int, input().split()))
l.append(a)
l.append(b)
i = 1

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

if len(ans) == 0:
    print(1)
else:
    print(ans[k-1])

Submission status: Runtime Error

Solution code:
l = []
ans = []
a, b, k = list(map(int, input().split()))
l.append(a)
l.append(b)
i = 1

print('l:',l)


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

if len(ans) == 0:
    print(1)
else:
    print('ans[k-1]',ans[k-1])

Submission status: Runtime Error

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

print(li[-k])

Submission status: Runtime Error

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

print(li[-k])

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().split())
li =[]
cnt = 0
for i in range(max(a, b)):
    if i == 0:
        continue
    elif a % i == 0 and b % i == 0:
        li.append(i)
        cnt += 1
    elif cnt == k:
        break

print(li[-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
A,B,K=map(int,input().split())
d=[]
if math.gcd(A,B)==1:
    d.append(1)
else:
    for i in range(2,math.gcd(A,B)+1):
        if A%i==0 and B%i==0:
            d.append(i)
print(d[len(d)-K])

Submission status: Runtime Error

Solution code:
import math
A,B,K=map(int,input().split())
d=[]
if A==1 or B==1:
    d.append(1)
else:
    for i in range(2,math.gcd(A,B)+1):
        if A%i==0 and B%i==0:
            d.append(i)
print(d[len(d)-K])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

X = []
cnt = 0
for i in range(1, 1 + int(min(list[0],list[1]))):
  if(list[0] % i == 0 and list[1] % i == 0):
    X.append(i)
    cnt = 1
X.sorted(reverse)
if (cnt == 1):
  print(X[list[2]-1])
else:
  print(1)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,K = [int(x) for x in input().split()]
ls =[i for i in range(1,A+1) if A % i == 0 and B % i == 0]
lsreverse = reverse(ls)
answer = lsreverse[K-1]
print(answer)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,K = [int(x) for x in input().split()]
ls =[i for i in range(1,A+1) if A % i == 0 and B % i == 0]
answer = ls[K]
 print(answer)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,K = [int(x) for x in input().split()]
ls =[i for i in range(1,A+1) if A % i == 0 and B % i == 0]
print(ls[K])

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,K = [int(x) for x in input().split()]
ls =[i in range(1,A+1) if A % i == 0 and B % i == 0]
print(ls[K])

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,K = [int(x) for x in input().split()]
ls =[]
for i in range(1,A+1):
    if A % i == 0 and B % i == 0:
        ls.append(i)

print(ls[K])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

t=[1]
for i in range(2, int(b/2)):
    if a%i == 0 and b%i == 0:
        t.append(i)
print(t[k-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

i_lst = []
for i in range(1, A+1):
	if A%i==0:
		i_lst.append(i)
		
j_lst = []
for j in range(1, B+1):
	if B%j==0:
		j_lst.append(j)
		
k_lst = []
for ii in range(1, len(i_lst)):
	for jj in range(1, len(j_lst)):
		if i_lst[ii]==j_lst[jj]:
			k_lst.append(i_lst[ii])
print(k_lst[K-1])A, B, K = map(int, input().split())

i_lst = []
for i in range(1, A+1):
	if A%i==0:
		i_lst.append(i)
		
j_lst = []
for j in range(1, B+1):
	if B%j==0:
		j_lst.append(j)
		
k_lst = []
for ii in range(1, len(i_lst)):
	for jj in range(1, len(j_lst)):
		if i_lst[ii]==j_lst[jj]:
			k_lst.append(i_lst[ii])
print(k_lst[K-1])

Submission status: Runtime Error

Solution code:

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

# 出力
print("{}".format(int(ret)))

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split());print([i for i in range(A,0,-1)if1>A%i+B%i][K-1])

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, K] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    count = 0

    if max(A, B) == 1:
        print 1
        return

    num_list = []
    for x in range(1, max(A, B)):
        if A%x == 0 and B%x == 0:
            num_list.append(x)
    num_list.sort(reverse = True)
    print num_list[K - 1]

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,K=map(int,input().split());print[i for i in range(A,0,-1)if1>A%i+B%i][K-1]

Submission status: Runtime Error

Solution code:
A,B,K=map(int,raw_input().split());print[i for i in range(A,0,-1)if1>A%i+B%i][K-1]

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

list =[]
for i in range(1,100):
    if (input[0]%i ==0) & (input[1]%i ==0) :
        list.append(i)
print(list[input[2]])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

olist = []
cnt = 0
for i in range(1, int(min(list[0],list[1]))):
  if(list[0] % i == 0 and list[1] % i == 0):
    olist.append(i)
    cnt = 1
if (cnt == 1):
  print(olist[len(olist) + 1 - list[2]])
else:
  print(1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
i = int(0)
l = list()
if a > b:
    maxim = a
else:
    maxim = b
for i in range(1,100):
        if ((a % i) == 0) and ((b % i) == 0):
            l.append(i)
        elif maxim < i:
            break

n = int(len(l))
if c != 1:
    n -= c
print(l[n])

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
i = int(0)
l = list()
if a > b:
    maxim = a
else:
    maxim = b
for i in range(1,100):
        if ((a % i) == 0) and ((b % i) == 0):
            l.append(i)
        elif maxim < i:
            break

n = int(len(l))
if c == 1:
    n = n
else:
    n -= c
print(l[n])

Submission status: Runtime Error

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

olist = []
for i in range(1, int(min(list[0],list[1]) / 2)):
  if(list[0] % i == 0 and list[1] % i == 0):
    olist.append(i)
print(olist[len(olist) + 1 - list[2]])

Submission status: Runtime Error

Solution code:
import sympy

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

g = sympy.gcd(A, B)
mini = min(A,B)
count = 0
lst = []

for _ in range(mini):
    i = mini - _

    if mini % i == 0:
        count += 1
        lst.append(i)

    else:
        pass


if max(A, B) % mini == 0:
    print(lst[K-1])
else:
    print(lst[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 + B%i) == 0:
        l.append(i)
    else:
        pass
if A == 1 & B == 1:
    print(1)
else:
    print(l[-K])

Submission status: Runtime Error

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

if A > B:
  judge = A
else:
  judge = B
for i in range(judge):
  if i != 0:
    if A % i == 0 and B % i == 0:
      list.append(i)
print(list[len(list)-K])

Submission status: Runtime Error

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

tmp = 0
for i in range(200):
  if a% i == 0 and b % i == 0:
    tmp += 1
    if tmp == k:
      print(i)