Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

answer = 0

nums=[]
for i in range(1, M+1):
    nums.append(i)

for balls in itertools.combinations_with_replacement(nums, N):
    score = 0
    for i in range(Q):
        test = list(balls)
        if test[abcd[i][0]-1] + abcd[i][2] == test[abcd[i][1]-1]:
            score += abcd[i][3]
    if score > answer:
        answer = score

print(answer)


Fixed submission:
import itertools

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

answer = 0

nums=[]
for i in range(1, M+1):
    nums.append(i)

for balls in itertools.combinations_with_replacement(nums, N):
    score = 0
    test = list(balls)
    for i in range(Q):
        if test[abcd[i][0]-1] + abcd[i][2] == test[abcd[i][1]-1]:
            score += abcd[i][3]
    if score > answer:
        answer = score

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

answer = 0

nums=[]
for i in range(1, M+1):
    nums.append(i)

for balls in itertools.combinations_with_replacement(nums, N):
    score = 0
    for i in range(Q):
        test = sorted(list(balls))
        if test[abcd[i][0]-1] + abcd[i][2] == test[abcd[i][1]-1]:
            score += abcd[i][3]
    if score > answer:
        answer = score

print(answer)


Fixed submission:
import itertools

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

answer = 0

nums=[]
for i in range(1, M+1):
    nums.append(i)

for balls in itertools.combinations_with_replacement(nums, N):
    score = 0
    test = list(balls)
    for i in range(Q):
        if test[abcd[i][0]-1] + abcd[i][2] == test[abcd[i][1]-1]:
            score += abcd[i][3]
    if score > answer:
        answer = score

print(answer)
Buggy python submission (verdict: Runtime Error):
A, B, N = map(int, input().split())

if B-1>N:
    answer = (A*N/B)//1 - A*((N/B)//1)

if A > B:
    answer = (A*(B-1)/B)//1 - A*(((B-1)/B)//1)

print(int(answer))


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

if B-1>N:
    answer = (A*N/B)//1 - A*((N/B)//1)

else:
    answer = (A*(B-1)/B)//1 - A*(((B-1)/B)//1)

print(int(answer))
Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())

if W >= S:
    print(unsafe)
else:
    print(safe)


Fixed submission:
S, W = map(int, input().split())

if W>=S:
    print("unsafe")
else:
    print("safe")

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())

if W >= S:
    print(undafe)
else:
    print(safe)


Fixed submission:
S, W = map(int, input().split())

if W>=S:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [str(input()) for i in range(N)]

S = sorted(S)
count = 0
first = 0
removecount = 0

for i in range(N):
    j = 0
    while first + count + 1 < len(S) :
        if S[first]==S[first+1+j]:
            S[first+1+j] = "nullsad"
            count+=1
            j += 1
        else:
            first += count + 1
            removecount += count
            count = 0
            break

for i in range(removecount + count):
    S.remove("nullsad")

print(len(S))


Fixed submission:
N = int(input())
S = [str(input()) for i in range(N)]

S = sorted(S)
count = 0
first = 0
removecount = 0

for i in range(N):
    j = 0
    while first + count + 1 < len(S) :
        if S[first]==S[first+1+j]:
            S[first+1+j] = "null"
            count+=1
            j += 1
        else:
            first += count + 1
            removecount += count
            count = 0
            break

print(len(S)-S.count("null"))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [str(input()) for i in range(N)]

S = sorted(S)
count = 0
first = 0
removecount = 0

for i in range(N):
    j = 0
    while first + count + 1 < len(S) :
        if S[first]==S[first+1+j]:
            S[first+1+j] = "nullsad"
            count+=1
            j += 1
            print(S)
        else:
            first += count + 1
            removecount += count
            count = 0
            print(S)
            break

for i in range(removecount + count):
    S.remove("nullsad")

print(len(S))


Fixed submission:
N = int(input())
S = [str(input()) for i in range(N)]

