Harryxun/stf_run huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n,C = LI()
    T = [[0 for i in range(200001)] for j in range(C)]
    for i in range(n):
        s,t,c = LI()
        c -= 1
        T[c][2*s-1] += 1
        T[c][2*t+1] -= 1
    for c in range(C):
        for i in range(200000):
            T[c][i+1] += T[c][i]
    ans = 0
    for i in range(200000):
        k = 0
        for c in range(C):
            k += T[c][i]
        ans = max(ans, k)
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n,C = LI()
    T = [[0 for i in range(200002)] for j in range(C)]
    for i in range(n):
        s,t,c = LI()
        c -= 1
        T[c][2*s] += 1
        T[c][2*t+1] -= 1
    for c in range(C):
        for i in range(200000):
            T[c][i+1] += T[c][i]
    ans = 0
    for i in range(200000):
        k = 0
        for c in range(C):
            if T[c][i]:k += 1
        ans = max(ans, k)
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()
import numpy as np
N, M = map(int, input().split())  # 品物の数、割引券の枚数
A = np.array(list(map(int, input().split())))  # 品物の値段
for _ in range(M):
    tmp = A.argmax()
    A[tmp] = A[tmp] // 2
print(str(sum(A)))


### FIXED CODE ###

N, M = map(int, input().split())  # 品物の数、割引券の枚数
A = list(map(int, input().split()))  # 品物の値段
A.sort(reverse=True)
i = 0
for _ in range(M):
    A[i] = A[i] // 2
    if i <= N - 2 and A[i] < A[i + 1] and A[0] < A[i+1]:
        i += 1
    else:
        A.sort(reverse=True)
        i = 0
print(str(sum(A)))
n, k = map(int, input().split())
A = []
for _ in range(n):
    t, d = map(int, input().split())
    A.append((d, t))
A.sort(reverse=True)
X = []
Y = []
st = set()
for i in range(k):
    d, t = A[i]
    if t in st:
        X.append(d)
    else:
        Y.append(d)
        st.add(t)
x = sum(X)
y = sum(Y)
v = len(Y)
ans = x + y + v ** 2
for i in range(k, n):
    if not X:
        break
    d, t = A[i]
    if t in st:
        continue
    st.add(t)
    x -= X.pop()
    y += d
    v += 1
    ans = max(ans, x + y + v ** 2)
print(ans)
n, k = map(int, input().split())
A = []
for _ in range(n):
    t, d = map(int, input().split())
    A.append((d, t))
A.sort(reverse=True)
X = []
Y = []
st = set()
for i in range(k):
    d, t = A[i]
    if t in st:
        X.append(d)
    else:
        Y.append(d)
        st.add(t)
x = sum(X)
y = sum(Y)
v = len(Y)
ans = x + y + v ** 2
for i in range(k, n):
    if not X:
        break
    d, t = A[i]
    if t in st:
        continue
    st.add(t)
    x -= X.pop()
    y += d
    v += 1
    ans = max(ans, x + y + v ** 2)
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
td = [[int(i) for i in input().split()] for _ in range(N)]
td.sort(key=lambda x:x[1],reverse=True)
ans = 0
ls = set()
dl = []
for i in range(K):
    ans += td[i][1]
    if not td[i][0] in ls:
        ls.add(td[i][0])
    else:
        dl.append(td[i][1])
ans = ans + len(ls)**2
res = ans
for i in range(K,N):
    if not dl:
        break
    if td[i][0] in ls:
        continue
    ans += len(ls)*2+1
    ans += td[i][1]
    ans -= dl[-1]
    del dl[-1]
    res = max(res,ans)
    ls.add(td[i][0])
print(res)
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * (n + 1) for _ in [0, 1]]
dp[0][0] = 0
dp[1][0] = -1 * 10 ** 10
for i in range(n):
    for j in [0, 1]:
        dp[j][i + 1] = max(dp[0][i] + (-1)**j * a[i],
                           dp[1][i] + (-1)**(j + 1) * a[i])
print(dp[n][0])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a_min = 0
minus_count = 0
for i in a:
    if i < 0:
        minus_count += 1
