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

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

a.insert(0, 0)
b.insert(0, 0)

for i in range(n+1):
    if sum(a[0:i+1]) > k:
        break
    for j in range(m+1):
        if sum(a[0:i+1]) + sum(b[0:j+1]) > k:
            break
        if sum(a[0:i+1]) + sum(b[0:j+1]) <= k and i + j > ans:
            ans = i + j

print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
amax = 0
samax = 0

for i in range(n):
    if samax + a[i]<=k:
        amax += 1
        samax += a[i]
    else:
        break
        
book = amax
ans = book
samax = sum(a[0:amax])
sbmax = 0

for j in range(m):
    sbmax += b[j]
    while samax + sbmax > k and amax >= 1:
        amax -= 1
        samax = samax - a[amax]
        book -= 1
    if samax + sbmax <= k:
        book += 1
        if book > ans:
            ans = book
    else:
        break

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

(N, K) = map(lambda a: int(a), input().split())
A = list(map(lambda a: int(a), input().split()))

for _ in range(0, K):
    B = [0 for _ in range(N)]

    for i in range(0,N):
        f = max(0, i - A[i])
        t = min(N-1, i + A[i])
        #for j in range(max(0, f), min(N, t)+1):
        #    B[j] += 1
        B[f] += 1
        if t+1 < N:
            B[t+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    if A == B:
        break
    A = B
    i += 1
    
print(" ".join(map(lambda a: str(a), A)))

### FIXED CODE ###

import numpy as np
from numba import njit

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

@njit
def solve(N,K,A):
    for j in range(0, K):
        B = np.zeros(N, dtype=np.int64)

        for i in range(0,N):
            f = max(0, i - A[i])
            t = min(N-1, i + A[i])
            #for j in range(max(0, f), min(N, t)+1):
            #    B[j] += 1
            B[f] += 1
            if t+1 < N:
                B[t+1] -= 1
        A = np.cumsum(B)
        if np.all(A == N):
            return A
        i += 1
    return A
    

print(" ".join(map(str, solve(N,K,A))))
### BUGGY CODE ###

from functools import reduce
from collections import Counter


def f2nom(f):
    return reduce(lambda x, y: x * (y + 1), f, 1)


def sp(n):
    p = [2]
    *t, = range(3, n + 1, 2)
    for i, _ in enumerate(t):
        if not t[i]:
            continue
        p.append(t[i])
        for j in range(i, len(t), t[i]):
            t[j] = 0
    return p


def solve(string):
    n = int(string)
    ps = sp(int(n))
    t = [0] * (n + 1)
    for p in ps:
        if p <= n:
            t[p] = [p]
    ans = 1
    for i in range(2, n + 1):
        ans += i * f2nom(Counter(t[i]).values())
        for p in ps:
            if i * p > n:
                break
            t[i * p] = t[i][:]
            t[i * p].append(p)
    return str(ans)


def _solve(string):
    n = int(string)
    ans = 0
    for i in range(1, n + 1):
        c = 0
        for j in range(1, int(i**0.5) + 1):
            if i % j == 0:
                c += 2
        if i**0.5 == int(i**0.5):
            c -= 1
        ans += i * c
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


### FIXED CODE ###

def solve(string):
    n = int(string)
    return str(sum(i * (n // i) * (n // i + 1) // 2 for i in range(1, n + 1)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
### BUGGY CODE ###

S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
for i in range(Qlen):
    if int(Query[i][0]) == 1:
        Slist= Slist[::-1]
    else:
        if int(Query[i][1]) == 1:
            Slist = [Query[i][2]] + Slist
        else:
            Slist = Slist + [Query[i][2]]
print("".join(Slist))

### FIXED CODE ###

S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []

for idx, value in enumerate(Query):
    if value[0] == "1":
        reverse ^= True
        head, back = back, head
    else:
        if value[1] == "1":
            head += [value[2]]
        else:
            back += [value[2]]

if reverse == False:
    head.reverse()
    print("".join(head + Slist + back))
else:
    head.reverse()
    print("".join(head + Slist[::-1] + back))
### BUGGY CODE ###

N = input()
S = input()
step = 1
ans = 0
for i in range(10):
    for i2 in range(10):
        for i3 in range(10):
            step = 1
            for i4 in range(len(S)):
                if step == 1:
                    if S[i4] == str(i):
                        step += 1
                elif step == 2:
                    if S[i4] == str(i2):
                        step += 1
                elif step == 3:
                    if S[i4] == str(i3):
                        ans += 1
                        break
print(ans)

### FIXED CODE ###

def Meg_nib(ng,border,lists):
    ng = -1
    ok = len(lists) - 1
    if len(lists) == 0 or border >= lists[ok]:
        return -1
    while(abs(ng - ok) > 1):
        mid = (ok + ng) // 2
        if lists[mid] > border:
            ok = mid
        else:
            ng = mid
    return lists[ok]

N = input()
S = input()
ans = 0
k = 0
k2 = 0
k3 = 0
find = [[]for _ in range(10)]
for i in range(len(S)):
    find[int(S[i])].append(i)
for i in range(10):
    for i2 in range(10):
        for i3 in range(10):
            k = Meg_nib(0,-1,find[i])
            if k == -1:
                break
            k2 = Meg_nib(0,k,find[i2])
            if k2 == -1:
                break
            k3 = Meg_nib(0,k2,find[i3])
            if k3 != -1:
                ans += 1
print(ans)
### BUGGY CODE ###

#D問題
NM=40
ABM=10

N,M1,M2=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(N):
    a,b,c=map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
amax,bmax,cmax,=max(A),max(B),max(C)
dp=[[[N*cmax for broop in range(NM*ABM+1)] for aroop in range(NM*ABM+1)] for nroop in range(NM+1)]
dp[0][0][0]=0
for i in range(N):
    for cb in range(NM*ABM):
        for ca in range(NM*ABM):
            dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb])
            if ca+A[i]<NM*ABM and cb+B[i]<NM*ABM:
                dp[i+1][ca+A[i]][cb+B[i]]=min(dp[i+1][ca+A[i]][cb+B[i]],dp[i][ca][cb]+C[i])

ans=N*cmax
for cb in range(NM*ABM):
    CB=cb+1
    for ca in range(NM*ABM):
        CA=ca+1
        if ca*M2 == cb*M1:
            ans=min(ans,dp[N][CA][CB])

if ans == N*cmax:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

#D問題
NM=40
ABM=10
MM=400

N,M1,M2=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(N):
    a,b,c=map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
cmax=max(C)
CM=N*cmax+10
dp=[[[CM for broop in range(401)] for aroop in range(401)] for nroop in range(N+1)]
dp[0][0][0]=0
for i in range(N):
    for cb in range(401):
        for ca in range(401):
            if dp[i][ca][cb]==CM:
                continue
            dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb])
            if ca+A[i]<401 and cb+B[i]<401:
                dp[i+1][ca+A[i]][cb+B[i]]=min(dp[i+1][ca+A[i]][cb+B[i]],dp[i][ca][cb]+C[i])

