Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import deque
n = int(input())

a = deque(map(int,input().split()))
ans = 1
for i in range(n):
    ans = ans * a.popleft()



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

### FIXED CODE ###

from collections import deque
import sys
n = int(input())

a = list(map(int,input().split()))
a.sort()
if(a[0] == 0):
    print("0")
    sys.exit()
ans = 1
for i in range(n):

    ans = ans * a[i]
    if(ans > 10**18):
        print("-1")
        sys.exit()
     




print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

#=====================================
class Tree():
  def __init__(self):
    self.children = []
    self.counter = 0

  def add_child(self, child):
    self.children += [child]
  
  def reconstruct(self, root=None):
    if root in self.children:
      self.children.remove(root)
    for child in self.children:
      child.reconstruct(self)
  
  def add_count(self, x):
    self.counter += x
    for child in self.children:
      child.add_count(x)

#=====================================
def solve():
  n,q = [int(i) for i in input().split()]
  trees = [Tree() for i in range(n)]

  for _ in range(n-1):
    a,b = [int(i) for i in input().split()]
    trees[a-1].add_child(trees[b-1])
    trees[b-1].add_child(trees[a-1])

  trees[0].reconstruct()

  for _ in range(q):
    p,x = [int(i) for i in input().split()]
    trees[p-1].add_count(x)

  print(*[trees[i].counter for i in range(n)])
  
#=====================================
if __name__ == '__main__':
  solve()

### FIXED CODE ###

N, Q = map(int, input().split())
graph = [[] for i in range(200010)]
ans = [0 for i in range(200010)]
import sys
#sys.setrecursionlimit(100000)
sys.setrecursionlimit(10**7)
#
readline = sys.stdin.readline


for _ in range(N - 1):
    #a, b = map(int, input().split())
    a, b = map(int, readline().split())
    a -= 1
    b -= 1

    graph[a].append(b)
    graph[b].append(a)

for _ in range(Q):
    #p, x = map(int, input().split())
    p, x = map(int, readline().split())
    p -= 1

    ans[p] += x

def dfs(node, frm=-1):
    for to in graph[node]:
        if to == frm:
            continue
        ans[to] += ans[node]
        dfs(to, node)
dfs(0)

print(*ans[:N])
### BUGGY CODE ###

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

v_total = sum([x[1] for x in wv])
dp = [0] + [float("inf")]*v_total

for i in range(n):
    for j in range(v_total, wv[i][1]-1, -1):
        dp[j] = min(dp[j], dp[j-wv[i][1]]+wv[i][0])

ans = 0
for i in range(v_total+1):
    if dp[i] <= w:
        ans = i
print(ans)

### FIXED CODE ###

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

v_total = sum([x[1] for x in wv])
dp = [0] + [float("inf")]*v_total

for i in range(n):
    for j in range(v_total, wv[i][1]-1, -1):
        dp[j] = min(dp[j], dp[j-wv[i][1]]+wv[i][0])

ans = 0
for i in range(v_total+1):
    if dp[i] <= w:
        ans = i
print(ans)
### BUGGY CODE ###

import copy
from collections import deque

h, w = map(int, input().split())
grid = [list(map(lambda x: x == "#", input().rstrip())) for _ in range(h)]

nq = deque([])
for i in range(h):
    for j in range(w):
        if grid[i][j]:
            nq.append([i, j])

moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

cnt = 0
while sum(sum(grid, [])) < h * w:
    cnt += 1
    q = copy.deepcopy(nq)
    while q:
        curr = q.popleft()
        for m in moves:
            nx, ny = curr[0] + m[0], curr[1] + m[1]
            if nx < 0 or ny < 0 or nx > h - 1 or ny > w - 1:
                continue
            else:
                if not grid[nx][ny]:
                    nq.append([nx, ny])
                    grid[nx][ny] = True

print(cnt)

### FIXED CODE ###

import copy
from collections import deque

h, w = map(int, input().split())
grid = [list(map(lambda x: x == "#", input().rstrip())) for _ in range(h)]

q = deque([])
for i in range(h):
    for j in range(w):
        if grid[i][j]:
            q.append([i, j, 0])

moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

ans = 0
while q:
    curr = q.popleft()
    ans = max(ans, curr[2])
    for m in moves:
        nx, ny = curr[0] + m[0], curr[1] + m[1]
        if nx < 0 or ny < 0 or nx > h - 1 or ny > w - 1 or grid[nx][ny]:
            continue
        else:
            q.append([nx, ny, curr[2] + 1])
            grid[nx][ny] = True

