Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
ans=1;
for i in range(n):
	ans=ans*l[i]
	if(ans==0):
		break
if(ans>10**18):
	print(-1)
else:
	print(ans)



Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if(0 in l):
	print(0)
else:
	c=False
	ans=1
	for i in range(n):
		ans=ans*l[i]
		if(ans>10**18):
			c=True
			break
		else:
			continue
	if(c):
		print(-1)
	else:
		print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0
dup = [x for x in set(A) if A.count(x) > 1]

A=set(A)
for i in range(len(dup)):
    A.remove(dup[i])


A=sorted(set(A))

if A==0:
    print(0)
else:
    for i in range(len(A)):
        k=0
        for j in range(i):
            if A[i]%A[j]==0:
                k=1
                break


        if k==0:
            
            ans+=1
    print(ans)

Fixed submission:
X=list(map(int,input().split()))
print(X.index(0)+1)
Buggy python submission (verdict: Runtime Error):
import math

A,V= map(int, input().split())
B,W= map(int, input().split())
T=int(input())
ans=0

if A>B:
    C=A
    A=B
    B=C

if A==B:
    print("YES")
else:

    if V<=W:
        print("NO")
    else:
        x=(1-(A-B)/(V-W))
        xint=math.floor(1-(A-B)/(V-W))
        A=A+(xint-1)*V
        B=B+(xint-1)*W

        if (xint-1)>T:
            print("NO")
        else:
            
            for i in range (3):
                if A<B:
                    A=A+V
                    B=B+W
                else:
                    A=A-V
                    B=B-W
                if xint+i>T:
                    ans=0
                    break
                if A==B:
                    ans=1
                    break
                
            print("YES" if ans==1 else "NO")


Fixed submission:
S=str(input())
print(S[0:3])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans=1
i=0
while ans<=1000000000000000000:
    ans=ans*A[i]
    i+=1

if A.count(0)>0:
    print(0)
else:
    print(ans if ans<=1000000000000000000 else "-1")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans=1
i=0
while ans<=1000000000000000000 and i<N:
    ans=ans*A[i]
    i+=1

if A.count(0)>0:
    print(0)
else:
    print(ans if ans<=1000000000000000000 else "-1")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans=1
for i in range(N):
    ans=ans*A[i]
print(ans if ans<=1000000000000000000 else "-1")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans=1
i=0
while ans<=1000000000000000000 and i<N:
    ans=ans*A[i]
    i+=1

if A.count(0)>0:
    print(0)
else:
    print(ans if ans<=1000000000000000000 else "-1")
Buggy python submission (verdict: Runtime Error):
N = int(input()) 
A=list(map(int,input().split())) 
i=0 
s=[] 
for i in range(N): 
    s.append(0)  
    s[i]=A.count(i+1) 
    print(s[i])

Fixed submission:
import math
a = int(input())
print(2*a*math.pi)

Buggy python submission (verdict: Runtime Error):
N = int(input()) 
A=list(map(int,input().split())) 
i=0 
s=[] 
for i in range(N): 
    s.append(0) 
for i in range(N): 
    s[i]=A.count(i+1) 
for i in range(N): 
    print(s[i])

Fixed submission:
import math
a = int(input())
print(2*a*math.pi)

Buggy python submission (verdict: Runtime Error):
N = int(input()) 
A=list(map(int,input().split())) 
i=0 
s=[] 
for i in range(N): 
    s.append(0) 
for i in range(N): 
    s[i]=A.count(i+1) 
for i in range(N): 
    print(s[i])

Fixed submission:
import math
a = int(input())
print(2*a*math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
s=0
K=int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            s=s+gcd(i,j,k)
print(s)

Fixed submission:
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
s=0
K=int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            s=s+gcd(i,j,k)
print(s)
Buggy python submission (verdict: Runtime Error):
a=[]
N,L=map(int,input().split())
for _ in range (N):
    a.append(str(input()))
    a=sorted(a)
print(*a,sep='')

Fixed submission:
a=list(sorted(map(int,input().split()))[::-1])
if a[0]==7 and a[1]==5 and a[2]==5 :
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for i in range(Q)]

def calc(A):
    ans = 0
    for i in range(len(A)):
        ans += A[i] * (i + 1)

    return ans

VALUE = [0 for i in range(100000)]

for i in range(N):
    VALUE[A[i] - 1] += 1

for i in range(Q):
    VALUE[BC[i][1] - 1] += VALUE[BC[i][0] - 1]
    VALUE[BC[i][0] - 1] = 0
    print(calc(VALUE))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for i in range(Q)]

