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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return int(a)

GCA = gcd(A, B)
A_all_div=[]
B_all_div=[]


for i in range(1,A+1):
    if A % i == 0:
        if i <= GCA:
            A_all_div.append(i)
A_all_div.sort(reverse=True)

for i in range(1,B+1):
    if B % i == 0:
        if i <= GCA:
            B_all_div.append(i)
B_all_div.sort(reverse=True)

ALL_DIV = set(A_all_div) & set(B_all_div)
all_div = list(ALL_DIV)

print(all_div[K-1])

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return int(a)

GCA = gcd(A, B)
A_all_div=[]
B_all_div=[]


for i in range(1,A+1):
    if A % i == 0:
        if i <= GCA:
            A_all_div.append(i)
A_all_div.sort(reverse=True)

for i in range(1,B+1):
    if B % i == 0:
        if i <= GCA:
            B_all_div.append(i)
B_all_div.sort(reverse=True)

ALL_DIV = set(A_all_div) & set(B_all_div)
all_div = list(ALL_DIV)

all_div.sort(reverse=True)

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


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

print(a)

Fixed code:
A, B, K = map(int, input().split())
l = list()
a = 0
c = 0
if A > B:
    c = A
else:
    c = B
for i in range(1, c + 1):
    if A % i == 0 and B % i == 0:
        l.append(i)
l.sort(reverse=True)
for i in range(len(l)):
    if i + 1 == K:
        a = l[i]
