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):
n,m=map(int,input().split())
ans=[]
for i in range(int(m**0.5)):
  if m%(i+1)==0:
    ans.append(i+1)
    ans.append(m//(i+1))
ans.sort()
for i in range(len(ans)):
  if n*ans[i]>m:
    break
  ans1=ans[i]
print(ans1)

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

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

gs.sort(reverse=True)


for j in gs:
  if m//j >= n:
    print(j)
    exit()

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

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

gs.sort(reverse=True)


for j in gs:
  if m//j >= n:
    print(j)
    exit()

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











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









ans_temp = M // N
if M % N == 0:
    print(ans_temp)
    exit()


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, sort=False):
    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)
    if sort:
        divisors.sort()
    return divisors


print(max(make_divisors(M), key=lambda x: 0 if x > ans_temp else x))

Solution (Python):










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

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

Solution (Python):










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

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

Solution (Python):
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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



N, M = list(map(int, sys.stdin.buffer.readline().split()))


def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


divs = get_divisors(M)

divs.sort(reverse=True)
for d in divs:
    if M // d >= N:
        print(d)
        break

Solution (Python):
N,M = map(int,input().split())
k = 1
for i in range(1,int(M**0.5)+1):
    if M%i==0:
        a = i
        b = M//i
        k1 = 1
        k2 = 1
        if b>=N:
            k1 = a
        if a>=N:
            k2 = b
        k = max(k,k1,k2)
print(k)

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

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

print(ans)

Solution (Python):
N, M = map(int, input().split())
S = 1
p = 0
X = []
for i in range(2, int(M ** (1/2)) + 1):
  if M % i == 0:
    if i <= M // N:
      p = i
      X.append(i)
    else:
      break
if M // N <= int(M ** (1/2)):
  if p != 0:
    S = p
else:
  if p != 0:
    S = M
    q = 0
    while S > M // N:
      S = M // X[q]
      if S <= M // N:
        break
      q += 1
      if q == len(X):
        break
    if q == len(X):
      S = max(X)
print(S)

Solution (Python):
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, M = MAP()

if N==M:
	print(1)
	sys.exit()

X = M//N+1
for i in range(X, -1, -1):
	if M % i == 0:
		print(i)
		sys.exit()
print(0)

Solution (Python):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
x = 2
res = 0
if N == 1: 
  print(M)
  exit(0)
while x * x <= M:
  if M % x == 0:
    if M // x >= N: res = max(res, x)
    y = M // x
    if M // y >= N: res = max(res, y)
  x += 1
if res == 0: print(1)
else: print(res)

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