ans=CM
for cb in range(400):
    for ca in range(400):
        CB=cb+1
        CA=ca+1
        if CA*M2 == CB*M1:
            ans=min(ans,dp[N][CA][CB])

if ans == CM:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

n,m = map(int,input().split())
L = []
R = []
for i in range(m):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
ans = 0
for i in range(n+1):
    count = 0
    for j in range(m):
        if i>=L[j] and i <=R[j]:
            count+=1
        if count==m:
            ans +=1
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
L = []
R = []
for i in range(m):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
L.sort(reverse=True)
R.sort()
ans =0
for i in range(n+1):
    if i >=L[0] and i <=R[0]:
        ans +=1
print(ans)
### BUGGY CODE ###

import numpy as np
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
m2 = [1 for i in range(60)]
for i in range(1,60):
    m2[i] = (m2[i-1]*2)%mod

n1 = np.zeros(60,dtype=int)
for i in a:
    sai = [int(i) for i in str(format(i,'060b'))]
    n1 += sai

ans = 0
for i in range(60):
    ans = (ans+((n1[i]*(n-n1[i]))%mod*m2[59-i])%mod)%mod

print(ans)


### FIXED CODE ###

#https://atcoder.jp/contests/abc147/submissions/12994515を見た

import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
mod = 10**9+7
m2 = [1 for i in range(60)]
for i in range(1,60):
    m2[i] = (m2[i-1]*2)%mod

