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

H, W = map(int, input().split())
MAP = [[] for _ in range(H)]
L = [[[] for h in range(W)] for _ in range(H)]
R = [[[] for h in range(W)] for _ in range(H)]
D = [[[] for h in range(W)] for _ in range(H)]
U = [[[] for h in range(W)] for _ in range(H)]
for i in range(H):
    MAP[i] = list(input())

for i in range(H):
    for j in range(W):
        if MAP[i][j] == "#":
            L[i][j] = 0
        elif j == 0:
            L[i][j] = 1
        else:
            L[i][j] = L[i][j - 1] + 1


for i in range(H):
    for j in reversed(range(W)):
        if MAP[i][j] == "#":
            R[i][j] = 0
        elif j == W - 1:
            R[i][j] = 1
        else:
            R[i][j] = R[i][j + 1] + 1

for j in range(W):
    for i in range(H):
        if MAP[i][j] == "#":
            U[i][j] = 0
        elif i == 0:
            U[i][j] = 1
        else:
            U[i][j] = U[i - 1][j] + 1

for j in range(W):
    for i in reversed(range(H)):
        if MAP[i][j] == "#":
            D[i][j] = 0
        elif i == H - 1:
            D[i][j] = 1
        else:
            D[i][j] = D[i + 1][j] + 1
result = 0
for i in range(H):
    for j in range(W):
        result = max(result, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)

print(result)


### FIXED CODE ###

H, W = map(int, input().split())
MAP = [list(input()) for _ in range(H)]
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if MAP[i][j] == "#":
            L[i][j] = 0
        elif j == 0:
            L[i][j] = 1
        else:
            L[i][j] = L[i] [j - 1] + 1

        if MAP[i][W - j - 1] == "#":
            R[i][W - j - 1] = 0
        elif j == 0:
            R[i][W - j - 1] = 1
        else:
            R[i][W - j - 1] = R[i][W - j] + 1

for j in range(W):
    for i in range(H):
        if MAP[i][j] == "#":
            U[i][j] = 0
        elif i == 0:
            U[i][j] = 1
        else:
            U[i][j] = U[i - 1][j] + 1

        if MAP[H - i - 1][j] == "#":
            D[H - i - 1][j] = 0
        elif i == 0:
            D[H - i - 1][j] = 1
        else:
            D[H - i - 1][j] = D[H - i][j] + 1
result = 0
for i in range(H):
    for j in range(W):
        result = max(result, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)

print(result)
### BUGGY CODE ###

def abs_result(x,y):
    tmp = abs(x-y)
    return tmp

def main():
    line = list(map(int,input().split()))
    n,k = line[0],line[1]
    
    # nを、nとkの差の絶対値で置き換える
    if n == 0 or k == 1:
        print(0)
        return
    
    com = 2
    for i in range(0,10**18):
        ans = abs_result(n,k)
        if ans == 0:
            print(0)
            return
        elif ans == 1:
            print(1)
            return
        if ans <= com:
            print(ans)
            return
        n = ans

main()

### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    t = n % k
    x = k - t
    if t < x:
        print(t)
    else:
        print(x)
main()
### BUGGY CODE ###

n, a, b = map(int, input().split())
x = 1
s = 0

for i in range(n):
    x = x * (n - i) // (i + 1)
    if i != a - 1 and i != b - 1:
        s = s + x

print(s %(10 ** 9 + 7) )


### FIXED CODE ###

n, a, b = map(int, input().split())
p = 1000000007

def remainder_of_combination(n, r, p):
    X = 1
    Y = 1
    
    for i in range(n - r +1, n + 1):
        X = X * i % p
    for i in range(1, r + 1):
        Y = Y * i % p
        
    return X * pow(Y, p-2, p)

ans = -1 + pow(2, n, p) - remainder_of_combination(n, a, p) - remainder_of_combination(n, b, p)

print(ans % p)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-
from sys import stdin