print(ans)
### BUGGY CODE ###

N = int(input())

A=[]
for i in range(N):
    A.append(int(input()))

B = []
for i in range(2**N):
    gokei = 0
    for j in range(N):
        if ((i >> j) & 1):
            gokei += A[j]
    B.append(gokei)

B.sort(reverse=True)

for i in B:
    if i%10 != 0:
        print(i)
        break
else:
    print(0)

### FIXED CODE ###

N = int(input())

A=[]
for i in range(N):
    A.append(int(input()))

A.sort()

gokei = sum(A)

if gokei%10 != 0:
    print(gokei)
else:
    for i in range(N):
        if (gokei - A[i])%10 != 0:
            print(gokei - A[i])
            break
    else:
        print(0)
### BUGGY CODE ###

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

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

k=int(input())
s=input()
lens=len(s)
mod=10**9+7
ans=0

dp=[0 for i in range(1+len(s)+k)]
dp[0]=1

import math
def  mcal(n,r):
    return math.factorial(n)//math.factorial(n-r)//math.factorial(r)


l={i:1 for i in range(lens+10)}
for i in range(lens+1,lens+k+2):
    l[i]=l[i-1]*i//(i-lens)

now=1

for i in range(k+1):
    ans+=pow(25,i,mod)*pow(26,k-i,mod)*cmb(lens+i-1,lens-1,mod)
    ans=ans%mod

print(ans)

### FIXED CODE ###

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

p = 10 ** 9 + 7
N = 2 * 10 ** 6 + 10 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

k=int(input())
s=input()
lens=len(s)
mod=10**9+7
ans=0

now=1

for i in range(k+1):
    ans+=pow(25,i,mod)*pow(26,k-i,mod)*cmb(lens+i-1,lens-1,mod)
    ans=ans%mod

print(ans)
### BUGGY CODE ###

S = input()

mod = 10**9+7
A = 0
AB = 0
ABC = 0
cnt = 0
for i in range(len(S)):
    if S[i] == "A":
        A += 3**cnt
    elif S[i] == "B":
        AB += A
    elif S[i] == "C":
        ABC += AB
    else:
        ABC = (3*ABC + AB) % mod
        AB = (3*AB + A) % mod
        A = (3*A + 3**cnt) % mod
        cnt += 1
        
        
print(ABC%mod)

### FIXED CODE ###

S = input()

mod = 10**9+7
A = 0
AB = 0
ABC = 0
cnt = 0
for i in range(len(S)):
    if S[i] == "A":
        A += pow(3, cnt, mod)
        A %= mod
    elif S[i] == "B":
        AB += A
        AB %= mod
    elif S[i] == "C":
        ABC += AB
        ABC %= mod
    else:
        ABC = (3*ABC + AB) % mod
        AB = (3*AB + A) % mod
        A = (3*A + pow(3, cnt, mod)) % mod
        cnt += 1
        
        
print(ABC)
### BUGGY CODE ###

s = input().split(" ")
s = [int(i) for i in s]
A = s[0]
B = s[1]
K = s[2]


for i , s in enumerate(range(A , B + 1) ):
    if (i < K) or (i > (B-A-K)) :
        print(s)
    

### FIXED CODE ###

s = input().split(" ")
s = [int(i) for i in s]
A = s[0]
B = s[1]
K = s[2]

dic = {}
for i in range(K) : 
    if A+i <= B : 
        print(A + i)
        dic[A+i] = True

for i in reversed(range(K)):
    if B-i >= A:
        if not (B-i in dic):
            print(B-i)
### BUGGY CODE ###

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

m = [0]*(10**6 + 1)

for i in a:
    if m[i] == 1:
        m[i] = 2
        continue
    tmp = i 
    for j in range(i,10**6+1,i):
        m[j]+=1
ans = 0
for i in a:
    if m[i] == 1:
        ans += 1
print(ans)

### FIXED CODE ###

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

ma = max(a)
m = [0]*(ma + 1)

for i in a:
    if m[i] == 1:
        m[i] = 2
        continue
    for j in range(i,ma+1,i):
        m[j]+=1
ans = 0
for i in a:
    if m[i] == 1:
        ans += 1
print(ans)
### BUGGY CODE ###

ans=1
for i in range(1,int(input())+1):
  ans*=i
print(ans%(10**9+7))

