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

cand = []
for i in range(101,1,-1):
  if A%i == 0 and B%i == 0:
    cand += [i]
    
    
print(cand[K-1])

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

cand = []
for i in range(100,0,-1):
  if A%i == 0 and B%i == 0:
    cand += [i]
    
    
print(cand[K-1])
Buggy code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

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

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

return 0

Fixed code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

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

th = 0
for i, item in enumerate(divisors[::-1]):
  if b % item == 0:
    th += 1
  if th == k:
    print(item)
    break
Buggy code:
a, b, k = map(int, input().split())
li =[]
for i in range(1, min(a, b)):
    elif a % i == 0 and b % i == 0:
        li.append(i)

print(li[-k])

Fixed 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[-k])
Buggy 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])

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

def ooo(x):
    lix =[]
    for i in range(1, x+1):
        if x % i == 0:
            lix.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])
Buggy code:
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(1,c):
	if a%i==0 and b%i==0:
		l.append(i)
l.sort(reverse=True)
print(l[k-1])

Fixed code:
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(1,c+1):
	if a%i==0 and b%i==0:
		l.append(i)
l.sort(reverse=True)
print(l[k-1])
Buggy code:
class Solution:
    def solve(self, A: int, B: int, K: int) -> str:

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

            if count == K:
                return i


if __name__ == '__main__':

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

    # solve
    solution = Solution()
    print(solution.solve(A, B, K))


Fixed code:
class Solution:
    def solve(self, A: int, B: int, K: int) -> str:

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

            if count == K:
                return i


if __name__ == '__main__':

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

    # solve
    solution = Solution()
    print(solution.solve(A, B, K))
Buggy code:
a,b,k=map(int,input().split())
m=max(a,b)
ans=[]
for i in range(1,m):
  if a%i==0 and b%i==0:
    ans.append(i)
ans.reverse()
print(ans[k-1])

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

def euclidean(a,b):
    if a < b:
        tmp = a
        a = b
        b = tmp
    if a%b != 0:
        return euclidean(a%b, b)
    else:
        return b

n = euclidean(a, b)
print(n)
for i in range(n , 0, -1):
  #print(i)
  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())

def euclidean(a,b):
    if a < b:
        tmp = a
        a = b
        b = tmp
    if a%b != 0:
        return euclidean(a%b, b)
    else:
        return b

n = euclidean(a, b)
for i in range(n , 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())
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)
      exit()


Fixed code:
a,b ,k = map(int,input().split())
cnt = 0
for i in range(min(a,b),0,-1):
    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())
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])

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

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

Fixed code:
a, b, c = map(int, input().split())
counter = 0
for i in reversed(range(1, min(a,b)+1)):
        if(a % i == 0 and b % i == 0):
                counter += 1
                if counter == c:
                        print(i)
                        exit()
Buggy code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  5 22:47:49 2019

@author: lab
"""

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

n = min(a,b)
count = 0
while n>0:
    if a%n == 0 and b%n == 0:
        count += 1
        n -= 1
        if count == k:
            print(n)    
    else:
        n -= 1
        
        

Fixed code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  5 22:47:49 2019

@author: lab
"""

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

n = min(a,b)
count = 0
while n>0:
    if int(a%n) == 0 and int(b%n) == 0:
        count += 1
        if count == k:
            print(n)
            break
        n -= 1
    else:
        n -= 1
Buggy code:
a, b,K = map(int, input().split())
ans=[]
for i in range(1,max(a,b)+1):
    if a%i==0 and b%i==0:
        ans.append(i)

print(ans[K-1])

Fixed 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)
ans=ans[::-1]
print(ans[K-1])
Buggy 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


Fixed code:
a, b, k = map(int, input().split(' '))
count = 0
for i in range(min(a,b),0,-1):
    if (a%i == 0) and (b%i == 0):
        count+=1
    if count == k:
        print(i)
        break
Buggy code:
a, b, k = map(int, input().split())
print([i for i in range(1,101) if a%i+b%i<1][k-1])

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

Fixed code:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

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

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


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

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

k = 0
for i in range(1, 100):
  if A%i == B%i == 0:
    k += 1
    if k == K:
      print(i)
      quit()

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

k = 0
for i in range(100, 0, -1):
  if A%i == B%i == 0:
    k += 1
    if k == K:
      print(i)
      quit()
