Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
mod =998244353

def nCr(n,r):
  if r*2>n:
      return nCr(n,n-r)
  else:
      a = b = 1
      for i in range(r):
          a = a * (n - i) % mod
          b = b * (r - i) % mod
      return (a * pow(b,mod-2,mod)) % mod
n,m,k=map(int,input().split())
ans=0
for i in range(0, k+1):
    ans += m * (pow(m-1, n-i-1, mod) %mod)* (nCr(n-1, i) % mod)
    ans%=mod
print(ans % mod)

Fixed submission:
MOD=998244353

fact = [0] * 220000
invfact = [0] * 220000

fact[0] = 1
for i in range(1, 220000):
    fact[i] = fact[i-1] * i % MOD

invfact[220000 - 1] = pow(fact[220000 - 1], MOD-2, MOD)

for i in range(220000 - 2, -1, -1):
    invfact[i] = invfact[i+1] * (i+1) % MOD

def nCk(n, k):
    if k < 0 or n < k:return 0
    return fact[n] * invfact[k] * invfact[n-k] % MOD

n,m,k=map(int,input().split())
ans=0
for i in range(0, k+1):
    ans += m * (pow(m-1, n-i-1, MOD) %MOD)* (nCk(n-1, i) % MOD)
    ans%=MOD
print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
ans=0
x=list(range(n+1))
for i in range(k,n+2):
  A=sum(x[n-i+1:n+1])
  B=sum(x[0:i])
  ans+=A-B+1
print(ans)


Fixed submission:
a,b=(int(x)for x in input().split())
z=0
while b<=a+1:z=(z+(a-b+1)*b+1)%(10**9+7);b+=1
print(z)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=map(int,input().split())

b = [ (a,i) for i,a in enumerate(a)]

b.sort(reverse=True)

dp=[ [0] * (n+1) for i in range(n+1) ]

ans=0

for l in range(n):
  for r in range(n):
    if l + r == n:
      ans = max( ans, dp[l][r] )
      break
    act , i = b[l+r]
    dp[l+1][r] = max( dp[l+1][r] , dp[l][r] +act*abs(i-l))
    dp[l][r+1] = max( dp[l][r+1] , dp[l][r] +act*abs(n-i-1-r))
print(ans)

Fixed submission:
n=int(input())
a=map(int,input().split())

b = [ (a,i) for i,a in enumerate(a)]

b.sort(reverse=True)

dp=[ [0] * (n+1) for i in range(n+1) ]

ans=0

for l in range(n):
  for r in range(n):
    if l + r == n:
      ans = max( ans, dp[l][r] )
      break
    act , i = b[l+r]
    dp[l+1][r] = max( dp[l+1][r] , dp[l][r] +act*abs(i-l))
    dp[l][r+1] = max( dp[l][r+1] , dp[l][r] +act*abs(n-i-1-r))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j+1
        while k<n:
            if l[i]+l[j]>l[k]:
                k+=1
                ans+=1
            else:
                break
print(ans)


Fixed submission:
n=int(input())
p=list(map(int,input().split()))
p.sort()
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if j<n-2:
            l=j+1
            r=n-1
            while r-l>1:
                c=(l+r)//2
                if p[c]>=p[i]+p[j]:
                    r=c
                else:
                    l=c
            if p[l]<p[i]+p[j]:
                ans+=l-j
            if p[r]<p[i]+p[j]:
                ans+=1
        if j==n-2:
            if p[i]+p[n-2]>p[n-1]:
                ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[]
x={}
ans=0
for j in range(n):
    s=list(input())
    s.sort()
    p=''.join(s)
    if s not in l:
        l.append(s)
        x[p]=1
    else:
        ans+=x[p]
        x[p]+=1
print(ans)

Fixed submission:
n=int(input())
x={}
ans=0
for j in range(n):
    s=list(input())
    s.sort()
    p=''.join(s)
    if p not in x:
        x[p]=1
    else:
        ans+=x[p]
        x[p]+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
m=10**9+7
s=list(input())
n=len(s)
s.reverse()
dp=[[0]*13 for _ in range(n)]
if s[0]=="?":
    for i in range(10):
        dp[0][i]+=1
else:
    dp[0][int(s[0])]=1
