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: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
def yak1(n,m):
  l=[]
  for i in range(1,min(int((m)**1/2),m//n)+1):
    if m%i==0:
      l.append(i)
      if m//(m//i)!=m/i and m//(m//i)>=m/n:
        l.append(m//i)
  return l
print(max(yak1(n,m)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

# Mの約数dのうち、Nd <= Mとなるものの最大

divisors = []
for d in range(1, M+1):
    if d*d > M:
        break
    divisors.append(d)
    divisors.append(M//d)

ans = 1

for d in divisors:
    if N*d <= M:
        ans = d

print(ans)

Submission status: Runtime Error

Solution code:
import sys
import collections
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()
for i in range(2, n + 1):
    if m % i == 0 and m // i >= n:
        ans = i
print(ans)

Submission status: Runtime Error

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

Solution code:
N, M = map(int, input().split())
L = M // N
A = [1]

A = [i for i in range(2, L + 1) if (M - i * N) % i == 0]
print(A[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,m=map(int,input().split())
if m%n==0:
  print(int(m/n))
else:
  print(gcd(m%n,m)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
n, m = [int(item) for item in input().split()]

ans = 1
for i in range(1, int(math.sqrt(m))+1):
  if m%i == 0 
    if m >= i*n:
      ans = max(ans, i)
    else:
      ans = max(ans, m%i)
    
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    else:
      s=N
      while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    if N<rM:
      nya-n
      
    print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    if ans==1:
      nya-n
      
    print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    else:
      nya-n
    print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    nya-n
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    print(ans)

Submission status: Runtime Error

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

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1:
            if (len(h0) > 0 and min(h0) >= list(hc)[0]) or len(h0) == 0:
                print(x, y, list(hc)[0])
                break

Submission status: Runtime Error

Solution code:

# coding: utf-8

# In[12]:


import numpy as np


# In[65]:


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


# In[66]:


def usage(n):
    print('# 素因数')
    fct = factorize(n)
    print(fct, num(fct))
    
    print('# 約数')
    for div in divisorize(fct):
        print(div, num(div))


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


# In[67]:


def func(n):
    fct = factorize(n)
    ret = []
    for div in divisorize(fct):
        ret.append(num(div))
    
    return ret


# In[68]:


div = np.array(func(M))


# In[69]:


print(div[div < M/N].max())

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':


def divisors(p, q):
	ans = []
	if q == 1:
		ans = [1]
	else:
		for i in range(2, q // p + 1):
			if q % i == 0:
				ans.append(i)
	return(ans)

N, M = map(int, input().rstrip().split())
print(divisors(N, M)[-1])

Submission status: Runtime Error

Solution code:
100000 1000000000

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fraction
# import math
n,m=map(int,input().split())
# 1*mのうちnコを予め除いた残りで組み合わせの数を求められる
# (m-n+n-1)!/((m-n)!(n-1)!)
if m%n==0:
    print(m//n)
else:
    print(fraction.gcd(m//n,m%n))
    # print(math.gcd(m//n,m%n))

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
# 1*mのうちnコを予め除いた残りで組み合わせの数を求められる
# (m-n+n-1)!/((m-n)!(n-1)!)
if m%n==0:
    print(m//n)
else:
    print(math.gcd(m//n,m%n))

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
# 1*mのうちnコを予め除いた残りで組み合わせの数を求められる
# (m-n+n-1)!/((m-n)!(n-1)!)
if n%m==0:
    print(m//n)
else:
    print(math.gcd(m//n,m%n))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

for i in range(1, math.ceil(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if m // i > n:
        continue
    ans = i
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

for i in range(1, int(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if i > m // n:
        continue
    ans = i
print(ans)

Submission status: Runtime Error

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

for i in range(1, int(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if i > m // n:
        continue
    ans = i
print(ans)

Submission status: Runtime Error

Solution code:
def s(n):
    return[m(t)for t in d(f(n))]
def f(n):
    l=[]
    b,e=2,0
    while b*b<=n:
        while not n%b:
            n//=b
            e+=1
        if e:
            l.append((b,e))
        b,e=b+1,0
    if n>1:
        l.append((n,1))
    return l
def d(l):
    b,e=l.pop()
    p=d(l)if l else[[]]
    v=[[(b,k)]for k in range(e+1)]
    return[s+t for s in p for t in v]
def m(l):
    a=1
    for b,e in l:
        a*=b**e
    return a
N,M=map(int,input().split())
a=0
for i in sorted(s(M))[::-1]:
    if M//i>=N:
        a=i
        break
print(a)

Submission status: Runtime Error

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

if N==1:
  print(M)
  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: Runtime Error

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

Submission status: Runtime Error

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

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

if tmp==1:
  else:
    print(1)

Submission status: Runtime Error

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

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

if tmp==1:
else:
  print(1)

Submission status: Runtime Error

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

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

print(1)

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

a = M//N
b = M%N    
    
print(math.gcd(a,b))

Submission status: Runtime Error

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

sei = M // N
yo = M % N
print(math.gcd(sei, yo))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

i=1
while i*i < M and i <= M//N:
  if M % i == 0:
    maxg = i
  i += 1

print(maxg)

Submission status: Runtime Error

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

i=1
while i*i < M:
  if M % i == 0:
    maxg = M // N
  i += 1

print(maxg)

Submission status: Runtime Error

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

if N == 1:
    print(M)
else:
    ans = 1
    for g in range(1, int(M ** 0.5) + 1):
        if M % g == 0 and M / g >= N:
            ans = g
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(5000000)

primes = []
MAX_NUM = 100000
is_prime = [True] * MAX_NUM
is_prime[0] = False
is_prime[1] = False
for num in range(MAX_NUM):
    if is_prime[num]:
        primes.append(num)
        for j in range(2*num, MAX_NUM, num):
            is_prime[j] = False

def do_prime_factorization(x):
    ps = []
    i = 0
    n = len(primes)
    while (x > 1) and (i < n):
        p = primes[i]
        while x % p == 0:
            x /= p
            ps.append(p)
        i += 1
    if x > 1:
        ps.append(p)
    res = {}
    for p in ps:
        if not p in res:
            res[p] = 0
        res[p] += 1
    return res

def f(x, d, n, m, ps):
    if x >= n:
        return x
    if d >= len(ps):
        return m
    p, num = ps.items()[d]
    res = m
    for i in range(num+1):
        y = x * (p**i)
        res = min(res, f(y, d+1, n, m, ps))
    return res

def solve(n, m):
    ps = do_prime_factorization(m)
    q = f(1, 0, n, m, ps)
    assert m % q == 0, (m, q)
    p = m // q
    return p

n, m = map(int, raw_input().split())
print(solve(n, m))

Submission status: Runtime Error

Solution code:
primes = []
MAX_NUM = 100000
is_prime = [True] * MAX_NUM
is_prime[0] = False
is_prime[1] = False
for num in range(MAX_NUM):
    if is_prime[num]:
        primes.append(num)
        for j in range(2*num, MAX_NUM, num):
            is_prime[j] = False

def do_prime_factorization(x):
    ps = []
    i = 0
    n = len(primes)
    while (x > 1) and (i < n):
        p = primes[i]
        while x % p == 0:
            x /= p
            ps.append(p)
        i += 1
    if x > 1:
        ps.append(p)
    res = {}
    for p in ps:
        if not p in res:
            res[p] = 0
        res[p] += 1
    return res

def f(x, d, n, m, ps):
    if x >= n:
        return x
    if d >= len(ps):
        return m
    p, num = ps.items()[d]
    res = m
    for i in range(num+1):
        y = x * (p**i)
        res = min(res, f(y, d+1, n, m, ps))
    return res

def solve(n, m):
    ps = do_prime_factorization(m)
    q = f(1, 0, n, m, ps)
    assert m % q == 0, (m, q)
    p = m // q
    return p

n, m = map(int, raw_input().split())
print(solve(n, m))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

upper=M/N
def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def divisorize(fct):
    b, e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

fct = factorize(M)

Ans=1
for div in divisorize(fct):
    if num(div)<=upper:
        Ans=max(Ans,num(div))
   
print Ans

Submission status: Runtime Error

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

upper=M/N
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
# 素因数
fct = factorize(M)
# 約数
Ans=1
for div in divisorize(fct):
    if num(div)<=upper:
        Ans=max(Ans,num(div))
   
print Ans

Submission status: Runtime Error

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

upper=M/N

for i in range(upper):
    if M%(upper-i)==0:            
        print upper-i
        exit()

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
gcd = m//n
while n*gcd != m:
  gcd = M//n
  n = 1 + (M-1)//gcd
print(gcd)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
gcd = m//n
while n*gcd != m:
  n = 1 + (M-1)//gcd
  gcd = M//n
print(gcd)

Submission status: Runtime Error

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)) forl 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: Runtime Error

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)):
    for com in itertools.combinations(f, i):
        tmp = 1
        for c in com:
            tmp *= c
        if tmp >= N:
            ans_list.append(M//tmp)

print(max(ans_list))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
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

if len(primes(M)) <= 1:
    print(1)
    exit()

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

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

print(1)

Submission status: Runtime Error

Solution code:
#include <cstdio>
#include <vector>
using namespace std;

vector<int> divisor(int m) {
    vector<int> divs;
    for (int i = 1; i*i <= m; i++) {
        if (m % i == 0) {
            divs.push_back(i);
            if (m != i*i) {
                divs.push_back(m / i);
            }
        }
    }
    sort(divs.begin(), divs.end());

    return divs;
}

int main() {
    int n, m;

    scanf("%d%d", &n, &m);
    vector<int> divs = divisor(m);

    for (int i = divs.size()-1; i >= 0; i--) {
        if (divs[i] * n <= m) {
            printf("%d\n", divs[i]);
            break;
        }
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set)
    print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

    return

if __name__ == "__main__":
main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)

def search_max_gcd(M, possible):
    if possible == 1:
        return 1
    elif (M % possible) == 0:
        return possible
    else:
        return search_max_gcd(M, possible-1)

def main():
    N, M = map(int, input().split())
    first_possible = M//N
    print(search_max_gcd(M, first_possible))

main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**10)

def search_max_gcd(M, possible):
    if possible == 1:
        return 1
    elif (M % possible) == 0:
        return possible
    else:
        return search_max_gcd(M, possible-1)

def main():
    N, M = map(int, input().split())
    first_possible = M//N
    print(search_max_gcd(M, first_possible))

main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)

def search_max_gcd(M, possible):
    if possible == 1:
        return 1
    elif (M % possible) == 0:
        return possible
    else:
        return search_max_gcd(M, possible-1)

def main():
    N, M = map(int, input().split())
    first_possible = M//N
    print(search_max_gcd(M, first_possible))

main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)

def search_max_gcd(M, possible):
    if possible == 1:
        return 1
    elif (M % possible) == 0:
        return possible
    else:
        return search_max_gcd(M, possible-1)

def main():
    N, M = map(int, input().split())
    first_possible = M//N
    print(search_max_gcd(M, first_possible))

main()

Submission status: Runtime Error

Solution code:
def search_max_gcd(M, possible):
    if possible == 1:
        return 1
    elif (M % possible) == 0:
        return possible
    else:
        return search_max_gcd(M, possible-1)

def main():
    N, M = map(int, input().split())
    first_possible = M//N
    print(search_max_gcd(M, first_possible))

main()

Submission status: Runtime Error

Solution code:
def search_max_gcd(M, possible):
    if (M % possible) == 0:
        return possible
    elif possible == 1:
        return 1
    else:
        return search_max_gcd(M, possible-1)

def main():
    N, M = map(int, input().split())
    first_possible = M//N
    print(search_max_gcd(M, first_possible))

main()

Submission status: Runtime Error

Solution code:
import math
n,m=list(map(int,input().split()))
lim=(int)(2*m/((n-1)*(n)))
for i in reversed(range(1,lim+2)):
    a=m%i
    b=m/i
    if a==0 and b>=n:
        x=(int)(n/3+1)
        for j in range(1,x):
            for k in range(1,x):
                for l in range(1,x):
                    if j+k+l==n:
                        print(j*2)
                        exit()

Submission status: Runtime Error

Solution code:
import math
n,m=list(map(int,input().split()))
lim=(int)(2*m/((n-1)*(n)))
for i in reversed(range(1,lim+2)):
    a=m%i
    b=m/i
    print(i,a,b,n)
    if a==0 and b>=n:
        for j in range(1,(int)(n/3+1)):
            if(math.factorial(b-2)
                    /(math.factorial(n-j-1)*math.factorial(b-n+j-1))>0):
                print(j*i)
                exit()

Submission status: Runtime Error

Solution code:
import fractions

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: Runtime Error

Solution code:
N,M=map(int,input().split())
import math
i=M//N
g=M%N
print(math.gcd(i,g))

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import math

n, m = map(int, input().split())
kouyaku_max = min(m // n, math.floor(sqrt(m))+1)
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: Runtime Error

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

    kouyaku_max = min(m//n, math.sqrt(m))
    kouyaku = 1
    for i in reversed(range(kouyaku_max)):
        if(m%(i+1) == 0):
            kouyaku = i+1
            break

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

Submission status: Runtime Error

Solution code:
n, m = map(int,input().split())
if n ==1:
    kouyaku = m
else:

    kouyaku_max = min(m//n, sqrt(m))
    kouyaku = 1
    for i in reversed(range(kouyaku_max)):
        if(m%(i+1) == 0):
            kouyaku = i+1
            break

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

Submission status: Runtime Error

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: Runtime Error

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>10000:
  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%(m-i+1)==0
    print(m-i+1)
    break

Submission status: Runtime Error

Solution code:
print(n)