def calc(A):
    ans = 0
    for i in range(len(A)):
        ans += A[i] * (i + 1)

    return ans

VALUE = [0 for i in range(100000)]

for i in range(N):
    VALUE[A[i] - 1] += 1

ANS = []
ANS.append(calc(VALUE))

for i in range(Q):
    VALUE[BC[i][1] - 1] += VALUE[BC[i][0] - 1]
    ANS.append(ANS[i] + (BC[i][1] - BC[i][0]) * VALUE[BC[i][0] - 1])
    VALUE[BC[i][0] - 1] = 0

for i in range(1, Q + 1):
    print(ANS[i])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for i in range(Q)]

def calc(A):
    ans = 0
    for i in range(len(A)):
        ans += A[i] * (i + 1)

    return ans



VALUE = [0 for i in range(100)]

for i in range(N):
    VALUE[A[i] - 1] += 1

for i in range(Q):
    VALUE[BC[i][1] - 1] += VALUE[BC[i][0] - 1]
    VALUE[BC[i][0] - 1] = 0
    print(calc(VALUE))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for i in range(Q)]

def calc(A):
    ans = 0
    for i in range(len(A)):
        ans += A[i] * (i + 1)

    return ans

VALUE = [0 for i in range(100000)]

for i in range(N):
    VALUE[A[i] - 1] += 1

ANS = []
ANS.append(calc(VALUE))

for i in range(Q):
    VALUE[BC[i][1] - 1] += VALUE[BC[i][0] - 1]
    ANS.append(ANS[i] + (BC[i][1] - BC[i][0]) * VALUE[BC[i][0] - 1])
    VALUE[BC[i][0] - 1] = 0

for i in range(1, Q + 1):
    print(ANS[i])
Buggy python submission (verdict: Runtime Error):
import math

A, B, H, M = map(int, input().split())

theta = (H * 30 - M * 9.5) * math.pi / 180

ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(theta))

print(ans)
~                                                                                                                       ~                                                                                                                       ~                                                                                                                       ~                                                                                                                       ~                                         

Fixed submission:
import math

A, B, H, M = map(int, input().split())

theta = (H * 30 - M * 5.5) * math.pi / 180

ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(theta))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H_i = list(map(int, input().split()))
U = [list(map(int, input().split())) for i in range(M)]

high_max = []
ans = 0

for i in range(N):
    Highes = []
    for j in range(M):
        if U[j][0] == i + 1:
            Highes.append(H_i[U[j][1] - 1])
        if U[j][1] == i + 1:
            Highes.append(H_i[U[j][0] - 1])

    if Highes == []:
        high_max.append(0)
    else:
        high_max.append(max(Highes))

for i in range(N):
    if H_i[i] > high_max[i]:
        ans += 1

print(ans)


Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))

good = [True] * N

for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  if H[A] >= H[B]:
    good[B] = False
  if H[A] <= H[B]:
    good[A] = False
print(sum(good))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H_i = list(map(int, input().split()))
U = [list(map(int, input().split())) for i in range(M)]

path = [[0 for i in range(N)] for j in range(N)]

ans = 0

for i in U:
    path[i[0] - 1][i[1] - 1] = 1
    path[i[1] - 1][i[0] - 1] = 1

for i in range(N):
    for j in range(N):
        if path[i][j] == 1:
            if H_i[i] <= H_i[j]:
                break
        if j == N - 1:
            ans += 1

print(ans)


Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))

good = [True] * N

for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  if H[A] >= H[B]:
    good[B] = False
  if H[A] <= H[B]:
    good[A] = False
print(sum(good))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P_i = list(map(int, input().split()))

total = 0


for i in range(N):
    if P_i[i] <= min(P_i[0:i + 1]) :
        total += 1


print(total)


Fixed submission:
N = int(input())
P_i = list(map(int, input().split()))

total = 0

equi = P_i[0]

for i in range(N):
    if equi >= P_i[i]:
        total += 1
        equi = P_i[i]

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P_i = list(map(int, input().split()))

total = 0


for i in range(N):
    count = 0
    for j in range(i):
        if P_i[i] <= P_i[j]:
            count += 1

    if count == i:
        total += 1

print(total)


Fixed submission:
N = int(input())
P_i = list(map(int, input().split()))

total = 0

equi = P_i[0]

for i in range(N):
    if equi >= P_i[i]:
        total += 1
        equi = P_i[i]

print(total)
Buggy python submission (verdict: Runtime Error):
import fraction

