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

def main():
    N, M = map(int, readline().rstrip().split())
    ans = 1
    for d in  make_divisors(M):
        if M // d >= N:
            ans = d
        else:
            break

    print(ans)

if __name__ == '__main__':
    main()

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


def make_divisors(n):
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            yield i
            if i != n // i:
                yield n // i


ans = 0
for x in make_divisors(M):
    if x >= N:
        ans = max(ans, M // x)
print(ans)

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

Solution (Python):
n, m = [int(elem) for elem in 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 = sorted(divisors)
for i in range(len(divisors), 0, -1):
  if m/n >= divisors[i-1]:
    print(divisors[i-1])
    break

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

Solution (Python):


N, M = map(int, input().split())
from fractions import gcd

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():
    x = M // N
    divisors = sorted(make_divisors(M))
    ok = 0
    ng = len(divisors) - 1
    if divisors[ng] <= x:
        print(divisors[ng])
        exit()
    while ok + 1 < ng:
        c = (ok + ng) // 2
        if divisors[c] <= x:
            ok = c
        else:
            ng = c
    print(divisors[ok])

if __name__ == "__main__":
    main()

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())
divisors=make_divisors(M)
ans=0
for d in divisors:
    if N*d<=M:
        ans=d
    else:
        break
print(ans)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

i = 1
ans = 0
while i * i <= M:
    if M % i == 0 and M // i >= N:
        ans = max(ans, i)
    if M % i == 0 and M // (M // i) >= N:
        ans = max(ans, M // i)

    i += 1

print(ans)

Solution (Python):
import heapq

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

lst = []
nf = M

for i in range(1, int(M**0.5 + 1)):
    if nf % i == 0:
        lst.append(-i)
        if i * i != nf: lst.append(-nf//i)

heapq.heapify(lst)
while lst:
    hq = -heapq.heappop(lst)
    if M // hq >= N:
        break
print(hq)

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

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

divisors = divisor(M)

ans = 1
divisors.sort()

for d in divisors:
  if N*d <= M:
    ans = d

print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    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 i in l:
        if n*i<=m:
            print(i)
            break



resolve()

Solution (Python):

"""
Created on Mon May  4 20:38:08 2020
"""

import sys


sys.setrecursionlimit(10 ** 9)


mod = 10**9+7


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)

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

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

def divisible(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 = divisible(M)

div = [d for d in div if d <= M / N]

print(max(div))

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

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

divisors = divisor(M)

ans = 1
divisors.sort()

for d in divisors:
  if N*d <= M:
    ans = d

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


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

    ma = m // n
    div = make_divisors(m)
    res = 1
    for d in div:
        if d <= ma:
            res = d
        else:
            break

    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):

import sys


def solve(N: int, M: int):
    for d in reversed(range(1, M // N + 1)):
        if M % d == 0:
            print(d)
            return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)


if __name__ == '__main__':
    main()

Solution (Python):
def make_divs(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)
                
    divs.sort(reverse=True)
    
    return divs

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

for d in divs:
    if M//d>=N:
        print(d)
        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)
    
    return divisors
l=make_divisors(m)
l.sort()
a=[li for li in l if li >=n][0]
print(m//a)

Solution (Python):
n,m=map(int,input().split())
num=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
make=make_divisors(m)
make.sort()
import bisect
ans=bisect.bisect_right(make,num)
print(make[ans-1])

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())
A=make_divisors(m)
ans=0
for i in A:
    if m%i==0 and n<=m//i:
        ans=max(ans,i)
print(ans)

Solution (Python):
from sys import stdin
import itertools
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= list(map(int, stdin.readline().strip().split()))
so=make_divisors(M)
so.sort(reverse=True)
for i in so:
    if M>=i*N:
        print(i)
        exit()

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())

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

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

from fractions import gcd

def make_divisors(n: int):
    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)

