qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n=int(input())
p=[list(map(int,input().split()))for i in range(n)]
for i in range(n):
  if p[i][2]==0:
    p.del(i)
if len(p)==1:
  print(p[0][0],p[0][1],p[0][2])
else:
  for i in range(0,101):
    for j in range(0,101):
      k=1
      l=p[0][2]+abs(i-p[0][0])+abs(j-p[0][1])
      for x,y,h in p:
        if h==0:
          continue
        m=h+abs(i-x)+abs(j-y)
        if l!=m:
          k=0
      if k:
        ans=[i,j,l]
  print(ans[0],ans[1],ans[2])


Fixed code:
n=int(input())
p=[list(map(int,input().split()))for i in range(n)]
d=[]
for i in range(n):
  if p[i][2]==0:
    d.append(i)
d.sort(reverse=1)
for i in d:
  del p[i]
if len(p)==1:
  print(p[0][0],p[0][1],p[0][2])
else:
  for i in range(0,101):
    for j in range(0,101):
      k=1
      l=p[0][2]+abs(i-p[0][0])+abs(j-p[0][1])
      for x,y,h in p:
        if h==0:
          continue
        m=h+abs(i-x)+abs(j-y)
        if l!=m:
          k=0
      if k:
        ans=[i,j,l]
  print(ans[0],ans[1],ans[2])
Buggy code:
import numpy as np

N = int(input())

point = [[int(item) for item in input().split()] for _ in range(N)]
point.sort(key=lambda x:x[2], reverse=True)

ans = np.zeros((101,101))

for i,p in enumerate(point):
  if i == 0:
    for j in range(101):
      for k in range(101):
        H = p[2] + abs(j - p[0]) + abs(k - p[1])
        ans[j,k] = H
        print(ans[j,k])
  else:
    for j in range(101):
      for k in range(101):
        if not ans[j,k] == 0:
          if ans[j,k] != p[2] + abs(j - p[0]) + abs(k - p[1]):
            ans[j,k] = 0
  if len(ans[ans!=0]) <= 1:
    break
x,y = np.where(ans!=0)
print(x[0],y[0],int(ans[x[0],y[0]]))

Fixed code:
import numpy as np

N = int(input())

point = [[int(item) for item in input().split()] for _ in range(N)]
point.sort(key=lambda x:x[2], reverse=True)

ans = np.zeros((101,101))

for i,p in enumerate(point):
  if i == 0:
    for j in range(101):
      for k in range(101):
        H = p[2] + abs(j - p[0]) + abs(k - p[1])
        ans[j,k] = H
      #  print(ans[j,k])
  else:
    for j in range(101):
      for k in range(101):
        if not ans[j,k] == 0:
          if ans[j,k] != p[2] + abs(j - p[0]) + abs(k - p[1]):
            ans[j,k] = 0
  if len(ans[ans!=0]) <= 1:
    break
x,y = np.where(ans!=0)
print(x[0],y[0],int(ans[x[0],y[0]]))
Buggy code:
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

for _ in range(0,n):
    if ab[_][2] !=0:
        x = ab[_][0]
        y = ab[_][1]
        h = ab[_][2]

for i in range(101):
    for j in range(101):
        f = True
        l = abs(i-x)+abs(i-y)+h
        for k in range(0,n):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            if max(l-abs(i-dx)-abs(j-dy),0) ==dh:
                pass
            else:
                f = False
                break
        if f:
            ansx =i
            ansy =j
            ansr = l
            break
print(str(ansx)+" "+str(ansy)+" "+str(ansr))

Fixed code:
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

for _ in range(0,n):
    if ab[_][2] !=0:
        x = ab[_][0]
        y = ab[_][1]
        h = ab[_][2]
        break

for i in range(101):
    for j in range(101):
        f = True
        l = abs(i-x)+abs(j-y)+h
        for k in range(0,n):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            if max(l-abs(i-dx)-abs(j-dy),0) ==dh:
                pass
            else:
                f = False
        if f:
            ansx =i
            ansy =j
            ansr = l
            break
