qyliang/CodeNanoFix huggingface dataset:
Buggy code:
A,B,K = map(int,input().split())
min_n = min(A,B)
gcd_ = []

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

print(gcd_[K-1])

Fixed code:
A,B,K = map(int,input().split())
min_n = min(A,B)
gcd_ = []

for i in range(1,min_n+1):
  if A%i == 0 and B%i == 0:
    gcd_.append(i)
gcd_.sort(reverse=True)
print(gcd_[K-1])
Buggy code:
n,m,k=map(int,input().split())
for i in range(1,101):
	if n%i==0 and m%i==0:
		k-=1
		if k==0:
			print(i)
			exit() 

Fixed code:
n,m,k=map(int,input().split())
for i in range(min(n,m),0,-1):
	if n%i==0 and m%i==0:
		k-=1
		if k==0:
			print(i)
			exit()
Buggy code:
a,b,k = map(int,input().split())
s = min(a,b)
A = []
for i in range(1,s+1):
    if a%i == 0 and b%i == 0:
        A.append(i)
A = sorted(A)
print(A[k-1])

Fixed code:
a,b,k = map(int,input().split())
s = min(a,b)
A = []
for i in range(1,s+1):
    if a%i == 0 and b%i == 0:
        A.append(i)
A = sorted(A,reverse=True)
print(A[k-1])
Buggy 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_div = make_divisors(a)
b_div = make_divisors(b)
div_list = a_div + b_div

ans = [x for x in set(div_list) if div_list.count(x) > 1]

print(sorted(ans[-k]))

Fixed 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_div = make_divisors(a)
b_div = make_divisors(b)
div_list = a_div + b_div

ans = sorted([x for x in set(div_list) if div_list.count(x) > 1])

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



Fixed code:
a,b,k=map(int,input().split())
l=[1]
n=min(a,b)
for i in range(2,n+1):
    if a%i==0 and b%i==0:
        l.append(i)
l.reverse()
print(l[k-1])
Buggy code:
import sys

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return a


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

j=0
for i in range(1,gcd+1):
    if gcd%i==0:
        j+=1
    if j==k:
        print(i)
        sys.exit()


Fixed code:
import sys

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return a


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


j=0
for i in range(gcd,0,-1):
    if gcd%i==0:
        j+=1
    if j==k:
        print(i)
        sys.exit()
Buggy code:
A, B, K = map(int, input().split())
d = [i for i in range(100,1,-1) if (A%i==0 and B%i==0)]
print(d[K-1])


Fixed code:
A, B, K = map(int, input().split())
d = [i for i in range(100,0,-1) if (A%i==0 and B%i==0)]
print(d[K-1])
Buggy 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])

Fixed code:
a,b,k=map(int,input().split())
d=[]
for i in range(1,101):
  if(a%i==0 and b%i==0):
    d.append(i)
e=d[::-1]
print(int(e[k-1]))
Buggy 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])

Fixed 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)])
Buggy code:
a,b,k = map(int,input().split())

l = []

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


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

l = []

for i in range(1,101):
	if a % i == 0 and b % i == 0:
		l.append(i)
        
print(l[len(l)-k])
Buggy code:
A, B, K = map(int, input().split())

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

print(lst[K-1])


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

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

print(lst[-K])
Buggy 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)

Fixed 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)
Buggy code:
A,B,K=map(int,input().split())
cd=A
if A>B:
    cd=B
l=[]
for i in range(1,cd+1):
    if A%i==0 and B%i==0:
        l.append(i)
print(l[K-1])

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

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

Fixed code:
A,B,K=map(int,input().split());print([i for i in range(A,0,-1)if 1>A%i+B%i][K-1])
Buggy 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

Fixed 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 list(reversed(range(1, min + 1))):
    if max % i == 0 and min % i == 0:
        k += 1
        if k == a[2]:
            print(i)
            break
Buggy 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])

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

list3 = list(set(list1) & set(list2))
list3.sort()
list3.reverse()

print(list3[max -1])
Buggy 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])

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

count = 0
cand = []
denom = 0

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

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

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

cnt = 0
for i in range(25):
    if (a % (i+1) == 0) and (b % (i+1) == 0):
        cnt += 1
    if cnt == k:
        print(i+1)
        exit()


Fixed code:
a, b, k = map(int, input().split())
cnt = 0
for i in range(a, 0, -1):
    if a % i == 0 and b % i == 0:
        cnt += 1
        if cnt == k:
            print(i)
            exit()
Buggy code:
A,B,K=(int(i) for i in input().split()) 
L=[]

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

Fixed code:
A,B,K=map(int,input().split())
l=[]
for i in range(min(A,B)):
    if A%(i+1)==0 and B%(i+1)==0: 
        l.append(i+1)