Buggy 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)
sorted(lst, reverse = True)
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)
lst1 = sorted(lst, reverse = True)
print(lst1[K - 1])
Buggy code:
a,b,k = map(int, input().split())
p = []
for i in range(1, min(a,b)+1):
  if a % i == 0 and b % i == 0:
    p.append(i)

print(p[k-1])  

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

print(p[len(p) - k])
Buggy code:
a, b, k = map(int, input().split())
n = 1
count = 0
list = []
while count < k:
    if a % n == 0 and b % n == 0:
        list.append(n)
        count += 1
        n += 1
        print(n)
    else:
        n += 1
        print(n)
print(list[k-1])

Fixed code:
a, b, k = map(int, input().split())
n = 1
count = 0
list = []
while n <= a and n <=  b:
    if a % n == 0 and b % n == 0:
        list.append(n)
        n += 1
    else:
        n += 1
print(list[-k])
Buggy code:
a, b, k = map(int,input().split())

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

ans = cf(a,b)
ans.sort(reverse=True)

print(ans[k-1])

Fixed 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

ans = cf(a,b)
ans.sort(reverse=True)

print(ans[k-1])
Buggy code:
A, B, K = map(int, input().split())
n_list = list(range(min(A,B)))
n_list.reverse()
n_list = [1+i for i in n_list]
c = 0

for n in n_list:
    if c == K:
        print(n+1)
        break
    elif A%n == 0 and B%n == 0:
        c += 1

Fixed code:
A, B, K = map(int, input().split())
n_list = list(range(min(A,B)))
n_list.reverse()
n_list = [1+i for i in n_list]
c = 0

for n in n_list:
    if A%n == 0 and B%n == 0:
        c += 1
    if c == K:
        print(n)
        break
Buggy 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 = list(set(yakusuuA) & set(yakusuuB))
yakusuu.append(1)     
print(sorted(yakusuu)[K])

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

Fixed 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 = list(set(yakusuuA) & set(yakusuuB))
yakusuu.append(1)     
print(sorted(yakusuu, reverse=True)[K-1])
Buggy code:
A,B,K=map(int,input().split())


def yaku(num):
    yaku_num=[num]
    for i in range(1,num):
        if num % i == 0:
            yaku_num.append(i)
    return yaku_num

A_yaku=set(yaku(A))
B_yaku=set(yaku(B))
# print(A_yaku)
# print(B_yaku)

yakusu=list(A_yaku & B_yaku)
# print(yakusu[K-1])
yakusu.sort()
print(yakusu[K-1])

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


def yaku(num):
    yaku_num=[num]
    for i in range(1,num):
        if num % i == 0:
            yaku_num.append(i)
    return yaku_num

A_yaku=set(yaku(A))
B_yaku=set(yaku(B))
# print(A_yaku)
# print(B_yaku)

yakusu=list(A_yaku & B_yaku)
# print(yakusu[K-1])
yakusu.sort(reverse=True)
print(yakusu[K-1])
Buggy code:
a, b, k = map(int, input().split())
li = list(range(1, min(a, b)+1))
temp_li = []
for i in range(len(li)):
    if a % li[i] == b % li[i] == 0:
        temp_li.append(li[i])
print(temp_li[k-1])


Fixed code:
a, b, k = map(int, input().split())
li = list(range(1, min(a, b)+1))
temp_li = []
for i in range(len(li)):
    if a % li[i] == b % li[i] == 0:
        temp_li.append(li[i])
temp_li = temp_li[::-1]
print(temp_li[k-1])
Buggy 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)
        exit()

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

A = []
B = []
for i in range(1,a):
    if a % i == 0:
        A.append(i)
for i in range(1,b):
    if b % i == 0:
        B.append(i)
common = list(set(A) & set(B))
common.sort()
print(common[k-1])

Fixed 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 i in range(1,b+1):
    if b % i == 0:
        B.append(i)
common = list(set(A) & set(B))
common.sort(reverse=True)

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

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

print(sorted(list(a & b))[K - 1])

Fixed 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 i in range(1, B + 1):
    if(B % i == 0):
        b.append(i)
        
a = set(a)
b = set(b)
 
