Problem:


Score : 400 points

Problem Statement

You are given integers N and M.

Consider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

N \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

Print the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.

Sample Input 1

3 14

Sample Output 1

2

Consider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.

Sample Input 2

10 123

Sample Output 2

3

Sample Input 3

100000 1000000000

Sample Output 3

10000



Sample input:
3 14


Sample output:
2

Submission status: Wrong Answer

Solution code:
# abc112_c

def gcd (a, b):
    if (b == 0):
        return a
    else:
         return gcd (b, a % b)

def gcd_from_list (input_arr):
    res = 1
    if len(input_arr)>0:
        res = input_arr[0]
        for c in input_arr[1::]:
            res = gcd(res, c)
    return res

def sum (arr):
    sum = 0
    for i in arr:
        sum += i
    return sum

def find_seq(N, M):
    sequences = []
    seq = []
    i = 1

    # populate initial list
    while len(seq) < N and i < M:
        seq.append(i)
        i += 1

    index = len(seq) - 1  # from right to left
    jump = index
    while index >= 0:
        total = sum(seq)
        if len(seq) == N and total == M: # we found it
            sequences.append(seq.copy())
            seq[index-1] = seq[index-1] + 1
            seq[index] = seq[index - 1] + 1
        else:
            if total < M:
                seq[index] = seq[index] + 1
            elif total > M:
                jump = jump - 1
                if jump > 0:
                    seq[jump-1] = seq[jump-1] + 1
                    seq[jump] = seq[jump-1] + 1
                    seq[jump + 1] = seq[jump] + 1
                if jump < index - 1:
                    index -= 1

    return sequences

def main ():
    N, M = map(int, input("").split())      # read input
    sequences = find_seq(N, M)              # find seq
    #print(sequences)
    max_gcd = 1                             # find gcd
    for seq in sequences:
        gcd = gcd_from_list(seq)
        if gcd > max_gcd:
            max_gcd = gcd

    print("{}".format(max_gcd))
    

if __name__ == "__main__": main()

Submission status: Wrong Answer

Solution code:
from math import sqrt
n,m = map(int,input().split())

