TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a = int(input())
b = list(map(int,input().split()))
c = str(b)
n = 1
m = 1

if c.count('0') != 0:
  print('0')
  exit()
  
aa = a/2

if a%2 == 1:
    aa = (aa*2+1)//2

for i in range(int(aa)):
  n = n * b[i]
  if n > 10**18:
    break
  
for i in range(int(aa),a):
    m *= b[i]
    if m > 10**18:
      break

if n * m <= 10**18:
    print(n*m)
    exit()
  
print('-1')

a = int(input())
b = list(map(int,input().split()))
c = str(b)
n = 1
m = 1

if c.count('0') != 0:
  print(0)
  exit()
  
aa = a/2

if a%2 == 1:
    aa = (aa*2+1)//2

for i in range(int(aa)):
  n = n * b[i]
  if n > 10**18:
    break
  
for i in range(int(aa),a):
    m *= b[i]
    if m > 10**18:
      break

if n * m <= 10**18:
    print(n*m)
    exit()
  
print('-1')

a = int(input())
b = []
n = 1
for i in range(a):
  b.append(int(input()))
  
for i in range(a):
  n = n * b[i]

if n > 10**18:
  print('-1')
else:
  print(n)

a = int(input())
b = list(map(int,input().split()))
n = 1

c = 0
d = 0

for i in b:
    if i == 0:
        c += 1
    elif i > 10**18:
        d += 1
        
if c > 0:
    print(0)
    exit()
if d > 1 and c == 0:
    print(-1)
    exit()

for i in b:
  n *= i
  if n > 10**18:
    print(-1)
    exit()
print(n)
    

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
#from operator import mul
#from functools import reduce
#cnt = 1000000000000000000
ans =1
N = int(input())
nums = list(map(int, input().split()))

if 0 in nums:
        print(0)
        exit()
for num in nums:
    ans *= num
    if ans > 10**18 :
        print(-1)
         exit()
print(ans)

#from operator import mul
#from functools import reduce
cnt = 1000000000000000000
ans =1
N = map(int, input().split())
nums = list(map(int, input().split()))


count  = reduce(mul, nums)
if "0" in N:
        print("0")
for  num in nums
    ans *= num
        if count  > cnt :
        print(-1)

print(count)


#include<stdio.h>


int main(){
  int N;
  long int A[1000000];
  long long int sum=1;
  scanf("%d", &N);
  for (int i = 0; i <N; i++){
    scanf("%ld",&A[i]);
    sum *= A[i];

  }

  
  if(sum >cnt){
    printf("-1\n");
  }else{
    printf("%lld\n", sum);
  }
  return 0;
}

#from operator import mul
#from functools import reduce
#cnt = 1000000000000000000
ans =1
N = int(input())
nums = list(map(int, input().split()))

if 0 in nums:
        print(0)
        exit()
for num in nums:
    ans *= num
    if ans > 10**18 :
        print(-1)
        exit()
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
l=list(map(int,input().split()))
z,flag=1,0
m=10**18
for i in l:
  z*=i  
  if z>=m:
    flag=1
    break
if flag==1:
  print(-1)
else:
  print(z)


n=int(input())
l=list(map(int,input().split()))
z,flag=1,0
m=10**18
mi=min(l)
if mi==0:
  print(0)
else:
  for i in l:
    z*=i  
    print(z)
    if z>m:
      flag=1
      break
  if flag==1:
    print(-1)
  else:
    print(z)


n=int(input())
l=list(map(int,input().split()))
z,flag=1,0
m=10**18
mi=min(l)
if mi==0:
  print(0)
else:
  for i in l:
    z*=i  
    if z>m:
      flag=1
      break
  if flag==1:
    print(-1)
  else:
    print(z)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
hoge=list(map(int,input().split()))
ans=1
flag=True

if(min(hoge)==0):
  print(0)
  flag=False
else:
  for i in range(n):
    ans=ans*hoge[i]
    if(ans>=10**18):
      print(-1)
      flag=False
      break
if(flag):
  print(ans)

n=int(input())
hoge=list(map(int,input().split()))
ans=1
flag=True

if(min(hoge)==0):
  print(0)
  flag=False
else:
  for i in range(n):
    ans=ans*hoge[i]
    if(ans>10**18):
      print(-1)
      flag=False
      break
if(flag):
  print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = (int(x) for x in input().split())
sum  = 1
for i in A:
    sum = sum * i
    if(i == 0):
        print(0)
        break
    if(sum > (10**18)):
        print(-1)
        break
    elif(len(A) == N)
        print(sum)
        break



