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:
# -*- coding: utf-8 -*-
import math

def make_divisor_list(num,tar):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        i = 2
        while i*i <= num:

            if num % i == 0 and i*i <= num:
                divisor_list.append(i)
                divisor_list.append(num//i)
            i += 1
        divisor_list.append(num)
        return divisor_list
def binary_search_loop(li,tar):
    arry = li
    target = tar

    left = 0
    right = len(arry)

    while left <= right:

        mid = (left + right) // 2
        if arry[mid] ==  target:
            break
        elif arry[mid] > target:
            right = mid
        else:
            left = mid
        if right - left == 1:
            mid += 1
            break

#    print(mid)
    return mid

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

li = make_divisor_list(M,M//N)
li = sorted(li)
mid = binary_search_loop(li,M//N)


ans = 0
i = mid
while True:
    if li[i]>=N:
        tmp = M//li[i]
        if tmp >= ans:
            ans = tmp
        else:
            break

    i += 1
print(ans)
# print(li)

# ans = 1
# for l in li[::-1]:
#     if l >= N:
#         ans = max(ans,M//l)
#     if ans >= l:
#         break

# i = 1
# ans = 0
# tmp = 1000000000

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

# while M//i >= i and N > i and i <= tmp:
#     if M%i == 0:
#         if tmp == 1000000000:
#             tmp = M//i
#         if M//i >= N:
#             ans = max(ans,i)
#     i += 1

#print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def make_divisor_list(num,tar):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        i = 2
        while i*i <= num:

            if num % i == 0 and i*i <= num:
                divisor_list.append(i)
                divisor_list.append(num//i)
            i += 1
        divisor_list.append(num)
        return divisor_list
def binary_search_loop(li,tar):
    arry = li
    target = tar

    left = 0
    right = len(arry)

    while left <= right:

        mid = (left + right) // 2
        if arry[mid] ==  target:
            break
        elif arry[mid] > target:
            right = mid
        else:
            left = mid
        if right - left == 1:
            mid += 1
            break

#    print(mid)
    return mid

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

li = make_divisor_list(M,M//N)
li = sorted(li)
mid = binary_search_loop(li,M//N)

print(M//li[mid])

# print(li)

# ans = 1
# for l in li[::-1]:
#     if l >= N:
#         ans = max(ans,M//l)
#     if ans >= l:
#         break

# i = 1
# ans = 0
# tmp = 1000000000

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

# while M//i >= i and N > i and i <= tmp:
#     if M%i == 0:
#         if tmp == 1000000000:
#             tmp = M//i
#         if M//i >= N:
#             ans = max(ans,i)
#     i += 1

#print(ans)

Submission status: Runtime Error

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

d = int(T / N)
else:
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break

Submission status: Runtime Error

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

Submission status: Runtime Error

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

MAX_SQRT = int(math.sqrt(M))
for i in range(MAX_SQRT, 0, -1):
    if M%i == 0 and M%(i*N) == 0:
        ans = i
        break

print(ans)

Submission status: Runtime Error

Solution code:
def solve(N, M):
    def fact(M):
        return [i for i in range(1, ceil(sqrt(M)) + 1) if M % i == 0]
    return max([m for m in fact(M) if m <= M // N  and M >= N * m])

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
n, m = map(long, input().split())
kotae=1

for i in range(1,long(math.sqrt(m))+1):
	if m%i==0:
		if i*n<=m:
			kotae=max(kotae, i)
		if (m/i)*n<=m:
			kotae=max(kotae, int(m/i))
print(kotae)

Submission status: Runtime Error

Solution code:
import math
n, m = map(long, input().split())
kotae=1

for i in range(1,long(math.sqrt(m))+1):
	if m%i==0:
		if i*n<=m:
			kotae=max(kotae, i)
		if (m/i)*n<=m:
			kotae=max(kotae, m/i)
print(kotae)

Submission status: Runtime Error

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

for i in range(1,int(math.sqrt(m))+1):
  if m%i==0:
    if i*n<=m:
	  kotae=max(kotae,i)
    if (m/i)*n<=m:
      kotae=max(kotae,i)
print(kotae)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
yaku=set()
for i in range(1,m):
    yaku.add(m//i)
import copy
yakuc=copy.copy(yaku)
for i in yakuc:
    if i<n:
        yaku.remove(i)
yakul=list(yaku)
p=yakul[0]
print(m//p)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math


def divisor(num):
    if num < 0:
        return 0
    elif num == 1:
        return 1
    else:
        divisor_list =[1,]
        for i in range(2, int(math.sqrt(num) + 1)):
            if num % i== 0:
                divisor_list.append(i)
        return divisor_list


N,M = map(int,input().split(' '))
P = M // N
divisor_list = divisor(M)
for i in reversed(range(len(divisor_list))):
    num = M // divisor_list[i]
    divisor_list.append(num)

for i in reversed(range(len(divisor_list))):
    if divisor_list[i] <= P:
        print(divisor_list[i])
        break

Submission status: Runtime Error

Solution code:
#coding:utf-8
import math
N, M = map(int, input().split())
yakusu = []
for i in range(2, min(int(M / N) + 1, int(math.sqrt(M)) + 1)):
    if M % i == 0:
        yakusu.append(i)
        if int(M / i) * N < M:
            yakusu.append(int(M / i))
print(max(yakusu))

Submission status: Runtime Error

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
ans = 0
for param in params:
    if n > m / iparam:
        break
    ans = param
print(ans)

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;

int main() {
  int n, m; cin >> n >> m;
  for (int i = m / n; i > 0; i--) {
    if (m % i == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Submission status: Runtime Error

Solution code:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)

Submission status: Runtime Error

Solution code:
import math

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

x=0

s = []
for i in range(math.sqrt(m)):
	if m%i==0:
		s.append(i)



for i in s:
	if m%(i+1)==0 and m//(i+1)>n-1:
		x=max(x,i+1)
print(x)

Submission status: Runtime Error

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

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

M_divisors = divisorize(factorize(M))
threshold = M // N
max_possible_divisor = 1
for M_divisor in M_divisors:
    divisor = num(M_divisor)
    if divisor <= threshold:
        max_possible_divisor = max(max_possible_divisor, divisor)
print(max_possible_divisor)

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())
tmp = [1]
if N == 1:
    print(M)
else:
    for i in range(2, int(math.ceil(M**0.5))):
        if M % i == 0:
            tmp.append(i)
            tmp.append(M/i)
    ans = 1
    for x in tmp:
        if m / x >= N:
            ans = max(ans, x)
    print(ans)

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())
tmp = [1]
if N == 1:
    print(M)
else:
    for i in range(2, int(math.ceil(M**0.5))):
        if M % i == 0:
            tmp.append(i)
            tmp.apend(M/i)
    ans = 1
    for x in tmp:
        if m / x >= N:
            ans = max(ans, x)
    print(ans)

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())
tmp = [1]
if N == 1:
    print(M)
else:
    for i in range(2, math.ceil(M**0.5)):
        if M % i == 0:
            tmp.append(i)
            tmp.apend(M/i)
    ans = 1
    for x in tmp:
        if m / x >= N:
            ans = max(ans, x)
    print(ans)

Submission status: Runtime Error

Solution code:
import itertools
iN,iM = [int(_) for _ in input().split()]

if iM % iN == 0:
    print(iM // iN)
else:
    for i in range( 1 , min(iM // iN + 1,int(iM ** 0.5)+1) ):
        if iM % i == 0:
            aRet.append( i )
    print( aRet[-1] )

Submission status: Runtime Error

Solution code:
N, M = list(map(int,input().split()))
 
d = int(M/N)
 
if M%N == 0:
	print(d)
else: 
    ans = 1
    for i in range(m//n+1, 0, -1):
        if m % i == 0:
            if (m // i) >= n:
                print(i)
                break
	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

Submission status: Runtime Error

Solution code:
#python D-Partition.py
"""
入力フォーマット
N M

出力:a_1+...+a_N=Mを満たす数列aについてmax(GCD(a_1,...,a_N))
"""
import math
line = list(map(int, input().split(" ")))
N = int(line[0])
M = int(line[1])

#TLE(実行時間制限超過)のコード
"""
for i in range(math.floor(M/N),0,-1):
	tmp = M-i*(N-1)
	if tmp%i==0:
		print(i)
		break
"""

#TLEを何とかしたコード（ポイント：素数判定と同じ要領で探索範囲をO(sqrt(M))にした
for i in range(sqrt(M)):
	tmp = M-(math.floor(M/N)-i)*(N-1)
	if tmp%(math.floor(M/N)-i)==0:
		print((math.floor(M/N)-i))
		break

Submission status: Runtime Error

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

ds = [x for x in range(1, m**.5+1) if m%x==0]
ds = ds + [m%x for x in ds]
ds = [x for x in ds if x<=m//n]
print(max(ds))

Submission status: Runtime Error

Solution code:
import math

N,M = map(int,input().split())
A = M//N
L = []
for i in range(1,int(math.sqrt(M))):
  if (M%i == 0 and i <= A):
    L.append(i)
    if (M//i <= A):
      L.append(M//i)
print(max(L))

Submission status: Runtime Error

Solution code:
from itertools import combinations

def fact(M):
    ans = []
    while M > 1:
        for i in range(2, M+1):
            if M % i == 0:
                ans.append(i)
                M //=i
                break
    return ans

def solve(N, M):
    ans = []
    divs = fact(M)
    done = set()
    for r in range(1, len(divs) + 1):
        for Xs in combinations(divs, r):
            if tuple(Xs) in done:
                continue
            done.add(Xs)

            X = 1
            for x in Xs:
                X *= x
            if M % X != 0:
                continue
            S = X * N
            if (M - S) >= 0 and (M - S) % X == 0:
                ans.append(X)
    return max(ans)

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
def make_divisor_list(num):
    if num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        i=2
        while i<=int(sqrt(num)):
            if num % i == 0:
                divisor_list.append(i)
            i+=1
        divisor_list.append(num)
        return divisor_list
      
ans=1
N,M=map(int,input().split())
divisors=make_divisor_list(M)
divisors.reversed()
for i in divisors:
  if M/divisors >=N:
    print(divisors)
    break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)
 
N = int(input())
P = [[0 for i in range(101)] for j in range(101)]
x, y, h = map(int, input().split())
P[x][y] = h
for i in range(101):
    for j in range(101):
        P[i][j] = dist(i, j, x, y, h)
 
for i in range(N-1):
    a, b, c = map(int, input().split())
    if P[a][b] != c:
        P[a][b] = False
    for j in range(101):
        for k in range(101):
            if P[j][k] != False and P[j][k] != dist(j, k, a, b, c):
                P[j][k] = False
temp = (0, 0, 0)
for i in range(101):
    for j in range(101):
        if P[i][j] > temp[2]:
            temp = (i, j, P[i][j])
print(temp[0], temp[1], temp[2])

Submission status: Runtime Error

Solution code:
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)
 
N = int(input())
P = [[0 for i in range(101)] for j in range(101)]
x, y, h = map(int, input().split())
P[x][y] = h
for i in range(101):
    for j in range(101):
        P[i][j] = dist(i, j, x, y, h)
 
for i in range(N-1):
    a, b, c = map(int, input().split())
    if P[a][b] != c:
        P[a][b] = False
    for j in range(101):
        for k in range(101):
            if P[j][k] != False and P[j][k] != dist(j, k, a, b, c):
                P[j][k] = False
temp = (0, 0, 0)
for i in range(101):
    for j in range(101):
        if P[i][j] > ans:
            temp = (i, j, P[i][j])
print(temp[0], temp[1], temp[2])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
def make_divisor_list(num):
    if num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        i=2
        while i<=int(num/2):
            if num % i == 0:
                divisor_list.append(i)
            i+=1
        divisor_list.append(num)
        return divisor_list
      
ans=1
N,M=map(int,input().split())
divisors=make_divisor_list(M)
i=0
while M/divisors[i]>=N:
  ans=divisors[i]
  i+=1
print(int(ans))

Submission status: Runtime Error

Solution code:
import  math
lis = []

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

for i in range(1,int(math.sqrt(M))):
    if M % i == 0:
        lis.append(i)
        lis.append(M//i)


lis.sort()
for i in lis:
    if i >= N:
        break

print(M//i )

Submission status: Runtime Error

Solution code:
import  math
lis = []

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

for i in range(1,int(math.sqrt(M))):
    if M % i == 0:
        lis.append(i)
        lis.append(M//i)


lis.sort()
for i in lis:
    if i >= N:
        break

print(M//i3 )

Submission status: Runtime Error

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

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

M_fct = factorize(M)
M_divisors = divisorize(M_fct)
max_divisor = 0
for M_divisor in M_divisors:
    cand = num(M_divisor)
    if cand >= N:
        max_divisor = max(M // cand, max_divisor)
print(max_divisor)

Submission status: Runtime Error

Solution code:
import  math
lis = []

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

for i in range(1,int(math.sqrt(M))):
    if M % i == 0:
        lis.append(i)


ret = 0
for i in lis:

    ret = i
    if i >= N:
        break

print(M//ret )

Submission status: Runtime Error

Solution code:
import  math
lis = []

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

for i in range(1,int(math.sqrt(M))):
    if M % i == 0:
        lis.append(i)
        lis.append(M//i)

lis.sort()
ret = 0
for i in lis:

    ret = i
    if i >= N:
        break

print(M//ret )

Submission status: Runtime Error

Solution code:
import  math
lis = []

N,M = [int(i) for i in input().split()]
M_ = M
i = 2
for i in range(1,int(math.sqrt(M))):
    if M % i == 0:
        lis.append(i)
        lis.append(M//i)

lis.sort()
ret = 0
for i in lis:

    ret = i
    if i >= N:
        break

print(M_//ret )

Submission status: Runtime Error

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

for i in range(M**0.5,0,-1):
    d=M%i 
    if d==0:
        k=i
        print(i)
        break

Submission status: Runtime Error

Solution code:
import  math
lis = []

N,M = [int(i) for i in input().split()]
M_ = M
i = 2
for i in range(1,int(math.sqrt(M))):
    if M % i == 0:
        lis.append(i)
        lis.append(M//i)

lis.sort()
ret = 0
for i in lis:

    ret = i
    if i > N:
        break

print(M_//ret )

Submission status: Runtime Error

Solution code:
import  math
lis = []

N,M = [int(i) for i in input().split()]
M_ = M
i = 2
for i in range(1,int(math.sqrt(M))):
    if M % i == 0:
        lis.append(i)
        lis.append(M//i)

lis.sort()
ret = 0
for i in lis:
    if i > N:
        break
    ret = i

print(M_//ret )

Submission status: Runtime Error

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

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

M_fct = factorize(M)
M_divisors = divisorize(M_fct)
max_divisor = 0
for M_divisor in M_divisors:
    cand = num(M_divisor)
    if cand >= N:
        max_divisor = max(M // cand, max_divisor)
print(max_divisor)

Submission status: Runtime Error

Solution code:
def solve(N, M):
    ans = []
    for X in range(1, M):
        S = X * N
        if (M - S) >= 0 and (M - S) % X == 0:
            ans.append(X)
        elif (M - S) < 0:
            break
    return ans[-1]

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Runtime Error

Solution code:
def solve(N, M):
    ans = []
    for X in range(2, M):
        S = X * N
        if (M - S) >= 0 and (M - S) % X == 0:
            ans.append(X)
        elif (M - S) < 0:
            break
    return ans[-1]

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sympy

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def is_prime3(q,k=50):
    q = abs(q)
    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 xrange(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

if __name__ == "__main__":
    list = input().split(" ")
    N = int(list[0])
    M = int(list[1])
    if is_prime3(M):
        print(1)
        exit()
    for i in range(M):
        if M%(N+i) == 0:
            print(int(M/(N+i)))
            exit()
        if M/(N+i) < 2:
            print(1)
            exit()

Submission status: Runtime Error

Solution code:
import sympy
N,M=list(map(int,input().split()))
LIST=[]
divide_list = sympy.divisors(M)
if M%N==0:
    print(M//N)
else:
    x = M/N
    for i in divide_list:
       if i <= x:
          LIST.append(i)
    print(max(LIST))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
yaku=set()
for i in range(1,m):
    yaku.add(m//i)
import copy
yakuc=copy.copy(yaku)
for i in yakuc:
    if i<n:
        yaku.remove(i)
yakul=list(yaku)
p=yakul[-1]
print(m/p)

Submission status: Runtime Error

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

k=[]

for i in range(m):
  if (m%i==0) and (m//i <= n):
    k.append(i)
    
print(max(k))

Submission status: Runtime Error

Solution code:
import math

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

x=0

s = []
for i in range(math.floor(math.sqrt(m)))
	if m%i==0:
		s.append(i)



for i in s
	if m%(i+1)==0 and m//(i+1)>n-1:
		x=max(x,i+1)
print(x)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

k=[]

for i in range(m):
  if (m%i==0) and (m//i <= n):
    k.append(i)
    
print(max(k))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n,m = map(int, input().split())
blist = []
for i in range(2**(n)):
    blist.append(list(map(int,list(bin(i)[2::].zfill(n)))))
#print(blist)


for num in blist:
    cl = []
    c = 0
    for i,nu in enumerate(num):
        if nu == 1:
            c += (i+1)
            cl.append(i+1)
        if i == n-1:
            if c == n:
                if gcd_list(cl) > gd:
                    gd = gcd_list(cl)
print(gd)

Submission status: Runtime Error

Solution code:
N, M =map(int,input().split())
ans=1
for i in seachPrimeNum(100):
    if M%i==0:
        if M//i>=N:
            print(i)
            ans=ans*i
print(ans)

Submission status: Runtime Error

Solution code:

def solve(N, M):
    ans = []
    for X in range(2, M):
        S = (N * (N + 1) // 2) * X
        # print(f"X={X}, S={S}, M={M}")
        if (M - S) % X == 0:
            ans.append(X)
            # print(f"ans append : {X}")
        elif S > M:
            # print(f"X={X}, S={S}, M={M}")
            break
    return ans[-1]

if __name__ == "__main__":
    l = input().split(" ")
    N, M = int(l[0]), int(l[1])
    print(solve(N, M))

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy
import math


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 is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


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])]
    if N == 1:
        print M
        exit()
    if is_prime(M):
        print 1
        exit()

    for num in range(M/N, 0, -1):
        if M % num == 0 and M/num >= N:
            print num
            exit()


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
m = M
prime = []
flg = True
while flg:
    for i in range(2, int(m+1)):
        if m % i == 0:
            m /= i
            prime.append(i)
            if m == 1:
                flg = False
            break
n = 1
for i in prime:
    n *= i
    if n * N <= M:
        res = n
print(res)

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy
import math
import numpy as np

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 is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


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])]
    if N == 1:
        print M
        exit()
    if is_prime(M):
        print 1
        exit()

    for num in range(M/N, 0, -1):
        if M % num == 0 and M/num >= N:
            print num
            exit()


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math

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

x=0

s = []
for i in range(math.sqrt(m))
	if m%i==0:
		s.append(i)



for i in s
	if m%(i+1)==0 and m//(i+1)>n-1:
		x=max(x,i+1)
print(x)

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;

int main(){
    int N,M;
    int count=0;
    cin >> N >> M;
    if(N == 1){
        cout << M << endl;
    }else{
        for(int i=M/N;i>0;i--){
            if(count!=0){
                break;
            }
            else if(M%i==0 && M/i>=N){
                cout << i << endl;
                count++;
            }
        }
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
from math import gcd
n, m = map(int, input().split())
if m % n == 0:
    print(m // n)
else:
    gcd = m // n
    for i in range(gcd, 0, -1):
        if m % i == 0:
            j = m // gcd
            if j >= n:
                print(i)
                exit()

Submission status: Runtime Error

Solution code:
# coding:utf-8
import math

a, b = map(int, raw_input().split())


s=0
I=b
ans = []

while s==0:
    for i in range(2,I+1):
        if I%i==0:
            I=I/i
            if I==1 or I<a:
                s=1
            # print(i)
            ans = ans +[i]
            break

# print ans
l = len(ans)
x=1
for i in range(0,l-1):
    x = x * ans[i]

print x

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
m = M
prime = []
flg = True
while flg:
    for i in range(2, int(m+1)):
        if m % i == 0:
            m /= i
            prime.append(i)
            if m == 1:
                flg = False
            break
for i in prime:
    if i * N <= M:
        res = i
print(res)

Submission status: Runtime Error

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

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

print output

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
m = M
prime = []
flg = True
while flg:
    for i in range(2, int(m+1)):
        if m % i == 0:
            m /= i
            prime.append(i)
            if m == 1:
                flg = False
            break
print(prime)
for i in prime:
    if i * N <= M:
        res = i
print(res)

Submission status: Runtime Error

Solution code:
import math
tmp=raw_input().split(" ")
N=int(tmp[0])
M=int(tmp[1])
dvd=[]
while i<=math.sqrt(M):
  if M%i==0:
    dvd.append(i)
  i=i+1
for j in len(dvd):
  sum=M/dvd[len(dvd)-j-1]
  if sum<N:
    pass
  else:
    print dvd[len(dvd)-j-1]

Submission status: Runtime Error

Solution code:
import math

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

x=0
if n<math.sqrt(m):
	for i in range(m//n):
		if m%(i+1)==0 and m//(i+1)>n-1:
			x=max(x,i+1)
	print(x)
else:
	for i in range(math.floor(math,sqrt(m))):
		if m%(i+1)==0 and m//(i+1)>n-1:
			x=max(x,i+1)
	print(x)

Submission status: Runtime Error

Solution code:
import fractions

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

for i in range(10000):
    a = fractions.gcd(m, i)
    if a == 1:
        continue
    tmp = int(a *(1 - a ** n) / (1 - a))
    if tmp == m:
        break

print(a)