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:
A,B,K=map(int,input().split())
ans=0
for i in range (1,min(A,B)+1):
    if A%i==0 and B%i==0:
        ans+=1
        if ans==K:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
import sys
import os
import math

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

C = min(A, B)
hairetu = []

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

print(hairetu[K-1])

Submission status: Wrong Answer

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

li = list()
for i in range(1,101):
    if A % i == 0:
        if B % i == 0:
            li.append(i)

print(li[K-1])

Submission status: Wrong Answer

Solution code:

import math

def resolve():
    inp = input()
    li = list(map(lambda x: int(x), inp.split(" ")))
    a = li[0]
    b = li[1]
    k = li[2]
    g = math.gcd(a, b)

    for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

a,b,k = map(int,input().split())
r = gcd(a,b)
e = []
for i in range(1,r+1):
    if r%i == 0:
        e.append(i)
print(e[k-1])

Submission status: Wrong Answer

Solution code:
A,B,K=map(int,input().split())
for i in range(1,101):
  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
for i in range(1,100)[::-1]:
  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(1,100):
  if a%i==0 and b%i==0:
    cnt+=1
  if cnt==k:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

A,B,K=map(int,input().split())
l1=divisor(A)
l2=divisor(B)
cnt=0
for a in l1:
  for b in l2:
    if a==b:
      cnt+=1
    if cnt==K:
      print(a)
      exit()

Submission status: Wrong Answer

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

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

a_y = set(make_divisors(a))
b_y = set(make_divisors(b))
#print(a_y & b_y)
y = list(a_y & b_y)

print(y[k-1])

