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:
import random

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

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

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

Submission status: Runtime Error

Solution code:
def divisor(m,k):
  divisor=[]
  for i in range(1,k+1):
    if m%i==0:
      divisor.append(i)
  return divisor

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def factor(x):
  factor=[]
  if x==1:
    return
  else:
    i=2
    while x>1:
      if x%i==0:
        factor.append([i,1])
        x/=i
        while x%i==0:
          factor[-1][1]+=1
          x/=i
      i+=1
    return factor

n,m=(int(i) for i in input().split(' '))
factor=factor(m)
ans=1
for data in factor:
  data[1]=data[1]//n
  ans=ans*(data[0]**data[1])
print(ans)

Submission status: Runtime Error

Solution code:
def factor(x){
  factor=[]
  if x==1:
    return
  else:
  i=2
    while x>1:
      if x%i==0:
        factor.append([i,1])
        x/=i
        while x%i==0:
          factor[-1][1]+=1
          x/=i
      i+=1
    return factor

n,m=(int(i) for i in input().split(' '))
factor=factor(m)
ans=1
for data in factor:
  data[1]=data[1]/n
  ans=ans*(data[0]**data[1])
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def solve():
	for i in range(n,m//2+1):
		if not m%i:
			return m/i

print(int(solve()))

Submission status: Runtime Error

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

def solve():
	for i in range( n,m//2):
		if not m%i:
			return m/i

print(int(solve()))

Submission status: Runtime Error

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

yueshu = []
state = 0
if m % n == 0:
    print m / n
else:
    for i in range(1, int(m**0.5)+1):
        if m % i == 0:
            yueshu.insert(0, m/i)
            if i >= n:
                print m / i
                state = 1
                break
    if state == 0:
        for i in range(int(m**0.5)+1, m):
            if m % i == 0:
                if i >= n:
                    print m / i
                    state = 1
                    break
    if state == 0:
        print 1

Submission status: Runtime Error

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

yueshu = []
state = 0
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        yueshu.insert(0, m/i)
        if i >= n:
            print m / i
            state = 1
            break
if state == 0:
    for i in range(int(m**0.5)+1, m):
        if m % i == 0:
            if i >= n:
                print m / i
                break
if state == 0:
    print 1

Submission status: Runtime Error

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

yueshu = []
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        yueshu.insert(0, m/i)
        if i >= n:
            print m / i
            break
for i in range(int(m**0.5)+1, m):
    if m % i == 0:
        if i >= n:
            print m / i
            break

Submission status: Runtime Error

Solution code:
def calc()
N,M = map(int,input().split())
for gcd in range(M // N,0,-1):
 if M % gcd == 0:
  return(gcd)

print(calc())

Submission status: Runtime Error

Solution code:
# abc112_c

FOUND = []

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

def gcd_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(output, i, N, M):
    if len(output) < N and i < M:
        output.append(i)
        find_seq(output, i + 1, N, M)
    else:
        total = sum(output)
        if total == M or total > M:                        # sum is equal or more than M
            if (len(output) == N and total == M):          # sum equal and len == N, we found it
                FOUND.append(output.copy())
            output.pop()
            last_try = output[-1]
            output.pop()
            find_seq(output, last_try + 1, N, M)
        else:
            if len(output) > 0:                             # sum is less than M
                last_try = output[-1]
                output.pop()
                find_seq (output, last_try + 1, N, M)

def main():
    output = []
    N, M = map(int, input("").split())                      # read input
    find_seq(output, 1, N, M)                               # find seq
    print(FOUND)
    max_gcd = 1                                             # find gcd
    for elem in FOUND:
        current_gcd = gcd_list(elem)
        if current_gcd > max_gcd:
            max_gcd = current_gcd

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

if __name__ == "__main__": main()

Submission status: Runtime Error

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

Solution code:
from math import gcd

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

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

Submission status: Runtime Error

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

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*(m/i)<m:
            divisors.append(m/i)
print(max(divisors))

Submission status: Runtime Error

Solution code:
n,m = map(int,input())
while n <= m:
  if m%n == 0:
    print(m%n)
    break
  n += 1

Submission status: Runtime Error

Solution code:
n,m = map(int,input())
while n <= m:
  if m%n == 0:
    print(m%n)
  n += 1
break

Submission status: Runtime Error

Solution code:
# nの約数を求める
def divisor(n):
    d = []
    for i in range(int(n**(0.5)+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: Runtime Error

Solution code:
N = int(input())
if N == 1:
    print('Hello World')
else:
    a, b = map(int, input().split())
    print(a + b)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

max = m//n
lis = []


for i in range(int(m**0.5)):
    if m%i == 0:
        lis.append(i)

lis = lis[::-1]

if m%n == 0:
    print(max)
else:
    for line in lis:
        if line > max:
            continue
        else:
            if lis%n == 0:
                print(lis)
                break

Submission status: Runtime Error

Solution code:
import sys
n,m=map(long,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: Runtime Error

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

def div(n):
    c = []
    for i in range(1,n):
        if n % i == 0:
            c.append(i)
    return c

d = div(M)
l = len(d)

k = 0
while M // d[k] > N:
    k += 1

print(d[k-1])

Submission status: Runtime Error

Solution code:
def input_int_list():
    return list(map(int, input().split()))
  
N,M = input_int_list()
 
D = M/N
i = 1
res = 0
 
for d in range(int(D)).reverse():
  r = i*(N-1)
  r1 = M - r
  if r1 > res and (M % i) == 0 and (r1 % i)==0:
    res = i
    exit()
  i+=1
    
print(res)

Submission status: Runtime Error

Solution code:
def input_int_list():
    return list(map(int, input().split()))
  
N,M = input_int_list()
 
D = M/N
i = 1
res = 0
 
for d in range(int(D)).reverse():
  r = i*(N-1)
  r1 = M - r
  if r1 > res and (M % i) == 0 and (r1 % i)==0:
    res = i
  i+=1
    
print(res)

Submission status: Runtime Error

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

D = M/N
i = 1
res = 0

for d in range(D):
  r = i*(N-1)
  r1 = M - r
  if r1 > res && (m / r1) == 0:
    res = r1
    
print(r1)

Submission status: Runtime Error

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]))+1):if a[1]%i==0 and i<=b:if a[1] // i <= b:c.append(a[1]//i);else:c.append(i);c.sort(reverse=True);print(c[0])

Submission status: Runtime Error

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]))+1):
    if a[1]%i==0 and i<=b:
        if a[1] // i <= b:
            c.append(a[1]//i)
        else:
            c.append(i)
c.sort(reverse=True)
print(c[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Target = N
L = make_divisor_list(M)

mid = bin_search(L,Target)

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

Submission status: Runtime Error

Solution code:
import math


def read():
    return int(input())


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


def readmap():
    return map(int, input().split())


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

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


N, M = readmap()
div = usage(M)
ans = 0
for d in div:
    if N * d <= M:
        ans = max(ans, d)
print(ans)

Submission status: Runtime Error

Solution code:
// finish date: 2018/10/08

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

//素因数分解
map<int, int> p_fact(int n) {
    map<int, int> mp;
    int i = 2;
    while (n >= i * i) {
        while (n % i == 0) mp[i]++, n /= i;
        i++;
    }
    if (n != 1) mp[n]++;
    return mp;
}

map<int, int> mp;
int N, M;
int ans = 1;

void dfs(map<int, int>::iterator itr, int temp = 1) {
    if (itr == mp.end()) {
        if (M % temp == 0 && M / temp >= N) ans = max(ans, temp);
        return;
    }
    rep(i, itr->second + 1) {
        dfs(next(itr), temp * (int) (round(pow(itr->first, i))));
    }
}

int main() {
    cin >> N >> M;
    mp = p_fact(M);
    dfs(mp.begin());
    cout << ans << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
N, M=map(int,input().split())
def is_prime_2(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False
    
    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step

    return True
if is_prime_2(M):
    print(1)
else:
    x=M//N
    for i in range(x,0,-1):
        if M%i==0 and M/i>=N:
            print(i)
            break

Submission status: Runtime Error

Solution code:
N, M = input.split()
div = int((int(M) + 0.1) // int(N) + 0.1)

hoge = div
for i in range(div):
    if int(M) % hoge == 0:
        break
    else:
        hoge -= 1

print(str(hoge))

Submission status: Runtime Error

Solution code:
N, M = input.split()
div = int((int(M) + 0.1) // int(N) + 0.1)

hoge = div
for i in range(div):
    if M % hoge == 0:
        break
    else:
        hoge -= 1

print(str(hoge))

Submission status: Runtime Error

Solution code:
import math
 
N, M=input().split(" ")
N=int(N)
M=int(M)
 
def get_number(M):
    result=list()
    for i in range(1,int(math.sqrt(M))):
        if M%i==0:
            result.append(i)
            result.append(int(M/i))
    result.sort()
    return(result)
    
def check_number(N,M):
    number=get_number(M)
    answer=list()
    for i in number:
        if M/i>=N:
            answer.append(i)
            
    return(answer[-1])
    
print(check_number(N,M))

Submission status: Runtime Error

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

ans = 1
for a in range(math.sqrt(M)):
    b = int(M / a)
    if M%a != 0:
        continue
    if a * N <= M:
        ans = max(ans, a)
    if b * N <= M:
        ans = max(ans, b)

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

def get_number(M):
    result=list()
    for i in range(1,int(math.sqrt(M))):
        if M%i==0:
            result.append(i)
            result.append(int(M/i))
    result.sort()
    return(result)
    
def check_number(N,M):
    number=get_number(M)
    answer=list()
    for i in number:
        if M/i>=N:
            answer.append(i)
            
    return(answer[-1])
    
check_number(N,M)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M = map(int,input().split())
R = M//N+1
R = sorted(np.arange(R),reverse=True)
for i in R :
    if M % i == 0 :
        if (M-i*(N-1))%i == 0 :
            print(i)
            break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
N,M = map(int,input().split())
R = M//N+1
R = sorted(np.arange(R),reverse=True)
for i in R :
    if (M-i*(N-1))%i == 0 :
        print(i)
        break

Submission status: Runtime Error

Solution code:
import math

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

d = max(d for d in range(1, math.ceil(M / (N - 1))) if M % d == 0)
print(d)

Submission status: Runtime Error

Solution code:
N, M = map(int, 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
  
fct = factorize(M)
#print(fct, num(fct))

ans = 1
for div in divisorize(fct):
    #print(div, num(div))
    temp = num(div)
    if N * temp <= M:
      ans = max(ans, temp)
      
print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, 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
  
fct = factorize(M)
#print(fct, num(fct))

sum_i = int(1e9+7)
for div in divisorize(fct):
    #print(div, num(div))
    temp = num(div)
    if temp >= N:
      sum_i = min(sum_i, temp)
      
print(M // sum_i)

Submission status: Runtime Error

Solution code:
iN,iM = [int(_) for _ in input().split()]
iD = iM // iN
if iM % iN == 0:
    print(iD)
else:
    aD = []
    for i in range(1,int(iM**0.5)+1):
        if iM % i == 0:
            if iD > i : aD.append(i)
            j = iM//i
            if iD > j :aD.append(j)
    print(max(aD))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
import numpy as np

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
res = M % np.arange(1, num+1, dtype='uint32')[::-1]
print(num - np.argmax(res == 0))

Submission status: Runtime Error

Solution code:
import math
import numpy as np

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
res = M % np.arange(1, num+1)[::-1]
print(num - np.argmax(res == 0))

Submission status: Runtime Error

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

max_ans = M // N

tmpM = M
insu = {}
tmp = 2
while tmpM != 1:
    if tmpM % tmp == 0:
        insu[tmp] = insu.get(tmp, 0) + 1
        tmpM = tmpM // tmp
        continue
    else:
        if tmp == 2:
            tmp = 3
        elif tmpM // tmp == 1:
            tmp = tmpM
        else:
            tmp += 2

ins = set()
for k, v in insu.items():
    # print(ins, k, v)
    ins.add(1)
    for s in list(ins):
        t = 1
        for _ in range(v):
            t *= k
            ans = t * s
            if ans > max_ans:
                break
            ins.add(ans)
# print(ins)
print(max(ins))

Submission status: Runtime Error

Solution code:
import math

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

ans = 1
for i in range(1,int(math.sqrt(M)+1)+1):
  if M % i != 0:#約数ではないとき
    continue
  B = M / i
  
  if (A * N <= M):
    ans = max(ans,A)
  if (B * N <= M):
    ans = max(ans,B)

print(ans)

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, raw_input().split())

start = None
if M % 2 == 1 and (M//N + 1) % 2 == 0:
    start = M//N
    step = -2
else:
    start = M//N + 1
    step = -1

for i in range(start, 0, step):
    if M % i == 0:
        print i
        break

Submission status: Runtime Error

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

res = 1
for i in range(1, M + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if long(i) * N <= M:
		res = max(res, i)
	if long(j) * N <= M:
		res = max(res, j)
print res

Submission status: Runtime Error

Solution code:
import math, collections, itertools, functools, operator
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:
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    factors.append(p)
                    cur = div
                else:
                    break
        if cur != 1:
            factors.append(cur)
        return factors
    @staticmethod
    # Returns a list of factors
    def factors(n):
        pf = PrimeUtils.pfd(n)
        pfc = collections.Counter(pf)
        ppv = [[pow(p, i) for i in range(n+1)] for p,n in pfc.items()]
        return [functools.reduce(operator.imul, x) for x in itertools.product(*ppv)]

N, M = map(int, input().split())
for factor in sorted(PrimeUtils.factors(M)):
    if N <= factor:
        print(M // factor)
        break
else:
    print(1)

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())
_M = M
primes = [1]
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
devides[1] = 1
for prime in primes:
  _devides = [d for d in devides]
  for i in range(N):
    if devides[i]:
      if i * prime < N:
        _devides[i * prime] = 1
      else:
        ans = max(M // i // prime, ans)
  devides = _devides
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if i*n<=m:
    if i <= y:
      ans=max(ans,i)
    if (m/i)*n<=m:
      ans=max(ans,m/i)
print(ans)

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())
_M = M
primes = []
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
devides[1] = 1
for prime in primes:
  _devides = [d for d in devides]
  for i in range(N):
    if devides[i]:
      if i * prime < N:
        _devides[i * prime] = 1
      else:
        ans = max(M // i // prime, ans)
  devides = _devides
print(ans)

Submission status: Runtime Error

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

res = 1
for i in range(1, N + 1):
	if i > M * M:
		break
	iif M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res

Submission status: Runtime Error

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

res = 0
for i in range(1, N + 1):
	if i > M * M:
		break
	iif M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res

Submission status: Runtime Error

Solution code:
def d_partition(N, M):
    if N == 1:
        return M  # a_1 = M とする他なく、これが最大公約数

    def divisor_list(n):
        # n の正の約数のリスト
        ret = []
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.extend([k, n // k])
        ret.sort()
        return ret

    divisor_m = divisor_list(M)
    ans = -1
    for d in divisor_m:
        if d <= M // N:
            ans = d
        else:
            break
    return ans

sys.stdin = io.StringIO(textwrap.dedent(INPUT).strip())
N, M = [int(i) for i in input().split()]
print(d_partition(N, M))

Submission status: Runtime Error

Solution code:
import math
N,T  = list(map(int,input().split()))
#d = int(T / N)
m = []
def ans():
    for i in range(1,int(math.sqrt(T))):    
            if T % i ==0:
                m.append(i)
    print (m[-1])
if T % N == 0:
    print (d)
else:
    ans()

Submission status: Runtime Error

Solution code:
import sys

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

for i in range(int(math.sqrt(M))+1, 1, -1):
    if M % i == 0:
        if M >= N*i:
            print(i)
            sys.exit()

Submission status: Runtime Error

Solution code:
import math
n, m,X = map(int, input().split(),1)
for i in range(1,32000):
	if m%i==0:
		if i*n<=m:
			X=max(X, i)
		if (m//i)*n<=m:
			X=max(X, m//i)
print(X)

Submission status: Runtime Error

Solution code:
import math
n, m = map(int, input().split()) X=1
for i in range(1,32000):
	if m%i==0:
		if i*n<=m:
			X=max(X, i)
		if (m//i)*n<=m:
			X=max(X, m//i)
print(X)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
N,T  = list(map(int,input().split()))
#d = int(T / N)
m = 1
def ans():
    for i in range(1,int(math.sqrt(T))):    
            if T % i ==0:
                m = max(1,i)
    print (m)
if T % N == 0:
    print (d)
else:
    ans()

Submission status: Runtime Error

Solution code:
import sys
Input = sys.stdin.readline

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

for i in range(int(math.sqrt(M))+1, 1, -1):
    if M % i == 0:
        if M >= N*i:
            print(i)
            sys.exit()

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
def f(N,M+1):
    if M%i ==0:
        return(M//i)
print(f(N,M+1))

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 = max(0,mid-10)
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)