print(a)
Buggy code:
def cf(x1, x2):
    cf = [1]
    for i in range(2, min(x1, x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


def main():
    a, b, k = map(int, input().split())
    ab_cf = cf(a, b)
    if len(ab_cf) == 1:
        ans = ab_cf[0]
    else:
        ans = sorted(ab_cf)[-2]
    print(ans)


if __name__ == "__main__":
    main()


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


def main():
    a, b, k = map(int, input().split())
    ab_cf = cf(a, b)
    ans = sorted(ab_cf)[-k]
    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
a,b,k=map(int,input().split())
ans=[]
for i in range(1,100):
    if a%i==0 and b%i==0:
        ans.append(i)
print(ans)
print(ans[len(ans)-k])

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

ans=[]

for i in range(1,max(a,b)):
  if a%i ==0 and b%i ==0:
    ans.append(i)

    
ans.sort(reverse=True)
print(ans[k-1])

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

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

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

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

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

Fixed code:
A, B, K = map(int,input().split())
li = []
for i in range(1,101,1):
  if A%(i) == 0 and B%(i) == 0:
    li.append(i)
print(li[len(li)-K])
Buggy code:
from math import *
a,b,k=map(int,input().split())
g=gcd(a,b)
for i in range(g,0,-1):
    if(g*i==0):
        k-=1
        if(k==0):
            print(i)
            break


Fixed code:
from math import *
a,b,k=map(int,input().split())
g=gcd(a,b)
for i in range(g,0,-1):
    if(g%i==0):
        k-=1
    if(k==0):
        print(i)
        break
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

print(cf(a,b)[-k])


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

print(cf(a,b)[-k])
Buggy code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

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


Fixed code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

ans = []

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

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

Fixed code:
a,b,k=map(int,input().split())
c=min(a,b)+1
ct=0
while ct <k:
  c=c-1
  if a%c==0 and b%c==0:
    ct+=1

  
print(c)
Buggy code:
import math
import copy

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
b = int(inputa[1])
c = int(inputa[2])

# inputb = input().split()
# inputbint = [int(x) for x in inputb]
# inputList = list(b)

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input().split()
#     inputNum = [int(x) for x in inputNum]
#     inputList.append(inputNum)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

min = min[a, b]
cnt = 0

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

Fixed code:
import math
import copy

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
b = int(inputa[1])
c = int(inputa[2])

# inputb = input().split()
# inputbint = [int(x) for x in inputb]
# inputList = list(b)

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input().split()
#     inputNum = [int(x) for x in inputNum]
#     inputList.append(inputNum)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

min = min([a, b])
cnt = 0

for i in range(min, 0, -1):
    checka = a % i
    checkb = b % i
    if checka == 0 and checkb == 0:
        cnt += 1
        if cnt == c:
            print(i)
Buggy code:
a,b,k=map(int,input().split())
c=min(a,b)
li1=list(range(1,c+1))
li2=[]
for i in li1:
    if a%1==0 and b%i==0:
        li2.append(i)
print(li2[-k])

Fixed code:
a,b,k=map(int,input().split())
c=min(a,b)
li1=list(range(1,c+1))
li2=[]
for i in li1:
    if a%i==0 and b%i==0:
        li2.append(i)
print(li2[-k])
Buggy code:
#ABC120B-K-thCommonDivisor.py

from sys import stdin

input = stdin.readline

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

commonDivisor = []

for i in range(1,101):
    if A % i == 0 and B % i == 0:
        commonDivisor.append(i)
    if len(commonDivisor) == K:
        print(commonDivisor[-1])
        break


Fixed code:
#ABC120B-K-thCommonDivisor.py

from sys import stdin

input = stdin.readline

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

commonDivisor = []

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

print(commonDivisor[-K])
Buggy code:
a = list(map(int, input().split()))

for i in range(max(a[0],a[1]),1,-1):
    if a[0] % i == 0 and a[1] % i == 0:
        a[2] = a[2] - 1
        if a[2] == 0:
            print(i)
            


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

for i in range(max(a[0],a[1]),0,-1):
    if a[0] % i == 0 and a[1] % i == 0:
        a[2] = a[2] - 1
        if a[2] == 0:
            print(i)
Buggy code:
A, B, N = map(int,input().split())
k = 0

for i in range(1,min(A,B)+1):
    if (A % i == 0) and (B % i == 0):
        k += 1
        if k == N:
            print(i)

Fixed code:
A, B, N = map(int, input().split())
k = 0

for i in range(min(A,B), 0, -1):
    if (A % i == 0) and (B % i == 0):
        k += 1
        if k == N:
            print(i)
Buggy code:
a, b, k = map(int, input().split())
while a != b:
    if a > b:
        a = a - b
    else:
        b = b - a
ans = []
for i in range(1, a):
    if a%i == 0:
        ans.append(i)
        ans.sort(reverse=True)
print(ans[k-1])

Fixed code:
a, b, k = map(int, input().split())
while a != b:
    if a > b:
        a = a - b
    else:
        b = b - a
ans = []
for i in range(1, a+1):
    if a%i == 0:
        ans.append(i)
        ans.sort(reverse=True)
print(ans[k-1])
Buggy code:
a,b,k = map(int,input().split())
ans = []
for i in range(1,101):
    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, 101):
    if a % i == 0 and b % i == 0:
        ans.append(i)
print(ans[-k])
Buggy code:
import sys
from sys import stdin

def f(num):
  d = []
  if num != 1:
    for i in range(1,num):
      if num % i == 0:
    	  d.append(i)
  else:
      d = [1]
  return d

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
a = f(A)
b = f(B)
d = set(a)&set(b)
d = list(d)
print(d[C-1])

Fixed code:
from sys import stdin

def f(num):
  d = []
  if num != 1:
    for i in range(1,num):
      if num % i == 0:
    	  d.append(i)
      d.append(num)
  else:
      d = [1]
  return d

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
a = f(A)
b = f(B)
d = set(a)&set(b)
d = sorted(list(d),reverse=True)
print(d[C-1])
Buggy code:
a,b,k=map(int,input().split())
ans=[]
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    ans.append(i)
print(ans[k-1])

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

lis=[]
if a>b:
    for i in range(b):
        if a%(b-i)==0 and b%(b-i)==0:
            lis.append(b-i)

else:
    for i in range(a):
        if a%(b-i)==0 and b%(b-i)==0:
            lis.append(b-i)

print(lis[c-1])


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

lis=[]
if a>b:
    for i in range(b):
        if a%int(b-i)==0 and b%int(b-i)==0:
            lis.append(int(b-i))

else:
    for i in range(a):
        if a%(a-i)==0 and b%(a-i)==0:
            lis.append(int(a-i))

#print(lis)
print(lis[c-1])
Buggy code:
A, B, K = map(int, input().split())

ans = []

for i in range(1, max(A, B)):
    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, A+1):
    if A % i == 0 and B % i == 0:
        ans.append(i)

ans.reverse()
print(ans[K-1])
Buggy code:
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []

    for i in range(1, max(A, B)):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        if len(ans) >= K:
            break
    # print(ans)
    print(ans[-1])


if __name__ == "__main__":
    main()


