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 s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)






from bisect import bisect_left,bisect_right

n,m=n1()

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)
i=bisect_right(div,m//n)
print(div[i-1])

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)

Solution (Python):

import sys
input = sys.stdin.readline









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

ans = 0
div1,div2 = [],[]
for m in range(1,int(M**.5)+1):
    if M%m == 0:
        div1.append(m)

for d in div1:
    if M%d == 0:
        div2.append(M//d)

div3 = div1+div2
div3.sort()
for d in div3:
    if d <= M//N:
        ans = d

print(ans)

Solution (Python):
n, m = map(int, input().split())
div = m//n
INF = 10**18
ans = -INF
for i in reversed(range(1, div+1)):
    if m % i != 0:
        continue
    if ans < i:
        ans = i
        break
print(ans)

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

ans = 1
for i in range(1,math.ceil(math.sqrt(m))):
	if m%i == 0:
		if m >= n*i:
			ans = max(ans, i)
		j = m//i
		if m >= n*j:
			ans = max(ans,j)

print (ans)

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

for i in range(1,int(m**0.5)+1):
    if m%i==0:
        if i<=m//n:
            tmp=i
        if i>=n:
            tmp=m//i
            print(tmp)
            sys.exit()
print(tmp)

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


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


def 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 gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N,M = IL()

l =make_divisors(M)
l.sort()

while True:
  ans = l.pop()
  if M//ans >= N:
    print(ans)
    exit()

Solution (Python):
def divisor(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()
    return d

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

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

print(ans)

Solution (Python):
N, M = map(int, input().split())
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

tab = divisor(M)
ans = []
for i in tab:
    j = M // i
    if j >= N:
        ans += [i]
print(max(ans))

Solution (Python):
def solve(n, m):
    ret = 1
    for i in range(1, int(m ** 0.5) + 1):
        if m % i != 0:
            continue
        c = m // i
        if n * c <= m:
            return c
        elif n * i <= m:
            ret = i
    return ret


def main():
    n, m = map(int, input().split())
    print(solve(n, m))


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    n,m=map(int,readline().split())
    d=make_divisors(m)
    l=m//n
    for v in d:
        if v<=l:
            print(v)
            break

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

        divisors.sort(reverse=True)
        return divisors

if __name__=="__main__":
    main()

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

prime, i = set(), 1
while i * i <= M:
    if M % i == 0:
        prime.add(i)
        prime.add(M//i)
    i += 1

ans = 0
for i in prime:
    if i * N <= M:
        ans = max(ans, i)
print(ans)

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

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

ans = 1
for d in ds:
    if d >= N:
        ans = max(ans, M//d)
print(ans)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
import heapq
import sys

INF = 10 ** 17
MOD = 998244353
def mint(lis):
    return list(map(int, lis))

def bifind(arr_sorted, x):
    idx = bisect_left(arr_sorted, x)
    if idx == len(arr_sorted):
        return False
    if arr_sorted[idx] == x:
        return True
    else:
        return False
def getyaku(n):
    ret = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            ret.append(i)
            ret.append(n // i)

    return ret

def main():
    n, m = getList()
    ans = 0
    for yaku in getyaku(m):
        if m // yaku >= n:
            if ans < yaku:
                ans = yaku
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):











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

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


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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())

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

    
    return divisors

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

Solution (Python):
def main():
    def trial_division(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 = (int(i) for i in input().split())
    divs = trial_division(M)
    for d in divs:
        if N*d <= M:
            return print(d)


if __name__ == '__main__':
    main()

Solution (Python):
import math

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


def calculate(n, m):
    res = 1
    for i in range(1, int(math.pow(m, 0.5))):
        if m % i != 0:
            continue

        j = m // i

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

        if j <= m // n:
            res = max(res, j)

    print(res)


calculate(N, M)

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *





































def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




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

	ans = 1
	for i in range(1,M):
		if i > math.sqrt(M):
			break

		if M % i == 0:
			X = M // i
			I = i

			kouho = []
			if M % X == 0:
				tmp = M // X
				if tmp >= N:
					kouho.append(X)
			if M % I == 0:
				tmp = M // I
				if tmp >= N:
					kouho.append(I)

			if len(kouho) == 0:
				continue
			mmm = max(kouho)
			if ans < mmm:
				ans = mmm

	print(ans)






def bisect_left_reverse(a, x):
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok

def bisect_right_reverse(a, x):
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok





def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return None




def sunuke(N, K, mod=10**9+7):
	if N < K or K-1 < 0:
		return 0
	else:
		return combination(N-1, K-1, mod)




def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv



def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)



if __name__ == "__main__":
	main()

Solution (Python):
import math
import sys
MOD = 1000000007

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

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

ans = 1
for i in range(1, int(math.sqrt(m))+1):
    if m % i == 0:
        j = m / i
        if i <= m/n:
            ans = max(ans, i)
        if j <= m/n:
            ans = max(ans, j)

print(int(ans))

Solution (Python):
n,m=map(int,input().split())
a=m//n
while True:
  if m/a==int(m/a):
    print(a)
    exit()
  a-=1

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().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)

        
        return divisors

    n, m = ns()
    gcd = make_divisors(m)

    max_gcd = 1
    for d in gcd:
        if m // d >= n:
            max_gcd = max(max_gcd, d)

    print(max_gcd)


if __name__ == '__main__':
    main()

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().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 = ns()
    gcd = make_divisors(m)

    max_gcd = 1
    for d in gcd:
        if m // d >= n:
            max_gcd = d
            break

    print(d)


if __name__ == '__main__':
    main()

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

    st = {1, M}
    d = 2
    while d * d <= M:
        if M % d == 0:
            st.add(d)
            st.add(M // d)
        d += 1

    ans = 1
    for d in st:
        if d >= N:
            e = M // d
            ans = max(ans, e)
    print(ans)


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

N,M = (int(x) for x in input().split())
m = 0
for x in make_divisors(M):
    if M // x >= N:
        m = max(m,x)
print(m)

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

divisor_ls = make_divisors(m)

ans = 1
for divisor in divisor_ls:
    if m // divisor < n:
        break
    else:
        ans = divisor

print(ans)

Solution (Python):
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


def make_divisors(n):
    divisors = []
    divisors2 = []
    for i in range(1, int(round(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, input().split())
    divisors = make_divisors(M)
    while True:
        d = divisors.pop()
        if M >= N * d:
            print(d)
            return




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

div = make_divisors(m)
ans = 0
for d in div:
    if d * n <= m:
        ans = max(ans, d)

print(ans)

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

Solution (Python):
from math import floor
N,M=map(int,input().split())
p= floor(M**0.5)
kumi=[]

for i in range(1,p+1):
  if M%i==0:
    kumi.append((i,M//i))
    
ans=1
for pair in kumi:
  if pair[0]>=N:
    ans = max(ans,pair[1])
  if pair[1]>=N:
    ans = max(ans,pair[0])
print(ans)

Solution (Python):
def resolve():
    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())
    c = make_divisors(m)
    for i in c:
        if n>m//i:
            continue
        else:
            print(i)
            break
        
if __name__ == '__main__':
    resolve()

Solution (Python):
n,m = map(int,input().split())
div = []
for i in range(1,int(m**0.5)+1):
    if m%i == 0:
        div.append(i)
        div.append(m//i)
div.sort(reverse=True)
for x in div:
    if m//x >= n:
        print(x)
        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:
        x = m//i
        if x >= n:
            ans = max(ans,i)
        if i >= n:
            ans = max(ans,x)
print(ans)

Solution (Python):




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

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


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

print(ans)

Solution (Python):

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

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

d = make_divisors(M)
print(M//d[bisect.bisect_left(d, N)])

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().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

n,m = inpl()
for i in make_divisors(m):
    if i < n:
        continue
    print(m//i)
    break

Solution (Python):
def create_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

from math import floor
n,m=map(int,input().split())
n_max=floor(m/n)
d=create_divisors(m)
for di in d:
  if di<=n_max:
    print(di)
    exit(0)

Solution (Python):
def 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())
ans = 0
nums = divisors(m)
nums.sort()
num = nums.pop(0)
while num * n <= m:
    if (m - num * n) % num == 0:
        ans = num
    if nums == []:
        break
    num = nums.pop(0)
print(ans)

Solution (Python):
def main():
    n, m = map(int, input().split())
    f = [1, m]
    i = 2
    while i * i <= m:
        if m % i == 0:
            f.append(i)
            if m != i * i:
                f.append(m // i)
        i += 1
    f.sort()
    answer = 0
    for ff in f:
        if n <= ff:
            answer = m // ff
            break
    print(answer)


if __name__ == '__main__':
    main()

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

ans = 1
for x in range(1, 10 ** 5 + 10):
    if M % x == 0:
        if N * x <= M:
            ans = max(ans, x)
        if N * (M // x) <= M:
            ans = max(ans, M // x)

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:
    y=m//i
    if m//i>=n and ans<i:
      ans=i
    if m//y>=n and ans<y:
      ans=y
print(ans)

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

    
    return divisors

N, M = map(int, input().split())
print(max([x for x in make_divisors(M) if x <= M // N]))

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

Solution (Python):
import sys

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


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

    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

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

    print(res)




if __name__ == '__main__':
    resolve()

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

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

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

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

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



def make_divisors(n):
    import math
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0: 
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    divisors.sort(reverse = True)
    return divisors

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

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

from collections import defaultdict


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


ans = 1
soin = divide(m)
soin.sort(reverse=True)
for num in soin:
    if num * n <= m:
        ans = num
        break

print(ans)

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

Solution (Python):
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()
for i in range(m//n,0,-1):
    s,a=divmod(m,i)
    if a%s==0:
        print(i)
        exit()

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


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 

div = divisor(M)
ans = 0
for d in div:
    if M//d >= N:
        ans = max(ans,d)
print(ans)

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


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

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

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

sq = math.sqrt(M)
sq = math.floor(sq)


ans = 1
for i in range(1,sq+2):
  if M % i == 0:
    if i * N <= M:
      ans = max(i,ans)
    if M / i * N <= M:
      ans = max(M // i,ans)
if N == 1:
  print(int(M))
else:
  print(int(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:
        if m // i >= n:
            ans = max(ans, i)
        if i >= n:
            ans = max(ans, m // i)
print(ans)

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

ans = 0
for i in range(1, int(m ** 0.5) + 1)[::-1]:
    if (m % i == 0):
        if m / i >= n:
            ans = max(ans, i)
        if i >= n:
            ans = max(ans, m // i)
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


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

    divisors.sort(reverse=True)
    return divisors


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

    divisors = make_divisors(M)
    ans = 1
    for d in divisors:
        if M // d >= N:
            if ans < d:
                ans = d

    print(ans)


if __name__ == "__main__":
    main()