x=1
for i in range(1,n):
    x=(x*10)%13
    for j in range(13):
        if s[i]=="?":
            if dp[i-1][j]!=0:
                for k in range(10):
                    dp[i][(j+k*x)%13]+=dp[i-1][j]
        else:
            if dp[i-1][j]!=0:
                dp[i][(j+int(s[i])*x)%13]+=dp[i-1][j]
print(dp[n-1][5]%m)

Fixed submission:
m=10**9+7
s=list(input())
n=len(s)
s.reverse()
dp=[[0]*13 for _ in range(n)]
if s[0]=="?":
    for i in range(10):
        dp[0][i]+=1
else:
    dp[0][int(s[0])]=1
x=1
for i in range(1,n):
    x=(x*10)%13
    for j in range(13):
        if s[i]=="?":
            if dp[i-1][j]!=0:
                for k in range(10):
                    dp[i][(j+k*x)%13]+=dp[i-1][j]
                    dp[i][j]%=m
        else:
            if dp[i-1][j]!=0:
                dp[i][(j+int(s[i])*x)%13]+=dp[i-1][j]
                dp[i][j]%=m
print(dp[n-1][5]%m)

Buggy python submission (verdict: Time Limit Exceeded):
m=10**9+7
s=list(input())
n=len(s)
s.reverse()
dp=[[0]*13 for _ in range(n)]
if s[0]=="?":
    for i in range(10):
        dp[0][i]+=1
else:
    dp[0][int(s[0])]=1
x=1
for i in range(1,n):
    x=(x*10)%13
    for j in range(13):
        if s[i]=="?":
            if dp[i-1][j]!=0:
                for k in range(10):
                    dp[i][(j+k*x)%13]+=dp[i-1][j]
        else:
            if dp[i-1][j]!=0:
                dp[i][(j+int(s[i])*x)%13]+=dp[i-1][j]
print(dp[n-1][5]%m)

Fixed submission:
m=10**9+7
s=list(input())
n=len(s)
s.reverse()
dp=[[0]*13 for _ in range(n)]
if s[0]=="?":
    for i in range(10):
        dp[0][i]+=1
else:
    dp[0][int(s[0])]=1
x=1
for i in range(1,n):
    x=(x*10)%13
    for j in range(13):
        if s[i]=="?":
            if dp[i-1][j]!=0:
                for k in range(10):
                    dp[i][(j+k*x)%13]+=dp[i-1][j]
                    dp[i][j]%=m
        else:
            if dp[i-1][j]!=0:
                dp[i][(j+int(s[i])*x)%13]+=dp[i-1][j]
                dp[i][j]%=m
