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())
k = m//n

if n == 1:
    print(m)

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

Submission status: Time Limit Exceeded

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

for i in range(k):
    j = k-i
    if m % j == 0:
        print(j)
        break

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
ans = 0
tmp = 1
while True:
    num = m - tmp*(n-1)
    if num < tmp:
        break
    elif num % tmp == 0:
        ans = tmp
    tmp += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

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())
print(max(d for d in range(1, M // N + 1) if M % d == 0))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

count = 1
for i in range(1, (m//n)+1):
    temp = m - (i*n)
    if temp % i == 0:
        count = i
        
print(count)

Submission status: Time Limit Exceeded

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

count = 1
for i in range(1, (m//n)+1):
    temp = m - (i*n)
    if temp % i == 0:
        count = i
        
print(count)

Submission status: Time Limit Exceeded

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

an = m //n
while an*n != m:
  an = m//n
  n = 1 + (m-1)*an
  
print(an)

Submission status: Time Limit Exceeded

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

h = int(m/n)
x = 0
result = [x for x in range(h, 0, -1) if m%x==0]
print(max(result))

Submission status: Time Limit Exceeded

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

h = int(m/n)+1
x = 0
for a in range(h, 0, -1):
    if a*n <= m:
        if m%a == 0:
            print(a)
            break
    else:
        continue

Submission status: Time Limit Exceeded

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

h = int(m/n)+1
x = 0
for a in range(h, 0, -1):
    if m>=a*n and m%a == 0:
        print(a)
        break

Submission status: Time Limit Exceeded

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

h = int(m/n)+1
x = 0
for a in range(h, 0, -1):
    q = m-a*n
    if q>=0 and m%a == 0:
        print(a)
        break

Submission status: Time Limit Exceeded

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

h = int(m/n)+1
for a in range(h, 0, -1):
    q = m-a*n
    if q<0:
        continue
    else:
        if q%a == 0 and m%a == 0:
            print(a)
            break

Submission status: Time Limit Exceeded

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

h = int(m/n)+1
for a in range(h, 0, -1):
    q = m-a*n
    if q<0:
        continue
    elif q == 0:
        print(a)
        break
    else:
        if q%a == 0 and m%a == 0:
            print(a)
            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:
    ans = i
    break
    
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ans = 0
  x = M
  for i in range(1,b+1):
    x -= N
    if gcd(i,x)>ans:
      ans = gcd(i,x)
  print(ans)
  print(' ')

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ls = []
  ans = 0
  x = M
  for i in range(1,b+1):
    x -= N
    if i>x:
      break
    if gcd(i,x)>ans:
      ans = gcd(i,x)
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ls = []
  ans = 0
  for i in range(1,b+1):
    x = M - i*N
    if gcd(i,x)>ans:
      ans = gcd(i,x)
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ls = []
  ans = 0
  for i in range(1,b+1):
    x = M - i*N
    if gcd(i,x)>ans:
      ans = gcd(i,x)
  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:
    print(i)
    exit()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

def div(x):
    div_list = []
    for i in range(1,x//N+2):
        if x%i == 0 and x//i >= N:
            div_list.append(i)
    return div_list

a = div(M)
print(a[-1])

Submission status: Time Limit Exceeded

Solution code:
import fractions
n,m=map(int,input().split())
if m%n==0:
    print(int(m/n))
else:
    ans=1
    for i in range(2,m//n+1):
        c=fractions.gcd(i,m-i*n)
        if c>ans:
            ans=c
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
if m%n==0:
  print(m//n)
else:
  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 = (int(x) for x in input().split())
ans = []
i = 1

while(m//i >= n):
  if(m%i == 0):
    ans.append(i)
  i += 1
  
print(ans[-1])

Submission status: Time Limit Exceeded

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

max_num = int(m/n)
ans = -1
for i in reversed(range(max_num + 1)):
  if(m % i == 0):
    ans = i
    break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N,M = II()

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

	base = math.floor(M / N)
	while (M - (base * N)) % base != 0:
		base -= 1
	print(base)

main()

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 and m // i >= n:
    ans = i
print(ans)

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 == 0:
        print(i)
        exit(0)

Submission status: Time Limit Exceeded

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


def divisor(num):
    opside = num
    i = 2
    div = [1, opside]
    while i <= opside:
        if num % i == 0:
            opside = num // i
            if i == opside:
                div.append(i)
            elif opside <= i:
                break
            else:
                div.append(i)
                div.append(opside)
        i += 1
    div.sort()
    return div


ans = 0
for i in divisor(m):
    if n <= m // i:
        ans = i
    else:
        break
print(ans)

Submission status: Time Limit Exceeded

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


def divisor(num):
    opside = num
    i = 2
    div = [1, opside]
    while i <= opside:
        if num % i == 0:
            opside = num // i
            if i == opside:
                div.append(i)
            elif opside <= i:
                break
            else:
                div.append(i)
                div.append(opside)
        i += 1
    div.sort()
    return div


ans = 0
for i in divisor(m):
    if n <= m // i:
        ans = i
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

divisor = deque([])

for i in range(2, M + 1) :
    if M % i == 0 :
        divisor.append(i)
    if i * N > M :
        break

while divisor :
    div = divisor.pop()
    if M // div >= N :
        print(div)
        break
else :
    print(1)

Submission status: Time Limit Exceeded

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

base = M // N
while (M - (base * N)) % base != 0:
	base -= 1
print(base)

Submission status: Time Limit Exceeded

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

k = m // n

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

c = 1
for i in range(1,k+1):
    if m % i == 0:
        c = i

print(c)

Submission status: Time Limit Exceeded

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

k = m // n

c = 1
for i in range(1,k+1):
    if m % i == 0:
        c = i

print(c)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
#全探索すると終わらない
import math
N, M = map(int, input().split())
ans = 1
    
for i in range((M+N-1)//N, 0, -1):
    if M%i == 0:
        if (M//i)//N >= 1:
            print (i)
            exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
ceil = M / N
tmp = 1
mx = 0
while ceil >= tmp:
    if (M - tmp * (N - 1)) % tmp == 0:
        mx = tmp
    tmp += 1

print(mx)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
#m%g=0 and m>=g*nが成立
ans=1
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())

for base in range(1, M//N+1)[::-1]:
    if M % base != 0:
        continue
    print(base)
    break

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = map(int, input().split())
k = math.floor(m / n)
for kk in range(k, 0, -1):
    if m % kk == 0:
        ans = kk
        break
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(max_gcd)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,m=map(int,input().split())
mv=m
l=[]
for i in range(2,int(m**0.5)+1):
	while m%i==0:
		l.append(i)
		m//=i
if m>1:l.append(m)
elif m==1 and l is None:l.append(1)

comb=set()
for i in range(len(l)+1):
	for x in itertools.combinations(l,i):
		comb.add(x)
		
ans=1
for i in comb:
	res=1
	for j in i:
		res*=j
	if res<=mv//n:
		ans=max(ans,res)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
###############################################################################

from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n, m = intin()

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


def factorize(n):
    if n == 1:
        return [1]

    i, factors = 2, []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


factors = factorize(M)
n_factors = len(factors)

ans = 0
for i in range(1 << n_factors):
    x = 1
    for j in range(n_factors):
        if i & (1 << j):
            x *= factors[j]
    y = M // x
    if N <= y:
        ans = max(ans, x)
print(ans)

Submission status: Time Limit Exceeded

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

i = 1
ans = 1
while i * i <= m:
  if m % i == 0:
    if i >= n:
      if i >= n:
        ans = max(ans, m // i)
      elif m // i >= n:
        ans = max(ans(ans, i))
  
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif is_prime(m):
  print(1)
  
else:
  i = m // n
  ans = 0
  while i  >= 1:
    if (m - i * n) % i == 0:
      ans = i
      break
    i -= 1

  print(ans)

Submission status: Time Limit Exceeded

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif is_prime(m):
  print(1)
  
else:
  i = 1
  ans = 0
  while i  <= m // n:
    if (m - i * n) % i == 0:
      ans = i
    i += 1

  print(ans)

Submission status: Time Limit Exceeded

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif is_prime(m):
  print(1)
  
else:
  ans = 0
  for i in range(1, m//n+1):
    tmp = m - i * n
    if tmp % i == 0 and ans < i:
      ans = i
    i += 1
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif is_prime(m):
  print(1)
  
else:
  i = 1
  ans = 0
  while i  <= m // n:
    tmp = m - i * n
    if tmp % i == 0 and ans < i:
      ans = i
    i += 1

  print(ans)

Submission status: Time Limit Exceeded

Solution code:
def isPrimeNumber(num):
  pn = 2 #素数は2から
  while pn * pn <= num: #√numまで調べる
    if num % pn == 0:
      return False
    pn += 1
  return True

n,m = map(int, input().split())
  
if m % n == 0:
  print(m//n)
  exit()
  
elif isPrimeNumber(m):
  print(1)
  
else:
  i = 1
  ans = 0
  while i  <= m // n:
    tmp = m - i * n
    if tmp % i == 0 and ans < i:
      ans = i
    i += 1

  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def make_divisors(n,m):
    divisors = []
    for i in range(1, (m//n)+1):
        if m % i == 0:
            divisors.append(i)
            if i != m // i and m//i<=m//n:
                divisors.append(m//i)
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

while ans > 0:
    if m%ans == 0:
        if m//ans >= n:
            break
    else:
        ans -= 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

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

Submission status: Time Limit Exceeded

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

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

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:
n,m=map(int,input().split())
if n==1:
  print(m)
  exit()
for i in range(n,m+1):
  if m%i==0:
    print(m//i)
    exit()
print(1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
input = sys.stdin.readline

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

    print(i)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import math
import collections
INF = float("inf")


def factorial(n):
    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


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

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def solve(x):
    if m % x == 0:
        return True
    else:
        return False
for i in range(m//n,-1,-1):
    if solve(i):
        print(i)
        exit()
    else:
        continue

Submission status: Time Limit Exceeded

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

ans = 1
for k in range(1, M + 1):
    if(0 == M % k):
        if((M // k) < k):
            break
        if((M // k) > N - 1):
            ans = max(ans, k)
#            print("k = {}, M/k = {}, ans = {}".format(k, M//k, ans))
#        else:
#            print("k = {}, M/k = {}, ans = {}, skip".format(k, M//k, ans))
        k_ = M // k
        if((M // k_) > N - 1):
            ans = max(ans, k_)
#            print("k = {}, M/k = {}, ans = {}".format(k_, M//k_, ans))
#        else:
#            print("k = {}, M/k = {}, ans = {}, skip".format(k_, M//k_, ans))
    else:
#        print("k = {}, M % k = {}, skip".format(k, M % k))
        continue

print(str(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:
        ans=m//i
        break
print(ans)

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:
        break
print(i)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

for k in reversed(range(m//n+1)):
    if m%k == 0:
        print(k)
        break

Submission status: Time Limit Exceeded

Solution code:
n, m = [int(s) for s in input().split(" ")]

for k in reversed(range(m//n+1)):
    if m%k == 0:
        print(k)
        break

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
# 問題はM//N>xを満たすようなMの約数xの中で最小のものと読み替えられる。
bdr = M//N
ans = 1
for i in range(1,M):
    if M%i==0:
        if i<=bdr:
            ans = i
        if i>bdr:
            break
print(ans)

Submission status: Time Limit Exceeded

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

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())
if M % N == 0:
    print(M // N)
    quit()
for i in range(M // N + 1):
    if M % (M//N-i) == 0:
        print(M//N-i)
        quit()

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

else:
	for i in range(2,int(M/N)+1):
		if M%i == 0:
			ans = i
		else:
			pass
print(ans)

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%i == 0:
		ans = i
	else:
		pass
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=[i for i in range(1,M//N+1) if M%i==0]#約数（m）の大きい順にM→M/mとしたときにNこの最大公約数が1になるか（というかM/mをN個にわけることができるか、で十分）を調べる
c=0
while c==0:
    if int(M//max(A))>=N:
        a=int(max(A))
        c+=1
    else:
        del A[len(A)-1]
print(a)

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 == 0:#約数（m）の大きい順にM→M/mとしたときにNこの最大公約数が1になるか（というかM/mをN個にわけることができるか、で十分）を調べる
        if M/i>=N:
            print(i)
        break

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=[i for i in range(1,M//N+1) if M%i == 0 ]
A.reverse()#mの約数の降順
for i in A:#約数（m）の大きい順にM→M/mとしたときにNこの最大公約数が1になるか（というかM/mをN個にわけることができるか、で十分）を調べる
    if M/i>=N:
        print(i)
        break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# a1 + a2 + a3 ... + an = M
# ai の 最大公約数をDとする
# ai = xi * D　のはず。 D * x0 + D * x1 ... + D * xn = M
# まとめて D(x1 + x2 + .... + xn) = M
# 変形し、D = M / (x1 + x2 + .... + xn)
# (x1 + ... xn) = K とすると、Kを最小化するとDが最大化する
# M / K が割り切れる必要があるので、KはMの約数のいずれか
# K >= N。なぜなら xi >= 1 なので、Kは最低でも数字の個数 N になる
# つまり、約数のうちで N 以上の最初の値が K になる
# ex: 3 14
# 14 の約数 {1, 2, 7}
# K >= N なので、　K >= 3
# K = 7 で確定。つまり D = M/K = 2 でAnswer

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

N,M=rl()

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

Submission status: Time Limit Exceeded

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

N,M=rl()

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

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

print(1)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

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