Problem:
 Score : 400 points    Problem Statement You are given integers N and M .  Consider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M . Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N .      Constraints  All values in input are integers.  1 \leq N \leq 10^5  N \leq M \leq 10^9         Input Input is given from Standard Input in the following format:  N  M       Output Print the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.        Sample Input 1 3 14      Sample Output 1 2  Consider the sequence (a_1, a_2, a_3) = (2, 4, 8) . Their greatest common divisor is 2 , and this is the maximum value.       Sample Input 2 10 123      Sample Output 2 3       Sample Input 3 100000 1000000000      Sample Output 3 10000

Solution (Python):
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()

Solution (Python):
import math
n, m = map(int, input().split())
X=1

for i in range(1,int(math.sqrt(m))+1):
	if m%i==0:
		if i*n<=m:
			X=max(X, i)
		if (m//i)*n<=m:
			X=max(X, m//i)
print(X)

Solution (Python):
import math
n, m = map(int, input().split())
kotae=1
for i in range(1,int(math.sqrt(m))+1):
 if m%i==0:
  if i*n<=m:
   kotae=max(kotae, i)
  if (m//i)*n<=m:
   kotae=max(kotae, m//i)
print(kotae)

Solution (Python):
import math
n, m = map(int, input().split())
kotae=1

for i in range(1,int(math.sqrt(m))+1):
	if m%i==0:
		if i*n<=m:
			kotae=max(kotae, i)
		if (m//i)*n<=m:
			kotae=max(kotae, m//i)
print(kotae)

Solution (Python):
n, m = map(int, input().split())
r = 1
for i in range(1, int(m**0.5)+1)[::-1]:
    if i<=m//n and m%i==0:
        if m//i<=m//n:
            r = max(r, m//i)
        else:
            r = max(r, i)
print(r)

Solution (Python):
N, M = map(int, input().split())

As = []
k = 1
while k * k <= M:
    if M % k == 0:
        As.append(k)
        As.append(M // k)
    k += 1

As = sorted(As, reverse=True)

for ans in As:
    if M // ans >= N:
        print(ans)
        break

Solution (Python):
n,m = map(int,input().split())

i = 1
yakusuu = []
while i*i <= m:
    if m%i==0:
        yakusuu.append(i)
        if i*i != m:
            yakusuu.append(m//i)
        
    i += 1

yakusuu.sort()

for i in yakusuu:
    if n <= i:
        print(m//i)
        break

Solution (Python):
n, m = map(int, input().split())

num = []
i = 1
while i * i <= m:
    if m % i == 0:
        num.append(i)
        if m // i != i:
            num.append(m//i)
    i += 1

ans = 0
for i in num:
    if i <= m // n:
        ans = max(ans, i)

print(ans)

Solution (Python):

from math import sqrt, ceil
def inpl(): return list(map(int, input().split()))

N, M = inpl()
ans = 1
for i in range(1, ceil(sqrt(M))+1):
    if M%i != 0:
        continue
    d = M // i
    if M >= N*i:
        ans = max(i, ans)
    if M >= N*d:
        ans = max(d, ans)

print(ans)

Solution (Python):


import math

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

l = []
for i in range(1,int(math.sqrt(M))+1):
    if M % i == 0:
        l.append(i)
        l.append(M//i)

ans = 1
for l_ in l:
    if l_ <= M//N:
        ans = max(ans,l_)

print(ans)

Solution (Python):
N,M=map(int,input().split())
import math
s = math.sqrt(M)
sq = math.floor(s)
l = []
for i in range(1,sq+1):
    if M%i == 0:
        l.append(i)
        l.append(M//i)
ans = 1
for r in l:
    n = M//r
    if n >= N:
        ans = max(ans,r)
print(ans)

Solution (Python):


import math

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

l = []
for i in range(1,int(math.sqrt(M))+1):
    if M % i == 0:
        l.append(i)
        l.append(M//i)

ans = 1
for l_ in l:
    if l_*N <= M:
        ans = max(ans,l_)

print(ans)

Solution (Python):
from math import sqrt
 
n, m = map(int, input().split())
l = []
for i in range(1, int(sqrt(m)) + 1):
	if m % i == 0:
		l.append(i)
		l.append(m // i)
 
ans = 1
for d in l:
	if d * n <= m:
		ans = max(ans, d)
 
print(ans)

Solution (Python):
import math

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

x=0

s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		s.append(i+1)
		s.append(m//(i+1))




for i in s:
	if m%(i)==0 and m//(i)>n-1:
		x=max(x,i)
print(x)

Solution (Python):
N, M = map(int,input().split())

yakusuu = []
for i in range(1, int((M + 1)**(1/2)+1)):
    if M % i == 0:
        yakusuu.append(i)
        yakusuu.append(int(M/i))
yakusuu.sort()
yakusuu.reverse()


for i in yakusuu:
    if M / i >= N:
        print(i)
        break

Solution (Python):
N, M = list(map(int,input().split()))
 
d = int(M/N)

def solve():
    
    
    
    
    
    
    for i in range(d+1,0,-1):
    	if M%i == 0:
    		print(i)
    		break

	
	
	
	
	
	

if M%N == 0:
	print(d)
else:
	solve()

Solution (Python):
N, M = map(int, input().split())

def divisors(n):
    div = []
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div += [A]
            else:
                B = n//A
                div += [A, B]
        A += 1
    div.sort()
    return div
factors = divisors(M)
k = M//N
L = [x for x in factors if x <= k]
print(max(L))

Solution (Python):
import math
N,M=map(int,input().split())
K=int(math.sqrt(M))+1
D=set()
for i in range(1,K+10):
    if M%i==0:
        D.add(M//i)
        D.add(i)
X=[]
for d in D:
    if M//d>=N:
        X.append(d)
print(max(X))

Solution (Python):
N, M = map(int, raw_input().split())

a = []
x = 1
while x * x <= M:
    if M % x == 0:
        a.append(x)
        a.append(M/x)
    x += 1

res = 0
for i in a:
    if M / i >= N:
        res = max(res, i)
print(res)

Solution (Python):

import math
N, M = map(int, input().split())
yakusu = []
for i in range(1, min(int(M / N) + 1, int(math.sqrt(M)) + 1)):
    if M % i == 0:
        yakusu.append(i)
        if int(M / i) * N <= M:
            yakusu.append(int(M / i))
print(max(yakusu))

Solution (Python):
import math


def divisor(num):
    if num < 0:
        return [0,]
    elif num == 1:
        return [1,]
    else:
        divisor_list =[1,]
        for i in range(2, int(math.sqrt(num) + 1)):
            if num % i== 0:
                divisor_list.append(i)
        return divisor_list


N,M = map(int,input().split(' '))
P = M // N
divisor_list = divisor(M)

for i in reversed(range(len(divisor_list))):
    num = M // divisor_list[i]
    divisor_list.append(num)

for i in reversed(range(len(divisor_list))):
    if divisor_list[i] <= P:
        print(divisor_list[i])
        break

Solution (Python):
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)

Solution (Python):
import sys
from collections import deque
import copy
import math
import numpy as np

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def divisor_sub(p, q):
    a = []
    for i in xrange(0, q + 1):
        a.append(p ** i)
    return a

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def divisor(n):
    xs = factorization(n)
    ys = divisor_sub(xs[0][0], xs[0][1])
    for p, q in xs[1:]:
        ys = [x * y for x in divisor_sub(p, q) for y in ys]
    return sorted(ys)

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    if N == 1:
        print M
        exit()
    if is_prime(M):
        print 1
        exit()
    div_list = divisor(M)
    div_list.sort(reverse = True)

    for num in div_list:
        if M % num == 0 and M/num >= N:
            print num
            exit()


if __name__ == '__main__':
    main()

Solution (Python):
N, M = list(map(int,input().split()))
 
d = int(M/N)

def solve():
    ans = 1
    for i in range(M//N+1, 0, -1):
        if M % i == 0:
            if (M // i) >= N:
                print(i)
                break
	
	
	
	
	
	

if M%N == 0:
	print(d)
else:
	solve()

Solution (Python):
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
ans = 0
for param in params:
    if n > m / param:
        break
    ans = param
print(ans)

Solution (Python):
from math import floor, ceil, sqrt
N, M = [int(elem) for elem in input().split(' ')]

def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    try:
        b, e = fct.pop()  
    except:
        return []
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

M_divisors = divisorize(factorize(M))
threshold = M // N
max_possible_divisor = 1
for M_divisor in M_divisors:
    divisor = num(M_divisor)
    if divisor <= threshold:
        max_possible_divisor = max(max_possible_divisor, divisor)
print(max_possible_divisor)

Solution (Python):
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)

Solution (Python):
import math

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

a = int(M/N)
q = int(math.sqrt(M))

m = 0
for i in range(1,q+1):
    if M % i == 0:
        if i <= a:
            m = max(m,i)
        b = int(M / i)
        if b <= a:
            m = max(m,b)

print(m)

Solution (Python):
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {m:1}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)

Solution (Python):
from math import sqrt

def factorization(n):
    l = set()
    for i in range(1, int(sqrt(n))+1):
        if not n % i:
            l.add(i)
            l.add(n//i)
    return l

N, M = map(int, input().split())
f = factorization(M)
ans = 1
for i in f:
    if (M / i) >= N:
        ans = max(i, ans)
print(ans)

Solution (Python):
import math
N, M = map(int, input().split())
tmp = [1]
if N == 1:
    print(M)
else:
    for i in range(2, int(math.ceil(M**0.5))):
        if M % i == 0:
            tmp.append(i)
            tmp.append(int(M/i))
    ans = 1
    for x in tmp:
        if M / x >= N:
            ans = max(ans, x)
    print(ans)

Solution (Python):
n,m = map(int,input().split())
l = m//n

def x():
    for i in range(l+1)[::-1]:
        if m % i == 0:
            return i
print(x())

Solution (Python):
n, m = list(map(int, input().split()))
d = m//n+1
for x in range(d)[::-1]:
  if m%x==0:
    break
print(x)

Solution (Python):




import math

if __name__ == "__main__":
    list = input().split(" ")
    N = int(list[0])
    M = int(list[1])
    list = []
    for i in range(1,int(math.sqrt(M)+1)):
        if M%i == 0:
            list.append(i)
    for i in range(len(list)):
        list.append(int(M/list[i]))
    print(max([i for i in list if i <= M // N]))

Solution (Python):
n, m = list(map(int, input().split(" ")))

ds = [x for x in range(1, int(m**.5)+1) if m%x==0]
ds = ds + [m//x for x in ds]
ds = [x for x in ds if x<=m//n]
print(max(ds))

Solution (Python):
n,m=map(int,input().split())
from math import sqrt,floor
k=1
divisor = []
sq = floor(sqrt(m))+2
while k < sq:
    if m%k==0:
        divisor += [k]
    k+=1

for v in divisor:
    if v >= n:
        print(m//v)
        exit()
divisor.reverse()
for v in divisor:
    if v <= m//n:
        print(v)
        exit()

Solution (Python):
import math

N,M = map(int,input().split())
A = M//N
L = []
for i in range(1,int(math.sqrt(M))+1):
  if (M%i == 0 and i <= A):
    L.append(i)
    if (M//i <= A):
      L.append(M//i)
print(max(L))

Solution (Python):
import math


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

for i in range(math.floor(m/n), 0, -1):
    if m % i == 0:
        ans = i
        break

print(ans)

Solution (Python):
N, M = map(int, input().split())

if N == 1:
    print(M)
else:
    ans = 1
    for p in range(2, int(M**0.5) + 1):
        if M % p == 0 and p <= M // N:
            q = M // p 
            ans = max(p, ans)
            if q <= M // N:
                ans = max(q, ans)
    print(ans)

Solution (Python):
from math import sqrt, ceil

def factorization(n):
    l = [n]
    for i in range(1,ceil(sqrt(n))+1):
        if not n % i:
            l.append(i)
            l.append(n//i)
    return l
N, M = map(int, input().split())

if (M % N) == 0:
    print(M//N)
    exit()

f = factorization(M)
ans = 1
for i in f:
    if (M / i) >= N:
        ans = max(i, ans)
print(ans)

Solution (Python):
N, M = list(map(int, input().split(" ")))
def solv(N, M):
    d = M//N
    for i in range(d+1)[::-1]:
        if M%i == 0:
            return i
print(solv(N, M))

Solution (Python):
from math import ceil
n, m = map(int, input().split())
for i in range(n, ceil(m**.5), 1):
    if not m % i:
        print(m//i)
        exit()
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break

Solution (Python):
N, M = map(int, input().split())
ans = 1
if N == 1:
    print(M)
    exit()

for i in range(2, int(M ** .5) + 1):
    p, q = divmod(M, i)
    if q == 0:
        if p >= N:
            ans = max(ans, i)
        if i >= N:
            ans = max(ans, p)

print(ans)

Solution (Python):
N, M = map(int, input().split())
ans = 1
if N == 1:
    print(M)
else:
    for n in range(2, int(M ** 0.5) + 1):
        if M % n == 0 and M / N >= n:
            ans = max(ans, n)
            if M // n * N <= M:
                ans = max(ans, M // n)
    print(ans)

Solution (Python):
import math

N,M=map(int,input().split())
MR=math.ceil(math.sqrt(M))

LISTM=[]
for i in range(1,MR+1):
    if M%i==0:
        LISTM.append(i)
        LISTM.append(M//i)
    
LISTM.sort()
LISTM.reverse()

for j in LISTM:
    if j<=M//N:
        print(j)
        break

Solution (Python):
import  math
lis = []

N,M = [int(i) for i in input().split()]

for i in range(1,int(math.sqrt(M))):
    if M % i == 0:
        lis.append(i)
        lis.append(M//i)


lis.sort()
i =1
for i in lis:
    if i >= N:
        break

print(M//i )

Solution (Python):
N, M = map(int, input().split())


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

    return sorted(divisors)


divisors = get_divisor(M)
for d in divisors:
    if d >= N:
        print(M // d)
        exit()

print(1)

Solution (Python):
n, m = map(int, input().split())

def solve():
    res = 1
    for i in range(m//n+1, 0, -1):
        if m % i == 0:
            if (m // i) >= n:
                res = i
                break
    print(res)

solve()

Solution (Python):
n,m=map(int,input().split())
x=1
if m%n==0:
    print(m//n)
else:
    for i in range(1,int(m**0.5)+1):
        if m%i==0 and i*n<=m:
            x=max(x,i)
        if m%(m//i)==0 and (m//i)*n<=m:
            x=max(x,m//i)
    print(x)

Solution (Python):
iN,iM = [int(_) for _ in input().split()]

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range(1,iM//iN + 1):
        if iM % i == 0:
            aRet.append(i)
    print(aRet[-1])

Solution (Python):
N, M = map(int, input().split())

def make_divisor_list(num, N):

    if num < 1:
        return 0
    elif num == 1:
        return 1
    else:
        max_num = 1
        for i in reversed(range(2, num // N + 1)):
            if num % i == 0:
                
                if num / i >= N:
                    max_num = i
                    break
                
                
        return max_num

print(make_divisor_list(M, N))

Solution (Python):
n,m=map(int,input().split())

ans=0
for i in range(1,int(m**0.5)+2):
    if m%i==0 :
        a=m//i
        if min(a,i)>=n :
            ans=max(ans,max(a,i))
        elif max(a,i)>=n :
            ans=max(ans,min(a,i))
print(ans)

Solution (Python):
n, m = map(int, input().split())
values = []

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


for i in pfac(m):
    if m % i == 0 and m / i >= n:
        values.append(i)
print(max(values))

Solution (Python):
import math
N, M  = list(map(int, input().split()))

s = M // N
r_list = []
for i in range(1, int(math.sqrt(M)) + 1):
    if M % i == 0 and i <= s:
        if M // i <= s:
            r_list.append(M // i)
        else:
            r_list.append(i)
r_list.sort()
r_list.reverse()
print(r_list[0])

Solution (Python):
n, m = map(int, input().split())
for i in range(m//n, 0, -1):
    if not m%i:
        print(i)
        break

Solution (Python):
import math

n, m = [int(i) for i in input().split()]
ret = []

i = 1
while i * i <= m:
    if m % i == 0:
        ret.append(i)
        ret.append(int(m / i))
    i += 1

ret = sorted(ret)

for i in reversed(ret):
    if i <= int(m/n):
        print(i)
        exit()

Solution (Python):
import math, sys, random

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


def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

d = int(math.floor(M/N))

if M%N == 0:
	print(d)
	sys.exit()

i = 0
f = False
while True:
	if M%(N+i+1) == 0:
		print(int(M/(N+i+1)))
		sys.exit()
	i += 1
	if i == 100000 and is_prime(M):
		print(1)
		sys.exit()

Solution (Python):
from itertools import product
from collections import Counter
from functools import reduce
import operator
num_product = lambda it: reduce(operator.mul,it,1)


def prime_factors(n):
  i = 2
  while i * i <= n:
    if n % i:
      i += 1
    else:
      n //= i
      yield i
  if n > 1:
    yield n



N,M = map(int,input().split())
P = tuple(tuple(p**i for i in range(d+1)) for p,d in Counter(prime_factors(M)).items())
def it():
  for nums in product(*P):
    t = num_product(nums)
    yield t
print(max(t for t in it() if t*N <= M))

Solution (Python):
import math
a = list(map(int,input().split()))

b = a[1]//a[0]

c = []

for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1] % i == 0 and i <= b:
        if a[1] // i <= b:
            c.append(a[1] // i)
        else:
            c.append(i)
c.sort()
c.reverse()
print(c[0])

Solution (Python):
n,m = map(int, input().split())
 
ma = m//n
 
flag=0
 
while(flag==0):
    if m%ma==0:
        print(ma)
        flag = 1
    ma -=1

Solution (Python):
from math import sqrt
n, m = [int(x) for x in input().split()]

def getDiviser(x):
  result = []
  for i in range(1, int(sqrt(x))+2):
    if x % i == 0:
      result.append(i)
      result.append(x//i)
  result.sort()
  result.reverse()
  return result

for x in getDiviser(m):
  if m//x >= n:
    print(x)
    break
else:
  print(0)

Solution (Python):
n, m = map(int, input().split())
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
if is_prime(m):
    print(1)
else:
    for i in range(m//n, 0, -1):
        if not m%i:
            print(i)
            break

Solution (Python):
def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop() 
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

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

if M == 1:
    print(1)
else:
    re = 1
    fa = factorize(M)
    div_list = divisorize(fa)

    for i in range(len(div_list)):
        num = 1
        for j in range(len(div_list[-1 - i])):
            l = div_list[-1-i][j]
            num *= l[0] ** l[1]
        d = M // num 
        if d >= N and num > re:
            re = num
    print(re)

Solution (Python):

from collections import defaultdict
from bisect import bisect
def inpl(): return list(map(int, input().split()))

def primes(N):
    sieve = [True]*(N+1)
    sieve[:2] = [False, False]
    for i in range(4, N+1, 2):
        sieve[i] = False

    for i in range(3, N+1, 2):
        if sieve:
            for j in range(2*i, N+1, i):
                sieve[j] = False
    P = []
    for i in range(N+1):
        if sieve[i]:
            P.append(i)
    return P

N, M = inpl()
P = primes(10**6)
searched = defaultdict(int)

Q = [1]

if N==1:
    print(M)
    exit()

if M%N == 0:
    ans = M//N
else:
    ans = 1
while Q:
    a = Q.pop()
    for p in P:
        c = a*p
        d = M - c*N
        if d < 0:
            break
        
        if d%c == 0:
            if not searched[c]:
                searched[c] = True
                ans = max(ans, c)
                Q.append(c)
print(ans)

Solution (Python):
n,m=map(int,input().split())
x=1
if m%n==0:
    print(m//n)
else:
    for i in range(1,m//n+1):
        if m%i==0 and i*n<=m:
            x=max(x,i)
        if m%i==0 and (m//i)*n<=m:
            x=max(x,m//i)
    print(x)

Solution (Python):
import math
import bisect
N, M = map(int, input().split())
rootM = math.sqrt(M)

factors = set()
for i in range(1, math.ceil(rootM)+1):
  if M % i == 0:
    factors.add(i)
    factors.add(M // i)
factarr = sorted(list(factors))
print(M // factarr[bisect.bisect_left(factarr, N)])

Solution (Python):
import math
def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        div_list.sort(reverse = True)
        return div_list

n, m = [int(i) for i in input().split()]
d_list = get_div_list(m)

for i in d_list:
    if (n-1)*i < m:
        if (m - (n-1)*i) % i == 0:
            print(i)
            break

Solution (Python):
from math import sqrt

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

l=[]

for i in range(1,int(sqrt(m))+1):
    if m%i==0:
        if i>=n:
            l.append(int(m/i))
        if m/i>=n:
            l.append(i)

print(max(l))

Solution (Python):
from math import floor, sqrt


def getDivisor(x):
    ans = []
    for d in range(1, floor(sqrt(x)) + 1): 
        if x % d == 0:
            ans.append(d)
            if x // d != d:
                ans.append(x // d)

    return sorted(ans)


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

divs = getDivisor(M)
for div in reversed(divs):
    if M // div >= N:
        print(div)
        break

Solution (Python):



def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


x,n = map(int,input().split())
if x == 1 and n == 1:
    print(1)
    exit()
fct = factorize(n)


divlist=[]
for div in divisorize(fct):
    divlist.append(num(div))

divlist.sort()
ans = 1
for i in range(0,len(divlist)):
    if divlist[i] <= n/x:
        ans = divlist[i]
print(ans)

Solution (Python):
N, M = map(int, input().split())

import math
class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]

def f():
    for p in PrimeUtils.primes_sieve(math.ceil(math.sqrt(M))):
        if M % p == 0:
            for x in range(N, (M//2) + 1):
                if M % x == 0:
                    return M // x
            else:
                return 1
    return 1
print(f())

Solution (Python):
N, M = map(int, input().split())
ans = 1

S = M / N
S = int(S)

import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            if M / i >= N and M % i == 0:
                ans = max(ans, i)
            j = M // i
            if M / j >= N and M % j == 0:
                ans = max(ans, j)
            
    if not_sosu == -1:
        ans = 1


if N == 1:
    ans = M

print(ans)

Solution (Python):
N, M = map(int, input().split())

m = M//N




















def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

if M == 1:
  print(1)
  exit()

fct = factorize(M)
current_n = 1

for div in divisorize(fct):
    n = num(div)
    if n <= m and current_n < n:
      current_n = n

print(current_n)

Solution (Python):
n,m = map(int,input().split())
a = int((m**0.5)//1)
b = 0
if n == 1:
    print(m)
else:
    for i in range(1,a+1):
        if m % i == 0:
            if (m//i) >= n:
                b = max(b,i)
            if i >= n:
                b = max(b,m//i)

    print(b)

Solution (Python):
import math
n, m = map(int, input().split())
ans = 1
k = m
soy = []
for i in range(2, int(math.sqrt(m))+1):
    if k % i == 0:
        are = 0
        while True:
            if k % i == 0:
                k = k // i
                are += 1
            else:
                break
        soy.append([i, are])
if k != 1:
    soy.append([k, 1])
for i in range(10-len(soy)):
    soy.append([1, 0])
for a in range(soy[0][1] + 1):
    for b in range(soy[1][1] + 1):
        for c in range(soy[2][1] + 1):
            for d in range(soy[3][1] + 1):
                for e in range(soy[4][1] + 1):
                    for f in range(soy[5][1] + 1):
                        for g in range(soy[6][1] + 1):
                            for h in range(soy[7][1] + 1):
                                for i in range(soy[8][1] + 1):
                                    for j in range(soy[9][1] + 1):
                                        t = soy[0][0]**a * soy[1][0]**b * soy[2][0]**c * soy[3][0]**d * soy[4][0]**e * soy[5][0]**f * soy[6][0]**g * soy[7][0]**h * soy[8][0]**i * soy[9][0]**j
                                        if n <= t:
                                        	ans = max(ans, m//t)
print(ans)

Solution (Python):
import bisect
n,m = map(int,input().split())
a = m//n

anslist = []
for i in range(1,int(m**0.5)+2):
    if m%i==0:
        anslist.append(i)
ansl = anslist.copy()
ansl.reverse()
for i in ansl:
    anslist.append(m//i)
    
anslist = list(set(anslist))
anslist.sort()
pos = bisect.bisect_left(anslist,n)
print(m//anslist[pos])

Solution (Python):



def inpl(): return list(map(int, input().split()))


N, M = inpl()

n = M // N
while n > 0:
    if M % n == 0:
        print(n)
        break
    else:
        n -= 1

Solution (Python):
n, m = map(int, input().split())
def func(n, num): 
    if num == 1:
        return 1
    else:
        for i in range(num//n ,0,-1):
            if num % i == 0:
                return i
print(func(n,m))

Solution (Python):
import math

def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b
M, N = getMN()

yakusuu = []
for i in range(1,int(math.sqrt(N))+2):
    if N % i == 0:
        yakusuu.append(i)
        yakusuu.append(N//i)

yakusuu = (sorted(yakusuu))
for y in yakusuu[::-1]:
    
    if y * M <= N:
        print(y)
        break

Solution (Python):

import numpy as np
def divisor(n,m):
    arr = []
    for i in range(1,(int(np.sqrt(m))+1)):
        if m % i == 0:
            if i <= m/n:
                arr.append(i)
            if m/i <= m/n:
                arr.append(int(m/i))
    return arr



n,m = list(map(int,input().split()))
print (max(divisor(n,m)))

Solution (Python):
import math

N, M = map(int, input().split(" "))
div1 = []
div2 = []

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        div1 += (i,)
        div2 += (M//i,)
for d in div2:
    if d * N <= M:
        print(d)
        break
else:
    div1 = div1[::-1]
    for d in div1:
        if d * N <= M:
            print(d)
            break