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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if m % n == 0:
	print(m // n)
elif m // n > 10**6:
	for i in range(n, m//n):
		if m % i == 0:
			print(m // i)
			break
else:
	for i in range(1, m//n)[::-1]:
		amari = m - n*i
		if amari % i == 0:
			print(i)
			break

Submission status: Wrong Answer

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

a = m % n
b = m

if a == 0:
    print(int(m / n))
else:
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    print(b)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N,M = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
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

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

fa_list = factorize(M)
re = 1
for fa in fa_list:
    a = M // fa[0]
    if a >= N and re % fa[0] > 0:
        if a % N == 0:
            cnt = a // N
        else:
            cnt = 1
        re *= fa[0] * cnt
        
print(re)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N,M = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
import math

def primes(n): # Eratosthenes' sieve
    prime = [True] * (n + 1)
    prime[0] = False
    prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            prime[j] = False
    return [i for i in range(n + 1) if prime[i]]
        
def factorize(n):
    result = defaultdict(int)
    for p in primes(n):
        while n % p == 0:
            n = n // p
            result[p] += 1
    return result

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

if M % N == 0:
    print(M // N)
else:
    quotient, rem = divmod(M, N)
    cand = None
    for p in range(1, int(math.sqrt(quotient)) + 1):
        if rem % p == 0:
            cand = p
    print(cand)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def factorize(M):
    fact=[]
    for i in range(2,4*10**4):
        tmp=[1]
        if M==1:
            break
        while M%i==0:
            M//=i
            tmp.append(tmp[-1]*i)
        if len(tmp)>1:
            fact.append(tmp)
    return fact

def divisor(fact,arr,i,p):
    if i == len(fact):
        arr.append(p)
        return 0
    for x in fact[i]:
        divisor(fact,arr,i+1,p*x)
    
N,M=list(map(int,input().split()))

fact = factorize(M)
arr=[]
divisor(fact,arr,0,1)
arr=sorted(arr)
ans=1
for x in arr:
    if x>M//N:
        break
    ans=x
print(ans)

Submission status: Wrong Answer

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//2 + 1):
    if m % i == 0:
        if i >= n:
            print(int(m/i))
            break

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
def factorize(M):
    fact=[]
    for i in range(2,4*10**4):
        tmp=[1]
        if M==1:
            break
        while M%i==0:
            M//=i
            tmp.append(tmp[-1]*i)
        if len(tmp)>1:
            fact.append(tmp)
    return fact

def divisor(fact,arr,i,p):
    if i == len(fact):
        arr.append(p)
        return 0
    for x in fact[i]:
        divisor(fact,arr,i+1,p*x)
    
N,M=list(map(int,input().split()))

fact = factorize(M)
arr=[]
divisor(fact,arr,0,1)
print(fact)
arr=sorted(arr)
print(arr)
ans=1
for x in arr:
    if x>M//N:
        break
    ans=x
print(ans)

Submission status: Wrong Answer

Solution code:
(n, m) = map(int, input().split())
a = m // n
maxkoubai = 10000
for i in range(2, a + 1):
    b = m % i
    c = m // i
    if b % c == 0:
        maxkoubai = i
print(maxkoubai)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
from math import sqrt, ceil

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N, M = ds_in()


def factorize(n):
    fct = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            fct.append(i)
    return fct

cand = factorize(M)
for c in cand[::-1]:
    if M//c >= N:
        print(c)
        exit()

Submission status: Wrong Answer

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

def dividable(x,y):
    if x/y == x//y:
        return True
    else:
        return False


answer=1
for i in range(2,N+1):
    if dividable(M,i) and int(M/i) >= N:
        answer = i

print(answer)

Submission status: Wrong Answer

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

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

for a in reversed(range(1, N)):
    if M % a != 0:
        continue
    else:
        ans = a
        # print(a, M // a)
        break

print(a)

Submission status: Wrong Answer

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

S = -100000
E = -100000
def sarch(s, e):
    global ans, S, E
    #print(s, e, ans)
    c = (s + e) // 2
    if S != -100000 and E != -100000:
        return 0
    if e - s < 1000:
        E = e
        S = s
        return 0
    if M / c >= N:
        if M % c == 0:
            ans = c
        if S != -100000 and E != -100000:
            return 0
        sarch(c, e)
    elif M / c < N:
        if S != -100000 and E != -100000:
            return 0
        sarch(s, c - 1)
        
sarch(0, M)
if S == 0:
    S = 1
for i in range(S, E):
    if M / i < N:
        break
    if M % i == 0:
        ans = i

#print(E, S)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x=1
for i in range(1,100000000):
    if m%i==0 and i*n<=m:
        x=i
print(x)

Submission status: Wrong Answer

Solution code:
import math

N, M = list(map(int, input().split()))
x = M // N
Mx = []
m = math.floor(math.sqrt(M))
for i in range(1, m + 1):
	if M % i == 0:
		Mx.append(i)

y = len(Mx)

My = []
for i in range(y):
	My.append(int(M // Mx[- i]))



for i in range(y):
	Mx.append(My[-1 - i])


ans = 1
for i in Mx:
	if i <= x:
		ans = i
	else:
		break

print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x=1
for i in range(1,10000000):
    if m%i==0 and i*n<=m:
        x=i
print(x)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
for i in list(range(N+1))[::-1]:
    flag=M-N*i
    if flag%i==0 and flag>=0:
        print(i)
        break

Submission status: Wrong Answer

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

if M%N==0:
  print(M//N)
else:
  ans= (M//N)
  cnt=[]
  for i in range(2,M):
    if i*i > M:
      break
    if M%i==0:
      cnt.append(i)
      cnt.append(M/i)
      
  cnt.sort(reverse=True)
  for j in range(len(cnt)):
    if cnt[j] < ans:
      ans=cnt[j]
      break
  
  print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x=0
for i in range(1,min([n,100000,m//n])+1):
    if m%i==0 and n*i<=m:
        x=i
print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if m % n == 0:
	print(m // n)
else:
	for i in range(1, m//n)[::-1]:
		amari = m - n*i
		if amari % i == 0:
			print(i)
			break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,m = map(int, input().split())

maxg = m//n+1

for x in range(maxg,0,-1):
    if (m - x*(n-1))%x==0:
        print(x)
        exit()

Submission status: Wrong Answer

Solution code:
iipt=lambda:int(input())
miipt=lambda:map(int,input().split(" "))
from math import sqrt
n,m=miipt()
r=0
for g in range(1, int(sqrt(m))):
    if m%g==0 and m//g>=n:

        r=max(r, g)
print(r)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
d=1
i=1
sm = m**0.5
while i<=sm:
  if m%i==0:
    if i>=n:
      d=max(d,m/i)
    if m/i>=n:
      d=max(d,i)
  i+=1
print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

N, M = list(map(int, input().split()))
x = M // N
Mx = []
m = math.floor(math.sqrt(M))
for i in range(1, m + 1):
	if M % i == 0:
		Mx.append(i)
ans = 1
for i in Mx:
	if i <= x:
		ans = i
	else:
		break

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
if b%a==0:
    print(int(b/a))
else:
    print(b%a)

Submission status: Wrong Answer

Solution code:
def run():
	N, M = (int(x) for x in input().split())
	i = 2
	result = 1

	if N == 1:
		print(M)

	elif N == M:
		print(M)

	else:
		while True:
			if M % i == 0 and N * i <= M:
				result = i

			i += 1
			if i * N > M:
				break

		print(result)



if __name__ == '__main__':
	run()

Submission status: Wrong Answer

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

if (M % N) == 0:
    print(int(M / N))
else:
    print(M % N)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
def divisor(n): #約数
    f=[]
    d=[1]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    for i in range(len(f)):
        t=[]
        for j in range(1,f[i][1]+1):
            t.append(f[i][0]**j)
        for j in range(len(d)):
            for k in range(len(t)):
                d.append(d[j]*t[k])
    return sorted(d)
x=divisor(m)
for i in range(len(x)):
    if m/x[i]<n:
        print(x[i-1])
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
N,M = map(int, input().split())
tmax = int(M/N)
t = tmax
divisor_list = [1]
for i in range(2, int(math.sqrt(M)) + 1):
  if M % i == 0:
    divisor_list.append(i)
    divisor_list.append(M//i)
divisor_list.sort(reverse = True)
for nums in divisor_list:
  if nums <= tmax:
    print(nums)
    sys.exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import fractions
n,m =map(int,input().split())
a = int(m/n)
b = m%n
print(fractions.gcd(a,b))

Submission status: Wrong Answer

Solution code:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]


def factorize(n):
    fct = []
    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)
        b, e = b + 1, 0
    if n > 1:
        fct.append(n)
    return reversed(fct)


n,m = ai()
f = factorize(m)
for p in f:
    if m//p >= n:
        print(p)
        exit()
print(1)

Submission status: Wrong Answer

Solution code:
import math
lis = []
n,m = map(int,input().split())
for i in range(1,math.ceil(math.sqrt(m))):
  if m % i == 0:
    lis.append(i)
    lis.append(m//i)
lis.sort()
cou = 0
ans = 0
for i in range(len(lis)):
  if m % lis[i] == 0 and m // lis[i] >= n:
    ans = max(ans,lis[i])
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans =1

for i in range(1,m+1):
    if i*n<=m:
        if m%i==0:
            ans=i
    else:
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
import math
n,m = map(int,input().split())
cou = 0
ans = 0
for i in range(1,math.ceil(math.sqrt(m))+1):
  if m % i == 0 and m // i >= n:
    ans = max(ans,i)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

n, m = map(int, input().split())
l = []
for i in range(2, int(sqrt(m)) + 1):
	if m % i == 0:
		l.append(i)

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

print(ans)

Submission status: Time Limit Exceeded

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

while True:
    if m % h == 0:
        break
    h -= 1

print(h)

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:
N, M = map(int, input().split())

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

A = []
for i in range (1, M//N+1):
	if M%i == 0:
		A.append(i)

print(A[-1])

Submission status: Time Limit Exceeded

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  if m%n==0:
    return m//n

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

# main()
print(main())

Submission status: Time Limit Exceeded

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = na()
MAX = M // N + 1
ans = 1
for i in range(1, MAX):
    res = M - i * N
    if res % i == 0:
        ans = max(ans, i)
print(ans)

Submission status: Time Limit Exceeded

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:

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

ans = 1
for n in range(1, M // N + 1):
    res = M - n * N
    if res % n == 0:
        ans = n

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    # if i * i > M:
    #     break
    if M % i == 0:
        ans = i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 1 <= N <= 10**5
# N <= M <= 10**9
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if M % i == 0:
        ans = i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 1 <= N <= 10**5
# N <= M <= 10**9
N, M = map(int, input().split())

V = M // N

ans = 1
for i in range(1, V + 1):
    if M % i == 0:
        ans = i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, M = mi()
    g = 1
    for i in range(1, M//N+1):
        if M%i==0:
            g = i
    print(g)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M = map(int, input().split())
    search = M//N + 1
    for s in range(search, 0, -1):
        sum_array = s * N
        if sum_array > M:
            continue
        remain = M - sum_array
        if remain % s == 0:
            print(s)
            return

if __name__ == "__main__":
    main()

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

Submission status: Time Limit Exceeded

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
mn = M//N
ml = M%N
if ml == 0:
    print(mn)
    exit()
ans = 0
for i in range(mn+1,0,-1):
    if i < ans:
        break
    tmp = math.gcd(i,M-i*(N-1))
    ans = max(ans,tmp)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
mn = M//N
ml = M%N
if ml == 0:
    print(mn)
    exit()
ans = 0
for i in range(1,mn+1):
    tmp = math.gcd(i,M-i*(N-1))
    ans = max(ans,tmp)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import *
n,m=map(int,input().split())
M=m
a=[1]
for i in range(2,int(m**.5)+1):
    while m%i==0:
        m//=i
        a+=[i]
if m!=1:a+=[m]
ans=1
for i in range(len(a)):
    for b in combinations(a,i):
        c=1
        for j in b:
            c*=j
        if c>=n:
            ans=max(ans,M//c)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()

    # Mの約数の中でMを割った時の値がN以上になるような最大のもの
    ans = 1
    for i in range(1, M // N + 1):
        if M % i == 0:
            ans = i

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()

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

Submission status: Time Limit Exceeded

Solution code:
from math import gcd

def solve():
    n, m = map(int, input().split())
    d = m // n
    p = m % n
    res = max(1, gcd(d, d + p))
    while d > 1:
        d -= 1
        q = m - n * d
        res = max(res, gcd(d, d + q))
    print(res)


solve()

Submission status: Time Limit Exceeded

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

if n == 1:
    print(m)
    exit()
a = []
for i in range(1, m // n + 1):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        a.append(i)

print(max(a))

Submission status: Time Limit Exceeded

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

if n == 1:
    print(m)
    exit()
a = []
for i in range(1, m):
    if m % n == 0:
        print(m // n)
        exit()
    if i * n <= m and m % i == 0:
        a.append(i)

print(max(a))

Submission status: Time Limit Exceeded

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

if n == 1:
    print(m)
    exit()
a = []
for i in range(1, m):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0 and i * n <= m:
        a.append(i)

print(max(a))

Submission status: Time Limit Exceeded

Solution code:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

[n,m] = [int(i) for i in input().split()]
if n == 1:
    print(m)
else:
    ans = -1
    #a1は高々この値
    a1_max = m // n
    for i in range(a1_max,0,-1):
        ls = make_divisors(i)
        if (m - i) % ls[-1] == 0 and (m - i)//ls[-1] >= (n-1):
            ans = max(ans,ls[-1])
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

[n,m] = [int(i) for i in input().split()]
if n == 1:
    print(m)
else:
    ans = -1
    #a1は高々この値
    a1_max = m // n
    for i in range(a1_max,0,-1):
        ls = make_divisors(i)
        for j in ls:
            if (m - i) % j == 0 and (m - i)//j >= (n-1):
                ans = max(ans,j)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

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

while(1):
    if m % n == 0:
        print(m//n)
        exit()
    n += 1

Submission status: Time Limit Exceeded

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

ans = 0
while m-k*(n-1) >0:
    if m%k == 0:
        ans = max(ans,k)
        #print(k,m-k*(n-1))
    k +=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3


def main():
    N, M = map(int, input().split())
    ans = 0
    for i in range(1,M+1):
        if M%i==0:
            if M//i >= N:
                ans = i
                # print(ans)
            else:
                break
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m//n
  for i in range(a,0,-1):
    s = m-n*i
    if (s+i)%i==0:
      print(i)
      exit()
    elif a>10**8 and i == 10**3:
      print(1)
      exit()

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m//n
  for i in range(a,0,-1):
    s = m-n*i
    if (s+i)%i==0:
      print(i)
      exit()

Submission status: Time Limit Exceeded

Solution code:
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n, m = map(int, input().split())

    ans = []

    for i in range(1, m // n + 1):
        if (m - i * n) % i == 0:
            ans.append(i)

    print(max(ans))


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 14"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10 123"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """100000 1000000000"""
        output = """10000"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Time Limit Exceeded

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

while True:
    if m % n == 0:
        break
    n += 1
print(m // n)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
#素因数分解(素因数を並べたリスト)(ex:60→[2,2,3,5])
def factorization(n): 
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            for _ in range(cnt):
                arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr
ls = factorization(m)
fi = []
for k in range(2**len(ls)):
    a = 1
    for l in range(len(ls)):
        if (k>>l)&1:
            a *= ls[l]
    if a not in fi:
        fi.append(a)
di = []
for i in range(len(fi)):
    if m//fi[i] >= n:
        di.append(fi[i])
print(max(di))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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