if m%n==0:
	print(m//n)
else:
	ans = [1]
	for i in range(2,int(sqrt(m))+1):
		if m%i==0 and m//i>=n:
			ans.append(i)
		if m%i==0 and m//i<n:
			ans.append(m//i)
	print(max(ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

N, M = [int(s) for s in input().strip().split()]

if N == 1:
    print(M)
    exit()

ROOT_M = int(math.sqrt(M))
divisors = []
for d in range(1, ROOT_M+1):
    if M % d == 0:
        divisors.append(d)
        divisors.append(M//d)

max_gcd = max([d for d in divisors if d > M/N])
print(max_gcd)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

N, M = [int(s) for s in input().strip().split()]

if N == 1:
    print(M)
    exit()

max_gcd = -1
ROOT_M = int(math.sqrt(M))

for d in range(1, ROOT_M+1):
    if d > M/N:
        break

    if M % d == 0:
        max_gcd = d

print(max_gcd)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

N, M = [int(s) for s in input().strip().split()]

if N == 1:
    print(M)
    exit()

max_gcd = -1
ROOT_M = int(math.sqrt(M))

for d in range(1, ROOT_M):
    if d > M/N:
        break

    if M % d == 0:
        max_gcd = d

print(max_gcd)

Submission status: Wrong Answer

Solution code:
from math import sqrt

def gcd(a, b):
    """Calculate the Greatest Common Divisor of a and b.

    Unless b==0, the result will have the same sign as b (so that when
    b is divided by it, the result comes out positive).
    """
    while b:
        a, b = b, a%b
    return a

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

if m%n==0:
	print(m//n)
else:
	mx = 1
	for i in range(2,int(sqrt(m))+2):
		# ~ print(i,((m-i)//(n-1))>=n-1)
		if m%i==0:
			mx = i
	print(mx)

Submission status: Wrong Answer

Solution code:
from math import sqrt

def gcd(a, b):
    """Calculate the Greatest Common Divisor of a and b.

    Unless b==0, the result will have the same sign as b (so that when
    b is divided by it, the result comes out positive).
    """
    while b:
        a, b = b, a%b
    return a

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

if m%n==0:
	print(m//n)
else:
	mx = 1
	for i in range(2,int(sqrt(m))+2):
		# ~ print(i,((m-i)//(n-1))>=n-1)
		if (m-i)%i==0 and ((m-i)//(n-1))>=(n-1) and i>mx:
			mx=i
	print(mx)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    """Calculate the Greatest Common Divisor of a and b.

    Unless b==0, the result will have the same sign as b (so that when
    b is divided by it, the result comes out positive).
    """
    while b:
        a, b = b, a%b
    return a

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

if m%n==0:
	print(m//n)
else:
	mx = 1
	for i in range(2,n):
		# ~ print(i,((m-i)//(n-1))>=n-1)
		if (m-i)%i==0 and ((m-i)//(n-1))>=(n-1) and i>mx:
			mx=i
	print(mx)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
r = M / N
if N > 1:
    for i in range(min(int(np.sqrt(M)), int(r)), 0, -1):
        if M % i == 0:
            print(i)
            exit()
else:
    print(M)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
r = M / N
for i in range(min(int(np.sqrt(M)), int(r)), 0, -1):
    if M % i == 0:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    """Calculate the Greatest Common Divisor of a and b.

    Unless b==0, the result will have the same sign as b (so that when
    b is divided by it, the result comes out positive).
    """
    while b:
        a, b = b, a%b
    return a

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

if m%n==0:
	print(m//n)
else:
	print(gcd(m//n,m//n+m%n))

Submission status: Wrong Answer

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

if m%n==0:
	print(m//n)
else:
	print(m%n)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

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

def factorize(x):
    fac = []
    i = 2
    done = False
    while done==False:
        if (x % i) == 0:
            fac.append(i)
            x = x/i
            if x == 1:
                done = True 
        else:
            i += 1
    return fac

fac = sorted(factorize(M))

mul = set()
for L in range(1, len(fac)+1):
    for subset in itertools.combinations(fac, L):
        mul.add(np.prod(subset))
mul = sorted(list(mul))
#print(mul)

thres = int(M/N)
for i in range(len(mul)):
   if mul[i] > thres:
       print(mul[i-1])
       break

Submission status: Wrong Answer

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

def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) ):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    return sorted(divisors, reverse=reverse)


divisors = enum_divisors(M)
divisors = filter(lambda x: x >= N, divisors)

for cand in divisors:
    if M % cand == 0:
        print( M //cand )
        exit()

Submission status: Wrong Answer

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

def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) ):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    return sorted(divisors, reverse=reverse)


divisors = enum_divisors(M, reverse=True)
divisors = filter(lambda x: x <= M//N, divisors)

for cand in divisors:
    if M % cand == 0:
        print(cand)
        exit()

Submission status: Wrong Answer

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

def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) ):
        if n % i == 0:
            divisors.append(i)
            if i != 1 and i * i != n:
                divisors.append(n//i)
    return sorted(divisors, reverse=reverse)
 
divisors = enum_divisors(M, reverse=True)
divisors = filter(lambda x: x <= M//N, divisors)
 
for cand in divisors:
    if M % cand == 0:
        print(cand)
        exit()

Submission status: Wrong Answer

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

def enum_divisors(n, reverse=False):
    divisors = []
    for i in range(1, int(math.sqrt(n)) ):
        if n % i == 0:
            divisors.append(i)
            if i != 1 and i * i != n:
                divisors.append(n//i)
    return sorted(divisors, reverse=reverse)


divisors = enum_divisors(M, reverse=True)
print()
divisors = filter(lambda x: x <= M//N, divisors)

cand = M // N

for cand in divisors:
    if M % cand == 0:
        print(cand)
        exit()

Submission status: Wrong Answer

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

def listpord(numlist):
    ret=1
    for i in numlist:
        ret *= i
    return ret

def all_possible_combinations(seq):
    conbinations=[]
    for i in range(len(seq)):
        conbinations += list(itertools.combinations(seq, i+1))
    return conbinations

def factorize_into_prime_factors(n):
    prime_factors = []
    i = 2
    while i ** 2 <= n:
        while True:
            quo, mod = divmod(n, i)
            if mod == 0:
                n = quo
                prime_factors.append(i)
            else:
                break
        i += 1
    if n > 1:
        prime_factors.append(n)
    return prime_factors

m_factors = factorize_into_prime_factors(M)
conb = all_possible_combinations(m_factors)
candlist=[]
for item in conb:
    candlist.append(listpord(item))
#unique
candlist=list(set(candlist))
candlist_ = list(filter(lambda x: x <= M // N, candlist))
candlist_.sort(reverse=True)

for cand in candlist_:
    if M % cand == 0:
        print(cand)
        exit()

Submission status: Wrong Answer

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

def listpord(numlist):
    ret=1
    for i in numlist:
        ret *= i
    return ret

def all_possible_combinations(seq):
    conbinations=[]
    for i in range(len(seq)):
        conbinations += list(itertools.combinations(seq, i+1))
    return conbinations

def factorize_into_prime_factors(n):
    prime_factors = []
    i = 2
    while i ** 2 <= n:
        while True:
            quo, mod = divmod(n, i)
            if mod == 0:
                n = quo
                prime_factors.append(i)
            else:
                break
        i += 1
    if n > 1:
        prime_factors.append(n)
    return prime_factors

m_factors = factorize_into_prime_factors(M)
conb = all_possible_combinations(m_factors)
candlist=[]
for item in conb:
    candlist.append(listpord(item))
#unique
candlist=list(set(candlist))
candlist_ = list(filter(lambda x: x <= M // N, candlist))
candlist.sort(reverse=True)

for cand in candlist_:
    if M % cand == 0:
        print(cand)
        exit()

Submission status: Wrong Answer

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

while cand > 0:
    print(cand)
    if M % cand == 0:
        #print(cand)
        exit()
    cand -= 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,m=(int(i) for i in input().split())
p = min(math.sqrt(m),int(m/n))
while p>1:
    if m%p==0 and m>=n*p:
        break
    p-=1
print(p)

Submission status: Wrong Answer

Solution code:
import math
n,m=(int(i) for i in input().split())
p = int(math.sqrt(m))
while p>1:
    if m%p==0 and m>=n*p:
        break
    p-=1
print(p)

Submission status: Wrong Answer

Solution code:
import math

#mの約数のうち、n以上の最小の約数でmを割った商が答え
inn,inm = list(map(int,input().split()))
root = math.floor(math.sqrt(inm))

a = []
for i in range(1,root+1):
  if inm%i == 0:
    a.append(i)
    a.append(inm/i)
    
a.sort()
for i in a:
  if i > inn:
    print(int(inm/i))
    break

Submission status: Wrong Answer

Solution code:
import math

#mの約数のうち、n以上の最小の約数でmを割った商が答え
inn,inm = list(map(int,input().split()))
rootm = math.floor(math.sqrt(inm))

prea = inm
for i in range(1,rootm+1):
  if inm % i == 0:
    if inn < i:
      ans = i
      break
    if inn > inm/i:
      ans = prea
      break
    prea = inm/i
  if i == rootm:
    ans = prea
print(int(inm/ans))

Submission status: Wrong Answer

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

# 約数列挙
divisor = []
for i in range(1, int(M ** 0.5) + 1):
    if M % i == 0:
        divisor.append(i)

ans = 0
for d in divisor:
    if M // d >= N:
        ans = max(ans, d)

print(ans)

Submission status: Wrong Answer

Solution code:
# nの約数を求める
def divisor(n):
    d = []
    for i in range(int(n**(0.5)+1))[1:]:
        if n % i == 0:
            d.append(i)
            if i * i != n:
                d.append(n / i)
    return d


N, M = map(int, input().split())
# d はnの約数のベクター
d = divisor(M)
g = M / N
d = [x for x in d if x <= g]
print(max(d))

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
root_m = int(math.sqrt(m) + 1)
ans = 1
for a in range(1, root_m):
    # print(a, ans)
    b = m // a
    if a * n <= m:
        ans = max(ans, a)
    if b * n <= m:
        ans = max(ans, b)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
root_m = int(math.sqrt(m))
ans = 1
for a in range(1, root_m):
    # print(a, ans)
    if m % a == 0:
        b = m / a
        if a * n <= m:
            ans = max(ans, a)
        if b * n <= m:
            ans = max(ans, b)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

max = m//n

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math


def main():
    n, m = map(int, input().split())
    for i in range(int(math.sqrt(m)) + 1, 1, -1):
        if m % i != 0:
            continue
        if n * i > m:
            continue
        print(i)
        return


main()

Submission status: Wrong Answer

Solution code:
import sys
n,m=map(int,input().split())
if n==1:
    print(m)
    sys.exit()
ans=[]
i=1
while i<=m/i:
    if m%i:
        i+=1
    else:
        j=m/i
        if j>=n:
            ans.append(i)
        if i>=n:
            ans.append(j)
        i+=1
ans.sort()
print(ans[len(ans)-1])

Submission status: Wrong Answer

Solution code:
import sys
n,m=map(int,input().split())
if n==1:
    print(m)
    sys.exit()
ans=[]
i=1
while i<=m/i:
    if m%i:
        i=i+1
    else:
        j=m/i
        if j>=n:
            ans.append(i)
        if i>=n:
            ans.append(j)
        i=i+1
ans.sort()
print(ans[len(ans)-1])

Submission status: Wrong Answer

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

if N < 11:
    print(0)
    exit()

k=1
while M / k >= N:
    if M % k == 0:
        t = k
    k += 1

print(t)

Submission status: Wrong Answer

Solution code:
# coding:utf-8


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


N, M = inpl()

d = 1
ans = 1
while d * d <= M:
    # 約数判定
    if M % d != 0:
        d += 1
        continue
    # dはM // N以下
    if d * N <= M:
        ans = max(ans, d)

    d += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import math


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


N, M = inpl()

d = min(int(math.sqrt(M)), M // N)
while d > 1:
    if M % d == 0:
        break
    d -= 1

print(d)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
can = []
for i in range(1, M+1):
	if M % i == 0:
		if i <= N:
			can.append(i)
		else:
			break

print(max(can))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N,M=[int(i) for i in input().split()]
sqrt=math.sqrt(M)
sqrt_=int(sqrt)
l=M//N
A=[]
if sqrt<=l:
    for i in range(1,l+1):
        if M%i==0:
            A.append(i)
        else:
            continue
else:
    for i in range(1,sqrt_+1):
        if M%i==0:
            A.append(i)
        else:
            continue
print(max(A))

Submission status: Wrong Answer

Solution code:
import math
N,M=[int(i) for i in input().split()]
sqrt=math.sqrt(M)
l=min(int(sqrt),int(M//N))
A=[]
for i in range(1,l+1):
    if M%i==0:
        A.append(i)
    else:
        continue
print(max(A))

Submission status: Wrong Answer

Solution code:
import sys

N, M = sys.stdin.readline().strip().split()
N = int(N)
M = int(M)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
res = 1
max_res = m//n
for i in range(2, math.ceil(math.sqrt(m)) + 1):
  if m % i == 0:
     if i <= max_res:
        res = max(res, i)
     x = m//i
     if x <= max_res:
        res = max(res, x)
print(res)

Submission status: Wrong Answer

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

def IsPrime(num):
    if num < 2:
        return False
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False

    sqrtNum = math.sqrt(num)
    for i in (3, sqrtNum + 1, 2):
        if num % i == 0:
            return False

    return True

if IsPrime(m):
    print(1)
    exit()


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

print(ans)

Submission status: Wrong Answer

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

i = 1
ans = 1
waru = M//N

if M%N == 0:
    ans = max(ans,M//N)

while M >= i*i:
    if M%i == 0:
        if waru >= i:
            ans = max(ans,i)
    i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        i = 1
        while i*i <= num:
            if num%i == 0:
                divisor_list.append(i)
                divisor_list.append(num//i)

            i += 1
        divisor_list.append(num)

        return sorted(set(divisor_list))


def bin_search(L,Target):
    left = 0
    righ = len(L)

    i = 0
    while left < righ:

        mid  = (left + righ) //2

        if L[mid] <= Target <= L[mid+1]:
            break
        elif L[mid] <= Target:
            left = mid
            righ = righ
        else:
            left = left
            righ = mid

    return mid

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

if N == 1:
    print(M)
elif N == M:
    print(1)
else:
    Target = N
    L = make_divisor_list(M)

    mid = bin_search(L,Target)

    ans = M//L[mid+1]
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = 1
ans = 1
while i ** 2 <= M:
    if M % i == 0:
        if i * N <= M:
            ans = max(i, ans)
        x = M / i
        if x  * N <= M:
            ans = max(x, ans)
    
    i += 1

print(ans)

Submission status: Wrong Answer

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

i = 2
ans = 0
while i ** 2 <= M:
    if M % i == 0:
        if i * N <= M:
            ans = max(i, ans)
        x = M / i
        if x  * N <= M:
            ans = max(x, ans)
    
    i += 1

print(ans)

Submission status: Wrong Answer

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

i = 1
ans = 0
while i ** 2 <= M:
    if M % i == 0:
        if i * N <= M:
            ans = max(i, ans)
        x = M / i
        if x  * N <= M:
            ans = max(x, ans)
    
    i += 1

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n%m == 0:
    print(int(m/n))
else:
    print(m%n)

Submission status: Wrong Answer

Solution code:
import numpy as np
from math import sqrt
N,M = map(int,input().split()) 
L = np.arange(int(sqrt(M))+1,dtype = int)
L = sorted(L,reverse = True)
for i in L :
    if M % i == 0 :
        if i*N <= M :
            print(i)
            break

Submission status: Wrong Answer

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

answer = 1
list = []
for i in range(2,math.floor(M**(1/2))+1):
    if M % i == 0 and int(M/i) >= N:
        answer = i
        list.append(int(M/i))


for k in list:
    if M/k >= N:
        answer = k
        break

print(answer)

Submission status: Wrong Answer

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

ans = 1

a = 1

while(a * a <= m):

    if m % a != 0:
        a += 1
        continue
    
    b = m / a

    if a * n <= m:
        ans = max(ans, a)
    if b * n <= m:
        ans = max(ans, b)
    
    a += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt
import numpy as np
N,M = map(int,input().split())
L = np.arange(sqrt(M)+1,dtype = int)
L = sorted(L,reverse = True)
for j in L :
    if M % j == 0 :
        if j * N <= M :
            print(j)
            break

Submission status: Wrong Answer

Solution code:
from math import sqrt
import numpy as np
N,M = map(int,input().split())
L = [i for i in range(0,int(sqrt(M))+1)]
L = sorted(L,reverse = True)
for j in L :
    if M % j == 0 :
        if j * N <= M :
            print(j)
            break

Submission status: Wrong Answer

Solution code:
from math import sqrt
import numpy as np
N,M = map(int,input().split())
L = [i for i in range(1,int(sqrt(M))+1)]
L = sorted(L,reverse = True)
for j in L :
    if M % j == 0 :
        if j * N <= M :
            print(j)
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# encoding: utf-8
import math
N, M = map(int, input().split())

rM = int(math.sqrt(M))

pairs = []
for a in range(2, rM + 1):
    if M % a == 0: pairs.append((a, M // a))

# a_i = p * b_i
# b_1 + b_2 + ... = m
p_max = 0
for m, p in filter(lambda x: x[0] >= N, pairs):
    if p > p_max: p_max = p

for p, m in filter(lambda x: x[1] >= N, pairs):
    if p > p_max: p_max = p

print(p_max)

Submission status: Wrong Answer

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

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

# 速度調整版
def primes(n):
    sq = int(math.sqrt(n)+1)
    ss = 30030
    a = [None] * (ss)
    a[0] = 1
    t = 1
    for i in range(2,ss):
        if not a[i] is None:
            continue
        if t * i > ss:
            break
        t *= i
        for j in range(i*2,ss,i):
            a[j] = 1
    a = [i for i in range(t) if a[i] is None]
    d = collections.defaultdict(int)
    for i in a[1:]:
        while n % i == 0:
            n //= i
            d[i] += 1

    for j in range(1,sq//t+2):
        if j > n:
            break
        for ii in a:
            i = t*j+ii
            while n % i == 0:
                n //= i
                d[i] += 1

    return d

# 約数をすべて返す
def divisions(n):
    d = primes(n)

    r = [1]
    for k, v in d.items():
        for c in r[:]:
            for i in range(1,v+1):
                r.append(c*(k**i))

    return sorted(r)


def main():
    n,m = LI()
    d = divisions(m)
    r = 1
    for c in d:
        if c * n > m:
            break
        r = c

    return r


print(main())

Submission status: Wrong Answer

Solution code:

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def fs(n):
    f = Counter()
    for i in range(2, math.ceil(math.sqrt(n)) + 1):
        if i > n:
            break
        while n % i == 0:
            f[i] += 1
            n /= i
    if int(n) != 1:
        f[int(n)] = 1
    return f

@mt
def slv(N, M):
    ans = 1
    for m in range(2, math.ceil(math.sqrt(M))+1):
        if M % m != 0:
            continue
        
        if  N*m <= M:
            ans = max(ans, m)
        if  N*(M//m) <= M:
            ans = max(ans, M//m)

    return ans


def main():
    N, M = read_int_n()
    print(slv(N, M))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def fs(n):
    f = Counter()
    for i in range(2, math.ceil(math.sqrt(n)) + 1):
        if i > n:
            break
        while n % i == 0:
            f[i] += 1
            n /= i
    if int(n) != 1:
        f[int(n)] = 1
    return f

@mt
def slv(N, M):
    ans = 1
    for m in range(2, math.ceil(math.sqrt(M))+1):
        if M % m != 0:
            continue
        
        ans = max(ans, m)
        if  M//m <= N:
            ans = max(ans, M//m)

    return ans


def main():
    N, M = read_int_n()
    print(slv(N, M))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import sqrt
from math import ceil
n, m = list(map(int, input().split()))
lst = range(n, ceil(sqrt(m)))
for i in lst:
    if m % i == 0:
        print(m // i)
        break
else:
    print(1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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