print(dp[n-1][5]%m)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append(A)
l=deque([a[0]])
for i in range(1,n):
    if l[0]>=a[i]:
        l.appendleft(a[i])
    elif l[-1]<=a[i]:
        l.append(a[i])
    else:
        p=0
        q=len(l)-1
        while q-p!=1:
            if l[(p+q)//2]>=a[i]:
                q=(p+q)//2
            else:
                p=(p+q)//2
        l[p]=a[i]
print(len(l))

Fixed submission:

from collections import deque

n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append(A)
l=deque([a[0]])
for i in range(1,n):
    if l[0]>=a[i]:
        l.appendleft(a[i])
    elif l[-1]<a[i]:
        l[-1]=a[i]
    else:
        p=0
        q=len(l)-1
        while q-p!=1:
            if l[(p+q)//2]>=a[i]:
                q=(p+q)//2
            else:
                p=(p+q)//2
        l[p]=a[i]
print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append(A)
a.append(a[n-1]+1)
l=[0]
for i in range(n):
    if a[i]>=a[i+1]:
        l.sort()
        if l[0]<a[i]:
            l[0]=a[i]
        else:
            l.append(a[i])
    else:
        continue
if l[0]==0:
    print(len(l))
else:
    print(len(l)+1)

Fixed submission:

from collections import deque

n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append(A)
l=deque([a[0]])
for i in range(1,n):
    if l[0]>=a[i]:
        l.appendleft(a[i])
    elif l[-1]<a[i]:
        l[-1]=a[i]
    else:
        p=0
        q=len(l)-1
        while q-p!=1:
            if l[(p+q)//2]>=a[i]:
                q=(p+q)//2
            else:
                p=(p+q)//2
        l[p]=a[i]
print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append(A)
a.append(a[n-1]+1)
l=[0]
for i in range(n):
    l.sort()
    if a[i]>=a[i+1]:
        if l[0]<a[i]:
            l[0]=a[i]
        else:
            l.append(a[i])
    else:
        continue
if l[0]==0:
    print(len(l))
else:
    print(len(l)+1)

Fixed submission:

from collections import deque

n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append(A)
l=deque([a[0]])
for i in range(1,n):
    if l[0]>=a[i]:
        l.appendleft(a[i])
    elif l[-1]<a[i]:
        l[-1]=a[i]
    else:
        p=0
        q=len(l)-1
        while q-p!=1:
            if l[(p+q)//2]>=a[i]:
                q=(p+q)//2
            else:
                p=(p+q)//2
        l[p]=a[i]
print(len(l))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numpy.linalg import solve

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

l=[[0]*n for _ in range(n)]
k=0
for i in range(n-1):
    l[i][k]=1
    l[i][k+1]=1
    k+=1
l[n-1][0]=1
l[n-1][n-1]=1
p=[[0] for _ in range(n)]
for i in range(n):
    p[i]=a[i]*2
for i in solve(l,p):
  print(int(i), end=" ")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
s=0
for i in range((n-1)//2):
    s+=a[2*i+1]
l[0]=sum(a)-2*s
for i in range(n-1):
    l[i+1]=2*a[i]-l[i]
for i in l:
    print(int(i), end=" ")
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append((x,y))
x={}
for i in l:
    for j in l:
        if i!=j:
            t=(i[0]-j[0],i[1]-j[1])
            if t in x:
                x[t]+=1
            else:
                x[t]=1
print(n-max(x.values()))

Fixed submission:
n=int(input())
l=[]
if n==1:
    print(1)
    exit()
else:
    for i in range(n):
        x,y=map(int,input().split())
        l.append((x,y))
    x={}
    for i in l:
        for j in l:
            if i!=j:
                t=(i[0]-j[0],i[1]-j[1])
                if t in x:
                    x[t]+=1
                else:
                    x[t]=1
    print(n-max(x.values()))

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append((x,y))
x={}
for i in l:
    for j in l:
        if i!=j:
            t=(i[0]-j[0],i[1]-j[1])
            if t in x:
                x[t]+=1
            else:
                x[t]=1
print(max(x.values()))

Fixed submission:
n=int(input())
l=[]
if n==1:
    print(1)
    exit()
else:
    for i in range(n):
        x,y=map(int,input().split())
        l.append((x,y))
    x={}
    for i in l:
        for j in l:
            if i!=j:
                t=(i[0]-j[0],i[1]-j[1])
                if t in x:
                    x[t]+=1
                else:
                    x[t]=1
    print(n-max(x.values()))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(n+1)
for i in range(n):
  dp[i]=10**5
  if i<=k:
    dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]))
  else:
    dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]))

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  dp[i]=float('inf')
  for j in range(1,k+1):
    if i-j>=0:
      dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]) , dp[i])
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
N,W= map(int,input().split())
w=[]
v=[]
for  i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp =[ [0]*(N+3) for _ in range(W+3) ]

for i in range(N):
    for  j in range(W+1):
        dp[i+1][j]=dp[i][j]
        if j-w[i]>=0:
            dp[i+1][j]= max(dp[i][j] , dp[i][j-w[i]]+v[i])

print(dp[N][W])

Fixed submission:
N,W= map(int,input().split())
w=[]
v=[]
for  i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp =[ [0]*(W+1) for _ in range(N+1) ]

for i in range(N):
    for  j in range(W+1):
        dp[i+1][j]=dp[i][j]
        if j-w[i]>=0:
            dp[i+1][j]= max(dp[i][j] , dp[i][j-w[i]]+v[i])

print(dp[N][W])

Buggy python submission (verdict: Runtime Error):
N,W= map(int,input().split())
w=[]
v=[]
for  i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp =[ [0]*(N*10) for _ in range(W*10) ]

for i in range(N):
    for  j in range(W+1):
        dp[i+1][j]=dp[i][j]
        if j-w[i]>=0:
            dp[i+1][j]= max(dp[i][j] , dp[i][j-w[i]]+v[i])

print(dp[N][W])

Fixed submission:
N,W= map(int,input().split())
w=[]
v=[]
for  i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp =[ [0]*(W+1) for _ in range(N+1) ]

for i in range(N):
    for  j in range(W+1):
        dp[i+1][j]=dp[i][j]
        if j-w[i]>=0:
            dp[i+1][j]= max(dp[i][j] , dp[i][j-w[i]]+v[i])

