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):
import sys
input = sys.stdin.readline
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
divisors_m = list(reversed(sorted(make_divisors(m))))
D = list(filter(lambda x:x <= m/n, divisors_m))
print(max(D))

Solution (Python):
import bisect

N,M=map(int,input().split())
d=[]
for i in range(1,int(M**0.5)+2):
    if M%i==0:
        d.append(i)
        d.append(M//i)
d.sort()
ind=bisect.bisect_right(d,M//N)
print(d[ind-1])

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
h=make_divisors(m)
h.sort()
for u in h:
    if u>=n:
        print(m//u)
        break

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

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0.0:
        if M // i >= N and ans < i:
            ans = i
        if M // (M // i) >= N and ans < (M // i):
            ans = M // i
print(ans)

Solution (Python):
n, m = map(int, input().split())
ret = 1
d = 1
while d * d <= m:
    if m % d == 0:
        if d >= n:
            ret = max(ret, m // d)
        if m // d >= n:
            ret = max(ret, d)
    d += 1
print(ret)

Solution (Python):
N, M = list(map(int, input().split(' ')))
p = []
for ct in range(2, 10000000):
    if M % ct == 0:
        p.append(ct)
        p.append(M//ct)
p.append(M)




 


 







ans = 1
for t in sorted(p):
    if M / N >= t:
        ans = t
print(ans)

Solution (Python):
import bisect

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

def solv():
    N, M = map(int, input().split())
    divisors = make_divisors(M)
    l_i, r_i = bisect.bisect_left(divisors, N), bisect.bisect_right(divisors, N)
    print(M//divisors[min(l_i, r_i)])

if __name__ == '__main__':
    solv()

Solution (Python):

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

t = m//n

fct_sup = int(m**(1/2)) + 1

fct = []
fct2 = []
for f in range(1,fct_sup+1):
    if m%f == 0:
        fct.append(f)
        fct2.append(m//f)
if fct[-1] == fct2[-1]:
    fct.pop()
fct2.reverse()
fct += fct2
i = bisect.bisect_right(fct,t)
print(fct[i-1])

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

t = m//n

fct_sup = int(m**(1/2)) + 1

fct = []
fct2 = []
for f in range(1,fct_sup+1):
    if m%f == 0:
        fct.append(f)
        fct2.append(m//f)
if fct[-1] == fct2[-1]:
    fct.pop()
fct2.reverse()
fct += fct2
i = bisect.bisect_right(fct,t)
print(fct[i-1])

Solution (Python):
import bisect

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

def solv():
    N, M = map(int, input().split())
    divisors = make_divisors(M)
    l_i, r_i = bisect.bisect_left(divisors, N), bisect.bisect_right(divisors, N)
    print(M//divisors[min(l_i, r_i)])

if __name__ == '__main__':
    solv()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n = II()
    if n == 1:
        print("Hello World")
    else:
        print(II()+II())
    return


def B():
    n, t = LI()
    ans = inf
    for _ in range(n):
        c, ti = LI()
        if ti <= t:
            ans = min(ans, c)
    if ans == inf:
        print("TLE")
        return
    print(ans)
    return


def C():
    n = II()
    xyh = LIR(n)
    xyh.sort(key = lambda x:x[2], reverse = True)
    x1, y1, h1 = xyh[0]
    del xyh[0]
    for x in range(101):
        for y in range(101):
            h = abs(x - x1) + abs(y - y1) + h1
            flg = True
            for xn, yn, hn in xyh:
                if max(h - abs(x - xn) - abs(y - yn), 0) == hn:
                    continue
                flg = False
                break
            if flg:
                print(x, y, h)
                return 
    return


def D():
    n, m = LI()
    ans = 1
    for i in range(1,int(math.sqrt(m)+1)):
        if m % i == 0:
            a = m // i
            
            if a * n <= m:
                ans = max(ans, a)
            if i * n <= m:
                ans = max(ans, i)
    print(ans)
    return


if __name__ == '__main__':
    D()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

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(reverse=True)
   return divisors
x = M // N
l = make_divisors(M)

for i in l:
    if i <= x:
        print(i)
        break

Solution (Python):
n,m = map(int,input().split())
K = m//n
ans = 0
i = 1
while i <= K:
  if m % i == 0:
    if m//i <= K:
      ans = m//i
      break
    ans = i
    K = min(m//n, m//i)
  i += 1
print(ans)

Solution (Python):
from bisect import bisect_right
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


divisors = make_divisors(M)
print(divisors[bisect_right(divisors, M // N) - 1])

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

li = []
for i in range(1, M + 1):
    if i * i > M:
        break
    if M % i == 0:
        li.append(i)
        li.append(M // i)

ans = 1

li.sort(reverse=True)

for i in li:
    if N * i <= M:
        ans = i
        break

print(ans)

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

d=list()
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    d.append(i)
    if i!=m//i:
      d.append(m//i)

c=1
for i in range(len(d)):
  if m//d[i]>=n:
    c=max(d[i],c)

print(c)

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

d=list()
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    d.append(i)
    if i!=m//i:
      d.append(m//i)

d.sort()

c=1
for i in range(len(d)):
  if m//d[i]>=n:
    c=max(d[i],c)

print(c)

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

fct = []
fct2 = []
sq = int(m**(1/2))
if sq + 1 ==m:
    sq += 1

for f in range(1, sq + 1):
    if m%f == 0:
        fct.append(f)
        fct2.append(m//f)
if fct2[-1] == fct[-1]:
    fct2.pop()

fct2.reverse()

fct += fct2

k = m//n
ind = bisect.bisect_left(fct,k)

print(fct[ind-1] if k<fct[ind] else fct[ind])

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

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

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

    start = m//n

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

main()

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

li=[]
for d in range(1,m+1):
    if d*d>m:
        break
    if m%d==0:
        li.append(d)
        li.append(m//d)
        
li.sort()

ans=0

for d in li:
    if d*n<=m:
        ans=d
print(ans)

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

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

for i in d:
  if i*N<=M:
    print(i)
    exit()

Solution (Python):
import math

n,m = map(int,input().split())
m_div = []
for i in range(1,math.ceil(math.sqrt(m)+1)):
  if m%i ==0:
    m_div.extend([i,m//i])
m_div = list(set(m_div))
m_div.sort(reverse = True)
for div in m_div:
  if div >= n:
    ans = m//div
  else:
    break
print(ans)

Solution (Python):


"""
解説動画
https://youtu.be/CURWJ1Dr44A?t=1708
"""

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

    divs = set()  

    
    n = 1
    while n*n <= M:
        if M%n == 0:
            
            divs.add(n)
            divs.add(M//n)
        n += 1

    
    ans = 0
    for d in divs:
        if d*N <= M:
            ans = max(ans, d)

    print(ans)


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

    divs = set()

    n = 1
    while n <= M**(1/2):
        if M%n == 0:
            divs.add(n)
            divs.add(M//n)
        n += 1

    ans = 0
    for d in divs:
        if M >= d*N:
            ans = max(ans, d)
    print(ans)


if __name__ == "__main__":
    solve2()

Solution (Python):
from sys import stdin

N, M = [int(x) for x in stdin.readline().rstrip().split()]
ans = 1
d = 1
while d ** 2 <= M:
    if M % d == 0:
        if M // d >= N:
            ans = max(d, ans)
        if M // (M // d) >= N:
            ans = max(M // d, ans)
    d += 1

print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 10 ** 9 + 7


n, m = LI()


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



min_d = min([d for d in make_divisors(m) if d >= n])
print(m // min_d)

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

ans = -float('inf')
N,M = map(int,input().split())
for div in make_divisors(M):
  if M//div >= N: ans = max(ans, div)
print(ans)

Solution (Python):
N, M=map(int, input().split())
def f(x):
  out=[]
  a=int(pow(x, 1/2))
  for i in range(1, a+1):
    if x%i==0:
      out.append(i)
      j=x//i
      if i!=j:
        out.append(j)
        
  out.sort()
  return out

temp=f(M)

i=0
while temp[i]<N:
  i+=1
  
print(temp[-i-1])

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


prime_list = make_divisors(m)
max_ = 0
for i in prime_list:
    if i <= m/n and i > max_:
        max_ = i
print(max_)

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

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

divs.sort()

ans = 0
for d in divs:
    if M//N >= d:
        ans = d
    else:
        break

print(ans)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n,m=map(int,input().split())

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

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

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

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

n,m = map(int, input().split())
divisors, mx = make_divisors(n, m)
print(mx)

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

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 sorted(divisors, reverse=True)

def main():
    N, M = map(int, input().split())

    divisors = make_divisors(M)

    for d in divisors:
        tmp = M - d * N
        if tmp >= 0 and tmp % d == 0:
            print(d)
            break
    
if __name__ == "__main__":
    main()

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

a = m//n

for i in range(1, a+1)[::-1]:
    if m%i == 0:
        break

print(i)

Solution (Python):
n,m=map(int,input().split())
maxi=0
import math
num=math.sqrt(m)
nums=math.floor(num)

for i in range(1,nums+1):
    if m%i==0:
        number1=i
        number2=m//i
        
        
        
        if m//number1>=n and m//number2>=n:
            maxi=max(number2,maxi)
        elif m//number1>=n and m//number2<n:
            maxi=max(maxi,number1)
        
    else:
        continue
print(maxi)

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

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


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(reverse=True)
    return divisors

def main():
    N,M = map(int, input().split())
    divs = make_divisors(M)
    for d in divs:
        k = M//d
        if k >= N:
            print(d)
            return


if __name__ == '__main__':
    main()

Solution (Python):
import math

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

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

ans = 1
for i in range(1, math.ceil(M ** 0.5)):
    if M % i == 0:
        if i*N <= M:
            ans = max(ans, i)
        if (M//i)*N <= M:
           ans = max(ans, M//i) 


print(ans)

Solution (Python):


import heapq

N,M=map(int,input().split())
ans=0
l=[1,M]

for i in range(2,-int(-M**0.5//1)):
    if M%i==0:
        l.append(i)
        l.append(int(M/i))

for item in l:
    if (M-N*item)>=0:
        ans=max(ans,item)
    else:
        pass
print(ans)

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)
  divisors.sort()
  return divisors

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

L=[]
for k in K:
  if k*N<=M:
    L.append(k)
print(max(L))

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())
arr = [i for i in make_divisors(M) if i>=N]
print(M//min(arr))

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())
arr = [i for i in make_divisors(M) if i>=N]
print(M//min(arr))

Solution (Python):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))


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

n,m = inpl()
pp = make_divisors(m)
ans = 1
for i in pp:
    if i <= m/n:
        ans = max(ans, i)
print(ans)

Solution (Python):
import math

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

q = int(math.sqrt(m))+1
li = [0 for i in range(10**6)]

for i in range(1,q):
    if (m%i) == 0:
        li[i] = 1
        
ans = 1
for i in range(1,q):
    if (li[i]==1) and (i*n<=m):
        ans = max(i,ans)
        
    if (li[i]==1) and (m*n<=m*i):
        ans = max((m/i),ans)
    

print(int(ans))

Solution (Python):
n,m = map(int,input().split())
Div = []
for i in range(1,int(m**0.5)+1):
  if m%i == 0:
    Div += [i]
    if i != m//i:
      Div += [m//i]
Div.sort(reverse=True)
for div in Div:
  if div <= m//n:
    print(div)
    break

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

def main():
    N, M = map(int, input().split())

    div = make_divisors(M)
    sort_div = sorted(div)

    ans = 0
    for a in sort_div:
        if a <= M // N:
            ans = a
        else:
            break

    print(ans)


main()

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

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

ans = 0
d = divisor(m)

for x, y in d:
    if x >= n:
        ans = max(ans, y)
    if y >= n:
        ans = max(ans, x)
print(ans)

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


def main():
    N, M = map(int, input().split())

    ans = 1
    i = 1
    while i**2<=M:
        if M%i==0:
            if i<=M//N:
                ans = max(ans, i)
            if M//i<=M//N:
                ans = max(ans, M//i)
        i += 1
    
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math

n, m = map(int, input().split())
mm = m // n
res = []
for k in range(1, int(math.sqrt(m)) + 1):
    if m % k == 0:
        if k > mm:
            break
        if m // k <= mm:
            k = m // k
        res.append(k)
print(max(res))

Solution (Python):
import math

n, m = map(int, input().split())
mm = m // n
res = []
for k in range(int(math.sqrt(m)), 0, -1):
    if m % k == 0:
        if k > mm:
            continue
        if m // k <= mm:
            k = m // k
        res.append(k)
print(max(res))

Solution (Python):
import collections
import itertools
import math


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


n, m = map(int, input().split())
m2 = math.ceil(math.sqrt(m)) + 1
sieve = eratosthenes(m2)
counter = collections.Counter()

mm = m
for k in range(2, m2):
    if sieve[k] and m % k == 0:
        while mm % k == 0:
            mm //= k
            counter[k] += 1
if mm > 1:
    counter[mm] += 1

es = [range(k + 1) for k in counter.values()]
res = 1
for ks in itertools.product(*es):
    x = 1
    for p, k in zip(counter.keys(), ks):
        x *= p**k
    if x <= m // n:
        res = max(res, x)
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)

    divisors.sort()
    return divisors
n,m = map(int,input().split())
tmp = []
for i in make_divisors(m):
    if m % i == 0 and m // i >= n:
        tmp.append(i)
print(tmp[-1])

Solution (Python):
import sys
import math

N, M = map(int, input().split())
factors = [1]

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

for m in range(2, int(math.sqrt(M)) + 1):
    tmp = M
    while tmp % m == 0:
        factors.append(m)
        factors.append(tmp // m)
        tmp = tmp // m
factors.append(M)

factors.sort()

for i in range(len(factors)):
    if factors[i] * N > M:
        ans = factors[i - 1]
        break
print(factors[i - 1])

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

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


divs = []
ans = 1


for i in range(1, int(M**(1/2))+2):
    if M % i == 0:
        divs.append(i)
        divs.append(M//i)



for d in divs:
    if M >= N * d:
        ans = max(ans, d)

print(ans)

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

ans = 1
for i in range(1, int(M**(1/2))+1):
    if M % i != 0:
        continue
    j = M // i  
    if j >= N:
        ans = max(ans, i)
    if i >= N:
        ans = max(ans, j)

print(ans)

Solution (Python):

n,m = map(int,input().split())
div = []
rdiv = []
for i in range(1,int(m**.5)):
  if m % i == 0:
    div.append(i)
    rdiv.append(m//i)
if m % int(m**.5) == 0:
  div.append(int(m**.5))
rdiv.reverse()
div += rdiv
for x in div:
  if x >= n:
    print(m//x)
    break

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


N,M = [int(x) for x in input().split()]
table = divisor(M,N)
table.sort()
b = bisect_right(table,M)
print(table[b-1]//N)

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

n, m = [ int(v) for v in input().split() ]
divisors_list = divisors(m)

ans = 1
for i in divisors_list:
    if i[1] >= n:
        ans = i[0]
print(ans)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    md = 1
    for i in range(1, int(m ** 0.5) + 1):
        if m % i == 0:
            if n <= m // i:
                md = max(md, i)
            if n <= i:
                md = max(md, m // i)
    print(md)


if __name__ == '__main__':
    slove()

Solution (Python):
N,M = map(int,input().split())
ans = M//N
while (ans > 1):
  if (M - ans * N) % ans == 0:
    break
  else:
    ans -= 1
print(ans)

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



max_num = 1
for i in range(1, int(M**(1/2))+2):
    if M%i:
        continue
    j = M // i
    if j >= N:
        max_num = max(max_num, i)
    if i >= N:
        max_num = max(max_num, j)

print(max_num)

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

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

yakusu = []

for i in range(1,int(M**0.5)+1):
    if M%i==0:
        yakusu.append(i)
        if M//i!=i:
            yakusu.append(M//i)
    
yakusu.sort()
for i in yakusu:
    if i>=N:
        print(M//i)
        break

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

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

m = math.floor(math.sqrt(M))
b = M == m * m
O = set([m]) if b else set()
for i in range(m - b,0,-1):
    if M % i == 0:
        O |= {i,M//i}

O = sorted(O)





a = M / N
left = 0
right = len(O)-1
while left + 1 != right:
    middle = (left + right)//2
    if O[middle] <= a:
        left = middle
    else:
        right = middle
    
print(O[left])

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
lst = make_divisors(m)
lst.sort()
for d in lst:
    if m>=d*n:
        ans = d
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
lst = make_divisors(m)
lst.sort()
for d in lst:
    if m>=d*n:
        ans = d
print(ans)

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)

    divisors.sort(reverse=True)
    return divisors


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

divisors = make_divisors(m)

for ans in divisors:
    if ans <= m/n:
        print(ans)
        exit()

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
x=make_divisors(m)
for i in range(len(x)):
	if x[i]>=n:
		print(x[-i-1])
		break

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

limit = int(m**(0.5))
ans = 1
for d in range(1, limit+1):
    if m % d == 0:
        if m>=d*n:
            ans = max(ans,d)
        if m>=(m//d)*n:
            ans=max(ans,(m//d))

print(ans)

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

limit=int(m**(1/2))+1

divisors=[]
for d in range(1,limit):
    if m%d==0:
        divisors.append(d)
        divisors.append(m//d)

divisors.sort()
ans=1

for d in divisors:
    if n*d<=m:
        ans=d
print(ans)

Solution (Python):
def divisors(N):
    U = int(N ** 0.5)
    L = {i for i in range(1, U + 1) if N % i == 0}
    R = {N // r for r in L}
    return L | R

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    U = int(N ** 0.5)
    L = [i for i in range(1, U) if N % i == 0]
    C = [U] if N % U == 0 else []
    R = [N // r for r in reversed(L)]
    return L + C + R

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    U = int(N ** 0.5)
    L = [i for i in range(1, U) if N % i == 0]
    C = [U] if M % U == 0 else []
    R = [N // r for r in reversed(L)]
    return L + C + R

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    U = int(N ** 0.5)
    res = [i for i in range(1, U) if N % i == 0]
    if N % U == 0:
        res.append(U)
    res += [N // r for r in reversed(res)]
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    U = int(N ** 0.5)
    L, R = [], []
    all((L.append(i), R.append(N // i)) for i in range(1, U) if N % i == 0)
    if N % U == 0:
        L.append(U)
    R.reverse()
    L += R
    return L

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    U = int(N ** 0.5)
    res = []
    any(res.extend((i, N // i)) for i in range(1, U) if N % i == 0)
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    U = int(N ** 0.5)
    res = []
    *_, = (res.extend((i, N // i)) for i in range(1, U) if N % i == 0)
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    U = int(N ** 0.5)
    res = []
    *_, = (res.extend([i, N // i]) for i in range(1, U) if N % i == 0)
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    U = int(N ** 0.5)
    res = []
    for i in range(1, U):
        if N % i == 0:
            res += [i, N // i]
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    i = 1
    U = int(N ** 0.5)
    res = []
    for i in range(1, U):
        if N % i == 0:
            res += [i, N // i]
    if N % i == 0:
        res.append(i)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

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

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Solution (Python):
def divisors(N):
    res = []
    i = 1
    while i * i < N:
        if N % i == 0:
            res += [i, N // i]
        i += 1
    if N % i == 0:
        res.append(i)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))