### FIXED CODE ###

ans=1
a=[i for i in range(1,int(input())+1)]
for i in a:
  ans*=i
  ans%=10**9+7
print(ans)
### BUGGY CODE ###


S = list(input())
Q = int(input())

tmplist = []
T = 0
for i in range(Q):
    Query = list(input().split())
    if len(Query) == 1:
        T = T+1
    else:
        if T%2 == 0:
            if Query[1] == '1':
                S.insert(0,Query[2])
            else:
                S.append(Query[2])
        else:
            if Query[1] == '2':
                S.insert(0,Query[2])
            else:
                S.append(Query[2])
#    print("len(Query)={}, Query={}, T={}, S={}".format(len(Query), Query,T,''.join(S)))

if T%2 == 1:
    S.reverse()

#print("ans={}".format(''.join(S)))
print(''.join(S))


### FIXED CODE ###

# キューを使ったアプローチ

from collections import deque

S = deque(input())
Q = int(input())

T = 0
for _ in range(Q):
    Query = list(input().split())
    if len(Query) == 1:
        T ^= 1
    elif T == 0:
        m = Query[2]
        if Query[1] == '1':
            S.appendleft(m)
        else:
            S.append(m)
    else:
        m = Query[2]
        if Query[1] == '2':
            S.appendleft(m)
        else:
            S.append(m)

if T==1:
    S.reverse()

print(''.join(S))
### BUGGY CODE ###

