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 divisors(N):
    res = []
    i = 1
    while i * i < N:
        if N % i == 0:
            res += [i, N // i]
        i += 1
    if i * i == N and N % i == 0:
        res.append(i)
    res.sort()
    return res

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
N, M = map(int, input().split())
print(next(d for d in reversed(range(M // N + 1)) if M % d == 0))

Solution (Python):
import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    for i in range(x, 0, -1):
        if M%i == 0:
            print(i)
            break

Solution (Python):
import math
N, M = map(int, input().split())
ulim = M//N
mid = int(math.sqrt(M))
if ulim >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= ulim:
                ans.append(M//i)
    print(max(ans))
 
else:
    for i in reversed(range(1, ulim+1)):
        if M%i == 0:
            print(i)
            break

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

Solution (Python):
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors

ans = 0
for d in make_divisors(M):
    if N*d <= M and d > ans:
        ans = d
print(ans)

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

r = max(filter(lambda i: M//i >= N, Ds))
print(r)

Solution (Python):
def find_prime_factor(num):
    if num & 1 == 0:
        return 2
    for i in range(3, int(num ** (1 / 2)) + 1):
        if num % i == 0:
            return i
    return num


def prime_factorization(num):
    subtract = num
    result = []
    while subtract > 1:
        factor = find_prime_factor(subtract)
        result.append(factor)
        subtract //= factor
    return result


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

prime_factors = prime_factorization(m)

power = {}
for prime in prime_factors:
    if prime in power:
        power[prime] += 1
    else:
        power[prime] = 1


divisors = [1]
for prime in power:
    divisors += [divisor * prime ** pw
                 for pw in range(1, power[prime] + 1)
                 for divisor in divisors]
divisors.sort()

answer = 0
for divisor in divisors:
    if divisor <= int(m / n):
        answer = divisor
    else:
        break

print(answer)

Solution (Python):
N, M = map(int, input().split())
M2 = M // N + 1 

ans = 1

for i in reversed(range(1, M2)):
  
  if M % i == 0:
    Sho = M // i
    if Sho >= N:
      ans = i
      print(i)
      quit()
      
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
DIV = make_divisors(M)


for i in DIV:
    if M - i*N >= 0:
        ans = i
print(ans)

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

d = sorted(d,reverse = True)


for j in range(len(d)):
    if m // d[j] >= n:
        print(d[j])
        break

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

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

print(count)

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

an = m //n
while an*n != m:
  an = m//n
  n = 1 + (m-1)//an
  
print(an)

Solution (Python):

from bisect import bisect_left as bs


def divisors(n: int) -> list:
    """
    Compute divisors of a number.
    
    Args: n (int): an integer to be evaluated.
    Returns: div (set): set of divisors
    """
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i)
            div.add(n // i)
    return sorted(div)


def main():
    N, M = tuple(map(int, input().split()))
    if M % N == 0:
        print(M // N)
    else:
        div = divisors(M)
        ans = div[bs(div, M / N) - 1]
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
p = m // n
ans_1 = 0
if p > 100000:
    for i in range(1, 10001):
        if m % i == 0 and i >= n:
            ans_1 = m // i
            break
for i in range(min(p, 100000), 0, -1):
    if m % i == 0:
        ans_2 = i
        break
    else:
        continue
print(max(ans_1, ans_2))

Solution (Python):
import sys

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

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

divisors = make_divisors(m)

for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()

Solution (Python):
import math

def main():
    N, M = map(int, input().split())
    divs = sorted(divisors(M), reverse = True)
    for d in divs:
        if M // d >= N:
            return d
    return -1


def divisors(i):
    ans = set()
    for j in range(1, int(math.sqrt(i))+1):
        if i % j == 0:
            ans.add(j)
            ans.add(i // j)
    return list(ans)

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

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

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

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

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

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

Solution (Python):
from math import factorial

def divisors(n):
    e = int(n**0.5+1)
    k = int(0)
    div=[0]*e
    divs =[]
    for i in range(1,e):
        if n%i == 0:
            div[k] = i
            k +=1

    i = int(0)
    while div[i]!=0 : i +=1
    end=int(i)

    del div[end:]
    divs = div
    for i in reversed(div):
        a = int(n//i)
        if not a in divs:
            div.append(a)

    return(div)

N, M = map(int, input().split())
L = divisors(M)
maxans = int(M//N)

anst = int(0)
for i in L:
    if i > maxans:
        break
    else:anst = i

ans = anst
print(ans)

Solution (Python):
N, M = map(int, input().split())
ls = []
for i in range(1,M+1):
  if M%i==0:
    j = M//i
    if i<=M//N:
      ls += [i]
    if j<=M//N:
      ls += [j]
  if M**0.5<i:
    break
print(max(ls))

Solution (Python):

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

lis = []

now = 1
while now ** 2 <= M:

    if M % now == 0 and now ** 2 != M:
        lis.append(now)
        lis.append(M // now)

    elif now ** 2 == M:
        lis.append(now)
        
    now += 1

maxi = 1
lis.sort()

for i in lis:

    if  M // i >= N:

        maxi = i

print (maxi)

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

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


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


div = sorted(enum_div(m), reverse=True)

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

Solution (Python):
n,m=map(int,input().split())
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

ans=(make_divisors(m))
ans.sort()

for i in range(len(ans)):
    if ans[i]>m//n:
        print(ans[i-1])
        break
else:
    print(ans[-1])

Solution (Python):
def makedivisor(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 solve():
  n,m = (int(i) for i in input().split())
  div = makedivisor(m)
  if len(div) == 0:
    print(1)
    exit()
  else:
    ans = 1
    for i in div:
      if (m-(n*i)) >= 0:
        ans = max(ans,i)
    print(ans)
solve()

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

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

    return divisors

l=make_divisors(m)
ans=0
for i in l:
    if i<=m/n:
        ans=max(ans,i)

print(ans)

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

def divisor(x) :
    d = []
    i = 1
    while i**2 <= x :
        if x%i == 0 :
            d.append(i)
            d.append(x//i)
        i += 1
    return d

maximum = 0
for d in divisor(m) :
    if d >= n :
        maximum = max(maximum, m//d)
print(maximum)

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

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

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

  for i in range(M // N, 0, -1):
    if M % i == 0:
      print(i)
      break
      
if __name__ == '__main__':
  main()

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

  for i in range(M // N, 0, -1):
    if M % i == 0:
      print(i)
      break
      
if __name__ == '__main__':
  main()

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

for i in range(M // N, 0, -1):
  if M % i == 0:
    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)

    
    return divisors

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

l = make_divisors(M)
l.sort()
for i in range(len(l)):
    if l[i] >= N:
        a = l[i]
        break

ans = M // a
print(ans)

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

d = int(M**(1/2))
div_list = []
while d >= 1:
    if M%d == 0:
        div_list.append(d)
        div_list.append(M//d)
    d -= 1

div_list.sort(reverse = True)
for i in range(len(div_list)):
    if div_list[i] <= M//N:
        print(div_list[i])
        break

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


divs = make_divisors(M)

i = bisect.bisect_right(divs, int(M/N))
print(divs[i-1])

Solution (Python):
import bisect

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


divs = make_divisors(M)


i = bisect.bisect_right(divs, int(M/N))

print(divs[i-1])

Solution (Python):
import heapq
n,m = (int(x) for x in input().split())
a1 = []
a2 = []
for i in range(1, int(m**0.5)+1):
  if(m%i == 0):
    a1.append(i)
    a2.append(m//i)
    
a1.extend(a2[::-1])
i = 0

while(i <= len(a1)):
  if(a1[i] >= n):
    print(m//a1[i])
    break
  i += 1

Solution (Python):
n, m = map(int, input().split())
l = []
for i in range(1, int(m**(1/2)) + 1):
	if m % i == 0:
		l.append(i)
		l.append(m // i)
l.sort()
l=l[::-1]
for i in l:
    if m//n>=i:
        print(i)
        break

Solution (Python):
import math

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

MAX = M // N

def prime2(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor


def prob(i, s, ans):
    if i == len(A):
        if s <= MAX:
            ans = max(ans, s)
        return ans
    n, m = A[i]
    for j in range(m+1):
        ans = prob(i+1, s*n**j, ans)
    return ans

A = list(prime2(M).items())
ans = prob(0, 1, 1)
print(ans)

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

max_num = int(m/n)
ans = -1
for i in reversed(range(max_num + 1)):
  if(m % i == 0):
    ans = i
    break

print(ans)

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

ans = 0
for i in range(1, 10**5+1):
    if m % i == 0:
        tmp = m // i
        if tmp >= n and ans < i:
            ans = i
        if n <= i and ans < tmp:
            ans = tmp
print(ans)

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


ans = max(
    (
        M // d if (M // d) * N <= M else
        d if d * N <= M else
        1
    )
    for d in range(1, int(M**0.5) + 10)
    if M % d == 0
)

print(ans)

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))



N,M = II()

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
kouho = make_divisors(M)
for i in kouho:
  if M%i==0 and i*N<=M:
    ans = 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

import bisect
d = make_divisors(m)
idx = bisect.bisect_left(d, n)
print(m // d[idx])

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

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()
    return divisors
M_div = make_divisors(M)

for i in range(len(M_div)):
	if N <= M_div[i]:
		break

a = len(M_div)-i
print(M_div[a-1])

Solution (Python):
import sys
input = sys.stdin.readline
from math import sqrt
from bisect import bisect_right

def main():
	n, m = map(int, input().strip().split())
	M = int(sqrt(m))
	ans = 1
	for i in range(1, M+1):
		if m % i == 0:
			if i*n <= m:
				ans = max(ans, i)
			if m//i * n <= m:
				ans = max(ans, m//i)
	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):
import sys
input = sys.stdin.readline
from math import sqrt
from bisect import bisect_right

def main():
	n, m = map(int, input().strip().split())
	M = int(sqrt(m))
	l = []
	for i in range(1, M+1):
		if m % i == 0:
			l.append(i)
			l.append(m // i)
	l.sort()
	k = m//n
	ind = bisect_right(l, k)
	
	print(l[ind-1])

if __name__ == '__main__':
	main()

Solution (Python):
import math
def judge(max_d,x):
    if x<=max_d:
        return x
    else:
        return 1

def main():
    n,m = map(int,input().split())
    max_d = m//n
    sq = math.floor((math.sqrt(m)))
    ans = 1
    for i in range(1,sq):
        if m%i==0:
            x1 = judge(max_d,i)
            x2 = judge(max_d,m//i)
            x = max(x1,x2)
            ans = max(ans,x)
        else:
            pass
    print(ans) 
if __name__ == '__main__':
    main()

Solution (Python):
import math

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

l = []
for i in range(1, int(math.sqrt(m))+1):
    if m % i == 0:
        l.append(i)
        l.append(m//i)
l.sort()

for i in l:
    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)

    
    return divisors

div = make_divisors(M)
div.sort(reverse = True)

for d in div:
    if d*N > M:continue
    break
print(d)

Solution (Python):
import math

n, m = list(map(int, input().split()))
reg = (m / n)
k = 1
for i in range(1, int(math.sqrt(m) + 1)):
    if m % i == 0:
        a = m/i
        b = i
        if reg >= b and k < b:
            k = b
        if reg >= a and k < a:
            k = a
print(int(k))

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

Solution (Python):


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

def divisors(n,m):
    div=[]
    end=int(pow(m,0.5))
    for i in range(1,end+1):
        if m%i==0:
            div.append(i)
            div.append(m//i)
    div.sort(reverse=True)
    return div

res=divisors(n,m)
for e in res:
    if m//n>=e:
        print(e)
        break

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

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

print(max(v for v in divisor if v <= M // N))

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

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

f1, f2 = [], []

k = 1
while k*k<=M:
    if M%k==0:
        f1.append(k)
        f2.append(M//k)
    k+=1

for f in f1 + list(reversed(f2)):
    if f>=N:
        print(M//f)
        break

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

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

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

Solution (Python):
import math


def main():
    N, M = map(int, input().split())
    rt = int(math.sqrt(M))
    div = []
    for i in range(1, rt+1):
        if M % i == 0:
            div.append(i)
            if i ** 2 != M:
                div.append(M//i)
    ans = 1
    for d in div:
        if d * N <= M:
            ans = max(ans, d)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import math

def get_divs(a):
	divs = [1, a]
	for n in range(2, int(a ** 0.5)):
		if a % n == 0:
			divs.append(n)
			divs.append(a // n)
	return divs

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

	divs = get_divs(M)
	divs.sort()
	divs.reverse()
	divs = filter(lambda x:x <= M // N, divs)

	for div in divs:
		if (M - N * div) % div == 0:
			print(div)
			break

main()

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

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

print(ans)

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

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

divisor = []
c = 1
while c <= M**0.5:
    if M % c == 0:
        divisor.append(c)
    c += 1
divisor2 = []
for i in range(len(divisor)):
    divisor2.append(M//divisor[i])
    
divisor = divisor + divisor2
divisor.sort(reverse=True)

for j in range(len(divisor)):
    if M//divisor[j] >= N:
        ans = divisor[j]
        break
        
print(ans)

Solution (Python):
def get_divisor(n):
    a,b = [],[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            a.append(i)
            b.append(n//i)
    if a[-1]==b[-1]:b.pop()
    a.extend(b[::-1])
    return a

N,M = map(int,input().split())
print(max(n for n in get_divisor(M) if n<=M//N))

Solution (Python):
import math 
N,M=map(int,input().split())
a=M//N
ans=0
for i in range(1,int(math.sqrt(M))+1):
    if M%i==0:
        if i<=a and i>ans:ans=i
        if M//i<=a and M//i>ans:ans=M//i
print(ans)

Solution (Python):
import math, bisect

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

s = set()
for x in range(1, math.ceil(math.sqrt(m)) + 1):
    if m % x == 0:
        s.add(x)
        s.add(m // x)

t = list(sorted(s))
i = bisect.bisect_left(t, n)
print(m // t[i])

Solution (Python):
from math import *
N,M=map(int,input().split())
d1,d2=[],[]
for n in range(1,int(sqrt(M))+1):
    if M%n == 0:
        d1.append(n)
        d2.append(M//n)
divs=d2+d1[::-1]
for d in divs:
    if d*N <= M:
        print(d)
        break

Solution (Python):





def divisors(n):
    """
    nの約数をO(√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())
ans = 0
for D in divisors(M):
    if ans < D <= M // N:
        ans = D
print(ans)

Solution (Python):
def main():
    n, m = map(int, input().split())
    divisors = get_divisors(m)
    small = [d for d in divisors if d >= n][0]
    print(m // small)


def get_divisors(m):
    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)
    return sorted(divisors)


main()

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


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

Solution (Python):
from collections import defaultdict



from bisect import bisect_left as bl
from bisect import bisect_right as br
from math import log

from fractions import gcd
import sys
input=sys.stdin.readline

N,M=map(int,input().split())
def prime_factor(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table
table=prime_factor(M)
l=[1]
l_=[]
for i,j in table.items():
    for m in range(1,j+1):
        l_.extend([k*i**m for k in l])
    l.extend(l_)
    l_=[]
a=M
for L in l:
    if L>=N:
        a=min(a,L)
print(M//a)

Solution (Python):
n,m=map(int,input().split())
pf=[]
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        pf.append(i);pf.append(m//i)
pf.sort(reverse=True)
ans=100000000
for i in pf:
  if i>=n:
    ans=i
print(m//ans)

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

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

for d in div :
    if M >= N * d :
        print(d)
        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 and m /n >= i:
        ans = max(ans,i)
        if i != m // i and m/n >= (m//i):
            ans = max(ans,m // i)

print(ans)

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

Solution (Python):
from bisect import bisect_left

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

st = set()
i = 1
while i * i <= m:
    if m % i == 0:
        st.add(i)
        st.add(m // i)
    i += 1

divs = tuple(sorted(st))
i = bisect_left(divs, n)
print(m // divs[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
mdiv = make_divisors(m)
mdiv.sort()


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

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

Solution (Python):
import sys
N, M = map(int, input().split())
ls = []
for i in range(2, int(M**(1/2))+1):
    if M%i == 0:
        ls.append(i)
if N == 1:
    print(M)
    sys.exit()
ans = 1
for x in ls:
    if x >= N:
        ans = max(ans, M//x)
        continue
    if M//x >= N:
        ans = max(ans, x)
print(ans)

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

Solution (Python):
import bisect

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

    
    return divisors



N,M= map(int,input().split(" "))
divs = make_divisors(M)
divs.sort(reverse=True)
d = M//N
for i in divs:
    if i <= d:
        print(i)
        exit()

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

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

list=make_yakusuu(M)
A=list[0]
result=1
i=0
while(A>1):
  if (N<=M/A):
    result=A
    break
  else:
    i+=1
    A=list[i]
    
print(result)

Solution (Python):

import math
N, M = map(int, input().split())
ans = 1
    
for i in range((M+N-1)//N, 0, -1):
    if M%i == 0:
        if (M//i)//N >= 1:
            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 = map(int, input().split())

lst = make_divisors(M)
for i in range(len(lst)):
  if M // lst[i] >= N:
    print(lst[i])
    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

if N==1:
    print(M)

else:
    div = sorted(make_divisors(M))
    i = 0 
    while i<=len(div) and M//div[i]>=N:
        ans = div[i]
        i+=1
    print(ans)

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

Solution (Python):
n,m=map(int,input().split())
def divisor(n): 
    ans = [1,n]
    i = 2
    while i**2 <= n:
        if n%i == 0:
            ans.append(i)
            if i**2 < n:
                ans.append(n//i)
        i += 1
    ans.sort()
    return ans

mlist=divisor(m)
ans = 0
for i in mlist:
    if n*i<=m:
        ans = max(ans,i)

print(ans)