a = [abs(e) for e in a]
if minus_count % 2 != 0:
    a_min = a.pop(a.index(min(a)))
ans = sum(a) - a_min
print(ans)
A,B = map(int,input().split())
a = 0

for i in range(A,B+1):
    if i[1:2] = i[4:5]:
        a += 1
print("a")

### FIXED CODE ###

A,B = map(int,input().split())
C = 0

for i in range(A,B+1):
    if str(i) == str(i)[::-1]:
        C += 1
print(C)
def insertionSort( nums, n, g ):
	global cnt
	for i in range( g, n ):
		v = nums[i]
		j = i - g
		while ( 0 <= j ) and ( v < nums[j] ):
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v

def shellSort( nums ):
	global cnt
	g = []
	v = 1
	n = len( nums )
	while v <= n:
		g.append( v )
		v = 3*v+1     
	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )  
	cnt = 0
	for i in range( m ):
		insertionSort( nums, n, g[i] )
	print( cnt )

n = int( input( ) )
nums = [ int( input( ) ) for i in range( n ) ]
shellSort( nums )
for v in nums:
	print( v )

### FIXED CODE ###

import sys
 
def insertionSort( nums, n, g ):
    cnt = 0
    i = g
    while i < n:
        v = nums[i]
        j = i - g
        while 0 <= j and v < nums[j]:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
        nums[ j+g ] = v
        i += 1
    return cnt
         
def shellSort( nums, n ):
    g = []
    val = 1
    while val <= n:
        g.append( val )
        val = 3*val+1
     
    g.reverse( )
    m = len( g )
    print( m )
    print( " ".join( map( str, g ) ) )
    cnt = 0
    for i in range( m ):
        cnt += insertionSort( nums, n, g[i] )
    print( cnt )
     
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
    nums.append( int( sys.stdin.readline( ) ) )
 
shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = sorted(c, reverse=True)

q = [(a[0]+b[0]+c[0], 0, 0, 0)]
t = []
for i in range(min(x*y*z, k)):
  m = q.pop(q.index(max(q, key=lambda x: x[0])))
  print(m[0])
  if m[1] < x-1:
    next_a = (a[m[1]+1]+b[m[2]]+c[m[3]], m[1]+1, m[2], m[3])
  if m[2] < y-1:
    next_b = (a[m[1]]+b[m[2]+1]+c[m[3]], m[1], m[2]+1, m[3])
  if m[3] < z-1:
    next_c = (a[m[1]]+b[m[2]]+c[m[3]+1], m[1], m[2], m[3]+1)
  if next_a not in t:
    q.append(next_a)
    t.append(next_a)
  if next_b not in t:
    q.append(next_b)
    t.append(next_b)
  if next_c not in t:
    q.append(next_c)
    t.append(next_c)


### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = sorted(c, reverse=True)

q = [(a[0]+b[0]+c[0], 0, 0, 0)]
t = []
next_a = (0,0,0,0)
next_b = (0,0,0,0)
next_c = (0,0,0,0)
for i in range(min(x*y*z, k)):
  m = q.pop(q.index(max(q, key=lambda x: x[0])))
  print(m[0])
  if m[1] < x-1:
    next_a = (a[m[1]+1]+b[m[2]]+c[m[3]], m[1]+1, m[2], m[3])
  if m[2] < y-1:
    next_b = (a[m[1]]+b[m[2]+1]+c[m[3]], m[1], m[2]+1, m[3])
  if m[3] < z-1:
    next_c = (a[m[1]]+b[m[2]]+c[m[3]+1], m[1], m[2], m[3]+1)
  if next_a not in t:
    q.append(next_a)
    t.append(next_a)
  if next_b not in t:
    q.append(next_b)
    t.append(next_b)
  if next_c not in t:
    q.append(next_c)
    t.append(next_c)
if e - a =< k:
  print('Yay!')
else:
  print(':(')

### FIXED CODE ###

input_list = [int(input()) for i in range(5)]
k = int(input())
if input_list[4] - input_list[0] <= k:
  print('Yay!')