print(l[-K])
Buggy code:
a,b,k=[int(s) for s in input().split()]
x=0
i=1
while True:
  if a%i==0 and b%i==0:
    x+=1
  if x==k:
    print(i)
    break

Fixed code:
a,b,k=[int(s) for s in input().split()]
x=0
i=min([a,b])
while True:
  if a%i==0 and b%i==0:
    x+=1
  if x==k:
    print(i)
    break
  i-=1
Buggy code:
A,B,K=(int(i) for i in input().split()) 
j=1
L=[]

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

Fixed code:
A,B,K=(int(i) for i in input().split()) 
L=[]
 
for i in range(1,min(A,B)+1):
  if A%i==0 and B%i==0:
    L.append(i)
L=L[::-1]
print(L[K-1])
Buggy code:
a, b, k = map(int, input().split())

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

print(e[k-1])



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

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

e.reverse()
print(e[k-1])
Buggy code:
# coding: utf-8
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)


Fixed code:
# coding: utf-8
a, b, k = map(int, input().split())
cnt = []
for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        cnt.append(i)
print(cnt[-k])
Buggy code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

print(ans[k-1])

Fixed code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

print(ans[-k])
Buggy code:
A, B, K = map(int, input().split())
cnt = 0
curr = 1
for i in range(1, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        cnt += 1
        curr = i
    if cnt == K:
        break

Fixed code:
A, B, K = map(int, input().split())
cnt = 0
curr = 1
for i in range(min(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        cnt += 1
        curr = i
    if cnt == K:
        break
    
print(curr)
Buggy code:
a, b, k = map(int, input().split())
ans = [e for e in range(1, min(a, b) // 2 + 1) if (a % e) + (b % e) == 0]
print(ans[-k])

Fixed code:
a, b, k = map(int, input().split())
ans = [e for e in range(1, min(a, b) + 1) if (a % e) + (b % e) == 0]
print(ans[-k])
Buggy code:
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
 
A,B,K = [int(i) for i in input().split()]

i = 100
count = 0
while(i<1):
 
    if is_integer_num(A/i) and is_integer_num(B/i):
        count = count+1
 
    if count == K:
        print(i)
        break    
    
    i = i-1

Fixed code:
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
 
A,B,K = [int(i) for i in input().split()]

i = 100
count = 0
while(i>0):
    
    if is_integer_num(A/i) and is_integer_num(B/i):
        count = count+1
 
    if count == K:
        print(i)
        break    
    
    i = i-1
Buggy code:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=0
if a>=b:
  for i in range(101):
    if a%(b-i)==0 and b%(b-i)==0:
      d=d+1
      if d==c:
        print(i)
        break
if a<b:
  for i in range(101):
    if a%(a-i)==0 and b%(a-i)==0:
      d=d+1
      if d==c:
        print(i)
        break

Fixed code:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=0
if a>=b:
  for i in range(101):
    if a%(b-i)==0 and b%(b-i)==0:
      d=d+1
      if d==c:
        print(b-i)
        break
if a<b:
  for i in range(101):
    if a%(a-i)==0 and b%(a-i)==0:
      d=d+1
      if d==c:
        print(a-i)
        break
Buggy code:
A, B, K = map(int, input().split())

max_num = max(A, B)
min_num = min(A, B)
divs = [m for m in range(1, min_num+1) if min_num % m == 0]

ans = []
for d in divs:
    if max_num % d == 0:
        ans.append(d)
print(ans[K-1])


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

max_num = max(A, B)
min_num = min(A, B)
divs = [m for m in range(1, min_num+1) if min_num % m == 0]

ans = []
for d in divs:
    if max_num % d == 0:
        ans.append(d)
ans = sorted(ans)[::-1]
print(ans[K-1])
Buggy 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])

Fixed 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])
Buggy code:
A, B, K = map(int, input().split())
a=[]
b=[]
if A>=B:
  for i in range(1,A+1): # i = [1,2,3,4,....A]
    if A%i==0 and B%i==0:
      a.append( A/i )
      b.append( B/i )
  
else:
  for i in range(1,B+1): # i = [1,2,3,4,....A]
    if A%i==0 and B%i==0:
      a.append( A/i )
      b.append( B/i )

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

print(c[K])
    


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

#print(a)
#print(b)

#c=[]
#for ea in a:
 # if ea in b:
  #  c.append( ea )
c=len(a)
print(a[c-K])
Buggy code:
a, b, k = map(int, input().split())

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


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

for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
            print(i)
            break
Buggy 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()


Fixed 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)
            exit()
Buggy code:
A,B,K = map(int,input().split())
ans_list = list()

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

print(ans_list[K-1])

