Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))

h = int(m/n)
x = 0
result = [x for x in range(h, 0, -1) if m%x==0]
print(max(result))

Fixed submission:
import sys

def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num%i == 0:
            divisors.append(i)
            if num//i != i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

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

divisors = make_divisors(m)

for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))

h = int(m/n)+1
x = 0
for a in range(h, 0, -1):
    if a*n <= m:
        if m%a == 0:
            print(a)
            break
    else:
        continue

Fixed submission:
import sys

def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num%i == 0:
            divisors.append(i)
            if num//i != i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

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

divisors = make_divisors(m)

for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))

h = int(m/n)+1
x = 0
for a in range(h, 0, -1):
    if m>=a*n and m%a == 0:
        print(a)
        break

Fixed submission:
import sys

def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num%i == 0:
            divisors.append(i)
            if num//i != i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

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

divisors = make_divisors(m)

for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))

h = int(m/n)+1
x = 0
for a in range(h, 0, -1):
    q = m-a*n
    if q>=0 and m%a == 0:
        print(a)
        break

Fixed submission:
import sys

def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num%i == 0:
            divisors.append(i)
            if num//i != i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

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

divisors = make_divisors(m)

for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))

h = int(m/n)+1
for a in range(h, 0, -1):
    q = m-a*n
    if q<0:
        continue
    else:
        if q%a == 0 and m%a == 0:
            print(a)
            break

Fixed submission:
import sys

def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num%i == 0:
            divisors.append(i)
            if num//i != i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

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

divisors = make_divisors(m)

for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))

h = int(m/n)+1
for a in range(h, 0, -1):
    q = m-a*n
    if q<0:
        continue
    elif q == 0:
        print(a)
        break
    else:
        if q%a == 0 and m%a == 0:
            print(a)
            break

Fixed submission:
import sys

def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num%i == 0:
            divisors.append(i)
            if num//i != i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

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

divisors = make_divisors(m)

for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()