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

s = 0
def sp(R):
  if R==1:
    return {1:1}
  dic = {}
  I = int(R)
  s=0
  while s==0:
    for i in range(2, R+1):
      if I%i==0:
        I=I/i
        if I==1:
          s=1
        if i not in dic:
          dic[i] = 0
        dic[i] += 1
        break
  return dic

a = sp(A)
b = sp(B)
c = []

if A == 1 and B == 1:
  print(1)
  sys.exit()
elif A == 1:
  for i in range(0, max(b.keys())+1):
    if i in b:
      t = b[i]
      c.append([i**j for j in range(t+1)])
elif B == 1:
  for i in range(0, max(a.keys())+1):
    if (i in a):
      t = a[i]
      c.append([i**j for j in range(t+1)])
else:
  for i in range(0, max(max(a.keys()), max(b.keys()))+1):
    if (i in a) and (i in b):
      t = min(a[i], b[i])
      c.append([i**j for j in range(t+1)])

arr = []
import itertools
from functools import reduce
for i in itertools.product(*c):
  v = reduce(lambda x,y:x*y,i)
  if v not in arr:
    arr.append(v)

arr.sort(reverse=True)

print(arr[K-1])

Submission status: Runtime Error

Solution code:
str_lis = input().split()
A, B, K = [int(x) for x in str_lis]
N = min(A, B)
num_lis = [n for n in range(1, N + 1) if A % n == 0 and B % n == 0]
print(num_lis[K])

Submission status: Runtime Error

Solution code:
str_lis = input().split()
A, B, K = [int(x) for x in str_lis]
N = min(A, B)
num_lis = [n for n in range(1, N + 1) if A % n == 0 and B % n == 0]
print(num_lis[K]

Submission status: Runtime Error

Solution code:
try:
  a = int(input('A'))
  b = int(input('B'))
  k = int(input('K'))
except EOFError:
  a = 8
  b = 12
  k = 2 
count = 0
kcount = 0
while True:
    count += 1
    if a % count == 0 and b % count == 0:
        kcount += 1
    if k == kcount:
        break

print(count)

Submission status: Runtime Error

Solution code:
try:
  A, B, K = (int(i) for i in input().split())
  list = []
  for i in range(1, 100):
    if A % == 0 and B % i == 0:
      list.append(i)
  print(list[len(list)-K])
  
except ZeroDivisionError:
    print("ZeroDivisionError!!")

Submission status: Runtime Error

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

if A >= B:
    L, S = A, B
if A < B:
    L, S = B, A

while L%S != 0:
    tmp = L;
    L = S;
    S = tmp%S;

gcd = int(S)

if gcd == 1:
    print(1)
    exit()

com_div = []
count = 1
while count < gcd:
    if gcd % count == 0:
        gcd = int(gcd / count)
        com_div.append(gcd)
        com_div.append(count)
    count += 1

com_div.sort(reverse=True)
print(com_div[K-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A = list(map(int,input().split( )))
a=A[0]
b=A[1]
k=A[2]
x=0
for h in range(1,51):
	i=50-h
	if a%i + b%i:
		continue
	x=x+1
	print(i)
	if x == k:
		break
print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
a, b, k = map(int, input().split())

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

Submission status: Runtime Error

Solution code:

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


c=0

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

A = inp[0]
B = inp[1]
K = inp[2]

# 約数を求める
yakusuu_a = []
yakusuu_b = []

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

for i in range(1,B):
    if B % i == 0:
        yakusuu_b.append(i)

c = []
for i in yakusuu_a:
  if i in yakusuu_b:
    c.append(i)

c.sort()
if len(c) == 0:
  print(1)
else:
  print(c[K-1])

Submission status: Runtime Error

Solution code:
# coding: utf-8
a, b, k = map(int, input().split())

if a > b:
    max = a
else:
    max = b
c = 0
for i in range(1, max):
    if a%i == 0 and b%i == 0:
        print(i)
        c += 1
    if c == k:
        break
print(i)

Submission status: Runtime Error

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

s = 0
def sp(R):
  if R == 1:
    return {1:1}
  dic = {}
  I = int(R)
  s=0
  while s==0:
    for i in range(2, R+1):
      if I%i==0:
        I=I/i
        if I==1:
          s=1
        if i not in dic:
          dic[i] = 0
        dic[i] += 1
        break
  return dic

a = sp(A)
b = sp(B)

c = []
for i in range(0, max(max(a.keys()), max(b.keys()))+1):
  if (i in a) and (i in b):
    t = min(a[i], b[i])
    c.append([i**j for j in range(t+1)])

arr = []
import itertools
from functools import reduce
for i in itertools.product(*c):
  v = reduce(lambda x,y:x*y,i)
  if v not in arr:
    arr.append(v)

arr.sort(reverse=True)

print(arr[K-1])

Submission status: Runtime Error

Solution code:
from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
for i in reversed(range()):
  if max % (i+1)==0:
    k += 1
    if k == a[2]:
      print(i)
      break

Submission status: Runtime Error

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


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

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().strip().split(''))
i = 1
l = []
while len(l)<k:
    if (a%i==0 and b%i==0) or i%2==0 or i%5==0:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-1])