print(str(ansx)+" "+str(ansy)+" "+str(ansr))
Buggy code:
N = int(input())

xyh = []

for i in range(N):
    x,y,h = map(int, input().split())
    xyh.append([x,y,h])

print("xyh",xyh)

xyh.sort(reverse=True, key=lambda x: x[2])

print("xyh",xyh)

for i in range(101):
    for j in range(101):
        px, py, ph = xyh[0]
        H = ph + abs(px-i) + abs(py-j)
        if all(h == max(H-abs(x - i) - abs(y - j),0) for x, y, h in xyh):
            print(i,j,H)
            break


Fixed code:
N = int(input())

xyh = []

for i in range(N):
    x,y,h = map(int, input().split())
    xyh.append([x,y,h])

xyh.sort(reverse=True, key=lambda x: x[2])

for i in range(101):
    for j in range(101):
        px, py, ph = xyh[0]
        H = ph + abs(px-i) + abs(py-j)
        if all(h == max(H-abs(x - i) - abs(y - j),0) for x, y, h in xyh):
            print(i,j,H)
            break
Buggy code:
N = int(input())
P = [list(map(int,input().split())) for k in range(N)]

for h in range(P[0][2]+1,P[0][2]+201):
    for x in range(101):
        for y in range(101):
            f = 1
            for e in P:
                if e[2] != max(0,h-abs(e[0]-x)-abs(e[1]-y)):
                    f = 0
                    break
            if f == 1:
                print(x,y,h)
                exit(0)


Fixed code:
N = int(input())
P = [list(map(int,input().split())) for k in range(N)]

for h in range(P[0][2],P[0][2]+201):
    for x in range(101):
        for y in range(101):
            f = 1
            for e in P:
                if e[2] != max(0,h-abs(e[0]-x)-abs(e[1]-y)):
                    f = 0
                    break
            if f == 1:
                print(x,y,h)
                exit(0)
Buggy code:
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.sort(key=lambda x:x[2],reverse=True)
def cal(y,x,datum):
  if datum[2]==0:
    return
  return abs(y-datum[1])+abs(x-datum[0])+datum[2]
for i in range(101):
  for j in range(101):
    height=cal(i,j,data[0])
    flag=0
    for k in data[1:]:
      if height!=cal(i,j,k):
        flag=1
        break
    if flag:pass
    else:print(height);exit()

Fixed code:
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.sort(key=lambda x:x[2],reverse=True)
def cal(y,x,datum,height):
  return max(height-(abs(y-datum[1])+abs(x-datum[0])),0)==datum[2]
for i in range(101):
  for j in range(101):
    height=abs(i-data[0][1])+abs(j-data[0][0])+data[0][2]
    flag=0
    for k in data[1:]:
      if not cal(i,j,k,height):
        flag=1
        break
    if flag:pass
    else:print(j,i,height);exit()
Buggy code:
from sys import stdin
n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
point = 0
for i in range(101):
    for j in range(101):
        flag = True
        kizyun = False
        count = 0
        for a,b,c in li:
            if c != 0:
                count += 1
                if kizyun == False:
                    h = c+abs(a-i)+abs(b-j)
                    if h-abs(a-i)-abs(b-j) != c:
                        flag = False
                    kizyun = True
                else:
                    k = c+abs(a-i)+abs(b-j)
                    if h != k and kizyun == True:
                        flag = False
            if count == 1:
                print(a,b,c)
                exit()
        if flag == True:
            point += 1
            print(i,j,h)

Fixed code:
from sys import stdin
n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
point = 0
for i in range(101):
    for j in range(101):
        flag = True
        kizyun = False
        count = 0
        for a,b,c in li:
            if c != 0:
                count += 1
                if kizyun == False:
                    h = c+abs(a-i)+abs(b-j)
                    if h-abs(a-i)-abs(b-j) != c:
                        flag = False
                    kizyun = True
                else:
                    k = c+abs(a-i)+abs(b-j)
                    if h != k and kizyun == True:
                        flag = False
        if count == 1:
            print(a,b-1,c+1)
            exit()
        if flag == True:
            point += 1
            print(i,j,h)
