Problem:
 Score : 400 points    Problem Statement You are given integers N and M .  Consider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M . Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N .      Constraints  All values in input are integers.  1 \leq N \leq 10^5  N \leq M \leq 10^9         Input Input is given from Standard Input in the following format:  N  M       Output Print the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.        Sample Input 1 3 14      Sample Output 1 2  Consider the sequence (a_1, a_2, a_3) = (2, 4, 8) . Their greatest common divisor is 2 , and this is the maximum value.       Sample Input 2 10 123      Sample Output 2 3       Sample Input 3 100000 1000000000      Sample Output 3 10000

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res

MOD=10**9+7

import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

def main():
    n, m = MII()
    divs = enumerate_divs(m)
    ans = []
    h = m/n
    for i,j in divs:
        if i <= h:
            ans.append(i)
        if j <= h:
            ans.append(j)
    print(max(ans))


if __name__ == '__main__':
    main()

Solution (Python):
N,M=list(map(int,input().split()))
def div(N):
   l=[]
   for i in range(1,int(N**0.5)+1):
      if N%i==0:
         l.append(i)
         if i != N//i:
            l.append(N//i)
   l.sort()
   return l
l = div(M)
ans=-1
for i in l:
   if M//i>=N:
      ans+=1
   else:
      break
print(l[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)

    
    return divisors
li = make_divisors(m) 

ans = 1
for l in li:
    if l>ans and l*n <= m:
        ans = l
print(ans)

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()

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

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

print(ans)

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


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

ans = 1
for a, b in pair:
    if b >= N:
        ans = max(ans, a)
    if a >= N:
        ans = max(ans, b)

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 i * n <= m:
        ans = i
    else:
        break

print(ans)

Solution (Python):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


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
x,y=MI()
u=make_divisors(y)
for j in u:
    if j>=x:
        ans=y//j
        break
print(ans)

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

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

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

print(ans)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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




def warshall_floyd(d, n):
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d



def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


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 lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)






def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret




n, m = map(int, input().split())
ans = m // n
while True:
    if (m - ans) % ans == 0 and (m - ans) // ans >= n - 1:
        print(ans)
        break
    ans -= 1

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

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,M//i))
ans = 0
for x in L:
    if x[1] >= N:
        ans = max(ans,x[0])
    if x[0] >= N:
        ans = max(ans,x[1])
print(ans)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

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

Solution (Python):


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

i=m//n

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

    divisors.sort(reverse=True)
    return divisors

lis=make_divisors(m)

for mm in lis:
    if mm<=i:
        ans=mm
        break

print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


n, m = Is()
a = m//n
for i in reversed(range(a+1)):
    if m % i != 0:
        continue
    else:
        print(i)
        exit()

Solution (Python):
def make_divisors(n):
    divisors = set([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors
N,M = map(int,input().split())
A=make_divisors(M)
ans=0
for i in A:
 if i<=M/N:
  ans=max(ans,i)
print(ans)

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

flag = True
yakusuu = []
for i in range(1, math.floor(math.sqrt(M))+1):
    if(M % i == 0):
        yakusuu.append(i)
        yakusuu.append(int(M / i))
yakusuu.sort()
yakusuu.reverse()
for i in yakusuu:
    if M / i >= N and flag == True:
        print(i)
        flag = False

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

D=make_divisors(M)
D=sorted(D)
ans=0
for d in D:
    if M//d>=N:
        ans=d
print(ans)

Solution (Python):





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

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

box = make_divisors(m)

for i in range(len(box)):
  if box[i] >= n:
    print(m // box[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()
    divisors.reverse()
    return divisors
n, m = map(int, input().split())
l = make_divisors(m)
for i in l:
    if m / n >= i:
        print(i)
        exit()
print(1)

Solution (Python):
import math


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

    return divisors


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

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

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

numbers = make_divisors(m)
for i in range(len(numbers)):
  if numbers[i] <= m/n:
    print(numbers[i])
    break

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

def resolve():
    n,m=map(int, input().split())
    def make_divisors(n):
             divisors = []
             for i in range(1, int(n**0.5)+1):
                 if n % i == 0:
                     
                     divisors.append(i)
                     
                     if i != n // i:
                         divisors.append(n//i)
             divisors.sort(reverse=True) 
             return divisors
    for i in make_divisors(m):
        if i*n<=m:
            print(i)
            break

resolve()

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

P = [1]
for k in range(2,math.floor(math.sqrt(M))+1):
    if M % k == 0:
        P.append(k)
        P.append(M//k)

P = sorted(P)
for e in P:
    if e >= N:
        print(M//e)
        exit(0)
print(1)

Solution (Python):
n,m=map(int,input().split())
i=1
x=[]
while(i*i<=m):
    if(m%i==0):
        x.append(i)
        x.append(m//i)
    i+=1
x.sort()
for xi in x:
    if(xi>=n):
        print(m//xi)
        break

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

n, m = [int(x) for x in input().split()]
ans = 0


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

    divisors.sort()
    return divisors

g = make_divisors(m)

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

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

def resolve():
    N,K=pin()
    t=K//N
    for i in range(t,0,-1):
        if K%i==0:
            print(i)
            return
        

resolve()

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

i = 1


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


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

Solution (Python):
def main():
    N, M = (int(i) for i in input().split())

    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
    divs = trial_division(M)
    for d in divs:
        if d*N <= M:
            return print(d)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

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

N, M = map(int, input().split())
ds = make_divs(M)
ans = 0

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

print(ans)

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

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

    divisors.sort(reverse=True)
    return divisors

d = make_divisors(m)
ans = -1
for i in d:
    j = m//i
    if j >= n:
        ans = max(i, ans)
print(ans)

Solution (Python):
import numpy as np

def factor(N):
    ans = []
    for i in range(1,int(np.sqrt(N))+1):
        if N%i == 0:
            ans.append(i)
            if N//i != i:
                ans.append(N//i)
    return ans

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a, b):
    return (a * b)//gcd(a,b)

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

p.sort()

for i in reversed(range(len(p))):
    if p[i] <= M/N:
        print(p[i])
        break

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

n = M

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

ans = 1
l = list(prime)
for i in l:
    if i * N <= M:
        ans = max(ans, i)

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

for k in divisors(M):
    if k * N <= M:
        print(k)
        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!=n//i:ass.append(n//i)
  return ass
ans=0
for i in divisor(m):
  if m//i>=n:ans=max(ans,i)
print(ans)

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


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

A = divisors(m)

ans = 0
for a in A:
    if m // a >= n:
        ans = a

print(ans)

Solution (Python):
def main():
    N, M = (int(_) for _ in input().split())
    a = []
    output = 0
    for p in range(1, int(M**.5)+1):
        if M%p == 0:
            a.append(p)
            a.append(M//p)
    for p in a:
        if M//p >= N: output = max(output, p)
    print(output)
    return

if __name__ == '__main__':
    main()

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

    def divisor(n):
        ''' nの約数列挙 '''
        arr = []
        for i in range(1, int(n**0.5) + 1):
            if n % i == 0:
                arr.append(i)
                arr.append(n // i)
        return arr  

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

abc112_d()

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

syou = m//n
amari = m%n

while True:
    if amari%syou == 0:
        print(syou)
        break
    else:
        amari+=n
        syou-=1

Solution (Python):
n, m = map(int, input().split())
import math
def divisor(n):
    a = set()
    for i in range(1, math.ceil(n**0.5) + 1):
        if n % i == 0:
            a.add(i)
            a.add(n // i)
    return a
d = list(divisor(m))
d.sort(reverse=True)
for di in d:
    if di * n <= m:
        print(di)
        exit()
print(1)

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

def f(m):
    d = []
    r = int(m**0.5)
    for i in range(1,r+1):
        if m % i == 0:
            d.append(i)
            d.append(m//i)
    d.sort(reverse = 1)
    return d

d = f(m)
for x in d:
    p = m//x
    
    
    if n <= p:
        print(x)
        exit()

Solution (Python):

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


n, m = map(int, input().split())
m_div = divisor(m)
m_div.sort()
ans = 0
for i in m_div:
    if i * n <= m and (m - i*n) % i == 0:
        ans = max(ans, i)
print(ans)

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return 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


def main():
    N, M = readnums()
    ml = make_divisors(M)
    print(max([x for x in ml if x <= M // N]))


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

Mlist = make_divisors(M)

ans = 0
for i in Mlist:
    if N * i <= M:
        ans = i
    else:
        break

print(ans)

Solution (Python):
def main():
    N, M = list(map(int, input().split(' ')))
    n = 1
    ans = 1
    while n**2 <= M:
        if M % n == 0:
            if n * N <= M:
                ans = max([ans, n])
            m = M // n
            if m * N <= M:
                ans = max([ans, m])
        n += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
import bisect
def main():
    n,m=map(int,input().split())
    div=make_divisors(m)
    print(div[bisect.bisect(div,m//n)-1])
    

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
import bisect
def main():
    n,m=map(int,input().split())
    div=make_divisors(m)
    print(div[bisect.bisect(div,m//n)-1])
    

if __name__=='__main__':
    main()

Solution (Python):


n, m = map(int, input().split())
if n == 1:
    ans = m
else:
    ans = 1
    i = 1
    limit = m / n
    while i <= limit:
        if m % i == 0 and m // i >= n:
            ans = max(ans, i)
        i += 1
print(ans)

Solution (Python):
n,m=map(int,input().split());print(next(v for v in range(m//n,-1,-1)if m%v<1))

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

Solution (Python):
n,m=map(int,input().split());print(next(v for v in range(m//n,-1,-1)if m%v==0))

Solution (Python):

n, m = map(int, input().split())
print(next(v for v in range(m // n, -1, -1) if m % v == 0))

Solution (Python):
n, m = map(int,input().split())
ps = [1]
nw = 1
mi = m//n
while nw**2 < m:
    if m%nw == 0:
        if mi >= nw:
            ps.append(nw)
        if mi >= m//nw:
            ps.append(m//nw)
    nw += 1
if nw**2 == m and nw <= mi:
    ps.append(nw)

print(max(ps))

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

d = M//N

divisor = sorted(make_divisors(M))

from bisect import *

b = bisect_left(divisor,d)
if divisor[b] == d:
  ans = divisor[b]
else:
  ans = divisor[b-1]
print(ans)

Solution (Python):
import math
from itertools import product
class Eratos:
    def __init__(self, num):
        assert(num >= 1)
        self.table_max = num
        
        self.table = [False if i == 0 or i == 1 else True for i in range(num+1)]
        for i in range(2, int(math.sqrt(num)) + 1):
            if self.table[i]:
                for j in range(i ** 2, num + 1, i):    
                    self.table[j] = False
        
        self.prime_numbers = [2] if self.table_max >= 2 else []
        for i in range(3, self.table_max + 1, 2):
            if self.table[i]:
                self.prime_numbers.append(i)
    
    def is_prime(self, num):
        """
        >>> e = Eratos(100)
        >>> [i for i in range(1, 101) if e.is_prime(i)]
        [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
        """
        assert(num >= 1)
        if num > self.table_max:
            raise ValueError('Eratos.is_prime(): exceed table_max({}). got {}'.format(self.table_max, num))
        return self.table[num]
    
    def prime_factorize(self, num):
        """
        >>> e = Eratos(10000)
        >>> e.prime_factorize(6552)
        {2: 3, 3: 2, 7: 1, 13: 1}
        """
        assert(num >= 1)
        if int(math.sqrt(num)) > self.table_max:
            raise ValueError('Eratos.prime_factorize(): exceed prime table size. got {}'.format(num))
        factorized_dict = dict()    
        candidate_prime_numbers = [i for i in range(2, int(math.sqrt(num)) + 1) if self.is_prime(i)]
        
        
        for p in candidate_prime_numbers:
            
            if num == 1:
                break
            if num % p == 0:
                cnt = 0
                while num % p == 0:
                    num //= p
                    cnt += 1
                factorized_dict[p] = cnt
        if num != 1:
            factorized_dict[num] = 1
        return factorized_dict
    
    def enum_divisor(self, num):
        """
        >>> e = Eratos(10000)
        >>> e.enum_divisor(4)
        [1, 2, 4]
        >>> e.enum_divisor(19)
        [1, 19]
        >>> e.enum_divisor(100)
        [1, 5, 25, 2, 10, 50, 4, 20, 100]
        """
        factorized_dict = self.prime_factorize(num)
        primes = list(factorized_dict.keys())
        all_pattern_powers = product(*[range(i + 1) for i in factorized_dict.values()])    
        divisor = []
        for power_pattern in all_pattern_powers:
            tmp = 1
            for i in range(len(power_pattern)):
                tmp *= pow(primes[i], power_pattern[i])
            divisor.append(tmp)
        return divisor

N, M = map(int, input().split())
eratos = Eratos(int(math.sqrt(M)) + 1)
L = eratos.enum_divisor(M)
L.sort(reverse=True)
for div in L:
    if div * N <= M:
        print(div)
        exit()

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

    divisors.sort()
    return divisors

n, m = map(int, input().split(" "))
max = 1

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

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

dvs = make_divisors(m)

for item in dvs:
    if item >= n:
        print(m // item)
        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())

if M%N == 0:
    print(M//N)
else:
    D = sorted(make_divisors(M))[::-1]
    for d in D:
        if M//d >= N:
            print(d)
            break

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

ans = 1
if(N < M//N):
  i = N
  while(ans == 1 and i <= math.sqrt(M)):
    if(M % i == 0):
      ans = M//i
    i += 1
if(N >= M//N or ans == 1):
  i = M//N
  while(ans == 1 and i >= 1):
    if(M % i == 0):
      ans = i
    i -= 1
  
print(ans)

Solution (Python):

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

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

a = 0
for x,y in ans:
    if x>=N:
        a = max(a, y)
    if y>=N:
        a = max(a, x)

print(a)

Solution (Python):
import sys
import bisect

inf = 10**15
mod = 10**9+7


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())
kouho = make_divisors(m)
for num in kouho:
    if m//num >= n:
        print(num)
        sys.exit()

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

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

    divisors.sort()
    return divisors

test=make_divisors(m,n)
print(m//min(test))