Fixed code:
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []
    ans.append(1)
    for i in range(2, max(A, B)+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


if __name__ == "__main__":
    main()
Buggy code:
A, B, K = tuple(map(int, input().split()))
k = 0
for i in range(1, min(A + 1, B + 1)):
    if A % i == 0 and B % i == 0:
        k += 1
    if k == K:
        print(i)
        break


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

kk = 0
out = 0

for i in range(1,min(a,b)):
    aa = a % i
    bb = b % i
    
    if (aa+bb)==0:
        kk += 1
        #print(aa,bb,i)
        if kk==k:
            out = i
            break
print(out)
    

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

kk = 0
out = 0

for i in range(min(a,b),0,-1):
    aa = a % i
    bb = b % i
    
    if (aa+bb)==0:
        kk += 1
        #print(aa,bb,i)
        if kk==k:
            out = i
            break
print(out)
Buggy code:
#B
A,B,K = map(int, input().split())

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


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

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

Fixed code:
a, b, c = 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 == c:
            print(i)
            break
Buggy code:
def gcd( x, y ):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

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

N = gcd(A, B)
print(make_divisors(N)[-K])

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

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, K = map(int, input().split())
N = gcd(A, B)
print(make_divisors(N)[-K])
Buggy code:
a,b,k = map(int,input().split())
cd = []
for i in range(1,min(a,b)+1):
    if a % i == 0:
        if b % i == 0:
            cd.append(i)
cd.sort(reverse=True)
print(cd)
print(cd[k-1])

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

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

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

print(yakusuu[K-1])

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

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

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

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
        if C == K:
            break
print(i)
Buggy code:
a,b,k = list(map(int, input().split()))
x=[]

for i in range(1, min(a, b)):
    if a%i == 0 and b%i==0:
      x.append(i)

x.sort(reverse=True)
print(x[k-1])

Fixed code:
a,b,k = list(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)

x.sort(reverse=True)
print(x[k-1])
Buggy code:
a,b,k=input().split()
A=int(a)
B=int(b)
K=int(k)
cnt=0
for i in range(1,A+1):
    if A%i==0 and B%i==0:
        cnt+=1
    if cnt==K:
        print(i)
        break


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

cnt = 0

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


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

cnt = 0

for i in reversed(range(1, 101)):
    if(A % i == 0) and (B % i == 0):
        cnt = cnt + 1
        if cnt == K:
            print(i)
            break
Buggy code:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

A,B,K=map(int,input().split())
gcdAB=gcd(A, B)
cnt=0
for i in range(gcdAB):
    n=i+1
    if gcdAB%n==0:
        cnt=cnt+1
    if cnt==K:
        print(n)
        exit()


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

A,B,K=map(int,input().split())
gcdAB=gcd(A, B)
cnt=0
for i in range(gcdAB):
    n=gcdAB-i
    if gcdAB%n==0:
        cnt=cnt+1
    if cnt==K:
        print(n)
        exit()
Buggy code:
A,B,K = map(int, input().split())
lista = []
listb = []
for i in range(1, (A + 1)):
        if A%i==0:
                lista.append(i)
for i in range(1, (B + 1)):
        if B%i==0:
                listb.append(i)
common_list = []
for i in lista:
        for j in listb:
                if i == j:
					common_list.append(i)
print(common_list[-K])


Fixed code:
A,B,K = map(int, input().split())
A = [i for i in range(1, (A+1)) if A%i==0]
B = [i for i in range(1, (B+1)) if B%i==0]
common_list = []
for i in A:
        for j in B:
                if i == j:
                        common_list.append(i)
print(common_list[-K])
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  6 16:28:37 2019

@author: iwata
"""

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

if A >= B:
    for i in reversed(range(B)):
        rema1 = A%i
        remb1 = B%i
        if rema1==0 & remb1==0:
            count = count +1
        if K == count:
            print(i)
            break
else:
    for j in reversed(range(A)):
        rema = A%j
        remb = B%j
        if rema==0 & remb==0:
            count = count +1
        if K == count:
            print(j)
            break

Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  6 16:28:37 2019

@author: iwata
"""

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

if A >= B:
    for i in reversed(range(B+1)):
        rema1 = A%i
        remb1 = B%i
        if rema1==0 and remb1==0:
            count = count +1
        if K == count:
            print(i)
            break
else:
    for j in reversed(range(A+1)):
        rema = A%j
        remb = B%j
        if rema==0 and remb==0:
            count = count +1
        if K == count:
            print(j)
            break
Buggy code:
a,b,k=map(int,input().split())
kk=0
for i in range(100):
  if a%(i+1)==0 and b%(i+1)==0:
    kk+=1
    if kk==k:
      print(i+1)
      break

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

def ans120(A:int, B:int, K:int):
    l=sorted([A,B])
    ans_list=[1]
    for i in range(2,l[1]):
        if A%i==0 and B%i==0:
            ans_list.append(i)
    return ans_list[K-1]

print(ans120(A,B,K))

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

def ans120(A:int, B:int, K:int):
    l=sorted([A,B])
    ans_list=[]
    for i in range(1,l[1]+1):
        if A%i==0 and B%i==0:
            ans_list.append(i)
    return ans_list[-K]

print(ans120(A,B,K))
Buggy code:
a, b, k = [int(s) for s in input().split()]


def f(s, l, k):
    numbers = []
    for i in range(2, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)


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


def f(s, l, k):
    numbers = []
    for i in range(1, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)
Buggy code:
a, b, k = map(int, input().split())
a, b = max(a,b), min(a,b)
c = []
for i in range(1, b+1):
    if (a % i == 0) & (b % i == 0):
        c.append(i)
print(c[k])

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

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

Fixed 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
result.reverse()
print(result[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 j in range(1,B+1):
  if B%j==0:
    b.append(j)

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

print(abset[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 j in range(1,B+1):
  if B%j==0:
    b.append(j)

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

print(abset[K-1])