Submission status: Runtime Error

Solution code:
from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
res 
for i in reversed(range()):
  if max % (i+1)==0:
    k += 1
    if k == a[2]:
      print(k)
      break

Submission status: Runtime Error

Solution code:
a = int(input('A'))
b = int(input('B'))
k = int(input('K'))

count = 0
kcount = 0
while True:
    count += 1
    if a % count == 0 and b % count == 0:
        print(count)
        kcount += 1
    if k == kcount:
        break

print(count)

Submission status: Runtime Error

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

list=[]
list= [i for i in range(1,15) if A%i==0 and B%i==0]
a = list[K-1]
ptint(a)

Submission status: Runtime Error

Solution code:
import math

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

if A >= B:
    L, S = A, B
if A < B:
    L, S = B, A

while L%S != 0:
    tmp = L;
    L = S;
    S = tmp%S;

gcd = int(S)

com_div = []
count = 1
while count <= gcd:
    if gcd % count == 0:
        gcd = int(gcd / count)
        com_div.append(gcd)
        com_div.append(count)
    count += 1

com_div.sort(reverse=True)
print(com_div[K-1])

Submission status: Runtime Error

Solution code:
a,b,k=map(int,input().split())
tar=[1]
r=min(a,b)-1
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:
A, B, K = map(int, input().split())

list=[]
list= [i for i in range(1,10000) if A%i==0 and B%i==0]
a = list[K-1]
ptint(a)

Submission status: Runtime Error

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

A = inp[0]
B = inp[1]
K = inp[2]

# 約数を求める
yakusuu_a = []
yakusuu_b = []

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

for i in range(1,B):
    if B % i == 0:
        yakusuu_b.append(i)

c = []
for i in yakusuu_a:
  for j in yakusuu_b:
    if i == j:
      c.append(i)

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

Submission status: Runtime Error

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


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

Submission status: Runtime Error

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

ans = 0

lista = list(range(a+1))
aa = lista.pop(0)

listb = list(range(b+1))
bb = listb.pop(0)

if (a < b):
    li = [i for i in lista if a % i == 0 && b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in listb if a % i == 0 && b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)

Submission status: Runtime Error

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


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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

a,b,c= map(int, input().split())
d= int(gcd(a,b))
if c==1:
  print(d)
else:
  arr=[]
  for i in range(1,d):
    if(d%i == 0):
      arr.append(i)
  print(arr[-(c-1)])

Submission status: Runtime Error

Solution code:
import math

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

gcd = int(math.gcd(A, B))

com_div = []
count = 1
while count <= gcd:
    if gcd % count == 0:
        gcd = int(gcd / count)
        com_div.append(gcd)
        com_div.append(count)
    count += 1

com_div.sort(reverse=True)
print(com_div[K-1])

Submission status: Runtime Error

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

yakusuu=[]
yakusuuA = []
yakusuuB = []
for i in range(1,A+1):
  if A% i == 0:
    yakusuuA.append(i)
  
for j in range(1,B+1):
  if B%j == 0:
    yakusuuB.append(j)
    