def divisors(n):
  divisors = set()
  for i in range(1, int(n**0.5)+1):
    if n%i == 0:
      divisors.add(i)
      divisors.add(n//i)
  return divisors

ans = 1
for i in sorted(divisors(M)):
  if i >= N:
    ans = M//i
    break
print(ans)

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

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


ans = 1

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

print(ans)

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

import math
sq=int(math.sqrt(m))//1


yaku=[]
for i in range(1,sq+1):
  if m%i==0:
    yaku.append(i)
    yaku.append(m//i)
yaku.sort(reverse=True)

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

    divisors.sort(reverse=True)
    return divisors
for i in range(len(make_divisors(m))):
  if make_divisors(m)[i]<=(m//n):
    break
print(make_divisors(m)[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

divisors = make_divisors(M)
divisors.sort()

for idx, a in enumerate(divisors):
    
    if M / a >= N:
        continue
    else:
        if idx-1 < 0:
            print(1)
            exit()
        else:
            print(divisors[idx-1])
            exit()
        break
       
print(divisors[-1])

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def divisors(N: int) -> set:
    """ 約数の列挙・個数 """
    from math import sqrt

    
    s = {1, N}
    
    for i in range(2, int(sqrt(N))+1):
        
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

N, M = MAP()


divs = sorted(divisors(M), reverse=1)

for div in divs:
    cnt = M // div
    if cnt >= N:
        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(reverse=True)
    return divisors

N,M = map(int,input().split())
divs = make_divisors(M)
for d in divs:
    m = M // d
    if m >= N:
        ans = d
        break
print(d)

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

for i in range(M//N +1,0,-1):
    if(M%i==0):
        if((M//i)>=N):
            print(i)
            exit()

Solution (Python):
import sys
import numpy as np
import fractions
input = sys.stdin.readline
N, M  = [int(x) for x 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
ans = make_divisors(M)
ans = sorted(ans)[::-1]
for i in ans:
    if i <= M/N:
        print(i)
        sys.exit()

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

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

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

    if M % N == 0:
        return print(M//N)

    divs = [i for i in trial_division(M) if i >= N]
    print(M//min(divs))


if __name__ == '__main__':
    main()

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
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)
            divisors.append(n // i)
    return divisors



def prime_factorization(n):
    fact=[]
    for i in range(2, int(sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            fact.append(i)
    return fact

def main():
    N,M= MI()
    P = find_divisor(M)
    ans = 1
    for p in P:
        if M/p>=N:
            ans = max(ans,p)
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):




from math import floor


def divisor(n):
    left = [1]
    right = [n]
    sup = floor(pow(n,1/2))
    for p in range(2,sup+1):
        if n % p == 0:
            if p == n//p:
                left.append(p)
                continue
            left.append(p)
            right.append(n//p)
    res = left + right[::-1]
    return res

N, M = map(int,input().split())
cand = divisor(M)
ans = 1
for ch in cand:
    if M // ch >= N:
        ans = max(ans, ch)

print(ans)

Solution (Python):

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd



def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)



show_flg = False


def divisor(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret

def eucledean(A, N):
    
    ans = A[0]
    for i in range(1, N):
        ans = gcd(A[i], ans)
    print(ans)


def main():
    N, M = MI()
    data = sorted(divisor(M))
    ans = 1

    for i in data:
        c = M // i
        
        if c >= N:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd



def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)



show_flg = False


def divisor(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret

def eucledean(A, N):
    
    ans = A[0]
    for i in range(1, N):
        ans = gcd(A[i], ans)
    print(ans)


def main():
    N, M = MI()
    data = sorted(divisor(M))
    ans = 1

    for i in data:
        c = M // i
        
        if c >= N:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()

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

def main():
    N, M = map(int, input().split())
    d = divisor(M)
    d.sort(reverse=True)
    for i in d:
        if i * N <= M:
            print(i)
            exit()




if __name__ == "__main__":
    main()

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


n, m = map(int,input().split())
k = (m+1) // n

div = calc_divisor(m)
for i in div:
    if i <= k:
        ans = i
print(ans)

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

for i in d:
    if m>=n*i:
        ans=max(ans,i)

print(ans)

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


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


d = div(m)
ans = 0
for x, y in d:
    if y >= n:
        ans = max(ans, x)

print(ans)

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

Solution (Python):
import bisect

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

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

divisors = make_divisors(M)
idx = bisect.bisect_right(divisors,int(M/N)) - 1
print(divisors[idx])

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

Solution (Python):
from collections import deque

def divider(m):
  i = 1
  s = deque()
  g = deque()
  while i**2 < m:
    if m % i == 0:
      s.append(i)
      g.appendleft(m//i)
    i += 1
  if i**2 == m:
    s.append(i)
  s += g
  return s
        

N, M = map(int, input().split())
D = divider(M)
ans = 0
for d in D:
  if d*N <= M:
    ans = d
  else:
    break
print(ans)

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

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

print(M//div)

Solution (Python):
import math

n,m = map(int,input().split())
roop = min(m//n,math.floor(math.sqrt(m)))
if n == 1:
    print(m)
    exit()
ans = -10**9
for i in range(1,roop+1):
    if m%i == 0:
        if m//i <= m//n:
            ans = max(ans,i,m//i)
        else:
            ans = max(ans,i)
print(ans)

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

N,M = map(int,input().split())
g=M//N
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

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

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

N, M = map(int, input().strip().split())
ans = 1
if N == 1:
    print(M)
    exit()

for n in range(2, int(M ** 0.5) +1):
    if M % n == 0:
        if n < N and M // n < N:
            continue
        elif n >= N and M // n < N:
            ans = max(ans, M // n)
        elif n < N and M // n >= N:
            ans = max(ans, n)
        else:
            ans = max(ans, n, M // n)

print(ans)

Solution (Python):

import sys
from bisect import bisect_left



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

def solve(N: int, M: int):
    if M%N == 0:
        print(M//N)
        return

    max_answer = M//N
    divisors = divisor(M)
    divisors.sort()

    index = bisect_left(divisors,max_answer)
    if index == 0:
        print(1)
        return 
    print(divisors[index-1])


    return


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

if __name__ == '__main__':
    main()

Solution (Python):
def make_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_list = make_divisors(M)
divisors_list.sort(reverse=True)

for val in divisors_list:
    if val * N <= M:
        break
print(val)

Solution (Python):
n,m=map(int,input().split())
ans=0
import math
for i in range(1,int(math.sqrt(m))+1):
  if m%i!=0:
    continue
  i2=m//i
  if i*n<=m:
    ans=max(ans,i)
  if i2*n<=m:
    ans=max(ans,i2)
print(ans)

Solution (Python):
import sys


def main():
    N, M = map(int, input().split())
    s = M // N  
    m = M % N

    for i in range(s, 0, -1):
        if m % i == 0:
            print(i)
            sys.exit()
        else:
            m += N


main()

Solution (Python):
import math
N,M = map(int,input().split())
ans = 0
for i in range(math.ceil(math.sqrt(M)),0,-1):
    if M%i == 0:
        j = M//i    
        if N<=i:
            ans = max(ans,j)
        if N<=j:
            ans = max(ans,i)
print(ans)

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

Solution (Python):
from math import floor


def solve(n, m):
    factor = [1]
    if m % n == 0:
        ans = m // n
    else:
        for f in range(floor(m//n), 1,-1):
            if m % f == 0:
                factor.append(f)
                break
        ans = factor[-1]

    return ans


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve(n, m))

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

ans = 1
for i in range(m//n,0,-1):
    rest = m - (i * (n - 1))
    if rest % i == 0:
        print(i)
        sys.exit()

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

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_max = m//n + 1
divs = sorted(make_divisors(m))
from bisect import bisect_left

ind = bisect_left(divs, div_max)
print(divs[ind-1])

Solution (Python):

import math
N,M = map(int,input().split())
n = 1
rootM = int(math.sqrt(M))+1
for i in range(rootM):
    if M % (i+1) == 0 and N*(i+1) <= M:
        if N*(M/(i+1)) <= M and n <= (M/(i+1)):
            n = M/(i+1)
        elif n <= i+1:
            n = i+1
        else:
            continue
print(int(n))

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

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

divs = divisors(m)
ans = 1
for d in divs:
    if m // d >= n:
        ans = d
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def divisors(n):
    S,T=[],[]
    for i in range(1,int(n**.5)+1):
        if n%i==0:
            S.append(i)
            T.append(n//i)
    T.reverse()
    return S+T if S[-1]!=T[0] else S+T[1:]

def resolve():
    n,m=map(int,input().split())
    D=divisors(m)
    ans=0
    for d in D:
        if(d*n<=m):
            ans=max(d,ans)
    print(ans)
resolve()

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

k = M // N + 1
ans = 1
for i in reversed(range(1, k+1)):
    if ans > i:
        break
    tmp = max(M - (N-1)*i, 1)
    if tmp % i == 0:
        ans = max(ans, i)

print(ans)

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
line = make_divisors(m)
print(m//line[bisect.bisect_left(line, n)])

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

d = divisor(M)

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

Solution (Python):
def divide(x): 
    div=[1]
    check=2
    for check in range(1,int(x**0.5)+1):
        if(x%check==0):
            div.append(check)
            div.append(x//check)
    div.sort()
    return div

def main():
    n,m = map(int,input().split())
    di=divide(m)
    for i in range(len(di)):
        if di[len(di)-1-i]<=m//n:
            print(di[len(di)-1-i])
            return
    
if __name__ == "__main__":
    main()

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

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

import bisect
def find_lt(a,x):
    i = bisect.bisect_right(a,x)
    if i:
        return a[i-1]
    else:
        return -1

MD=make_divisors(M)
print(find_lt(MD,M//N))

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

n,m = map(int,input().split())
y = make_divisors(m)
for i in y:
  if m // i >= n:
    print(i)
    exit()

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

    divisors.sort(reverse=True)
    return divisors

N, M = map(int, input().split())
L = make_divisors(M)
for l in L:
    if M // l >= N:
        print(l)
        exit()
print(1)

Solution (Python):
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
d = 1
if (N == 1):
    print(M)
else:
    while (d*d <= M):
        if (M//d * d != M): 
            d += 1
            continue
        d2 = M//d
        if (d*N <= M):
            ans = max(ans, d)
        if (d2*N <= M):
            ans = max(ans, d2)
        d += 1
    print(ans)

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

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

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

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

def solve() :
    ret = 1
    i = 1
    while i * i <= M :
        if M % i == 0 :
            if i >= N :
                ret = max(ret, M // i)
            if M // i >= N :
                ret = max(ret, i)
        i += 1
    
    return ret

print(solve())

Solution (Python):



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

x = min(M//N, int(M**0.5))
ans_list = []

while x > 0:
    if M % x == 0:
        ans_list.append(x)
        if (M//x) * N <= M:
            ans_list.append(M//x)
    x -= 1
    
print(max(ans_list))

Solution (Python):



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

x = min(M//N, int(M**0.5))
ans_list = []

while x > 0:
    if M % x == 0:
        ans_list.append(x)
        if (M//x) * N <= M:
            ans_list.append(M//x)
    x -= 1
    
print(max(ans_list))

Solution (Python):



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

if N == 1:
    print(M)
    exit()

x = M//N

while 1:
    if M % x == 0:
        ans = x
        break
    x -= 1
    
print(ans)

Solution (Python):
import sys
import math




		
def main():
	n,m = map(int, input().split())
	if m % n ==0:
		return m // n
		
	ll=1
	for i in range(1, int(math.sqrt(m))+1):
		
		if m % i == 0:
			if i >= n:
				ll=max(ll, m // i)
			if m // i >= n:
				ll=max(ll, i)
	return ll
				


isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
N, M = map(int, input().split())
tmp = M // N
ansMax = 0
y = []
for i in range(1, (int(M ** (0.5)) + 1)):
    if M % i == 0:
        y.append(i)
        if i != M // i:
            y.append(M // i)
y.sort()

for i in y:
    if i <= tmp:
        ansMax = i
    else:
        break
print(ansMax)

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

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

    return divisors

divs = compute_divisors(M)
divs.sort(reverse=True)

for div in divs:
    if M / div >= N:
        ans = div
        break

print(ans)

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

mx = 0
for i in range(1, int(M ** 0.5) + 1)[::-1]:
    if M % i == 0 and M // i >= N:
        mx = max(mx, i)
    if M % i == 0 and i >= N:
        mx = max(mx, M // i)
print(mx)

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!=n//i:ass.append(n//i)
  return ass
n,m=map(int,input().split())
d=sorted(divisor(m))
for i in d[::-1]:
  if m//i>=n:print(i);break

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

def get_divisors(num):
    f_divs, l_divs = [], []
    for i in range(1, int(num**0.5)+1):
        if not num % i:
            f_divs.append(i)
            if i != num // i:
                l_divs.append(num // i)
    return f_divs + l_divs[::-1]

for d in reversed(get_divisors(m)):
    if n * d <= m:
        print(d)
        break

Solution (Python):

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

    
    divisors.sort() 

    return divisors

n,m = [int(_) for _ in input().split()]
ans = 0
l = make_divisors(m)
for i in range(0, len(l)):
    if m // l[i] >= n:
        ans = max(l[i], ans)
print(ans)

Solution (Python):
def div(N):
    ans = []


    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
    ans.sort()
    return ans

N,M=map(int,input().split())
if N==1:
    print(M)
    exit()

divM=div(M)

for i in range(1,len(divM)):
    if divM[i]>M//N:
        print(divM[i-1])
        exit()

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

ans=0
cnt=make_divisors(M)
tmp=bisect.bisect_right(cnt,M/N)

print(cnt[tmp-1])

Solution (Python):
N,M=map(int,input().split())
if N==1:
    print(M)
    exit()

if N>=M**0.5:
    for i in range(M//N,0,-1):
        if M%i==0:
            print(i)
            exit()
else:
    for i in range(N,M+1):
        if M%i==0:
            print(M//i)
            exit()
print(1)

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

def get_divisor(n):
    '''nの約数を返す
    '''
    d = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            d.add(i)
            d.add(n//i)
    return d

D = list(get_divisor(M))
D.sort(reverse=True)

ans = 0
for d in D:
    if M//d < N:
        continue
    ans = d
    break

print(ans)