Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, 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

amax = M // N
L = make_divisor_list(M)
L = [i for i in L if i <= amax]

ans = L[-1]

print(ans)


Fixed submission:
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 python submission (verdict: Time Limit Exceeded):
N, M = map(int, 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

amax = M // N
L = make_divisor_list(M)
L = [i for i in L if i <= amax]

if M % N == 0:
    ans = int(M/N)
else:
    for i in L[::-1]:
        if (M - (i * N)) % i == 0:
            ans = i
            break

print(ans)


Fixed submission:
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 python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

if M % N == 0:
    ans = int(M/N)

elif M / N > 100000000:
    ans = 1

else:
    amax = M // N
    for i in range(amax, 0, -1):
        if (M - (i * N)) % i == 0:
            ans = i
            break

print(ans)

Fixed submission:
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 python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

if M % N == 0:
    ans = int(M/N)
else:
    amax = M // N
    for i in range(amax, 0, -1):
        if (M - (i * N)) % i == 0:
            ans = i
            break

print(ans)

Fixed submission:
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 python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

amax = M // N
for i in range(amax, 0, -1):
    if (M - (i * N)) % i == 0:
        ans = i
        break

print(ans)

Fixed submission:
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))