qyliang/CodeNanoFix huggingface dataset:
Buggy code:
# coding=utf-8


def solve_gcd(number1, number2):
    if number1 == number2:
        return number1

    if number1 < number2:
        number1, number2 = number2, number1

    if number1 % number2 == 0:
        return number2

    return solve_gcd(number2, number1 % number2)


if __name__ == '__main__':
    A, B, K = map(int, input().split())
    gcd = solve_gcd(A, B)
    ctr = 0
    for i in range(1, gcd+1):
        if gcd % i == 0:
            ctr += 1
        if ctr == K:
            print(ctr)
            break


Fixed code:
# coding=utf-8


def solve_gcd(number1, number2):
    if number1 == number2:
        return number1

    if number1 < number2:
        number1, number2 = number2, number1

    if number1 % number2 == 0:
        return number2

    return solve_gcd(number2, number1 % number2)


if __name__ == '__main__':
    A, B, K = map(int, input().split())
    gcd = solve_gcd(A, B)
    ctr = 0
    for i in range(gcd, 0, -1):
        if gcd % i == 0:
            ctr += 1
        if ctr == K:
            print(i)
            break
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


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

c_set = list(set(make_divisors(a))&set(make_divisors(b)))

c_set.sort()


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


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

c_set = list(set(make_divisors(a))&set(make_divisors(b)))

c_set.sort()
# print(c_set)
print(c_set[-c])
Buggy code:
A, B, K = [int(i) for i in input().split()]

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

print(res[K-1])


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

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

print(res[::-1][K-1])
Buggy code:
A, B, K = map(int, input().split())
count = 0
for_max = max([A, B])

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

Fixed code:
A, B, K = map(int, input().split())
count = 0
for_max = max([A, B])

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

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

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

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


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

def main():
    a = list(map(int, input().split()))
    count = 0
    for i in range(1, a[0] + 1):
        if a[0] % i == 0 and a[1] % i == 0:
            count += 1
            if count == a[2]:
                print(i)
                break


if __name__ == '__main__':
    main()

Fixed code:

def main():
    a = list(map(int, input().split()))
    count = 0
    data_list = [i for i in range(1, a[0] + 1)]
    for i in data_list[::-1]:
        if a[0] % i == 0 and a[1] % i == 0:
            count += 1
            if count == a[2]:
                print(i)
                break


if __name__ == '__main__':
    main()
Buggy 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[K-1])

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

Fixed code:
a, b, k = map(int, input().split())
m = min(a, b)
cnt = 0
for i in range(m, 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())
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

def divisors(n):
    div = []
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div += [A]
            else:
                B = n//A
                div += [A, B]
        A += 1
    div.sort()
    return div

g = gcd(A, B)
v = divisors(g)
print(v[K-1])

Fixed code:
A, B, K = map(int, input().split())
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

def divisors(n):
    div = []
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div += [A]
            else:
                B = n//A
                div += [A, B]
        A += 1
    div.sort()
    return div

g = gcd(A, B)
v = divisors(g)
v.reverse()
print(v[K-1])
Buggy 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)
        exit()


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

cnt = 0

for i in range(max(A, B)+1, 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())
C=[]
for i in range(1,(min(A,B))+1):
    if A%i==0 and B%i==0:
        C.append(i)
C.sort()
print(C[K-1])

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

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

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

print(X[K - 1])

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

print(X[-K])
Buggy code:
def gcd(m, n):
    return m if n == 0 else gcd(n, m % n)

if __name__ == "__main__":
    s = input()
    mylist = s.split()
    a = int(mylist[0])
    b = int(mylist[1])
    k = int(mylist[2])
    mygcd = gcd(a,b)
    cdList = []
    for i in range(1, mygcd+1, 1):
        if(a % i == 0 and b % i == 0):
            cdList.append(i)
    print(cdList[k-1])



Fixed code:
def gcd(m, n):
    return m if n == 0 else gcd(n, m % n)

if __name__ == "__main__":
    s = input()
    mylist = s.split()
    a = int(mylist[0])
    b = int(mylist[1])
    k = int(mylist[2])
    mygcd = gcd(a,b)
    cdList = []
    for i in range(1, mygcd+1, 1):
        if(a % i == 0 and b % i == 0):
            cdList.append(i)
    print(cdList[len(cdList) - k])