else:
  print(':(')
import numpy as np
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())),dtype=int64)
B=np.zeros(N+1,dtype=int64)
if K>41:
  A=np.ones(N,dtype=int64)*N
else:
  for k in range(K):
    for i in range(N):
      B[max(0,i-int(A[i]))] +=1
      B[min(N,i+int(A[i])+1)] -=1
    A=np.cumsum(B)[:N]
    B=np.zeros(N+1,dtype=int64)

for i in A:
  print(i)

### FIXED CODE ###

import numpy as np
from numba import jit
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())),dtype=np.int64)
@jit
def loop(a,k):
  if k>41:
    ans=np.ones(N,dtype=np.int64)*N
  else:
    ans=a
    for j in range(k):
      B=np.zeros(N+1,dtype=np.int64)
      for i in range(N):
        B[max(0,i-int(ans[i]))] +=1
        B[min(N,i+int(ans[i])+1)] -=1
      ans=np.cumsum(B)[:N]
  return ans

for i in loop(A,K):
  print(i)
SA = list(input())
SB = list(input())
SC = list(input())

LenSA = len(SA)
LenSB = len(SB)
LenSC = len(SC)

NowCard = SA.pop()

while True:
    if NowCard == 'a':
        NowList = SA
    elif NowCard == 'b':
        NowList = SB
    elif NowCard == 'c':
        NowList = SC

    NowCard = NowList.pop()

    if SA == [] or SB == [] or SC == []:
        break

if SA == []:
    print('A')
if SB == []:
    print('B')
if SC == []:
    print('C')


### FIXED CODE ###

from collections import deque

SA = deque(input())
SB = deque(input())
SC = deque(input())

NowCard = SA.popleft()
ans = 'A'

while True:
    if NowCard == 'a':
        NowList = SA
        ans = 'A'
    elif NowCard == 'b':
        NowList = SB
        ans = 'B'
    elif NowCard == 'c':
        NowList = SC
        ans = 'C'

    if len(NowList) == 0:
        break

    NowCard = NowList.popleft()

print(ans)
n = int(input())
l = list(map(int,input().split()))
l.append(10**9)
m = 'Yes'
for i in range(0,n-1)
  if l[n-i-1] <= l[n-i]:
    Continue
  elif l[n-i-1] > l[n-i] + 1:
    m = 'No'
    Break
  else:
    l[n-i-1] = l[n-i-1] - 1

print(m)


### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
l.append(1000000000)
m = 'Yes'
for i in range(0,n-1):
  if l[n-i-1] <= l[n-i]:
    continue
  elif l[n-i-1] > l[n-i] + 1:
    m = 'No'
    break
  else:
    l[n-i-1] = l[n-i-1] - 1

print(m)
n,l=map(int,input().split())
s=[input() for i in range(n)]
s.sort()
print("".join(s))

### FIXED CODE ###

