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:
n, m = map(int, input().split())
s = 0
arr = []
if m % n == 0:
	ans = m / n
	print(int(ans))
else:
	for i in range(1, m):
		if m % i == 0:
			arr.append(i)
	for num in arr:
		if num * n > m:
			arr.remove(num)
	print(max(arr))

Submission status: Wrong Answer

Solution code:
import math
a = list(map(int,input().split()))

b = a[1]//a[0]

c = []

for i in range(1,int(math.sqrt(a[1]))):
    if a[1] % i == 0 and i <= b:
        c.append(i)
c.reverse()
for i in c:
    if a[1] % i == 0:
        print(i)
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = 1
if N == 1:
    print(M)
elif M % N == 0:
    print(M // N)
else:
    for n in range(2, 10**6+1):
        X = M - (n * N)
        if X % n == 0 and X >= 0:
            ans = n
    print(ans)

Submission status: Wrong Answer

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

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            if M / i >= N and M % i == 0:
                print(100)
                ans = max(ans, i)
            j = M // i
            if M / j >= N and M % j == 0:
                print(2999)
                ans = max(ans, j)
            #print(i)
    if not_sosu == -1:
        ans = 1


if N == 1:
    ans = M

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

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

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

if is_prime(M):
    print(1)
    exit()

p = list(set(prime_factorization(M)))

ans = 1
for i in p:
    if (M // i) >= N:
        ans = max(i, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


n, m = map(int, input().split())
x = m // n
y = m % n
print(gcd(x, y))

Submission status: Wrong Answer

Solution code:
import itertools

iN,iM = [int(_) for _ in input().split()]


if iM % iN == 0:
    print(iM // iN)
else:
    iUlim = iM//iN + 1
    aRet = [1]
    iF = 2
    iterIncrements = itertools.chain([1,2,2],itertools.cycle([4,2,4,2,4,6,2,6]))
    for i in iterIncrements:
        if  iUlim < iF:
            break
        if iM % iF == 0:
            aRet.append(iF)
        iF += i

    print(aRet[-1])

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil
import sys

N, M = map(int, input().split())
rootM = max(ceil(sqrt(M)), M//N)

for m in reversed(range(1, rootM+1)):
    if M % m == 0:
        print(m)
        if M // m >= N:
            print(m)
            sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# j = M
# I=int(j)
# s=0
# R=int(I)
# L=[]

# while s==0:
#     for i in range(2,R+1):
#         if I%i==0:
#             I=I/i
#             if I==1:
#                 s=1
#             L.append(i)
#             break
# print(L)
# ans = 1
# for l in L:
#     if l >= N:
#         ans = max(M//l,ans)

i = 1
ans = 0

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

iN,iM = [int(_) for _ in input().split()]


if iM % iN == 0:
    print(iM // iN)
else:
    iUlim = iM//iN
    aRet = [1]
    iF = 2
    iterIncrements = itertools.chain([1,2,2],itertools.cycle([4,2,4,2,4,6,2,6]))
    for i in iterIncrements:
        if  iUlim < iF:
            break
        if iM % iF == 0:
            aRet.append(i)
        iF += i

    print(aRet[-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

a=int(m/n)
b=m%n

g1=gcd(a,a+b)
g2=gcd(a+b, m-(a+b)*(n-1))
if g1 > g2:
    print(g1)
else:
    print(g2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict
from bisect import bisect
def inpl(): return list(map(int, input().split()))

def primes(N):
    sieve = [True]*(N+1)
    sieve[:2] = [False, False]
    for i in range(4, N+1, 2):
        sieve[i] = False

    for i in range(3, N+1, 2):
        if sieve:
            for j in range(2*i, N+1, i):
                sieve[j] = False
    P = []
    for i in range(N+1):
        if sieve[i]:
            P.append(i)
    return P

N, M = inpl()
P = primes(31625)
searched = defaultdict(int)

Q = [1]

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

ans = 1
while Q:
    a = Q.pop()
    for p in P[:bisect(P, (M-a*N)//N)]:
        c = a*p
        d = M - c*N
        if d%c == 0 and d >= 0:
            if not searched[c]:
                searched[c] = True
                ans = max(ans, c)
                Q.append(c)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def p_fact(n):
    res = []
    i = 2
    while i ** 2 <= n:
        cnt = 0
        while n % i == 0:
            n /= i
            cnt += 1
        if cnt > 0:
            res.append((i, cnt))
        i += 1
    if n > 0:
        res.append((n, 1))
    return res


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

if M % N == 0:
    print(M // N)
else:
    p = p_fact(M)
    p = sorted(p, reverse=True, key=lambda x: x[0])

    N_max = M // N

    x = 1
    ans = 0
    for prim, cnt in p:
        #print(prim, cnt)
        x *= prim ** cnt
        while x > N_max:
            x //= prim
        ans = max(ans, x)
        
    print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1

for i in range(2,N):

    temp = M

    temp -= i * (N-1)

    if temp > 0 and temp % i == 0:
        ans = i
    

print(ans)

Submission status: Wrong Answer

Solution code:
def p_fact(n):
    res = []
    i = 2
    while i ** 2 <= n:
        cnt = 0
        while n % i == 0:
            n /= i
            cnt += 1
        if cnt > 0:
            res.append((i, cnt))
        i += 1
    if n > 0:
        res.append((n, 1))
    return res


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

if M % N == 0:
    print(M // N)
else:
    p = p_fact(M)
    p = sorted(p, reverse=True, key=lambda x: x[0])

    N_max = int(M / N)

    x = 1
    ans = 0
    for prim, cnt in p:
        print(prim, cnt)
        x *= prim ** cnt
        while x > N_max:
            x //= prim
        ans = max(ans, x)
        
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def isPrime(n):
    return not [x for x in range(2,int(math.sqrt(n))+1)
                if n%x == 0]
def factorize(n):
    primes = []
    candidates = range(2,int(n)+1)
    candidate = 2
    while not primes and candidate in candidates:
        if n%candidate == 0 and isPrime(candidate):
            primes = primes + [candidate] + factorize(n/candidate)
        candidate += 1            
    return primes

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

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

p = list(set(factorize(M)))

ans = 1
for i in p:
    if (M // i) >= N:
        ans = max(i, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

a=int(m/n)
b=m%n

print(a, a+b)
g1=gcd(a,a+b)
g2=gcd(a+b, m-(a+b)*(n-1))
if g1 > g2:
    print(g1)
else:
    print(g2)

Submission status: Wrong Answer

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

a = int(M/N)

if M % 2 == 1:
    if a % 2 == 0:
        a += 1
else:
    if a % 2 == 1:
        a += 1

for i in range(a,0,-2):
    if M % i == 0:
        c = i
        break

print(c)

Submission status: Wrong Answer

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

print(M % N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
N,M=(int(i) for i in input().split())
for i in range(N):
    if M%(M-i)==0 and (M-(N-i)*N)>=0:
        print(N-i)
        break

Submission status: Wrong Answer

Solution code:
#M%N=0なら、M/Nが回答
#そうでないとき、MのM/Nより小さく、最大の公約数を探して
#それをSとしたとき、S*N<MならSが回答
#これを延々とやれば、最小でも1が回答になる。

n,m = map(int,input().split())
if m%n==0:
    print(m/n)
    exit()
s = m//n+1
while(True):
    s = s-1
    if m%s == 0:
        if s*n <= m:
            print(s)
            break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, min(num // 2, 100000) + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    div_list = make_divisor_list(M)
    div_list.sort(reverse = True)
    for p in div_list:
        if M/p >= N:
            print p
            exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import floor, ceil
N, M = [int(elem) for elem in input().split(' ')]

max_gcd = 1
cand = M // N

for cand in range(M // N, 1, -1):
    rest = M - cand * N
    if rest % cand == 0:
        max_gcd = max(max_gcd, cand)
        break
    else:
        continue

Submission status: Wrong Answer

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

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

# j = M
# I=int(j)
# s=0
# R=int(I)
# L=[]

# while s==0:
#     for i in range(2,R+1):
#         if I%i==0:
#             I=I/i
#             if I==1:
#                 s=1
#             L.append(i)
#             break
# print(L)
# ans = 1
# for l in L:
#     if l >= N:
#         ans = max(M//l,ans)

i = 1
ans = 1

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
for i in range(2, int((M + 1) ** 0.5) + 1):
    if M % i == 0:
        if M / i >= N:
            ans = max(ans, i)
        if M / (M / i) >= N:
            ans = max(ans, M / i)

print(ans)

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 n != 1:
        f[n] = 1
    return f

@mt
def slv(N, M):

    m = M//N
    rem = M - m*N
    mf = fs(m)
    
    ans = 1
    if rem == 0:
        for k, v in mf.items():
            ans *= k**v
        return ans
    
    for i in range(1, rem+1):
        if i * N < rem:
            continue
        rf = fs(m + i)

        t = 1
        for f in mf:
            if f in rf:
                t *= f**min(mf[f], rf[f])
            ans = max(ans, t)

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

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

a=int(m/n)
b=m%n

g=gcd(a,a+b)
print(g)

Submission status: Wrong Answer

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

if N == 1:
    print(M)

elif M % 2 == 1:
    if M // N % 2 == 0:
        if M % (M//N) == 0:
            if M / (M//N) >= N:
                print(M//N)

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = int((m**0.5)//1)
b = 0

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

Submission status: Wrong Answer

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

import math
class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]
    @staticmethod
    # Prime Factor Decomposition
    def pfd(n):
        rn = math.ceil(math.sqrt(n))
        primes = PrimeUtils.primes_sieve(rn)

        factors = []
        cur = n
        for p in primes:
            cnt = 0
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    cnt += 1
                    cur = div
                else:
                    break
            if cnt != 0:
                factors.append((p, cnt))
        if cur != 1 or n == 1:
            factors.append((cur, 1))
        return factors

import itertools,functools,operator
factors = PrimeUtils.pfd(M)
factors = list(itertools.chain(*[[x] * y for (x, y) in factors]))
fa = []
for m in range(1, len(factors) +1):
    for c in itertools.combinations(factors, m):
        fa.append(functools.reduce(operator.imul, c))
for x in sorted(fa):
    if x >= N:
        print(M // x)
        break
else:
    print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
factor = [1]
for i in range(2,int(m**0.5)+2):
    if m%i == 0:
        factor.append(i)
        factor.append(m//i)
factor.sort()
factor.reverse()
for i in range(len(factor)):
    if m%factor[i] == 0:
        if m//factor[i] >= n:
            print(factor[i])
            break

Submission status: Wrong Answer

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

def isPrime(x):
  if x&1 == 0:
    return 2
  d = 3
  while d * d <= x:
    if x % d == 0:
      return d
    d = d + 2
  return 0

m = T//N
if T%N==0:
  print(m)
else:
  r = isPrime(T)
  if r==0:
    print(1)
  else:
    while m>r and T%m!=0:
      m -= 1
    print(max(m, r))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = int((m**0.5)//1)
b = 0

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

Submission status: Wrong Answer

Solution code:
import math, sys, time

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

d = math.floor(M/N)

if M%N == 0:
	print(d)
	sys.exit()

i = 0
while True:
	if M%(N+i+1) == 0:
		print(int(M/(N+i+1)))
		sys.exit()
	i += 1
	if i > d:
		break

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
A = M//N
L = []
flag = False
if (A <= 10**8):
  for i in range(1,A+1):
    if (M%(A+1-i) == 0):
      flag = True
      break
  if flag:
    print(A+1-i)
else:
  for i in range(1,10**7):
    if (M%i == 0):
      L.append(i)
  print(max(L))

Submission status: Wrong Answer

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

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

a=int(m/n)
b=m%n

g=gcd(a,a+b)
print(g)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n, m = il()

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
factor = [1]
for i in range(2,int(m**0.5)+2):
    if m%i == 0:
        factor.append(i)
        factor.append(m//i)
factor.reverse()
for i in range(len(factor)):
    if m%factor[i] == 0:
        if m//factor[i] >= n:
            print(factor[i])
            break

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil
import sys

N, M = map(int, input().split())
rootM = ceil(sqrt(M))

for m in reversed(range(1, rootM+1)):
    if M % m == 0:
        if M // m >= N:
            print(m)
            sys.exit()

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

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

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

p = list(set(prime_factorization(M)))

ans = 1
for i in p:
    if (M // i) >= N:
        ans = max(i, ans)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n, m = il()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int,input().split())
A = M//N
L = []
flag = False
if (A <= 10**8):
  for i in range(1,A+1):
    if (M%(A+1-i) == 0):
      flag = True
      break
  if flag:
    print(A+1-i)
else:
  for i in range(1,int(math.sqrt(A))):
    if (M%i == 0):
      L.append(i)
  print(max(L))

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

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

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

p = list(set(prime_factorization(M)))

ans = 1
for i in sorted(p, reverse=True):
    print(i, M//i)
    if (M // i) >= N:
        ans = max(i, ans)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ma = m//n
re = m%n

flag=0

if re==0:
    while(flag==0):
        if m%ma==0:
            print(ma)
            flag = 1
        ma -=1
else:
    flag2=0
    while(flag==0):
        if m%ma==0:
            print(ma)
            flag = 1
            
        if flag2==0:
            ma -=1
            if ma%re==0:
                flag2=1
        
        else:
            if ma>re:
                ma -= re
            else:
                ma -=1
                flag2=1

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

N,M = [int(x) for x in stdin.readline().rstrip().split()]
go = False

while go == False:
    if N == M:
        print(1)
        exit()
    if M % N == 0:
        print(N)
        exit()
    N -= 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
iN,iM = [int(_) for _ in input().split()]
def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a


if iM % iN == 0:
    print(iM // iN)
else:
    iJ = iM % iN
    iD = iM // iN
    print(fgcd(iD *iN * 2 , iN *iD + iJ))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
n,m = map(int,input().split())	
r = m
a = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
for i in range(len(a)):
    if m%a[i] == 0 and m >= a[i]:
        r = m//a[i]
        break
if r == m and m >= 199:
    r = m//199


while n <= r :
    if m % n == 0:
        break
    n += 1

print(m//n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=[]
b=0
n,m=map(int,input().split(" "))
for i in range(2,n+1):
    if m%i==0:
        a.append(i)
for i1 in a:
    if m/i1 >=n:
        b=i1
print(b)

Submission status: Wrong Answer

Solution code:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n, m = il()

i = 0
ans = 0
while i*i <= m:
    i += 1
    if m % i == 0 and m//i >= n:
        ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if m%n == 0:
    print(m//n)
else:
    factor = [1]
    for i in range(2,int(m**0.5)+2):
        if m%i == 0:
            factor.append(i)
    factor.reverse()
    for i in range(len(factor)):
        if m%factor[i] == 0:
            print(factor[i])
            break

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int, input().split())
ulim = M//N
mid = int(math.sqrt(M))
for i in reversed(range(1, min(ulim, mid) +1)):
    if M%i == 0:
        print(i)
        break

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if m%n == 0:
    print(n)
else:
    factor = [1]
    for i in range(2,int(m**0.5)+2):
        if m%i == 0:
            factor.append(i)
    factor.reverse()
    for i in range(len(factor)):
        if m%factor[i] == 0:
            print(factor[i])
            break

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

from math import sqrt, ceil

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

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

p = prime_factorization(M)

if M % N == 0:
    print(M//N)
    exit()
ans = 1
for i in sorted(p, reverse=True):
    if (M // i) >= N:
        ans = max(i, ans)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
nums = []
target = m

for i in range(2,pow(10,9)+1):
  if m <= i*i:
    break
  if target % i == 0:
    nums.append([i,target//i])
  if target == 1:
    break

keep = 0
for x in range(len(nums)):
  if n <= nums[x][0]:
    print(nums[x][1])
    exit()
  elif n <= nums[x][1]:
    keep = nums[x][0]
if 0 < keep:
  print(keep)
else:
  print(1)

Submission status: Wrong Answer

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

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