Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03162 (python)

Fixed submission:
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
b=[0]*3
for i in range(n-2,-1,-1):
    for j in range(3):
        t=0
        for k in range(3):
            if j!=k:
                t=max(t,a[i][j]+a[i+1][k])
        a[i][j]=t
print(max(a[0]))

Buggy submission (verdict: Runtime Error):
def maxreturn(t,n,a):
    ma=[0]*3
    if t==n-1:
        for i in range(3):
           ma[i]=a[n-1][i]
    else:
      b=list(maxreturn(t+1,n,a))
      
      for i in range(3):
        for j in range(3):
            if i!=j:
                ma[i]=max(ma[i],a[t][i]+b[j])
                
    return ma
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
ma=maxreturn(0,n,a)
print(max(ma))

Buggy submission (verdict: Runtime Error):
def maxreturn(t,n,a):
    ma=[0]*3
    b=[0]*3
    if t==n-1:
        for i in range(3):
           ma[i]=a[n-1][i]
    else:
      b=list(maxreturn(t+1,n,a))
      for i in range(3):
        for j in range(3):
            if i!=j:
                ma[i]=max(ma[i],a[t][i]+b[j])
                
    return ma
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
ma=maxreturn(0,n,a)
print(max(ma))

Buggy submission (verdict: Runtime Error):
def maxreturn(t,n,a):
    ma=[0]*3
    b=[0]*n
    if t==n-1:
        for i in range(3):
           ma[i]=a[n-1][i]
    else:
      b=list(maxreturn(t+1,n,a))
      for i in range(3):
        for j in range(3):
            if i!=j:
                ma[i]=max(ma[i],a[t][i]+b[j])
                
    return ma
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
ma=maxreturn(0,n,a)
print(max(ma))

Buggy submission (verdict: Runtime Error):
def maxreturn(t,n,a):
    ma=[0]*3
    if t==n-1:
        for i in range(3):
           ma[i]=a[n-1][i]
    else:
      a[t+1]=list(maxreturn(t+1,n,a))
      for i in range(3):
        for j in range(3):
            if i!=j:
                ma[i]=max(ma[i],a[t][i]+a[t+1][j])
    
    return ma
    
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
ma=maxreturn(0,n,a)
print(max(ma))

Buggy submission (verdict: Runtime Error):
def maxreturn(t,n,a):
    ma=[0]*3
    if t==n-1:
        for i in range(3):
           ma[i]=a[n-1][i]
    else:
      a[t+1]=list(maxreturn(t+1,n,a))
      for i in range(3):
        for j in range(3):
            if i!=j:
                ma[i]=max(ma[i],a[t][i]+a[t+1][j])
    return ma
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
ma=maxreturn(0,n,a)
print(max(ma))

Buggy submission (verdict: Runtime Error):
def maxreturn(t,n,a):
    ma=[0]*n
    b=[0]*n
    if t==n-1:
        for i in range(3):
           ma[i]=a[n-1][i]
    else:
      b=list(maxreturn(t+1,n,a))
      for i in range(3):
        for j in range(3):
            if i!=j:
                ma[i]=max(ma[i],a[t][i]+b[j])
                
    return ma
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
ma=maxreturn(0,n,a)
print(max(ma))
Problem p02788 (python)

Fixed submission:
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

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

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

N, D, A = map(int, input().split())
XH = []

for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    XH.append([x1, y1])

    
def counting(hp):
    if hp < 0:
        return 0
    return hp//A + int(hp%A!=0)

XH.sort()


bombs = deque([]) # 有効な爆弾の威力と範囲を保存する
power = 0 # 有効な爆弾の威力の合計

ans = 0
for i in range(N):
    
    # 使えない爆弾を捨てる
    while len(bombs)>0 and bombs[0][0] < XH[i][0]:
        power -= bombs.popleft()[1]

    # パワーの不足分の爆弾
    add = counting(XH[i][1]-power) 
    ans += add
    
    # 追加した爆弾をキューに加える
    bombs.append((XH[i][0] + 2*D, add*A))
    power += add*A


print(ans)









"""
ATTENTION: Pythonで間に合うか？？

            <目安>
 文字列結合、再帰関数を含む→Python
 上を含まず時間が不安→PyPy3

"""