###########################################
# delete here

############################################
#from sys import stdin
import numpy as np

# read data for n sequences.
d = stdin.readline().split()
N = int(d[0])
Q = int(d[1])
data = str(stdin.readline().split()[0])

q = []
for _ in range(Q):
    q.append(stdin.readline().split())

count=0
right=[]
left=[]
for i,d in enumerate(q):
    if d[1]=='R':
        right.append([d[0], i])
    else:
        left.append([d[0], i])
        
#for i in data:
# それは捨てられるか、または最後にすてられる順番も記録。
# 捨てられるタイミングが最後に前の数字が捨てられる順番が前だったら続ける。
last=Q+1
count=0
for i in data:
    token=0
    for elm in reversed(left[:last]):
        if elm[0] == i and last>elm[1]:
           count+=1
           last=elm[1]
           token=1
           break
    if token==0:
        break
#print(count)
last=Q+1
    
for i in reversed(data):
    token=0
    for elm in reversed(right[:last]):
        if elm[0] == i and last>elm[1]:
           count+=1
           last=elm[1]
           token=1
           break
    if token==0:
        break    
print(N-count)


### FIXED CODE ###

# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-
from sys import stdin


############################################
#from sys import stdin
import numpy as np

# read data for n sequences.
d = stdin.readline().split()
N = int(d[0])
Q = int(d[1])
data = str(stdin.readline().split()[0])

q = []
for _ in range(Q):
    q.append(stdin.readline().split())

count=0

def leftsearch(N, q, data):
    x = 0 
    for spell in q:
        now = data[N]
        if now==spell[0]:
            if spell[1]=='R':
                N+=1
            else:
                N-=1
            if N < 0:
                x = 1
                break
            elif N==len(data):
                break
    return(x)
def rightsearch(N, q, data):
    x = 0    
    for spell in q:
        now = data[N]
        if now==spell[0]:
            if spell[1]=='R':
                N+=1
            else:
                N-=1
            if N >= len(data):
                x = 1
                break
            elif N == 0:
                break
    return(x)

# binary search
left = 0
right = len(data)-1
while(right >= left):
    mid = left + int((right - left)/2)
    if 1 == leftsearch(mid, q, data):
        left = mid + 1
    else:
        right = mid -1
#print("left:",mid)
if mid == 0: 
    if 0 == leftsearch(mid, q, data):
        leftamount = 0
    else:
        leftamount = 1
else:
    if 1 == leftsearch(mid, q, data):
        leftamount = mid+1
    else:
        leftamount = mid

# right binary
left = 0
right = len(data)-1
while(right >= left):
    mid = left + int((right - left)/2)
#    print(mid)
    if 1 == rightsearch(mid, q, data):
        right = mid -1
    else:
        left = mid + 1
#print("right:",mid)

#if mid == len(data)-1:
if 0 == rightsearch(mid, q, data):
    rightamount = 0
else:
    rightamount = 1

rightamount += len(data)-1 - mid

print(len(data) - (leftamount + rightamount))
### BUGGY CODE ###

import copy
import math
import collections