ans = 0
for i in range(60):
    ni = np.count_nonzero(a&1)
    ans = (ans+ni*(n-ni)%mod*m2[i])%mod
    a >>= 1

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

S = list(input())
T = []
for i in range(len(S)):
    T.append((int("".join(S[i:])))%2019)

ans = 0
for i in range(len(T)):
    if T[i] == 0:
        ans += 1
print(ans + len(T)-len(set(T)))

### FIXED CODE ###

from collections import Counter

S = list(input())
T = [int(S[len(S)-1])]
k = int(S[len(S)-1])
for i in range(len(S)-2,-1,-1):
    k = (int(S[i])*pow(10,len(S)-i-1,2019) + k ) % 2019
    T.append(k)

A = Counter(T)
ans = 0
ans += A.get(0,0)
for i in A.values():
    ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

def solve_145e():
    from collections import namedtuple
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Food = namedtuple('Food', 'time_to_eat deliciousness')
    INF = 3000 * 3000 + 1

    N, T = map(int, input().split())
    foods = []
    for _ in range(N):
        row = map(int, input().split())
        foods.append(Food(*row))
    foods.sort(key=attrgetter('time_to_eat'))
    # 同じ料理の組を食べるなら時間のかかるものを後回しにしても結果は悪くならない

    dp = [-INF] * T
    dp[0] = 0
    # dp[time]:=timeに食べ終わる注文の仕方で得られる最大満足度

    ma = 0  # 回答候補
    ca = 0  # フィニッシュ前候補
    for food in foods:
        # これでフィニッシュの場合
        ma = max(ma, ca + food.deliciousness)

        # まだ食べる場合
        for time in reversed(range(T - food.time_to_eat)):
            when_eat = dp[time] + food.deliciousness
            if dp[time + food.time_to_eat] < when_eat:
                dp[time + food.time_to_eat] = when_eat
                ca = max(ca, when_eat)

    print(ma)
    return


if __name__ == '__main__':
    solve_145e()


### FIXED CODE ###

def solve():
    from collections import namedtuple
    import sys

    input = sys.stdin.readline
    Dish = namedtuple('Dish', 'idx cost pt')

    n, t = map(int, input().split())
    dishes = []
    for idx in range(1, n + 1):
        cost, pt = map(int, input().split())
        dishes.append(Dish(idx=idx, cost=cost, pt=pt))

    dp_ht = [[0] * t for _ in range(n + 2)]  # head->tail
    dp_th = [[0] * t for _ in range(n + 2)]  # tail->head
    # dp[注文可能な範囲の端][完食にかかる総時間]:= 美味しさの最大値

    for dish in dishes:
        for cost_ in range(t):
            if cost_ >= dish.cost:
                dp_ht[dish.idx][cost_] = max(dp_ht[dish.idx - 1][cost_],
                                             dp_ht[dish.idx - 1][cost_ - dish.cost] + dish.pt)
            else:
                dp_ht[dish.idx][cost_] = dp_ht[dish.idx - 1][cost_]

    for dish in reversed(dishes):
        for cost_ in range(t):
            if cost_ >= dish.cost:
                dp_th[dish.idx][cost_] = max(dp_th[dish.idx + 1][cost_],
                                             dp_th[dish.idx + 1][cost_ - dish.cost] + dish.pt)
            else:
                dp_th[dish.idx][cost_] = dp_th[dish.idx + 1][cost_]

    ret = 0
    for last_dish in dishes:
        for cost_ in range(t):
            ret = max(ret, dp_ht[last_dish.idx - 1][cost_] + dp_th[last_dish.idx + 1][t - 1 - cost_] + last_dish.pt)
    return ret


print(solve())
### BUGGY CODE ###

import sys
INF = 10**18
sys.setrecursionlimit(10**6)
from collections import defaultdict
def li():
    return [int(x) for x in input().split()]
from collections import deque

H, W = li()
Ch, Cw = li()
Dh, Dw = li()
S = [list(input()) for x in range(H)]

v = [(1,0), (0,1), (-1,0), (0,-1)]