A, B = map(int, input().split())

print(A * B // fraction.gcd(A, B))


Fixed submission:
import fractions

A, B = map(int, input().split())

print(A * B // fractions.gcd(A, B))

Buggy python submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())

print(A * B // math.gcd(A, B))


Fixed submission:
import fractions

A, B = map(int, input().split())

print(A * B // fractions.gcd(A, B))
Buggy python submission (verdict: Runtime Error):
N = int(input())

count = 0
div = 10

if N % 2 == 0:
    for i in range(1, 26):
    count += N // div
    div *= 5

print(count)


Fixed submission:
N = int(input())

count = 0
div = 10

if N % 2 == 0:
    for i in range(1, 26):
        count += N // div
        div *= 5

print(count)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())

MOD = int(1.0e+9 + 7)
DP_max = 3333334

DP = []
if(2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0:
    print(0)

if(2 * y - x) < 0 or (2 * x - y) < 0:
    print(0)

X = int((2 * y - x) / 3)
Y = int((2 * x - y) / 3)

for i in range(X + 1):
    DP.append([1])

for i in range(Y + 1):
    DP[0].append(1)


for i in range(1, X + 1):
    for j in range(1, Y + 1):
        DP[i].append((DP[i][j - 1] + DP[i - 1][j]) % MOD)

print(DP[X][Y])


Fixed submission:
x, y = map(int, input().split())

MOD = int(1.0e+9 + 7)
DP_max = 3333334

DP = []

X = int((2 * y - x) / 3)
Y = int((2 * x - y) / 3)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

if((2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0 or
   (2 * y - x) < 0 or (2 * x - y) < 0):
    print(0)
else:
    print(cmb(X + Y, Y, MOD))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_i = list(map(int, input().split()))

B_i = []

for i in range(1, N + 1):
    B_i.append(str(A_i.index(i) + 1))

print(" ".join(B_i))


Fixed submission:
N = int(input())
A_i = list(map(int, input().split()))

B_i = [0 for s in range(N)]

for i in range(1, N + 1):
    B_i[A_i[i - 1] - 1] = str(i)


print(" ".join(B_i))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

count = 0

for i in range(N):
    count += B[i]

for i in range(0, N - 1):
    count += C[i]

if N > 2:
    count -= C[A[N - 1] - 1]

print(count)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

count = 0

for i in range(N):
    count += B[i]

    if  i >= 1 and A[i] == A[i - 1] + 1:
        count += C[A[i - 1] - 1]

print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 1:
    print(0)

else:
    print(int((N / 2) * (N - 1))


Fixed submission:
N = int(input())

print(N * (N - 1) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
num = []
num.append(N)

min = N
while True:
    if K == 1:
        print(0)
        break

    N = abs(N - K)
    if  (N in num)  == True:
        print(min)
        break
    else:
        num.append(N)
        if N < min:
            min = N


Fixed submission:
N,K = map(int, input().split())
num = []
num.append(N)

if N > K:
    s = N // K
    N -= (K * s)
min = N
if K == 1:
    print(0)
else:
    while True:
        if K == 1:
            print(0)
            break
        N = abs(N - K)
        if  (N in num)  == True:
            print(min)
            break
        else:
            num.append(N)
            if N < min:
                min = N
Buggy python submission (verdict: Runtime Error):
,N = map(int, input().split())
AN = max = i = j = 0
c = []

A = [int(N) for N in input().split()]
while i+1 != N:
    c.append(A[i+1] - A[i])
    if c[i] > max:
        max = c[i]
    i = i+1

c.append(A[0] - 0 + K - A[N-1])

if A[0] - 0 + K - A[N-1] > max:
    max = A[0] - 0 + K - A[N-1]

while j != N:
    AN = AN + c[j]
    j = j + 1

AN = AN - max

print(AN)

Fixed submission:
K,N = map(int, input().split())
AN = max = i = j = 0
c = []

A = [int(N) for N in input().split()]
while i+1 != N:
    c.append(A[i+1] - A[i])
    if c[i] > max:
        max = c[i]
    i = i+1

c.append(A[0] - 0 + K - A[N-1])

if A[0] - 0 + K - A[N-1] > max:
    max = A[0] - 0 + K - A[N-1]

while j != N:
    AN = AN + c[j]
    j = j + 1

AN = AN - max

print(AN)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K = map(int,input().split())
A = np.array(list(map(int,input().split())))
A.sort()
posi = A[A > 0]
zero = A[A = 0]
nega = A[A < 0]

# x以下の数を求める
def check(x):
    count = 0  # 積がx以下の組
    if x >= 0:
        count += len(zero) * N  # zero * N
    count += np.searchsorted(A, x // posi, side = 'right').sum()  # posi * N
    count += np.searchsorted(A, (-x - 1) // nega, side = 'left').sum()  # nega * N
    count -= np.count_nonzero(A * A <= x)  # 自分自身との組
    return count // 2  #重複を消す

# 二分探索
low = -10 ** 18
high = 10 ** 18
while low + 1 < high:
    mid = (low + high) // 2
    if check(mid) >= K:
        low = mid
    else:
        high = mid

print(low)


Fixed submission:
import numpy as np

N, K = map(int,input().split())
A = np.array(list(map(int,input().split())))
A.sort()
posi = A[A > 0]
zero = A[A == 0]
nega = A[A < 0]

# 積がx以下の組を求める
def check(x):
    count = 0  # 積がx以下の組
    if x >= 0:
        count += len(zero) * N  # zero * N
    count += np.searchsorted(A, x // posi, side = 'right').sum()  # posi * N
    count += (N - np.searchsorted(A, (-x - 1) // (-nega), side = 'right')).sum()  # nega * N
    count -= np.count_nonzero(A * A <= x)  # 自分自身との組
    return count // 2  #重複を消す

# 二分探索
low = -10 ** 18
high = 10 ** 18
while low + 1 < high:
    mid = (low + high) // 2
    if check(mid) < K:  # OK
        low = mid
    else:               # NG
        high = mid

print(high)
Buggy python submission (verdict: Runtime Error):
n, k = input().split()
print(sum(sorted([int(i) for i in input().split()])[:k]))

Fixed submission:
n, k = [int(i) for i in input().split()]
print(sum(sorted([int(i) for i in input().split()])[:k]))

Buggy python submission (verdict: Runtime Error):
n, k = input().split()
sum(sorted([int(i) for i in input().split()])[:k])

Fixed submission:
n, k = [int(i) for i in input().split()]
print(sum(sorted([int(i) for i in input().split()])[:k]))

Buggy python submission (verdict: Runtime Error):
n, k = input().split()
sum(input().split().sorted()[:k])

Fixed submission:
n, k = [int(i) for i in input().split()]
print(sum(sorted([int(i) for i in input().split()])[:k]))
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
ws, vs = zip(*[map(int, input().split()) for _ in range(N)])

def maxvalue_recursive(N, W):
    def memoize(func):
        func.d = d = {}
        def _f(*va):
            if va not in d: d[va] = func(*va)
            return d[va]
        return _f

    @memoize
    def maxvalue(i, w):
        if i < 0: return 0
        if w < ws[i]:
            return maxvalue(i - 1, w)
        else:
            return max(maxvalue(i - 1, w), maxvalue(i - 1, w - ws[i]) + vs[i])

    res = maxvalue(N - 1, W)
    return res

def maxvalue_dp(N, W):
    dp = [0] * (W + 1)
    for i in range(N):
        dp = [max(dp[w], dp[w - ws[i]] + vs[i] if w >= ws[i] else 0) for w in range(W + 1)]
    return dp[-1]

#print(maxvalue_recursive(N, W))
print(maxvalue_dp(N, W))

#import timeit
#print(timeit.timeit('maxvalue_recursive(N, W)', globals=globals(), number=10000))
#print(timeit.timeit('maxvalue_dp(N, W)', globals=globals(), number=10000))

Fixed submission:
N, W = map(int, input().split())
ws, vs = zip(*[map(int, input().split()) for _ in range(N)])

def maxvalue_recursive(N, W):
    def memoize(func):
        func.d = d = {}
        def _f(*va):
            if va not in d: d[va] = func(*va)
            return d[va]
        return _f

    @memoize
    def maxvalue(i, w):
        if i < 0: return 0
        if w < ws[i]:
            return maxvalue(i - 1, w)
        else:
            return max(maxvalue(i - 1, w), maxvalue(i - 1, w - ws[i]) + vs[i])

    res = maxvalue(N - 1, W)
    return res

def maxvalue_dp(N, W, ws, vs):
    import numpy as np
    dp = np.zeros(W + 1, 'int64')
    ws = np.array(ws, 'int64')
    vs = np.array(vs, 'int64')
    for i in range(N):
        idx = np.arange(W + 1) - ws[i]
        dp = np.maximum(dp, (dp[idx] + vs[i]) * (idx >= 0))
    return dp[-1]

#print(maxvalue_recursive(N, W))
print(maxvalue_dp(N, W, ws, vs))

#import timeit
#print(timeit.timeit('maxvalue_recursive(N, W)', globals=globals(), number=10000))
#print(timeit.timeit('maxvalue_dp(N, W)', globals=globals(), number=10000))
Buggy python submission (verdict: Time Limit Exceeded):
import functools
N, W = map(int, input().split())
ws, vs = zip(*[map(int, input().split()) for _ in range(N)])
maxV = max(vs)
V = maxV * N
INF = 10**10

dp = {}
def minweight(i, v):
    if (i, v) not in dp:
        if i == 0:
            if v == 0: dp[i, v] = 0
            elif v == vs[i]: dp[i, v] = ws[i]
            else: dp[i, v] = INF
        else:
            if vs[i] <= v:
                dp[i, v] = min(minweight(i - 1, v - vs[i]) + ws[i], minweight(i - 1, v))
            else:
                dp[i, v] = minweight(i - 1, v)
    return dp[i, v]

for v in range(V, -1, -1):
    if minweight(N - 1, v) <= W:
        print(v)
        break

Fixed submission:
import numpy as np
N, W = map(int, input().split())
ws, vs = zip(*[map(int, input().split()) for _ in range(N)])
INF = 10**13

def maxvalue_dp(ws, vs, W):
    V = sum(vs)
    dp = np.zeros(V + 1, np.int64)
    dp += INF
    dp[0] = 0
    for w, v in zip(ws, vs):
        dp[v:] = np.minimum(dp[v:], dp[:-v] + w)
    for v in range(V, -1, -1):
        if dp[v] <= W:
            return v

print(maxvalue_dp(ws, vs, W))

Buggy python submission (verdict: Time Limit Exceeded):
import functools
N, W = map(int, input().split())
ws, vs = zip(*[map(int, input().split()) for _ in range(N)])

@functools.lru_cache(None)
def maxvalue(i, w):
    if i < 0: return 0
    if w < ws[i]:
        return maxvalue(i - 1, w)
    else:
        return max(maxvalue(i - 1, w), maxvalue(i - 1, w - ws[i]) + vs[i])

print(maxvalue(N - 1, W))

Fixed submission:
import numpy as np
N, W = map(int, input().split())
ws, vs = zip(*[map(int, input().split()) for _ in range(N)])
INF = 10**13

def maxvalue_dp(ws, vs, W):
    V = sum(vs)
    dp = np.zeros(V + 1, np.int64)
    dp += INF
    dp[0] = 0
    for w, v in zip(ws, vs):
        dp[v:] = np.minimum(dp[v:], dp[:-v] + w)
    for v in range(V, -1, -1):
        if dp[v] <= W:
            return v

print(maxvalue_dp(ws, vs, W))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ps = range(1, N)
candidates = []
for p in ps:
    if M % p == 0:
        if M // p >= N:
            candidates.append(p)
        if p >= N:
            candidates.append(M // p)
print(max(candidates))

Fixed submission:
N, M = map(int, input().split())
candidates = []
for p in range(1, max(int(M ** 0.5) + 1, N + 1)):
    if M % p == 0:
        if M // p >= N:
            # p * (M // p = a1+a2+.. >= N) = M
            candidates.append(p)
        if p >= N:
            # (M // p) * (p = a1+a2+.. >= N) = M
            candidates.append(M // p)
print(max(candidates))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
pp = range(1, M // N + 2)
P = max(p for p in pp if M % p == 0 and M // p >= N)
print(P)

Fixed submission:
N, M = map(int, input().split())
candidates = []
for p in range(1, max(int(M ** 0.5) + 1, N + 1)):
    if M % p == 0:
        if M // p >= N:
            # p * (M // p = a1+a2+.. >= N) = M
            candidates.append(p)
        if p >= N:
            # (M // p) * (p = a1+a2+.. >= N) = M
            candidates.append(M // p)
print(max(candidates))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
pp = range(2, M // N + 2)
P = max(p for p in pp if M % p == 0 and M // p >= N)
print(P)

Fixed submission:
N, M = map(int, input().split())
candidates = []
for p in range(1, max(int(M ** 0.5) + 1, N + 1)):
    if M % p == 0:
        if M // p >= N:
            # p * (M // p = a1+a2+.. >= N) = M
            candidates.append(p)
        if p >= N:
            # (M // p) * (p = a1+a2+.. >= N) = M
            candidates.append(M // p)
print(max(candidates))