print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
n=int(input())
cnt=0
for i in range(n):
    a=int(input())
    cnt+=(a%2)
if:
    if cnt==0:
        print("second")
    else:
        print("first")

Fixed submission:
n=int(input())
cnt=0
for i in range(n):
    a=int(input())
    cnt+=(a%2)
if cnt==0:
    print("second")    
else:
    print("first")

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=0
for i in range(n):
    a=int(input())
    cnt+=(a-1)%2
    cnt%=2
    x=max(a,x)
if x==1:
    print("first")
    if n%2==0:
        if cnt==0:
            print("second")
        else:
            print("first")
    else:
        if cnt==0:
            print("second")
        else:
            print("first")

Fixed submission:
n=int(input())
cnt=0
for i in range(n):
    a=int(input())
    cnt+=(a%2)
if cnt==0:
    print("second")    
else:
    print("first")

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=0
cnt=0
for i in range(n):
    a=int(input())
    x=max(a,x)
    cnt+=a
if x==1:
    print(first)
else:
    if (a-2)%2==1:
        print("first")
    else:
        print("second")

Fixed submission:
n=int(input())
cnt=0
for i in range(n):
    a=int(input())
    cnt+=(a%2)
if cnt==0:
    print("second")    
else:
    print("first")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    for j in range(i+1,n+1):
        s=sum(a[i:j])
        b.append(s)

x=0
for i in reversed(range(41)):
    cnt=0
    for j in b:
        if (x+2**i) & j ==(x+2**i):
            cnt+=1
    if cnt>=k:
        x+=2**i
print(x)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    for j in range(i+1,n+1):
        s=sum(a[i:j])
        b.append(s)

x=0
for i in reversed(range(41)):
    cnt=0
    for j in b:
        if (x+2**i) & j ==(x+2**i):
            cnt+=1
    if cnt>=k:
        x+=2**i
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0

for i in range(n):
    l=i
    r=i
    s=0
    while r<n:
        if s ^ a[r]== s+a[r]:
            s+=a[r]
            r+=1
            ans+=1
        else:
            break
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0

l=r=s=0
while l<n:
    if s^a[r]==s+a[r]:
        s+=a[r]
        if r!=n-1:
            r+=1
        else:
            break
    else:
        ans+=r-l
        s-=a[l]
        l+=1

ans+=(r-l+1)*(r-l+2)//2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[[0] for _ in range(n)]
for i in range(n):
    s[i]=input()

ans=0
for p in range(n):
    cnt=0
    t=[[0] for _ in range(n)]
    for i in range(n):
        t[i]=s[(i+p)%n]
    for r in range(n):
        for l in range(n):
            if t[r][l]==t[l][r]:
                cnt+=1
    if cnt==n**2:
        ans+=1
print(ans*n)


Fixed submission:
n=int(input())
s=[[0] for _ in range(n)]
for i in range(n):
    s[i]=input()

ans=0
for p in range(n):
    cnt=0
    t=[[0] for _ in range(n)]
    for i in range(n):
        t[i]=s[(i+p)%n]
    for r in range(n):
        for l in range(n):
            if t[r][l]==t[l][r]:
                cnt+=1
    if cnt==n**2:
        ans+=1
print(ans*n)
Buggy python submission (verdict: Time Limit Exceeded):
n,x=map(int,input().split())
a=list(map(int,input().split()))

cnt=0
for i in range(1,n):
    v = a[i]+a[i-1]-x
    if v>0:
        cnt+=v
        while v>0:
            if a[i]>0:
                a[i]-=1
            else:
                a[i-1]-=1
            v-=1

print(cnt)

Fixed submission:
n,x=map(int,input().split())
a=list(map(int,input().split()))

cnt=0
for i in range(1,n):
    v = a[i]+a[i-1]-x
    if v>0:
        cnt+=v
        if a[i]>=v:
            a[i]-=v
        else:
            v-=a[i]
            a[i]=0
            a[i-1]-=v
        
print(cnt)
Buggy python submission (verdict: Runtime Error):
s=int(input())
n=len(s)
sum=0
for i in range(1<<n-1):
  t=0
  for j in range(n-1):
    if i & (1<<j):
      sum += int("".join(s[t:j+1]))
      t = j+1 
print(sum)