def main():
    n = int(input())
    A = [int(x) for x in input().split()]

    m = 0
    B = [0 for _ in range(n)]

    for i in range(n//2+1, n):
        if A[i] == 1: B[i] = 1

    for i in range(n//2, -1, -1):
        count = 0
        for j in range(n-1, -1, -1):
            if B[j] == 1: count += 1
        if count % 2 != A[i]:
            added = False
            for j in range(n):
                if (j+1) % (i+1) == 0 and B[j] == 0:
                    B[j] = 1
                    added = True
                    break
            if not added:
                return -1, -1

    output = []
    for i in range(n):
        if B[i] == 1:
            output.append(i+1)
    return len(output), output

if __name__ == '__main__':
    m, output = main()
    if m == -1: print(str(m))
    else:
        print(str(m))
        if m > 0:
            print(' '.join(map(str, output)))

### FIXED CODE ###

# from other person's code
n = int(input())
a = list(map(int, input().split()))
ls = [0]*(n+1)
ans = []
for i in reversed(list(range(n))):
    if sum(ls[::i+1][1:]) % 2 != a[i]:
        ls[i+1] = 1
        ans.append(i+1)
print(sum(ls))
if ans: print(' '.join(map(str, ans)))
### BUGGY CODE ###

A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100

max_solvent = 0
max_solute = 0
max_strength = 0.0

for na in range(0, 31):
    for nb in range(0, 31):
        for nc in range(0, 100):
            for nd in range(0, 100):

                solute = nc * C + nd * D
                solvent = na * A + nb * B

                if not (any([na, nb]) and any([nc, nd])):
                    continue

                if (solute + solvent) > F:
                    # print("exceeded")
                    continue

                if (solvent/100) * E < solute:
                    # print("exceeded2")
                    continue

                strength = float(solute) / (solute + solvent)
                # print(strength, solvent+solute, solute)

                if max_strength < strength:
                    max_strength = strength
                    max_solute = solute
                    max_solvent = solute + solvent

print(max_solvent, max_solute)

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
# A *= 100
# B *= 100

max_solvent = 0
max_solute = 0
max_strength = 0.0

for na in range(0, 31):
    for nb in range(0, 31):
        for nc in range(0, 101):
            for nd in range(0, 101):

                solute = nc * C + nd * D
                solvent = 100 * na * A + 100 * nb * B

                # if not (any([na, nb]) and any([nc, nd])):
                    # continue
                if solvent == 0:
                    break

                if solute + solvent > F:
                    # print("exceeded")
                    break

                else:
                    # if (solvent/100) * E < solute:
                    if solvent/100 * E >= solute:
                    # print("exceeded2")
                    # break
                        strength = 100 * solute / (solute + solvent)
                        # print(strength, solvent+solute, solute)
                        if max_strength <= strength:
                            max_strength = strength
                            max_solute = solute
                            max_solvent = solute + solvent

print(max_solvent, max_solute)
### BUGGY CODE ###

K, S = map(int , input().strip().split(" "))


count = 0
for x in range(K+1):
    if x > S:
        continue
    for y in range(K+1):
        if x + y > S:
            continue
        for z in range(K+1):
            if x + y + z > S:
                continue
            elif x + y + z == S:
                count +=1
print(count)


### FIXED CODE ###

K, S = map(int , input().strip().split(" "))


count = 0
for x in range(K+1):
    if x > S :
        break
    elif S - x > 2*K:
        continue
    for y in range(K+1):
        if x + y > S:
            break
        elif S - (x+y) > K:
            continue
        count+= 1
print(count)
### BUGGY CODE ###

#%%
import time

start = time.time()

import numpy as np

N = int(input())
A = [0] * N
B = [0] * N
C = [[] for _ in range(N) ]
takahashi = 0
aoki = 0
for i in range(N):
  A[i], B[i] = map(int,input().split())
  C[i].append(i)
  C[i].append((np.array(A) + np.array(B))[i])

elapsed_time = time.time() - start
#print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
start = time.time()

C = sorted(C, key=lambda x:x[1])


elapsed_time = time.time() - start
#print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
start = time.time()

while len(C) > 0:
  tmp_max = C[-1][0]
  takahashi += A[tmp_max]
  A.pop(tmp_max)
  B.pop(tmp_max)
  C.pop(tmp_max)

  if len(C)>0 :
    tmp_max = C[-1][0]
    aoki += B[tmp_max]
    A.pop(tmp_max)
    B.pop(tmp_max)
    C.pop(tmp_max)

print(takahashi-aoki)

elapsed_time = time.time() - start
#print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")





### FIXED CODE ###

#%%
import time

import numpy as np

N = int(input())
A = [0] * N
B = [0] * N
C = [[] for _ in range(N) ]
takahashi = []
aoki = []

start = time.time()

for i in range(N):
  A[i], B[i] = map(int,input().split())


D = np.array(A) + np.array(B)
for i in range(N):
  C[i] = [i, D[i]]


elapsed_time = time.time() - start
#print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
start = time.time()

C = sorted(C, key=lambda x:x[1])


elapsed_time = time.time() - start
#print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
start = time.time()


if N %2 == 0 :
  for i in range(1,N,2):
    tmp_max = C[-i][0]
    takahashi.append(A[tmp_max])
    tmp_max = C[-i-1][0]
    aoki.append(B[tmp_max])

elif N %2 != 0 :
  for i in range(1,N-1,2):
    tmp_max = C[-i][0]
    takahashi.append(A[tmp_max])
    tmp_max = C[-i-1][0]
    aoki.append(B[tmp_max])
  tmp_max = C[-N][0]
  takahashi.append(A[tmp_max])

print(sum(takahashi)-sum(aoki))

elapsed_time = time.time() - start
#print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
### BUGGY CODE ###

import math

a, b = map(int, input().split())
cd = set()
ans = 0

for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        cd.add(i)

for s in cd:
    if s == 1:
        ans += 1
    else:
        for t in range(2, int(math.sqrt(s)) + 1):
            if s % t == 0:
                break
        else:
            ans += 1

print(ans)


### FIXED CODE ###

import math
from fractions import gcd

a, b = map(int, input().split())
cd = set()
ans = set()

'''
g = gcd(a, b)

for i in range(1, g+1):
    if a % i == 0 and b % i == 0:
        cd.add(i)
        '''

i =  1
a_set = set()

for i in range(1, int(math.sqrt(a)) + 1):
    if a % i == 0:
        a_set.add(i)
        a_set.add(a // i)
    i += 1

i = 1
b_set = set()

for i in range(1, int(math.sqrt(b)) + 1):
    if b % i == 0:
        b_set.add(i)
        b_set.add(b // i)
    i += 1

cd = set(a_set) & set(b_set)

for s in sorted(list(cd)):
    if s == 1:
        ans.add(s)
    else:
        for t in sorted(list(ans)):
            if t == 1:
                continue
            elif s % t == 0:
                break
        else:
            ans.add(s)

print(len(ans))
### BUGGY CODE ###

def main():
    n,k = map(int, input().split())
    town = list(map(int, input().split()))
    dic = {}
    for i,t in enumerate(town):
        dic[i+1] = t
    set_t = set()
    list_t = []
    current = 1
    is_loop = False
    counter = {}
    for i in range(k):
        current = dic[current]
        set_t.add(current)
        list_t.append(current)
        if len(list(set_t)) != len(list_t):
            loop_start = counter[list_t[-1]]
            is_loop = True
            break
        counter[current] = i
    if not is_loop:
        print(list_t[-1])
    else:
        loop_list = list_t[loop_start:-1]
        am = (k-i) % len(loop_list)
        print(loop_list[am-1])

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n,k = map(int, input().split())
    town = list(map(int, input().split()))
    town = [i-1 for i in town]
    visited = [-1] * n
    current_town = 0
    current_order = 0
    memo = []
    while visited[current_town] == -1:
        visited[current_town] = current_order
        memo.append(current_town)
        current_town = town[current_town]
        current_order += 1
    loop_start = visited[current_town]
    if k < len(memo):
        print(memo[k]+1)
    else:
        loop_length = len(memo) - loop_start
        k =  (k - loop_start) % loop_length
        print(memo[k+loop_start]+1)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

# F
import numpy as np
from collections import deque
 
TT_list = []
# input
N, L = map(int, input().split())
T = 0.0
vt_now = 0.0
v_now = 0
que = deque()

for i in range(N):
    ti, v = map(int, input().split())
    t = float(ti)
    v_now += v
    vt_now += v*t
    # add
    if v == L:
        que.append([t, v])
    else:
        while v < L and len(que) > 0:
            t_, v_ = que[-1]
            if t_ <= t:
                que.append([t, v])
                break
            elif v + v_ >= L:
                v_ = v + v_ - L
                t = ((L - v) * t_ + v * t) / L
                v = L
                que = deque([[t, v]])
                v_now = L
                vt_now = t*L
                # break
            else:
                t = (t*v + t_*v_) / (v + v_)
                v = v + v_
                que.pop()
    # minus
    while v_now > L:
        if que[0][1] <= v_now - L:
            v_now -= que[0][1]
            vt_now -= que[0][1]*que[0][0]
            que.popleft()
        else:
            que[0][1] -= v_now - L
            vt_now -= (v_now - L)*que[0][0]
            v_now = L
            
    TT_list.append(vt_now / L)

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


### FIXED CODE ###

# F
from collections import deque
 
TT_list = []
# input
N, L = map(int, input().split())
T = 0.0
vt_now = 0.0
v_now = 0
que = deque()

for i in range(N):
    ti, v = map(int, input().split())
    t = float(ti)
    v_now += v
    vt_now += v*t
    # add
    if v == L:
        que.append([t, v])
    else:
        while v < L and len(que) > 0:
            t_, v_ = que[-1]
            if t_ <= t:
                que.append([t, v])
                break
            elif v + v_ >= L:
                v_ = v + v_ - L
                t = ((L - v) * t_ + v * t) / L
                v = L
                que = deque([[t, v]])
                v_now = L
                vt_now = t*L
                # break
            else:
                t = (t*v + t_*v_) / (v + v_)
                v = v + v_
                que.pop()
    # minus
    while v_now > L:
        if que[0][1] <= v_now - L:
            v_now -= que[0][1]
            vt_now -= que[0][1]*que[0][0]
            que.popleft()
        else:
            que[0][1] -= v_now - L
            vt_now -= (v_now - L)*que[0][0]
            v_now = L
            
    TT_list.append(vt_now / L)

for i in range(N):
    print(TT_list[i])
### BUGGY CODE ###

from collections import deque
n, m = map(int, input().split())
q = deque()
t = {i: set() for i in range(1, n + 1)}
v = [0] * n
p = [0] * n

for _ in range(m):
    a, b = map(int, input().split())
    t[a].add(b)
    t[b].add(a)

v[0] = 1
for i in t[1]:
    p[i - 1] = 1
    q.append(i)
while q:
    next = q.popleft()
    v[next -1] = 1
    for i in t[next]:
        if v[i - 1] == 0 and i not in q:
            q.append(i)
            p[i - 1] = next
print('Yes')
print(*p[1:], sep='\n')

### FIXED CODE ###

from collections import deque
n, m = map(int, input().split())
q = deque()
t = {i: set() for i in range(1, n + 1)}
v = [-1] * n

for _ in range(m):
    a, b = map(int, input().split())
    t[a].add(b)
    t[b].add(a)
q.append(1)
v[0] = 1
while q:
    next = q.popleft()
    for i in t[next]:
        if v[i - 1] == -1:
            q.append(i)
            v[i - 1] = next
print('Yes')
print(*v[1:], sep='\n')