ans = 0
for i in range(len(divisors)):
    d = divisors[i]
    if d*(N-1) >= M:
        continue
    ans = max(ans, gcd(d, M-(d*(N-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()
    divisors=divisors[::-1]
    return divisors
n,m=map(int,input().split())

divisors=make_divisors(m)

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

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

Solution (Python):
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
sys.setrecursionlimit(10**6)

n,m = na()
k = m//n
ans = 0
for i in range(1,k+1)[::-1]:
    if m%i == 0:
        ans = i
        break

print(ans)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()


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 = na()
k = m/n
a = make_divisors(m)
ans = 0
for i in a:
    if i <= k:
        ans = max(ans,i)

print(ans)

Solution (Python):
n,m = map(int,input().split())
def prime(x):
  ret = []
  i = 1
  while i*i <= x:
    if x%i == 0:
      ret.append(i)
      if x != i*i:
        ret.append(x//i)
    i += 1
  return sorted(ret)
for i in prime(m)[::-1]:
  if i*n <= m:
    print(i)
    exit(0)

Solution (Python):
import sys
import collections
from math import ceil
ma = lambda : map(int,input().split())
ni = lambda : int(input())
def divisor(n):
    d = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            d.append(i)
            if i != n//i:
                d.append(n//i)
    
    return d
n,m = ma()
gcd = 1
D = divisor(m)
for d in D:
    q,r = divmod(m,d)
    if q>=n and r==0:gcd = max(gcd,d)
print(gcd)

Solution (Python):




"""
Memo:
- A=[a1,...,an]の最大公約数をDとする
- sum(A)=MもDで割り切れる，よってDはMの約数 (Mも割れる)

2条件
- DがMの約数であって，M >= N * Dであるとき
    - a1=...=an-1=D, an = M - (N - 1) * D は全てDで割り切れる (最大公約数)
- Mの約数かつM // N以下の整数で最大
"""

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



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

factors.sort(reverse=True)

for f in factors:
    if M // f >= N:
        print(f)
        exit()

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().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

N, M = lr()
primes = make_divisors(M)
answer = 1
for p in primes:
    if p * N <= M:
        answer = p
        break
print(answer)

Solution (Python):
n,m=map(int,input().split())
ans=1
ps=[]
for i in range(1,int(m**(1/2))+1):
    if m%i:continue
    if n*(i)<=m:ans=max(i,ans)
    if n*(m//i)<=m:ans=max(ans,m//i)
print(ans)

Solution (Python):
n,m=map(int,input().split())
def divisors(n):
  div=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      div.append(i)
      if not i==n//i:
        div.append(n//i)
  div=sorted(div)[::-1]
  return div
ans=1
for i in divisors(m):
  if m-i*(n-1)>0:
    ans=i
    break
print(ans)

Solution (Python):
import sys
import math  
import bisect  
import queue  


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 input():
    return sys.stdin.readline().rstrip()


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

    if N == 1:
        return print(M)

    divisors = make_divisors(M)
    divisors.sort(reverse=True)
    for r in divisors[1:]:
        if M // r < N:
            continue
        else:
            return print(r)


if __name__ == '__main__':
    main()

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

for i in range(M//N+1)[::-1]:
    if M % i == 0:
        print(i)
        break
else:
    print(1)

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

def md(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

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

Solution (Python):
import sys


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


sys.setrecursionlimit(10 ** 9)


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

    def make_divisors(n):
        divisors = []
        cnt = 0
        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

    divisor = make_divisors(M)
    cnt = len(divisor)
    for i in range(cnt):
        if M // divisor[cnt - i - 1] >= N:
            print(divisor[cnt - i - 1])
            return


if __name__ == "__main__":
    main()

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

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

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

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

D=make_divisors(m)
ans=1

for d in D:
    if d>l:
        continue
    if m//d>=n:
        ans=d

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 m // i >= n:
            ans = max(ans, i)
        if m // (m//i) >= n:
            ans = max(ans, m//i)

print(ans)

Solution (Python):
from math import sqrt,ceil
N,M=map(int,input().split())
yakusuu=[]
for i in range(ceil(sqrt(M))):
    if M%(i+1)==0:
        yakusuu.append(i+1)
        yakusuu.append(M//(i+1))
yakusuu.sort()

for i in range(len(yakusuu)):
    if yakusuu[i]>=N:
        print(M//yakusuu[i])
        break

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

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

Solution (Python):
from bisect import bisect_left, 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(n//i)
            if i != n // i:
                divisors.append(n//(n//i))

    divisors.sort()
    return divisors


divisors_M = make_divisors(M)

Max = bisect_left(divisors_M,N)
print(M // divisors_M[Max])

Solution (Python):
from math import sqrt
N, M = map(int, input().split())
l = []
for i in range(1, int(sqrt(M)) + 1):
  if M % i == 0:
    l.append(i)
    l.append(M // i)

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

Solution (Python):
import math,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 LF(): return [float(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()
  ans=1
  if n==1:
    return m
  for i in range(1,int(math.sqrt(m)+1)):
    if m%i==0:
      if i*n>m:
        continue
      ans=max(ans,i)
      x=m//i
      if x*n>m:
        continue
      ans=max(ans,x)

  return ans


print(main())

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


cnd = make_divisors(m)

for i in range(len(cnd)):
    if m // cnd[i] >= n:
        print(cnd[i])
        exit()

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

max_cnd = m//n

for i in range(max_cnd):
    if m % (max_cnd-i) == 0:
        print(max_cnd-i)
        exit()

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


def divisor(x):
    div = []
    div_append = div.append
    for i in range(1, int(x**.5)+1):
        if x % i == 0:
            div_append(i)
            div_append(x//i)
    div.sort()
    return div


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

Solution (Python):
import sys
import collections

sys.setrecursionlimit(10**6)
N, M = map(int, input().split())

def factor(m):
    fac = collections.Counter()
    while (m&1) == 0:
        m >>= 1
        fac[2] += 1
    for p in range(3, m, 2):
        if p*p > m:
            break
        while m % p == 0:
            m //= p
            fac[p] += 1
    if m > 1:
        fac[m] += 1
    return fac

fac = factor(M)

def search(i, ps, divisor):
    if M < N * divisor:
        return 1
    if i == len(ps):
        assert M % divisor == 0
        return divisor
    p, cnt = ps[i]
    dmax = 1
    for j in range(cnt+1):
        dmax = max(dmax, search(i+1, ps, divisor))
        divisor *= p
    return dmax

print(search(0, list(fac.items()), 1))

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: 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)
    divisors.sort(reverse=True)
    return divisors

n, m = nm()

for divisor in make_divisors(m):
    if divisor <= m / n:
        print(divisor)
        exit()

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():

    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 = nm()

    for divisor in make_divisors(m):
        if divisor <= m / n:
            print(divisor)
            exit()

if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
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

N, M = mi()
yakusu = make_divisors(M)
lim = M // N
ind = bisect.bisect_right(yakusu, lim)
ans = 1

print(yakusu[ind-1])

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
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

N, M = mi()
yakusu = make_divisors(M)
lim = M // N
ind = bisect.bisect_right(yakusu, lim)
ans = 1

for i in reversed(range(1, ind)):
    amari = M % yakusu[i]
    if not amari:
        ans = yakusu[i]
        break

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):
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())
ans_sub = make_divisors(m)
for i in ans_sub:
  if i >= n:
    print(m//i)
    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(reverse=True)
    return divisors

l = make_divisors(M)

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

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, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
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 debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(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()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

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()
a = make_divisors(m)
for i in a:
    if i >= n:
        print(m // i)
        exit()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


n, m = map(int, readline().split())
if is_prime(m):
    if n == 1:
        print(m)
    else:
        print(1)
    exit()
for i in range(m // n, 0, -1):
    if m % i == 0:
        print(i)
        exit()

Solution (Python):
n, m = map(int, input().split())
divisors = set()
for i in range(1, int(m**.5)+1):
    if m % i == 0:
        divisors |= {i, m//i}
divisors = sorted(divisors)
for div in divisors:
    if n <= div:
        print(m//div)
        break

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

max_cand = 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


divs = make_divisors(m)
divs.sort()

from bisect import bisect_right

index = bisect_right(divs, max_cand)

print(divs[index-1])

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

Solution (Python):
N,M = list(map(int, input().split()))
divi = []

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

print(M//min(divi))

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())
ans = 1
for i in make_divisors(m):
    if m // i >= n:
        ans = i
    else:
        break
print(ans)

Solution (Python):
import math
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())
div = make_divisors(M)
ans = 0
for i in div:
    if M // i >= N:
        ans = max(ans,i)
print(ans)

Solution (Python):
N,M = map(int,input().split())
A = []
for i in range(1,M+1):
    if i*i>M:break
    if M%i==0:
        A.append(i)
        A.append(M//i)
A.sort()
for a in A:
    if a>=N:
        print(M//a)
        break

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


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


d = divisors(M)

ans = 0

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

print(ans)

Solution (Python):
import io
import math

n,m=map(int,input().split())
L=[]
x=m/n

for i in range(1,min(int(x)+1,int(m**0.5)+1)):
    if m%i==0:
        if i<=x:
            L.append(i)
        if m//i<=x:
            L.append(m//i)
print(max(L))

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

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