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: Wrong Answer

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

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

    try:
        print(S[-K])
    except:
        print("1")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys


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

cnt = 0
tnum = A if A >= B  else B

for i in range(tnum):
    divisor_num = i + 1
    if (A % divisor_num == 0) and (B % divisor_num == 0):
        cnt += 1
        if cnt == K:
            print(divisor_num)
            sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  c=a//b
  d=a%b
  
  if d==0:
    return b
  else:
    return gcd(b,d)
  
  
a,b,k=map(int,input().split())

count=0
for i in range(1,gcd(a,b)+1):
  if gcd(a,b)%i==0:
    count+=1
    if count==k:
      print(gcd(a,b)//count)
      break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print (n - 1)

Submission status: Wrong Answer

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

al = [a/i for i in range(1,a+1) if len(str(a/i)) == 3]
bl = [b/i for i in range(1,b+1) if len(str(b/i)) == 3]

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

print(int(cd[k-1]))

Submission status: Wrong Answer

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

al = [a/i for i in range(1,a+1) if len(str(a/i)) == 3]
bl = [b/i for i in range(1,b+1) if len(str(b/i)) == 3]

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

print(int(cd[-k]))

Submission status: Wrong Answer

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

al = [a/i for i in range(1,a+1) if len(str(a/i)) == 3]
bl = [b/i for i in range(1,b+1) if len(str(b/i)) == 3]

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

print(int(cd[k-1]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(b%a, a)
if __name__ == '__main__':
    A, B, K = map(int, input().split())
    primes = [2, 3, 5, 7]
    cds = [gcd(A, B)]
    for p in primes:
        for cd in cds:
            if cd%p == 0:
                cds.append(cd//p)
                if p not in cds:
                    cds.append(p)
    cds.append(1)
    cds.sort(reverse=True)
    print(cds[K-1])

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(b%a, a)
if __name__ == '__main__':
    A, B, K = map(int, input().split())
    primes = [2, 3, 5, 7]
    GCD = gcd(A, B)
    for p in primes:
        while GCD%p == 0:
            if K <= 1:
                break
            GCD = GCD//p
            K -= 1
    print(GCD)

Submission status: Wrong Answer

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

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

print(divisors[-k])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(result[k - 1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
ans = 0
for i in range(N):
  for j in range(i, N):
    if all('ACGT'.count(c) == 1 for c in S[i:j+1]):
      ans += max(ans, j-i+1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A, B, K = map(int, input().split())
g = gcd(A, B)
k = 1
r = 0
while True:
  if k > min(A, B):
    print(g)
    exit(0)
  if r == K:
    print(g)
    exit(0)
  if g % k == 0:
    g = g // k
    r += 1
  k += 1

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A, B, K = map(int, input().split())
g = gcd(A, B)
k = 1
while True:
  if k == K:
    print(g)
    exit(0)
  if g % k == 0:
    g = g // k
    k += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


print(list[k-1])

Submission status: Wrong Answer

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

div = []

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

print(div)
print(div[-K])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

div_a = set()
div_b = set()

for i in range(1, 100):
    if a % i == 0:
        div_a.add(i)
    if b % i == 0:
        div_b.add(i)

ans = sorted(list(div_a & div_b))
print(ans[-k])

Submission status: Wrong Answer

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

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

print(d[K - 1])

Submission status: Wrong Answer

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

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

else :
    C=A
    A=B
    B=C

#A<B

li=[]

for i in range(1,B+1):
    #print(i)
    if A%i==0 and B%i==0:
        li.append(i)

A%1
#print(li)        
        
if len(li)==1: 
    print(A)
else:
    print(li[-K])

Submission status: Wrong Answer

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

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

else :
    C=A
    A=B
    B=C

#A<B

li=[]

for i in range(1,B+1):
    #print(i)
    if A%i==0 and B%i==0:
        li.append(i)

A%1
#print(li)        
        
if len(li)==1: 
    print(A)
else:
    print(li[-K])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(li)
print(li[len(li)-K])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Wrong Answer

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

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

else :
    C=A
    A=B
    B=C

#A<B

li=[]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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


cf_list = cf(A, B)
print(cf_list[C - 1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if B > A:
    tmp = B
    B = A
    A = tmp
sort = [x for x in range(1, B + 1) if A % x == 0 and B % x == 0]

print(sort[K - 1])

Submission status: Wrong Answer

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

if B > A:
    tmp = B
    B = A
    A = tmp
sort = [x for x in range(1, B + 1) if A % x == 0 and B % x == 0]

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

Submission status: Wrong Answer

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

divA = [x for x in range(1, A + 1) if A % x == 0]
divB = [y for y in range(1, B + 1) if B % y == 0]
ss = divA + divB
s = set(ss)
sort = sorted(s)
print(sort[K - 1])

Submission status: Wrong Answer

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

divA = [x for x in range(1, A + 1) if A % x == 0]
divB = [y for y in range(1, B + 1) if B % y == 0]
s = divA + divB
s = set(s)
sort = sorted(s)
print(sort[K - 1])

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
c = 0
ans = 0
for i in range(min(A, B)):
    if A % (i + 1) == 0 and B % (i + 1) == 0:
        ans = i + 1
        c += 1
        if c == K:
            print(ans)
            exit()
        else:
            pass

Submission status: Wrong Answer

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

cnt = 0
arr = []
for i in range(1, max(a, b)+1):
    if len(arr) == k:
        break
    if a % i == 0 and b % i == 0:
        arr.append(i)


print(arr[-1])

Submission status: Wrong Answer

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

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

print(li[K-1])

Submission status: Wrong Answer

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

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

print(li[K-1])

Submission status: Wrong Answer

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

cnt = 0
for i in range(gcd,1,-1):
  if gcd % i == 0:
    cnt += 1
    if cnt == K:
      print (i)
      break

Submission status: Wrong Answer

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

    for j in range(abs(len(c)-k)):
        c.remove(max(c))

    print(max(c))


if __name__ == "__main__":
    test()

Submission status: Wrong Answer

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

    print(c)

    for j in range(abs(len(c)-k)):
        c.remove(max(c))

    print(c)
    print(max(c))


if __name__ == "__main__":
    test()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, k = map(int, input().split())
    print(make_divisors(a*b)[k-1])


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

gcd=fractions.gcd(a,b)
count=0
for i in range(1, gcd):
  if gcd%i==0:
    count+=1
    if count==k:
      print(gcd//i)
      break

Submission status: Wrong Answer

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

for num in range(1,a+1):
  if(a%num==0 and b%num==0):
    c.append(num)

print(str(c[k-1]))

Submission status: Wrong Answer

Solution code:
A, B, K=map(int, input().split())
if A>B:
    tmp=A
    A=B
    B=tmp
count=0
for i in range(A, 0, -1):
    if A%i ==0 & B%i==0:
        count+=1
    if count ==K:
        break
print(i)

Submission status: Wrong Answer

Solution code:
A, B, K=map(int, input().split())
if A>B:
    tmp=A
    A=B
    B=tmp
count=0
for i in range(1,A+1):
    if A%i ==0 & B%i==0:
        count+=1
    if count ==K:
        break
print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


A,B,K =map(int,input().split())
k = 0
for i in range(1, 101):
    if (A % K) == 0 and (B % K) ==0:
        k += 1
    if k == K:
        break
print(i)

Submission status: Wrong Answer

Solution code:


A,B,K =map(int,input().split())
k = 0
for i in range(1, 101):
    if A % K == 0 and B % K ==0:
        k += 1
    if k == K:
        break
print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a_list = []
for num in range(1, A + 1):
  if A % num == 0:
    a_list.append(num)

list = []
for num in a_list:
  if B % num == 0:
    list.append(num)
print(list[K-1])

Submission status: Wrong Answer

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

for i in range(1,a+1):
    if a%i == 0:
        al.append(a//i)
else:
    sorted(al)

for j in range(1,b+1):
    if b%j == 0:
        bl.append(b//j)
else:
    sorted(bl)

m = len(al)
n = len(bl)    

if a >= b:
    for s in range(n):
        if bl[s] in al :
            cl.append(bl[s])
elif a < b:
    for t in range(m):
        if al[t] in bl :
            cl.append(al[t])

sorted(cl)
print(cl[-k])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
count = 0
n = 0
while True:
    n += 1
    if a % n == 0 and b % n == 0:
        count += 1
        if count == k:
            print(n)
            break

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
count = 0
n = 0
while True:
    n += 1
    if a % n == 0 & b % n == 0:
        count += 1
        if count == k:
            print(n)
            break

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
count = 0
n = 1
while True:
    if a % n == 0 & b % n == 0:
        count += 1
        if count == k:
            print(n)
            break
    n += 1

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
count = 0
n = 1
while True:
    if a % n == 0 & b % n == 0:
        count += 1
        print(count)
        if count == k:
            print(n)
            break
    n += 1

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
count = 0
n = 1
while True:
    if a % n == 0 & b % n == 0:
        count += 1
        if count == k:
            print(n)
            break
        n += 1

Submission status: Wrong Answer

Solution code:
a, b , k = map(int, input().split(' '))
count = 0
result = 1
if a < b:
    i = a
else:
    i = b
while count != k:
    if a%i == 0 and b%i == 0:
        count += 1
        result = i
        print(i)
    i -= 1
print(result)

Submission status: Wrong Answer

Solution code:
a, b , k = map(int, input().split(' '))
count = 0
result = 1
i= 1
while count != k:
    if a%i == 0 and b%i == 0:
        count += 1
        result = i
    i += 1
print(result)

Submission status: Wrong Answer

Solution code:
a, b , k = map(int, input().split(' '))
count = 1
result = 1
i= 1
while count != k:
    if a%i == 0 and b%i == 0:
        count += 1
        result = i
    i += 1
print(result)

Submission status: Wrong Answer

Solution code:
a, b , k = map(int, input().split(' '))
count = 1
result = 0
i= 1
while count != k:
    if a%i == 0 and b%i == 0:
        count += 1
        result = i
    i += 1
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,k=map(int, input().split())
s = []
for i in range(min(A,B)):
    if A%(i+1)==0 and B%(i+1)==0:
        s.append(i+1)
sorted(s, reverse=True)
print(s[k-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# import numpy as np
# import copy

def main():
    a,b,k = [int(i) for i in input().split(' ')]
    
    count = 1
    kc = 0
    while True:
        if a%count == 0 and b%count == 0:
            kc = kc +1


            if kc == k:
                print(count)
                break
        count = count + 1

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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: Wrong Answer

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)
print(ans[k-1])

Submission status: Wrong Answer

Solution code:
a,b,k= map(int, input().split())
i=1
j=1
while j!=k :
    i+=1
    if a%i==0 and b%i==0:
      j+=1

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
flag = 0
min_number = min(A,B)
for i in range(1,min_number+1):
    if A%i==0 and B%i==0:
        flag +=1
        #print(flag,i)
        if flag==K:
            print(i)
            break
    elif i==min_number:
        flag = 0
        print(flag)

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
flag = 0
max_number = max(A,B)
for i in range(1,max_number+1):
    if A%i==0 and B%i==0:
        flag +=1
        if flag==K:
            print(K)
            break
    elif i==max_number:
        flag = 0
        print(flag)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
a = make_divisors(A)
b = make_divisors(B)
c = sorted(set(a)&set(b))
print(c,list(c)[-K])

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
a = make_divisors(A)
b = make_divisors(B)
c = (set(a)&set(b))
print(list(c)[-K])

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
a = make_divisors(A)
b = make_divisors(B)
c = (set(a)&set(b))
print(c)
print(list(c)[-K])

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
a = make_divisors(A)
b = make_divisors(B)
c = (set(a)&set(b))
print(list(c)[-K+1])

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
a = make_divisors(A)
b = make_divisors(B)
c = (set(a)&set(b))
print(list(c)[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()

S = S.split()

S = list(map(int, S))

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

list = []

if A >= B:
  C = A
else:
  C = B

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

print(list[K-1])

Submission status: Wrong Answer

Solution code:
from fractions import*
a,b,k=map(int,input().split());c=0
for i in range(a,0,-1):
  print(i)
  c+=(gcd(a,b)%i==0)
  if c==k:print(i)

Submission status: Wrong Answer

Solution code:
from fractions import*
a,b,k=map(int,input().split());c=0
for i in range(a,0,-1):
  c+=gcd(a,b)%i==0
  if c==k:print(i)

Submission status: Wrong Answer

Solution code:
from fractions import*
a,b,k=map(int,input().split());c=0
for i in range(a+1,1,-1):
  if not gcd(a,b)%i:
    c+=1
    if c==k:print(i)

Submission status: Wrong Answer

Solution code:
from fractions import*
a,b,k=map(int,input().split());s=[0]
for i in range(1,a+1):
  if not gcd(a,b)%i:s+=[i]
print(s[k])

Submission status: Wrong Answer

Solution code:
str_in = input().split()
a = int(str_in[0])
b = int(str_in[1])
k = int(str_in[2])

if(a >= b):
  div = b
else:
  div = a

cnt = 0

for i in range(div):
  res_a = a % (div - i)
  res_b = b % (div - i)
  
  print(res_a, res_b, div-i,cnt)

  if ((res_a == 0) & (res_b == 0)):
    cnt += 1
    if(cnt == k):
      print (div - i)
      break

Submission status: Wrong Answer

Solution code:
def factor(num):
    factor_set = set()
    for i in range(1,num+1):
        if num%i == 0:
            factor_set.add(i)
    return factor_set

l = [int(i) for i in input().split(" ")]
a = l[0]
b = l[1]
k = l[2]

and_list = sorted(list(factor(a) & factor(b)))
print(and_list[k-1])

Submission status: Wrong Answer

Solution code:
def factor(num):
    factor_set = set()
    for i in range(1,num+1):
        if num%i == 0:
            factor_set.add(i)
    return factor_set

l = [int(i) for i in input().split(" ")]
a = l[0]
b = l[1]
k = l[2]

and_list = sorted(list(factor(a) & factor(b)))
print(and_list)
print(and_list[k-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
index = 0
for i in range(100, 0, -1):
  if A / i == 0 and B / i == 0:
    index += 1
    if(K == index):
      print(i)

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())
index = 0
for i in range(100, 0, -1):
  if int(A / i) == 0 and int(B / i) == 0:
    index += 1
    if(K == i):
      print(i)

Submission status: Wrong Answer

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