Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

max_ans = M // N

tmpM = M
insu = {}
tmp = 2
while tmpM != 1:
    if tmpM % tmp == 0:
        insu[tmp] = insu.get(tmp, 0) + 1
        tmpM = tmpM // tmp
        continue
    else:
        if tmp == 2:
            tmp = 3
        elif tmpM // tmp == 1:
            tmp = tmpM
        else:
            tmp += 2

ins = set()
for k, v in insu.items():
    # print(ins, k, v)
    ins.add(1)
    for s in list(ins):
        t = 1
        for _ in range(v):
            t *= k
            ans = t * s
            if ans > max_ans:
                break
            ins.add(ans)
# print(ins)
print(max(ins))

Fixed submission:
from itertools import product

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

max_ans = M // N

ans = 1
tmp = 2
tmpM = M
max_prime = int(M ** 0.5)
all_list = []
i = -1
k = 0
div = 2
while tmpM != 1:
    if tmpM % div == 0:
        tmpM = tmpM // div
        if k == 0:
            i += 1
            all_list.append(set())
            all_list[i].add(div ** k)
            k += 1
        all_list[i].add(div ** k)
        k += 1

    else:
        k = 0
        if div == 2:
            div = 3
        elif div > max_prime:
            div = tmpM
        else:
            div += 2

if all_list == []:
    print(1)
    exit()

# print(all_list)
ans = 1

