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):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    n,m = map(int, input().split())
    def yakusuu(N):
        n = int(N**.5)+1
        res1 = []
        res2 = []
        for i in range(1, n):
            if N%i==0:
                res1.append(i)
                if N!=i**2:
                    res2.append(N//i)
        res2.reverse()
        return res1+res2
    a = yakusuu(m)
    a.sort(reverse=True)
    for i in a:
        if m//i >= n:
            print(i)
            break

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

if __name__ == '__main__':
    main()

Solution (Python):
from math import sqrt

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

divisor = set([])
for i in range(1,int(sqrt(M))+1):
	if M % i == 0:
		if i <= int(M / N):
			divisor.add(i)
		if (M // i) <= int(M / N):
			divisor.add(M // i)

print(max(divisor))

Solution (Python):
N, M = [int(str) for str in input().strip().split()]

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

print(1)

Solution (Python):

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

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

divs.sort(reverse=True)

for div in divs:
    if M // div >= N:
        print(div)
        exit()

Solution (Python):
from functools import reduce
from fractions import gcd
import heapq
import queue
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


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

    table = set()
    i = 1
    while i * i <= M:
        if M % i == 0:
            table.add(i)
            table.add(M//i)
        i += 1
    
    res = 1
    for p in table:
        if p * N <= M:
            res = max(res, p)
    
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
N,M=map(int,input().split())
div=[]
for i in range(1,int(M**(1/2)+1)):
  if M%i==0:
    div.append(i)
    if i!=M//i:
      div.append(M//i)
ans=[]
for j in range(len(div)):
  if M-(N-1)*div[j]>0:
    ans.append(div[j])
print(max(ans))

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

flag = True
for i in range(N, M//10 + 1):
    if M%i == 0:
        print(M//i)
        flag = False
        break
for i in range(9):
    if flag and M%(10 - i) == 0 and M//(10 - i) >= N:
        print(10 - i)
        flag = False
if flag:
    print(1)

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

Solution (Python):
def acinput():
    return list(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 sorted(divisors)


N,M=acinput()


for d in make_divisors(M):
    if d<=M/N:
        res=d
        

print(res)

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

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

Solution (Python):
import math

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

max_n = math.floor(m/n)

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

Solution (Python):
N,M=map(int,input().split(' '))
l = [0]
for i in range(1,int(pow(M,0.5)+2)):
    if M%i==0:
        l.append(i)
        l.append(M//i)
if len(l)==1:
    print(0)
    exit()
l = sorted(list(set(l)))
for n,i in enumerate(l[1:]):
    if M/i<N:
        print(l[n])
        exit()
print(l[-1])

Solution (Python):


def main():
    n, m = map(int, input().split())
    dm = dividor_of(m)
    res = 1
    for d in dm:
        if d <= m / n:
            res = d
    print(res)

def dividor_of(m):
    res = set()
    for i in range(1, 10 ** 5):
        if m % i == 0:
            res.add(i)
            res.add(m // i)
        if i ** 2 >= m:
            return sorted(list(res))

if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
l=[1]
k=m//n
if n==1:
  print(m)
  exit()
for i in range(2,int(m**0.5)+1):
  if m%i==0:
    if i<=k:
      l.append(i)
    if (m//i)<=k:
      l.append(m//i)
print(max(l))

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

import math

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


divisor+=[M//val for val in reversed(divisor)]

for val in divisor:
    if val>=N:
        print(M//val)
        break

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

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 = make_divisors(m)

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

Solution (Python):

import math


def divisor(x):
    d = {}
    for i in range(1, math.ceil(math.sqrt(x)) + 1):
        q, r = divmod(x, i)
        if r == 0:
            d[i] = 1
            if q != i:
                d[q] = 1
    d = list(d.keys())
    d.sort()
    return d
    


def submit():
    n, m = map(int, input().split())

    
    d = divisor(m)
    nd = len(d)

    
    l = 0
    r = nd - 1
    while l <= r:
        mid = (l + r) // 2
        if n * d[mid] <= m:
            l = mid + 1
        else:
            r = mid - 1
    print(d[l - 1])


submit()

Solution (Python):
n, m = map(int, input().split())
ans = m//n
t = []
for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        t.append(i)
        t.append(m//i)
t = sorted(t,reverse = True)
for i in t:
    if i <= ans:
        print(i)
        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())
    MN = M/N
    divisor = make_divisors(M)
    max_gcd = 0
    for d in divisor:
        if (d<=MN) and (d>=max_gcd):
            max_gcd = d
    print(max_gcd)
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=sorted(l,reverse=False)
while l:
  v=l.pop(-1)
  tot=M//v
  if tot<N:
    pass
  else:
    print(v)
    break

Solution (Python):
N, M = map(int,input().split())
lim = M // N
ans = 0
for i in range(1, int(M ** (1/2)) + 1):
    if M % i == 0:
        if ans < i <= lim:
            ans = i
        if ans < M // i <= lim:
            ans = M // i
print(ans)

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

Solution (Python):
import sys
import math

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

divisor_set=set()
for i in range(1,int(math.sqrt(M)+1)):
  if M%i==0:
    divisor_set.add(i)
    divisor_set.add(M//i)


divisor_list=list(divisor_set)
divisor_list.sort()

for l in divisor_list:
  if l>=N:
    answer=M//l
    print(answer)
    break

Solution (Python):

def divisor(x):
    ret = []
    for i in range(1,int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    return list(set(ret))

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

div = divisor(m)
div.sort(reverse=True)

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

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

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


cand = sorted(divisors(m), reverse=True)

result = 1
i = 0
for i in range(len(cand)):
    if m // cand[i] >= n:
        result = cand[i]
        break

print(result)

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

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

for i in A:
    if i >= n:
        print(m//i)
        break

Solution (Python):
n,m=map(int,input().split())
m_root=int(m**0.5)
div_l=[]
ans=0

for i in range(1,m_root + 1):
    if m%i == 0:
        div_l.append(i)
        div_l.append(m//i)

if m//n in div_l:
    ans = m//n
else:
    div_l.append(m//n)
    div_l.sort()
    ans = div_l[div_l.index(m//n) - 1]
print(ans)

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

base=M//N
li=[]


for i in range(1,int(pow(M,1/2))+1):
    if i<=base and M%i==0:
        li.append(i)
    if M%i==0 and M//i<=base:
        li.append(M//i)

print(max(li))

Solution (Python):
import math
N, M = [int(x) for x in input().split()]

upper_bound = int(math.sqrt(M))

qmin = M
for q in range(1, upper_bound + 1):
    if M % q != 0:  continue
    
    q2 = M // q
    if q >= N:
        qmin = q
        break
    elif q2 < N:
        break
    else: 
        qmin = q2

print(M // qmin)

Solution (Python):
import bisect
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr

N,M=map(int,input().split())
li=sorted(factor(M))
res=1
for i in li:
    if(i>M//N):
        break
    if(M//i>=N):
        res=i
print(res)

Solution (Python):
n,m = map(int,input().split())
k = m//n
ans = 1
i = 1
while i**2 <= m:
	if m%i==0:
		j = m//i
		if j <= k:
			print(j);exit()
		if i <= k:
			ans = max(ans,i)
	i += 1
print(ans)

Solution (Python):
def divisor(i):
    s = []
    for j in range(1, int(i ** (1 / 2)) + 1):
        if i % j == 0:
            s.append(i // j)
            s.append(j)
    return sorted(set(s))

n, m = map(int, input().split())
l = m // n
s = divisor(m)
s.reverse()
for i in s:
    if m % i == 0 and l >= i:
        ans = i
        break
print(ans)

Solution (Python):
N, M = map(int, input().split())
i = 1
lis = []
while M//i>=N and i<=M**0.5:
  if M % i == 0:
    lis.append(i)
  i += 1
for l in lis[::-1]:
  ans = M//l
  if M//ans>=N:
    lis.append(ans)
print(lis[-1])

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


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

divs = divs_right + divs_left[::-1]
for d in divs:
  if M//d >= N:
    print(d)
    quit()

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

divisors = set()

for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        divisors.add(i)
        divisors.add(m//i)

divisors = sorted(list(divisors))
ans = 1

for d in divisors:
    if d <= m/n:
        ans = max(ans, d)
    else:
        break

print(ans)

Solution (Python):
def make_divisors(n):
    if n==1:
        divisors=[1]
        return divisors
    else:
        divisors=[]
        for i in range(1,n):
            if i*i>n:
                break
            if n%i==0:
                divisors.append(i)
                if i!=n//i:
                    divisors.append(n//i)

        divisors.sort()
        return divisors

from sys import stdin
def main():
    
    readline=stdin.readline
    N,M=map(int,readline().split())

    d=make_divisors(M)
    for i in range(len(d)):
        if d[i]-N>=0:
            print(M//d[i])
            break

if __name__=="__main__":
    main()

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

Solution (Python):
import bisect
n,m = map(int,input().split())
l = []
for i in range(1,int(m**0.5)+1):
    if m%i == 0:
        l.append(i)
        l.append(m//i)

l.sort()
for i in range(len(l)-1,-1,-1):
    if l[i] <= m//n:
        print(l[i])
        exit()

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

i=1
ans=0

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

print(ans)

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

Solution (Python):

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

ret = 1
for i in range(1, int(M**0.5)+1):
    if M % i == 0 and i * N <= M:
        ret = max(ret, i)

        j = M//i
        if M % j == 0 and j * N <= M:
            ret = max(ret, j)

        
print(ret)

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

Solution (Python):
N,M = map(int,input().split())
divisors = []
for i in range(1,int(M**.5)+1):
    if M%i == 0:
        divisors.append(i)
        if M//i != i:
            divisors.append(M//i)
ans = 1
for x in divisors:
    if x <= M//N:
        ans = max(ans,x)
print(ans)

Solution (Python):
import bisect

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

vector = []

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

vector.sort()

bottom = M//N
index = bisect.bisect_right(vector, bottom)

ans = vector[index-1]
print(ans)

Solution (Python):



from math import floor

def main():
  n, m = map(int, input().split())
  divisors = []
  for i in list(range(1, floor(m**0.5)+1))[::-1]:
    if m%i == 0:
      divisors.insert(0, i)    
      if m//i != i:
        divisors.append(m//i)
  
  for divisor in divisors[::-1]:
    if m//divisor >= n:
      print(divisor)
      return
    
if __name__=='__main__':
  main()

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

def divisor_all(n): 
    l = [1,n]
    for i in range(2,int(pow(n,1/2))+1):
        if n % i == 0:
            if i == n//i:
                l.append(i)
            else:
                l.append(i)
                l.append(n//i)
    l.sort()
    return l 

DM = list(reversed(divisor_all(M)))
ans = 1
for d in DM:
    r = M//d
    if r < N:
        continue
    else:
        ans = d
        break
print(ans)

Solution (Python):
from math import sqrt

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


def fact(x):
	ret = []
	for i in range(1, int(sqrt(x)) + 1):
		if x % i == 0:
			ret.append(i)
			ret.append(x // i)

	return ret


fct = fact(m)
ans = 1
for e in fct:
	if e <= m / n:
		ans = max(ans, e)

print(ans)

Solution (Python):
n,m=map(int,input().split())
r=m//n
if r>=10**7:
  for i in range(n,r):
    if m%i==0:
      print(m//i)
      break
else:
  for i in range(r):
    if m%(r-i)==0 and m//(r-i)>=n:
      print(r-i)
      break

Solution (Python):



 
N, M = map(int, input().split())
 
for i in range(M//N, 0, -1):
    r, q = divmod((M - i), i)
    if r >= N - 1 and q == 0:
        break
print(i)

Solution (Python):




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

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

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

l=make_divisors(M)
l.sort()
ans=0
for i in range(len(l)):
    if (l[i]*N)<=M:
        ans=max(l[i],ans)
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())
common_divisors = make_divisors(M)


max_cd = 1

for c in common_divisors:
    if c*N<=M:
        max_cd = max(max_cd, c)

print(max_cd)

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

Solution (Python):
N, M = (int(i) for i in 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(reverse=True)
    return divisors
  
div = make_divisors(M)

for d in div:
    if int(M/d) >= N:
        print(d)
        break

Solution (Python):
import sys, re, os
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
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

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

yakusu = divisor(M)
yakusu.sort(reverse=True)

ans = 0
for y in yakusu:
    if y <=  M / N:
        ans = y
        break
print(ans)

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

max_check = (m**(1/2))//1
ans = 0
for i in range(1, int(max_check)+1):
    if m % i == 0:
        josuu = i
        shou = int(m//i)
        if josuu >= n:
            ans = max(ans, shou)
        if shou >= n:
            ans = max(ans, josuu)
print(ans)

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

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

cnt = 1

for i in range(1, int(m ** 0.5) + 1):
    if m % i == 0:
        b = m // i
        if i * n <= m:
            cnt = max(cnt, i)
        if b * n <= m:
            cnt = max(cnt, b)
print(cnt)

Solution (Python):

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

Solution (Python):
import bisect
N,M = map(int,input().split())
maxa = M//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)
    return divisors
mdiv = sorted(make_divisors(M))
ans = mdiv[bisect.bisect_right(mdiv,maxa)-1]
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

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    d = []
    i = 1
    while i * i <= M:
        if M % i == 0:
            d.append(i)
            if M // i != i:
                d.append(M // i)
        i += 1
    d.sort(reverse=True)
    for i in d:
        if M // i >= N:
            print(i)
            return
    print(1)
main()

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

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

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

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

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

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

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):
def main():
    N, M = (int(i) for i in input().split())

    def trial_division(n):
        """
        nの約数のリストをO(sqrt(n))で求める
        """
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.append(i)
                if i != n//i:
                    divs.append(n//i)
        return divs
    divs = trial_division(M)
    ans = 0
    for d in divs:
        if d*N <= M:
            ans = max(ans, d)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int,input().split())
def divisor(m): 
    i = 1
    table = []
    while i * i <= m:
        if m%i == 0:
            table.append(i)
            table.append(m//i)
        i += 1
    table = list(set(table))
    return table
L = divisor(m)
ans = 0
for l in L:
  if l <= m/n:
    ans = max(ans, l)
print(ans)

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

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

A = divisor(M)

b = M//N

ans = A[0]

for a in A:
    if a <= b:
        ans = a
    else:
        break
print(ans)

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

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

n, m = na()
div = []
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        j = m // i
        
        if i >= n:
            div.append(j)
        if j >= n:
            div.append(i)

print(max(div))

Solution (Python):
import math
n, m = map(int, input().split())
if m%2 == 0:
    divisor = [1, 2, m//2, m]
else:
    divisor = [1, m]
for i in range(3, int(math.sqrt(m))+1):
    if m%i == 0:
        divisor.append(i)
        divisor.append(m//i)
divisor = sorted(divisor, reverse=True)
a = m//n
for i in divisor:
    if i > a:
        continue
    if (m-(m//i*i))%i == 0:
        break
print(i)

Solution (Python):

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

divisors=[]
for i in range(1,int(M**.5)+1):
    if M%i==0:
        divisors.append(i)
        if i!=(M//i):
            divisors.append(M//i)
Ans=1
for x in sorted(divisors):
    if M//N>=x:
        Ans=x
    else:
        break
print(Ans)

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

num=m//n
ans=1
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        Num=m//i
        if Num <= num and ans < Num:
            ans = Num

        if i<=num and ans<i:
            ans=i
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)

    
    return divisors

n,m=map(int,input().split())
a=make_divisors(m)
ans=0
for i in a:
    if i<=m/n and i>ans:
        ans=i
print(ans)

Solution (Python):

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

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

Solution (Python):
def main():
    def trial_division(n):
        """
        nの約数のリストをO(sqrt(n))で求める
        """
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.append(i)
                if i != n//i:
                    divs.append(n//i)
        return divs
    N, M = (int(i) for i in input().split())
    ans = 0
    divs = trial_division(M)
    for d in divs:
        if M >= N*d:
            ans = max(ans, d)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from itertools import combinations as combi
input = sys.stdin.readline
N, M = map(int, input().split())
if N == 1:
  print(M)
  exit(0)
i = 2
res = 1
while i * i <= M:
  t = 1
  if M % i == 0 and (M // i >= N):
    res = max(res, i)
    t = M // i
  if M % t == 0 and (M // t >= N):
    res = max(res, t)
  i += 1
print(res)

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

P = []
for k in range(1,math.floor(math.sqrt(M))+1):
    if M % k == 0:
        P.append(k)
        P.append(M//k)
ans = 1
for e in P:
    if e*N <= M:
        ans = max(ans,e)
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())
gcd_max = 0 
a_list = [[0]*N]

divisor_list = make_divisors(M)

for d in divisor_list:
    check_sum = N * d
    if check_sum<=M:
        gcd_max = max(gcd_max, d)

print(gcd_max)

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

div = make_divisors(M)

ans = 0
for x in div:
    if x*N <= M:
        ans = max(ans, x)

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

l = make_divisors(m)
for c in l:
    if m//c >= n:
        print(c)
        exit()

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

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

ans = 1
for i in fact:
    if n*i<=m: ans = i
print(ans)

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

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')

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

def main():
    N,M=MI()
    ans = 0
    for d in find_divisor(M):
        if N<=M//d:
            ans = max(ans,d)
    print(ans)
    
    

if __name__ == '__main__':
    main()

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    maxGCD = 1
    for gcd in range(1, M):
        if gcd * gcd > M: break
        else:
            if M % gcd == 0:
                other = M // gcd
                if gcd >= N: maxGCD = max(other, maxGCD)
                if other >= N: maxGCD = max(gcd, maxGCD)
    print(maxGCD)

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
import sys

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
import fractions
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def getyaku(n):
    res = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            res.append(i)
            res.append(n // i)

    return(sorted(list(set(res))))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    n,m = getlist()
    arr = getyaku(m)
    for num in arr:
        if num >= n:
            print(m//num)
            return
    print(1)
    
    return

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""