N = int(input())
A = (int(x) for x in input().split())
sum  = 1
flag = 0
for i in A:
    if(i == 0):
        print(0)
        flag=1
        break
if(flag==0):
    for i in A:
        sum = sum * i
        if(sum > (10**18)):
            print(-1)
            flag=1
            break
    if(flag==0):
        print(sum)


N = int(input())
A = (int(x) for x in input().split())
sum  = 1
for i in A:
    sum = sum * i
    if(i == 0):
        print(0)
        break
    if(sum > (10**18)):
        print(-1)
        break
    elif(len(A) == N):
        print(sum)
        break



N = int(input())
A = (int(x) for x in input().split())
sum  = 1
flag = 0
for i in A:
    if(i == 0):
        print(0)
        flag=1
        break
if(flag==0):
    for i in A:
        sum = sum * i
        if(sum > (10**18)):
            print(-1)
            flag=1
            break
    if(flag==1):
        print(sum)


N = int(input())
A = [int(input(i)) for i in range(N)]
sum  = 1
for i in A:
    sum = sum * i
if(sum > (10**18)):
    print(-1)
else:
    print(sum)


N = int(input())
A = list(map(int, input().split()))
sum  = 1
flag = 0
for i in A:
    if(i == 0):
        print(0)
        flag=2
        break
if(flag==0):
    for i in A:
        sum = sum * i
        if(sum > 10**18):
            flag=1
            break
if(flag==0):
    print(sum)
elif(flag==1):
    print(-1)


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
  n=int(input())
  a=list(map(int, input().split()))
  if 0 in A:
    print(0)
    return
  p=1
  for a in A:
    p*=a
    if(a>1000000000000000000):
      print(-1)
      return
  print(p)
  


def main():
  n=int(input())
  A=list(map(int, input().split()))
  if 0 in A:
    print(0)
    return
  p=1
  for a in A:
    p*=a
    if p>1000000000000000000:
      print(-1)
      return
  print(p)

  



def main():
  n=int(input())
  a=list(map(int, input().split()))
  if 0 in A:
    print(0)
    return
  p=1
  for a in A:
    p*=a
    if p>1000000000000000000:
      print(-1)
      return
  print(p)
main()
  


def main():
  n=int(input())
  a=list(map(int, input().split()))
  if 0 in A:
    print(0)
    return
  p=1
  for a in A:
    p*=a
    if p>100000000000000000:
      print(-1)
      return
  print(p)
  


def main():
  n=int(input())
  a=list(map(int, input().split()))
  if 0 in A:
    print(0)
    return
  p=1
  for a in A:
    p=*=a
    if(a>1000000000000000000):
      print(-1)
      return
  print(p)
  


def main():
  n=int(input())
  a=list(map(int, input().split()))
  if 0 in A:
    print(0)
    return
  p=1
  for a in A:
    p*=a
    if p>1000000000000000000:
      print(-1)
      return
  print(p)
  


def main():
  n=int(input())
  a=list(map(int().split()))
  if 0 in A:
    print(0)
    return
  p=1
  for a in A:
    p=*=a
    if(a>1000000000000000000):
      print(-1)
      return
  print(p)
  

def main():
  n=int(input())
  A=list(map(int, input().split()))
  if 0 in A:
    print(0)
    return
  p=1
  for a in A:
    p*=a
    if p>1000000000000000000:
      print(-1)
      return
  print(p)
main()
  



Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
num = int(input())
a = list(map(int, input().split()))
b = 1
for i in a:
  if b > 10 ** 18:
    print(-1)
    break
  else:
    b *= i
    

import sys

num = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
    print(0)
    sys.exit()
for i in a:
  if b * i > 10 ** 18:
    print(-1)
    sys.exit()
  else:
    b *= i
print(b)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
L = 1000000000000000000
r = 1
for a in map(int, input().split()):
    r *= a
if r > L: print(-1)
else: print(r)

L = 1000000000000000000
r = 1
n = input()
A = list(map(int, input().split()))
A = sorted(A)
if A[0] == 0:
    print(0)
else:
    p = True
    while len(A) > 0:
        b = A.pop()
        r *= b
        if r > L:
            print(-1)
            p = False
            break
    if p: print(r)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np
a = int(input())
b = np.array(list(map(int, input().split())))
b = np.prod(b)
if b > 10**18-1:
    print(-1)
else:print(b)


import numpy as np
a = int(input())
b = np.array(list(map(int, input().split())))
b = np.prod(b)
if b > 10**18:
    print('-1')
else:print(c)


import numpy as np
a = int(input())
b = np.array(list(map(int, input().split())))
b = np.prod(b)
if b > 10**18:
    print('-1')