for div_tuple in product(*all_list):
    tmp = 1
    for k in div_tuple:
        tmp *= k
        if tmp > max_ans:
            break
    else:
        ans = max(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

max_ans = M // N

tmpM = M
insu = {}
tmp = 2
while tmpM != 1:
    if tmpM % tmp == 0:
        insu[tmp] = insu.get(tmp, 0) + 1
        tmpM = tmpM // tmp
        continue
    else:
        if tmp == 2:
            tmp = 3
        elif tmpM // tmp == 1:
            tmp = tmpM
        else:
            tmp += 2

ins = set()
ins.add(1)
for k, v in insu.items():
    tmp = [k ** i for i in range(v + 1)]
    for s in list(ins):
        for t in tmp:
            ans = t * s
            if ans > max_ans:
                break
            ins.add(ans)
# print(ins)
print(max(ins))

Fixed submission:
from itertools import product

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

max_ans = M // N

ans = 1
tmp = 2
tmpM = M
max_prime = int(M ** 0.5)
all_list = []
i = -1
k = 0
div = 2
while tmpM != 1:
    if tmpM % div == 0:
        tmpM = tmpM // div
        if k == 0:
            i += 1
            all_list.append(set())
            all_list[i].add(div ** k)
            k += 1
        all_list[i].add(div ** k)
        k += 1

    else:
        k = 0
        if div == 2:
            div = 3
        elif div > max_prime:
            div = tmpM
        else:
            div += 2

if all_list == []:
    print(1)
    exit()

# print(all_list)
ans = 1

for div_tuple in product(*all_list):
    tmp = 1
    for k in div_tuple:
        tmp *= k
        if tmp > max_ans:
            break
    else:
        ans = max(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

max_ans = M // N
if M % 2 == 1:
    x = 2
else:
    x = 1

for a in reversed(range(1, max_ans + 1, x)):
    mod = M % a
    if mod == 0:
        print(a)
        exit()

Fixed submission:
from itertools import product

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

max_ans = M // N

ans = 1
tmp = 2
tmpM = M
max_prime = int(M ** 0.5)
all_list = []
i = -1
k = 0
div = 2
while tmpM != 1:
    if tmpM % div == 0:
        tmpM = tmpM // div
        if k == 0:
            i += 1
            all_list.append(set())
            all_list[i].add(div ** k)
            k += 1
        all_list[i].add(div ** k)
        k += 1

    else:
        k = 0
        if div == 2:
            div = 3
        elif div > max_prime:
            div = tmpM
        else:
            div += 2

if all_list == []:
    print(1)
    exit()

# print(all_list)
ans = 1

for div_tuple in product(*all_list):
    tmp = 1
    for k in div_tuple:
        tmp *= k
        if tmp > max_ans:
            break
    else:
        ans = max(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

max_ans = M // N

for a in reversed(range(1, max_ans + 1)):
    mod = M % a
    if mod == 0:
        print(a)
        exit()

Fixed submission:
from itertools import product

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

max_ans = M // N

ans = 1
tmp = 2
tmpM = M
max_prime = int(M ** 0.5)
all_list = []
i = -1
k = 0
div = 2
while tmpM != 1:
    if tmpM % div == 0:
        tmpM = tmpM // div
        if k == 0:
            i += 1
            all_list.append(set())
            all_list[i].add(div ** k)
            k += 1
        all_list[i].add(div ** k)
        k += 1

    else:
        k = 0
        if div == 2:
            div = 3
        elif div > max_prime:
            div = tmpM
        else:
            div += 2

if all_list == []:
    print(1)
    exit()

# print(all_list)
ans = 1

for div_tuple in product(*all_list):
    tmp = 1
    for k in div_tuple:
        tmp *= k
        if tmp > max_ans:
            break
    else:
        ans = max(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

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

max_ans = M // N

tmpM = M
insu = {}
tmp = 2
while tmpM != 1:
    if tmpM % tmp == 0:
        insu[tmp] = insu.get(tmp, 0) + 1
        tmpM = tmpM // tmp
        continue
    else:
        if tmp == 2:
            tmp = 3
        elif tmpM // tmp == 1:
            tmp = tmpM
        else:
            tmp += 2

ins = []
for k, v in insu.items():
    tmp = 1
    k_list = set()
    k_list.add(1)
    for i in range(v):
        tmp *= k
        k_list.add(tmp)
    ins.append(k_list)

ans = 1
for ins_set in product(*ins):
    tmp_ans = 1
    for a in ins_set:
        tmp_ans *= a
        if tmp_ans > max_ans:
            break
    else:
        # print(ins_set, tmp_ans)
        ans = max(ans, tmp_ans)

print(ans)

Fixed submission:
from itertools import product

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

max_ans = M // N

ans = 1
tmp = 2
tmpM = M
max_prime = int(M ** 0.5)
all_list = []
i = -1
k = 0
div = 2
while tmpM != 1:
    if tmpM % div == 0:
        tmpM = tmpM // div
        if k == 0:
            i += 1
            all_list.append(set())
            all_list[i].add(div ** k)
            k += 1
        all_list[i].add(div ** k)
        k += 1

    else:
        k = 0
        if div == 2:
            div = 3
        elif div > max_prime:
            div = tmpM
        else:
            div += 2

if all_list == []:
    print(1)
    exit()

# print(all_list)
ans = 1

for div_tuple in product(*all_list):
    tmp = 1
    for k in div_tuple:
        tmp *= k
        if tmp > max_ans:
            break
    else:
        ans = max(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

max_ans = M // N
for a in reversed(range(1, max_ans + 1)):
    if M % a != 0:
        continue
    else:
        ans = a
        # print(a, M // a)
        break

else:
    print(1)
    exit()

print(ans)

Fixed submission:
from itertools import product

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

max_ans = M // N

ans = 1
tmp = 2
tmpM = M
max_prime = int(M ** 0.5)
all_list = []
i = -1
k = 0
div = 2
while tmpM != 1:
    if tmpM % div == 0:
        tmpM = tmpM // div
        if k == 0:
            i += 1
            all_list.append(set())
            all_list[i].add(div ** k)
            k += 1
        all_list[i].add(div ** k)
        k += 1

    else:
        k = 0
        if div == 2:
            div = 3
        elif div > max_prime:
            div = tmpM
        else:
            div += 2

if all_list == []:
    print(1)
    exit()

# print(all_list)
ans = 1

for div_tuple in product(*all_list):
    tmp = 1
    for k in div_tuple:
        tmp *= k
        if tmp > max_ans:
            break
    else:
        ans = max(ans, tmp)

print(ans)