Fixed submission:
s=input()
n=len(s)
sum=0
for i in range(1<<n-1):
  t=0
  for j in range(n-1):
    if i & (1<<j):
      sum += int("".join(s[t:j+1]))
      t = j+1 
  sum += int(''.join(s[t:]))
print(sum)
Buggy python submission (verdict: Runtime Error):
import math

n ,d  = input().split()
n = int(n)
d = int(d)

for i in range(n):
    x ,y  = input().split()
    x = int(x)
    y = int(y)

    a = math.sqrt(x*x + y*y)
    
    if a <= d:
        nanko += 1

print(nanko) 


Fixed submission:
import math

p = 0

n,d  = input().split()
n = int(n)
d = int(d)

for i in range(n):
    x,y  = input().split()
    x = int(x)
    y = int(y)

    a = math.sqrt(x*x + y*y)
    
    if a <= d:
        p = p + 1

print(p)

Buggy python submission (verdict: Runtime Error):
import math
n,d=list(map(int,input().split()))
ans=0
for i in range(n):
  x,y=list(map(int,input().split()))
  if (math.sqrt((x*x)+(y*y)))//d>=1:
    ans+=1
print(ans)

Fixed submission:
n,d=list(map(int,input().split()))
ans=0
for i in range(n):
  x,y=list(map(int,input().split()))
  if (x*x)+(y*y)>d*d:
    
    ans+=1
print(n-ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = input()
i,j = 0, len(c)-1
count = 0
while i!=j:
    if c[i]=='W' and c[j]=='R':
        i+=1
        j-=1
        count += 1
        continue
    if c[i]=='W' and c[j]!='R':
        j -= 1
        continue
    if c[i]!='W' and c[j]=='R':
        i += 1
    if abs(i-j)==1:
        break
print(count)


Fixed submission:
n = int(input())
c = input()
R = c.count('R')
ans = 0
for i in range(R):
    if c[i]=='W':
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))

count = 0
pre = p[0]
for i, now in enumerate(p):
    if now <=pre:
         count+=1
    pre = min(p[:i+1])
print(count)


Fixed submission:
n = int(input())
p = list(map(int, input().split()))

count = 0
pre = p[0]
for now in p:
    if now <=pre:
        count+=1
        pre = now
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
res = 1000000000000
for i in range(N):
    count = 0
    x = int(input())
    while x%2==0:
        x /= 2
        count += 1
    if res > count: res = count
print(res)


Fixed submission:
N = int(input())
res = 1000000000000
x = list(map(int, input().split()))
for x in x:
    count = 0
    while x%2==0:
        x /= 2
        count += 1
    if res > count: res = count
print(res)
Buggy python submission (verdict: Runtime Error):
if input() >= 30:
  print("Yes")
else:
  print("No")

Fixed submission:
if int(input()) >= 30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().strip().split(" "))
scores = input().strip().split(" ")
i = 0
grade = 1
for i in range(K):
    grade *= int(scores[i])

for i in range(K, N):
    last = grade
    grade = int(grade / int(scores[i-K]))
    grade *= int(scores[i])
    if (grade > last):
        print("Yes")
    else:
        print("No")

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

for i in range(K, N):
    if (int(scores[i]) > int(scores[i-K])):
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().strip().split(" "))
scores = [int(x) for x in input().strip().split(" ")]
i = 0
grade = 1
for i in range(K):
    grade *= scores[i]

for i in range(K, N):
    last = grade;
    grade = int(grade / scores[i-K])
    grade *= scores[i]
    if (grade > last):
        print("Yes")
    else:
        print("No")

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

for i in range(K, N):
    if (int(scores[i]) > int(scores[i-K])):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
verdicts = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

v = input()
while v:
    verdicts[v] += 1
    v = input()

for v, f in verdicts.items():
    print(f'{v} x {f}')


Fixed submission:
verdicts = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
N = int(input())
for i in range(N):
    v = input()
    verdicts[v] += 1

for v, f in verdicts.items():
    print(f'{v} x {f}')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())z
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



n=int(input())
#n,m=input_list()
a=input_list()
ans=1
for i in a:
    ans*=i

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

else:
    print(ans)


Fixed submission:
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())z
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



n=int(input())
#n,m=input_list()
a=input_list()
ans=1
if 0 in a:
    print(0)
    exit()
for i in a:
    ans*=i
    if ans>10**18:
        print(-1)
        exit()



print(ans)