else:print(c)


import numpy as np
a = int(input())
b = np.array(list(map(int, input().split())))
b = np.prod(b)
if c > 10**18:
    print('-1')
else:print(c)


a = int(input())
b = list(map(int, input().split()))
c = 1
for i in b:
    c *= i
if c > 10**18
    print('-1')
print(c)

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

if 0 in a:
    print(0)
    exit()

mult = 1

for i in a:
    mult *= i
    if mult > 10**18:
        print(-1)
        exit()
print(mult)


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
    n = int(input())
    nums = list(map(int, input().split()))
    
    if 0 in nums:
        print(0)
        return
    
    mul = 1
    for i in nums:
        mul *= nums
        if mul >= 1000000000000000000:
            print(-1)
            return
        
    print(mul)
    
main()

def main():
    n = int(input())
    nums = list(map(int, input().split()))
    
    if 0 in nums:
        print(0)
        return
    
    mul = 1
    for i in nums:
        mul *= i
        if mul >= 1000000000000000000:
            print(-1)
            return
        
    print(mul)
    
main()

def main():
    n = int(input())
    nums = list(map(int, input().split()))
    
    if 0 in nums:
        print(0)
        return
    
    mul = 1
    for i in nums:
        mul *= i
        if mul > 1000000000000000000:
            print(-1)
            return
        
    print(mul)
    
main()

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

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

if 0 in As:
    print("0")
    exit()

pi = 1
for A in As:
  pi*=A
  if pi>10^18:
    print("-1")
    exit()

print(str(pi))

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

pi = 1
for A in As:
  pi*=A
  if pi==0:
  	break

if pi>10^18:
  print("-1")
else:
  print(str(pi))

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

if 0 in As:
    print("0")
    exit()

pi = 1
for A in As:
  pi*=A
  if pi>1000000000000000000:
    print("-1")
    exit()

print(str(pi))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split(" ")))
ans = A[0]
max_ans = 10 ** 18
if 0 in A:
    ans = 0
else:
    for i in range(1,len(A)):
        ans *= A[i]
        if ans >= max_ans:
            ans = -1
            break
print(ans)         

N = int(input())
A = list(map(int,input().split(" ")))
ans = A[0]
max_ans = 10 ** 18
if 0 in A:
    ans = 0
else:
    for i in range(1,len(A)):
        ans *= A[i]
        if ans > max_ans:
            ans = -1
            break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range (0, N):
	if A[i] == 0:
		ans = 0
        break
	else:
		ans *= A[i]

if ans > 10 ** 18:
	print(-1)
else:
	print(ans)

N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range (0, N):
	if A[i] == 0:
		ans = 0
		break
	else:
		if ans > 0
        	ans *= A[i]
		if ans > 10 ** 18:
			ans = -1

print(ans)

N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range (0, N):
	if A[i] == 0:
		ans = 0
		break
	else:
		if ans > 0:
			ans *= A[i]
		if ans > 10 ** 18:
			ans = -1

print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print('0')
else:
    threshold = 10**18
    res = 1
    for x in A:
        res *= x
        if res >= threshold:
            res = -1
            break
    print(res)

n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print('0')
else:
    threshold = 10**18
    res = 1
    for x in A:
        res *= x
        if res > threshold:
            res = -1
            break
    print(res)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
    num = int(input())
    suzi = list(map(int,input().split()))
    ans = 1
    if 0 in suzi:
	    print(0)
	    return

    for kazu in suzi:
        ans *= kazu
        if ans > 1000000000000000:
            print(-1)
            return
    print(ans)


main()

def main():
    num = int(input())
    suzi = list(map(int,input().split()))

    if 0 in suzi:
	    print(0)
	    return
    ans = 1
    for kazu in suzi:
        ans *= kazu
        if ans > 1000000000000000000:
            print(-1)
            return
    print(ans)


main()

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

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

ans = 1
for n in nums:
  
  if n == 0:
    print(0)
    break

  print(ans)
  ans *= n
  if ans > 10**18:
    print(-1)
    break

  print(ans)

import sys

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

if 0 in nums:
  print(0)
  sys.exit(0)

ans = 1
for n in nums:
  ans *= n
  if ans > 10**18:
    print(-1)
    sys.exit(0)

print(ans)

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

ans = 1
if 0 in nums:
  print(0)
else:
  for n in nums:
    ans *= n
    if ans > 10**18:
      print(-1)
      break
  if ans <= 10**18: print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
str = input().split()
num_list = []
for i in str:
  num_list.append(int(i))

