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, m = map(int,input().split())
for i in range(m//n, -1 , -1):
    if m%i == 0:
        print(i)
        exit()

Solution (Python):












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






















def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]



















l = make_divisors(M)



threshold = M / N

for i, d in enumerate(l):
    if threshold < d:
        print(l[i - 1])
        exit()

print(M)

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

    
    return divisors

n, m = map(int, input().split())
h = m // n
ans = 0

for d in make_divisors(m):
    if d <= h:
        ans = max(ans, d)

print(ans)

Solution (Python):
N,M=list(map(int, input().split()))
ans=1
for i in range(1,int(M**0.5)+1):
  if M%i==0:
    j=M//i
    if i>=N:
      ans=max(ans,j)
    if j>=N:
      ans=max(ans,i)
print(ans)

Solution (Python):





def divisor(x):
    """約数"""
    from math import floor
    re = []
    _x = floor(x ** 0.5)
    for i in range(1, _x + 1):
        if x % i == 0:
            re.append(i)
            if x // i != i:
                re.append(x // i)
    re.sort()
    return re






def solve(N, M):
    div = divisor(M)
    div.sort()
    ans = 0
    for d in div:
        if M // d >= N:
            ans = d
    print(ans)


if __name__ == '__main__':
    
    
    N, M = map(int, input().split())
    
    
    
    solve(N, M)

Solution (Python):
N, M = map(int, input().split())
nums = []
for n in range(1, int(M**0.5)+1):
  if M%n == 0:
    nums.append(n)
    nums.append(M//n)
nums.sort()
answer = 1
for num in nums:
  if M//num < N:
    break
  else:
    answer = num
print(answer)

Solution (Python):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

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

for d in div:
  if d <= m/n:
    ans = d
print(ans)

Solution (Python):
import math

def main():
	N, M = [int(a) for a in input().split(" ")]
	divM = []
	for i in range(1, int(math.sqrt(M)) + 1):
		if M % i == 0:
			divM += [i, M // i]
	divM.sort()
	divM = list(filter(lambda m: m >= N, divM))
	print(M // divM[0])

main()

Solution (Python):
import bisect
N,M=map(int,input().split())
divd=[]
i=1
while i*i<=M:
    if M%i==0:
        divd.append(i)
        if i!=M//i:
            divd.append(M//i)
    i+=1
divd.sort()
k=bisect.bisect_left(divd,N)
print(M//divd[k])

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

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

print([i for i in divisors if i <= m/n][-1])

Solution (Python):
import bisect
def enum_devisors(n):
    divisors = set([])
    for i in range(1, int(n**.5) + 1):
        if n%i == 0:
            divisors.add(i)
            divisors.add(n//i)
    return divisors

n,m = list(map(int, input().split()))
devisors = sorted(enum_devisors(m))
d = devisors[bisect.bisect_left(devisors, n)]
print(m//d)

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

yakusuu=[]
import math
for i in range(1,int(math.sqrt(m)+1)):
  if m%i==0:
    yakusuu.append(i)
    yakusuu.append(m//i)
yakusuu.sort()
for num in yakusuu:
  if num>=n:
    print(m//num)
    exit()

Solution (Python):
n,m=map(int,input().split())
for i in range(n,10**8):
  if m%i==0:
    print(m//i)
    exit()
print(1)

Solution (Python):
import sys



def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, m = input_int_list()
    max_gcd = m // n
    while max_gcd > 1:
        if (m - max_gcd) % max_gcd == 0 and (m - max_gcd) // max_gcd >= n - 1:
            print(max_gcd)
            return
        else:
            max_gcd -= 1
    print(1)
    return


if __name__ == "__main__":
    main()

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

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

A = []
for i in range (1, M//N+1):
	if M%i == 0:
		A.append(i)

print(A[-1])

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  if m%n==0:
    return m//n

  ans=0
  for i in range(1,m//n+1):
    if m%i==0:
      ans=i
  
  return ans


print(main())

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def make_divisors(n: int) -> list:
    return_list = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            return_list.append(i)
            if i != n // i:
                return_list.append(n//i)

    return return_list

def main():
    n, m = i_map()

    divisors_list = make_divisors(m)

    divisors_list.sort(reverse=True)

    for num in divisors_list:
        if num <= m / n:
            print(num)
            exit()

if __name__ == '__main__':
    main()

Solution (Python):
k, s = list(map(int, input().split()))

p = s
factors = {}

while p > 1:
    f = False
    for i in range(2, int(p**0.5)+1):
        if p % i == 0:
            if i in factors:
                factors[i] += 1
            else:
                factors[i] = 1

            p //= i
            f = True
            break

    if not f:
        if p in factors:
            factors[p] += 1
        else:
            factors[p] = 1
        break

if len(factors) == 0:
    print(1)
else:
    primes = list(factors.keys())
    exp = [0] * len(primes)
    upper = s/k
    ans = 1

    while exp[0] <= factors[primes[0]]:
        num = 1
        for i in range(len(primes)):
            num *= pow(primes[i], exp[i])

        if num == upper:
            ans = num
            break
        elif num < upper:
            ans = max(ans, num)

        index = len(primes)-1
        done = False
        while not done:
            exp[index] += 1
            if exp[index] > factors[primes[index]]:
                if index == 0:
                    break
                else:
                    exp[index] = 0
                    index -= 1
            else:
                done = True

    print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

N, M = na()
MAX = M // N
ans = 1

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

if M % N == 0:
    print(M // N)
else:
    tmp = make_divisors(M)
    print(tmp[max(bisect.bisect_left(tmp, MAX) - 1, 0)])

Solution (Python):
n,m = map(int,input().split())
a = m//n
di = []
for i in range(1, min(a+1,int(m**0.5)+1)):
  if m % i == 0:
    di.append(i)
    if i != m // i and a >=  m // i:
      di.append(m//i)
di.sort()
print(di[-1])

Solution (Python):
n,m=map(int,input().split())
p=[]
pp=[]
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    p.append(i)
    pp.append(m//i)
pp.reverse()
p+=pp
l,r=-1,len(p)
while r-l!=1:
  t=(l+r)//2
  if p[t]>=n:
    r=t
  else:
    l=t
print(m//p[r])

Solution (Python):
import sys
from sys import exit
from collections import deque
from copy import copy, deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

N,M=mint()
P=pf(M,mode='list')
i=bisect_right(P,M//N)
print(P[i-1])

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

    for i in range(m//n, 0, -1):
        if m % i == 0:
            print(i)
            break

main()

Solution (Python):

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass 


def main():
    N, M = map(int, input().split())
    ass = divisor(M)
    ass.sort()
    ans = 1
    for a in ass:
        if a <= (M // N):
            ass = a
        else:
            print(ass)
            exit()
    print(ass)

if __name__ == "__main__":
    main()

Solution (Python):
import math
n, m = map(int, input().split())
fact = []
ans = 1
MAX = int(math.sqrt(m)) + 1
for i in range(1, MAX):
    if m % i == 0:
        fact.append(i)
        if i != m // i:
            fact.append(m//i)
fact.sort()
for x in fact:
    if m < n * x:
        break
    ans = x
print(ans)

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

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


def enum_div(N):
    ret = []
    for i in range(1,int(N**0.5)+1):
        if N % i == 0:
            ret.append(i)
            if i**2 != N:
                ret.append(N // i)
        i += 1
    return ret

ans = 0
for i in enum_div(M):
    if i >= N:
        ans = max(ans,M // i)

print(int(ans))

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


def enum_div(N):
    ret = []
    i = 1
    while True:
        if i**2 > N:
            break
        if N % i == 0:
            ret.append(i)
            if i**2 != N:
                ret.append(N / i)
        i += 1
    return ret

ans = 0
for i in enum_div(M):
    if i >= N:
        ans = max(ans,M / i)

print(int(ans))

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

a = M // N
for i in range(a, 0, -1):
    if M % i == 0:
        print(i)
        break

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

Solution (Python):
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    
    i = 1
    max_gcd = 1
    while i*i <= M:
        if M%i == 0:
            if M//i >= N:
                max_gcd = max(max_gcd, i)
            if i >= N:
                max_gcd = max(max_gcd, M//i)
        i += 1
    return max_gcd


if __name__ == '__main__':
    print(solve())

Solution (Python):

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


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

    divisors.sort()
    return divisors


b = make_divisors(m)

a = m//n

ans = 0
for i in b:
    if i <= a:
        ans = i
print(ans)

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

while gcd*N!=M:
  gcd = M//N
  N = 1+(M-1)//gcd

print(gcd)

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
a=make_divisors(m)

ans=[]

for i in a:
  if m//i>=n:
    ans.append(i)
    
print(max(ans))

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

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

print([i for i in divisors if i <= m/n][-1])

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):
N,M = list(map(int,input().split()))

f=[]
for m in range(1,int(M**(1/2))+3):
    if M % m == 0:
        f.extend([m,M//m])
f.sort(reverse=True)

for f_ in f:
    if N <= M/f_:
        ans=f_
        break
print(ans)

Solution (Python):






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





def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]





for x in make_divisors(M)[::-1]:
    if M//x >= N:
        ans = x
        break
print(ans)

Solution (Python):
N,M=map(int, input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
A=make_divisors(M)
for i in range(len(A)):
  if A[i]>=N:
    print(A[-1-i])
    exit()

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

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

d=primes(M)

for i in d[::-1]:
    if M//i>=N:
        ans=i
        break

print(ans)

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

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

    divisors.sort()
    return divisors


A = make_divisors(M)
for an, a in zip(A, A[1:]):
    ans = an
    if a * N > M:
        break
else:
    ans = M
print(ans)

Solution (Python):
N, M = map(int,input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
D = sorted(make_divisors(M))[::-1]

for e in D:
    if N*e <= M:
        print(e)
        exit(0)

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

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

Solution (Python):
def enum_divisors(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return res


N, M = map(int, input().split())
divs = sorted(enum_divisors(M), reverse=True)
ans = max(d for d in divs if M // d >= N)
print(ans)

Solution (Python):
def LI():
    return list(map(int, input().split()))


N, M = LI()
x = M//N
for i in range(x, 0, -1):
    if M % i != 0:
        continue
    ans = i
    break
print(ans)

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

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

    
    return divisors

ans = 1
for i in make_divisors(M):
    work1 = i * N
    work2 = M - work1
    if work2 >= 0 and work2 % i == 0:
        ans = max(i, ans)

print(ans)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect














import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n,m = readInts()
def yaku(m):
        ans = []
        i = 1
        while i*i <= m:
            if m % i == 0:
                j = m // i
                ans.append(i)
                if j != i:
                    ans.append(j)
            i += 1
        ans = sorted(ans)
        return ans
dic = yaku(m)
ans = 1
for k in dic:
    if k*n <= m:
        ans = max(ans,k)
print(ans)

Solution (Python):
N,M = map(int,input().split())
amax = 1
for i in range(1,int(M**0.5)+1):
    if M%i==0:
        b = i
        c = M//i
        if b>=N and c>=N:
            a = max(b,c)
        elif c<N<=b:
            a = c
        elif b<N<=c:
            a = b
        else:
            a = 1
        amax = max(amax,a)
print(amax)

Solution (Python):
from collections import defaultdict

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

ans = 0
i = 1
while i * i <= m:
    if m % i == 0:
        a, b = i, m // i
        if b >= n:
            ans = max(ans, a)
        if a >= n:
            ans = max(ans, b)
    i += 1
print(ans)

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

ans = 1
for i in range(1,10**5):
    if m%i == 0:
        v = i
        cnt = m//i
        if cnt >= n:
            ans = max(ans,v)

        v = m//i
        cnt = i
        if cnt >= n:
            ans = max(ans,v)

print(ans)

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

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

    divisors.sort()
    return divisors

lst=make_divisors(m)

for i in lst:
    if i>=n:
        print(m//i)
        exit()

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

P=[]
A=round(M**0.5)+2
for i in range(1,A):
    if M%i==0:
        P.append(i)
        P.append(M//i)
P.sort()

B=M//N
ans=now=1
for p in P:
    now=p
    if now<=B:
        ans=now
print(ans)

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

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

x = m //n
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

y = make_divisors(m)

res = 1

for i in y:
    if i <=x:
        res = i
        
print(res)

Solution (Python):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
n, m  = map(int, input().split())
divs = make_divisors(m)
divs.sort()
ans = 0
for d in divs:
    if m // d >= n:
        ans = d
print(ans)

Solution (Python):

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

divisor = []
for i in range(1, int(M ** 0.5) + 1):
    if M % i == 0:
        divisor.append(i)
        if i != M // i:
            divisor.append(M // i)

print(max(filter(lambda x: x <= M // N, divisor)))

Solution (Python):

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

if M % N == 0:
    print(M // N)
else:
    ans = 1
    for n in range(1, M // N + 1):
        res = M - n * N
        if res % n == 0:
            ans = n

    print(ans)

Solution (Python):


import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if i * i > M:
        break
    if M % i == 0:
        j = M // i
        if j <= V:
            ans = max(ans, j)
        else:
            ans = max(ans, i)
print(ans)

Solution (Python):
import sys, math
from functools import lru_cache
from collections import deque
from bisect import bisect_left
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, M = mi()

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

    d.sort()

    for v in d:
        if v <= M//N:
            ans = v
        else:
            break

    print(ans)

    



if __name__ == '__main__':
    main()

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)
    if i != M//i:
      l.append(M//i)
      
l.sort(reverse=True)
for n in l:
  if n*N <= M:
    ans = n
    break
print(ans)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
ans = -1
for i in range(1,m+1):
    if i*i>m+10:
        break
    if m%i==0:
        if m//i>=n:
            ans = max(ans, i)
        if i>=n:
            ans = max(ans, m//i)
print(ans)

Solution (Python):


N, M = map(int, input().split())
from math import sqrt

def divisor(num):
    max_num = int(sqrt(num))
    divisor_list = []
    for i in range(1, max_num + 1):
        if num % i == 0:
            divisor_list.append(i)
            divisor_list.append(num//i)
    return divisor_list

div = divisor(M)
div.sort(reverse=True)
ans = None
for g in div:
    if N > M//g:
        continue
    ans = g
    break
print(ans)

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

Solution (Python):
import sys
input = sys.stdin.readline


def read():
    N, M = map(int, input().strip().split())
    return N, M


def divisor(n):
    divisors = []
    i = 1
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
            if i * i != n:
                divisors.append(n // i)
        i += 1
    return list(sorted(divisors))


def solve(N, M):
    D = divisor(M)
    ans = 1
    for p in D:
        n = M // p
        if n >= N:
            ans = max(ans, p)
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
import math
n,m=map(int,input().split())
num=int(math.sqrt(m))
ans=1
for i in range(1,num+2):
    if m%i==0 and i>=n:
        ans=max(ans,m//i)
        break
    if m%i==0 and m//i>=n:
        ans=max(ans,i)
print(ans)

Solution (Python):
def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    table = list(table)
    return table
from bisect import *
N, M = map(int, input().split())
A = divisors(M)
A.sort()
print(M//A[bisect_left(A,N)])

Solution (Python):
from bisect import bisect_left,bisect


def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

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

div=enum_div(m)+[m]
div.sort(reverse=True)

rd=[0]*len(div)
for i in range(len(div)):
    rd[i]=m//div[i]

mm=bisect_left(rd,n)

print(div[mm])

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

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

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

temp=[]
i=1
while i*i<=m:
    if m%i==0:
        temp.append(i)
        if m//i!=i:
            temp.append(m//i)
    i+=1
temp.sort()
for i in temp:
    if i>=n:
        print(m//i)
        break

Solution (Python):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
n,m=map(int, input().split())
ans=0
for i in make_divisors(m):
  if m//i>=n:
    ans=i
print(ans)

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

l = make_divisors(m)

l.reverse()


for x in l:
    if m // x >= n:
        print(x)
        break

Solution (Python):
N,M = map(int,input().split())
def make_divisors(n):
    divisors = []
    
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
div_ls = make_divisors(M)
ans = 1
for div in div_ls:
    if div*N <= M:
        ans = max(ans,div)
print(ans)

Solution (Python):
from math import sqrt

def f(x):
    divisors = [[], []]
    for i in range(1, int(sqrt(x))+1):
        if x % i == 0:
            divisors[0].append(i)
            if i * i != x:
                divisors[1].append(x//i)
    return divisors[0] + divisors[1][::-1]

n, m = map(int, input().split())
for i in f(m):
    if n <= i:
        print(m//i)
        exit()

Solution (Python):
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

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

if m%n==0:
    print(m//n)
else:
    arr = sorted(divisor(m))
    
    for i in arr:
        if i >= n:           
            print(m//i)
            exit()

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


for i in reversed(make_divisors(M)):
    if M//i<N:
        pass
    else:
        print(i)
        exit()

Solution (Python):

n, m = map(int, input().split())
for i in reversed(range(1,m//n+1)):
    if m%i<1:
        print(i)
        exit()