def bfs():
    costmap = defaultdict(lambda : -1)
    costmap[Cw, Ch] = 0
    que = deque([])
    que.append((Cw, Ch))

    while que:
        # print(que)
        # 左から取り出す
        x, y = que.popleft()
        # 通常移動パターン
        for i in range(len(v)):
            nx = x + v[i][0]
            ny = y + v[i][1]
            # バリデーション
            if nx <= 0 or nx > W or ny <= 0 or ny > H:
                continue
            if S[ny-1][nx-1] != '.':
                continue
            # 初探索 or コストが下がる場合
            if costmap[nx, ny] == -1 or costmap[x, y] < costmap[nx, ny]:
                # コストゼロは左から
                que.appendleft((nx, ny))
                costmap[nx, ny] = costmap[x, y]
        # 特殊移動パターン
        for i in range(x-2, x+3):
            for j in range(y-2, y+3):
                nx, ny = i, j
                # バリデーション
                if nx <= 0 or nx > W or ny <= 0 or ny > H:
                    continue
                if S[ny-1][nx-1] != '.':
                    continue
                # 初探索 or コストが下がる場合
                if costmap[nx, ny] == -1 or costmap[x, y] < costmap[nx, ny]:
                    # コスト1は右から
                    que.append((nx, ny))
                    costmap[nx, ny] = costmap[x, y] + 1
    return costmap

costmap = bfs()
# print(costmap)
print(costmap[Dw, Dh])


### FIXED CODE ###

from collections import deque
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[list(input()) for i in range(h)]
 
#幅優先で解く。
dx=[1,0,-1,0]
dy=[0,1,0,-1]
def bfs():
  maze=[[-1]*w for i in range(h)]
  maze[ch-1][cw-1]=0
  qu=deque([])
  qu.append((cw-1,ch-1))
  magic=0
  
  while qu:
    x,y=qu.popleft()
    for i in range(4):
      nx=dx[i]+x
      ny=dy[i]+y
      if 0<=nx<=w-1 and 0<=ny<=h-1 and s[ny][nx]=="." and (maze[ny][nx]==-1 or maze[ny][nx]>maze[y][x]):
        qu.appendleft((nx,ny))
        maze[ny][nx]=maze[y][x]
    for i in range(x-2,x+3):
      for j in range(y-2,y+3):
        nx=i
        ny=j
        if 0<=nx<=w-1 and 0<=ny<=h-1 and s[ny][nx]=="." and (maze[ny][nx]==-1 or maze[ny][nx]>maze[y][x]+1):
          qu.append((nx,ny))
          maze[ny][nx]=maze[y][x]+1
  return maze
    
maze = bfs()
print(maze[dh-1][dw-1])
### BUGGY CODE ###

from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

c = Counter(s)
ans_number = c.most_common()[0][1]

s_max = []
for i in range(len(c)):
  if c.most_common()[i][1] == ans_number:
    s_max.append(c.most_common()[i][0])
  else:
    break;

s_max.sort()
for a in s_max:
  print(a)

### FIXED CODE ###

from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

c = Counter(s)
c = c.most_common()
ans_number = c[0][1]
c.sort()

for i in range(len(c)):
  if c[i][1] == ans_number:
    print(c[i][0])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 10
for i in range(1, len(a)):
    ans = min(ans, abs(sum(a[:i]) - sum(a[i:])))
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
L = sum(a)
l = 0
i = 0
while l < L / 2:
    l += a[i]
    i += 1
print(min(abs(sum(a[:i - 1]) - sum(a[i - 1:])), abs(sum(a[:i]) - sum(a[i:]))))
### BUGGY CODE ###

#input
X = int(input())

#output
import math
initial_num = 1
while initial_num**5 < X:
    initial_num += 1
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()
A = initial_num
C = A**5 -X

if C >= 0:
    B = pow(C, 1/5)
else:
    B = -pow(-C, 1/5)

while not is_integer(B):
    A -= 1
    C = A**5 - X
    if C >= 0:
        B = pow(C, 1/5)
    else:
        B = -pow(-C, 1/5)

print(A, int(B))

### FIXED CODE ###

#input
X = int(input())

#output
for a in range(200):
    for b in range(-200, 200):
        if a**5 - b**5 == X:
            print(a, b)
            exit()
### BUGGY CODE ###