ans = num_list[0]
LIMIT_NUM = 10**18
for i in range(1,len(num_list):
  ans *= num_list[i]

if ans > LIMIT_NUM:
               print(-1)
else:
               print(ans)

def main(): 
  N = int(input())
  str_num = input().split()

  num_list = []
  for i in str_num:
    num_list.append(int(i))

  num_list.sort(reverse=True)

  ans = num_list[0]

  LIMIT_NUM = 10**18

  if 0 in num_list:
    print(0)
    return

  for i in range(1,N):
    ans *= num_list[i]
    if ans > LIMIT_NUM:
      print(-1)
      return

  print(ans)


main()

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def Qb():
    from functools import reduce
    from operator import mul

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

    if 0 in lina:
        print(0)
        exit()

    ans = reduce(mul, lina)

    if 10 ** 18 < ans:
        ans = -1
    print(ans)


def Qc():
    pass


if __name__ == '__main__':
    Qb()


def Qb():
    from functools import reduce
    from operator import mul

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

    if 0 in lina:
        print(0)
        exit()
        
    ans = 1
    for a in lina:
        ans *= a
        if 10 ** 18 < ans:
            ans = -1
            break
    print(ans)


def Qc():
    pass


if __name__ == '__main__':
    Qb()


def Qb():
    n = int(input())
    lina = list(map(int, input().split()))

    if 0 in lina:
        print(0)
        exit()

    ans = 1
    for a in lina:
        ans *= a
        if 10 ** 18 < ans:
            ans = -1
            break
    print(ans)

if __name__ == '__main__':
    Qb()


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys

N = int(input())
A = list(map(int, input().split()))
a = 1

if 0 in A :
    print(0)
    sys.exit()

for i in range(N):
    a = a*A[i]
        if a > 10**18 :
        print(-1)    
        sys.exit()

else : print(a)



import sys

N = int(input())
A = list(map(int, input().split()))
a = 1

if 0 in A :
    print(0)
    sys.exit()

for i in range(N):
    a = a*A[i]
    if a > 10**18 :
        print(-1)    
        sys.exit()

else : print(a)



Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

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

if 0 in A:
    print(0)
    exit()

A.sort(reverse=True)
print(A)
result = A[0]
for a in A[1:]:
    if result * a > 10**18:
        print(-1)
        exit()
    else:
        result = result * a

print(result)

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

if 0 in A:
    print(0)
    exit()

A.sort(reverse=True)

result = A[0]
for a in A[1:]:
    if result * a > 10**18:
        print(-1)
        exit()
    else:
        result = result * a

print(result)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

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

ans = 1
if 0 in A:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > 10**18:
            ans = -1
            break

print(ans)


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

ans = 1
if 0 in A:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > 10**18:
            ans = -1
            break

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

ans = 1
for i in range(0,a):
    ans = ans * b[i]
    print(i)
if ans > 10 ** 18:
    ans = -1

print(ans)

from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

if 0 in b:
    print(0)
else:
    ans = 1
    for i in range(0,a):
        ans = ans * b[i]
        if ans > 10**18:
            print(-1)
            break
        else:
            continue
    else:
        print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            if sum * i > 1000000000000000000:
                print(-1)
            sum = sum * i
    
if __name__ == '__main__':
    main()

import numpy as np

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    for i in a:
        sum = sum * i
    if np.log10(sum) >= 18:
        print(-1)
    else:
       print(sum)
    
if __name__ == '__main__':
    main()

import copy

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            sum = sum * i
            if sum > 1000000000000000000:
                print(-1)
                exit()
        print(sum)
    
if __name__ == '__main__':
    main()
   



Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = input()
A = list(map(int,input().split()))
result = 1
for a in A:
    result *= a
if len(str(result)) > 18:
  result = -1
print(result)

N = input()
A = list(map(int,input().split()))
if 0 in A:
  result = 0
else:
  result = 1
for a in A:
  if len(str(result)) > 19:
    exit
  else:
    result *= a
if result > 10 ** 18:
    result = -1
print(result)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
        print(-1):
            return
    print(prod)
main ()


def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main ()


Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a:
    ans=0
else:
    for i in range(n):
        ans =ans*a[i]
    if ans > 10**18:
        ans=-1
         break  
print(ans)

N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    ans=0
else:
    for i in range(1,N):
        if ans<=10**18:
            ans*=A[i]
        else:
            ans=-1
            exit()
    
print(ans )
    


N = int(input())
A = list(map(int, input().split()))
for i in range(N): 
    C=A[i-1];D=A[i];
    E=C*D
if E>=1000000000000000000:
	print('-1')
else:
	print(E)

n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)     

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
ans = 0
i=0
if A in 0:
  print(0)