yakusuu = set(yakusuuA) & set(yakusuuB)
yakusuu.append(1)     
print(sorted(yakusuu)[K])

Submission status: Runtime Error

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

ans = 0

lista = range(a+1)
aa = lista.pop(0)

listb = range(b+1)
bb = listb.pop(0)

if (a < b):
    li = [i for i in lista if a % i == 0 && b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in listb if a % i == 0 && b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)

Submission status: Runtime Error

Solution code:
import fraction

a,b,c= map(int, input().split())
d= int(fraction.gcd(a,b))
if c==1:
  print(d)
else:
  arr=[]
  for i in range(1,d):
    if(d%i == 0):
      arr.append(i)
  print(arr[-(c-1)])

Submission status: Runtime Error

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

list=[]
list= [i for i in range(10000) if A%i==0 and B%i==0]
list[K-1]

Submission status: Runtime Error

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

ans = 0

lista = range(a+1)
aa = lista.pop(0)

listb = range(b+1)
bb = listb.pop(0)

if (a < b):
    li = [i for i in listb if a % i == 0 && b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in lista if a % i == 0 && b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)

Submission status: Runtime Error

Solution code:
import fraction

a,b,c= map(int, input().split())
d= int(math.gcd(a,b))
if c==1:
  print(d)
else:
  arr=[]
  for i in range(1,d):
    if(d%i == 0):
      arr.append(i)
  print(arr[-(c-1)])

Submission status: Runtime Error

Solution code:
def get_div(num):
    if num == 1:
        return [1]
    else:
        return [i for i in range(1,num) if num%i==0]

