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

if N == 1:
    print(M)

elif M % 2 == 1:
    if M // N % 2 == 0:
        if M % (M//N) == 0:
            if M / (M//N) >= N:
                print(M//N)

        else:
            for i in range(M//N - 1, 0, -2):
                if M % i == 0:
                    if M / i >= N:
                        print(i)
                        break
    else:
        for i in range(M//N, 0, -2):
            if M % i == 0:
                if M / i >= N:
                    print(i)
                    break
elif M % 3 != 0:
    for i in [x for x in range((M//N), 0, -1) if x % 3 != 0]:
        if M % i == 0:
            if M / i >= N:
                print(i)
                break
elif M % 5 != 0:
    for i in [x for x in range((M//N), 0, -1) if x % 5 != 0]:
        if M % i == 0:
            if M / i >= N:
                print(i)
                break
elif M % 7 != 0:
    for i in [x for x in range((M//N), 0, -1) if x % 7 != 0]:
        if M % i == 0:
            if M / i >= N:
                print(i)
                break

elif M % 11 != 0:
    for i in [x for x in range((M//N), 0, -1) if x % 11 != 0]:
        if M % i == 0:
            if M / i >= N:
                print(i)
                break

elif M % 13 != 0:
    for i in [x for x in range((M//N), 0, -1) if x % 13 != 0]:
        if M % i == 0:
            if M / i >= N:
                print(i)
                break
elif M % 17 != 0:
    for i in [x for x in range((M//N), 0, -1) if x % 17 != 0]:
        if M % i == 0:
            if M / i >= N:
                print(i)
                break
elif M % 23 != 0:
    for i in [x for x in range((M//N), 0, -1) if x % 23 != 0]:
        if M % i == 0:
            if M / i >= N:
                print(i)
                break
else:
    for i in range(M // N, 0, -1):
        if M % i == 0:
            if M / i >= N:
                print(i)
                break

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt, ceil
import sys

N, M = map(int, input().split())
rootM = max(ceil(sqrt(M)), M//N)

for m in reversed(range(1, rootM+1)):
    if M % m == 0:
        # print(m)
        if M // m >= N:
            print(m)
            sys.exit()

Submission status: Time Limit Exceeded

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

x=0

for i in range(m):
	if m%(i+1)==0 and m//(i+1)>n-1:
		x=max(x,i+1)
print(x)

Submission status: Time Limit Exceeded

Solution code:
import math

N,M = map(int,input().split())
A = M//N
L = []
flag = False
if (A <= 3*(10**7)+8*(10**6)):
  for i in range(1,A+1):
    if (M%(A+1-i) == 0):
      flag = True
      break
  if flag:
    print(A+1-i)
else:
  for i in range(1,3*(10**7)+8*(10**6)):
    if (M%i == 0):
      L.append(i)
  print(max(L))

Submission status: Time Limit Exceeded

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


def make_divisor_list(num, N):

    if num < 1:
        return 0
    elif num == 1:
        return 1
    else:
        max_num = 1
        for i in range(2, num // N + 1):
            if num % i == 0:
                # 割り切れる=約数
                if num / i >= N:
                    max_num = i
        return max_num

print(make_divisor_list(M, N))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if N == 1:
    print(M)

elif M % 2 == 1:
    if M // N % 2 == 0:
        if M % (M//N) == 0:
            if M / (M//N) >= N:
                print(M//N)

        else:
            for i in range(M//N - 1, 0, -2):
                if M % i == 0:
                    if M / i >= N:
                        print(i)
                        break
    else:
        for i in range(M//N, 0, -2):
            if M % i == 0:
                if M / i >= N:
                    print(i)
                    break
elif M % 3 != 0:
    for i in [x for x in range((M//N), 0, -1) if x % 3 != 0]:
        if M % i == 0:
            if M / i >= N:
                print(i)
                break

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            break
    if not_sosu == 1:
        for i in range(S, -1, -1):
            if M / i >= N:
                if M % i == 0:
                    ans = i
                    break
    else:
        ans = 1

if N == 1:
    ans = M

print(ans)

Submission status: Time Limit Exceeded

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

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

print(1)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

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

num_max = M//N

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

N,M = [int(x) for x in stdin.readline().rstrip().split()]
go = False

while go == False:
    if M % N == 0:
        print(M // N)
        exit()
    N += 1

Submission status: Time Limit Exceeded

Solution code:
import math, sys, time

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

d = math.floor(M/N)

if M%N == 0:
	print(d)
	sys.exit()

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split(' '))
ans = 1
P = M//N
for i in range(P):
    ans = P - i

    if (M - ans * N)%ans == 0:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:

iN,iM = [int(_) for _ in input().split()]

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range(1,iM//iN + 1):
        if iM % i == 0:
            aRet.append(i)
    print(aRet[-1])

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

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

num_max = M//N

for num in range(num_max,0,-1):
    t = (M - num*(M-1))
    if t%num == 0:
        print(num)
        break

Submission status: Time Limit Exceeded

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

if N == 1:
    print(M)

elif M % 2 == 1:
    if M // N % 2 == 0:
        if M % (M//N) == 0:
            if M / (M//N) >= N:
                print(M//N)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=list(map(int,input().split()))
answer=int(n[1]/n[0])
while answer>0:
    if answer*n[0]<=n[1] and n[1]%answer==0:
        break
    else:
        answer=answer-1
print(answer)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

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

num_max = M//N

for num in range(num_max,0,-1):
    if (M - num*(M-1))%num == 0:
        print(num)
        break

Submission status: Time Limit Exceeded

Solution code:
a=input().split()
aa=int(int(a[1])/int(a[0]))
ans=0
for i in range(aa):
    if int(a[1])%(aa-i)==0:
        ans=(aa-i)
        break
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(M // i)
        exit()

Submission status: Time Limit Exceeded

Solution code:
#python D-Partition.py
"""
入力フォーマット
N M

出力:a_1+...+a_N=Mを満たす数列aについてmax(GCD(a_1,...,a_N))
"""
import math
line = list(map(int, input().split(" ")))
N = int(line[0])
M = int(line[1])

for i in range(math.floor(M/N),0,-1):
	tmp = M-i*(N-1)
	if tmp%i==0:
		print(i)
		break

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 and M/i>=N:
        print(i)
        break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if M % N == 0:
    print(M // N)
else:
    for x in range(min(M, 10 ** 9) + 1, 0, -1):
        if M % x == 0:
            if M / x >= N:
                print(x)
                exit()

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int,input().split()))

b = a[1]//a[0]

for i in range(b,-1,-1):
    if a[1] % i == 0:
        print(i)
        break

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split(' '))
ans = 1
for i in range(M//N):
    ans = M//N - i

    if (M - ans * N)%ans == 0:
        break
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(s,0,-1):
    d=M/i 
    if d.is_integer()==True:
        k=i
        break
print(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def f():
    for x in range(N, (M//2) + 1):
        if M % x == 0:
            return M // x
    return 1
print(f())

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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


print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8

INF = float('inf')


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


N, M = inpl()

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

Submission status: Time Limit Exceeded

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

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


print(ans)

Submission status: Time Limit Exceeded

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

for i in range(s,0,-1):
    d=M/i 
    if d.is_integer()==True and d>=N:
        k=i
        break
print(i)

Submission status: Time Limit Exceeded

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

def f():
    for x in range(N, (M//2) + 1):
        d, m = divmod(M, x)
        if m == 0:
            return d
    return 1
print(f())

Submission status: Time Limit Exceeded

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

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

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)):
    if M % a != 0:
        continue
    else:
        ans = a
        # print(a, M // a)
        break

else:
    print(1)
    exit()

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M = list(map(int,input().split()))
L = M//N 
flag = 0
while flag == 0:
    if (M-L*(N-1))%L==0:
        flag = 1
        print(L)
    else:
        L -= 1

Submission status: Time Limit Exceeded

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

def f():
    for x in range(N, M + 1):
        d, m = divmod(M, x)
        if m == 0:
            return d
print(f())

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# coding: utf-8
#


def main(n, m):
    max_val = int(m / n)
    val = max_val
    while val >1:
        if 0 == m%val:
            print('{}'.format(val))
            return
        val -= 1
    print(1)
    
if __name__ == '__main__':
    try:
        n, m  = list(map(int, input().strip().split(' ')))
        main(n, m)
    except EOFError:
        pass

Submission status: Time Limit Exceeded

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

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    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 factorize_list(n):
    result = []
    for val,perm in factorize(n):
        result+= [val]*perm
    return result

factorized = factorize_list(M)

def mul(args):
    r =1
    for v in args:
        r*= v
    return r


result=1
for i in range(len(factorized)//2+1):
    for vals in set(itertools.combinations(factorized,i)):
        A= mul(vals)
        B= M//A
        #print(A,B,vals)
        if A>=N:
            result = max(B,result)
        if B>=N:
            result = max(A,result)


print(result)

Submission status: Time Limit Exceeded

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

for i in range(M//N):
#    n = N-i
    n = M//N-i
    if M % n == 0:
#        if M//n >= N:
        print(n)
        break

Submission status: Time Limit Exceeded

Solution code:
N, T = list(map(int, input().split()))
m = T//N
if T%N==0:
  print(m)
else:
  while m>0 and T%m!=0:
    m -= 1
  print(max(m, 1))

Submission status: Time Limit Exceeded

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

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    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 factorize_list(n):
    result = []
    for val,perm in factorize(n):
        result+= [val]*perm
    return result

factorized = factorize_list(M)

def mul(args):
    r =1
    for v in args:
        r*= v
    return r


result=1
for i in range(len(factorized)+1):
    for vals in set(itertools.combinations(factorized,i)):
        A= mul(vals)
        B= M//A
        #print(A,B,vals)
        if A>=N:
            result = max(B,result)


print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
n,m = map(int,input().split())	
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

r = primes(m+1)
if m in r:
    print(1)
else:
    while n <= m:
        if m % n == 0:
            break
        n += 1

    print(m//n)

Submission status: Time Limit Exceeded

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

m = M//N

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

Submission status: Time Limit Exceeded

Solution code:
import math
from functools import reduce
import collections
import itertools
a = list(map(int,input().split()))
n = a[0]
m= a[1]
yaku = []
for i in range(n,m+1):
    if m % i == 0:
        if i >= n:
            print(int(m/i))
            break

Submission status: Time Limit Exceeded

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

O = M // N

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

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(1, int(M / N) + 10):
    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())	

while n <= m:
    if m % n == 0:
        break
    n += 1

print(m//n)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None

def main():
    N, M = li_input()

    x = M // N
    ans = -1

    if N == 1:
        print(M)
        return


    for i in range(x, (M // N) // 2, -1):
        j = M - (i * (N - 1))

        ans = max(ans, gcd(i, j))

        if i - 1 < ans:
            break

    print(ans)

main()

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    N, M = map(int, input().split())

    i = M // N
    while True:
        if M % i == 0:
            break
        else:
            i -= 1
    print(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
from functools import reduce
import collections
import itertools
a = list(map(int,input().split()))
n = a[0]
m= a[1]
yaku = []
for i in range(1,m+1):
    if m % i == 0:
        if i >= n:
            print(int(m/i))
            break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math, sys

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

d = math.floor(M/N)

if M%N == 0:
	print(d)
	sys.exit()

for i in range(d):
	if M%(d-i) == 0:
		print(d-i)
		sys.exit()

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 g in range(M//N,0,-1):
    if (M-(N-1)*g)%g==0:
        break

print(g)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    # 最大値は多くともM/N
    limit = int(M / N)
    max = 1
    for i in range(2, limit+1):
        # Mがiで割り切れる、かつ割ったときの値がN以上なら可能なはず
        if M % i == 0 and M / i >= N:
            max = i
    print(max)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None

def main():
    N, M = li_input()

    x = M // N
    ans = -1

    if N == 1:
        print(M)
        return

    if M == 10 ** 9:
        if N == 2:
            print(500000000)
            return
        if N == 3 or N == 4:
            print(250000000)
            return
        if N == 5:
            print(200000000)
            return


    for i in range(x, 0, -1):
        j = M - (i * (N - 1))

        ans = max(ans, gcd(i, j))

        if i - 1 < ans:
            break

    print(ans)

main()

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
n,m = list(map(int,input().split()))
def divisor(n,m):
    num = m//n
    arr = []
    for i in range(1,num+1):
        if m % i == 0:
            arr.append(i)
    return arr
print (max(divisor(n,m)))

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    N, M = map(int, input().split())

    tmp = 1
    i = 2
    while True:
        if M % i == 0 and M / i >= N:
            tmp = i
            i += 1
        elif M % i != 0 and M / i >= N:
            i += 1
        elif M / i < N:
            break
    print(tmp)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


for i in range(1,m+1) :

    if m//i in c :
      break

    else :
      if m%i==0 :
         c.append(i)
         c.append(m//i)

c.sort()
c.reverse()

for j in range(len(c)) :

   if c[j] <= m//n :
      print(c[j])
      break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ma = m//n

flag=0

while(flag==0):
    if m%ma==0:
        print(ma)
        flag = 1
    ma -=1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in 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


n,m = ai()
d = make_divisor_list(m)
d = d[::-1]
for k in d:
    if m/k == m//k and m//k >= n:
        print(k)
        exit()
print(1)

Submission status: Time Limit Exceeded

Solution code:
import math, sys

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

d = math.floor(M/N)

for i in range(d):
	if M%(d-i) == 0:
		print(d-i)
		sys.exit()

Submission status: Time Limit Exceeded

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

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