Buggy code:
a,b,k=list(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(i)
print(ans[-k])

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

num = min(a, b)

ans = []

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

num = min(a, b)

ans = []

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

print(ans[-k])
Buggy code:
A, B, K = [int(x) for x in input().split(" ")]

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

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

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

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

warikiru.reverse()
print(warikiru[K-1])
Buggy code:
a, b, k = map(int, input().split())
count = 0
if(a > b):
    tmp = a
    a = b
    b = tmp
for i in range(1, b + 1):
    if a % i == 0 and b % i == 0:
        count += 1
        if count == k:
            print(i)
            exit(0)

Fixed code:
a, b, k = map(int, input().split())
count = 0
if(a > b):
    tmp = a
    a = b
    b = tmp
for i in range(b, 0, -1):
    if a % i == 0 and b % i == 0:
        count += 1
        if count == k:
            print(i)
            exit(0)
Buggy code:
s=list(map(int,input().split()))
a=0
for i in range(1,s[0]+1):
  if a==s[2]:
    print(b)
    break
  if s[0]%i==0:
    if s[1]%i==0:
      a+=1
      b=i

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

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

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

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)
            break
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)
    else:
        continue
        
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)
    else:
        continue
        
print(l[len(l)-k])
Buggy code:
a, b, k = map(int, input().split())
def calc(n):
    res = []
    for i in range(1,n+1):
        if not n % i:
            res.append(i)
    return set(res)
print(sorted(list(calc(a) & calc(b)))[k-1])


Fixed code:
a, b, k = map(int, input().split())
def calc(n):
    res = []
    for i in range(1,n+1):
        if not n % i:
            res.append(i)
    return set(res)
print(sorted(list(calc(a) & calc(b)))[-k])
Buggy code:
def factorize(n):
    n_list = []
    for i in range(n):
        x = i + 1
        if n % x == 0:
            n_list.append(x)
    return n_list

if __name__ == '__main__':
    A, B, C = input().split()
    a_list = factorize(int(A))
    b_list = factorize(int(B))
    and_list = list(set(a_list)&set(b_list))
    and_list.reverse()
    print(and_list)
    print(and_list[int(C)-1])

Fixed code:
def factorize(n):
    n_list = []
    for i in range(n):
        x = i + 1
        if n % x == 0:
            n_list.append(x)
    return n_list


if __name__ == '__main__':
    A, B, C = input().split()
    a_list = factorize(int(A))
    b_list = factorize(int(B))
    and_list = list(set(a_list) & set(b_list))
    and_list.sort(reverse=True)
    print(and_list[int(C) - 1])
Buggy code:
a,b,c=map(int,input().split(' '))
count=0
for i in range(1,100):
    if a%i==0 and b%i==0:
        count+=1
        #print(i)
    if count==c:
        print(i)
        break
    


Fixed code:
a,b,c=map(int,input().split(' '))
count=0
for i in reversed(range(1,101)):
    if a%i==0 and b%i==0:
        count+=1
        #print(i)
    if count==c:
        print(i)
        break
Buggy code:
A, B, K = map(int, input().split(" "))

yakusu = []
for n in range(1, 101):
    if A % n == 0 and B % n == 0:
        yakusu.append(n)
print(sorted(yakusu)[K-1])

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

yakusu = []
for n in range(1, 101):
    if A % n == 0 and B % n == 0:
        yakusu.append(n)
print(sorted(yakusu)[-K])
Buggy code:
a,b,c = 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[c-1])

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

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(0)
Buggy code:
a, b, k = [int(x) for x in input().split()]

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

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

cnt = 0
N = min(a, b)
for i in range(N, 0, -1):
    if a%i == 0 and b%i == 0:
        cnt += 1
    if cnt == k:
        print(i)
        break
Buggy code:
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a