Buggy submission (verdict: Runtime Error):
import sys
import math
import fractions
import bisect
sys.setrecursionlimit(4100000)

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

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

N, D, A = map(int, input().split())
XH = []
X = []

for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    XH.append([x1, y1])

    
def counting(hp):
    return hp//A + int(hp%A!=0)

ans = 0
XH.sort()
for i in range(N):
    X.append(XH[i][0])

begin = 0
last = XH[begin][0] + 2*D

# これより手前までを減らす
end = bisect.bisect_right(X, last)

while True:
    need = counting(XH[begin][1])
    ans += need
    

    # 爆発
    for i in range(begin, end):
        # 最後に達したら終える
        if i == N:
            break
        XH[i][1] -= need*A
        
    # 次の範囲に更新
    for i in range(begin, end):
        
        if XH[i][1] > 0:
            begin = i
            last = XH[begin][0] + 2*D
            for j in range(end, N):
                if XH[j][1] > last:
                    end = j
                    break
                elif j == N-1:
                    end = N
                    break
            break

        # 最後まで０にできてたらおしまい
        elif i == N-1:
            print(ans)
            sys.exit()

        # 範囲がすべて０以下なら次に行く
        elif i == end-1:
            begin = end
            last = XH[begin][0] + 2*D
            for j in range(end, N):
                if XH[j][1] > last:
                    end = j
                    breake
                elif j == N-1:
                    end = N
                    break







"""
ATTENTION: Pythonで間に合うか？？

            <目安>
 文字列結合、再帰関数を含む→Python
 上を含まず時間が不安→PyPy3

"""
Problem p03029 (python)

