TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
n, m = (list)(map(int, input().split()))

upper = m//n
ans = 0
for i in reversed(range(1, upper+1)):
    if m % i == 0:
        ans = i
        if (m // i) > i and (m // i) <= upper:
            ans = m // i
            break

print(ans)


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


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

upper = m//n
ans = 0
for i in range(1, upper+1):
    if m % i == 0:
        ans = i
        if (m // i) > i and (m // i) <= upper:
            ans = m // i
            break

print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
input = sys.stdin.readline

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

    print(i)

import bisect
import math
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
if M % N == 0:
    print(M//N)
else:
    upper = math.ceil(M/N)
    factor = set()
    for i in range(1, int(M**0.5)+1):
        if M % i == 0:
            factor.add(i)
    
    factor1 = set()
    for i in factor:
        factor1.add(M//i)
    factor |= factor1
    
    factor = sorted(list(factor))
    print(factor[bisect.bisect_right(factor, upper)-1])

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from fractions import gcd
N, M = map(int, input().split())
cnt = M // N
M -= N * cnt
ans = 1
while True:
    if cnt == 1:
        ans = cnt
        break
    if M == 0:
        ans = cnt
        break
    tmp = gcd(cnt, M)
    if tmp != 1:
        ans = min(cnt, tmp)
        break
    M += N
    cnt -= 1

print(ans)

from fractions import gcd
N, M = map(int, input().split())
k = 0
while True:
    if M % (N + k) == 0:
        ans = M // (N+k)
        break
    k += 1
print(ans)

from fractions import gcd
N, M = map(int, input().split())
cnt = M // N
M -= N * cnt
ans = 1
while True:
    if M == 0:
        ans = cnt
        break
    tmp = gcd(cnt, M)
    if tmp != 1:
        ans = min(cnt, tmp)
        break
    M += N
    cnt -= 1

print(ans)

import bisect
def make_divisors(N):
    divisors = []
    for i in range(1, int(N**0.5)+1):
        if N % i == 0:
            divisors.append(i)
            if i != N // i:
                divisors.append(N//i)
    divisors.sort()
    return divisors
N, M = map(int, input().split())
lst = make_divisors(M)
print(lst[bisect.bisect_right(lst, M//N)-1])

Verdicts: Wrong Answer

Time Limit Exceeded

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
vn,m=map(int,input().split())

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

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

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

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

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

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

ans=0

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

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

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m))
params = {}
for i in range(2, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)

mdn = m // n
for i in params:
    if mdn <= i:
        print(i)
        break

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)

import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(2, 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 m > m / i:
        break
    maxans = i
print(maxans)

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 / param:
        break
    ans = param
print(ans)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,m=map(int,input().split())

limit=int(m**(1/2))+1

divisors=[]
for d in range(limit):
    if m%d==0:
        divisors.append(d)
        divisors.append(m//d)
ans=1

for d in divisors:
    if n*d<=m:
        ans=d
print(ans)


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

limit = int(m**(0.5))
ans = 1
for d in range(1, limit+1):
    if m % d == 0:
        if m>=d*n:
            ans = max(ans,d)
        if m>=(m//d)*n:
            ans=max(ans,(m//d))

print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
n, m = map(int, input().split(' '))
     
h = int(m/n)+1
x = 0

if h%2 == 0:
    if m%h == 0:
        print(h)
        sys.exit()
    h -= 1
    for a in range(h, 0, -2):
        if a*n <= m:
            if m%a == 0:
                print(a)
                sys.exit()
        else:
            continue
else:
    if m%h == 0:
        print(h)
        sys.exit()
    for a in range(h, 0, -2):
        if a*n <= m:
            if m%a == 0:
                print(a)
                sys.exit()
        else:
            continue

import sys

def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num%i == 0:
            divisors.append(i)
            if num//i != i:
                divisors.append(num//i)
        divisors.sort()
        return divisors

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

divisors = make_divisors(n)
for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()

import sys

def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num%i == 0:
            divisors.append(i)
            if num//i != i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

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

divisors = make_divisors(m)

for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288




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

ans = 0
for i in range(1, int(math.sqrt(M))+1):

    if M < i*N:
        break

    if M >= (M//i)*N:
        ans = M//i
        break

    if M % i == 0:
        ans = i



print(int(ans))

import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288




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

ans = 0
for i in range(1, int(math.sqrt(M))+1):

    if M < i*N:
        break

    if M % i == 0:
        if M >= (M//i)*N:
            ans = M//i
            break

        ans = i



print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split(" "))
div1 = []
div2 = []

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        div1 += (i,)
        div2 += (M//i,)
for d in div2:
    if d * N <= M:
        print(d)
        break
else:
    div1 = div1[::-1]
    for d in div1:
        if d * N <= M:
            print(d)
            break

import math

N, M = map(int, input().split(" "))
div1 = []
div2 = []

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        div1 += (i,)
        div2 += (M//i,)
for d in div2:
    if d * N <= M:
        print(d)
        break
else:
    div1 = div1[::-1]
    for d in div1:
        if d * N <= M:
            print(d)
            break

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())


def factorize(n):
    if n == 1:
        return [1]

    i, factors = 2, []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


factors = factorize(M)
n_factors = len(factors)

ans = 0
for i in range(1 << n_factors):
    x = 1
    for j in range(n_factors):
        if i & (1 << j):
            x *= factors[j]
    y = M // x
    print(x, y, N <= y)
    if N <= y:
        ans = max(ans, x)
print(ans)


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


def make_divisors(n):
    i, divisors = 1, []
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
        i += 1
    return divisors


ans = 0
for x in make_divisors(M):
    if N <= M // x:
        ans = max(ans, x)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
n,m = map(int, input().split())
if (n==1):
    print(m)
    exit(0)
for i in range(1,int(math.sqrt(m))+1):
    if (m%i==0):
        if(n<=i):
            print(m//i)
            exit(0)
        elif(n<=m//i):
            print(i)
            exit(0)


100000 1000000000

import math
n,m = map(int, input().split())
factors = []
comp = m//n
for i in range(int(math.sqrt(m)),0,-1):
    if(m%i==0):
        factors.insert(0,i)
        factors.append(m//i)
for item in factors[::-1]:
    if (item <= comp):
        print(item)
        exit(0)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):





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


def enum_divisor(n):
    ret = []
    for i in range(1, int(n**0.5)):
        if n % i == 0:
            ret.append(i)
    return ret


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    
    lis = enum_divisor(x)
    print(lis[-1])







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


def enum_divisor(n):
    ret = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            ret.append(i)
    return ret


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    
    lis = sorted(enum_divisor(x), reverse=true)
    for l in lis:
        if l <= x:
            print(l)
            exit()








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


def enum_divisor(n):
    ret = []
    for i in range(1, int(n**0.5)):
        if n % i == 0:
            ret.append(i)
    return ret


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    
    lis = sorted(enum_divisor(x), reverse=True)
    for l in lis:
        if l <= x:
            print(l)
            exit()








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


def make_divisors(n):
    lower_divisors = []
    upper_divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)

    upper_divisors.reverse()
    return lower_divisors + upper_divisors


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    divisors = make_divisors(m)[::-1]
    for d in divisors:
        if d <= x:
            print(d)
            exit()

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)


from math import sqrt

def factorization(n):
    l = set()
    for i in range(1, int(sqrt(n))+1):
        if not n % i:
            l.add(i)
            l.add(n//i)
    return l

N, M = map(int, input().split())
f = factorization(M)
ans = 1
for i in f:
    if (M / i) >= N:
        ans = max(i, ans)
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,M = map(int,input().split())

a = int(M/N)

if M % 2 == 0:
m = M / 2
a =  int(a/2) + 1

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

if c == 1 and M % 2 == 0
    c = 2
    
print(c)



import math

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

a = int(M/N)
q = int(math.sqrt(M))

m = 0
for i in range(1,q+1):
    if M % i == 0:
        if i <= a:
            m = max(m,i)
        b = int(M / i)
        if b <= a:
            m = max(m,b)

print(m)



Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
N, M = list(map(int, input().split()))
if N == 1:
  print(M)
  exit()
X = int(math.sqrt(M))+1
for i in range(N, X):
  if M % i == 0:
      print(int(M/i))
      exit()
print(1)

import math
N, M = list(map(int, input().split()))
if N == 1:
  print(M)
  exit()
X = int(math.sqrt(M))+1
for i in range(N, X):
  if M % i == 0:
      print(int(M/i))
      exit()
X = int(M / N)
for i in range(X, 0, -1):
  if M % i == 0:
      print(i)
      exit()
print(1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import fractions
n,m=map(int,input().split())
if m%n==0:
    print(int(m/n))
else:
    print(fractions.gcd(m//n,m//n+m%n))



import fractions
n,m=map(int,input().split())
if m%n==0:
    print(int(m/n))
else:
    ans=1
    for i in range(m//n,1,-1):
        c=fractions.gcd(i,m-i*n)
        if c>ans:
            ans=c
            break
    print(ans)




import fractions
n,m=map(int,input().split())
if m%n==0:
    print(int(m/n))
else:
    ans=1
    for i in range(2,m//n+1):
        c=fractions.gcd(i,m-i*n)
        if c>ans:
            ans=c
    print(ans)




import fractions
n,m=map(int,input().split())
if m%n==0:
    print(int(m/n))
else:
    ans=1
    for i in range(m//n,1,-1):
        c=fractions.gcd(i,i+m-i*n)
        if c>ans:
            ans=c
            break
        else:
            continue
    print(ans)




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



Verdicts: Wrong Answer

Wrong Answer

Time Limit Exceeded

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())

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

def main():
  N, M = map(int, input().split())

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from fractions import gcd
n,m=map(int,input().split())
ans=1
for i in range(m//n+1):
  if gcd(m-i*(n-1),i)==i:
    ans=i
print(ans)

n,m=map(int,input().split())
def divisors(n):
  div=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      div.append(i)
      if not i==n//i:
        div.append(n//i)
  div=sorted(div)[::-1]
  return div
ans=1
for i in divisors(m):
  if m-i*(n-1)>0:
    ans=i
    break
print(ans)

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ans = 0
  x = M
  for i in range(1,b+1):
    x -= N
    if gcd(i,x)>ans:
      ans = gcd(i,x)
  print(ans+1)


from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ls = []
  ans = 0
  for i in range(1,b+1):
    x = M - i*N
    if gcd(i,x)>ans:
      ans = gcd(i,x)
  print(ans)

from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  g = 0
  for i in range(1,c+1):
    if c%i==0:
      if g<gcd(c//i,b):
        g = gcd(c//i,b)
  print(g)

from fractions import gcd
N, M = map(int, input().split())
if M%N==0:
  print(M//N)
else:
  c = M%N
  b = M//N
  ans = 0
  x = M
  for i in range(1,b+1):
    x -= N
    if gcd(i,x)>ans:
      ans = gcd(i,x)
  print(ans)
  print(' ')

N, M = map(int, input().split())
g = []
for i in range(1,M+1):
  if M%i==0:
    j = M//i
    if i<=M//N:
      g += [i]
    if j<=M//N:
      g += [j]
  if i>M**0.5:
    break
print(max(g))

Verdicts: Wrong Answer

Time Limit Exceeded

Wrong Answer

Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
n, m = map(int, input().split())


def divisor(num):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


ans = 0
for i in divisor(m):
    if n <= m // i:
        ans = i
    else:
        break
print(ans)

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


def divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors


ans = 0
for i in divisor(m):
    if n <= m // i:
        ans = i
    else:
        break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from math import sqrt

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

a = 1
flg = False
for i in range(2, int(sqrt(M)) + 1):
    if i <= M / N:
        a = max(a, i)
    b = M // i
    if b <= M / N:
        a = max(a, b)

print(a)


from math import sqrt

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

a = 0
flg = False
for i in range(1, int(sqrt(M)) + 1):
    if M % i==0:
        if i <= M / N:
            a = max(a, i)
        b = M // i
        if b <= M / N:
            a = max(a, b)

print(a)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

n,m=map(int,input().split())
l=divisore(m)
for i in l:
  if m/n>=i:
  print(i)
  exit()

def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

n,m=map(int,input().split())
l=divisore(m)
print(l)
for i in l:
 if m/n>=i:
  print(i)
  exit()

def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

n,m=map(int,input().split())
l=divisore(m)
for i in l:
 if m//n>=i:
  print(i)
  exit()

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
N, M = map(int, input().split())

def factorization(n):
    factor_list = []
    if n <= 1:
        return factor_list
    limit = int(math.sqrt(n))+1
    for i in range(2, limit):
        if n % i == 0:
            factor_list.append(i)
            if not n == i**2:
                factor_list.append(n//i)

    return factor_list

factor = factorization(M)
factor.sort()
print(factor)
ans = 1
for f in factor:
    if N * f <= M and f > ans:
        ans = f
print(ans)

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

def factorization(n):
    factor_list = []
    if n < 1:
        return factor_list
    limit = int(math.sqrt(n))+1
    for i in range(1, limit):
        if n % i == 0:
            factor_list.append(i)
            if not n == i**2:
                factor_list.append(n//i)
    factor_list.sort()
    return factor_list

factor = factorization(M)


ans = 1
for f in factor:
    if N * f <= M and f > ans:
        ans = f
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())

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

print(ans)

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

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

print(int(ans))

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

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

print(int(ans))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

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

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

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

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/l[i]:
    o.append(l[i])
print(max(o))


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

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


n,m=map(int,input().split())
def divisor_gen(n,m):
  l=[]
  o=[]
  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))
divisor_gen(n,m)


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


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


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


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


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


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#include <cstdio>

using namespace std;

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

    return divs;
}

int main() {
    int n, m;

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

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


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

def divisor(m):
    ans = []
    for i in range(1, int(math.sqrt(m)) + 1):
        if m % i == 0:
            ans.append(i)
            ans.append(m // i)

    return sorted(ans)


divs = divisor(m)
j = len(divs) - 1
while True:
    if divs[j] * n <= m:
        print(divs[j])
        break
    j -= 1


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,m=map(int,input().split())
p=1
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    if m//i>=n:
      p=max(i,m//i,p)
print(p)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,M = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
div = sorted(make_divisors(M))
import bisect
ind = bisect.bisect_left(div,N)
print(div[ind])


import bisect
N,M = map(int,input().split())
maxa = M//N
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
mdiv = sorted(make_divisors(M))
ans = mdiv[bisect.bisect_right(mdiv,maxa)-1]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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))

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

ds = [x for x in range(1, int(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))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,M=map(int,input().split())

base=M//N
answer=[0]*N
j=0

for i in range(base,base//2+1,-1):
    if M%i==0:
        answer[j]=i
        break
    elif M%(base-i+1)==0:
        answer[j]=base-i+1
        j+=1
print(max(answer))

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

base=M//N
li=[]


for i in range(1,int(pow(M,1/2))+1):
    if i<=base and M%i==0:
        li.append(i)
    if M%i==0 and M//i<=base:
        li.append(M//i)

print(max(li))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,m = map(int,input().split())
ans = 0
tmp = int(m/n)
for i in range(1,int(np.sqrt(m))):
    if m%i == 0:
        if (ans < i) and(i <= tmp):
            ans = i
print(ans)

import numpy as np

n,m = map(int,input().split())
ans = 0
tmp = int(m/n)
for i in range(1,int(np.sqrt(m)+1)):
    if m%i == 0:
        if (ans < i) and(i <= tmp):
            ans = i
        tmp2 = m//i
        if (ans < tmp2) and(tmp2 <= tmp):
            ans = tmp2
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,M=[int(i) for i in input().split()]
print(N,M)
m=3;list=[1];n=M
while m<=n:
    if n%m==0:
        list.append(m)
    m=m+1
    
print(list)
k = len(list)
for i in range(k):
    if N<list[i]:
        break

ans = int(M/list[i])
print(ans)

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

if M % N == 0:    print(M//N)
elif M//N > 100000:
    for i in range(N,M//2+1):
        if M % i == 0:
            print(M//i)
            break
    else:
        print(1)
else:
    m = M//N
    for i in range(2,m)[::-1]:
        if M % i == 0:
            print(i)
            break
    else:
        print(1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x > mid:
    ans = []
    for i in range(1, mid+1):
        ans.append(i)
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    ans = []
    for i in range(x, 0, -1):
        if M%i == 0:
            print(i)
            break

import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x >= mid:
    ans = []
    for i in range(1, mid+1):
        ans.append(i)
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    for i in range(x, 0, -1):
        if M%i == 0:
            print(i)
            break

import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x >= mid:
    ans = []
    for i in range(1, mid+1):
        ans.append(i)
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    for i in rreversed(range(1, x+1)):
        if M%i == 0:
            print(i)
            break

import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    for i in range(x, 0, -1):
        if M%i == 0:
            print(i)
            break

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from fractions import gcd

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

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

prime = reversed(primes(m))

for p in prime:
    x = m - p
    if gcd(x, n-1) % p == 0:
        print(p)
        exit()

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

def divisor(n):
    res = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.append(i)
            if n % n//i == 0:
                res.append(n//i)

    res.sort()
    return res

d = divisor(M)
ans = 1
for x in d:
    m = M
    m -= x * (N - 1)
    if m > 0 and m % x == 0:
        ans = x

print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

def main():
    N, M = map(int, input().split())

    st = {1, M}
    d = 2
    while d * d <= M:
        if M % d == 0:
            st.add(d)
            st.add(M // d)
        d += 1

    ans = 1
    for d in st:
        if d >= N:
            e = M // d
            ans = max(ans, e)
    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#python D-Partition.py

import math
line = list(map(int, input().split(" ")))
N = int(line[0])
M = int(line[1])





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


from math import sqrt

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

divisor = set([])
for i in range(1,int(sqrt(M))+1):
	if M % i == 0:
		if i <= int(M / N):
			divisor.add(i)
		if (M // i) <= int(M / N):
			divisor.add(M // i)

print(max(divisor))


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,M=map(int,input().split())
a=M//N
b=min(a,N)
while (M&b)!=0:
  b-=1
print(b)

N,M=map(int,input().split())
D=[]
for i in range(1,int(M**0.5+1)):
  if M%i==0:
    D.append(i)
    D.append(M//i)
D.sort()
print(D)
for j in D:
  if j >=N:
    print(M//j)
    exit()

N,M=map(int, input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
A=make_divisors(M)
for i in range(len(A)):
  if A[i]>=N:
    print(A[-1-i])
    exit()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

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

print(calc())

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N, M = list(map(int,input().split()))
 
d = int(M/N)
 
if M%N == 0:
	print(d)
else: 
	for i in range(d):
		if M%(d-i) == 0:
			print(d-i)
	
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

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

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

	
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

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

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

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

	
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

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

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
	
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

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

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

	
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def divisor(n):
    i = 1
    res = []
    for i in range(1, n**.5 + 1)
        if n%i == 0:
            res.append(i)
            if n//i not in res:
                res.append(n//i)
    res.sort(reverse=True)
    return res

def main():
    n, m = map(int, input().split())
    md = divisor(m)
    for i in md:
        if i*n <= m:
            print(i)
            exit()

if __name__ == '__main__':
    main()

def divisor(n):
    i = 1
    res = set()
    for i in range(1, int(n**.5) + 1):
        if n%i == 0:
            res.add(i)
            res.add(n//i)
    return res

def main():
    n, m = map(int, input().split())
    md = list(divisor(m))
    md.sort(reverse=True)
    for i in md:
        if i*n <= m:
            print(i)
            exit()

if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def divisors(N):
    U = int(N ** 0.5)
    res = []
    all(res.extend((i, N // i)) for i in range(1, U) if N % i == 0)
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


def divisors(N):
    U = int(N ** 0.5)
    L = {i for i in range(1, U + 1) if N % i == 0}
    R = {N // r for r in L}
    return L | R

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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])

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

import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    maxGCD = 1
    for gcd in range(1, M):
        if gcd * gcd > M: break
        else:
            if M % gcd == 0:
                other = M // gcd
                if gcd >= N: maxGCD = max(other, maxGCD)
                if other >= N: maxGCD = max(gcd, maxGCD)
    print(maxGCD)

    return 0

if __name__ == "__main__":
    solve()

Verdicts: Runtime Error

Runtime Error

Accepted