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())
def dv(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 sorted(divisors)

for i in dv(m):
    if i>=n:
        print(m//i)
        exit()

Solution (Python):

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

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

    divisors.sort()
    return divisors

print([i for i in make_divisors(M) if i <= M / N][-1])

Solution (Python):
import math

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


def get_divisors(n):
    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 d * n <= m:
        print(d)
        break

Solution (Python):
N,M = list(map(int,input().split(' ')))
 
if M % N == 0:
	print(M//N)
	exit()

ans = 1
for i in range(2,100000+1):
	k = M % i
	if k == 0:
		j = M//i
		if i >= N and j >= N:
			ans = max(ans,i,j)
		elif i >= N:
			ans = max(ans,j)
		elif j >= N:
			ans = max(ans,i)
print(ans)

Solution (Python):
import math

n, m = map(int, input().split())
max_i = 1
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i != 0:
        continue
    j = m // i
    if i * n <= m and i > max_i:
        max_i = i
    if j * n <= m and j > max_i:
        max_i = j
print(max_i)

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

N, M = map(int, input().split())
if M % N == 0:
    print(M//N)
else:
    upper = math.ceil(M/N)
    factor = set()
    for i in range(1, int(M**0.5)+1):
        if M % i == 0:
            factor.add(i)
    
    factor1 = set()
    for i in factor:
        factor1.add(M//i)
    factor |= factor1
    
    factor = sorted(list(factor))
    print(factor[bisect.bisect_right(factor, upper)-1])

Solution (Python):
from math import sqrt
N,M=map(int, input().split())
tmp=int(sqrt(M))
ma=1
for i in range(1, tmp+1):
    if not M % i:
        div = M//i
        ma = max(i if i*N <= M else 0, ma, div if div*N <= M else 0)
print(ma)

Solution (Python):

import sys


def solve(N: int, M: int):
    ret = 0
    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
    print(ret)
    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):
N, M = list(map(int, input().split()))

def solution():
    if N==1:
      return M
    
    if M-N < M//N:
        for n in range(N, M+1):
            if M%n==0:
                return M//n
    else:
        for m in range(M//N, 0, -1):
            if M%m==0:
                return m

print(solution())

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

def solution():
    answer = 1
    for i in range(1, int(M**0.5)+1):
        if M%i ==0:
            if M//i>=N:
                answer = max(answer , i)
            if i>=N:
                answer = max(answer, M//i)
    return answer

print(solution())

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

def solution():
    if M-N < M//N:
        for n in range(N, M+1):
            if M%n==0:
                return M//n
    else:
        for m in range(M//N, 0, -1):
            if M%m==0:
                return m

print(solution())

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

def solution():
    if M-N < M//N:
        for n in range(N, M+1):
            if M%n==0:
                return M//n
    else:
        for m in range(M//N, 0, -1):
            if M%m==0:
                return m

print(solution())

Solution (Python):
import math
def soinsu(N):
    sqr = int(math.sqrt(N))
    lis = []
    for i in range(2,sqr+2):
        while N % i == 0:
            lis.append(i)
            N = N // i
    if not N == 1:
        lis.append(N)
    return lis

def yakusu(N):
    sqr = int(math.sqrt(N))
    lis = []
    for i in range(1,sqr+2):
        if N % i == 0:
            lis.append(i)
            lis.append(N//i)
    return lis

mod = 1000000007
def modpow(a,b,MOD=mod):
    res = 1
    while b > 0:
        if (b & 1) == 1:
            res = (res*a) % MOD
        a = (a*a) % MOD
        b = b >> 1
    return res
fact = []
def ncrinit(MOD=mod):
    fact.append(1)
    for i in range(1,110005):
        fact.append((fact[i-1]*i)%MOD)

def calcnCr(n,r,MOD=mod):
    up = fact[n]
    down = modpow((fact[n-r]*fact[r])%mod,mod-2,mod)
    return (up*down)%mod

def compres(lis):
    li = []
    se = set(lis)
    for i in se:
        li.append(lis.count(i))
    return li
res = 1
N,M = list(map(int,input().split()))
co = yakusu(M)
co.sort()
for i in co:
    if M // i >= N:
        res = max(res,i)
print(res)

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

	total = m//n
	answer = 1
	for i in range(1, total+1):
		if i * i > m:
			break

		if m % i == 0:
			answer = max(i, answer)
			if i >= n:
				answer = max(m//i, answer)

	print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
x = 0
m = 0
for i in range(10**5):
    if i**2 < M <= (i+1)**2:
        m = i+1
        break
if m >N:
    for i in range(N, m):
        if M % i == 0:
            x = M // i
            break
if x == 0:
    for i in reversed(range(1, M //N +1)):
        if M % i == 0:
            x = i
            break
print(x)

Solution (Python):
n,m=map(int,input().split())
for i1 in range(1,int(m**0.5)+1):
    if m%i1==0:
        i2=m//i1
        if i1>=n:
            ans=i2
            break
        elif i2==n:
            ans=i1
            break
        elif i2<n:
            ans=pre_i1
            break
        pre_i1=i1
else:
    ans=pre_i1
print(ans)

Solution (Python):
n,m=map(int,input().split())
f1=[]
f2=[]
for i1 in range(1,int(m**0.5)+1):
    if m%i1==0:
        i2=m//i1
        if i1>=n:
            ans=i2
            break
        elif i2==n:
            ans=i1
            break
        elif i2<n:
            ans=f1[-1]
            break
        f1+=[i1]
        f2+=[i2]
else:
    ans=f1[-1]
print(ans)

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

Solution (Python):
n,m = map(int,input().split())
 
def solve(x):
    if m % x == 0:
        return True
    else:
        return False
for i in range(m//n,-1,-1):
    if solve(i):
        print(i)
        exit()
    else:
        continue

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

n = 0
for i in range(1, int(math.sqrt(M))+1):
    if M < i * N:
        break

    if M % i == 0:
        n = max(i, n)
        if i >= N:
            n = max(M//i, n)

print(n)

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

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


ans=0

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

print(ans)

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

    for g in range(M//N, 0, -1):
        if M % g == 0:
            print(g)
            return

if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
from functools import partial, reduce
from operator import mul
prod = partial(reduce, mul)
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 II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, M = LI()
    for i in range(N, int(M ** 0.5) + 1):
        if M % i == 0:
            return M // i
    for i in range(min(N - 1, int(M ** 0.5), M // N), 0, -1):
        if M % i == 0:
            return i
    return 1

print(main())

Solution (Python):
import math
N, M = map(int, input().split())
sqrtM = round(math.sqrt(M))+1

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

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

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

print(str(ans))

Solution (Python):
def d_partition(N, M):
    def divisor_list(n):
        
        ret = []
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.append(k)
                if k != n // k:
                    ret.append(n // k)
        return sorted(ret)
    
    return max([d for d in divisor_list(M) if d <= M // N]) if N >= 2 else M

N, M = [int(i) for i in input().split()]
print(d_partition(N, M))

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

if M//N < 10**7:
    for i in range(M//N,0,-1):
        if M % i ==0:
            break
    print(i)
else:
    for i in range(N,int(M**0.5)):
        if M % i == 0:
            break
    else:
        i = M
    print(M//i)

Solution (Python):
def gen_divisor(n):
    ps = []
    for i in range(1, int(1 + n ** 0.5)):
        if n % i == 0:
            yield i
            ps.append(n // i)
    if n // ps[-1] == ps[-1]:
        del ps[-1]
    for p in reversed(ps):
        yield p

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

def solve():
    for di in gen_divisor(M):
        if di >= N:
            ans = M // di
            return ans

print(solve())

Solution (Python):

def factorize(n):
    nn = n
    lst = []
    for i in range(2, int(1 + n ** 0.5)):
        k = 0
        while nn % i == 0:
            k += 1
            nn = nn // i
        if k > 0:
            lst.append([i, k])
    if nn != 1:
        lst.append([nn, 1])
    return lst

def gen_divisor(m):
    
    yield 1
    factorized = factorize(m)
    length = len(factorized)
    if length == 0:
        return
    factor_nexps = [0] * length
    while True:
        
        factor_nexps[0] += 1
        for idx in range(length - 1):
            if factor_nexps[idx] > factorized[idx][1]:
                factor_nexps[idx] = 0
                factor_nexps[idx+1] += 1
        if factor_nexps[-1] > factorized[-1][1]:
            return
        divisor = 1
        for i, tup in enumerate(factorized):
            divisor *= tup[0] ** factor_nexps[i]
        yield divisor

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

def solve():
    divisors = sorted([di for di in gen_divisor(M) if di >= N])
    ans = M // divisors[0]
    return ans

print(solve())

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

ans = 1
for i in range(1, int(m**(0.5))):
    if m%i==0:
        d = m//i
        if d >= n:
            ans = i
            if i>=n:
                ans = d
                break
        else:
            break
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())
l=make_divisors(m)
for i in l:
    if n<=i:
        ans=m//i
        break
print(ans)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)


def A():
    return


def B():
    return


def C():
    n = I()
    a = LIR(n)
    if n == 1:
        print(*a[0])
        quit()
    for cy in range(101):
        for cx in range(101):
            for i in range(n):
                x,y,h = a[i]
                if h > 0:
                    H = abs(x-cx)+abs(y-cy)+h
                    break
            f = True
            for i in range(n):
                x,y,h = a[i]
                if max(H-abs(x-cx)-abs(y-cy),0) != h:
                    f = False
                    break
            if f:
                print(cx,cy,H)
                quit()

def D():
    def factorize(n):
        if n == 1:
            return [1]
        if n<4:
            return [1,n]
        l = [1,n]
        m = n
        z = 2
        while z**2 <= n:
            if m%z == 0:
                l.append(z)
                if m//z != z:
                    l.append(m//z)
            z += 1
        l = list(set(l))
        l.sort()
        return l

    n,m = LI()
    l = factorize(m)
    for i in l[::-1]:
        if n*i <= m:
            print(i)
            quit()


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == "__main__":
    D()

Solution (Python):


n,m=map(int,raw_input().split())
for i in xrange(m/n,0,-1):
 if m%i==0:
  print i
  break

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), long(input_raw[1])]

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




if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
def getDivisor(inte):
    Ans1 = [1]
    Ans2 = [inte]
    for i in range(2,int(inte**(0.5))):
        if inte % i == 0:
            Ans1.append(i)
            Ans2.append(int(inte/i))
    if inte % inte**(0.5) == 0:
        Ans1.append(int(int(inte**(0.5))))
    Ans = Ans1 + Ans2[::-1]
    return Ans

limit = int(m/n)
for i in reversed(getDivisor(m)):
    if i <= limit:
        print(i)
        break

Solution (Python):
import math
n, m = [int(item) for item in input().split()]

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

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

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

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

if M % N == 0:
    ans = M // N
else:
    for i in range(1, M // N + 1):
        if M % i == 0:
            ans = i
            if M // i > i and M // i <= M // N:
                ans = M // i
                break
        
print(ans)

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

bdr = M//N
ans = 1

for i in range(1,int(M**0.5+1)):
    if M%i==0:
        yakusu = M//i
        if yakusu<=bdr:
            ans = yakusu
            break
        elif i <= bdr:
            ans = i
print(ans)

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

Solution (Python):
print((lambda a:max([i for j in [[i,a[1]//i] for i in range(1,int(a[1]**0.5)+1) if a[1]%i==0] for i in j if a[1]//i >= a[0]]))(list(map(int,input().split()))))

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

Solution (Python):
n,m=list(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, input().split())
c=[]
if n==1:
    print(m)
else:
    for i in range(1,math.floor(m**(1/2))+1):
        if m%i==0:
            c.append(i)
            c.append(m//i)
    c=sorted(c, reverse=True)
    for ci in c:
        if ci*n<=m:
            print(ci)
            break

Solution (Python):
n,m = map(int, input().split())
l = []
for i in range(1,int(m**0.5)+1):
  if m%i == 0:
    l.append(i)
    l.append(m//i)
r = [x for x in l if x <= m//n]
print(max(r))

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

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

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)
d.sort()
for i in range(1,len(d)+1):
	if d[-i] <= M//N:
		print(d[-i])
		exit()

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

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

l=make_divisors(m)

for i in l:
    if i*n<=m:
        print(i)
        import sys
        sys.exit()

Solution (Python):
import math

n,m=map(int,input().split())
if n==1:
        print(m)
else:
        l=[]
        for i in range(1,math.floor(m**0.5)+1):
           if m%i==0 and i<=m//n:
                l.append(i)
                if m//i<=m//n:
                        l.append(m//i)
        l.sort()
        print(l[-1])

Solution (Python):

import sys
import math


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


def solve(N: int, M: int):
    
    yakusu = [i for i in range(1, int(math.sqrt(M))+1) if M % i == 0]
    yakusu.extend([M/y for y in yakusu[::-1]])

    ans = 0
    for y in yakusu:
        rest = M / y
        if rest >= N:
            
            ans = y

    print(int(ans))
    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):

import sys
import math


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


def solve(N: int, M: int):
    
    yakusu = [i for i in range(1, int(math.sqrt(M))+1) if M % i == 0]
    yakusu.extend([M/y for y in yakusu[::-1]])

    ans = 0
    for y in yakusu:
        rest = M / y
        if rest >= N:
            
            ans = y

    print(int(ans))
    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):
import math
N, M = map(int, input().split())
mm = math.floor(math.sqrt(M)) + 1
ans = 0
for a in range(mm, 0, -1):
  if M % a == 0:
    b = M // a
    if a >= N:
      ans = max(ans, b)
    elif b >= N:
      ans = max(ans, a)
print(ans)

Solution (Python):
import math
N, M = map(int, input().split())
mm = math.floor(math.sqrt(M)) + 1
ans = 0
for a in range(mm, 0, -1):
  if M % a == 0:
    b = M // a
    if a >= N:
      ans = max(ans, b)
    elif b >= N:
      ans = max(ans, a)
print(ans)

Solution (Python):














N, M = map(int, input().split())
M_ROOT = int(M ** 0.5)
k = M
for i in range(1, M_ROOT + 1):
    if M % i == 0:
        if i >= N:
            print(M // i)
            exit()
        d = M // i
        if d < k and d >= N:
            k = d
print(M // k)

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











lst = []
temp = int(math.sqrt(M) + 1)
for x in range(1 , temp):
    if (M % x == 0):
        lst.append(x)
        lst.append(int(M // x))
ans = 1
for d in lst:
    if M >=  (N * d):
        ans = max(ans , d)
print(ans)

Solution (Python):
N,M = (int(x) for x in input().split())

max_i = 0
for i in range(1, int(M**0.5)+1):
    if M%i == 0:
        if M//i >= N:
            max_i = max(max_i, i)
        if i >= N:
            max_i = max(max_i, M//i)
print(max_i)

Solution (Python):
import math


def divisors(n: int) -> list:
    s = int(math.sqrt(n))
    ret = []
    if s * s == n:
        ret.append(s)
    else:
        s += 1

    for i in range(1, s):
        if n % i == 0:
            ret.append(i)
            ret.append(n // i)

    return sorted(ret, reverse=True)


def partition(N: int, M: int) -> int:
    for gcd in divisors(M):
        if gcd * N > M:
            continue
        return gcd
    return -1


if __name__ == "__main__":
    N, M = map(int, input().split())
    ans = partition(N, M)
    print(ans)

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,M=rl()

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

    import bisect
    l_i = bisect.bisect_right(l,x)-1
    print(l[l_i])

Solution (Python):
n, m = map(int, input().split())
if m % n == 0:
    print(m//n)
    exit()
ret = 1
for d in reversed(range(2,100001)):
    while(m % d == 0):
        if m//d >= n:
            m //= d
            ret *= d
        else:
            break
print(ret)

Solution (Python):
n, m = map(int, input().split())
if m % n == 0:
    print(m//n)
    exit()
ret = 1
for d in reversed(range(2,100001)):
    while(m % d == 0):
        if m//d >= n:
            m //= d
            ret *= d
        else:
            break
print(ret)

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,M=rl()

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

Solution (Python):
N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    else:
      s=N
      while s!=1:
        if M%s==0:
          ans=s
          break
        s-=1
    print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from bisect import bisect_right
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

D=make_divisors(m)
print(D[bisect_right(D,m/n)-1])

Solution (Python):


import bisect

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

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

y.sort()
print(M // y[bisect.bisect_left(y, N)])

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

ans = 0
for x in range(1, int(M ** 0.5) + 1):
    if M % x != 0:
        continue
    else:
        x1, x2 = x, M // x
        if M // x1 >= N:
            ans = max(ans, x1)
        if M // x2 >= N:
            ans = max(ans, x2)

print(ans)

Solution (Python):
import bisect
import math

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

divisors=[]
for i in range(1,math.floor(math.sqrt(M))+1):
    if M%i==0:
        divisors.append(i)
        divisors.append(M//i)
        
divisors.sort()
print(M//divisors[bisect.bisect_left(divisors,N)])

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

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

div = divisor(M)

for i in range(len(div)):
    if div[i] <= M // N:
        res = div[i]
            
print(res)

Solution (Python):
def solve(string):
    n, m = map(int, string.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])
    return str(max([i for i in d if m // i >= n]))


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

Solution (Python):
def divisionize(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 = sorted(divisors) 
    return divisors
n,m = map(int, input().split())
dm = divisionize(m)
print(max([d for d,d_ in zip(dm,dm[::-1]) if d_>=n]))

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

Solution (Python):
from collections import Counter
n, m = map(int, input().split())

def factorize(m):
    c = Counter()
    t = 2
    while t**2 <= m:
        if m % t:
            t += 1
            continue
        while not m%t:
            c[t] += 1
            m //= t
    if m > 1:
        c[m] += 1
    return c
yakusu = [1]
for key, value in factorize(m).items():
    next_yakusu = []
    for i in range(value+1):
        for j in yakusu:
            next_yakusu.append(j*key**i)
    yakusu = next_yakusu

ans = 1
for i in yakusu:
    if n <= m//i:
        ans = max(ans, i)
print(ans)

Solution (Python):
import sys, os, random, math

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

def rdi():
        return [ int(x) for x in rd().split() ]

def solve(N, M):
        L = math.sqrt(M) + 0.5
        i = N
        while i <= L:
                if M % i == 0:
                        return M / i
                i = i + 1
        i = N-1
        while i >= 1:
                if M % i == 0 and M / i >= N:
                        return i
                i = i - 1
        assert 0

N, M = rdi()
print solve(N, M)

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


ans = min(filter(lambda e:e >= N, divisor))

ans = M // ans
print(ans)

Solution (Python):
import math

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

sup = math.ceil(m**0.5)

ans = 1

for i in range(1,sup+1):
    if m%i==0:
        j = m//i
        if j>=n and i>ans:
            ans = i
        if i>=n and j>ans:
            ans = j

print(ans)

Solution (Python):

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass 
n, m = map(int,input().split())
divs = list(reversed(sorted(divisor(m))))
for i in divs:
    if m//i >= n:
        print(i)
        break

Solution (Python):
import math

n, m = [int(i) for i in input().split(" ")]
pq_max = 0

for p in range(1, int(math.sqrt(m)) + 1):
    if m % p == 0:
        q = m // p
        
        if p >= n and q > pq_max:
            pq_max = q
            
        if q >= n and p > pq_max:
            pq_max = p
        
print(pq_max)

Solution (Python):
import math

N,M = map(int,input().split())
A = []
n = 0
if N == 1:
    print(M)
else:
    ans = 1
    for i in range(1, int(math.sqrt(M))+1):
        if (M % i == 0):
            if i <= M//N:
                A.append(i)
            if M/i <= M//N:
                A.append(int(M/i))
    A.sort()
    print(A[-1])

Solution (Python):


import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline












def divisors(n, m):
	for i in range(m//n, 0, -1):
		if m % i == 0:
			return(i)


N, M = map(int, input().rstrip().split())
print(divisors(N, M))

Solution (Python):
import math
n,m = map(int, input().split())
factors = []
comp = m//n
for i in range(int(math.sqrt(m)),0,-1):
    if(m%i==0):
        factors.insert(0,i)
        factors.append(m//i)
for item in factors[::-1]:
    if (item <= comp):
        print(item)
        exit(0)

Solution (Python):
import math

def main():
    N, M = list(map(int, input().split(' ')))
    s = min(math.ceil(math.sqrt(M)), M//N)
    ret = []
    while s > 0:
        if M%s == 0:
            a = M//s
            ret.append(a)
            ret.append(s)
        s -= 1
    print(max([s for s in ret if s <= M//N]))



if __name__ == '__main__':
    main()

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

kmax = M // N
sqrt = int(M**0.5)

k = 0
for i in range(sqrt)[::-1]:
    k1, k2 = i+1, M//(i+1)
    if M % k2 == 0 and k2 <= kmax:
        k = max(k, k2)
    elif M % k1 == 0 and k1 <= kmax:
        k = max(k, k1)

print(k)