r, g, b, n = map(int, input().split())
ans = 0
for i in range(0, n+1):
    for j in range(0, n-i+1):
        check = (n-(i*r + j*g))/b
        if check % 1 == 0 and check >= 0:
            ans += 1
print(ans)


### FIXED CODE ###

r, g, b, n = map(int, input().split())
ans = 0
for i in range(0, n+1):
    for j in range(0, n-i+1):
        check = (n-(i*r + j*g))/b
        if check % 1 == 0 and check >= 0:
            ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())
L = list( map( int, input().split() ) )
comb = [' '.join( str(n) for n in sorted( [L[a],L[b],L[c]] ) ) for a in range(N) for b in range(1+a,N) for c in range(1+b,N) if (L[a] + L[b] > L[c]) and (L[b] + L[c] > L[a]) and (L[c] + L[a] > L[b])]
print( len( set(comb) ) )

### FIXED CODE ###

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

import bisect
L=sorted(L)
comb = 0
for a in range(N-2):
    for b in range(1+a,N-1):
        posIndex = bisect.bisect_left(L, L[a] + L[b])
        comb += posIndex - b - 1 if posIndex != 0 else 0
print(comb)
### BUGGY CODE ###

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

if n == 1:
    print(p)
else:
    m = 1
    while m ** n <= p:
        m += 1
    for i in reversed(range(1, m + 1)):
        if p % (i ** n) == 0:
            print(i)
            break


### FIXED CODE ###

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

if n == 1:
    print(p)
else:
    m = int((p + 1) ** (1 / n))
    while m ** n > p:
        m -= 1
    for i in reversed(range(1, m + 1)):
        if p % (i ** n) == 0:
            print(i)
            break
### BUGGY CODE ###

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

ans = A[0]
for i in range(1, N):
    ans = ans * A[i]

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

### FIXED CODE ###

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

if 0 in A:
    print("0")
    f = 1
else:

    ans = A[0]
    for i in range(1, N):
        ans = ans * A[i]
        if ans > 10**18:
            print("-1")
            f = 1
            break

if f == 0:
    print(ans)
### BUGGY CODE ###


h,w=map(int,input().split())
s=[[]*w for i in range(h)]
for i in range(h):
    s[i]=list(input())

#h,w=4,6
#s=[['#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '.']]    

ww=[[0]*w for i in range(h)]
for i in range(h):
    jsum=0
    jst=0
    jed=0
    for j in range(w):
        if s[i][j]==".":
            jsum+=1
            jst=min(j,jst)
            jed=max(j,jed)
        else:
#            print(jsum,jst,jed)
            for jj in range(jst,jed+1):
                ww[i][jj]=jsum
            jsum=0
            jst=j+1
            jed=j+1
        if jst<w:
            for jj in range(jst,jed+1):
                ww[i][jj]=jsum
                
hh=[[0]*w for i in range(h)]
for j in range(w):
    isum=0
    ist=0
    ied=0
    for i in range(h):
        if s[i][j]==".":
            isum+=1
            ist=min(i,ist)
            ied=max(i,ied)
        else:
#            print(isum,ist,ied)
            for ii in range(ist,ied+1):
                hh[ii][j]=isum
            isum=0
            ist=i+1
            ied=i+1
        if ist<h:
            for ii in range(ist,ied+1):
                hh[ii][j]=isum
            
ijmax=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ijmax=max(ijmax,ww[i][j]+hh[i][j]-1)

print(ijmax)
                

### FIXED CODE ###

import sys
input = sys.stdin.readline

h,w=map(int,input().split())
s=[[] for i in range(h)]
for i in range(h):
    si=input()
    s[i]=si
"""
h,w=4,6
s=[['#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '.']]    
"""
ww=[[0]*w for i in range(h)]
#www=[[0]*w for i in range(h)]
www=[0]*w
for i in range(h):
    jsum=0
    jcnt=1
    jj=[0]*(w+1)
    for j in range(w):
        if s[i][j]==".":
#            www[i][j]=jcnt
            www[j]=jcnt
            if j<w-1 and s[i][j+1]=="#":
                jcnt+=1
            jsum+=1
        else:
#            print(jsum,jst,jed)
            if jsum!=0:
                jj[jcnt-1]=jsum
            jsum=0
    jcnt+=1
    jj[jcnt-1]=jsum
            
    for j in range(w):
        if s[i][j]==".":