Fixed code:
A,B,K = map(int,input().split())
ans_list = list()
for i in range(1,min(A,B)+1):
	if A%(i) == 0 and B%(i) == 0:
		ans_list.append(i)
print(ans_list[-1*K])
Buggy 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])

Fixed 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(list(c)[-K])
Buggy code:
if __name__ == '__main__':
    A, B, K = map(int, input().split())

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

    print(answer)

Fixed code:
if __name__ == '__main__':
    A, B, K = map(int, input().split())

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

    print(answer)
Buggy code:
A,B,K = map(int,input().split())

i=0
j=1
while i<K:
  if A%j=0 and B%j=0:
     i +=1
  else:
     i =i
  j+=1

print(j)
  


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

i=0
j=100
while i<K:
    if A%j==0 and B%j==0:
        i +=1
    else:
        i =i
    j-=1

print(j+1)
Buggy code:
def main():
    a,b,k = map(int,input().split())
    counter = 0

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



if __name__ == '__main__':
    main()

Fixed code:
def main():
    a,b,k = map(int,input().split())
    counter = 0

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



if __name__ == '__main__':
    main()
Buggy 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)
            exit()

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

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

m = max(a,b)
c = 0;

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

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

m = max(a,b)
c = 0;

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


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

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

print(ans)      

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

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

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

Fixed code:
A,B,K = map(int,input().split())
tmp = []
for i in range(100):
    if A%(i+1) == 0:
        if B%(i+1) == 0:
            tmp.append(i+1)
print(tmp[len(tmp)-K])
Buggy 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
    
lstA = make_divisors(A)
lstB = make_divisors(B)
#print(lstA,lstB)
fin = []
for i in lstA:
    if i in lstB:
        fin.append(i)
#print(fin)
print(fin[K-1])




Fixed 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
    
lstA = make_divisors(A)
lstB = make_divisors(B)
#print(lstA,lstB)
fin = []

for i in lstA:
    if i in lstB:
        fin.append(i)
#print(fin)
fin.sort(reverse = True)
print(fin[K-1])
Buggy code:
import math
import itertools
import numpy as np

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

def solve():
    a, b, k = map(int, input().split())
    print(cf(a, b)[k-1])
    return 0

if __name__ == "__main__":
    solve()


Fixed code:
import math
import itertools
import numpy as np

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

def solve():
    a, b, k = map(int, input().split())
    print(cf(a, b)[-k])
    return 0

if __name__ == "__main__":
    solve()
Buggy code:
A, B, K = map(int, input().split())

n = 0
L = min(A, B) // 2 + 1

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

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

n = 0
L = min(A, B) + 1

for i in range(L, 0, -1):
  if A % i == 0 and B % i == 0:
    n += 1
    if n == K:
      print(i)
      break
Buggy code:
A, B, K = [int(s) for s in input().split()]

count = 0
answer = -1
for i in range(1, min(A, B)+1):
    if A % i == 0 and B % i == 0:
        count += 1

        if count == K:
            answer = i
            break

print(answer)


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

count = 0
answer = -1
for i in range(min(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        count += 1

        if count == K:
            answer = i
            break

print(answer)
Buggy 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])

Fixed 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:
        fact.append(i)
print(fact[-k])
Buggy code:
a, b, k = map(int, input().split())

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

Fixed code:
a, b, k = map(int, input().split())
num = []
mini = min(a, b)
for i in range(1, mini+1):
    if a % i == 0 and b % i == 0:
        num.append(i)
num.sort()
num.reverse()
print(num[k-1])
Buggy 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)

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

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

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

Fixed code:
a=[0,0]
s=[]
a[0],a[1],k=map(int,input().split())
for i in range(1,min(a)+1):
  if a[0]%i==0 and a[1]%i==0:
    s.append(i)
print(s[len(s)-k])
Buggy code:
a, b, k = list(map(int, input().split()))
li = [x for x in range(1, max(a, b)+1) if a%x==0 and b%x==0]
print(li[k-1])

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

Fixed code:
a,b,k = map(int,input().split(" "))
c = [1]
for i in range(1,max(a,b)+1):
  if a % i == 0 and b % i == 0 and i!=1:
    c.append(i)
c.sort(reverse=True)
print(c[k-1])
Buggy code:
A,B,K=map(int,input().split())
i=0
j=0
while i<K:
  j+=1
  if A%j==0 and B%j==0:
    i+=1
print(j)

Fixed code:
A,B,K=map(int,input().split())
i=0
j=min(A,B)+1
while i<K:
  j-=1
  if A%j==0 and B%j==0:
    i+=1
print(j)
Buggy code:
a, b, k = map(int, input().split())
min_a_b = min(a, b)
counter = 0

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

Fixed code:
a, b, k = map(int, input().split())
min_a_b = min(a, b)
counter = 0

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