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

Solution (Python):
from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M/j for j in divisor_set)
    print(int(max([i for i in divisor_set if special_value >= i])))
    return

main()

Solution (Python):
import math


def prime(M):
    if M == 1:
        return [1]
    lst = []
    for i in range(1, int(math.sqrt(M)+1)):
        if M % i == 0:
            lst.append(i)
            div = M // i
            if div not in lst:
                lst.append(div)
    return sorted(lst)


N, M = map(int, input().split())
lst = prime(M)
res = 1
for num in lst:
    if (M // N) < num:
        break
    else:
        res = num

print(res)

Solution (Python):
import math

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

if N == 1:
    print(M)
else:
    divisor = []
    n = int(math.sqrt(M))
    for i in range(1, n+1):
        if M % i == 0:
            tmp = M // i
            if not i in divisor:
                divisor.append(i)
            if not tmp in divisor:
                divisor.append(tmp)
    maximize = 0
    threshold = M // N
    for item in divisor:
        if item <= threshold and maximize < item:
            maximize = item

    print(maximize)

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

Solution (Python):
from math import sqrt

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

l=[]
for i in range(1,int(sqrt(m))+1):
    if m%i == 0:
        l.append(i)
        l.append(m//i)
l.sort(reverse=True)
for i in l:
    if i*n<=m:
        print(i)
        break

Solution (Python):
def soinsuubunkai(n):
    i = 2
    list = [1]
    while i**2 <= n:
        if n%i == 0:
            list.append(i)
            if i != n//i:
                list.append(n//i)
        i += 1
    list.append(n)
    return list
n, m = map(int, input().split())
l = soinsuubunkai(m)
l.sort()
r = len(l)
for i in range(r):
    if m//l[r-i-1] >= n:
        print(l[r-i-1])
        quit()

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


gcd=1
while(1):
    if(M%i==0):
        print(M//i)
        sys.exit(0)
    if(i**2 >M):
        break
    i+=1

i=M//N
while(1):
    if(M%i==0):
        print(i)
        sys.exit(0)
    i-=1

Solution (Python):
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break

Solution (Python):
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break

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

Solution (Python):
import math
N, M = map(int, input().strip().split())
st= min(M//N,int(math.sqrt(M)))
cand=0
if M//N <= int(math.sqrt(M)):
    for i in range(M//N,0,-1):
        if M%i==0:
            print(i)
            break
else:
    for i in range(1,int(math.sqrt(M)),1):
        if M%i==0:
            if M//N >= i:
                cand=max(cand,i)
            if M//N >= M//i:
                cand=max(cand,M//i)
    print(cand)

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

if n > 100:
    for i in range(p, 0, -1):
        if m % i == 0:
            print(i)
            break
else:
    for i in range(n, m + 1):
        if m % i == 0:
            print(int(m / i))
            break

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

c = [1]
for i in range(1,math.ceil(math.sqrt(M))):
    if M%i == 0 :
        if i <= M//N and M//i > M//N:
            c.append(i)
        if i <= M//N and M//i <= M//N:
            c.append(M//i)
        else:
            continue
c = sorted(c)
print(c[-1])

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

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

Solution (Python):
'''input
100000 1000000000
'''
from math import sqrt
def div(n):
	s = set()
	for i in range(1,int(sqrt(n))+1):
		if n%i == 0:
			s.add(i)
			s.add(n//i)
	return s
n,m = map(int,raw_input().split())
s = div(m)
aa = -1
for i in s:
	if i*n <= m:
		aa = max(aa,i)
print aa

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




ans = 1
x = 1
while x * x <= M:
    if M % x == 0:
        if x >= N:
            ans = max(ans, M//x)
        if M//x >= N:
            ans = max(ans, x)
    x += 1
print(ans)

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

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

yueshu = []
state = 0
if m % n == 0:
    print m / n
else:
    for i in range(1, int(m**0.5)+1):
        if m % i == 0:
            yueshu.insert(0, m/i)
            if i >= n:
                print m / i
                state = 1
                break
    if state == 0:
        for i in yueshu:
            if m % i == 0:
                if i >= n:
                    print m / i
                    state = 1
                    break
    if state == 0:
        print 1

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

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

Solution (Python):
import math
N, M = map(int, input().split())
d = []
for i in range(1, int(math.sqrt(M)) + 1):
    if M % i == 0:
        d.append(i)
        d.append(int(M / i))
d = list(filter(lambda x: x <= int(M / N), d))
print(max(d))

Solution (Python):
def calc():
 N,M = map(int,input().split())
 for gcd in range(M // N,0,-1):
  if M % gcd == 0:
   break
 return(gcd)
print(calc())

Solution (Python):
def calc():
 N,M = map(int,input().split())
 for gcd in range(M // N,0,-1):
  if M % gcd == 0:
   break
 return(gcd)
print(calc())

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

Solution (Python):

import math

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

a = []
root_m = int(math.sqrt(m)) + 1
for i in range(1,root_m):
    if m%i == 0:
        a.append(m/i)
        if i >= n:
            print m/i
            exit()
for i in reversed(a):
    if m%i == 0:
        if i >= n:
            print m/i
            exit()
print "1"

Solution (Python):
import sys


def divisor_gen(n):
    ret = set()
    for i in range(1, int(n ** (1 / 2) + 1)):
        if n % i == 0:
            ret.add(i)
            ret.add(int(n/i))
    return sorted(list(ret), reverse=True)





N, M = [int(x) for x in input().split()]

for d in divisor_gen(M):
    if N <= (M / d):
        print(d)
        sys.exit(0)

Solution (Python):
import sys


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

    ans = 1

    for i in range(1, m + 1):
        if i*i > m:
            break
        if m % i == 0 and i * n <= m:
            ans = max(ans, i)

            if (m // i) * n <= m:
                ans = m // i
                break

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

import math

N, M = [int(s) for s in input().strip().split()]

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

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

divisors.sort()
MAX_VAL = int(M/N)
for d in divisors:
    if d > MAX_VAL:
        break
    max_gcd = d

print(max_gcd)

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

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

Solution (Python):
import math
N, M = map(int, input().split())
 
def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1 ):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    return sorted(divisors, reverse=reverse)
 
 
divisors = enum_divisors(M, reverse=True)
divisors = list(filter(lambda x: x <= M//N, divisors))

print(divisors[0])

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

def factorize(x):
    fac = []
    for i in range(1, int(x**0.5)+1):
        if (x % i) == 0:
            fac.append(i)
            fac.append(M//i)
    return sorted(fac)

fac = factorize(M)
fac = filter(lambda x: x <= int(M/N), fac)

print(max(fac))

Solution (Python):
import math
N, M = map(int, input().split())
 
def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1 ):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    return sorted(divisors, reverse=reverse)
 
 
divisors = enum_divisors(M, reverse=True)
divisors = filter(lambda x: x <= M//N, divisors)
 
for cand in divisors:
    if M % cand == 0:
        print(cand)
        exit()

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

k = n
while True:
  if m%k == 0:
    print(k)
    exit()
  k -= 1

Solution (Python):
import math


inn,inm = list(map(int,input().split()))
root = math.floor(math.sqrt(inm))

a = []
for i in range(1,root+1):
  if inm%i == 0:
    a.append(i)
    a.append(inm/i)
    
a.sort()
for i in a:
  if i >= inn:
    print(int(inm/i))
    break

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


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

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

print(ans)

Solution (Python):
import sys
from math import sqrt

n, m = map(int, input().split())
isqrtm = int(sqrt(m))
for revdiv in range(1, 1+isqrtm):
	if m % revdiv == 0:
		div = m // revdiv
		if div <= m//n:
			print(div)
			sys.exit()
for div in range(isqrtm, 0, -1):
	if m % div == 0:
		if div <= m//n:
			print(div)
			sys.exit()

Solution (Python):
import sys

n, m = map(int, input().split())
for div in reversed(range(1, 1+m//n)):
	if m % div == 0:
		print(div)
		sys.exit()

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

Solution (Python):

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


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

d = divisor(M)
g = int(M / N)
d = [x for x in d if x <= g]
print(max(d))

Solution (Python):
N, M = map(int, input().split())
i = 1
ans = 0
while i*i<=M:
    if M%i != 0:
        pass
    else:
        j = M//i
        if i*N <= M:
            ans = max(ans, i)
        if j*N <= M:
            ans = max(ans, j)
    i += 1
print(ans)

Solution (Python):
import math


def main():
    ret = 0
    n, m = map(int, input().split())
    for i in range(1, int(math.sqrt(m)) + 1):
        if m % i == 0 and n * i <= m:
            ret = max([ret, i])
        if m % i == 0:
            j = m //i
            if n * j <= m:
                ret = max([ret, j])
    print(ret)
main()

Solution (Python):

def solve():
    N, M = map(int, input().split())
    for i in range(M//N,0,-1):
        if not M%i: 
            return str(i)

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

Solution (Python):
import math
import bisect


def divisorGenerator(n):
    large_divisors = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            if i*i != n:
                large_divisors.append(n // i)
    for divisor in reversed(large_divisors):
        yield divisor
        
a = input().split()
a = [int(i) for i in a]
lister = list(divisorGenerator(a[1]))
ind = bisect.bisect_left(lister, a[0])
print(a[1] // lister[ind])

Solution (Python):
import math
n, m = map(int, input().split())
root_m = int(math.sqrt(m))
ans = 1
for a in range(1, root_m):
    
    if m % a == 0:
        b = m // a
        if a * n <= m:
            ans = max(ans, a)
        if b * n <= m:
            ans = max(ans, b)
print(ans)

Solution (Python):
import math
n,m = map(int,input().split())
if n==1:
    print(m)
    exit()
mm = int(math.sqrt(m))
a = []
for i in range(1,mm):
    if m%i == 0:
        a.append(i)
        a.append(m//i)
ans = 1
for D in a:
    if m - (n-1)*D >= D:
        ans = max(ans,D)
print(ans)

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

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

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

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

max = m//n
lis = []


for i in range(int(m**0.5)):
    if i != 0 and m%i == 0:
        lis.append(i)
l = len(lis)
for i in range(l):
    if m/lis[i] != lis[i]:
        lis.append(m//lis[i])

lis.sort()
lis = lis[::-1]

if m%n == 0:
    print(max)
else:
    for line in lis:
        if line > max:
            continue
        else:
            if m/line > n:
                print(line)
                break

Solution (Python):
import sys
n,m=map(int,input().split())
if n==1:
    print(m)
    sys.exit()
ans=[]
i=int(1)
while i<=m/i:
    if m%i!=0:
        i+=1
    elif m%i==0:
        j=int(m/i)
        if j>=n:
            ans.append(i)
        if i>=n:
            ans.append(j)
        i+=1
ans.sort()
print(ans[len(ans)-1])

Solution (Python):
import math
N,M= map(int, input().split())
 
answer = 1
list = []
for i in range(1,math.floor(M**(1/2))+1):
    if M % i == 0 and int(M/i) >= N:
        answer = i
        list.append(int(M/i))
 
 
for k in list:
    if M/k >= N:
        answer = k
        break
 
print(answer)

Solution (Python):



def inpl(): return list(map(int, input().split()))


N, M = inpl()

A = 1
ans = 1
while A * A <= M:
    
    if M % A != 0:
        A += 1
        continue
    B = M // A

    
    if A * N <= M:
        ans = max(ans, A)
    
    
    
    
    if B * N <= M:
        ans = max(ans, B)

    A += 1

print(ans)

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

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

divs.sort(reverse=True)
x = m // n

for i in divs:
  if i <= x:
    print(i)
    break

Solution (Python):
n,m=map(int,input().split())
x=1
s=1
while x**2<=m:
  a,b=divmod(m,x)
  if a>=n and b==0:
    s=max(x,s)
  if x>=n and b==0:
    s=max(a,s)
  x+=1

print(s)

Solution (Python):
import math
N, M = [int(i) for i in input().split()]

ans = 1
sosu = True if M % 2 == 1 else False

if M % 2 == 1:
    sqrt = int(math.ceil(math.sqrt(M)))
    for i in range(3, sqrt, 2):
        if M % i == 0:
            sosu = False
            break

if sosu == False:
    for i in range(N, M):
        if M % i == 0:
            ans = M / i
            break


print(int(ans))

Solution (Python):
import numpy as np
N, M = list(map(int, input().split()))
can = []
for i in range(1, int(np.sqrt(M)) + 1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		if N <= i:
			can.append(M // i)

if N == 1:
	print(M)
else:
	print(max(can))

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

def yakusuu(n,m):
    for i in range(int(m/n),0,-1):
        if m % i == 0:
            print(i)
            break

yakusuu(n,m)

Solution (Python):
import math;a = list(map(int,input().split()));b = a[1]//a[0];c = []
for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1]%i==0 and i<=b:
        if a[1] // i <= b:
            c.append(a[1]//i)
        else:
            c.append(i)
c.sort(reverse=True);print(c[0])

Solution (Python):
import math
a = list(map(int,input().split()))
b = a[1]//a[0]
c = []
for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1]%i==0 and i<=b:
        if a[1] // i <= b:
            c.append(a[1]//i)
        else:
            c.append(i)
c.sort(reverse=True)
print(c[0])

Solution (Python):
n,m = map(int,input().split())
g = 1
def fact(k):
  a = []
  for i in range(1,int(k **(0.5))+1):
    if k%i ==0:
      a.append(i)
      a.append(int(k/i))
  b = list(set(a))
  b.sort()
  return b

g = fact(m)
for i in range(len(g)):
  if g[len(g)-i-1] <= m/n:
    print(g[len(g)-i-1])
    break

Solution (Python):
import math
A=[]
N,M=[int(i) for i in input().split()]
sqrt=math.sqrt(M)
for i in range(1,int(sqrt)+1):
    if M%i==0:
        A.append(i)
        A.append(M//i)
ans=[1]
for i in A:
    if i*N<=M:
        ans.append(i)
    else:
        continue
print(max(ans))

Solution (Python):
import sys
import math

N, M = sys.stdin.readline().strip().split()
N = int(N)
M = int(M)
P = M//N 
Q = math.floor(math.sqrt(M)) 




if P <= Q:
  
  for x in range(P, 0, -1):
    
    if M % x == 0:
      print(x)
      break
elif P == M: 
  print(M)
else:
  
  res = 1
  flag = 0
  for x in range(1, N, 1):
    
    if M % x == 0:
      res = x
  for x in range(N, Q+1, 1):
    if M % x == 0:
      print(M//x)
      flag = 1
      break
  if flag == 0:
    print(res)

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

Solution (Python):
import math
n, m = map(int, input().split())
res = 1
max_res = m//n
for i in range(1, math.ceil(math.sqrt(m)) + 1):
  if m % i == 0:
     if i <= max_res:
        res = max(res, i)
     x = m//i
     if x <= max_res:
        res = max(res, x)
print(res)

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

solve()

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())



N,M = inpl()
dl = []
for d in range(1,int(math.sqrt(M))):
    if M%d == 0:
        dl.append(d)
        dl.append(M//d)

dl.sort()
ans = 1
for p in dl:
    if N*p <= M:
        ans = p
    else:
        break

print(ans)

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

if __name__=='__main__':
  solve()

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

if __name__=='__main__':
  solve()

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

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

Solution (Python):
import math


def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))


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


def usage(n):
    fct = factorize(n)
    ret = []
    for div in divisorize(fct):
        ret.append(num(div))
    return ret

def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base ** exponent
    return a


N, M = readmap()
if M == 1:
    print(1)
    quit()
div = usage(M)
ans = 0
for d in div:
    if N * d <= M:
        ans = max(ans, d)
print(ans)

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

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

print(ans)

Solution (Python):


def main():
    n, m = map(int, input().split())
    ans = 1
    for i in range(1, int(m**0.5)+1):
        if m % i == 0:
            if m >= i * n:
                ans = max(ans, i)
            if m >= (m // i) * n:
                ans = max(ans, m // i)
    print(ans)
    
if __name__ == '__main__':
    main()

Solution (Python):
from fractions import math

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

ans = 1
for i in range(1,int(math.sqrt(M))+1):
    if M%i==0: 
        j = M//i
        if j<=M/N and j>ans:
            ans = j
        elif i<=M/N and i>ans:
            ans = i
            
print(ans)

Solution (Python):
import math

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

sqrtM = math.floor(math.sqrt(M))
maxd  = min(sqrtM, M // N)

d1 = max(      d for d in range(1, maxd  + 1) if M % d == 0)
d2 = max((M // d for d in range(N, sqrtM + 1) if M % d == 0), default=1)
print(max(d1, d2))

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

g = m // n
while 1:
    if m % g == 0:
        break
    g -= 1

print(g)

Solution (Python):
def make_divisor(n):
    divisor = [1, n]
    i = 2
    while i * i <= n:
        q, r = divmod(n, i)
        if r == 0:
            divisor.append(i)
            divisor.append(q)
        i += 1
    return sorted(divisor)


n, m = [int(v) for v in input().split()]
divisors = make_divisor(m)

ans = 1
maxv = m // n
for v in divisors:
    if v <= maxv:
        ans = v
    else:
        break

print(ans)

Solution (Python):
def make_divisor(n):
    divisor = set([1, n])
    i = 2
    while i * i <= n:
        q, r = divmod(n, i)
        if r == 0:
            divisor.add(i)
            divisor.add(q)
        i += 1
    return sorted(list(divisor))


n, m = [int(v) for v in input().split()]
divisors = make_divisor(m)

ans = 1
maxv = m // n
for v in divisors:
    if v <= maxv:
        ans = v
    else:
        break

print(ans)

Solution (Python):
import math

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

def divisors(M):
    for d in range(1, math.floor(math.sqrt(M)) + 1):
        if M % d == 0:
            yield d
            yield M // d

d = max(d for d in divisors(M) if d <= M // N)
print(d)

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

if N == 1:
    print(M)
else:
    d = max(d for d in range(1, M // N + 1) if M % d == 0)
    print(d)

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

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

Solution (Python):
import numpy as np
from math import sqrt
ANS = []
N,M = map(int,input().split())
L = np.arange(1,int(sqrt(M))+1,dtype=int)

for i in L :
    if M % i == 0 :
        ANS.append(i)
        ANS.append(M//i)
ANS = sorted(ANS,reverse = True)
for j in ANS :
    if j * N <= M :
        print(j)
        break

Solution (Python):
import math
 
N, M=input().split(" ")
N=int(N)
M=int(M)
 
def get_number(M):
    result=list()
    for i in range(1,int(math.sqrt(M))):
        if M%i==0:
            result.append(i)
            result.append(int(M/i))
    result.sort()
    return(result)
    
def check_number(N,M):
    if N==1:
        return(M)
    number=get_number(M)
    answer=list()
    for i in number:
        if M/i>=N:
            answer.append(i)
            
    return(answer[-1])
    
print(check_number(N,M))

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

ans = 1
for a in range(1, int(math.sqrt(M))):
    b = int(M / a)
    if M%a != 0:
        continue
    if a * N <= M:
        ans = max(ans, a)
    if b * N <= M:
        ans = max(ans, b)

print(ans)

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

Solution (Python):

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

rM = int(math.sqrt(M))

pairs = []
for a in range(1, rM + 1):
    if M % a == 0: pairs.append((a, M // a))



p_max = 0
for m, p in filter(lambda x: x[0] >= N, pairs):
    if p > p_max: p_max = p

for p, m in filter(lambda x: x[1] >= N, pairs):
    if p > p_max: p_max = p

print(p_max)

Solution (Python):
import math

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

if N == 1:
    print(M)
else:
    d = max(d for d in range(1, math.ceil(M / (N - 1))) if M % d == 0)
    print(d)

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

work = M//N

while work > 0:
  if M%work == 0:
    print(work)
    exit(0)
  work -= 1

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def primes(n):
    sq = int(math.sqrt(n)+1)
    ss = 30030
    a = [None] * (ss)
    a[0] = 1
    t = 1
    for i in range(2,ss):
        if not a[i] is None:
            continue
        if t * i > ss:
            break
        t *= i
        for j in range(i*2,ss,i):
            a[j] = 1
    a = [i for i in range(t) if a[i] is None]
    d = collections.defaultdict(int)
    for i in a[1:]:
        while n % i == 0:
            n //= i
            d[i] += 1

    for j in range(1,sq//t+2):
        if j > n:
            break
        for ii in a:
            i = t*j+ii
            while n % i == 0:
                n //= i
                d[i] += 1
    if n > 1:
        d[n] += 1

    return d


def divisions(n):
    d = primes(n)

    r = [1]
    for k, v in d.items():
        for c in r[:]:
            for i in range(1,v+1):
                r.append(c*(k**i))

    return sorted(r)


def main():
    n,m = LI()
    d = divisions(m)
    
    r = 1
    for c in d:
        if c * n > m:
            break
        r = c

    return r


print(main())

Solution (Python):
import sys
import math
N,M=map(int,input().split())
ans=0
a=min(M+1,10**5)
b=M//N
for i in range(1,a):
    if M%i!=0:
        continue
    if i<=b:
        ans=max(ans,i)
    if M//i <=b:
        ans=max(ans,M//i)
print(ans)

Solution (Python):
N, M = map(int, input().split())
if M == 1:
  print(1)
  exit(0)
  
def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
  
fct = factorize(M)


ans = 1
for div in divisorize(fct):
    
    temp = num(div)
    if N * temp <= M:
      ans = max(ans, temp)
      
print(ans)