print(sorted(list(a & b), reverse = True)[K - 1])
Buggy code:
A,B,K=[int(x) for x in input().split()]
M=min(A,B)
L=[]

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

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

M=min(A,B)
L=[]
 
for i in range(1,M+1):
    if (A%i==0)&(B%i==0):
        L.append(i)
print(L[len(L)-K])
Buggy code:
A,B,K = map(int, input().split())
l = [x for x in range(1, 101) if A % x == 0 and B % x == 0]
print(l[K-1])


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


Fixed 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])
Buggy 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
    if count==k-1:
      num=i
      break
 
print(num)

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

Fixed 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)
    
l.sort(reverse=True)
print(l[K-1])
Buggy code:
# -*- coding: utf-8 -*-

a, b, c = map(int, input().split())

max = max(a, b)
if max > 101:
    max = 101

list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list[-c])

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

a, b, c = map(int, input().split())

max = max(a, b) + 1
if max > 101:
    max = 101

list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list[-c])
Buggy code:
# -*- coding: utf-8 -*-

a, b, c = map(int, input().split())

max = 101
#if a < b:
#    max = a

list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list)

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

a, b, c = map(int, input().split())

max = 101
#if a < b:
#    max = a

list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list[-c])
Buggy 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])
    

Fixed code:

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

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

print(sei)

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

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

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


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

Fixed code:
A, B, K = map(int, input().split())
D = []
for i in range(max(A, B), 0, -1):
  if A % i == 0 and B % i == 0:
    D.append(i)
print(D[K - 1])
Buggy code:
A, B, K = [int(i) for i in input().split()]
tmp = []
for j in range(1, 101):
    if A % j == 0 and B % j == 0:
        tmp.append(j)
print(tmp[K - 1])

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

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

Fixed code:
a,b,n=map(int,input().split())
c=[]
i=0
while(1):
  i=i+1
  if a%i==0 and b%i==0:
    c.append(i)
  if a<=i or b<=i:
    break
d=len(c)-n
print(c[d])
Buggy code:
def main():
    A,B,C = map(int, input().split())
    if A>B:
        D=A
    else:
        D=B

    list =[]
    for i in range(D):
        if i!=0:
            if (A%i == 0) & (B%i == 0) :
                list.append(i)
    print(list[(len(list)-C)])

main()

Fixed code:
def main():
    A,B,C = map(int, input().split())
    if A>B:
        D=A
    else:
        D=B

    list =[]
    for i in range(D+1):
        if i!=0:
            if (A%i == 0) & (B%i == 0) :
                list.append(i)
    print(list[(len(list)-C)])
    


main()
Buggy code:
from sys import stdin
a, b, k = [int(x) for x in stdin.readline().rstrip().split()]
divides=[]
for i in range(1,101):
    if a%i == 0 and b%i == 0:
        divides.append(i)
print(divides[k-1])

Fixed code:
from sys import stdin
a, b, k = [int(x) for x in stdin.readline().rstrip().split()]
divides=[]
for i in range(1,101):
    if a%i == 0 and b%i == 0:
        divides.append(i)
divides.sort(reverse=True)
print(divides[k-1])
Buggy code:
a, b, k = map(int, input().split())

min = a
if b < min:
  min = b

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

ans_lists.reverse()
ans = lists[k-1]

print(ans)

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

min = a
if b < min:
  min = b

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

ans_lists.reverse()
ans = ans_lists[k-1]

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

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

Fixed code:
a,b,k=(int(x) for x in input().split())
list =[]
 
for x in range(1,max(a,b)+1):
    if(a%x == 0 and b%x == 0):
        list.append(x)
 
print(list[-k])
Buggy code:
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = 0
    while t < K:
        i += 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()


Fixed code:
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = max(A,B)+1
    while t < K:
        i -= 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()
Buggy code:
#!/usr/bin/env python3
import sys


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

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)


if __name__ == "__main__":
    main()


Fixed code:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    diviser = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            diviser.append(i)
    diviser.sort(reverse=True)
    print(diviser[K - 1])

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)


if __name__ == "__main__":
    main()
Buggy code:
A,B,K = map(int,input().split())
if A>=B:
  A,B=B,A
new=[]

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

print(new[K-1])

Fixed code:
A,B,K = map(int,input().split())
if A>=B:
  A,B=B,A
new=[]

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

print(new[-K])