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



Sample input:
3 14


Sample output:
2

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
for i in range (n, (m + 3) // 2):
  if m % i == 0:
    print(m // i)
    exit()
print(1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def solve():
	for i in range(n,m//2+1):
		if not m%i:
			return m/i
	return 1

print(int(solve()))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
for i in range(M,0,-1):
    if(M%i==0):
        if(i*N<=M):
            print(i)
            break;

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
arr=[]
for i in reversed(range(1,M+1)):
  if M%i==0:        
        if(i*N<=M):
            print(i)
            break

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
arr=[]
for i in range(1,M+1):
  if M%i==0:
        arr.append(i)
arrlen=len(arr)

#for j in range(0,arrlen):    
    #print("test",arr[j])

for j in reversed(range(0,arrlen)):    
    if(arr[j]*N<=M):
        print(arr[j])
        break

Submission status: Time Limit Exceeded

Solution code:
def calc():
 N,M = map(int,input().split())
 gcd = M // N
 while gcd > 0:
  tmp = M - gcd
  if tmp % gcd == 0:
   break
  gcd = gcd - 1
 return(gcd)
print(calc())

Submission status: Time Limit Exceeded

Solution code:
def calc():
 N,M = map(int,input().split())
 gcd = M // N
 gcd_tmp = 0
 while gcd > 0:
  tmp = M - gcd
  if tmp % gcd == 0:
   break
  gcd = gcd - 1
 return(gcd)
print(calc())

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
gcd = M // N
gcd_tmp = 0
while gcd > 0:
 if M % gcd == 0:
  tmp = M - gcd
  if tmp % gcd == 0:
   gcd_tmp = gcd
   break
 gcd = gcd - 1
print(gcd_tmp)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math


def get_prime(num):
    upper = int(math.sqrt(num)) + 1
    checks = [True for _ in range(upper + 1)]
    primes = []
    for i in range(2, len(checks)):
        if checks[i]:
            primes.append(i)
            for j in range(i, len(checks), i):
                checks[j] = False
    return primes


n, m = map(int, input().split(" "))
answer = 1
# for p in get_prime(m):
for p in range(1, m // n + 1):
    if m % p == 0:
        answer = p
print(answer)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
gcd = M // N
gcd_tmp = 0
while gcd > 0:
 tmp = M - gcd
 if tmp % gcd == 0:
  gcd_tmp = gcd
  break
 gcd = gcd - 1
print(gcd_tmp)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
gcd = 1
gcd_tmp = 0
while gcd * N <= M:
 tmp = M - gcd
 if tmp % gcd == 0:
  gcd_tmp = gcd
 gcd = gcd + 1
print(gcd_tmp)

Submission status: Time Limit Exceeded

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

g = int(M / N)

for i in reversed(range(g+1)):
    if (M - i * N) % i== 0:
        print (i)
        exit()

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
cand = M // N

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

Submission status: Time Limit Exceeded

Solution code:
def canPartition(M, N, ret_cand):
    if ((M - (ret_cand * N)) % ret_cand) == 0:
        return True
    return False

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

while cand > 0:
    if canPartition(M, N, cand):
        print(cand)
        exit()
    cand -= 1

Submission status: Time Limit Exceeded

Solution code:
n,m=(int(i) for i in input().split())
p = int(m/n)
while p>1:
    if m%p==0:
        break
    p-=1
print(p)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
while True:
  if m%n == 0:
    print(m//n)
    break
  n += 1

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
while n <= m:
  if m%n == 0:
    print(m//n)
    break
  n += 1

Submission status: Time Limit Exceeded

Solution code:
n,m=(int(i) for i in input().split())
p = int(m/n)
while p>1:
    if m%p==0 and m>=n*p:
        break
    p-=1
print(p)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

Submission status: Time Limit Exceeded

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from string import *
from itertools import *
from copy import *

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

Submission status: Time Limit Exceeded

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

k=1
while M / k >= N:
    if M % k == 0:
        t = k
    k += 1

print(t)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

max = m//n

if m%n == 0:
    print(max)
else:
    for i in range(max):
        if m%(max-i) == 0:
            print(max-i)
            break

Submission status: Time Limit Exceeded

Solution code:
list = input().split()
N = int(list[0])
M = int(list[1])

k = int(M / N)

m = 0

while m <= k:
    if (M - (k - m)*N) % (k - m) == 0:
        break
    else:
        m = m + 1

print(k-m)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
ans=0
k=0
i=m//n
while k==0:
    if m%i==0:
        ans=i
        k=1
    i-=1
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
n,m=map(int,input().split())
ans=0

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

for i in range(1,(m//n)+1):
    if m%i==0:
        ans=i
        
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
ans=0
for i in range(1,(m//n)+1):
    if m%i==0:
        ans=i
        
print(ans)

Submission status: Time Limit Exceeded

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

k=1
while M / k >= N:
    if M % k == 0:
        t = k
        k += 1
    else:
        k += 1

print(t)

Submission status: Time Limit Exceeded

Solution code:
def input_int_list():
    return list(map(int, input().split()))
  
N,M = input_int_list()
 
D = M/N
res = 0
 
for d in reversed(range(int(D))):
  d += 1
  r = d*(N-1)
  r1 = M - r
  if r1 > res and (M % d) == 0 and (r1 % d)==0:
    res = d
    break
  
    
print(res)

Submission status: Time Limit Exceeded

Solution code:
def input_int_list():
    return list(map(int, input().split()))
  
N,M = input_int_list()
 
D = M/N
i = 1
res = 0
 
for d in range(int(D)):
  r = i*(N-1)
  r1 = M - r
  if r1 > res and (M % i) == 0 and (r1 % i)==0:
    res = i
  i+=1
    
print(res)

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int, input().split()))
can = []
for i in range(1, M // 2 + 1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		else:
			break

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

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int, input().split()))
can = []
for i in range(1, M+1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		else:
			break

print(max(can))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
g = 1
for i in range(1,int(1+m/n)):
  if m%i == 0:
    if int(m/i) >= n:
      g = i
    else:
      break
      
print(g)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in range(2,int(math.sqrt(m)+1)):
    if m % i == 0:
        flag = True
        break

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

a = int(m/n)

li = []
for i in range(1,a+1):
    if m % i == 0:
        li.append(i)
print(li[len(li)-1])

Submission status: Time Limit Exceeded

Solution code:
N,M=[int(i) for i in input().split()]
a=M//N
A=[]
for i in range(1,a+1):
    if M%i==0:
        A.append(i)
    else:
        continue
print(max(A))

Submission status: Time Limit Exceeded

Solution code:
import sys

N, M = sys.stdin.readline().strip().split()
N = int(N)
M = int(M)
L = M//N

for x in range(L, 0, -1):
  if M % x == 0:
    print(x)
    break

Submission status: Time Limit Exceeded

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

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

print(int(ans))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

k = int(m/n)
ans = 1
for i in range(k):
    if m % (k-i) == 0:
        break
print(k-i)

Submission status: Time Limit Exceeded

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

k = int(m/n)
ans = 1
for i in range(k):
    if m % (k-i) == 0:
        ans = k-i
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
#n個に分けてあげなきゃいけない
#合計はmにならなきゃいけない。素数のときは1確定？
#10 123のとき12から試す。余りが０だといいけどこの場合は３余るこのときあまりは１〜１１
#結局この問題はmを素因数分解して２数の積で表現したときにn以上の数で表せるかって話なわけよ、
#約数っていうのはその数の二乗を境にペアになっているから小さい方で割れれば商が相方になっているというわけ
#できる限り平均的に分けてあげたほうがいいってことはわかる。
#大きい方から下って見つかって瞬間終わりにするほうが賢いかも
#候補のうち最大の数字は
k = int(m/n)
ans = 1
for i in range(k):
    if m % (k-i) == 0:
        if m / (k-i) >= n:
            ans = k-i
            break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
#n個に分けてあげなきゃいけない
#合計はmにならなきゃいけない。素数のときは1確定？
#10 123のとき12から試す。余りが０だといいけどこの場合は３余るこのときあまりは１〜１１
#結局この問題はmを素因数分解して２数の積で表現したときにn以上の数で表せるかって話なわけよ、
#約数っていうのはその数の二乗を境にペアになっているから小さい方で割れれば商が相方になっているというわけ
#できる限り平均的に分けてあげたほうがいいってことはわかる。
#大きい方から下って見つかって瞬間終わりにするほうが賢いかも
#候補のうち最大の数字は
i = int(m/n)
ans = 1
while i >= 1:
    if m % i == 0:
        if m / i >= n:
            ans = i
            break
    i = i-1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
nm=[int(i) for i in input().split()]

for i in range(1,-((nm[1]+1)//-nm[0]))[::-1]:
	if nm[1]%i==0:
		print(i)
		break

Submission status: Time Limit Exceeded

Solution code:
nm=[int(i) for i in input().split()]

for i in range(1,-((nm[1]+1)//-nm[0]))[::-1]:
	if nm[1]%i==0:
		if i*nm[0]<=nm[1]:
			print(i)
			break

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
#n個に分けてあげなきゃいけない
#できる限り平均的に分けてあげたほうがいいってことはわかる。
#大きい方から下って見つかって瞬間終わりにするほうが賢いかも
#候補のうち最大の数字は
i = int(m/n)
ans = 1
while i>=1:
    if m % i == 0 and m / i >= n:
        ans = i
        break
    i = i-1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
#n個に分けてあげなきゃいけない
#できる限り平均的に分けてあげたほうがいいってことはわかる。
#大きい方から下って見つかって瞬間終わりにするほうが賢いかも
#候補のうち最大の数字は
i = int(m/n)
ans = 1
while n*i <= m:
    if m % i == 0 and m / i >= n:
        ans = i
        break
    i -= 1
print(ans)

Submission status: Time Limit Exceeded

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

#できる限り平均的に分けてあげたほうがいいってことはわかる。
i = 1
ans = 1
while n*i <= m:
    if m % i == 0 and m / i >= n:
        ans = i
    i += 1
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(m // n, -1, -1):
    #print(i)
    if m % i == 0 and m // i >= n:
        ans = i
        break

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
for i in range(1, math.ceil(M / N) + 1):
    if M % i == 0 and M / i >= N:
        ans = i

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M=map(int,input().split())
x=M//N
while x>0:
    if M%x==0 and M/x>=N:
        print(x)
        break
    x-=1

Submission status: Time Limit Exceeded

Solution code:
N, M=map(int,input().split())
x=M//N
for i in range(x,0,-1):
    if M%i==0 and M/i>=N:
        print(i)
        break

Submission status: Time Limit Exceeded

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

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

print(g)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = input().split()

div = int((int(M) + 0.1) // int(N) + 0.1)

hoge = div
for i in range(div):
    if int(M) % hoge == 0:
        break
    else:
        hoge -= 1

print(str(hoge))

Submission status: Time Limit Exceeded

Solution code:
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

N,M = map(int,input().split())
L = sorted(make_divisor_list(M),reverse = True)
for j in L :
    if j <= M//N :
        if (M - j*(N-1)) % j == 0 :
            print(j)
            break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

work = M//N

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

Submission status: Time Limit Exceeded

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

def make_divisor_list(num):
	if num < 1:
		return []
	elif num == 1:
		return [1]
	else:
		divisor_list = []
		divisor_list.append(1)
		for i in range(2, num // 2 + 1):
			if num % i == 0:
				divisor_list.append(i)
		divisor_list.append(num)
		return divisor_list
		
list = make_divisor_list(M)
list = reversed(list)

for i in list:
	if M % i == 0 and M / i >= N:
		print(i)
		break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
n, m = list(map(int, input().split()))
i = 1
lst = []
while i <= sqrt(m):
    if m % i == 0:
        j = m // i
        if i >= n:
            lst.append(i)
        if j >= n:
            lst.append(j)
        i += 1
print(m//min(lst))

Submission status: Time Limit Exceeded

Solution code:
n, m = list(map(int, input().split()))
lst = range(n, (m//2)+1)
for i in lst:
    if m % i == 0:
        print(m // i)
        break
else:
    print(1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = list(map(int,input().split()))
ans = 1
if n[0] == 1:
	ans = n[1]
else:	
	i=1
	flag=0
	while i*i<=n[1]:
		if n[1] % i ==0:
			flag = 1
		i += 1
	if flag == 1:
		i=1
		while (i <= n[1]//n[0]):
			if (n[1]%i==0):
				ans = i
			i+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = list(map(int,input().split()))
ans = 0
if n[0] == 1:
	ans = n[1]
else:	
	i=1
	while i*n[0] <= n[1]:
		if n[1]%i ==0:
			ans = i
		i+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = list(map(int,input().split()))
ans = 0
if n[0] == 1:
	ans = n[1]
else:	
	i=1
	while i <= n[1]//n[0]:
		if n[1]%i ==0:
			ans = i
		i+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = list(map(int,input().split()))
ans = 0
if n[0] == 1:
	ans = n[1]
else:	
	for i in range(1,(n[1]+1)//2):
		if n[1]%i == 0 and i*n[0] <= n[1]:
			ans = i
		
	

print(ans)

Submission status: Time Limit Exceeded

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

if N == 1:
    print(M)

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

Submission status: Time Limit Exceeded

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

def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

if m%n==0:
    print(m//n)

elif is_prime(m):
    print(1)

else:
    index=m//n
    while index >0:
        if m%index==0:
            print(index)
            break
        index-=1

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
if m%n==0:
    print(m//n)
else:
    index=m//n
    while index >0:
        if m%index==0:
            print(index)
            break
        index-=1

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
if m%n==0:
    print(m//n)
elif n > m//2:
    index = m
    while index >0:
        if m%index==0:
            if m//index > n-1:
                print(index)
                break
        index+=1
else:
    index=1
    while index <m+1:
        if m%index==0:
            if index > n-1:
                print(m//index)
                break
        index+=1

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
if m%n==0:
    print(m//n)
else:
    index=1
    while index <m+1:
        if m%index==0:
            if index > n-1:
                print(m//index)
                break
        index+=1

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
if m%n==0:
    print(m//n)
else:
    index=m
    while index >0:
        if m%index==0:
            if m//index > n-1:
                print(index)
                break
        index-=1

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int, input().split())
a=1
b=0
while b==0:
    for i in range(m,1,-1):
        if m%i==0 and m>=(i*n):
            a*=i
            m=m//i
            break
    else:b=1
print(a)

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(_) for _ in input().split()]

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

result = 1

a = 1

while True:
    b = M - (a * (N - 1))
    if b < 1:
        break
    # print(a, b)
    x = gcd(a, b)
    result = max(result, x)
    a += 1

print(result)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
l = M//N
if M+1-N < l:
    for i in range(N,M+1):
        if M%i == 0:
            print(M//i)
            break
else:
    for i in range(l,-1,-1):
        if M % i == 0:
            print(i)
            break

Submission status: Time Limit Exceeded

Solution code:
iN,iM = [int(_) for _ in input().split()]
iD = iM // iN
if iM % iN == 0:
    print(iD)
else:
    for i in range( iD , 0,-1):
        if iM % i == 0:
            print(i)
            exit()

Submission status: Time Limit Exceeded

Solution code:
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
for i in range(num+1)[::-1]:
    if M % i == 0:
        print(i)
        break

Submission status: Time Limit Exceeded

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

max_ans = M // N

tmpM = M
insu = {}
tmp = 2
while tmpM != 1:
    if tmpM % tmp == 0:
        insu[tmp] = insu.get(tmp, 0) + 1
        tmpM = tmpM // tmp
        continue
    else:
        if tmp == 2:
            tmp = 3
        elif tmpM // tmp == 1:
            tmp = tmpM
        else:
            tmp += 2

ins = set()
ins.add(1)
for k, v in insu.items():
    tmp = [k ** i for i in range(v + 1)]
    for s in list(ins):
        for t in tmp:
            ans = t * s
            if ans > max_ans:
                break
            ins.add(ans)
# print(ins)
print(max(ins))

Submission status: Time Limit Exceeded

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

output = 1
for i in range(M//N, 0, -1):
    if M % i == 0 and output < i:
        output = i
print(output)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

max_ans = M // N
if M % 2 == 1:
    x = 2
else:
    x = 1

for a in reversed(range(1, max_ans + 1, x)):
    mod = M % a
    if mod == 0:
        print(a)
        exit()

Submission status: Time Limit Exceeded

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

max_ans = M // N

for a in reversed(range(1, max_ans + 1)):
    mod = M % a
    if mod == 0:
        print(a)
        exit()

Submission status: Time Limit Exceeded

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

msq = int(math.sqrt(M))
if N == 1:
    ans = M
else:
    for i in range(M, 0, -1):
        if M%i == 0:
            tmp = M - i*(N-1)
            if tmp > 0 and tmp%i == 0:
                ans = i
                break

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

if is_prime(M) == True:
    if M/N == 1:
        print(N)
    else:
        print(1)
else:
    for i in range(int(M/N),0,-1):
        if M % i ==0:
            print(i)
            break

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
def f():
    for i in range(N,M+1):
        if M%i == 0:
            return M//i
print(f())

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
k=m//n
s=[]
for i in range(1,int(m**2)+2):
    if m%i==0 and i<=k:
        s.append(i)
        if m/i<=k:
           s.append(m/i)
print(int(max(s)))

Submission status: Time Limit Exceeded

Solution code:
N,T  = list(map(int,input().split()))
d = int(T / N)
if T % N == 0:
    print (d)


else:
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break

Submission status: Time Limit Exceeded

Solution code:
N,T  = map(int,input().split())
d = int(T / N)
if T % N == 0:
    print (d)


else:
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,T  = map(int,input().split())
if T % N == 0:
    print (int(T / N))


else:
    d = int(T / N)
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

Solution code:
N , M = map(int, input().split())
yakusuu = []

for i in range(int(M/N),0,-1):
    if M % i ==0:
        yakusuu.append(i)
        break
print (yakusuu[0])

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=m//n
if m//n<=int(m**0.5):
    for i in range(m//n,0,-1):
        if m%i==0:
            print(i)
            break
else:
    for i in range(m//n,0,-1):
        if m%i==0:
            print(i)
            break

Submission status: Time Limit Exceeded

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

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

amax = M // N
L = make_divisor_list(M)
L = [i for i in L if i <= amax]

ans = L[-1]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int,input().split()))
 
d = int(M/N)

def solve():
    # ans = 1
    # for i in range(M//N+1, 0, -1):
    #     if M % i == 0:
    #         if (M // i) >= N:
    #             print(i)
    #             break
    for i in range(d):
    	if M%(d-i) == 0:
    		print(d-i)
    		break

	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

if M%N == 0:
	print(d)
else:
	solve()

Submission status: Time Limit Exceeded

Solution code:
N,M=(int(i) for i in input().split())
k=int(M/N)
ans=0
for i in range(k):
	if M%(k-i) == 0:
		ans=max(k-i,ans)
print(ans)

Submission status: Time Limit Exceeded

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

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

amax = M // N
L = make_divisor_list(M)
L = [i for i in L if i <= amax]

if M % N == 0:
    ans = int(M/N)
else:
    for i in L[::-1]:
        if (M - (i * N)) % i == 0:
            ans = i
            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int,input().split()))
 
d = int(M/N)

def solve():
	i = 0
	while True:
		if M%(N+i+1) == 0:
			print(int(M/(N+i+1)))
			break
		i += 1

if M%N == 0:
	print(d)
else:
	solve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

def solve(N, M):
    ans = [1]
    for D in range(2, M//N + 1):
        if M >= N * D and M % D == 0:
            ans.append(D)
    return max(ans)

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Time Limit Exceeded

Solution code:
# coding : utf-8

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

b = M//N

print(max([i for i in range(1,b+1) if M%i == 0]))

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int,input().split()))
 
d = int(M/N)
 
if M%N == 0:
	print(d)
else: 
    ans = 1
    for i in range(M//N+1, 0, -1):
        if M % i == 0:
            if (M // i) >= N:
                print(i)
                break
	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

def fact(M):
    ans = []
    while M > 1:
        for i in range(2, M+1):
            if M % i == 0:
                ans.append(i)
                M //=i
                break
    return ans

def solve(N, M):
    ans = [1]
    divs = fact(M)
    cand = set([tuple(Xs)
        for r in range(1, len(divs) + 1)
        for Xs in combinations(divs, r)
    ])
    for Xs in cand:
        X = 1
        for x in Xs:
            X *= x
        if M % X != 0:
            continue
        S = X * N
        if (M - S) >= 0 and (M - S) % X == 0:
            ans.append(X)
    return max(ans)

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))