A, B, K  = [int(a) for a in input().split()]
cat = get_div(A) + get_div(B)
dup = [x for x in set(cat) if cat.count(x) > 1]
dup = sorted(dup)
print(dup[K-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

a,b,c= map(int, input().split())
d= int(math.gcd(a,b))
if c==1:
  print(d)
else:
  arr=[]
  for i in range(1,d):
    if(d%i == 0):
      arr.append(i)
  print(arr[-(c-1)])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def ooo(x):
    lix =[]
    for i in range(1, x+1):
        if x % i == 0:
            li.append(i)
    return lix

lia = ooo(a)
lib = ooo(b)
li = lia + lib

li2 =[]
for n in range(len(li)):
    if not li[n] in li2: 
        if li.count(li[n]) == 2:
            li2.append(li[n])

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

Submission status: Runtime Error

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

ans = 0

lista = range(a+1)
aa = lista.pop(0)

listb = range(b+1)
bb = listb.pop(0)

if (a < b):
    li = [i for i in listb if (a % i == 0 && b % i == 0)]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in lista if (a % i == 0 && b % i == 0)]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

list= [i for i in range(10000) if A%i==0 and B%i==0]
list[K-1]

Submission status: Runtime Error

Solution code:
import math

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

C = min(A,B)

for i in range(1,C+1):
    if C % i == 0:
        if i <= GCA:
            all_div.append(i)
all_div.sort(reverse=True)
print(all_div[K-1])

Submission status: Runtime Error

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

def ooo(x):
    list =[]
    for i in range(1, x+1):
        if x % i == 0:
            li.append(i)
    return li

lia = ooo(a)
lib = ooo(b)
li = lia + lib

li2 =[]
for n in range(len(li)):
    if not li[n] in li2: 
        if li.count(li[n]) == 2:
            li2.append(li[n])

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math


def main():
    a = list(map(int, input().split()))
    b = math.gcd(a[0], a[1])
    c = b
    for i in range(a[2]-1):
        while True:
            c -= 1
            if b % c == 0:
                break
    print(c)


main()

Submission status: Runtime Error

Solution code:
import math

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

Max = int(math.gcd(A, B) )


list = [0] * 100

j =0

if A == 1 or B == 1:
    print("1")
    quit()

for i in range(Max):

    if i == 0:
        continue
    if Max % i == 0:
        list[j] = i
        j += 1


print(list[j - K+1])

Submission status: Runtime Error

Solution code:
a,b,c = map(int, input().split())
def m(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

print(m(a), m(b))
list = m(a)+ m(b)
res = [e for e in set(list) if list.count(e) > 1]
print(res[c])

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
count = 0
ans = 0

for i in 100:
    if (a % i) == 0 and (b % i) == 0:
        count += 1
        if count >= c:
            ans = i
            break

print(ans)

Submission status: Runtime Error

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

a=0
if(A>B): i=A
if(B>A): i=B
count=0
while(a==0):
  if(A%i==0 and B%i==0):
    count+=1
    if(count==K):
      print(i)
      break
  i-=1

Submission status: Runtime Error

Solution code:
import fraction


def main():
    a = list(map(int, input().split()))
    b = fraction.gcd(a[0], a[1])
    c = b
    for i in range(a[2]-1):
        while True:
            c -= 1
            if b % c == 0:
                break
    print(c)


main()

Submission status: Runtime Error

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

ans = 0

lista = range(a+1)
aa = lista.pop(0)

listb = range(b+1)
bb = listb.pop(0)

if (a < b):
    li = [i for i in listb if (a % i == 0 && b % i == 0)]
    ans = li[k-1]
else:
    li = [i for i in lista if (a % i == 0 && b % i == 0)]
    ans = li[k-1]

print(ans)

Submission status: Runtime Error

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

count = 0
cand = []
denom = 0

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

print(cand[-K])

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
count = 0

for i in 100:
    if (a % i) == 0 and (b % i) == 0:
        count += 1
        if count >= c:
            break

print(i)

Submission status: Runtime Error

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

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

igcd = fgcd(A,B)
if igcd == 1:
    print(1)
else:
    aP = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97)
    aD =[igcd,1]
    for eP in aP:
        if igcd < eP:
            break
        if igcd % eP == 0:
            i = 1
            while igcd % (eP**i) == 0 :
                aD.append(eP**i)
                aD.append(igcd // (eP ** i))
                i += 1
    aD = sorted(list(set(aD)),reverse=True)
    print(aD[K-1])

Submission status: Runtime Error

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

if a==1 or b==1 or k==1:
	print(1)
	exit()

divisorA = [ i for i in range(1,a ) if a % i == 0 ]
divisorB = [ i for i in range(1,b ) if b % i == 0 ]

divisor = set(divisorA + divisorB)

divisor = sorted(divisor &  set(divisorA) )

print( divisor[k-1] )

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

a,b,k=map(int,input().split())
l=[]
g=gcd(a,b)
q=g
i=1

if a==1 and b==1:
  print(1)
else:
  for i in range(1,int(g/2)+1):
   
    if q%i==0:
      if int(g/i)==i:
        l.append(i)
      else:
        l.append(int(g/i))
        l.append(i)
  l.sort()
  l=set(l)
  l=list(l)
  print(l[(-1)*k])

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 A % j == 0]

result = list(set(arr1) & set(arr2))
result.sort()

print(result[k - 1])

Submission status: Runtime Error

Solution code:
import math
import sys
a, b, k = map(int, input().split())
c = math.gcd(a, b)
ls = []
for i in range(1, c):
    if i == 0:
        continue
    if c % i == 0:
        ls.append(i)
ls.append(c)
ls.sort(reverse=True)
print(ls[k-1])

Submission status: Runtime Error

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

yakusuu=[]
for i in range(1,A):
  if A% i == 0:
    yakusuu.append(i)
  
for j in range(1,B):
  if B%j == 0:
    yakusuu.append(j)
    
print(sorted(yakusuu)[K])

Submission status: Runtime Error

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

import sympy as sym
list_A = sym.divisors(A)
list_B = sym.divisors(B)

list_and = set(list_A) & set(list_B)

list_and_sort = sorted(list_and, reverse=True)

print(list_and_sort[K-1])

Submission status: Runtime Error

Solution code:

A,B,K  = map(int, input().split(" "))
count = 0
i = 1
tempList = []
for i in range(1,max(A,B)) :
    if A%i == 0 and B%i == 0:
        tempList.append(i)
print(tempList[-K])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,k=(int(x) for x in input().split())
list =[]

for x in range(1,max(a,b)):
    if(a%x == 0 and b%x == 0):
        list.append(x)

print(list[-k])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:44 2019

@author: Yamazaki Kenichi
"""

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

counta = 0
for i in range(1,K):
    if len(str(A/i)) < 10**10 and len(str(B%i)) < 10**10:
        counta += 1
    if counta == K:
        ans = i
        break
print(ans)

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
num1 = a[0]
num2 = a[1]
list1 = []
list2 = []
max = a[2]
for i in range(1, num1):
  if num1 % i == 0:
    list1.append(i)
    
for i in range(1, num2):
  if num2 % i == 0:
    list2.append(i)

list3 = list1 + list2
list3 = list(set(list3))
print(list3[max -1])

Submission status: Runtime Error

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

ans = 0

if (a < b):
    li = [i for i in range(b+1) if (a % i == 0 && b % i == 0 && i != 0)]
    ans = li[k-1]
else:
    li = [i for i in range(a+1) if (a % i == 0 && b % i == 0 && i != 0)]
    ans = li[k-1]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main(int argc, char *argv[]) {
  int a,b,k,i;
  cin>>a>>b>>k;
  vector<int> x;
  for(i=1;i<=a;i++)
    if(a%i==0 && b%i==0)
      x.push_back(i);
  sort(x.begin(),x.end(),greater<int>());
  cout<<x[k-1]<<endl;
}

Submission status: Runtime Error

Solution code:
import math

a,b,k=map(int,input().split())
l=[]
g=math.gcd(a,b)
q=g
i=1

if a==1 and b==1:
  print(1)
else:
  for i in range(1,int(g/2)+1):
   
    if q%i==0:
      if int(g/i)==i:
        l.append(i)
      else:
        l.append(int(g/i))
        l.append(i)
  l.sort()
  l=set(l)
  l=list(l)
  print(l[(-1)*k])

Submission status: Runtime Error

Solution code:
a,b,k=map(int,input().split())
yakusuu_array=[]
if a==b:
    max_gcd=a
else:
    for l in  reversed(range(min(a,b))):
        if max(a,b)%l==0:
            max_gcd=l
            break        
if k==1:
    print(max_gcd)
else:
    for i in range(1,max_gcd):
        if max_gcd % i == 0:
            yakusuu_array.append(i)

    print(yakusuu_array[-(k-1)])

Submission status: Runtime Error

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

for i in range(1, a):
    if a % i == 0:
        li.append(i)
    else:
        continue

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

li2 =[]
for n in range(len(li)):
    if not li[n] in li2: 
        if li.count(li[n]) == 2:
            li2.append(li[n])

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

Submission status: Runtime Error

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

ans = 0

if (a < b):
    list = [i for i in range(b+1) if (a % i == 0 && b % i == 0 && i != 0)]
    ans = list[k-1]
else:
    list = [i for i in range(a+1) if (a % i == 0 && b % i == 0 && i != 0)]
    ans = list[k-1]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(sorted(yakusuu)[K+1])

Submission status: Runtime Error

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

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

if warikiru == []:
    print(1)
else:
    print(warikiru[-1::-1][K-1])

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=int(input())
count=0
minab=min(a,b)
minabb=int(minab)/2
flag=0
for i in range(int(minab),0,-1):
        if(a%i==0 and b%i==0 and count<c):
                count+=1
        if(a%i==0 and b%i==0 and count==c):
                print(i)
                flag=1
                break
        
        else:
                continue

Submission status: Runtime Error

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

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

igcd = fgcd(A,B)
if igcd == 1:
    print(1)
else:
    aP = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97)
    aD =[igcd,1]
    for eP in aP:
        if igcd % eP == 0:
            aD.append(eP)
            i = 1
            while igcd % (eP**i) == 0 :
                aD.append(igcd // (eP ** i))
                i += 1
    aD = sorted(list(set(aD)),reverse=True)
    print(aD[K-1])

Submission status: Runtime Error

Solution code:
a, b, k = map(int, input().split())
l1 = [i for i in range(1, a) if (a % i == 0)]
l2 = [i for i in range(1, b) if (b % i == 0)]
l = list(set(l1) & set(l2))
l.sort()
print(l[k-1])

Submission status: Runtime Error

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

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

print(sorted(yakusuu)[K+1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
import sys
a,b,k = map(int, input().split())
c = math.gcd(a, b)
ls = []
for i in range(1, c):
    if c % i == 0:
        ls.append(i)
ls.append(c)
ls.sort(reverse=True)
print(ls[k-1])

Submission status: Runtime Error

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

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

a_list.extend(b_list)
co_divisor = list(set(a_list))
print(co_divisor[k-1])

Submission status: Runtime Error

Solution code:
from math import gcd

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

Submission status: Runtime Error

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

ans = 0

if (a < b):
    list = [i for i in range(b) if a % i == 0 && b % i == 0 && i != 0]
    ans = list[k-1]
else:
    list = [i for i in range(a) if a % i == 0 && b % i == 0 && i != 0]
    ans = list[k-1]

print(ans)

Submission status: Runtime Error

Solution code:
a,b,k = map(int,input().split())
x=0
y=[0]
c=min(a,b)

if a==1 or b==1:
    print(1)
    exit()
    
for d in range(1,c):
    if a%d==0 and b%d==0:
            y.append(d)

print(y[k])

Submission status: Runtime Error

Solution code:
def main():
  A, B, K = map(int, input().split(" "))
 
  i = 1
  result = []
  while i <= min(A, B):
    if A % i == 0 and B % i == 0:
      result.append(i)
    i += 1
  print(result[-K])
 
 if __name__ == '__main__':
  main()

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:
import math
nums=list(map(int,input().split(" ")))
g=math.gcd(nums[0],nums[1])
arr=[0 for i in range(100)]
a=0
for i in range(100):
    i+=1
    if nums[0]%i==0 and nums[1]%i==0:
        arr[a]=i
        a+=1
        if i==g:
            print(arr[a-nums[2]])
            break

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a, b, k = map(int, input().split())
if a > b:
    t = a
    a = b
    b = t
# 0<a<b<100
fact = []
for i in range(1,a+1,):
    if a%i==0 and b%i==0:
        count = count + 1
        fact.append(i)
print(fact[-k])

Submission status: Runtime Error

Solution code:
a,b,k = map(int,input().split())
x=0
y=[0]
c=min(a,b)

if a==1 or b==1:
    print(1)
    exit()
    
for d in range(1,c):
    if a%d==0 and b%d==0:
            y.append(d)

print(y[k])
print(y)

Submission status: Runtime Error

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

ans = 0

if (a < b):
    list = [i for i in range(b) if a % i == 0 && b % i == 0]
    ans = list[k-1]
else:
    list = [i for i in range(a) if a % i == 0 && b % i == 0]
    ans = list[k-1]

print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin


def b(input_string):
    a, b, k = [int(x) for x in input_string.split()]
    mod_0_numbers = []
    if a >= b:
        for i in range(1, a):
            if a % i == 0:
                if b % i == 0:
                    mod_0_numbers.append(i)
    else:
        for i in range(1, b):
            if b % i == 0:
                if a % i == 0:
                    mod_0_numbers.append(i)
    return mod_0_numbers[-k]


def main():
    input_line = stdin.readline().rstrip()
    answer = b(input_line)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

S = [1]

for i in range(2,min(A,B)):
    if A % i == 0 or B % i == 0:
        S.append(i)

S.sort(reverse=True)

print(S[K-1])

Submission status: Runtime Error

Solution code:
x,y,z = map(int,input().split())
n = (y if x < y else x) 
array = []
for i in range(1,n):
	if (x%i==0 and y%i==0):
		array.append(i)
array.reverse()
print(array[z-1])

Submission status: Runtime Error

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

for i in range(1, a):
    if a % i == 0:
        li.append(i)
    else:
        continue

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

li2 =[]
for n in range(len(li)):
    if li.count(li[n]) == 2:
        li[n] = num
        li2.append(num)
        li.remove(num)
        li.remove(num)
    else:
        continue

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

Submission status: Runtime Error

Solution code:
import math

a,b,c=map(int,input().split())
lis=[]
for i in range(1,a):
	if b%i==0 and a%i==0:
		lis.append(i)
lis=sorted(lis,reverse=True)
print(lis[c-1])