def divisor(a):
    res = set()
    for i in range(1, int(a * 0.5 + 1)):
        if a % i == 0:
            res.add(i)
            res.add(a // i)
    return sorted(res)


a, b, k = map(int, input().split())
ans = divisor(gcd(a, b))[-k]
print(ans)

Fixed code:
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a


def divisor(a):
    res = set()
    for i in range(1, int(a * 0.5 + 1) + 1):
        if a % i == 0:
            res.add(i)
            res.add(a // i)
    return sorted(res)


a, b, k = map(int, input().split())
ans = divisor(gcd(a, b))[-k]
print(ans)
Buggy code:
a,b,k = map(int,input().split())

tmp = 0

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



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

tmp = 0

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

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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0
for a in range(mx+1, 1, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break
print(ans)


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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0

for a in range(mx, 0, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break

print(ans)
Buggy code:
from sys import stdin

A,B,K = map(int,stdin.readline().strip().split())

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

print(ans)


Fixed code:
from sys import stdin

A,B,K = map(int,stdin.readline().strip().split())

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

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

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

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

    #print(max_gcd)
    #print(yakusuu_array)
    print(yakusuu_array[-(k-1)])
Buggy code:
A,B,K=(int(x) for x in input().split())
count=0
result=0
for i in range(1,min([A,B])//2):
  if A%i==0 and B%i==0:
    count+=1
  if count==K:
    result=i
    break
print(result)

Fixed code:
A,B,K=(int(x) for x in input().split())
count=0
result=0
for i in reversed(range(1,min([A,B])+1)):
  if A%i==0 and B%i==0:
    count+=1
  if count==K:
    result=i
    break
print(result)
Buggy code:
# coding: utf-8
# Your code here!

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

def d(n):
    div = []
    for i in range(1,n+1):
        if(n % i == 0):
            div.append(i)
    return div
        
a_d = d(a)
b_d = d(b)
s = []
l = []
ab = []

if len(a_d) < len(b_d):
    s = a_d
    l = b_d
else:
    s = b_d
    l = a_d

for i in s:
    if i in l:
        ab.append(i)
print(ab[k-1])
    

Fixed code:
# coding: utf-8
# Your code here!

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

def d(n):
    div = []
    for i in range(1,n+1):
        if(n % i == 0):
            div.append(i)
    return div
        
a_d = d(a)
b_d = d(b)
s = []
l = []
ab = []

if len(a_d) < len(b_d):
    s = a_d
    l = b_d
else:
    s = b_d
    l = a_d

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

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


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

ans=0
while K:
    ans += 1
    if (not A%ans and not B%ans):
        K -= 1

print(ans)


Fixed code:
A,B,K=map(int, input().split())
ans=min(A,B)+1
while K:
    ans -= 1
    if (not A%ans and not B%ans):
        K -= 1
print(ans)
Buggy code:
a,b,k = map(int,input().split())

#a,b,k=8,12,2

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

print(ans)

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

#a,b,k=8,12,2

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

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

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

OK = A & B
OK = sorted(OK)

print(OK[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)

OK = A & B
OK = sorted(OK)

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

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

ans_l = []
for num in range(min(a, b)):
  if a % num == 0 and b % num == 0:
    ans_l.append(num)

sorted(ans_l)

print(ans_l[-k])

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


print(ans_l[-k])
Buggy code:
def cd(a,b):
  p = min(a,b)
  q = max(a,b)
  lst = []
  for i in range(1, p + 1):
    if (p % i == 0 and q % i == 0):
      lst.append(i)
  return lst

A,B,K = map(int, input().split())
lst = cd(A,B)
print(lst[K-1])

Fixed code:
def cd(a,b):
  p = min(a,b)
  q = max(a,b)
  lst = []
  for i in range(1, p + 1):
    if (p % i == 0 and q % i == 0):
      lst.append(i)
  return lst
 
A,B,K = map(int, input().split())
lst = cd(A,B)
print(lst[-K])
Buggy code:
a,b,k=map(int,input().split())
n=min(a,b)
cnt=0
for i in range(1,n+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())
n=min(a,b)
cnt=0
for i in range(n,0,-1):
    if a%i==0 and b%i==0:
        cnt+=1
    if cnt==k:
        print(i)
        exit()
Buggy code:
a,b,c=map(int,input().split())
lst=[]
for i in range(1,101):
  if a %i==0 and b % i ==0:
    lst.append(i)
print(lst[c-1])

Fixed code:
a,b,c=map(int,input().split())
lst=[]
for i in range(1,101):
  if a %i==0 and b % i ==0:
    lst.append(i)
print(sorted(lst,reverse=True)[c-1])
Buggy code:
a,b,k=map(int,input().split())
i=1
list=[]

while a>i and b>i:
    if a%i==0 and b%i==0:
        list.append(i)
    i+=1

print(list[k-1])

Fixed code:
a,b,k=map(int,input().split())
i=1
list=[]

while a>=i and b>=i:
    if a%i==0 and b%i==0:
        list.append(i)
    i+=1

print(list[len(list)-k])
Buggy code:
a,b,k=map(int,input().split())
i=0
c=0
while(c!=k):
    i+=1
    if a%i==0 and b%i==0:
        c+=1
print(i)


Fixed code:
a,b,k=map(int,input().split())
i=101
c=0
while(c!=k):
    i-=1
    if a%i==0 and b%i==0:
        c+=1
print(i)
Buggy code:
a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, m):
    if n % i == 0:
        ans.append(i)

#print(ans)
if ans:
    print(ans[k-1])
else:
    print("1")


Fixed code:
a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, n+1):
    if m % i == 0 and n % i == 0:
        ans.append(i)

if ans:
    print(ans[-k])
else:
    print("1")
Buggy code:
a,b,c=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==c:
    print(i)
    break


Fixed code:
a,b,c=map(int,input().split())
cnt=0
for i in range(0,min(a,b)+1):
  j=min(a,b)-i
  if a%j==0 and b%j==0:
    cnt+=1
  if cnt==c:
    print(j)
    break