Fixed submission:
A, P = (int(x) for x in input().split())
print((3*A + P) // 2)

Buggy submission (verdict: Runtime Error):

A = int(input())
P = int(input())

ans = (A*3+P)//2

print(ans)

Buggy submission (verdict: Runtime Error):

A = int(input())
P = int(input())

ans = (A*3+P)//2

print(ans)
Problem p02555 (python)

Fixed submission:
import math
s = int(input())
ans = 0
if s < 3:
  ans = 0
else:
  p = s // 3
  q = s % 3
  if q == 0:
    ans += 1
  elif q == 1:
    ans += p
  elif q == 2:
    if p == 1:
      ans += 1
    else:
      ans += p + math.factorial(p) // (math.factorial(p - 2) * math.factorial(2))
  for i in range(1, p):
    ans += math.factorial((s - 3 * (p - i)) + (p - i - 1)) // (math.factorial((s - 3 * (p - i))) * math.factorial(p - i - 1))
ans = ans % (10 ** 9 + 7)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
s = int(input())
p = s // 3
q = s % 3
ans = 0
if s < 3:
  ans = 0
else:
  if q == 0:
    ans += 1
  elif q == 1:
    ans += p
  elif q == 2:
    ans += p + math.factorial(p) // (math.factorial(p - 2) * math.factorial(2))
  for i in range(1, p):
    ans += math.factorial((s - 3 * (p - i)) + (p - i - 1)) // (math.factorial((s - 3 * (p - i))) * math.factorial(p - i - 1))
ans = ans % (10 ** 9 + 7)
print(ans)
Problem p02608 (python)

Fixed submission:
n = int(input())
ans = [0] * 10050
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i
      if v<10050:
        ans[v]+=1
for i in range(n):
  print(ans[i+1])

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = [0] * 10000
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      v = i*i+j*j+k*k+i*j+j*k+k*i
      if v<10050:
        ans[v]+=1
for i in range(n):
  print(ans[i+1])
Problem p02630 (python)

Fixed submission:
k = [i for i in range(1, 10 ** 5 + 1)]
v = [0] * (10 ** 5)
dic = {key: val for key, val in zip(k, v)}
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  dic[a[i]] += 1
q = int(input())
ans = [sum(a)]
for i in range(q):
  b, c = map(int, input().split())
  ans.append(ans[-1] + (c - b) * dic[b])
  dic[c] += dic[b]
  dic[b] = 0
for i in range(1, q + 1):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
k = [i for i in range(1, 10 ** 5 + 1)]
v = [0] * 10 * 5
dic = {key: val for key, val in zip(k, v)}
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  dic[a[i]] += 1
q = int(input())
ans = [sum(a)]
for i in range(q):
  b, c = map(int, input().split())
  ans.append(ans[-1] + (c - b) * dic[b])
  dic[c] += dic[b]
  dic[b] = 0
for i in range(1, q + 1):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  dic[a[i]] += 1
q = int(input())
ans = [sum(a)]
for i in range(q):
  b, c = map(int, input().split())
  ans.append(ans[-1] + (c - b) * dic[b])
  dic[c] += dic[b]
  dic[b] = 0
for i in range(1, q + 1):
  print(ans[i])
Problem p02639 (python)

Fixed submission:
l = list(map(int, input().split()))
print(l.index(0) + 1)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
a = 0
ans = ''
p.sort()
print(p)
while ans == '':
  if len(p) == 0:
    ans = x
  elif x - a not in p:
    ans = x - a
  elif x + a not in p:
    ans = x + a
  else:
    a += 1
print(ans)
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
e = []
m = 0
arr = []
ans = 0
for i in range(n):
  m += (p[i] + 1) / 2
  e.append(m)
arr.append(e[k - 1])
for i in range(n - k):
  arr.append(e[i + k] - e[i])
ans = max(arr)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
e = []
m = 0
arr = []
ans = 0
for i in range(n):
  m += (p[i] + 1) / 2
  e.append(m)
for i in range(n - k):
  arr.append(e[i + k] - e[i])
ans = max(arr)
print(ans)
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
a = [0]
i = 0
while i < n - 1:
  k = 0
  p = h[i]
  for j in range(i + 1, n):
    if p >= h[j]:
      p = h[j]
      k += 1
    else:
      break
  i = j
  a.append(k)
print(max(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
a = []
i = 0
while i < n - 1:
  k = 0
  p = h[i]
  for j in range(i + 1, n):
    if p >= h[j]:
      p = h[j]
      k += 1
    else:
      break
  i = j
  a.append(k)
print(max(a))
Problem p02952 (python)

Fixed submission:
n = input()
a = len(n)  # 桁数
if a % 2 == 0:  # 桁数が偶数
  ans = "90" * (a // 2)
  ans = int(ans[:-1])
else:
  if a == 1:
    ans = int(n)
  else:
    ans = "90" * ((a - 1) // 2)
    ans = int(ans[:-1])
    ans += int(n) - 10 ** (a - 1) + 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
a = len(n)  # 桁数
if a % 2 == 0:  # 桁数が偶数
  ans = "90" * (a // 2)
  ans = int(ans[:-1])
else:
  ans = "90" * ((a - 1) // 2)
  ans = int(ans[:-1])
  ans += int(n) - 10 ** (a - 1) + 1
print(ans)
Problem p02995 (python)

Fixed submission:
import math
a, b, c, d = map(int, input().split())
e = b - ((b // c) + (b // d) - (b // (c * d // math.gcd(c, d))))
f = (a - 1) - (((a - 1) // c) + ((a - 1) // d) - ((a - 1) // (c * d // math.gcd(c, d))))
ans = e - f
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
ans = 0
def notdiv(n, m):
  return n // m

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a -= 1
e = b - notdiv(b, c) - notdiv(b, d) + notdiv(b, lcm(c, d))
f = a - notdiv(a, c) - notdiv(a, d) + notdiv(a, lcm(c, d))
ans = e - f
print(ans)
Problem p03037 (python)

Fixed submission:
n, m = map(int, input().split())
max_l = 0
min_r = n
ans = n
for i in range(m):
  l, r = map(int, input().split())
  if ans != 0:
    if l <= min_r or r <= max_l:
      max_l = max(max_l, l)
      min_r = min(min_r, r)
    else:
      ans = 0
if ans != 0:
  ans = min_r - max_l + 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
arr = [0] * n
for i in range(m):
  l, r = map(int, input().split())
  arr[l - 1] += 1
  arr[l] += 1
  arr[r - 1] += 1
ans = 0
for i in range(n):
  if arr[i] == m:
    ans += 1
print(ans)
Problem p03086 (python)

Fixed submission:
s = input()
a = ['A', 'C', 'G', 'T']
ans = []
k = 0
for i in range(len(s)):
  if s[i] in a:
    k += 1
  else:
    ans.append(k)
    k = 0
ans.append(k)
print(max(ans))

Buggy submission (verdict: Runtime Error):
s = input()
a = ['A', 'C', 'G', 'T']
ans = []
k = 0
for i in range(len(s)):
  if s[i] in a:
    k += 1
  else:
    ans.append(k)
    k = 0
print(max(ans))
Problem p03147 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
H = [h]
ans = 0
while len(H) > 0:
  for e in H:
    if len(e) == 0:
      H.remove(e)
    elif 0 in e:
      a = e[:e.index(0)]
      b = e[e.index(0) + 1:]
      H.append(a)
      H.append(b)
      H.remove(e)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
    else:
      ans += min(e)
      c = [e[j] - min(e) for j in range(len(e))]
      a = c[:c.index(0)]
      b = c[c.index(0) + 1:]
      H.append(a)
      H.append(b)
      H.remove(e)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
    if [] in H:
      H.remove([])
      if len(H) == 0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
H = [h]
ans = 0
while len(H) > 0:
  if [] in H:
    H.remove([])
    if len(H) == 0:
      break
  for i in range(len(H)):
    if len(H[i]) == 0:
      H.pop(i)
    elif 0 in H[i]:
      a = H[i][:H[i].index(0)]
      b = H[i][H[i].index(0) + 1:]
      H.append(a)
      H.append(b)
      H.pop(i)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
    else:
      ans += min(H[i])
      H[i] = [H[i][j] - min(H[i]) for j in range(len(H[i]))]
      a = H[i][:H[i].index(0)]
      b = H[i][H[i].index(0) + 1:]
      H.append(a)
      H.append(b)
      H.pop(i)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
print(ans)
Problem p03427 (python)

Fixed submission:
n = input()
k = len(n)
a = 9 * (k - 1) + int(n[0]) - 1
b = 0
for i in range(k):
  b += int(n[i])
c = 0
m = ''
if k > 2 and n[-2] != '0':
  m = str(int(n))[:k - 2] + str(int(n[-2]) - 1) + '9'
elif k > 2 and n[-2] == '0':
  m = str(int(n) - (int(n[-1]) + 1))
for i in range(len(m)):
  c += int(m[i])
ans = max(a, b, c)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = len(str(n))
a = 9 * (k - 1)
b = 0
for i in range(k):
  b += int(str(n)[i])
c = 0
if k > 2:
  m = str(int(n))[:k - 2] + str(int(int(str(n)[-2]) - 1)) + '9'
  for i in range(k):
    c += int(m[i])
ans = max(a, b, c)
print(ans)
Problem p02584 (python)

Fixed submission:
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


x, k, d = List()
x = abs(x)
if d * k > x:
    distance = x % d
    do = k - (x // d)
    if do & 1:
        print(d - distance)
    else:
        print(distance)
else:
    print(x - k * d)

Buggy submission (verdict: Runtime Error):
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


x, k, d = List()
x = abs(x)
if k * d > x:
    point1 = x - (x // d) * d
    point2 = point1 - d
    travel_to_point1 = (x - point1) // d
    travel_to_point2 = (x - point2) // d
    pair = [[abs(point1), abs(travel_to_point1)], [abs(point2), abs(travel_to_point2)]]
    pair.sort(key = lambda i: i[0])
    # print(pair)
    if pair[0][1] != 0 or pair[1][1] != 0:
        if k % pair[0][1] == 0:
            if pair[0][1] != 1:
                print(pair[0][0])
            else:
                if k & 1:
                    print(pair[0][0])
                else:
                    print(pair[1][0])
        else:
            if pair[1][1] != 1:
                print(pair[1][0])
            else:
                if k & 1:
                    print(pair[1][0])
                else:
                    print(pair[0][0])
    else:
        if pair[0][1] == 0:
            if k % 2 == 0:
                print(pair[0][0])
            else:
                print(pair[1][0])
        else:
            if k % 2 == 0:
                print(pair[1][0])
            else:
                print(pair[0][0])

else:
    print(x - k * d)

Buggy submission (verdict: Runtime Error):
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


x, k, d = List()
x = abs(x)
if k * d > x:
    point1 = x - (x // d) * d
    point2 = point1 - d
    travel_to_point1 = (x - point1) // d
    travel_to_point2 = (x - point2) // d
    pair = [[abs(point1), abs(travel_to_point1)], [abs(point2), abs(travel_to_point2)]]
    pair.sort(key = lambda i: i[0])
    # print(pair)
    if k % pair[0][1] == 0:
        if pair[0][1] != 1:
            print(pair[0][0])
        else:
            if k & 1:
                print(pair[0][0])
            else:
                print(pair[1][0])
    else:
        if pair[1][1] != 1:
            print(pair[1][0])
        else:
            if k & 1:
                print(pair[1][0])
            else:
                print(pair[0][0])

else:
    print(x - k * d)
Problem p02621 (python)

Fixed submission:
"""
~~ Author : Bhaskar
~~ Dated : 10~06~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")
input = lambda : sys.stdin.readline()

def solve():
    n = int(sys.stdin.readline())
    print(n + n ** 2 + n ** 3)
    


if __name__ == "__main__":
    try:
        sys.stdin = open('input.txt','r')
        sys.stdout = open('output.txt','w')
    except:
       pass
    solve()

Buggy submission (verdict: Runtime Error):
"""
~~ Author : Bhaskar
~~ Dated : 10~06~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")
input = lambda : sys.stdin.readline()

def solve():
    n = int(sys.stdin.readline())
    print(a+a**2+a**3)


if __name__ == "__main__":
    try:
        sys.stdin = open('input.txt','r')
        sys.stdout = open('output.txt','w')
    except:
       pass
    solve()
Problem p02658 (python)

Fixed submission:
"""
~~ Author : Bhaskar
~~ Dated : 31~05~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 10**18
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")

def solve():
    n = int(sys.stdin.readline())
    a = list(map(int,sys.stdin.readline().split()))
    ans =  1
    flag = False
    for i in a:
        ans *= i
        # print(ans)
        if ans > mod:
            flag = True
            break
    if 0 in a:
        print(0)
    else:
        if not flag:
            print(ans)
        else:
            print(-1)

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
"""
~~ Author : Bhaskar
~~ Dated : 13~06~2020
"""

import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque

INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize) - 1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a, b: (a * b) // gcd(a, b)
setbit = lambda x: bin(x)[2:].count("1")
INT = lambda type: type(sys.stdin.readline()) if type in [int, float] else type(sys.stdin.readline()).replace("\n", "")
ARRAY = lambda type: list(map(type, sys.stdin.readline().split()))
NUMS = lambda type: map(type, sys.stdin.readline().split())


def solve():

    n = INT(int)
    a = ARRAY(int)
    if 0 in a:
        print(0)
    else:
        p = 1
        ok = False
        for i in a:
            a *= i
            if a > 10**18:
                ok = True
                break
        print(a if not ok else -1)



if __name__ == "__main__":
    try:
        sys.stdin = open("input.txt", "r")
    except:
        pass
    solve()

Buggy submission (verdict: Runtime Error):
"""
~~ Author : Bhaskar
~~ Dated : 13~06~2020
"""

import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque

INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize) - 1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a, b: (a * b) // gcd(a, b)
setbit = lambda x: bin(x)[2:].count("1")
INT = lambda type: type(sys.stdin.readline()) if type in [int, float] else type(sys.stdin.readline()).replace("\n", "")
ARRAY = lambda type: list(map(type, sys.stdin.readline().split()))
NUMS = lambda type: map(type, sys.stdin.readline().split())


def solve():

    n = INT(int)
    a = ARRAY(int)
    if 0 in a:
        print(0)
        return
    p = 1
    for i in a:
        a *= i
        if a > 10**18:
            print(-1)
            return 
    print(a)



if __name__ == "__main__":
    try:
        sys.stdin = open("input.txt", "r")
    except:
        pass
    solve()