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):
from math import sqrt,floor
N,M =map(int,input().split())
ans = 1
for g in range(1,floor(sqrt(M))+1):
    if M%g == 0:
        x = M//g
        if x > floor(sqrt(M)) and g >= N:
            ans = x
            break
        if x >= N:
            ans = g
print(ans)

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

Solution (Python):


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

ans = 1
num = int(m**0.5)+1

for i in range(1, num):
    if m % i != 0:
        continue
    j = m//i
    if i >= n:
        ans = max(ans, j)
    if j >= n:
        ans = max(ans, i)
print(ans)

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

res = 1
num = int(m ** 0.5) + 1
for i in range(1, num):
    if m % i != 0:continue 
    j = m // i
    if i >= n:
        res = max(j, res)
    if j >= n:
        res = max(i, res)
print(res)

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

i = 1
A = []
B = []

while i*i <= M:
  if M % i == 0:
    A.append(i)
    B.append(M//i)
  i += 1 
    
for i in range(len(B)):
  if A[i] >= N:
    print(B[i])
    exit()
    
for i in range(len(A)-1,-1,-1):
  if B[i] >= N:
    print(A[i])
    exit()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

from decimal import *
 

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

divisors = make_divisors(M)
n = divisors[bisect_left(divisors, N)]
print(M//n)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

from decimal import *
 

N, M = MAP()

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

m.sort()
n = m[bisect_left(m, N)]

print(M//n)

Solution (Python):

import sys
read = sys.stdin.read
from math import sqrt, ceil
def main():
    n, m = map(int, input().split())
    if n == 1:
        print(m)
        sys.exit()

    divs = []
    for i1 in range(2, ceil(sqrt(m))+1):
        if m % i1 == 0:
            divs.append(i1)
            divs.append(int(m/i1))
    divs.sort()
    r = 1
    for div in divs:
        if n * div <= m:
            r = div
        else:
            break
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):

from bisect import bisect_left
from heapq import heappush

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

def main():
    N, M = map(int, input().split())
    ans = cal_divisors(M)
    
    i = bisect_left(ans,N)
    print(M//ans[i])

if __name__ == "__main__":
    main()

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

print(ans)

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

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

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

div = divisor(M)
div.sort(reverse=True)
for num in div:
    if num <= M//N:
        print(num)
        exit()

Solution (Python):
import sys
from io import StringIO
import unittest
import os


sys.setrecursionlimit(999999999)



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

    for i in reversed(range(1, m // n + 1)):
        if (m - i * n) % i == 0:
            print(i)
            return





class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 14"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10 123"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """100000 1000000000"""
        output = """10000"""
        self.assertIO(test_input, output)

    
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)



if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        
        resolve()

    else:
        
        unittest.main()

Solution (Python):
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m/n
  l = []
  for i in range(int(m**0.5),0,-1):
    if m%i==0:
      l.append(i)
      l.append(m//i)
  l = sorted(l)[::-1]
  for j  in l:
    if j<=a:
      print(j)
      exit()
  else:
    print(1)

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

Solution (Python):
def cd_generator(num):
    i=1
    lower=[]
    upper=[]
    while i*i<=num:
        if num%i==0:
            lower.append(i)
            if num!=i*i:
                upper.append(num//i)
        i+=1
    return reversed(lower+upper[::-1])
n,m=map(int,input().split())

for ele in cd_generator(m):
    if m/ele>=n:
        print(ele)
        exit()

Solution (Python):
from bisect import bisect_left

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

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

div.sort()

print(m // div[bisect_left(div, n)])

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

Solution (Python):
N,M=map(int,input().split())
d=set()
k=1
while(k*k<=M):
    if M%k==0:
        d.add(k)
        d.add(M//k)
    k+=1
ans=1
for n in d:
    if n>=N:
        ans=max(ans,M//n)
print(ans)

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

Solution (Python):
import copy
def cd_generator(num):
    ans=[]
    for i in range(1,10000000):
        if num%i==0:
            ans.append(i)
    temp=copy.deepcopy(ans)
    temp.reverse()
    for ele in temp:
        ans.append(num//ele)
    return ans
def main():
    n,m=map(int,input().split())
    array=cd_generator(m)
    ans=0
    for ele in array:
        if m//ele>=n:
            ans=max(ans,ele)
    print(ans)
main()

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

ans = 0
for i in range(1, int(m ** 0.5) + 1):
    if m % i == 0:
        div = m // i

        if i <= m // n:
            ans = max(ans, i)

        if div <= m // n:
            ans = max(ans, div)

print(ans)

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

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

def divisor(a):
    res = []
    for i in range(1, int(a**0.5)+1):
        if a % i == 0:
            res.append(i)
            res.append(a//i)
    return res
    
div = divisor(M)
div.sort(reverse=True)

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

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


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


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

    ans = 1
    for i in sorted(make_divisors(M), reverse=True):
        if i * N <= M and M % i == 0:
            ans = i
            break

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


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

    ans = 1
    inf = M // N + 1
    for i in range(inf, 1, -1):
        if i * N <= M and M % i == 0:
            ans = i
            break

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
s={1,m}
for i in range(2,int(m**0.5)+1):
  if m%i<1: s|={i,m//i}
for i in sorted(s):
  if i*n>m: break
  a=i
print(a)

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


N, M = map(int, input().split())
divs = filter(lambda x: x <= M // N, enum_divisors(M))
print(max(divs))

Solution (Python):
import math
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
N,M=map(int,input().split())
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
if N==1:
  print(M)
else:
  ans=0
  a=M//N
  v=make_divisors(M)
  for i in range(a,0,-1):
    if M%i==0:
      print(i)
      break

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

Solution (Python):
n, m = map(int, input().split())
d = []
i = 1
while i ** 2 <= m:
    if m % i == 0:
        d.append(i)
        j = m // i
        if j != i:
            d.append(j)
    i += 1
d.sort(reverse=True)
for t in d:
    if m // t >= n:
        print(t)
        exit()

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

print(ans)

Solution (Python):
import numpy as np

n,m = map(int,input().split())
ans = 0
tmp = int(m/n)
for i in range(1,int(np.sqrt(m)+1)):
    if m%i == 0:
        if (ans < i) and(i <= tmp):
            ans = i
        tmp2 = m//i
        if (ans < tmp2) and(tmp2 <= tmp):
            ans = tmp2
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,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 operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]




n,m=mii()

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

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

Solution (Python):
def __gcd__(m,n):
    x,y=max(m,n),min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x,y=y,z
        else:
            return z
        
from functools import reduce
def GCD(*X):
    return reduce(__gcd__,X)

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

Q=M//N
R=M%N

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

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

print(ans)

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


def make_divisors(num):
    divisors = []
    for i in range(1, m+1):
        if i * i > m:
            break
        if m % i == 0:
            divisors.append(i)
            divisors.append(m // i)
    return divisors

div = make_divisors(num=m)
div.sort()
ans = 1
for x in div:
    if x*n <= m:
        ans = x
print(ans)

Solution (Python):
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 = list(map(int, input().split()))
    for i in make_divisors(m):
        if m // i >= n:
            print(i)
            exit()

if __name__ == '__main__':
    main()

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

def factorization(n):
    factor_list = []
    if n < 1:
        return factor_list
    limit = int(math.sqrt(n))+1
    for i in range(1, limit):
        if n % i == 0:
            factor_list.append(i)
            if not n == i**2:
                factor_list.append(n//i)
    factor_list.sort()
    return factor_list

factor = factorization(M)


ans = 1
for f in factor:
    if N * f <= M and f > ans:
        ans = f
print(ans)

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

st = m//n

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

Solution (Python):
def resolve():
    N, M = list(map(int, input().split()))
    factors = []
    i = 1
    while i <= M**(1/2):
        if M%i==0:
            factors.append(i)
            factors.append(M//i)
        i += 1
    factors = sorted(factors, reverse=True)
    
    for fac in factors:
        if N*fac <= M and (M-N*fac)%fac == 0:
            print(fac)
            break


if '__main__' == __name__:
    resolve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SMI(): return input().split()
def SLI(): return list(input())
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N, M = MI()

    ans = 1
    for i in range(1, int(pow(M, 0.5))+1):
        if M % i: continue
        if N * i <= M: ans = max(ans, i)
        if N * (M // i) <= M: ans = max(ans, M//i)
    print(ans)

if __name__ == '__main__':
    solve()

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

Solution (Python):
import bisect

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

n, m = map(int, input().split())
M = divisor(m)
if n not in M:
    x = bisect.bisect_left(M, n)
    ans = (m // M[x])
else:
    ans = m // n
print(ans)

Solution (Python):
n, m = map(int, input().split())
factors = [1, m]
sqrt = round(m ** 0.5 + 0.5)
for i in range(2, sqrt + 1):
    if not m % i:
        factors.append(i)
        factors.append(m // i)
factors = sorted(factors)
def search(l):
    for i in l:
        if i >= n:
            return m // i
print(search(factors))

Solution (Python):





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


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

    for x in reversed(xs):
        if M // x >= N:
            return x


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

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

res = 1

for k in l:
    x = M // k
    
    if x >= N:
        res = max(res, k)
print(res)

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

maxi = 1
for i in range(int(M**0.5), 0, -1):
    if M % i != 0:
        continue
    if M//i >= N:
        maxi = max(maxi, i)
    if i >= N:
        maxi = max(maxi, M//i)

print(maxi)

Solution (Python):





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


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

    upper_divisors.reverse()
    return lower_divisors + upper_divisors


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    divisors = make_divisors(m)[::-1]
    for d in divisors:
        if d <= x:
            print(d)
            exit()

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

if m % n == 0:
    print(m // n)
    sys.exit()


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


div = make_divisors(m)
div = [x for x in div if x <= m // n]

print(max(div))

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

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

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

    res.sort()
    return res

d = divisor(M)
ans = 1
for x in d:
    m = M
    m -= x * (N - 1)
    if m > 0 and m % x == 0:
        ans = x

print(ans)

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


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

mlis=make_divisors(m)

I=1
for i in mlis:
    if m<i*n:
        break
    else:
        I=i
    
print(I)

Solution (Python):
import bisect

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

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


n_faces = n_facs_s + n_facs_l[::-1]
ind = bisect.bisect_right(n_faces, n)
if n_faces[ind-1] == n:
    ind-=1
print(m//n_faces[ind])

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    n, m = map(int, readline().split())
    div = []
    for i in range(1, int(m**0.5)+1): 
        if m%i == 0:
            div.append(i)
            div.append(m//i)

    ans = 0
    for d in div:
        if m//n >= d:    
            ans = max(ans, d)
    print(ans)
if __name__ == '__main__':
    main()

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

div = M
for i in range(1, int(math.sqrt(M))+1):
    if M % i:
        continue
    i2 = M // i
    if i >= N:
        div = min(div, i)
    if i2 >= N:
        div = min(div, i2)

print(M//div)

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

a,b = map(int, input().split())
l = make_divisors(b)
l.sort(reverse=False)
res = 1

for x in l:
    if x <= b//a:
        res = max(x, res)
print(res)

Solution (Python):

import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())

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



if __name__ == '__main__':
    main()

Solution (Python):
N,M=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 divisors
Mdiv = make_divisors(M)
out = 1
for k in Mdiv:
    A = M//k
    if A>=N:
        out = max(out,k)
print(out)

Solution (Python):
n,m=map(int,input().split())
s=set()
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        s.add(i)
        s.add(m//i)
s=sorted(s,reverse=True)
for i in range(len(s)):
    if s[i]<n:
        print(m//s[i-1])
        break
else:print(m)

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

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

ans=M//N
while True:
    if (M-(N-1)*ans)%ans==0:
        break
    ans-=1
print(ans)

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

def f(M):
    l = []
    for i in range(1,int(math.sqrt(M))+1):
        if M%i==0:
            l.append(i)
    n = len(l)
    for i in range(n):
        j = l[n-1-i]
        if M/j!=j:
            l.append(M//j)
    return l

l = f(M)

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))

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


if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()

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

d = 1
ds = []
while d ** 2 <= M:
    if M % d == 0:
        ds.append(d)
        ds.append(M // d)
    d += 1
ds.sort(reverse=True)
for d in ds:
    if N * d <= M:
        print(d)
        break

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

if N == 1:
    print(M)
else:
    d = 1
    ds = []
    while d ** 2 <= M:
        if M % d == 0:
            ds.append(d)
            ds.append(M//d)
        d += 1
    ds.sort(reverse=True)
    for d in ds:
        if N * d <= M:
            print(d)
            break

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    N, M = MI()

    ans = 1
    for i in range(1, int(pow(M, 0.5))+1):
        if M % i: continue
        j = M // i

        if i * N <= M: ans = max(ans, i)
        if j * N <= M: ans = max(ans, j)
    print(ans)




if __name__ == '__main__':
    solve()

Solution (Python):

printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import math


def isprime(x):
    q = int(math.sqrt(x))  
    for i in range(2,q+1):   
        if x%i == 0:
            return False
    return True

def prime_division(x):
    q = int(math.sqrt(x))
    a = []
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            a.append([i,ex])
    if x>q:
        a.append([x,1])
    return a

def prime_division2(x):
    q = int(math.sqrt(x))
    h = {}
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            h[i] = ex
    if x>q:
        h[x] = 1
    return h

def divisorlist(z): 
    if len(z)==1:
        return [z[0][0]**i for i in range(z[0][1]+1)]
    y = divisorlist(z[1:])
    s = []
    for i in range(z[0][1]+1):
        for j in y:
            s.append((z[0][0]**i)*j)
    return s

n,m = inm()
if m==1:
    print(1)
    exit()


ps = divisorlist(prime_division(m))

ps2 = [x for x in ps if x<=m//n]
print(max(ps2))

Solution (Python):
n, m = map(int, input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return upper_divisors + lower_divisors[::-1]
m_divisor = make_divisors(m)
for i in m_divisor:
    if i <= m / 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(reverse = True)
    return divisors
  
n, m = list(map(int, input().split()))
div = make_divisors(m)
for i in div:
  if m / i >= n:
    print(i)
    quit()

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

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



ans = 0
for i in range(1,int(M ** 0.5) + 1):
  if M % i == 0:
    p = M // i
    if i >= N:
      if ans < p:
        ans = p
    if p >= N:
      if ans < i:
        ans = i

print(ans)