#            ww[i][j]=jj[www[i][j]]
            ww[i][j]=jj[www[j]]
#    print(jj)
                
hh=[[0]*w for i in range(h)]
hhh=[0]*h
for j in range(w):
    isum=0
    icnt=1
    ii=[0]*(h+1)
    for i in range(h):
        if s[i][j]==".":
#            www[i][j]=jcnt
            hhh[i]=icnt
            if i<h-1 and s[i+1][j]=="#":
                icnt+=1
            isum+=1
        else:
#            print(jsum,jst,jed)
            if isum!=0:
                ii[icnt-1]=isum
            isum=0
    icnt+=1
    ii[icnt-1]=isum
            
    for i in range(h):
        if s[i][j]==".":
#            ww[i][j]=jj[www[i][j]]
            hh[i][j]=ii[hhh[i]]
#    print(jj)
            
ijmax=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ijmax=max(ijmax,ww[i][j]+hh[i][j]-1)

print(ijmax)
### BUGGY CODE ###

"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

n = int(input())
a = list(map(int,input().split()))
num = 1
for x in a:
    num*=x
if 10**18<num:
    print(-1)
else:
    print(num)


### FIXED CODE ###

"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print("0")
else:
    num = 1
    for x in range(n):
        num *= a[x]
        if 10**18 < num:
            num = -1
            break

    print(num)
### BUGGY CODE ###

n = int(input())
s = input()

rc = s.count('R')
gc = s.count('G')
bc = s.count('B')
ans = rc * gc * bc

for i in range(n-1):
  for j in range(i+1,n):
    k = j*2 - i
    if k >= n:
      continue
    if len(set([s[i],s[j],s[k]])) == 3:
      ans -= 1
      
print(ans)      

### FIXED CODE ###

n = int(input())
s = input()

rc = s.count('R')
gc = s.count('G')
bc = s.count('B')
ans = rc * gc * bc

for i in range(n-1):
  for j in range(i+1,n):
    k = j*2 - i
    if k >= n:
      continue
    if len(set([s[i],s[j],s[k]])) == 3:
      ans -= 1
      
print(ans)
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


xs,ys,xt,yt = list(map(int, input().split()))
n = int(input())
xyr = [None]*(n+2)
for i in range(n):
    xyr[i] = tuple(map(int, input().split()))
from itertools import product
ns = [[] for _ in range(n+2)]
s = n
t = n+1
xyr[s] = (xs,ys,0)
xyr[t] = (xt,yt,0)
for i,j in product(range(n+2), range(n+2)):
    if i!=j:
        d = max(0, ((xyr[i][0]-xyr[j][0])**2 + (xyr[i][1]-xyr[j][1])**2)**0.5 - (xyr[i][2]+xyr[j][2]))
        ns[i].append((d,j))
        ns[j].append((d,i))
def dijkstra(start):
    import heapq
    vals = [None] * (n+2)
    h = [(0, start)] # (距離, ノード番号)
    vals[start] = 0
    while h:
        val, u = heapq.heappop(h)
        for d, v in ns[u]:
            if vals[v] is None or vals[v]>val+d:
                vals[v] = val+d
                heapq.heappush(h, (vals[v], v))
    return vals
vals = dijkstra(s)
ans = vals[t]
print(ans)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


xs,ys,xt,yt = list(map(int, input().split()))
n = int(input())
xyr = [None]*(n+2)
for i in range(n):
    xyr[i] = tuple(map(int, input().split()))
from itertools import product
# ns = [[] for _ in range(n+2)]
data = []
rs = []
cs = []
s = n
t = n+1
xyr[s] = (xs,ys,0)
xyr[t] = (xt,yt,0)
for i,j in product(range(n+2), range(n+2)):
    if i<j:
        d = max(0, ((xyr[i][0]-xyr[j][0])**2 + (xyr[i][1]-xyr[j][1])**2)**0.5 - (xyr[i][2]+xyr[j][2]))
        data.append(d)
        rs.append(i)
        cs.append(j)
import scipy.sparse
m = scipy.sparse.csr_matrix((data, (rs, cs)), shape=(n+2, n+2))
ans = scipy.sparse.csgraph.dijkstra(m, indices=t, directed=False)
print(ans[s])