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

msq = int(math.sqrt(M))
if N == 1:
    ans = M
else:
    for i in range(M, 0, -1):
        if M%i == 0:
            tmp = M - i*(N-1)
            if tmp > 0 and tmp%i == 0:
                ans = i
                break

print(ans)


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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = int(TMPM/i)

if TMPM > 1 or len(prime_dic) == 0:
    prime_dic[TMPM] = 1

max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

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

MAX_SQRT = int(math.sqrt(M))
for i in range(MAX_SQRT, 0, -1):
    if M%i == 0 and M%(i*N) == 0:
        ans = i
        break

print(ans)


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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = int(TMPM/i)

if TMPM > 1 or len(prime_dic) == 0:
    prime_dic[TMPM] = 1

max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
primes = []

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while M%i == 0:
            primes.append(i)
            M = int(M/i)

if M > 1:
    primes.append(M)


max_mul = 1
def Rec(primes, p, mul):
    global max_mul

    if TMPM//mul < N:
        return

    if p >= len(primes):
        if mul > max_mul:
            max_mul = mul
    else:
        Rec(primes, p+1, mul)
        Rec(primes, p+1, mul*primes[p])


Rec(primes, 0, 1)
print(max_mul)



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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = int(TMPM/i)

if TMPM > 1 or len(prime_dic) == 0:
    prime_dic[TMPM] = 1

max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
primes = []

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while M%i == 0:
            primes.append(i)
            M = int(M/i)

if M > 1:
    primes.append(M)


def CalcMulti(primes, flags):
    mul = 1
    for i in range(len(primes)):
        if flags[i] == True:
            mul *= primes[i]
    return mul

max_mul = 1
def Rec(primes, p, flags):
    global max_mul
    if p >= len(primes):
        mul = CalcMulti(primes, flags)
        if TMPM//mul >= N and mul > max_mul:
            max_mul = mul
    else:
        flags[p] = False
        Rec(primes, p+1, flags)
        flags[p] = True
        Rec(primes, p+1, flags)


flags = [False] * len(primes)
Rec(primes, 0, flags)
print(max_mul)



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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = int(TMPM/i)

if TMPM > 1 or len(prime_dic) == 0:
    prime_dic[TMPM] = 1

max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
primes = []

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while M%i == 0:
            primes.append(i)
            M = int(M/i)

if M > 1:
    primes.append(M)


def CalcMulti(primes, flags):
    mul = 1
    for i in range(len(primes)):
        if flags[i] == True:
            mul *= primes[i]
    return mul

max_mul = 1
def Rec(primes, p, flags):
    global max_mul
    if p >= len(primes):
        mul = CalcMulti(primes, flags)
        if TMPM//mul >= N and mul > max_mul:
            max_mul = mul
    else:
        flags[p] = False
        Rec(primes, p+1, flags)
        flags[p] = True
        Rec(primes, p+1, flags)


flags = [False] * len(primes)
Rec(primes, 0, flags)
print(max_mul)



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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = int(TMPM/i)

if TMPM > 1 or len(prime_dic) == 0:
    prime_dic[TMPM] = 1

max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)