qyliang/CodeNanoFix huggingface dataset:
Buggy code:
from sys import stdin
n,m = map(int,stdin.readline().rstrip().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
li = make_divisors(m)
point = 1
for i in li:
    if i > n:
        break
    m //= i
    point = i
print(point)

Fixed code:
from sys import stdin
n,m = map(int,stdin.readline().rstrip().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
li = make_divisors(m)
point = m
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)
Buggy code:
N, M = map(int, input().split())
ans = 1

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            if M / i >= N and M % i == 0:
                print(100)
                ans = max(ans, i)
            j = M // i
            if M / j >= N and M % j == 0:
                print(2999)
                ans = max(ans, j)
            #print(i)
    if not_sosu == -1:
        ans = 1


if N == 1:
    ans = M

print(ans)


Fixed code:
N, M = map(int, input().split())
ans = 1

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            if M / i >= N and M % i == 0:
                ans = max(ans, i)
            j = M // i
            if M / j >= N and M % j == 0:
                ans = max(ans, j)
            #print(i)
    if not_sosu == -1:
        ans = 1


if N == 1:
    ans = M

print(ans)
Buggy code:
import math
import sys
input = sys.stdin.readline

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 sorted(divisors, reverse=True)

def main():
    N, M = map(int, input().split())

    divisors = make_divisors(M)

    for d in divisors:
        tmp = M - d * N
        if tmp > 0 and tmp % d == 0:
            print(d)
            break
    
if __name__ == "__main__":
    main()

Fixed code:
import math
import sys
input = sys.stdin.readline

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 sorted(divisors, reverse=True)

def main():
    N, M = map(int, input().split())

    divisors = make_divisors(M)

    for d in divisors:
        tmp = M - d * N
        if tmp >= 0 and tmp % d == 0:
            print(d)
            break
    
if __name__ == "__main__":
    main()
Buggy code:
N,M = list(map(int,input().split()))

if N==1:
    print(M)
else:
    ans = 1
    for i in range(1,10**5):
        if i*i>M:
            break
        if M%i==0:
            j = max(i.M//i)
            if j>=N:
                ans = max(j,ans)

    print(ans)

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

if N==1:
    print(M)
else:
    ans = 1
    for i in range(1,10**5):
        if i*i>M:
            break
        if M%i==0:
            j=0
            k=0
            if M//i>=N:
                j=i
            if i>=N:
                k=M//i
            ans = max(j,k,ans)

    print(ans)
Buggy code:
import math
N, M = map(int, input().split())
if N == 1:
    print(M)
    exit()

n = 0
for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        n = max(i, n)
    if i >= N:
        n = max(M//i, n)
    if M < i * N:
        break

print(n)


Fixed code:
import math
N, M = map(int, input().split())

n = 0
for i in range(1, int(math.sqrt(M))+1):
    if M < i * N:
        break

    if M % i == 0:
        n = max(i, n)
        if i >= N:
            n = max(M//i, n)

print(n)
Buggy code:
n,m=(int(i) for i in input().split())
p = int(m**(1/2))
divisors = []
for i in range(1,p+1):
    if m%i == 0:
        if n*i<m:
            divisors.append(i)
        if n*(m/i)<m:
            divisors.append(m/i)
print(max(divisors))

Fixed code:
n,m=(int(i) for i in input().split())
p = int(m**(1/2))
divisors = []
for i in range(1,p+1):
    if m%i == 0:
        if n*i<=m:
            divisors.append(i)
        if n<=i:
            divisors.append(int(m/i))
print(max(divisors))
Buggy code:
n,m = map(int,input().split())

a = min(int(m /n),m//2)

for i in range(a,a//2,-1):
  if m % i == 0:
    print(i)
    break

Fixed code:
n,m = map(int,input().split())

a = int(m /n)
for i in range(a,0,-1):
  if m % i == 0:
    print(i)
    break
Buggy code:
import math
n,m = map(int,input().split())
MAX = m//n
ans = 1
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
def divisor_sub(p, q):
    a = []
    for i in range(0, q + 1):
        a.append(p ** i)
    return a

def divisor(n):
    xs = factorization(n)
    ys = divisor_sub(xs[0][0], xs[0][1])
    for p, q in xs[1:]:
        ys = [x * y for x in divisor_sub(p, q) for y in ys]
    return sorted(ys)
a = divisor(m)
for i in a:
  if i <= MAX:
    ans = i
print(ans)

Fixed code:
import math
n,m = map(int,input().split())
MAX = m//n
ans = 1
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
def divisor_sub(p, q):
    a = []
    for i in range(0, q + 1):
        a.append(p ** i)
    return a

def divisor(n):
    if n == 1:
      return([1])
    xs = factorization(n)
    ys = divisor_sub(xs[0][0], xs[0][1])
    for p, q in xs[1:]:
        ys = [x * y for x in divisor_sub(p, q) for y in ys]
    return sorted(ys)
a = divisor(m)
for i in a:
  if i <= MAX:
    ans = i
print(int(ans))
Buggy code:
n,m=map(int,input().split())
def yak1(n,m):
  l=[]
  for i in range(1,min(int((m)**1/2+1)),m//n+1):
    if m%i==0:
      l.append(i)
      if m//(m//i)!=m/i and m//(m//i)<=m//n:
        l.append(m//i)
  return l
print(min(yak1(n,m)))      

Fixed code:
n,m=map(int,input().split())
def yak1(n,m):
  l=[]
  for i in range(1,min(int((m)**(1/2))+1,(m//n)+1)):
    if m%i==0:
      l.append(i)
      if m//i!=i and m//i<=m//n:
        l.append(m//i)
  return l
print(max(yak1(n,m)))
Buggy code:
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set)
    print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

    return

if __name__ == "__main__":
main()

Fixed code:
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set)
    print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

    return

main()
Buggy code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set if special_value >= M/j)
    print(int(max(list(divisor_set))))
    return

main()


Fixed code:
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M/j for j in divisor_set)
    print(int(max([i for i in divisor_set if special_value >= i])))
    return

main()
Buggy code:
# AGC112 D - Partition
from math import floor
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


n,m=map(int,input().split())

n_max=floor(m/n)
div_m=divisor(m)
div_m.sort(reverse=True)
ans=0
for i in div_m:
    if i<=n_max*n:
        ans=m//i
        print(ans)
        exit()


Fixed code:
# AGC112 D - Partition
from math import floor
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


n,m=map(int,input().split())

n_max=floor(m/n)
div_m=divisor(m)
div_m.sort(reverse=True)
ans=0
for i in div_m:
    if i<=n_max:
        print(i)
        exit()
Buggy code:
n,m=map(int,input().split())
x=1
if m%n==0:
    print(m//n)
else:
    for i in range(1,n):
        if m%i==0 and i*n<=m:
            x=max(i,m//i)
    print(x)

Fixed code:
n,m=map(int,input().split())
x=1
if m%n==0:
    print(m//n)
else:
    for i in range(1,int(m**0.5)+1):
        if m%i==0 and i*n<=m:
            x=max(x,i)
        if m%(m//i)==0 and (m//i)*n<=m:
            x=max(x,m//i)
    print(x)
Buggy code:
N, M = map(int, input().split(" "))
div1 = []
div2 = []

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        div1 += (i,)
        div2 += (M//i,)
for d in div2:
    if d * N <= M:
        print(d)
        break
else:
    div1 = div1[::-1]
    for d in div1:
        if d * N <= M:
            print(d)
            break

Fixed code:
import math

N, M = map(int, input().split(" "))
div1 = []
div2 = []

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        div1 += (i,)
        div2 += (M//i,)
for d in div2:
    if d * N <= M:
        print(d)
        break
else:
    div1 = div1[::-1]
    for d in div1:
        if d * N <= M:
            print(d)
            break
Buggy code:
import math
N, M = map(int, input().split())

def factorization(n):
    factor_list = []
    if n <= 1:
        return factor_list
    limit = int(math.sqrt(n))+1
    for i in range(2, limit):
        if n % i == 0:
            factor_list.append(i)
            if not n == i**2:
                factor_list.append(n//i)

    return factor_list

factor = factorization(M)
factor.sort()
print(factor)
ans = 1
for f in factor:
    if N * f <= M and f > ans:
        ans = f
print(ans)

Fixed code:
import math
N, M = map(int, input().split())

def factorization(n):
    factor_list = []
    if n < 1:
        return factor_list
    limit = int(math.sqrt(n))+1
    for i in range(1, limit):
        if n % i == 0:
            factor_list.append(i)
            if not n == i**2:
                factor_list.append(n//i)
    factor_list.sort()
    return factor_list

factor = factorization(M)


ans = 1
for f in factor:
    if N * f <= M and f > ans:
        ans = f
print(ans)
Buggy code:
def factorize(M):
    fact=[]
    for i in range(2,4*10**4):
        tmp=[1]
        if M==1:
            break
        while M%i==0:
            M//=i
            tmp.append(tmp[-1]*i)
        if len(tmp)>1:
            fact.append(tmp)
    return fact

def divisor(fact,arr,i,p):
    if i == len(fact):
        arr.append(p)
        return 0
    for x in fact[i]:
        divisor(fact,arr,i+1,p*x)
    
N,M=list(map(int,input().split()))

fact = factorize(M)
arr=[]
divisor(fact,arr,0,1)
print(fact)
arr=sorted(arr)
print(arr)
ans=1
for x in arr:
    if x>M//N:
        break
    ans=x
print(ans)

Fixed code:
def factorize(M):
    fact=[]
    for i in range(2,10**5):
        tmp=[1]
        if M==1:
            break
        while M%i==0:
            M//=i
            tmp.append(tmp[-1]*i)
        if len(tmp)>1:
            fact.append(tmp)
    if M!=1:
        fact.append([1,M])
    return fact

def divisor(fact,arr,i,p):
    if i == len(fact):
        arr.append(p)
        return 0
    for x in fact[i]:
        divisor(fact,arr,i+1,p*x)
    
N,M=list(map(int,input().split()))

fact = factorize(M)
arr=[]
divisor(fact,arr,0,1)
arr=sorted(arr)
ans=1
for x in arr:
    if x>M//N:
        break
    ans=x
print(ans)
Buggy code:
n,m=map(int,input().split())
ans=1
for i in range(2,int(m**(1/2))+1):
    if m%i==0:
        if i>=n:ans=max(m//i*(n//i),ans)
        if m//i>=n:
            ans=max(i*(m//i//n),ans)
print(ans)

Fixed code:
n,m=map(int,input().split())
ans=1
for i in range(1,int(m**(1/2))+1):
    if m%i==0:
        if i>=n:ans=max(m//i,ans)
        if m//i>=n:
            ans=max(i,ans)
print(ans)
Buggy code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
ans = 0
for param in params:
    if n > m / iparam:
        break
    ans = param
print(ans)

Fixed code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
ans = 0
for param in params:
    if n > m / param:
        break
    ans = param
print(ans)
Buggy code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(2, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if m > m / i:
        break
    maxans = i
print(maxans)

Fixed code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {m:1}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)
Buggy code:
n,m=map(int,input().split())
m_root=int(m**0.5)
div_l=[]
ans=0

for i in range(1,m_root + 1):
    if m%i == 0:
        div_l.append(i)
        div_l.append(m//i)

if n//m in div_l:
    ans = m//n
else:
    div_l.append(m//n)
    div_l.sort()
    ans = div_l[div_l.index(m//n) - 1]
print(ans)

Fixed code:
n,m=map(int,input().split())
m_root=int(m**0.5)
div_l=[]
ans=0

for i in range(1,m_root + 1):
    if m%i == 0:
        div_l.append(i)
        div_l.append(m//i)

if m//n in div_l:
    ans = m//n
else:
    div_l.append(m//n)
    div_l.sort()
    ans = div_l[div_l.index(m//n) - 1]
print(ans)
Buggy code:
import bisect
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
        if(N//i!=i):
            arr.append(N//i)
    return arr

N,M=map(int,input().split())
li=sorted(factor(M))
res=1
for i in li:
    if(i>M//N):
        break
    if(M//i>=N):
        res=i
print(res)

Fixed code:
import bisect
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr

N,M=map(int,input().split())
li=sorted(factor(M))
res=1
for i in li:
    if(i>M//N):
        break
    if(M//i>=N):
        res=i
print(res)
Buggy code:
N, M = map(int, input().split())

ans = 1
for i in range(1,min(int(M ** 0.5) + 1, M // N + 1)):
    if M % i == 0:
        ans = max(ans, M // i)

print(ans)

Fixed code:
N, M = map(int, input().split())

ans = 1
for i in range(1,int(M ** 0.5) + 1):
    if M % i == 0:
        if i >= N:
            ans = max(ans, M // i)
        if M // i >= N:
            ans = max(ans, i)

print(int(ans))
Buggy code:
N,M = 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
div = sorted(make_divisors(M))
import bisect
ind = bisect.bisect_right(div,N)
print(div[ind-1])

Fixed code:
N,M = 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
div = sorted(make_divisors(M))
import bisect
ind = bisect.bisect_right(div,M/N)
print(div[ind-1])
Buggy code:
N, M = map(int, input().split())

ans = 1
for i in range(1,int(M ** 0.5) + 1):
    if M % i == 0:
        if i >= M // N:
            ans = max(ans, M // i)
        if M // i >= M // N:
            ans = max(ans, i)

print(int(ans))

Fixed code:
N, M = map( int, input().split())
ans = 1
for i in range(1, N):
    if M%i == 0 and M//i >= N:
        ans = max( ans, i)
for i in range(N,int(M**(0.5))+2):
    if M%i == 0:
        ans = max( max( ans, i), M//i)
        break
print(ans)
Buggy code:
N, M = map(int, input().split())
div = []
for i in range(1, M + 1):
    if i * i > M:
        break
    if M % i == 0:
        div.append(i)
    if M % i == 0 and i != M // i:
        div.append(M // i)
div.sort()
div.reverse()
print(div)
for i in div:
    if M // i >= N:
        print(i)
        break


Fixed code:
N, M = map(int, input().split())
div = []
for i in range(1, M + 1):
    if i * i > M:
        break
    if M % i == 0:
        div.append(i)
    if M % i == 0 and i != M // i:
        div.append(M // i)
div.sort()
div.reverse()
for i in div:
    if M // i >= N:
        print(i)
        break
Buggy code:
n,m = map(int,input().split())
ans = 0
for i in range(1,int(n**0.5)+1):
  if m % i == 0 and m // i >= n:
    ans = max(ans,i)
  if m % i == 0 and i >= n:
    ans = max(ans,m//i)
print(ans)

Fixed code:
n, m = map(int, input().split())
ans = 1
for i in range(1, int(m ** 0.5) + 1):
    if m % i == 0:
        if i >= n:
            ans = max(ans, m // i)
        elif (m // i) >= n:
            ans = max(ans, i)
print(ans)
Buggy code:
n,m = map(int,input().split())
ans = 1
if m % n == 0:
  print(m//n)
  exit()
else:
  for i in range(2,int(n**0.5)+1):
    if m % i == 0 and m // i >= n:
      ans = max(ans,i)
    if m % i == 0 and i >= n:
      ans = max(ans,m//i)
print(ans)

Fixed code:
n,m = map(int,input().split())
ans = 0
for i in range(1,int(m**0.5)+1):
  if m % i == 0 and m // i >= n:
    ans = max(ans,i)
  if m % i == 0 and i >= n:
    ans = max(ans,m//i)
print(ans)
Buggy code:
N, M = 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

div = sorted(make_divisors(M))
while M//div[i]>=N:
    ans = div[i]
    i+=1
    
print(ans)

Fixed code:
N, M = 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

if N==1:
    print(M)

else:
    div = sorted(make_divisors(M))
    i = 0 
    while i<=len(div) and M//div[i]>=N:
        ans = div[i]
        i+=1
    print(ans)
Buggy code:
N, M = map(int, input().strip().split())

i=1
while i*i < M:
  if M % i == 0:
    maxg = M // N
  i += 1

print(maxg)

Fixed code:
N, M = map(int, input().strip().split())

i=1
while i <= M//N: 
  if M % i == 0:
    maxg = i
    if M//i <= M//N:
      maxg = M // i
      break
  i += 1

print(maxg)
Buggy code:
N,M=map(int,input().split())
D=[]
for i in range(1,int(M**0.5+1)):
  if M%i==0:
    D.append(i)
    D.append(M//i)
D.sort()
print(D)
for j in D:
  if j >=N:
    print(M//j)
    exit()

Fixed code:
N,M=map(int,input().split())
D=[]
for i in range(1,int(M**0.5+1)):
  if M%i==0:
    D.append(i)
    D.append(M//i)
D.sort()
for j in D:
  if j >=N:
    print(M//j)
    exit()
Buggy code:
n,m = map(int,input().split())
gcd = m//n
while n*gcd != m:
  n = 1 + (M-1)//gcd
  gcd = M//n
print(gcd)

Fixed code:
n,m = map(int,input().split())
gcd = m//n
while n*gcd != m:
  gcd = m//n
  n = 1 + (m-1)//gcd
print(gcd)
Buggy code:
N, M = map(int, input().split())
ans = 1
n = 1
while n*n <= M//N:
    if M % n == 0:
        if M//n >= N:
            ans = max(n, ans)
        m = M//n
        if M//m >= N:
            ans = max(m, ans)
    n += 1
print(ans)


Fixed code:
N, M = map(int, input().split())
ans = 1
n = 1
while n*n <= M:
    if M % n == 0:
        if M//n >= N:
            ans = max(n, ans)
        m = M//n
        if M//m >= N:
            ans = max(m, ans)
    n += 1
print(ans)
Buggy code:
from math import sqrt
N,M=map(int, input().split())
tmp=int(sqrt(M))
ma=1
for i in range(1, tmp+1):
    if not M % i:
        div = M//i
        ma = max(i, ma, div if div <= N else 0)
print(ma)


Fixed code:
from math import sqrt
N,M=map(int, input().split())
tmp=int(sqrt(M))
ma=1
for i in range(1, tmp+1):
    if not M % i:
        div = M//i
        ma = max(i if i*N <= M else 0, ma, div if div*N <= M else 0)
print(ma)
Buggy code:
from math import sqrt
n, m = list(map(int, input().split()))
i = 1
lst = []
while i <= sqrt(m):
    if m % i == 0:
        j = m // i
        if i >= n:
            lst.append(i)
        if j >= n:
            lst.append(j)
        i += 1
print(m//min(lst))

Fixed code:
from math import sqrt
n, m = list(map(int, input().split()))
i = 1
lst = []
while i <= sqrt(m):
    if m % i == 0:
        j = m // i
        if i >= n:
            lst.append(i)
        if j >= n:
            lst.append(j)
    i += 1
print(m//min(lst))
Buggy code:
N, M = map(int, input().split())

import math

divisor=[]
for i in range(1, M+1):
    if M%i==0:
        divisor.append(i)
#print(divisor)

divisor=list(reversed(divisor))
for val in divisor:
    if M//val>=N:
        print(val)
        break

Fixed code:
N, M = map(int, input().split())

import math

divisor=[]
for i in range(1, math.ceil(math.sqrt(M))+1):
    if M%i==0:
        divisor.append(i)
#print(divisor)

divisor+=[M//val for val in reversed(divisor)]
#print(divisor)
for val in divisor:
    if val>=N:
        print(M//val)
        break
Buggy code:
n,m = map(int,input().split())
divisors = []
for i in range(1,int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i)
        divisors.append(n//i)
divisors.sort()
k = 0
for i in range(len(divisors)):
    if divisors[i] > m/n:
        k = i - 1
        break
    if i == len(divisors) - 1:
        k = len(divisors) - 1
print(divisors[i])

Fixed code:
n,m = map(int,input().split())
divisors = []
for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        divisors.append(i)
        divisors.append(m//i)
divisors.sort()
k = 0
for i in range(len(divisors)):
    if divisors[i] > m/n:
        k = i - 1
        break
    if i == len(divisors) - 1:
        k = len(divisors) - 1
print(divisors[k])
Buggy code:
n, m = list(map(int,input().split()))
def solve():
    for i in range(m//n, 0, -1):
        if m % i == 0:
			print(i)
            break
solve()

Fixed code:
n, m = list(map(int,input().split()))
def solve():
    for i in range(m//n, 0, -1):
        if m % i == 0:
            if m//i>= n:
                print(i)
                break
solve()
Buggy code:
n, m = map(int, input().split())
if m%2:
    for i in range(m//n, 0, -2):
    if not m%i:
        print(i)
        break
else:
    for i in range(m//n, 0, -1):
        if not m%i:
            print(i)
            break

Fixed code:
n, m = map(int, input().split())
for i in range(m//n, 0, -1):
    if not m%i:
        print(i)
        break