S = sorted(S)
count = 0
first = 0
removecount = 0

for i in range(N):
    j = 0
    while first + count + 1 < len(S) :
        if S[first]==S[first+1+j]:
            S[first+1+j] = "null"
            count+=1
            j += 1
        else:
            first += count + 1
            removecount += count
            count = 0
            break

print(len(S)-S.count("null"))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
number = []
n = 0

for i in range(N):
  n = A.count(i)
  number.append(n)
  if n != 0:
    A.remove(i)
  n = 0

del number[0]
number.append(0)
for Answer in number:
  print(Answer)


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

for i in range(N-1):
  n = A[i-1]*1
  number[n] = number[n] + 1

del number[0]
number.append(0)
for Answer in number:
  print(Answer)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
number = []

for i in range(N):
  n = A.count(i)
  number.append(n)

del number[0]
number.append(0)
for Answer in number:
  print(Answer)


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

for i in range(N-1):
  n = A[i-1]*1
  number[n] = number[n] + 1

del number[0]
number.append(0)
for Answer in number:
  print(Answer)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

if N%K == 0:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K:

    for i in range(18):
        k = K*(10**(17-i))
        while N>=k:
            k=k+K*(10**(17-i))
        k = k-K*(10**(17-i))
    k = k+K
    if k-N<N-(k-K):
        print(k-N)
    else:
        print(N-(k-K))


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

if N%K == 0:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K:
    if K-(N%K)>N%K:
        print(N%K)
    else:
        print(K-(N%K))

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

if N == K:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K:

    for i in range(18):
        k = K*(10**(17-i))
        while N>=k:
            k=k+K*(10**(17-i))
        k = k-K*(10**(17-i))
    k = k+K
    if k-N<N-(k-K):
        print(k-N)
    else:
        print(N-(k-K))


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

if N%K == 0:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K:
    if K-(N%K)>N%K:
        print(N%K)
    else:
        print(K-(N%K))

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

if N == K:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K*(10**8):
    k = K*(10**8)
    for i in range(9):
        while N>k:
            k=k+K*(10**(8-i))
        k = k-K*(10**(8-i))
    k = k+K
    if k-N<N-k/K:
        print(k-N)
    else:
        print(N-k/K)


elif N>K:
    k = K
    while N>k:
        k=k+K
    if k-N<N-k/K:
        print(k-N)
    else:
        print(N-k/K)


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

if N%K == 0:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K:
    if K-(N%K)>N%K:
        print(N%K)
    else:
        print(K-(N%K))

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

if N == K:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K:
    k = K
    while N>k:
        k=k+K
    if k-N<N-k/K:
        print(k-N)
    else:
        print(N-k/K)


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

if N%K == 0:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K:
    if K-(N%K)>N%K:
        print(N%K)
    else:
        print(K-(N%K))

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

if N == K:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K:
    while N>0:
        N = N - K
    if -N<N+K:
        print(-N)
    else:
        print(N + K)


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

if N%K == 0:
    print(0)

elif N<K and N<=K-N:
    print(N)

elif N<K and N>K-N:
    print(K-N)

elif N>K:
    if K-(N%K)>N%K:
        print(N%K)
    else:
        print(K-(N%K))
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

List=[]

while len(List) < N:
    for i in range(A):
        List.append("b")
    for i in range(B):
        List.append("r")

for i in range (len(List)-N):
    del List[N]

print(List.count("b"))


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

brset = A + B
inside = N // (A+B)
count = inside*A

if inside*brset + A <= N:
    count += A
else:
    count += N - (inside*brset)

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
# = map(int, input().split())
P = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

count = 0

for i in range(N):
    if P[i] == 1:
        count += 1
        break
    if P[i] == min(P[:i+1]):
        count += 1

print(count)


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

count = 0
minimum = 300000

for i in range(N):
    if P[i] == 1:
        count += 1
        break
    if P[i] < minimum:
        count += 1
        minimum = P[i]

