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:
import sys, os, random

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

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

def solve(N, M):
        i = N
        while i <= M:
                if M % i == 0:
                        return M / i
                i = i + 1
        assert 0

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M = list(map(int, input().split(' ')))
    s = M // N
    r = M % N
    while True:
        if r%s == 0:
            print(s)
            break
        if s > r:
            a = (s-r)//N
        else:
            a = 1
        if a == 0:
            a = 1
        s -= a
        r += a*N



if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M = list(map(int, input().split(' ')))
    s = M // N
    r = M % N
    while True:
        if r%s == 0:
            print(s)
            break
        s -= 1
        r = M - s * N


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

max_k = M // N

for i in range(max_k)[::-1]:
    if M % (i+1) == 0:
        print(i+1)
        break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
a = M//N
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

ma = 0
for i in range(a, 0, -1):
    if M % i == 0:
        ma = max(ma, i)
    
print(ma)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
a = M//N
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

ma = gcd(a, M)
for i in range(a, 0, -1):
    ma = max(ma, gcd(i, M))
    
print(ma)

Submission status: Time Limit Exceeded

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

print(res)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N, M=map(int,input().split())
for i in range(int(M//N)+1,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())
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

# a1,...,anがdivisorで割り切れる、すなわちdivisorはMの約数である
divisor=m//n
while m%divisor!=0:
    divisor-=1
print(divisor)

Submission status: Time Limit Exceeded

Solution code:
nm=[int(x) for x in input().split()]
temp=[]
for x in range(1,int(nm[1]/nm[0])+1):
    if(nm[1]%x==0 and (nm[1]/x)>=nm[0]):
        temp.append(x)
print(int(max(temp)))

Submission status: Time Limit Exceeded

Solution code:
inputlist = list(map(int, input().split()))
n, m = inputlist[0], inputlist[1]

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

Submission status: Time Limit Exceeded

Solution code:
inputlist = list(map(int, input().split()))
n, m = inputlist[0], inputlist[1]

for i in range(1,m+1):
    if m % i != 0:
        continue
    if n > i:
        continue
    print(m // i)
    break

Submission status: Time Limit Exceeded

Solution code:
import math
# 公約数xとすると，
# sum(a_i / x) = M / x
# N < M / x であればこれを満たすような数列が取れるよって
# 
# maximize x
# s.t. M%x==0 and x < M/N

N,M = map(int,input().split())
x = M//N
while(M % x != 0):
    x -= 1

print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if flag:
    print(1)

Submission status: Time Limit Exceeded

Solution code:
S = list(map(int,input().split()))
N = S[0]
M = S[1]
ans = 1
for x in range(N,M//2+1):
    if M % x == 0:
        ans = M // x
        break

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

if tmp==0:
  print(1)

Submission status: Time Limit Exceeded

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

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

if tmp==0:
  print(1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

maxnum = m//n

for i in range(maxnum,0,-1):
  if m%i==0:
    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 m % i == 0:
        ans = max(ans, i)
        if m // i > i and m // i <= m // n:
            ans = max(ans, m // i)
            
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

for i in range(1,M+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())
a = m // n

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

maxg = 1
if N == 1:
  maxg = M
else:
  for i in range(2, M//N+1):
    if (M - N*i) % i == 0:
      maxg = i

print(maxg)

Submission status: Time Limit Exceeded

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

maxg = 1
for i in range(2, M//N+1):
  if (M - N*i) % i == 0:
    maxg = i

print(maxg)

Submission status: Time Limit Exceeded

Solution code:
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
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())
if m % n == 0:
    print(m // n)
    exit()
ret = 1
for i in range(1,1+m//n):
    if m % i == 0:
        ret = i
print(ret)

Submission status: Time Limit Exceeded

Solution code:
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(2,m.floor(pow(M,1/2)) + 1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
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())
if m % n == 0:
    print(m // n)
    exit()
ret = 1
i = 1
while(n * i <= m):
    if m % i == 0:
        ret = i
    i += 1
print(ret)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
if N == 1:
    print(M)
    exit()
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(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())
a = M // N
x = 1

for i in range(1, a + 1):
    if M % i == 0:
        x = i

print(x)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
pp = range(1, M // N + 2)
P = max(p for p in pp if M % p == 0 and M // p >= N)
print(P)

Submission status: Time Limit Exceeded

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

N = int(N)
M = int(M)

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

Submission status: Time Limit Exceeded

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

if n==1:
  print(m)
else:
  a=int(m**0.5)

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

Submission status: Time Limit Exceeded

Solution code:
def df(n):
  return [i for i in range(1,n+1) if n % i == 0]

N,M = input().strip().split(' ')
N,M = int(N), int(M)

dflist = df(M)
for d in dflist[::-1]:
  tmp = M/d
  if float(tmp).is_integer() and tmp >= N:
    print(d)
    break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, m =map(int, input().split())
a=m//n
c=0
while c==0:
  if((m-a*n)%a==0):
      c=a
  a=a-1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n, m =map(int, input().split())
a=m//n
c=0
while c==0:
  b=m-a*n
  if(b%a==0):
      c=a
  a=a-1
print(c)

Submission status: Time Limit Exceeded

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python

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

# N splited by number of M 
import math
plist = [2]
for i in range(3, int(1e5+1)):
    ok = True
    for j in plist:
        if j > math.sqrt(i):
            break   
        elif i % j == 0:
            ok = False
            break
    if ok:
        plist.append(i)

# print(plist)

## 

prime_pair = {}

def cnt_power(n, p):
    if p < 2:
        raise "p is smaller than 2."
    if n >= p and n % p == 0:
        return 1 + cnt_power(int(n/p), p)
    else:
        return 0
        
def fac(N):
    global prime_pair
    for p in plist:
        if N % p == 0:  
            # print(N,p)
            # prime_pair[p = ] = (p, cnt_power(N, p))
            prime_pair[p] = cnt_power(N, p)

# print(fac(M))
fac(M)

import copy
divisor = []
init_nowpair = {}
for k in prime_pair:
    # print("prime pair: ", k, prime_pair[k])
    init_nowpair[k] = 0


def makedivisor(prime_pair, now_pair):
    # print(now_pair)
    multi = 1
    for np in now_pair:
        multi *= int(pow(np, now_pair[np]))
    #     print("\tmulti:", multi)
    # print("multi:", multi)
    if multi > M:
        return 
    else:
        if not multi in divisor:
            divisor.append(multi)
    

    for np in now_pair:
        if prime_pair[np] > now_pair[np]:
            now_pair2 = copy.deepcopy(now_pair)
            now_pair2[np] += 1
            makedivisor(prime_pair, now_pair2)
makedivisor(prime_pair, init_nowpair)            
divisor.sort()
# print(divisor)

maxx = 0
for d in divisor:
    if M % d == 0 and int(M/d) >= N:
        maxx = max(maxx, d)

print(maxx)
        
    
# for k in prime_pair:
#     print(k,prime_pair[k])





# maxx = 0
# maxlen = 0
# for i in range(3, int(1e9)):
#     if i % int(1e3) == 0:
#         print(i)
#         print(maxx, maxlen)

#     prime_pair = {}
#     fac(i)
#     maxlen = max(maxlen, len(prime_pair))
#     for k in prime_pair:
#         maxx = max(maxx, prime_pair[k])

Submission status: Time Limit Exceeded

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

while M//2 >= N+i:
    if M%(N+i) == 0:
        ans = M//(N+i)
        break
    else:
        i += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,M = list(map(int,input().strip().split()))
num = N
i = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


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

f = primes(M)

# 素数の場合などは１
if len(f) <= 1:
    print(1)
    exit()

ans_list = []
for i in range(1,len(f)):
    set1 = set([tuple(sorted(l)) for l in list(itertools.combinations(f, i))])
    for com in set1:
        tmp = 1
        for c in com:
            tmp *= c
        if tmp >= N:
            ans_list.append(M//tmp)

if len(ans_list) == 0:
    print(1)
else:
    print(max(ans_list))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
from  collections import Counter

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


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

f = primes(M)
cnt = Counter(f)

# 素数の場合などは１
if len(f) <= 1:
    print(1)
    exit()

# print(mod,div)
for i in reversed(range(1,div)):
    an = M - i*(N-1)
    if an % i == 0:
        print(i)
        exit()

print(1)

Submission status: Time Limit Exceeded

Solution code:
#a_1+a_2+...+a_N = M   Find greatest common divisor of a
N,M=map(int,input().split())

Q=M//N #Quotient
R=M%N  #Reminder
'''
if Q>R :
    k=int((Q-R)//(1+N))
    k-=1
    Q -= k
    R += k*N
    '''
memo=0
while R%Q != 0:
    k= int(Q//(N+R//Q+1))   #max k:k*(N+R//Q)<Q-k
    #print(R,Q,R%Q,R//Q,k)
    while (R+k*N)//(Q-k) != memo and k >= 0:
        k -= 1
        #print(k,memo,(R+k*N)//(Q-k))
    if k > 0:
        Q -= k
        R += k*N
        memo=R//Q
    else:
        Q -= 1
        R += N
        memo=R//Q

print(Q)

Submission status: Time Limit Exceeded

Solution code:
#a_1+a_2+...+a_N = M   Find greatest common divisor of a
N,M=map(int,input().split())

Q=M//N #Quotient
R=M%N  #Reminder
'''
if Q>R :
    k=int((Q-R)//(1+N))
    k-=1
    Q -= k
    R += k*N
    '''
memo=0
while R%Q != 0:
    k= int(Q//(N+R//Q+1))   #max k:k*(N+R//Q)<Q-k
    #print(R,Q,R%Q,R//Q,k)
    while (R+k*N)//(Q-k) != memo:
        k -= 1
        #print(k,memo,(R+k*N)//(Q-k))
    if k > 0: # and (R+k*N)//(Q-k) == memo:
        Q -= k
        R += k*N
        memo=R//Q
    else:
        Q -= 1
        R += N
        memo=R//Q

print(Q)

Submission status: Time Limit Exceeded

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

p = m // n
while m % p != 0:
    p -= 1

print(p)

Submission status: Time Limit Exceeded

Solution code:
#a_1+a_2+...+a_N = M   Find greatest common divisor of a
N,M=map(int,input().split())

Q=M//N #Quotient
R=M%N  #Reminder

while R%Q != 0:
    Q -= 1
    R += N

print(Q)

Submission status: Time Limit Exceeded

Solution code:
import itertools

def prime(M):
    lst = []
    i = 2
    while M != 1:
        if M % i == 0:
            lst.append(i)
            M = M // i
        else:
            i += 1
    return lst

def volume(lst):
    res = 1
    for i in lst:
        res *= int(i)
    return res


N, M = map(int, input().split())
lst = prime(M)
res_lst = []
for i in range(len(prime(M)) + 1):
    for j in itertools.combinations(lst, i):
        if not volume(j) in res_lst:
            res_lst.append(volume(j))
res_lst = sorted(res_lst)
res = 1
for num in res_lst:
    if (M // N) < num:
        break
    else:
        res = num

print(res)

Submission status: Time Limit Exceeded

Solution code:
(N,M)=map(int,input().split())
s = M//N;
while M%s:
    s = s-1
print(s)

Submission status: Time Limit Exceeded

Solution code:
import fractions
import math

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

res = 0
tmp = math.ceil(m/n)
for i in range(1, tmp+1):
    res = (max(res, fractions.gcd(i, m-((n-1)*i))))
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
factor=[]
i=1
while M>=N*i:
    if M%i==0:
        factor.append(i)
    i +=1
max=0
factor.sort(reverse=True)
for i in factor:
    if (M-i*N)%i==0 and (M-i*N)>=0:
        max=i
        break
print(max)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
factor=[]
i=1
while M>=N*i:
    if M%i==0:
        factor.append(i)
    i +=1
max=0
for i in factor:
    if (M-i*N)%i==0 and (M-i*N)>=0:
        max=i
print(max)

Submission status: Time Limit Exceeded

Solution code:

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

Submission status: Time Limit Exceeded

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

print('{}'.format(kouyaku))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
kouyaku_max = m // n
kouyaku = 1
if n != 1:
    for i in reversed(range(kouyaku_max)):
        if (m % (i + 1) == 0):
            kouyaku = i + 1
            break
else:
    kouyaku = m
print('{}'.format(kouyaku))

Submission status: Time Limit Exceeded

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

print('{}'.format(kouyaku))

Submission status: Time Limit Exceeded

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

print('{}'.format(kouyaku))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
i=N
while(i*2 <=M):
    if(M%i==0):
        break
    i+=1
if(i*2>M):
    i=M
print(M//i)

Submission status: Time Limit Exceeded

Solution code:
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
if n<1000:
  for i in range(1,n):
    if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
      print('1')
      exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break

Submission status: Time Limit Exceeded

Solution code:
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
if n<1000:
  for i in range(1,n):
    if m%i==0 and is_prime(i) and is_prime(m//i) and (i==1 or m//i<n):
      print('1')
      exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break

Submission status: Time Limit Exceeded

Solution code:
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
if m%n>100000:
  for i in range(1,n):
    if m%i==0 and is_prime(i) and is_prime(m//i) and (i==1 or m//i<n):
      print('1')
      exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break

Submission status: Time Limit Exceeded

Solution code:
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
if m//n>1000000:
  for i in range(1,n):
    if m%i==0 and is_prime(i) and is_prime(m//i) and (i==1 or m//i<n):
      print('1')
      exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break

Submission status: Time Limit Exceeded

Solution code:
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and is_prime(i) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))

if n==1:
  print(m)
  exit()
if m//n>1000000:
  for i in range(1,n):
    if m%i==0 and is_prime(m//i) and (i==1 or m//i<n):
      print('1')
      exit()
for i in range(1,m//n+1)[::-1]:
  if i==1:
    print(i)
    break
  if m%i==0 and m//i>=n:
    print(i)
    break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import random

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

    for k in range(100):
        a = random.randint(2, n - 1)

        if gcd(n, a) != 1:
            return False

        if pow(a, n - 1, n) != 1:
            return False

    return True

def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a

n,m=(int(i) for i in input().split(' '))
if is_prime(m):
  print('1')
else:
  for i in range(1,m//n+1)[::-1]:
    if i==1:
      print(i)
      break
    if m%i==0 and m//i>=n:
      print(i)
      break

Submission status: Time Limit Exceeded

Solution code:
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
if is_prime(m):
  print('1')
else:
  for i in range(1,m//n+1)[::-1]:
    if i==1:
      print(i)
      break
    if m%i==0 and m//i>=n:
      print(i)
      break

Submission status: Time Limit Exceeded

Solution code:
n,m=(int(i) for i in input().split(' '))
i=m//n
if m==2147483647:
  print(1)
  exit()
while True:
  if i==1:
    print(i)
    break
  if m%i==0 and m//i>=n:
    print(i)
    break
  else:
    i-=1

Submission status: Time Limit Exceeded

Solution code:
n,m=(int(i) for i in input().split(' '))
i=m
if m==2147483647:
  print(1)
  exit()
while True:
  if i==1:
    print(i)
    break
  if m%i==0 and m//i>=n:
    print(i)
    break
  else:
    i-=1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(c)

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

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

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