else:
  while N > i:
  	if ans > 10**18:
    	print(-1)
        exit()
    else:
      ans *= A[i]
      i += 1
print(ans)

N = int(input())
A = list(map(int,input().split()))
ans = 0

if A in 0:
  print(0)
else:
  while N > i:
  	if ans > 10**18:
    	print(-1)
        exit()
    else:
      ans *= A[i]
print(ans)

N ＝　int(input())
A ＝　list(map(int,input().split()))

ans ＝　1
if A in 0:
  print(0)
else:
  while N > i:
    if ans <= 10**18:
      ans *= A[i]
    else:
      print(-1)
      exit()
print(ans)

##169

##B
N = int(input())
A = list(map(int,input().split()))
ans = 1
i=0
if 0 in A:
  print(0)
else:
  while N > i:
    if ans <= 10**18:
        ans *= A[i]
        i += 1
    else:
        ans = -1
        break
  
  if ans > 10**18:
        print(-1)
  else:
    print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
num = list(map(int,input().split()))
ans = 1
inf_ = 10**18
f = 0
for i in range(len(num)):
    ans *= num[i]

if(ans >=inf_):
    f = 1

if(f ==1):
    print(-1)
else:
    print(ans)

n = int(input())
num = list(map(int,input().split()))
num.sort()
if(num[0] == 0):
    print(0)
else:
    ans = 1
    for i in range(len(num)):
        ans *= num[i]
        if(ans >1000000000000000000):
            print(-1)
            return
    print(ans)


#include <math.h>

using namespace std;

int main() {
    int N;
    cin >> N;
    long long k;
    long long ans = 1;
    for (int i = 0; i<N; i++ ){
        cin >>k;
        // cout << i << endl;
        ans *= k;
    } 
    if(ans > pow(10,18)){
        cout << -1;
    }else{
        cout << ans;
    }

    return 0;
}

n = int(input())
num = list(map(int,input().split()))
num.sort()
if(num[0] == 0):
    print(0)