inf = (10 ** 9) + 7
n, m = map(int, input().split())
prime_list = []
m_copy = copy.deepcopy(m)
while (m_copy % 2 == 0):
    m_copy = int(m_copy // 2)
    prime_list.append(2)
for i in range(3, int(math.sqrt(m)) + 1, 2):
    while (m_copy % i == 0):
        m_copy = int(m_copy // i)
        prime_list.append(i)
if m_copy != 1:
    prime_list.append(m_copy)
k = collections.Counter(prime_list)
b = list(k.values())
ans = 1
for bb in b:
    ans *= math.factorial(bb + n - 1) % inf
    ans *= pow(math.factorial(bb), inf - 2, inf)
    ans *= pow(math.factorial(n - 1), inf - 2, inf)
    ans = ans % inf
print(ans)

### FIXED CODE ###

import copy
import math
import collections

inf = (10 ** 9) + 7
n, m = map(int, input().split())
prime_dict = {}
m_copy = copy.deepcopy(m)
while (m_copy % 2 == 0):
    m_copy = int(m_copy // 2)
    if 2 not in prime_dict.keys():
        prime_dict[2] = 1
    else:
        prime_dict[2] += 1
for i in range(3, int(math.sqrt(m)) + 1, 2):
    while (m_copy % i == 0):
        m_copy = int(m_copy // i)
        if i not in prime_dict.keys():
            prime_dict[i] = 1
        else:
            prime_dict[i] += 1
if m_copy != 1:
    if m_copy not in prime_dict.keys():
        prime_dict[m_copy] = 1
    else:
        prime_dict[m_copy] += 1
b = list(prime_dict.values())
ans = 1

dp = [[1 for _ in range(30)] for _ in range(n)]
for i in range(1, 30):
    for j in range(1,n):
        dp[j][i] = (dp[j - 1][i] + dp[j][i - 1]) % inf

for bb in b:
    ans *= dp[n - 1][bb]
    ans = ans % inf
print(ans)
### BUGGY CODE ###

import math
import fractions


def calc_lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a = list(map(lambda x: int(x)//2, input().split()))

    while True:
        odd_flag = 0
        even_flag = 0
        for i in range(len(a)):
            if a[i] % 2 == 0:
                a[i] = a[i] / 2
                even_flag = 1
            else:
                odd_flag = 1

        if odd_flag > 0 and even_flag > 0:
            print(0)
            exit()
        elif even_flag == 0:
            break
        elif odd_flag == 0:
            m = m // 2

    a = list(set(a))
    # print(a)

    lcm = a[0]
    for i in a:
        lcm = calc_lcm(lcm, i)

    # print(lcm)

    # print(m, lcm)
    print(math.ceil((m//lcm)/2))

### FIXED CODE ###

from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 7)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    # for j in a:
    #     if j % 2 != 0:
    #         print("0")

    # a = [i/2 for i in a]
    l = lcm_list(a)

    # if l == 0:
    #     print(0)
    #     exit()

    if (2 * m) < l:
        print("0")
        exit()

    i = l / 2

    for j in a:
        if i // (j // 2) % 2 == 0:
            print(0)
            exit()

    # if m < i:
    #     print("0")
    else:
        # print("1")
        print(int(((m - i) // l) + 1))
        # print(int((m // i + 1) // 2))
### BUGGY CODE ###

from collections import deque
 
def bfs():
  d = [0]*n
  que = deque([])
  que.append(0)
  d[0] = 1 #到達済み
  for i in range(10**10):
    if que == []:
      break
    now = que.popleft() 
    if d == [1]*n: #全て到達したら終わり
      break
    for next in g[now]: #部屋1から行ける場所で回す
      if d[next] == 0:
        que.append(next)
        d[next] = 1
        direction[next] = now +1
        
n,m = map(int,input().split())
g = [[] for i in range(n)]
direction = [0]*n
for i in range(m):
  a,b = map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
  
bfs()
print('Yes')
print(*direction[1:],sep='\n')

### FIXED CODE ###

from collections import deque
 
def bfs():
  que = deque([])
  que.append(0)
  
  while que:
    now = que.popleft()
    for next in g[now]: #部屋1から行ける場所で回す
      if d[next] == 0:
        que.append(next)
        d[next] = now +1
        
n,m = map(int,input().split())
g = [[] for i in range(n)]
d = [0]*n
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  g[a].append(b)
  g[b].append(a)
  
bfs()
print('Yes')
for i in range(1,n):
  print(d[i])
### BUGGY CODE ###

from collections import defaultdict
import sys
from functools import lru_cache

sys.setrecursionlimit(4100000)

@lru_cache(maxsize=None)
def f(x):
    if x == 0:
        return 0
    
    mod = x % (bin(x).count('1'))
    if mod == 0:
        return 1

    return f(mod) + 1


def main():
    N = int(input())
    X = input()
    O = int(X, 2)
    Y = list(X)
    ans = [0] * N
    pre = 1
    for i in range(N-1,-1,-1):
        if Y[i] == '1':
            tmp = O - pre
        else:
            tmp = O + pre
        ans[i] = f(tmp)
        pre *= 2

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


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from functools import lru_cache
 
sys.setrecursionlimit(4100000)
 
@lru_cache(maxsize=None)
def f(n):
    if n == 0:
        return 0

    return f(n % bin(n).count('1')) + 1

def main():
    N = int(input())
    X = list(input())
    pc = X.count('1')
    now = 0
    for i in range(N):
        if X[i] == '1':
            now += pow(2,N-i-1)

    ac = pc + 1
    dc = pc - 1
    ac_now = now % ac
    if dc:
        dc_now = now % dc
    for i in range(N):
        cnt = 0
        if X[i] == '1' and dc:
            tmp = (dc_now - pow(2, N-i-1, dc)) % dc
            cnt = 1 + f(tmp)
        elif X[i] == '0':
            tmp = (ac_now + pow(2, N-i-1, ac)) % ac
            cnt = 1 + f(tmp)

        print(cnt)



if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

N = int(input())
*A, = map(int, input().split())
C = [0]*4
for a in A:
    C[a] += 1

c1, c2, c3 = C[1:]
memo = [[[-1]*(301) for i in range(301)] for j in range(301)]
memo[0][0][0] = 0.
def dfs(a, b, c):
    if memo[a][b][c] != -1:
        return memo[a][b][c]
    r = 0
    if a:
        r += a*(dfs(a-1, b, c)+1)
    if b:
        r += b*(dfs(a+1, b-1, c)+1)
    if c:
        r += c*(dfs(a, b+1, c-1)+1)
    p = (a + b + c)
    memo[a][b][c] = r = (r + N - p) / p
    return r

print("%.10f" % dfs(c1, c2, c3))

### FIXED CODE ###

N = int(input())
*A, = map(int, input().split())
C = [0]*4
for a in A:
    C[a] += 1

c1, c2, c3 = C[1:]
dp = [[[0]*(c1+c2+c3+1) for i in range(c2+c3+2)] for j in range(c3+2)]
for c in range(c3+1):
    M1 = c2+c3-c
    T = dp[c-1]
    S = dp[c]
    for b in range(M1+1):
        M2 = N-b-c
        X = S[b-1]; Y = S[b]
        Z = T[b+1]
        for a in range(M2==N, M2+1):
            r = N
            if a:
                r += a*Y[a-1]
            if b:
                r += b*X[a+1]
            if c:
                r += c*Z[a]
            Y[a] = r / (a+b+c)
print("%.10f" % dp[c3][c2][c1])
### BUGGY CODE ###

import heapq

n, m, s, t = map(int, input().split())

root1 = []
for i in range(n):
    root1.append({})
root2 = []
for i in range(n):
    root2.append({})
   
for i in range(m):
    u, v, a, b = map(int, input().split())
    root1[u - 1][v] = a
    root1[v - 1][u] = a
    root2[u - 1][v] = b
    root2[v - 1][u] = b

def min_cost(root, start):
    S = [[0, start]]
    heapq.heapify(S)
    D = [float("inf")] * n
    D[start - 1] = 0
    while len(S) > 0:
        cost, site = heapq.heappop(S)
        if D[site - 1] > cost:
            D[site - 1] = cost
        for site2, cost2 in root[site - 1].items():
            if D[site2 - 1] > cost + cost2:
                heapq.heappush(S, [cost + cost2, site2])
    return D

jpy = min_cost(root1, s)
snuke = min_cost(root2, t)
cost = [jpy[i] + snuke[i] for i in range(n)]

for i in range(n):
    print(10 ** 15 - min(cost[i:]))

### FIXED CODE ###

import heapq

n, m, s, t = map(int, input().split())

root1 = []
for i in range(n):
    root1.append({})
root2 = []
for i in range(n):
    root2.append({})
   
for i in range(m):
    u, v, a, b = map(int, input().split())
    root1[u - 1][v] = a
    root1[v - 1][u] = a
    root2[u - 1][v] = b
    root2[v - 1][u] = b

def min_cost(root, start): # 経路の端点を１つ指定して任意の点への最小コストを計算
    S = [[0, start]]
    heapq.heapify(S)
    D = [float("inf")] * n
    D[start - 1] = 0
    while len(S) > 0:
        cost, site = heapq.heappop(S)
        if D[site - 1] < cost:
            continue
        for site2, cost2 in root[site - 1].items():
            if D[site2 - 1] > cost + cost2:
                D[site2 - 1] = cost + cost2
                heapq.heappush(S, [cost + cost2, site2])
    return D

jpy = min_cost(root1, s) # 円で両替地点まで移動する最小コスト
snuke = min_cost(root2, t) # 両替地点からスヌークで移動する最小コスト
cost = [jpy[i] + snuke[i] for i in range(n)] # 両替地点についてループ

minimum_cost = []
temp_min = cost[n - 1]
for i in reversed(range(n)):
    temp_min = min(temp_min, cost[i])
    minimum_cost.append(temp_min)

for i in reversed(range(n)):
    print(10 ** 15 - minimum_cost[i])
### BUGGY CODE ###

R, C, K = map(int, input().split())
# = int(input())
p = []
for k in range(K):
  p.append(list(map(int, input().split())))
nextlist = [[0, 0]]

maps = [[0 for _ in range(C)] for _ in range(R)]
for k in range(K):
  maps[p[k][0]-1][p[k][1]-1] += p[k][2]

point = [[[0, 0, 0] for _ in range(C)] for _ in range(R)]

point[0][0][0] = maps[0][0]

for k in range(R + C):
  for r in range(max(0, k - C + 1), min(k+1, R)):
    c = k - r
    a, b, d = point[r][c][0], point[r][c][1], point[r][c][2] 
    if r < R - 1:
      point[r+1][c][0] = max(point[r+1][c][0], maps[r+1][c] + max(a, b, d))      
    if c < C - 1:
      point[r][c+1][0] = max(point[r][c+1][0], maps[r][c+1], a)
      point[r][c+1][1] = max(point[r][c+1][1], a + maps[r][c+1], b)
      point[r][c+1][2] = max(point[r][c+1][2], b + maps[r][c+1], d)


print(max(point[-1][-1][0:3]))

### FIXED CODE ###

R, C, K = map(int, input().split())
# = int(input())
p = []
for k in range(K):
  p.append(list(map(int, input().split())))

maps = [[0 for _ in range(C)] for _ in range(R)]
for k in range(K):
  maps[p[k][0]-1][p[k][1]-1] += p[k][2]

point1 = [[0 for _ in range(C)] for _ in range(R)]
point2 = [[0 for _ in range(C)] for _ in range(R)]
point3 = [[0 for _ in range(C)] for _ in range(R)]

point1[0][0] = maps[0][0]

for r in range(R):
  for c in range(C):
    a, b, d = point1[r][c], point2[r][c], point3[r][c]  
    if c < C - 1:
      x = maps[r][c+1]
      point1[r][c+1] = max(point1[r][c+1], x, a)
      point2[r][c+1] = max(point2[r][c+1], a + x, b)
      point3[r][c+1] = max(point3[r][c+1], b + x, d)
    if r < R - 1:
      point1[r+1][c] = maps[r+1][c] + max(a, b, d)


print(max(point1[-1][-1], point2[-1][-1], point3[-1][-1]))
### BUGGY CODE ###

S = str(input())
s = len(S)
cnt = 0
A = [0]*2019
for i in range(s):
  x = int(S[i:])%2019
  A[x] += 1
for i in range(1,2019):
  if A[i] >= 2:
    cnt += A[i]*(A[i]-1)//2
cnt += A[0]*(A[0]+1)//2
print(cnt)

### FIXED CODE ###

S = str(input())
s = len(S)
cnt = 0
A = [0]*2019
r = 0
for i in range(s):
  x = (r+pow(10, i, 2019)*int(S[s-i-1]))%2019
  A[x] += 1
  r = x
  
for i in range(1,2019):
  if A[i] >= 2:
    cnt += A[i]*(A[i]-1)//2
cnt += A[0]*(A[0]+1)//2

print(cnt)
### BUGGY CODE ###

from collections import deque
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
dist = [[float('inf')]*w for _ in range(h)]
moves = ((1, 0), (0, 1), (0, -1), (-1, 0))

def bfs(sy, sx):
  q = deque([[sy, sx]])
  dist[sy][sx] = 0 
  visited = [[0]*w for _ in range(h)]
  while q:
    y, x = q.popleft()
    for dy, dx in moves:
      ny = y + dy 
      nx = x + dx 
      if 0<=ny<h and 0<=nx<w and a[ny][nx]=='.' and visited[ny][nx]==0 and dist[ny][nx]>dist[y][x]+1:
        dist[ny][nx] = dist[y][x] + 1
        visited[ny][nx] = 1
        q += [[ny, nx]]


for i in range(h):
  for j in range(w):
    if a[i][j] == '#':
      bfs(i,j)

ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, dist[i][j])

print(ans)

### FIXED CODE ###

from collections import deque
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
moves = ((1, 0), (-1, 0), (0, 1), (0, -1))
cnt = [[float('inf') for _ in range(w)] for _ in range(h)]
ans = 0
searched = [[0 for _ in range(w)] for _ in range(h)]
q = deque([])

def bfs():
  while q:
    y, x = q.popleft()
    for dy, dx in moves:
      next_y = y + dy
      next_x = x + dx 
      if 0 <= next_y < h and 0 <= next_x < w and searched[next_y][next_x] == 0 and a[next_y][next_x] == '.' and cnt[next_y][next_x] > cnt[y][x]+1:
        searched[next_y][next_x] = 1
        q.append([next_y, next_x])
        cnt[next_y][next_x] = cnt[y][x]+1

for i in range(h):
  for j in range(w):
    if a[i][j] == '#':
      cnt[i][j] = 0
      searched[i][j] = 1
      q.append([i, j])

bfs()
for i in range(h):
  for j in range(w):
    ans = max(ans, cnt[i][j])

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

H, N = map(int, input().split())
A, B = [], []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

dp = [1e9]*(H+max(A))
dp[0] = 0
for h in range(H):
  for n in range(N):
    dp[h+A[n]] = min(dp[h+A[n]], dp[h]+B[n])
print(min(dp[H:]))

### FIXED CODE ###

import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for x in range(1, H + max_damage):
    dp[x] = min(dp[x - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

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

# C - pushpush
n = int(input())
a = list(map(str,input().split()))

b = []

for i in range(n):
    ref = a.pop(0)
    b.append(ref)
    b = list(reversed(b))

ans = " ".join(b)
print(ans)


### FIXED CODE ###

# C - pushpush
n = int(input())
a = list(map(str,input().split()))

b = [""]*n
var = 0

if n % 2 == 0:
    for i in range(n):
        res = a[i]
        var += i*(-1)**i
        ind = n//2 + var
        b[ind] = res
else:
    for i in range(n):
        res = a[i]
        var += i*(-1)**i
        ind = n//2 - var
        b[ind] = res

ans = " ".join(b)
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
count = 1
for i in a:
  count *= i
if count > 1000000000000000000:
  print(-1)
else:
  print(count)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
count = 1
l = 0
if (0 in a) == True:
  print(0)
else:
  for i in a:
    count *= i
    if count > 1000000000000000000:
      l = -1
      break
  if l == 0:
    print(count)
  else:
    print(l)
### BUGGY CODE ###


N = int(input())
S = input()

ans = 0
r = range(N)
for i in r:
    for j in r:
        if j < i: continue
        if S[i] == S[j]: continue
        dji = j - i
        for k in r:
            if k < i: continue
            if k < j: continue
            if S[i] == S[k]: continue
            if S[j] == S[k]: continue
            dkj = k - j
            if dji == dkj: continue
            ans += 1


print(ans)

### FIXED CODE ###


N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

all_case = r*g*b

excluded_case = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] == S[j]: continue
        k = j*2-i
        if k>= N or S[k] == S[i] or S[k] == S[j]: continue
        excluded_case += 1

print(all_case-excluded_case)
### BUGGY CODE ###

import sys
from collections import deque


H,W=map(int, raw_input().split())
A=[ list( sys.stdin.readline().strip())  for i in range(H) ]


D=[ (-1,0),(1,0),(0,1),(0,-1) ]
K=[ [ float("inf") for j in range(W) ] for i in range(H)  ]  #Kyori

def bfs(h,w):
	V=[ [ 0 for j in range(W) ] for i in range(H)  ]
	q=deque()
	V[h][w]=1
	K[h][w]=0
	q.append( (h,w) )
	while q:
		h, w=q.popleft()	# newh , neww
		for dx,dy in D:
			if 0<=h+dx<H and 0<=w+dy<W:
				if A[h+dx][w+dy]=="." and K[h+dx][w+dy]>K[h][w]:
					V[h+dx][w+dy]=1
					K[h+dx][w+dy]=min( K[h+dx][w+dy], K[h][w]+1 )
					q.append( (h+dx,w+dy) )	


for i in range(H):
	for j in range(W):
		if A[i][j]=="#":
			bfs(i,j)

ans=0
for i in range(H):
	ans=max(ans , max(K[i]))

print ans

### FIXED CODE ###

import sys
from collections import deque

H,W=map(int, raw_input().split())
A=[ list( sys.stdin.readline().strip())  for i in range(H) ]


D=[ (-1,0),(1,0),(0,1),(0,-1) ]
K=[ [ float("inf") for j in range(W) ] for i in range(H)  ]  #Kyori

q=deque()

for i in range(H):
	for j in range(W):
		if A[i][j]=="#":
			q.append( (i,j) )
			K[i][j]=0


while q:
	h,w=q.popleft()
	for dx,dy in D:
		if 0<=h+dx<H and 0<=w+dy<W and K[h+dx][w+dy]>K[h][w]+1:
				K[h+dx][w+dy]=K[h][w]+1
				q.append( (h+dx,w+dy) )	

ans=0
for x in K:
	ans=max(ans, max(x) )
print ans
### BUGGY CODE ###

s = input()
n = len(s)
t = 0
for i in range(n+1):
    l = 0
    r = 0
    for j in range(i)[::-1]:
        if(s[j] == '>'):break
        l += 1
    for j in range(i,n):
        if(s[j] == '<'):break
        r += 1
    t += max(l,r)
print(t)

### FIXED CODE ###

s = input()
n = len(s)

l = [0 for _ in range(n+1)]
r = [0 for _ in range(n+1)]

for i in range(n):
    if(s[i] == '<'):
        l[i+1] = l[i] + 1
    else:
        l[i+1] = 0
for i in range(n)[::-1]:
    if(s[i] == '>'):
        r[i] = r[i+1] + 1
    else:
        r[i] = 0

t = 0
for i in range(n+1):
    t += max(l[i],r[i])
print(t)