Buggy code:
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
for cx in range(101):
    for cy in range(101):
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            break

print(cx,cy,h)

Fixed code:
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
Cx,Cy,H = -1,-1,-1
        
for cx in range(101):
    for cy in range(101):
        if H >= 0:
            break
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            Cx,Cy,H = cx,cy,h

print(Cx,Cy,H)
Buggy code:
n,m=map(int,input().split())
ans=1
for i in range(1,m**0.5+1):
    if m%i==0:
        if m/i>=n:
            ans=max(ans,i)
        elif 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 m/i>=n:
            ans=max(ans,i)
        if i>=n:
            ans=max(ans,m//i)
print(ans)
Buggy code:
from math import sqrt
N, M = map(int, input().split())
cand = 1
for i in range(1, int(sqrt(M))+1):
    if M % i == 0:
        if M >= (M // i) * N:
            cand = max(cand, M//i)
        else:
            cand = max(cand, i)
print(cand)

Fixed code:
from math import sqrt
N, M = map(int, input().split())
cand = 1
for i in range(1, int(sqrt(M))+1):
    if M % i == 0:
        if M >= (M // i) * N:
            cand = max(cand, M//i)
        elif M >= i * N:
            cand = max(cand, i)
print(cand)
Buggy code:
#!/usr/bin/env python3
import sys

def factoring(n: int):
    factors = []
    p = 1
    while p * p <= n:
        if n % p == 0:
            factors.append(p)
            if n != p * p:
                factors.append(n // p)
        p += 1
    return factors

def solve(N: int, M: int):
    if N == 1:
        print(M)
        return
    F = factoring(M)
    F.sort()
    print(F)
    for f in F:
        if f >= N:
            print(M // f)
            break
    return


# Generated by 1.1.4 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()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


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

def factoring(n: int):
    factors = []
    p = 1
    while p * p <= n:
        if n % p == 0:
            factors.append(p)
            if n != p * p:
                factors.append(n // p)
        p += 1
    return factors

def solve(N: int, M: int):
    if N == 1:
        print(M)
        return
    F = factoring(M)
    F.sort()
    for f in F:
        if f >= N:
            print(M // f)
            break
    return


# Generated by 1.1.4 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()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()
Buggy code:
import math

# N, M = map(int, input().split())

N = 100000
M = 1000000000

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values

L = pfac(M)
L = [i for i in L if i * N <= M]

ans = []
for i in L[::-1]:
    if (M - (N * i)) % i == 0:
    # if M % i == 0:
        ans.append(i)
print(max(ans))

# ans2 = 1
# for i in L[::-1]:
#     if (M - (N * i)) % i == 0:
#     # if M % i == 0:
#         ans2 = i
#         break
# print(ans2)

Fixed code:
import math

N, M = map(int, input().split())

# N = 100000
# M = 1000000000

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values

L = pfac(M)
L = [i for i in L if i * N <= M]

ans = []

for i in L[::-1]:
    # if (M - (N * i)) % i == 0:
    if M % i == 0:
        ans.append(i)

print(max(ans))
Buggy code:
import math
n, m = map(int, input().split())
fact = []
ans = 1
MAX = int(math.sqrt(m)) + 1
for i in range(1, MAX):
    if m % i == 0:
        fact.append(i)
        if i != m // i:
            fact.append(m//i)
fact.sort()
for x in fact:
    if x > n:
        break
    ans = x
print(ans)

Fixed code:
import math
n, m = map(int, input().split())
fact = []
ans = 1
MAX = int(math.sqrt(m)) + 1
for i in range(1, MAX):
    if m % i == 0:
        fact.append(i)
        if i != m // i:
            fact.append(m//i)
fact.sort()
for x in fact:
    if m < n * x:
        break
    ans = x
print(ans)
Buggy code:
from math import sqrt
from math import floor
n,m = map(int,input().split())
d = m // n
ans = 1
for i in range(1,floor(sqrt(m))+1):
    if m % i == 0:
        x = m // i
        if i <= d:
            ans = max(ans,x,i)
print(ans)

Fixed code:
from math import sqrt
from math import floor
n,m = map(int,input().split())
d = m // n
ans = 1
for i in range(1,floor(sqrt(m))+1):
    if m % i == 0:
        x = m // i
        if i <= d:
            ans = max(ans,i)
        if x <= d:
            ans = max(ans,x)
print(ans)
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

N,M = map(int,input().split())
arr = [i for i in make_divisors(M) if i>N]
print(M//min(arr))


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

N,M = map(int,input().split())
arr = [i for i in make_divisors(M) if i>=N]
print(M//min(arr))
Buggy code:
import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x > mid:
    ans = []
    for i in range(1, mid+1):
        ans.append(i)
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    ans = []
    for i in range(x, 0, -1):
        if M%i == 0:
            print(i)
            break

Fixed code:
import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    for i in range(x, 0, -1):
        if M%i == 0:
            print(i)
            break
Buggy code:
import math
n, m = map(int, input().split()) X=1
for i in range(1,32000):
	if m%i==0:
		if i*n<=m:
			X=max(X, i)
		if (m//i)*n<=m:
			X=max(X, m//i)
print(X)

Fixed code:
import math
n, m = map(int, input().split())
X=1
for i in range(1,32000):
	if m%i==0:
		if i*n<=m:
			X=max(X, i)
		if (m//i)*n<=m:
			X=max(X, m//i)
print(X)
Buggy code:
import math
n, m = map(int, input().split())
kotae=1

for i in range(1,int(math.sqrt(m))+1):
  if m%i==0:
    if i*n<=m:
	  kotae=max(kotae,i)
    if (m/i)*n<=m:
      kotae=max(kotae,i)
print(kotae)

Fixed code:
import math
n, m = map(int, input().split())
kotae=1

for i in range(1,int(math.sqrt(m))+1):
	if m%i==0:
		if i*n<=m:
			kotae=max(kotae, i)
		if (m//i)*n<=m:
			kotae=max(kotae, m//i)
print(kotae)
Buggy code:
N,M = map(int,input().split())

ds = set()
n = 1
while n*n <= M:
    if M%n==0:
        ds.add(n)
        ds.add(M//n)
    n += 1

ans = 1
for d in ds:
    if d <= N:
        ans = max(ans, d)
print(ans)

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

divs = set()
n = 1
while n*n <= M:
    if M%n == 0:
        divs.add(n)
        divs.add(M//n)
    n += 1

ans = 0
for d in divs:
    if d <= M//N:
        ans = max(ans,d)
print(ans)
Buggy code:
def f():
  n,m=map(int,input().split())
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
f()

Fixed code:
def f():
  n,m=map(int,input().split())
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
print(f())
Buggy code:
import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)

Fixed code:
import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
ans = 0
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)
Buggy code:
import sys
import math
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
ans = 1
for i in range(2, math.ceil(math.sqrt(m)) + 1):
    if m % i == 0:
        ans = max(i, m // i)
print(ans)


Fixed code:
import sys
import math
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
ans = 1
for i in range(1, int(math.sqrt(m)) + 2):
    if m % i == 0:
        if m // i >= n and i >= n:
            ans = max(ans, i, m // i)
        elif m // i >= n:
            ans = max(ans, i)
        elif i >= n:
            ans = max(ans, m // i)
print(ans)
Buggy code:
def divisor(n):
    i = 1
    res = []
    for i in range(1, n**.5 + 1)
        if n%i == 0:
            res.append(i)
            if n//i not in res:
                res.append(n//i)
    res.sort(reverse=True)
    return res

def main():
    n, m = map(int, input().split())
    md = divisor(m)
    for i in md:
        if i*n <= m:
            print(i)
            exit()

if __name__ == '__main__':
    main()

Fixed code:
def divisor(n):
    i = 1
    res = []
    for i in range(1, int(n**.5) + 1):
        if n%i == 0:
            res.append(i)
            if n//i not in res:
                res.append(n//i)
    res.sort(reverse=True)
    return res

def main():
    n, m = map(int, input().split())
    md = divisor(m)
    ans = 0
    for i in md:
        if i*n <= m:
            print(i)
            exit()

if __name__ == '__main__':
    main()
Buggy code:
import bisect

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

n_facs_s = []
n_facs_l = []
for i in range(1, int(-(-n**0.5//1))+1):
    if m%i == 0:
        n_facs_s.append(i)
        n_facs_l.append(m//i)

n_faces = n_facs_s + n_facs_l
ind = bisect.bisect_right(n_faces, n)
print(m//n_faces[ind])


Fixed code:
import bisect

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

n_facs_s = []
n_facs_l = []
for i in range(1, int(-(-m**0.5//1))+1):
    if m%i == 0:
        n_facs_s.append(i)
        n_facs_l.append(m//i)


n_faces = n_facs_s + n_facs_l[::-1]
ind = bisect.bisect_right(n_faces, n)
if n_faces[ind-1] == n:
    ind-=1
print(m//n_faces[ind])
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

N,M=map(int,input().split())
divisors=make_divisors(M)
ans=0
for d in divisors:
    if N*d<=M:
        ans=d
    else:
        break

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

N,M=map(int,input().split())
divisors=make_divisors(M)
ans=0
for d in divisors:
    if N*d<=M:
        ans=d
    else:
        break
print(ans)
Buggy code:
n,m = map(int, input().split())
l = []
for i in range(1,int(m**0.5)+1):
  if m%i == 0:
    if i <= n:
      l.append(i)
    if m//i <= n:
      l.append(m//i)
print(max(l))

Fixed code:
n,m = map(int, input().split())
l = []
for i in range(1,int(m**0.5)+1):
  if m%i == 0:
    l.append(i)
    l.append(m//i)
r = [x for x in l if x <= m//n]
print(max(r))
Buggy code:
import math
n, m = map(int, input().split())

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
for i in range(len(b)):
    if i * n <= m:
        a.append(i)
        print(max(a))

if len(b) == 2:
    print(1)
else:
    print(max(a))


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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
#print(b)

for i in range(len(b)):
    if b[i] * n <= m:
        a.append(b[i])
#print(a)

if len(b) == 2:
    print(1)
else:
    print(max(a))
Buggy code:
n, m = map(int, input().split())
k = m//n
ans = 0
for i in range(1, int(m**0.5)+1):
  if m%i == 0:
    if i <= k:
      if i <= k:
      ans = max(ans, i)
    if m//i <= k:
      ans = max(ans, m//i)
print(ans)

Fixed code:
n, m = map(int, input().split())
k = m//n
ans = 0
for i in range(1, int(m**0.5)+1):
  if m%i == 0:
    if i <= k:
      ans = max(ans, i)
    if m//i <= k:
      ans = max(ans, m//i)
print(ans)
Buggy code:
n,m = map(int,input().split())

ans = 1

for i in range(1,int(m**0.5)+1):
    if m % i == 0 and m /n >= i:
        ans = max(ans,i)
        if i != n // i and m/n >= (n//i):
            ans = max(ans,n // 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 and m /n >= i:
        ans = max(ans,i)
        if i != m // i and m/n >= (m//i):
            ans = max(ans,m // i)

print(ans)
Buggy code:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]


def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list


n,m = ai()
d = make_divisor_list(m)
d = d[::-1]
for k in d:
    if m/k == m//k and m//k >= n:
        print(k)
        exit()
print(1)

Fixed code:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]


def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(1, 100):
            if num % i == 0:
                divisor_list.append(i)
                divisor_list.append(num//i)
        for i in range(2, num // 100 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return sorted(divisor_list)


n,m = ai()
d = make_divisor_list(m)
d = d[::-1]
for k in d:
    if m/k == m//k and m//k >= n:
        print(k)
        exit()
print(1)