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


import math
N, M = map(int, input().split())
ans = 1
for i in range(2, math.floor(math.sqrt(M))//3):
    if M % i == 0:
        if M // i >= 1:
            ans = i
        else:
            break
print(ans)


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

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0.0:
        if M // i >= N and ans < i:
            ans = i
        if M // (M // i) >= N and ans < (M // i):
            ans = M // i
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):
from math import floor, ceil
N, M = [int(elem) for elem in input().split(' ')]

max_gcd = 1
cand = M // N

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

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

def factorize(n):
    fct = []  
    b, e = 2, 0  
    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):
    try:
        b, e = fct.pop()  
    except:
        return []
    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)


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

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

        g2 = M / g
        if M % g2 == 0 and M / g2 >= N:
            ans = max(ans, int(g2))
    print(ans)


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

ans = 0
for x in range(1, int(M ** 0.5) + 1):
    if M % x != 0:
        continue
    else:
        x1, x2 = x, M // x
        if M // x1 >= N:
            ans = max(ans, x1)
        if M // x2 >= N:
            ans = max(ans, x2)

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

i=1
while i*i < M:
  if M % i == 0:
    maxg = M // N
  i += 1

print(maxg)

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

i=1
while i <= M//N: 
  if M % i == 0:
    maxg = i
    if M//i <= M//N:
      maxg = M // i
      break
  i += 1

print(maxg)


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

# coding: utf-8

# In[12]:


import numpy as np


# In[65]:


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


# In[66]:


def usage(n):
    print('
    fct = factorize(n)
    print(fct, num(fct))
    
    print('
    for div in divisorize(fct):
        print(div, num(div))


def factorize(n):
    fct = []  
    b, e = 2, 0  
    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()  
    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


# In[67]:


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


# In[68]:


div = np.array(func(M))


# In[69]:


print(div[div < M/N].max())



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

# In[11]:


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


# In[12]:


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]


# In[14]:


for x in make_divisors(M)[::-1]:
    if M//x >= N:
        ans = x
        break
print(ans)


# In[ ]:






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=map(int,input().split())

P=math.ceil(M**0.5)
ans=1
i=1

while i<=P:
  if M%i==0:
    j = M//i
    if j>=N:
      ans=j
  i +=1
      
print(ans)

from math import floor
N,M=map(int,input().split())
p= floor(M**0.5)
kumi=[]

for i in range(1,p+1):
  if M%i==0:
    kumi.append((i,M//i))
    
ans=1
for pair in kumi:
  if pair[0]>=N:
    ans = max(ans,pair[1])
  if pair[1]>=N:
    ans = max(ans,pair[0])
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())
if m%i==0:
    ans=m//i
else:
    ans=m//i-1
print(ans)

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())
l=make_divisors(m)
for i in l:
    if n<=i:
        ans=m//i
        break
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 = map(int, input().split())
ans = 1

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


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

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


if N == 1:
    ans = M

print(ans)


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

i = 1
ans = 0
while True:
    if i * i > M + 1:
        break
    j = M // i
    if M % i == 0 and M // i >= N:
        ans = max(ans, i)
    if M % j == 0 and M // j >= N:
        ans = max(ans, j)
    i += 1
    

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



divisors = []
for d in range(1, M+1):
    if d*d > M:
        break
    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())



divisors = []
for d in range(1, M+1):
    if d*d > M:
        break
    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())



divisors = []
for d in range(1, M+1):
    if d*d > M:
        break
    if M%d == 0:
        divisors.append(d)
        divisors.append(M//d)

ans = 1

divisors.sort()

for d in divisors:
    if N*d <= M:
        ans = d

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


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)


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)


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(int(M/i))
    ans = 1
    for x in tmp:
        if M / x >= N:
            ans = max(ans, x)
    print(ans)


Verdicts: Runtime Error

Runtime Error

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 = map(int, input().split())