print(count)

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

count = 0

for i in range(N):
    if P[i] == min(P[:i+1]):
        count += 1

print(count)


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

count = 0
minimum = 300000

for i in range(N):
    if P[i] == 1:
        count += 1
        break
    if P[i] < minimum:
        count += 1
        minimum = P[i]

print(count)

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

count = 0

for i in range(N):
    if P[N-1-i] == min(P):
        count += 1
        del P[N-1-i]
    else:
        del P[N-1-i]

print(count)


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

count = 0
minimum = 300000

for i in range(N):
    if P[i] == 1:
        count += 1
        break
    if P[i] < minimum:
        count += 1
        minimum = P[i]

print(count)
Buggy python submission (verdict: Runtime Error):
X = int(input())
number = X//100
teen = X%100

elif teen <= 5*number:
    print(1)
else:
    print(0)


Fixed submission:
X = int(input())
number = X//100
teen = X%100

if teen <= 5*number:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
S = list(map(str, input()))
N = len(S)+1
List = [0]*N
rightcount = 0
leftcount = 0

if S[0] == "<":
    leftcount+=1
else:
    rightcount+=1

for i in range(1, N-1):
    if S[i] == "<":
        leftcount+=1
        if S[i-1] == ">":
            for j in range(rightcount):
                List[i-j] = j
            if List[i-rightcount]<List[i-rightcount+1]:
                List[i-rightcount] = List[i-rightcount+1] + 1
            rightcount = 0


    if S[i] == ">":
        rightcount+=1
        if S[i-1] =="<":
            for j in range(leftcount+1):
                List[i-j] = leftcount - j
            leftcount = 0

if S[N-2] == "<":
    List[N-1] = 1
else:
    for j in range(rightcount):
        List[N-j] = j
    if List[N-rightcount]<List[N-rightcount+1]:
        List[N-rightcount] = List[N-rightcount+1] + 1

print(sum(List))

Fixed submission:
S = list(map(str, input()))
N = len(S)+1
List = [0]*N
rightcount = 0
leftcount = 0

if S[0] == "<":
    leftcount+=1
else:
    rightcount+=1

for i in range(1, N-1):
    if S[i] == "<":
        leftcount+=1
        if S[i-1] == "<":
            List[i] = List[i-1]+1
        elif S[i-1] == ">":
            for j in range(rightcount):
                List[i-j] = j
            if List[i-rightcount]<=List[i-rightcount+1]:
                List[i-rightcount] = List[i-rightcount+1] + 1
            rightcount = 0


    if S[i] == ">":
        rightcount+=1
        if S[i-1] =="<":
            for j in range(leftcount+1):
                List[i-j] = leftcount - j
            leftcount = 0

if S[N-2] == "<":
    List[N-1] = List[N-2] + 1
else:
    for j in range(rightcount):
        List[N-1-j] = j
    if List[N-1-rightcount]<=List[N-1-rightcount+1]:
        List[N-1-rightcount] = List[N-1-rightcount+1] + 1

print(sum(List))
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]

Point = []

for i in range(N):
    Point.append(K - Q + A.count(i+1))

    if Point[i] > 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
A = sorted(A)
Acount = 0
j = 0

Point = []

for i in range(N):

    while j != len(A):
        if A[j] == i + 1:
            Acount += 1
            j +=1
        else:
            break

    Point.append(K - Q + Acount)

    Acount = 0

    if Point[i] > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]

Point = []
Result = []

for i in range(N):
    Point.append(A.count(i+1))

for i in range(N):
    Point[i] = K - (Q - Point[i])

for i in range(N):
    if Point[i] > 0:
        Result.append("Yes")
    else:
        Result.append("No")

for i in range(N):
    print(Result[i])


Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
A = sorted(A)
Acount = 0
j = 0

Point = []