Submission status: Wrong Answer

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
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
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b,c=map(int,input().split())
n=lcm(a,b)
ans=make_divisors(n)
print(ans[c-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(lis[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, k  = map(int, input().split())
c = 0
ans = []
if a > b:
  c = b
else:
  c = a

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


print(ans[k-1])

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
a_yaku = []
b_yaku = []
for i in range(1, min(A,B)+1):
    if A % i == 0:
        a_yaku.append(i)
for q in range(1, min(A,B)+1):
    if B % q == 0:
        b_yaku.append(q)

a_set = set(a_yaku)
b_set = set(b_yaku)

s_inter = a_set & b_set
uni = list(s_inter)
uni.reverse()

print(uni[K-1])

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
a_yaku = []
b_yaku = []
for i in range(1, A+1):
    if A % i == 0:
        a_yaku.append(i)
for q in range(1, B+1):
    if B % q == 0:
        b_yaku.append(q)

a_set = set(a_yaku)
b_set = set(b_yaku)

s_inter = a_set & b_set
uni = list(s_inter)
uni.reverse()

print(uni[K-1])

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
temp = 0
for i in range(1, max(A, B)+1):
    if A % i == 0 and B % i == 0:
        temp += 1
    if temp == K:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
temp = 0
for i in range(1, max(A, B)+1):
    if A % 2 == 0 and B % 2 == 0:
        temp += 1
    if temp == K:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
yaku = []
for i in range(1, A+1):
    if A % i == 0:
        yaku.append(i)
for q in range(1, B+1):
    if B % q == 0:
        yaku.append(q)


l_unique = list(set(yaku))

l_unique.sort()

print(l_unique[K-1])

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
yaku = []
for i in range(1, A+1):
    if A % i == 0:
        yaku.append(i)
for i in range(1, B+1):
    if B % i == 0:
        yaku.append(i)


l_unique = list(set(yaku))
l_unique.sort()
print(l_unique[K-1])

Submission status: Wrong Answer

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

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

print(list(reversed(list(set(divisor(A)) & set(divisor(B)))))[K-1])

Submission status: Wrong Answer

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

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

print(list(set(divisor(A)) & set(divisor(B)))[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# abc120_b.py
A, B, K = map(int,input().split())
cnt = 0
for i in range(1,10000):
    if A%i==0 or B%i==0:
        cnt += 1
        if cnt == K:
            print(i)
            exit()

Submission status: Wrong Answer

Solution code:
# abc120_b.py
A, B, K = map(int,input().split())
cnt = 0
for i in range(1,10000):
    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 = list(map(int, input().split()))

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

print(ans)

Submission status: Wrong Answer

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

ans=0
res=0
for i in range(1, min(A, B)+1):
    if A%i==0 and B%i==0:
        res+=1
        if res==2:
            ans=i
            break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


A, B, K = map(int, input().split())
A_yaku = make_divisors(A)
B_yaku = make_divisors(B)
A_B_yaku = list(set(A_yaku) & set(B_yaku))
print(A_B_yaku[len(A_B_yaku) - K])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

check = a if a < b else b

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = []

for i in range(1, 101):
    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())


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


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

ans = list(a & b)

print(ans[k - 1])

Submission status: Wrong Answer

Solution code:
a,b,k=map(int,input().split())
n=0
for i in range(min(a,b),0,-1):
    if (a/i==a//i) and (b/i==b//i):
        print(i)
        n+=1
        if n==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) + 1, 1):
  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())

count = 0

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

Submission status: Wrong Answer

Solution code:
A,B,K=map(int,input().split())
l=[]
for i in range(max(A,B)):
    if A%(i+1)==0 and B%(i+1)==0: l.append(i+1)
l.sort(key=int)
print(l[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):
  if a%i==0 & b%i==0:
    count+=1
    if count==k:
      print(i)
      break
  else:
    continue

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 & b%i==0:
    count+=1
    if count==k:
      print(i)
      break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def yakusu(num):
    list_a = []
    for i in range(1, num//2 + 1):
        if num % i == 0:
            list_a.append(i)
    list_a.append(num)
    return list_a

cd = []

for i in range(len(yakusu(A))):
    for j in range(len(yakusu(B))):
        if yakusu(A)[i] == yakusu(B)[j]:
            d = yakusu(A)[i]
            cd.append(d)
            
arr = set(cd)
x = list(arr)
print(x[int(K - 1)])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

A, B, K = map(int, input().split())
n = 0
for i in range(1,100):
    if A % i == 0 and B % i == 0:
        n += 1
    else:
        pass
    
    if n == K:
        ans = i
        break

print(ans)

Submission status: Wrong Answer

Solution code:

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

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())
count = 0
for i in range(101,0,-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())
result=[]
n=1
while n<=100:
    if a%n==0 and b%n==0:
        result.append(n)
    n+=1
print(result[k-1])

Submission status: Wrong Answer

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

# check
if K == 1:
    print(1)
else:
    cnt = 1
    op = 1
    for i in range(2, 101):
        if A % i == 0 and B % i == 0:
            cnt += 1
            op = i
        if cnt == K:
            break
    print(op)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

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

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:
            print(i)
            exit()

Submission status: Wrong Answer

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

import math
def divisor(n):
    a = set()
    for i in range(1, math.ceil(n**0.5) + 1):
        if n % i == 0:
            a.add(i)
            a.add(n // i)
    return a

d = divisor(g)
ans = list(d)
ans.sort()
print(ans[k-1])

Submission status: Wrong Answer

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

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

    S.append(i)

print(S[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1,min(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())
cnt=0

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

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

a,b,k = MI()
c = 0
for i in range(a-1):
    s = a-i
    if a % s == 0 and b % s == 0:
        c += 1
    if c == k:
        print(s)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

a,b,k = MI()
c = 0
for i in range(a):
    s = i + 1
    if a % s == 0 and b % s == 0:
        c += 1
    if c == k:
        print(s)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
a, b, k = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

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

Submission status: Wrong Answer

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

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

abset = list(set(a)&set(b))[::-1]

print(abset[K-1])

Submission status: Wrong Answer

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

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

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

print(abset[K-1])

Submission status: Wrong Answer

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

    if c == k:
        print (i)
        exit ()

Submission status: Wrong Answer

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

num_list = []

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


print(num_list[-k])

Submission status: Wrong Answer

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

num_list = []

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

# num_list.sort(reverse = True)

print(num_list[-k])

Submission status: Wrong Answer

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

num_list = []

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

# num_list.sort(reverse = True)

print(num_list[-k])

Submission status: Wrong Answer

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

num_list = []

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

# num_list.sort(reverse = True)

print(num_list[k-1])

Submission status: Wrong Answer

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

num_list = []

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

num_list.sort(reverse = True)

print(num_list[k-1])

Submission status: Wrong Answer

Solution code:
def cf(A,B):
    l=[]
    for i in range(1,min(A,B)+1):
        if A % i == 0 and B % i == 0:
            l.append(i)
    return l

def main():
    A, B, K = map(int,input().split())
    koyaku = cf(A,B)
    #print(koyaku)
    print(koyaku[-1])
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

num_list = []

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

print(num_list[k-1])

Submission status: Wrong Answer

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

num_list = []

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

print(num_list[k-1])

Submission status: Wrong Answer

Solution code:
def cf(A,B):
    l=[]
    for i in range(1,min(A,B)+1):
        if A % i == 0 and B % i == 0:
            l.append(i)
    return l

def main():
    A, B, K = map(int,input().split())
    koyaku = cf(A,B)
    #print(koyaku)
    print(koyaku[K-1])
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

A,B,K = inputIL()

c = 0
for i in range(1,max(A,B)+1):
  if A%i == B%i == 0:
    c += 1
    if K == c:
      print(i)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


def main():
    A, B, K = map(int, input().split())
    d = gcd(A, B)
    div = [1]
    div2 = [d]
    root = int(d ** 0.5)
    for i in range(2, root):
            if d % i == 0:
                div.append(i)
                div2.append(d // i)
    if root ** 2 == d:
        div.append(root)
    div2.reverse()
    div = div + div2
    for _ in range(K - 1): div.pop()
    print(div[-1])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
lst = []
for i in range(1, 100)[::-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())
A=[]

for i in range(1,101):
    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())
l=[]
p=A
q=B
if A>B:
    A=q
    B=p
for i in range(1,B+1):
    if A%i==0 and B%i==0:
        l.append(i)
print(l)
print(l[len(l)-K])