ans = 1
if(N < M//N):
  i = N
  while(ans == 1 and i <= math.sqrt(M)):
    if(M % i == 0):
      ans = M//i
    i += 1
else:
  i = M//N
  while(ans == 1 and i >= 1):
    if(M % i == 0):
      ans = i
    i -= 1
  
print(ans)

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

ans = 1
if(N < M//N):
  i = N
  while(ans == 1 and i <= math.sqrt(M)):
    if(M % i == 0):
      ans = M//i
    i += 1
if(N >= M//N or ans == 1):
  i = M//N
  while(ans == 1 and i >= 1):
    if(M % i == 0):
      ans = i
    i -= 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 = 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

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


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


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

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

Verdicts: Runtime Error

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 main():
    from math import gcd
    n, m = map(int, input().split())

    if gcd(n, m) == 1:
        print(1)
        exit()

    l = int(m / n)
    for i in range(l, 1, -1):
        p, q = divmod(m, i)
        if q != 0 or p < n:
            continue

        print(i)
        break


if __name__ == '__main__':
    main()


def main():
    from fractions import gcd
    n, m = map(int, input().split())
    ans = 1
    l = int(m / n)
    for i in range(2, l + 1):
        p, q = divmod(m, i)
        if q != 0 or p < n:
            continue

        ans = max(ans, i)

    print(ans)


if __name__ == '__main__':
    main()


def main():
    from fractions import gcd
    n, m = map(int, input().split())

    if gcd(n, m) == 1:
        print(1)
        exit()

    l = int(m / n)
    for i in range(l, 1, -1):
        p, q = divmod(m, i)
        if q != 0 or p < n:
            continue

        print(i)
        break


if __name__ == '__main__':
    main()


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


if __name__ == '__main__':
    main()


Verdicts: Runtime Error

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())
x = 0
m = 0
for i in range(10**5):
    if i**2 < M <= i*(i+1):
        m = i+1
        break
for i in range(N, m):
    if M % i == 0:
        x = M // i
        break
if x == 0:
    for i in reversed(range(1,m+1)):
        if M % i == 0:
            x = i
            break
print(x)

N, M = map(int, input().split())
x = 0
m = 0
for i in range(10**5):
    if i**2 < M <= (i+1)**2:
        m = i+1
        break
if m >N:
    for i in range(N, m):
        if M % i == 0:
            x = M // i
            break
if x == 0:
    for i in reversed(range(1, M //N +1)):
        if M % i == 0:
            x = i
            break
print(x)

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
import math

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

res = 0
tmp = math.ceil(m/n)
for i in range(1, tmp+1):
    res = (max(res, fractions.gcd(i, m-((n-1)*i))))
print(res)


import fractions

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

res = 0
tmp = math.ceil(m/n)
for i in range(1, tmp+1):
    res = (max(res, fractions.gcd(i, m-((n-1)*i))))
print(res)


import math

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

diff = float("inf")
res = 0
for i, j in array:
    if i >= n:
        res = max(res, j)
    if j >= n:
        res = max(res, i)
print(res)


Verdicts: Time Limit Exceeded

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):
#112_D
N,M=map(int,input().split())

divisors=[]
for i in range(1,int(M**.5)+1):
    if M%i==0:
        divitors.append(i)
        if i!=(M//i):
            divitors.append(M//i)
Ans=1
for x in divitors:
    if M//N>=x:
        Ans=x
    else:
        break
print(Ans)

#112_D
N,M=map(int,input().split())

divisors=[]
for i in range(1,int(M**.5)+1):
    if M%i==0:
        divisors.append(i)
        if i!=(M//i):
            divisors.append(M//i)
Ans=1
for x in sorted(divisors):
    if M//N>=x:
        Ans=x
    else:
        break
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 math

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

for i in range(1, math.ceil(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if m // i > n:
        continue
    ans = i
print(ans)

inputlist = list(map(int, input().split()))
n, m = inputlist[0], inputlist[1]

for i in range(1, int(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if i > m // n:
        continue
    ans = i
print(ans)
    

import math

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


ans = 0
for i in range(1, math.ceil(math.sqrt(m))+1):
    if m % i == 0:
        if min(i, m//i) >= n:
            ans = max(ans, max(i, m//i))
        elif max(i, m//i) >= n:
            ans = max(ans, min(i, m//i))
print(ans)

Verdicts: Runtime Error

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 = map(int, input().split())

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
for i in range(len(b)):
    if i * n <= m:
        a.append(i)
        print(max(a))

if len(b) == 2:
    print(1)
else:
    print(max(a))


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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
print(b)

for i in range(len(b)):
    if b[i] * n <= m:
        a.append(b[i])
print(a)

if len(b) == 2:
    print(1)
else:
    print(max(a))


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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
#print(b)

for i in range(len(b)):
    if b[i] * n <= m:
        a.append(b[i])
#print(a)

if len(b) == 2:
    print(1)
else:
    print(max(a))


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 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(reverse=True)
    return divisors

lis=make_divisors(m)

for mm in lis:
    if mm<=i:
        ans=mm
        break

print(ans)



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

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

    divisors.sort(reverse=True)
    return divisors

lis=make_divisors(m)

for mm in lis:
    if mm<=i:
        ans=mm
        break

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 = map(int,input().split())
divisors = []
for i in range(1,int(n**0.5)+1):
    if m % i == 0:
        divisors.append(i)
        divisors.append(n//i)
divisors.sort()
k = 0
for i in range(len(divisors)):
    if divisors[i] > m/n:
        k = i - 1
        break
    if i == len(divisors) - 1:
        k = len(divisors) - 1
print(divisors[i])


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

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

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 math
n,m=list(map(int,input().split()))
ret=1
for i in range(m//n+1,2,-1):
  if m%i == 0:
    ret=i
    break
print(ret)

[print(max([i for j in [[i,a[1]//i] for i in range(1,int(a[1]**0.5)+1) if a[1]%i==0] for i in j if a[1]//i>=a[0]])) for a in [list(map(int,input().split()))]]

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())
L = []
 
for i in range(1,(M**0.5)+1):
    if M % i == 0:
        L.append(i)
        L.append(int(M / i))
L1 = [i for i in L if M / i >= N]
print(max(L1))

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

if m%n==0:
    print(int(m/n))
else:
    for i in range(n+1,int(m/2)):
        if m%i==0:
            print(int(m/i))
            break


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


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())
for i in range(math.floor((M/N)**0.5),-1,-1):
    if M%i == 0:
        print(int(M/i))
        break

import math
N,M = map(int,input().split())
for i in range(1,math.floor((M/N)**0.5)):
    if M%i == 0:
        print(int(M/i))
        break

N,M = map(int,input().split())
a = []
for i in range(1,int(M**0.5)+1):
    if M%i == 0:
        a.append(i)
        a.append(int(M/i))
a.sort(reverse = True)
for i in a:
    if i <= M/N:
        print(i)
        break

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

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


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

for i in range(1, int(m**0.5)+1)[::-1]:
    if (m % i == 0):
        if m / i >= n:
            ans = max(ans, i)
        if i >= n:
            ans = max(ans, m // i)
print(ans)


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

ans = 0
for i in range(1, int(m ** 0.5) + 1):
    if m % i == 0:
        if m // i >= n:
            ans = max(ans, i)
        if i >= n:
            ans = max(ans, m // i)
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):
n,m=map(int,input().split())
d=[]
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    d.append(i,m//i)
d.sort(reverse=True)
for i in d:
  if i*n<=m:
    print(i)
    exit()

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(reverse=True)
for i in d:
  if i*n<=m:
    print(i)
    exit()

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 divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
n,m=map(int,input().split())
d=divisor(m)
d.sort(reverse=1)
for i in d:
  if m//i>=n:print(i):exit()

n,m=map(int,input().split())
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
ans=0
for i in divisor(m):
  if m//i>=n:ans=max(ans,i)
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 = map(int,input().split())

max = m//n

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





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





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

max = m//n
lis = []


for i in range(int(m**0.5)):
    if i != 0 and m%i == 0:
        lis.append(i)
l = len(lis)
for i in range(l):
    if m/lis[i] != lis[i]:
        lis.append(m//lis[i])

lis.sort()
lis = lis[::-1]

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





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):
#!/usr/bin/env python3

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

ans = 1
num = int(m**0.5)+1

for i in range(1, num):
    if m % i != 0:
        continue
    j = m//i
    if i >= n:
        ans = max(ans, j)
    # if j >= n:
    #     ans = max(ans, i)
print(ans)


#!/usr/bin/env python3

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

ans = 1
num = int(m**0.5)+1

for i in range(1, num):
    if m % i != 0:
        continue
    j = m//i
    if i >= n:
        ans = max(ans, j)
    if j >= n:
        ans = max(ans, i)
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 sympy
n,m = map(int, input().split())

N = sympy.divisors(m)

for i in range(len(N)):
    if N[i] <= m/n:
        print(N[i])
        break

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)
  divisors.sort(reverse=True)
  return divisors

numbers = make_divisors(m)
for i in range(len(numbers)):
  if numbers[i] <= m/n:
    print(numbers[i])
    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):
import numpy as np
def factorize(n):
    fct = []  
    b, e = 2, 0  
    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()  
    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
def yaku(n):
    fct = factorize(n)
    y = divisorize(fct)
    ys = []
    for yy in y:
        ys.append(num(yy))
    ys.sort()
    return ys

n,m = list(map(int,input().split()))
y = yaku(m)
np.max(np.array(y)[np.array(y) <= m/n])

import numpy as np
def factorize(n):
    fct = []  
    b, e = 2, 0  
    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()  
    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
def yaku(n):
    fct = factorize(n)
    y = divisorize(fct)
    ys = []
    for yy in y:
        ys.append(num(yy))
    ys.sort()
    return ys

n,m = list(map(int,input().split()))
if n == 1 and m == 1:
    print(1)
else:
    y = yaku(m)
    print(np.max(np.array(y)[np.array(y) <= m/n]))

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
from math import sqrt, floor
from bisect import bisect_right as bi_r

def factorize(n):
    res = []
    for i in range(1, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i, n // i)
    return sorted(res)

n, m = map(int, sys.stdin.readline().split())


def main():
    res = factorize(m)
    ans = res[bi_r(res, m / n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

def factorize(n):
    res = []
    for i in range(1, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i)
            res.append(n // i)
    return sorted(res)

n, m = map(int, sys.stdin.readline().split())

def main():
    res = factorize(m)
    ans = res[bi_r(res, m / n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    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 = map(int,input().split())
k = (m+1) // n
for i in range(1, k+1):
    if m % i == 0:
        ans = max(i, m // i)
    if i > m ** 0.5:
        break

print(ans)

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


n, m = map(int,input().split())
k = (m+1) // n

div = calc_divisor(m)
for i in div:
    if i <= k:
        ans = i
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())
for i in range(1, min(m//n, int(m**0.5))+1)[::-1]:
    if m%i == 0:
        print(max(m//i, i)
        break

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

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

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

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


# coding: utf-8
import math

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

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


# coding: utf-8
import math

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

ans = 0
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i == 0:
        if i >= n:
            ans = m / i
        elif (m/i) >= n:
            ans = i

# coding: utf-8
import math

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

ans = 0
divList = []
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i == 0:
        j = m / i
        divList.append(i)
        divList.append(j)
divList = sorted(divList)
for i in divList:
    if i < n:
        continue
    ans = m / i
    break

print(int(ans))


Verdicts: Runtime Error

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):
nm=[int(x) for x in input().split()]
for x in range(int(nm[1]/nm[0]),1,-1):
    print(x)
    if(nm[1]%x==0):
        print(x)
        break

n,m = map(int,input().split())
def getDivisor(inte):
    Ans1 = [1]
    Ans2 = [inte]
    for i in range(2,int(inte**(0.5))):
        if inte % i == 0:
            Ans1.append(i)
            Ans2.append(int(inte/i))
    if inte % inte**(0.5) == 0:
        Ans1.append(int(int(inte**(0.5))))
    Ans = Ans1 + Ans2[::-1]
    return Ans

limit = int(m/n)
for i in reversed(getDivisor(m)):
    if i <= limit:
        print(i)
        break


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())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m//n
  for i in range(a,0,-1):
    s = m-n*i
    if (s+i)%i==0:
      print(i)
      exit()

from fractions import gcd
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
    a = m%n
    b = m//n
    c = a+b
    while True:
        if gcd(b,c)!=1:
            print(gcd(b,c))
            exit()
        else:
            c -= 1
print(1)

n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m/n
  l = []
  for i in range(int(m**0.5),0,-1):
    if m%i==0:
      l.append(i)
      l.append(m//i)
  l = sorted(l)[::-1]
  for j  in l:
    if j<=a:
      print(j)
      exit()
  else:
    print(1)

Verdicts: 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):
import math
N, M = map(int, input().split())
mx = 0
for i in range(1, math.floor(math.sqrt(M))+1):
    if M % i == 0:
        if M // i >= N:
            mx = max(mx, i)
    	if i >= N:
        	mx = max(mx, M//i)
print(mx)

import math
N, M = map(int, input().split())
mx = 0
for i in range(1, math.floor(math.sqrt(M))+1):
    if M % i == 0:
        if M // i >= N:
            mx = max(mx, i)
    	else:
            mx = max(mx, M//i)
print(mx)

def make_divisors(div, n):
    divisors = []
    mx = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if n // i >= div:
                mx = max(mx, i)
            if i != n // i:
                divisors.append(n//i)
                if i >= div:
                    mx = max(mx, n // i)
    return divisors, mx

n,m = map(int, input().split())
divisors, mx = make_divisors(n, m)
print(mx)

Verdicts: Runtime Error

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




import math

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

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
    if (m/i)*n<=m:
      ans=max(ans,m/i)
print(int(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 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)


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

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = int(TMPM/i)

if TMPM > 1 or len(prime_dic) == 0:
    prime_dic[TMPM] = 1

max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

    


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 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
ans = 1
for i in make_divisors:
    if i>=n:
        ans=max(ans,m//i)
print(ans)

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)
    divisors.sort()
    return divisors
ans = 1
for i in make_divisors(m):
    if i>=n:
        ans=max(ans,m//i)
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 fractions
N, M = map(int, input().split())
ans = fractions.gcd(M//N,(M//N)+M%N)
print(ans)

import math
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
N, M  = map(int, input().split())
div = make_divisors(M)
ans = 0
for i in div:
    if M // i >= N:
        ans = max(ans,i)
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())
gcd = m//n
while n*gcd != m:
  gcd = M//n
  n = 1 + (M-1)//gcd
print(gcd)

n,m = map(int,input().split())
gcd = m//n
while n*gcd != m:
  n = 1 + (M-1)//gcd
  gcd = M//n
print(gcd)

n,m = map(int,input().split())
gcd = m//n
while n*gcd != m:
  gcd = m//n
  n = 1 + (m-1)//gcd
print(gcd)

Verdicts: Runtime Error

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 = map(int,input().split())

sq = math.sqrt(M)

for i in range(1,sq+1):
  if M % i == 0:
    if i <= math.floor(M/N):
      ans = i
    
print(int(ans))

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

if M % N != 0:
  
  a = int(M % N)
  b = (M - a) / N
  c = fractions.gcd(a, b)
  print(int(c))
else:
  print(int(M/N))


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

if M % N != 0:
  
  a = int(M % N)
  b = (M - a) / N
  c = math.gcd(a, b)
  print(c)
else:
  print(int(M/N))


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

if M % N != 0:
  
  a = int(M % N)
  b = (M - a) / N
  c = math.gcd(a, b)
  print(c)
else:
  print(int(M/N))


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

sq = math.sqrt(M)
sq = math.floor(sq)


ans = 1
for i in range(1,sq+2):
  if M % i == 0:
    if i * N <= M:
      ans = max(i,ans)
    if M / i * N <= M:
      ans = max(M // i,ans)
if N == 1:
  print(int(M))
else:
  print(int(ans))


Verdicts: Runtime Error

Wrong Answer

Runtime Error

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

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1:
            if (len(h0) > 0 and min(h0) >= list(hc)[0]) or len(h0) == 0:
                print(x, y, list(hc)[0])
                break


# -*- coding: utf-8 -*-

import bisect

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

y = [1, M]
for i in range(2, int(M ** 0.5) + 1):
    if M % i == 0:
        y.append(i)
        y.append(M // i)

y.sort()
print(M // y[bisect.bisect_left(y, N)])



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 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())
divisors=make_divisors(M)
ans=0
for d in divisors:
    if N*d<=M:
        ans=d
    else:
        break

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())
divisors=make_divisors(M)
ans=0
for d in divisors:
    if N*d<=M:
        ans=d
    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):
# 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)


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

divisors.sort()
MAX_VAL = int(M/N)
for d in divisors:
    if d > MAX_VAL:
        break
    max_gcd = d

print(max_gcd)


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
from math import floor
n,m = map(int,input().split())
d = m // n
ans = 1
for i in range(1,floor(sqrt(m))+1):
    if m % i == 0:
        x = m // i
        if i <= d:
            ans = max(ans,x,i)
print(ans)

from math import sqrt
from math import floor
n,m = map(int,input().split())
d = m // n
ans = 1
for i in range(1,floor(sqrt(m))+1):
    if m % i == 0:
        x = m // i
        if i <= d:
            ans = max(ans,i)
        if x <= d:
            ans = max(ans,x)
print(ans)

Verdicts: Wrong Answer

Accepted