for i in range(N):

    while j != len(A):
        if A[j] == i + 1:
            Acount += 1
            j +=1
        else:
            break

    Point.append(K - Q + Acount)

    Acount = 0

    if Point[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

for i in range(25):
  if B <= A + (A-1)*i:
    print(i + 1)
    break


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

if B ==1:
  print(0)

else:
  for i in range(19):
    if B <= A + (A-1)*i:
      print(i + 1)
      break

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
int i = 0

for i in range(25):
  if B <= A + (A-1)*i:
    print(i + 1)
    break
  else:


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

if B ==1:
  print(0)

else:
  for i in range(19):
    if B <= A + (A-1)*i:
      print(i + 1)
      break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
score = 0

for i in range(1, N):
    score += i

print(score)


Fixed submission:
N = int(input())

print((N)*(N-1)//2)
Buggy python submission (verdict: Runtime Error):
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [list(map(int, input().split())) for i in range(N)]
List = [A, B, C, D, E]
Time = []
Cost = []
answer = 0

for i in range(5):
    Time.append(List[i]%10)
    Cost.append(math.ceil(List[i]/10)*10)

for i in range(5):
    answer += Cost[i]

Time = list(set(Time))
if Time[0] == 0:
    Time.remove(0)

answer = answer - (10-min(Time))

print(answer)


Fixed submission:
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [list(map(int, input().split())) for i in range(N)]
List = [A, B, C, D, E]
Time = []
Cost = []
answer = 0

for i in range(5):
    Time.append(List[i]%10)
    Cost.append(math.ceil(List[i]/10)*10)

for i in range(5):
    answer += Cost[i]

if Time.count(0)==5:
    print(answer)

else:
    Time = list(set(Time))
    if Time[0] == 0:
        Time.remove(0)

    answer = answer - (10-min(Time))

    print(answer)
Buggy python submission (verdict: Runtime Error):
import string

S = list(map(str, input()))
s = sorted(set(S))

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(30):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break


Fixed submission:
import string

S = list(map(str, input()))
s = sorted(set(S))
count = 0

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(len(s)):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break
        else:
            count += 1

if count == len(s):
    print(alphabet[len(s)])

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

S = list(map(str, input()))

s = sorted(set(S))

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")
else:

    for i in range(53):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break


Fixed submission:
import string

S = list(map(str, input()))
s = sorted(set(S))
count = 0

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(len(s)):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break
        else:
            count += 1

if count == len(s):
    print(alphabet[len(s)])
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
S = input()
T = []
Answer = []

for i in range(N):
  if S[i] == "a":
    if A + B > Answer.count("Yes"):
      Answer.append("Yes")
    else:
      Answer.append("No")
  elif S[i] == "b":
    if A + B > Answer.count("Yes") and B > T.count("Yes"):
      Answer.append("Yes")
      T.append("Yes")
    else:
      Answer.append("No")
  else:
    Answer.append("No")
  print(Answer[i])


Fixed submission:
N, A, B = map(int, input().split())
S = input()
T = []
Answer = []
Acount = 0
Tcount = 0

for i in range(N):
  if S[i] == "a":
    if A + B > Acount:
      Answer.append("Yes")
      Acount += 1
    else:
      Answer.append("No")
  elif S[i] == "b":
    if A + B > Acount and B > Tcount:
      Answer.append("Yes")
      T.append("Yes")
      Acount +=1
      Tcount +=1
    else:
      Answer.append("No")
  else:
    Answer.append("No")
  print(Answer[i])

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
S = input()
T = []
Answer = []

for i in range(N):
  if S[i] == "a":
    if A + B > Answer.count("Yes"):
      Answer.append("Yes")
    else:
      Answer.append("No")
  elif S[i] == "b":
    if A + B > Answer.count("Yes") and B > T.count("Yes"):
      Answer.append("Yes")
      T.append("Yes")
    else:
      Answer.append("No")
  else:
    Answer.append("No")
  print(Answer[i])


Fixed submission:
N, A, B = map(int, input().split())
S = input()
T = []
Answer = []
Acount = 0
Tcount = 0

for i in range(N):
  if S[i] == "a":
    if A + B > Acount:
      Answer.append("Yes")
      Acount += 1
    else:
      Answer.append("No")
  elif S[i] == "b":
    if A + B > Acount and B > Tcount:
      Answer.append("Yes")
      T.append("Yes")
      Acount +=1
      Tcount +=1
    else:
      Answer.append("No")
  else:
    Answer.append("No")
  print(Answer[i])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	if(p[i]==0):
		flag=1
	i+=1
if(flag==1):
	print(0)
else:
	flag=0
	i=0			
	while(n>i):
		ans*=p[i]
		if(ans>k):
			flag=1
		i+=1		
	if( flag==1):
		print(-1)
	else:
		print(ans)
		


Fixed submission:
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	if(p[i]==0):
		flag=1
	i+=1
if(flag==1):
	print(0)
else:
	flag=0
	i=0			
	while(n>i):
		ans*=p[i]
		if(ans>k):
			flag=1
			break
		i+=1		
	if( flag==1):
		print(-1)
	else:
		print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	ans*=p[i]
	if(p[i]==0):
		break
	if(ans>k):
		flag=1
	i+=1		
if((ans>k or flag==1) and ans!=0):
		print(-1)
else:
		print(ans)
		


Fixed submission:
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	if(p[i]==0):
		flag=1
	i+=1
if(flag==1):
	print(0)
else:
	flag=0
	i=0			
	while(n>i):
		ans*=p[i]
		if(ans>k):
			flag=1
			break
		i+=1		
	if( flag==1):
		print(-1)
	else:
		print(ans)

Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std; 
typedef long long int  ll;
#pragma GCC optimize("O3")
#define pb push_back

int32_t main()  {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n ;
	cin >> n ;
	ll ans = 1;
	ll k = 1000000000000000000;
	int fl =0;
	while ( n--)
	{
		ll in ;
		cin >> in;
		ans=ans*in;
		if(ans>k) {
			fl=1;}
		if(in==0){
			ans=0;
		}
		if(ans!=0)	
		if((k/ans)>in) {
			fl=1;
		}	
	}
	if(	fl==1 and ans!=0)
	cout<<-1<<endl;
	else
	cout << ans;
}


Fixed submission:
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	if(p[i]==0):
		flag=1
	i+=1
if(flag==1):
	print(0)
else:
	flag=0
	i=0			
	while(n>i):
		ans*=p[i]
		if(ans>k):
			flag=1
			break
		i+=1		
	if( flag==1):
		print(-1)
	else:
		print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
while(n>0):
	ans*=p[i]
	i+=1
	n-=1
if(ans>1000000000000000000):
		print(-1)
else:
		print(ans)
		


Fixed submission:
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	if(p[i]==0):
		flag=1
	i+=1
if(flag==1):
	print(0)
else:
	flag=0
	i=0			
	while(n>i):
		ans*=p[i]
		if(ans>k):
			flag=1
			break
		i+=1		
	if( flag==1):
		print(-1)
	else:
		print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
ans=0
for i in range(1,N+1):
  Y=math.floor(N/i)
  ans+=(Y*(Y+1)*i)//2
print(ans)


Fixed submission:
N = int(input())
ans = 0
for i in range(1, N + 1):
    largest = N // i * i
    ans += ((largest + i) * (N // i)) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
ans=0
for i in range(1,N+1):
  Y=math.floor(N/i)
  #print('i',i,'Y',Y)
  ans+=(Y*(Y+1)*i)//2
  #print('ans',ans)
print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(1, N + 1):
    largest = N // i * i
    ans += ((largest + i) * (N // i)) // 2
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
ans=0
for i in range(1,N):
  Y=math.ceil(N/i)
  ans+=(Y*(Y+1)*x)//2
print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(1, N + 1):
    largest = N // i * i
    ans += ((largest + i) * (N // i)) // 2
print(ans)