print(["NO","YES"][eval(input().replace(" ","*"))==175])
#97
judge=0
N,M = map(int,input().split())
import fractions
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
for i in a:
    if (ans//i)%2==0:
        judge=1
        sss=0
        break
if judge==0 and M-ans//2 <0:
    sss=0
elif judge==0 and M-ans >=0:
    sss=((M-ans//2)//ans)+1
print(sss)

### FIXED CODE ###

judge=0
N,M = map(int,input().split())
import fractions
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
for j in a:
    if (ans//j)%2==0:
        judge=1
        sss=0
        break
if judge==0 and M-ans//2 <0:
    sss=0
elif judge==0 and M-ans//2 >=0:
    sss=((M-ans//2)//ans)+1
print(sss)
S = input()
if "a" in S and "b" in S and "c" in S:
	print("YES)
else:
    print("NO")

### FIXED CODE ###

S =input()
if "a" in S and "b" in S and "c" in S:
	print("Yes")
else:
  	print("No")
N = int(input())
L = map(int,input().split())

sLength = set(L)
count = 0

for i in sLength:
    for j in sLength:
        for k in sLength:
            if i!=j and i!=k and j!=k:
                m = max([i,j,k])
                if i+j+k-2*m>0:
                    count+=1

print(count)


### FIXED CODE ###

s = input()

table = {'RRR':3,'RRS':2,'RSR':1,'RSS':1,'SRS':1,'SRR':2,'SSS':0,'SSR':1}

for key,value in table.items():
    if key==s:
        print(value)
# D
import numpy as np
N = int(input())
X = np.zeros(N, dtype=int)
Y = np.zeros(N, dtype=int)

for i in range(N):
    x, y = map(int, input().split())
    X[i] = x
    Y[i] = y

# edges
X_s = np.argsort(X)
Y_s = np.argsort(Y)

edge_list = []
edge_weight = []
for i in range(N-1):
    edge_list.append([X_s[i], X_s[i+1]])
    edge_weight.append(min(abs(X[X_s[i+1]] - X[X_s[i]]), abs(Y[X_s[i+1]] - Y[X_s[i]])))
    edge_list.append([Y_s[i], Y_s[i+1]])
    edge_weight.append(min(abs(X[Y_s[i+1]] - X[Y_s[i]]), abs(Y[Y_s[i+1]] - Y[Y_s[i]])))
    
# sort edges
sel = np.argsort(np.array(edge_weight))

# union find tree
uf = dict()
for i in range(N):
    uf[i] = i

res = 0
flg = np.zeros(N)

for s in sel:
    m, n = edge_list[s]
    # find union
    gr_m = m
    gr_m_list = []
    gr_n = n
    gr_n_list = []
    while gr_m != uf[gr_m]:
        gr_m_list.append(gr_m)
    for m_ in gr_m_list:
        uf[m_] = gr_m
    while gr_n != uf[gr_n]:
        gr_n_list.append(gr_n)
    for n_ in gr_n_list:
        uf[n_] = gr_n
    if gr_m == gr_n:
        pass
    else:
        res += edge_weight[s]
        if dep_m > dep_n:
            uf[gr_n] = gr_m
        elif dep_m > dep_n:
            uf[gr_n] = gr_m
        else:
            uf[gr_m] = gr_n
print(res)

### FIXED CODE ###

# D
import numpy as np
N = int(input())
X = []
Y = []

for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

# edges
X_s = np.argsort(np.array(X))
Y_s = np.argsort(np.array(Y))

edge_list = []
edge_weight = []
for i in range(N-1):
    edge_list.append([X_s[i], X_s[i+1]])
    edge_weight.append(X[X_s[i+1]] - X[X_s[i]])
    edge_list.append([Y_s[i], Y_s[i+1]])
    edge_weight.append(Y[Y_s[i+1]] - Y[Y_s[i]])
    
# sort edges
sel = np.argsort(np.array(edge_weight))

# union find tree
uf = np.arange(N)


res = 0
flg = np.zeros(N)

for s in sel:
    m, n = edge_list[s]
    # find union
    gr_m = m
    gr_m_list = []
    gr_n = n
    gr_n_list = []
    while gr_m != uf[gr_m]:
        gr_m_list.append(gr_m)
        gr_m = uf[gr_m]
    for m_ in gr_m_list:
        uf[m_] = gr_m
        
    while gr_n != uf[gr_n]:
        gr_n_list.append(gr_n)
        gr_n = uf[gr_n]
    for n_ in gr_n_list:
        uf[n_] = gr_n
        
    if gr_m == gr_n:
        pass
    else:
        res += edge_weight[s]
        uf[gr_n] = gr_m
print(res)
if n > k:
  print(int(k*x+(n-k)*y))
else:  
  print(int(n*x))

### FIXED CODE ###

n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n<=k:
    sum=n*x
else:
    sum=k*x+(n-k)*y
print(sum)
H, W = map(int, input().split())
inputs = [input() for _ in range(H)]

y = 0
x = 0

goal_y = H - 1
goal_x = W - 1

counts = 0
for item in inputs:
    counts += item.count('#')

if counts != (H + W - 1):
    print('Impossible')
else:
    for i in range(H + W - 2):
        if 0 <= x <= W - 1 and inputs[y][x + 1] == '#':
            x = x + 1
        elif 0 <= y <= H - 1 and inputs[y + 1][x] == '#':
            y = y + 1
    print('Possible' if y == goal_y and x == goal_x else 'Impossible')

### FIXED CODE ###

H, W = map(int, input().split())
inputs = [input() for _ in range(H)]

y = 0
x = 0

goal_y = H - 1
goal_x = W - 1

counts = 0
for item in inputs:
    counts += item.count('#')

if counts != (H + W - 1):
    print('Impossible')
else:
    for _ in range(H + W - 2):
        if x + 1 < W and inputs[y][x + 1] == '#':
            x += 1
        elif y + 1 < H and inputs[y + 1][x] == '#':
            y += 1
    print('Possible' if y == goal_y and x == goal_x else 'Impossible')
def input_undirected_graph(V: int, E: int, origin: int = 1):
    graph = [list() for _ in range(V)]
    for i in range(E):
        u, v = [int(x) for x in input().split()]
        u -= origin
        v -= origin
        graph[u].append(v)
        graph[v].append(u)
    return graph


def main():
    N, Q = [int(x) for x in input().split()]
    graph = input_undirected_graph(N, N-1)

    vals = [0] * N
    for _ in range(Q):
        p, x = [int(x) for x in input().split()]
        vals[p-1] += x
    
    ans = [0] * N
    def dfs(node, par, val):
        ans[node] += vals[node] + val

        for child in graph[node]:
            if child == par:
                continue
            dfs(child, node, ans[node])

    dfs(0, -1, 0)
    for i in range(N):
        print(ans[i])
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

### FIXED CODE ###

from collections import defaultdict, deque


def main():
    N, Q = map(int, input().split())

    tree = defaultdict(list)
    counter = defaultdict(int)
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    for _ in range(Q):
        p, x = map(int, input().split())
        counter[p] += x

    # bfs
    q = deque([1])
    visited = {1}

    while q:
        i = q.popleft()

        for j in tree[i]:
            if j not in visited:
                q.append(j)
                counter[j] += counter[i]
                visited.add(j)

    counts = [counter[i] for i in range(1, N+1)]
    ans = " ".join(map(str, counts))
    print(ans)



if __name__ == '__main__':
    main()
def solve(s):
    if len(s) ==3:
        if s[0]=='A' and s[1]=='B' and s[2]=='C':
            return True
        else:
            return False
    i=0
    a = 0
    b = 0
    c = 0
    lis =[]
    while i < len(s):
        if i+2<len(s) and s[i] =='A' and s[i+1] == 'B' and s[i+2] == 'C':
            lis.append('X')
            i += 3
        else:
            lis.append(s[i])
            if s[i] == 'A':
                a = 1
            if s[i] == 'B':
                b = 1
            if s[i] == 'C':
                c = 1
            i += 1

    if not(a+b+c == 2):
        return False
    if a==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='A'
    if b==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='B'
    if c==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='C'
    if len(s) == len(lis):
        return False

    return solve(lis)


if solve(input()):
    print("Yes")
else:
    print("No")



### FIXED CODE ###

import sys
sys.setrecursionlimit(5010)

def solve(s): 
    if len(s) ==3:
        if s[0]=='A' and s[1]=='B' and s[2]=='C':
            return True
        else:
            return False
    i=0
    a = 0
    b = 0
    c = 0
    lis =[]
    while i < len(s):
        if i+2<len(s) and s[i] =='A' and s[i+1] == 'B' and s[i+2] == 'C':
            lis.append('X')
            i += 3
        else:
            lis.append(s[i])
            if s[i] == 'A':
                a = 1
            if s[i] == 'B':
                b = 1
            if s[i] == 'C':
                c = 1
            i += 1

    if not(a+b+c == 2):
        return False
    if a==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='A'
    if b==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='B'
    if c==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='C'
    if len(s) == len(lis):
        return False

    return solve(lis)


if solve(input()):
    print("Yes")
else:
    print("No")
a,b = map(int,input().split())
li = list(map(int,input().split()))
li = [abs(x-b) for x in li]
#print(li)
import functools
import math
li2 = []
for i in range(len(li)-1):
    c = (math.gcd(li[i],li[i+1]))
    li2.append(c)
print(min(li2))

### FIXED CODE ###

n, x = map(int,input().split())
li = list(input().split())
li = [abs(int(a)-x) for a in li]

def gcd(a,b):
    while a%b!=0:
        a,b = b,a%b
    return b
    
if n == 1:
    print(abs(li[0]))
    
elif n == 2:
    print(gcd(li[0],li[1]))
    
elif n >= 3:

    c = gcd(li[0],li[1])
    #print(c)
    for i in range(2,len(li)-1):
        c = gcd(c,li[i])
    print(c)
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit(0)
ans = 1
for i in A:
    ans = ans * i
    if ans > pow(10, 18):
        print(-1)
        exit(0)
else:
    print(ans)

### FIXED CODE ###

a,b = map(int,input().split())
print(a*b)
def swap(A, i, j):
    tmp  = A[i]
    A[i] = A[j]
    A[j] = tmp

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
  
def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [g]
    while 3 * g + 1 < n:
        g = 3 * g + 1
        G.append(g)
    m = len(G)
    G.reverse()
    print(m)
    print(' '.join(map(str, G)))
    for i in range(m):
        insertionSort(A, n, G[i])

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

shellSort(A, n)
print(cnt)
for a in A:
    print(a)



### FIXED CODE ###

from sys import stdin

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
  
def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [g]
    while 3 * g + 1 < n:
        g = 3 * g + 1
        G.append(g)
    m = len(G)
    G.reverse()
    print(m)
    print(' '.join(map(str, G)))
    for i in range(m):
        insertionSort(A, n, G[i])

n =  int(stdin.readline())
A = [int(stdin.readline()) for i in range(n)]

shellSort(A, n)
print(cnt)
for a in A:
    print(a)
# C
n = int(input())
preX = [0,0,0]
ans = True
for i in range(n):
    curX = list(map(int, input().split()))
    time = 
    if not curX[0] - preX[0] >= (abs(curX[1] - preX[1]) + abs(curX[2] - preX[2])) and curX[0] - preX[0] % 2 == (abs(curX[1] - preX[1]) + abs(curX[2] - preX[2])) % 2:
        ans = False
if ans:
    print('Yes')
else:
    print('No')
            

### FIXED CODE ###

import numpy as np

n = int(input())
input_X = [[int(i) for i in input().split()] for i in range(n)]
X = np.array(input_X)

pre_t = 0
pre_x = 0
pre_y = 0
for i in range(n):
    x_move = abs(X[i][1] - pre_x)
    y_move = abs(X[i][2] - pre_y)
    xy_sum = x_move + y_move
    spend_time = X[i][0]-pre_t
    if xy_sum%2 == spend_time%2 and spend_time >= xy_sum:
        pre_t = X[i][0]
        pre_x = X[i][1]
        pre_y = X[i][2]
        if i+1 == n:
            print('Yes')
        else:
            continue
    else:
        print('No')
        break
s = [input() for i in range(3)]
temp = 0
if int(s[1])-int(s[0]) > int(s[5]):
  temp += 1
if temp == 0:
  print('Yay!')
else:
  print(':(')

### FIXED CODE ###

i = [int(input()) for i in range(6)]
temp = 0
if i[4] - i[3] > i[5]:
  temp += 1
if i[4] - i[2] > i[5]:
  temp += 1
if i[4] - i[1] > i[5]:
  temp += 1
if i[4] - i[0] > i[5]:
  temp += 1
if i[3] - i[2] > i[5]:
  temp += 1
if i[3] - i[1] > i[5]:
  temp += 1
if i[3] - i[0] > i[5]:
  temp += 1
if i[2] - i[1] > i[5]:
  temp += 1
if i[2] - i[0] > i[5]:
  temp += 1  
if i[1] - i[0] > i[5]:
  temp += 1  
if temp != 0:
  print(':(')
else:
  print('Yay!')