else:
    ans = 1
    f = 0
    for i in range(len(num)):
        ans *= num[i]
        if(ans >1000000000000000000):
            print(-1)
            f = 1
            break
    if(f == 0):
        print(ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = [int(i) for i in input().split()]
if 0 in a:
  print(0)
  break
A = 1
for i in range(N):
  A = A * a[i]
  if A > 1000000000000000000:
    print(-1)
    break
print(A)

N = int(input())
a = [int(i) for i in input().split()]
A = 1
if 0 in a:
    A = 0
else: 
    for i in range(N-1):
        A = A * a[i]
        if A > 1000000000000000000:
            A = -1
        break
print(A)

N = int(input())
a = [int(i) for i in input().split()]
A = 1
if 0 in a:
  print(0)
  exit()
for i in range(N):
  A = A * a[i]
  if A > 1000000000000000000:
    print(-1)
    exit()
print(A)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
    from functools import reduce
    n = int(input())
    tab = [int(n) for n in input().split()]
    if 0 in tab:
      print("0")
    res = reduce(lambda x, y: x*y, tab)
    if res > 1000000000000000000:
      print("-1")
    else:
      print(res)

def main():
	N = int(input())
	A = list(map(int, input().split()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main()

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = []
a = input().split()
b = 1
for num in range(n):
  b = b * num
print(b)

n = int(input())
a = []
a = input().split()
b = 1
for num in range(n):
  b = b * num
if b > 10**18:
  b = -1
print(b)

n = int(input())
a = []
a = input().split()
b = 1
for num in range(n):
  b = b * a[num]
if b > 10**18:
  b = -1
print(b)

n = int(input())
a = []
a = input().split()
b = 1
for num in a:
  b = b * num
if b > 10**18:
  b = -1
print(b)

n = int(input())
a = input().split()
a_int = [int(n) for n in a]
ans = 1
for num in a_int:
    if ans !> 10**18:
        ans *= num
    else:
        print(-1)
print(ans)

def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    
    prod = 1
    for a in A:
        prod *= a
        if prod > 10**18:
            print(-1)
            return
    print(prod)
    
main ()

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

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

ans = 1

a.sort()
if 0 in a:
    for x in range(n):
        ans *= a[x]

        if ans > 10**18:
            ans = -1
            break
else:
    ans = 0
    
print(ans)


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

ans = 0
for x in range(n):
    ans *= a[x]
    if ans > 10**18:
        ans = -1
        break

print(ans)


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

ans = 1

a.sort(reverse=True)

if 0 not in a:
    for x in range(n):
        ans *= a[x]

        if ans > 10**18:
            ans = -1
            break
else:
    ans = 0

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
result = 1
list = []
list = list(map(int,input().split()))

for i in list:
  result *= i

if result > 10 ^ 18:
  print(-1)
else:
  print(result)

N = int(input())
A = [int(ai) for ai in input().split()]
ans = 1
if 0 in A:
  print(0)
else:
  for ai in A:
    ans *= ai
  if ans > 10**18:
    print(-1)
    break
  else:
    print(ans)



n = int(input())
result = 1
list=[]
list = list(map(int,input().split()))
if 0 in list:
  print(0)
else:
  for i in list:
  result *= list[i]
  if result > 10 ** 18:
  print(-1)
  break

print(result)

N = int(input())
 
list=[int(i) for i in input().split()]
 
answer=1
if 0 in list:
  print(0)
else:
  for i in range(N):
    answer = answer*A[i]
    if answer>10**18:
      print(-1)
      break
  else:
    print(answer)

n = int(input())
result = 1
for i in range(n):
  result *= int(input())

if result > 10 ^ 18:
  print(-1)
else:
  print(result)

n =int(input())
ls =[]
ls =list(map(int,input().split()))
if 0 in ls:
	print(0)
else:
	ans = 1
	for a in ls:
		ans *= a
		if ans > 10 ** 18:
			ans = -1;
			break
		
	print(ans)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys

n=int(input())
a=list(map(int,input().split()))
x=1
if 0 in a:
    print(0)
    sys.exit()

for i in range(len(a)):
    x=a[i]*x
    if x>10^18:
        print(-1)
        sys.exit()
print(x if x<=10**18 else -1)

    

import sys

n=int(input())
a=list(map(int,input().split()))
x=1
if 0 in a:
    print(0)
    sys.exit()

for i in range(len(a)):
    x=a[i]*x
    if x>10^18:
        print(-1)
        exit()
print(x if x<=10**18 else -1)

    

import sys

n=int(input())
a=list(map(int,input().split()))
x=1
if 0 in a:
    print(0)
    sys.exit()

for i in range(len(a)):
    x=a[i]*x
    if x>10**18:
        print(-1)
        sys.exit()
print(x if x<=10**18 else -1)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
x = list(map(int, input().split()))
x = sorted(x)
ans=1
for i in a:
  ans *= i
  if ans > 10 ** 8:
    print(-1)
    exit()
print(ans)



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

if 0 in x:
  print(0)

flag=True
prod = 1
for a in x:
  prod *= a
  if a > 10**18:
    flag = False
    break
  
if flag:
  print(a)
else:
  print("-1")

n = int(input())
a = sorted(map(int, input().split()))
ans = 1
for i in a:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
ls = list(map(int, input().split()))
res = 1
for i in range(n):
    res = res * ls[i]
print(res if res<10**18 else "-1")

n=int(input())
a=list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
else:
    res=1
    for i in a:
        res*=i
        if res>10**18:
            res=-1
            break
    print(res)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
lists = list(int(input()) for i in range(n))
number = 1
for j in lists:
  if number == 0:
    number = 0
    break
  number = number * j
  if number > 10**18:
    number = -1
    break
print(number)

n = int(input())
lists = list(map(int, input().split()))
number = 1
if 0 in lists:
  number = 0
else:
  for j in lists:
    number = number * j
    if number > 10 ** 18:
      number = -1
      break
print(str(number))

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
ans = 1
a = sorted(a,reverse=True)
if(0 in a):
	print(0)
	exit()
for i in a:
	if(len(str(i)) + len(str(ans)) >= 20):
		print(-1)
		exit()
	ans *=i

print(ans)

n = int(input())
a = list(map(int,input().split()))
ans = 1
a = sorted(a,reverse=True)
if(0 in a):
	print(0)
	exit()
for i in a:
	if(len(str(i)) + len(str(ans)) >= 20):
		print(-1)
		exit()
	ans *=i

print(ans if(ans<=pow(10,18)) else -1)

n = int(input())
a = list(map(int,input().split()))
ans = 1
a = sorted(a,reverse=True)
if(0 in a):
	print(0)
	exit()
for i in a:
	if(len(str(i)) + len(str(ans)) >= 19):
		print(-1)
		exit()
	ans *=i

print(ans)

n = int(input())
a = list(map(int,input().split()))
ans = 1
a = sorted(a,reverse=True)
if(0 in a):
	print(0)
	exit()
for i in a:
	if(len(str(i)) + len(str(ans)) >= 20):
		print(-1)
		exit()
	ans *=i

print(ans if(ans<pow(10,18)) else -1)

n = int(input())
a = list(map(int,input().split()))
ans = 1
a = sorted(a,reverse=True)
if(0 in a):
	print(0)
	exit()
for i in a:
	if(len(str(i)) + len(str(ans)) > 20):
		print(-1)
		exit()
	ans *=i

print(ans if(ans<=pow(10,18)) else -1)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A,B=[0]*n,[0]*n
    for i in range(n):
        A[i],B[i]=map(int,input().split())
    A.sort()
    B.sort()
    if n%2==1:
        print(B[n//2]-A[n//2]+1)
    else:
        print(int(((B[n//2-1]+B[n//2])/2-(A[n//2-1]+A[n//2])/2)*2)+1)

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    ans = 1
    if 0 in A:
        print(0)
        sys.exit()
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

if __name__=='__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

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

multi = 1
a = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        break

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

print(multi)
if multi<=1e18:
    print(multi)
else:
    print(-1)


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

multi = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        multi = 0
        break

for i in range(n):
    if a == 0:
        break

    multi *= n_list[i]

    if multi>1e18:
        break

print(multi)
if multi<=1e18:
    print(multi)
else:
    print(-1)

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

multi = 1
a = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        break

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

if multi<=1e18:
    print(multi)
else:
    print(-1)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main(n, a):
  for x in a:
    if(x == 0):
      print(0)
      return
   
  ans = a[0]
  for i in range(1, n):
    ans = ans * a[i]
    if(ans > 1000000000000000000):
      print(-1)
      return
  print(ans)
 
if(__name__ == '__main__'):
  n = int(input())
  a = map(int, input().split())
  main(n, a)


def main(n, a):
  for x in a:
    if(x == 0):
      print(0)
      return
   
  ans = a[0]
  for i in range(1, n):
    ans = ans * a[i]
    if(ans > 1000000000000000000):
      print(-1)
      return
  print(ans)

if(__name__ == '__main__') {
  n = int(input())
  a = map(int, input().split())
  main(n, a)
  	

def main(n, a):
  a = list(a)
  for x in a:
    if(x == 0):
      print(0)
      return
   
  ans = a[0]
  for i in range(1, n):
    ans = ans * a[i]
    if(ans > 1000000000000000000):
      print(-1)
      return
  print(ans)
 
if(__name__ == '__main__'):
  n = int(input())
  a = map(int, input().split())
  main(n, a)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = [int(x) for x in input().split()]

a=1
b=False
for i in range(N):
    a=a*A[i]
    if a>10^18:
        b=True
        continue

if b==False:
    print(a)
else:
    print(-1)




import sys
N=31
A=[4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5,0]
if 0 in A:
    print(0)
    sys.exit()

prod = 1
for a in A:
    prod *= a
    if prod > 10**18:
        print(-1)
        sys.exit()

print(prod)


N = int(input())
A = [int(x) for x in input().split()]

if 0 in A:
    print(0)
    return

prod = 1
for a in A:
prod *= a
if prod > 10**18:
    print(-1)
    return

print(prod)

N = input()
A = [int(x) for x in input().split()]

a=1
b=False
for i in range(N):
    a=a*A[i]
    if a>10^18:
        b=True
        continue

if b==False:
    print(a)
else:
    print(-1)

def main():
N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    return
prod = 1
for a in A:
    prod *= a
if prod > 1000000000000000000:
    print(-1)
    return
print(prod)
main()

def main():
N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    return
prod = 1
for a in A:
    prod *= a
    if prod > 1000000000000000000:
        print(-1)
        return
print(prod)
main()


N = input()
A = [int(x) for x in input().split()]

a=1
b=False
for i in range(N):
    a=a*A[i]
    if a>10^18:
        b=True
        continue

if b==False:
    print(a)
else:
    print(-1)




N = int(input())
A = [int(x) for x in input().split()]

a=1
b=False
for i in range(N):
    a=a*A[i]
    if a>10^18:
        b=True
        continue

if b==False:
    print(a)
else:
    print(-1)


def main():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
    
main()


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
array=[]
for i in range(n):
    array+=[int(input())]
flag=0
flag2=0
s=1
for m in range(len(array)):
    if array[m]==0:
        flag=1
        break
    s=s*array[m]
    if s>10**18:
        flag2=1
        break

if flag==1:
    print("0")
elif flag==2:
    print("-1")
else:print(s)



n=int(input())
array=[]
array+=map(int,input().split())
flag=0
flag2=0
s=1
for m in range(len(array)):
    if array[m]==0:
        flag=1
        break
    s=s*array[m]
    if s>10**18:
        flag2=1
        break
flag3=0
if flag==1:
    print("0")
elif flag2==1:
    for i in range(m,len(array)):
        if array[i]==0:
            flag3=1
            print("0")
    if flag3==0:
        print("-1")

else:print(s)



Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

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

if 0 in A :
    print(0)

for i in range(len(A)):
    n *= A[i]

if n <= 10**18:
    print(N)
else:
    print(-1)

    


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

if 0 in A :
    print(0)
    exit()
for i in A:
    m*= i
    if m > 10**18:
        print(-1)
        exit()
print(m)

    


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np
n = int(input())
a_list = np.array([int(x) for x in input().split()], dtype=np.uint64)
print(a_list)
ans = np.prod(a_list)
print(ans if ans <= 10 ** 18 else -1)

n = int(input())
a_list = sorted([int(x) for x in input().split()], reverse=True)

if a_list[-1] == 0:
    print(0)
    exit()

ans = 1
s = 10 ** 18
for a in a_list:
    ans *= a
    if ans > s:
        ans = -1
        break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
print(A)
i = 10**18
ans = 1

for a in A:
    #print(a,ans)
    if a == 0:
        ans = 0
        break
    else:
        ans *= a
if ans > i:
    print(-1)
else:
    print(ans)

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
#print(A)
i = 10**18
ans = 1
if min(A) == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > i:
            ans = -1
            break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def mulallnumber(numbers): #Function to multiply all numbers in list
   x=1
   for i in numbers:
      x*=i
      return x

A=list() #Creates a list

N=int(input("Enter the size of the list ::")) #size of list

print("Enter the element of list ::")
for i in range(int(N)):
   k=int(input(""))
   A.append(k) #append number in list

if mulallnumber(A)<1000000000000000000:
    print(mulallnumber(A))
else:
    print('-1') #will print '-1' if it exceeds 10^18



z=0
total=1
N=int(input()) #take the N value
    
while z<N: #show how many number of multiplication
    A=int(input()) #Inout from user
    total*=A #multiplication
    z+=1 #increment
    
num1=10**18   
num2=10**5

if N>=2 and N<=num2: #make sure input N is 2<=N<=10^5
    if A>=0 and A<=num1: #make sure input A is 1<A<10^18
        if total>num1:
            print(-1) #over the limit, show -1
            
            
        else:
            print(total) #inside limit, show total
    else:   
        print('Wrong input') #tell the user that the input is wrong
else:
    print('Wrong input') #tell the user that the input is wrong



def mulallnumber(lst):
   x=1
   for i in lst:
      x=x*i
      return x

A=list()

N=int(input("Enter the size of the list ::"))

print("Enter the element of list ::")
for i in range(int(N)):
   k=int(input(""))
   A.append(k)

if mulallnumber(A)<1000000000000000000:
    print(mulallnumber(A))
else:
    print('-1')


n = int(input())
m = int(input().split(" "))
for i in range n:
    total=1
    for x in m:
        total *= m

if total<10000000000000000
    print(total)
else:
    print("-1")

# we collect the input A1 upto An.
# limit cannot exceed 10**18
# if N = 0 then ans = 0
# in N is in range then compute ans * A[n]
# else if  ans is greater than limit then display 1
# finally if length equal 1 then display -1
N = int(input())
ans = 1
limit = 10 ** 18
length = 0

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

A0 = set(A)
if 0 in A0:
    ans = 0
else:
    pass

for n in range(N):
    ans = ans * A[n]
    if ans == 0:
        break
    elif ans > limit:
        length = 1
        break
    else:
        pass

if length == 1:
    print(-1)
else:
    print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np

N = int(input())
AList = np.array([int(element)for element in input().split(" ")])
result = np.prod(AList)

if len(str(result)) > 17:
    print("-1")
else:
    print(str(result))

import numpy as np

N = int(input())
AList = np.array([int(element)for element in input().split(" ")])
result = np.prod(AList)

if len(str(result)) >= 18:
    print("-1")
else:
    print(str(result))

import decimal

N = int(input())

AList = [decimal.Decimal(element) for element in input().split(" ")]

result = 1

for element in AList:
    result += result * element

if result > 10 ** 18:
    print("-1")
else:
    print(result)

import numpy as np

N = int(input())
AList = np.array([int(element)for element in input().split(" ")])
result = np.prod(AList)

if len(str(result)) >= 19:
    print("-1")
else:
    print(str(result))

import sys

N = int(input())
AList = input().split()

result = 1

if "0" in AList:
    print(0)
    sys.exit()
    
for element in AList:
    result = result * int(element)

    if result > 1e+18:
        print(-1)
        sys.exit()

print(result)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted