Buggy python submission (verdict: Time Limit Exceeded):
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    # if i * i > M:
    #     break
    if M % i == 0:
        ans = i
print(ans)


Fixed submission:
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if i * i > M:
        break
    if M % i == 0:
        j = M // i
        if j <= V:
            ans = max(ans, j)
        else:
            ans = max(ans, i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if M % i == 0:
        ans = i
print(ans)


Fixed submission:
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if i * i > M:
        break
    if M % i == 0:
        j = M // i
        if j <= V:
            ans = max(ans, j)
        else:
            ans = max(ans, i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if M % i == 0:
        ans = i
print(ans)


Fixed submission:
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if i * i > M:
        break
    if M % i == 0:
        j = M // i
        if j <= V:
            ans = max(ans, j)
        else:
            ans = max(ans, i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# 1 <= N <= 10**5
# N <= M <= 10**9
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if M % i == 0:
        ans = i
print(ans)


Fixed submission:
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if i * i > M:
        break
    if M % i == 0:
        j = M // i
        if j <= V:
            ans = max(ans, j)
        else:
            ans = max(ans, i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
import numpy as np
N, M = map(int, input().split())
original_M = M
# 素因数分解して N より大きい数になるまで積をかけた時、残りの数の積が答え
# M = N * a -> gcm : a
# M = 2 * b

U = 10**5 * 1
is_prime = np.full(U, True, dtype='bool')
is_prime[0:2] = False
for i in range(2, U):
    if i * i > U:
        break
    if is_prime[i]:
        is_prime[i * 2::i] = False

primes = np.arange(U)[is_prime]
v = []
while M not in primes:
    for prime in primes:
        if M % prime == 0:
            v.append(prime)
            M //= prime
            break
v.append(M)
v = np.array(v)
# print('v', v)
v_prod = [
    v[np.array(list(i), dtype='bool')].prod()
    for i in product([True, False], repeat=len(v))
]
v_prod = sorted(v_prod)
# print(v_prod)
idx = np.searchsorted(v_prod, N, side='left')
# print(v_prod[idx])
ans = original_M // v_prod[idx]
print(ans)


Fixed submission:
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if i * i > M:
        break
    if M % i == 0:
        j = M // i
        if j <= V:
            ans = max(ans, j)
        else:
            ans = max(ans, i)
print(ans)