Harryxun/stf_run huggingface dataset:
from collections import defaultdict
from operator import itemgetter


def solve():
    N, M = map(int, input().split())
    xy_dict = defaultdict(int)
    xy = [[] for _ in range(N)]
    for _ in range(M):
        x, y, z = map(lambda j: int(j)-1, input().split())
        xy_dict[x] += 1
        xy_dict[y] += 1
        xy[x].append(y)
        xy[y].append(x)
    
    xy_sorted = sorted(xy_dict.items(), key=itemgetter(1), reverse=True)
    opened = [0 for _ in range(N)]
    ans = N
    for i in range(M):
        parent = xy_sorted[i][0]
        if opened[parent] == 1:
            for child in xy[parent]:
                if opened[child] == 0:
                    opened[child] = 1
                    ans -= 1
            continue
        opened[parent] = 1
        for child in xy[parent]:
            opened[child] = 1
        ans -= xy_dict[parent]
    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components


def solve():
    N, M = map(int, input().split())
    X = [0 for _ in range(M)]
    Y = X[:]
    for i in range(M):
        X[i], Y[i], _ = map(lambda x: int(x)-1, input().split())
    
    graph = csr_matrix(([1]*M, (X, Y)), (N, N))
    ans = connected_components(graph)[0]
    print(ans)


if __name__ == '__main__':
    solve()
import sys
from heapq import*
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S]=0
 H=[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r()
  if'0'==f[0]:print(g(n,E,*map(int,f[2:].split())))
  else:
   c,d,e=map(int,f[2:].split())
   E[c]+=[(e,d)];E[d]+=[(e,c)]
if'__main__'==__name__:s()
 for e in iter(r,'0 0\n'):s(*map(int,e.split()))


### FIXED CODE ###

def s():
 import sys
 r=sys.stdin.readline
 I=float('inf')
 for e in iter(r,'0 0\n'):
  n,k=map(int,e.split())
  F=[[I]*-~n for _ in[0]*-~n]
  for i in range(1,n+1):F[i][i]=0
  for _ in[0]*k:
   f=r();g=map(int,f[2:].split())
   if'0'==f[0]:a,b=g;A=F[a][b];print([A,-1][A==I])
   else:
    c,d,e=g
    if e<F[c][d]:
     for i in range(2,n+1):
      for j in range(1,i):
       F[i][j]=F[j][i]=min(F[i][j],F[i][c]+e+F[d][j],F[i][d]+e+F[c][j])
s()
l = []
n = int(input())
for _ in range(n):
    c, *i = input().split()
    if c == 'insert':
        l = [*i, *l]
    elif c == 'delete':
        l.remove(*i)
    elif c == 'deleteFirst':
        del l[0]
    elif c == 'deleteLast':
        del l[len(l)-1]
    else:
        pass
print(*l)

### FIXED CODE ###

from collections import deque
n = int(input())
q = deque()
for i in range(n):
    c = input()
    if c[0] == 'i':
        q.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            q.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        q.popleft()
    else:
        q.pop()
print(*q)
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for line in sys.stdin.readlines():
        a,b,c=map(int, line.split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

if __name__=='__main__':
    main()


### FIXED CODE ###

import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for _ in range(N):
        a,b,c=map(int, input().split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

if __name__=='__main__':
    main()
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #B
    #input
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    #output
    #A < Bの時
        #V <= Wであれば、相手はひたすら逃げれば良く、この時鬼は相手を捕まえられない。
        #V > Wであれば、鬼は1秒に相手との距離をV-Wだけ詰められる。
        #B-A//V-WがTより小さいか同じ場合は鬼は相手を捕まえられる。
    #A > Bの時
        #上の議論とほぼ同じ。

    # %%
    if A < B:
        if V <= W:
            print("No")
            exit()
        else:
            if  T * (V-W) >= (B-A):
                print("Yes")
                exit()
            else:
                print("No")
                exit()
    elif A > B:
        if V <= W:
            print("No")
            exit()
        else:
            if T * (V-W) >= (A-B):
                print("Yes")
                exit()
            else:
                print("No")
                eixt()

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

### FIXED CODE ###

#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #B
    #input
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    #output
    #A < Bの時
        #V <= Wであれば、相手はひたすら逃げれば良く、この時鬼は相手を捕まえられない。
        #V > Wであれば、鬼は1秒に相手との距離をV-Wだけ詰められる。
        #B-A//V-WがTより小さいか同じ場合は鬼は相手を捕まえられる。
    #A > Bの時
        #上の議論とほぼ同じ。

    if A < B:
        if V <= W:
            print("NO")
        else:
            if (V-W)*T >= B-A:
                print("YES")
            else:
                print("NO")
    elif A > B:
        if V <= W:
            print("NO")
        else:
            if (V-W)*T >= A-B:
                print("YES")
            else:
                print("NO")

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()
a,b=int(input())
if a < b:
	print(a)
else:
	print(a-1)

### FIXED CODE ###

a, b=map(int,input().split())
if  a <= b :
	print(a)
else:
	print(a-1)
s = int(input())
print(s//3600+":"+(s//3600)//60+":"+s%60)

### FIXED CODE ###

s = int(input())
print(str(s//3600) + ":" + str((s%3600)//60) + ":" + str(s%60))
n,m=map(int,input().split())

listA=[]
for i in range(n):
    listA.append(list(map(int,input().split())))

for i in range(n):
    popped_item1=listA[i].pop(0)

listB=[]
for i in listA:
    for j in i:
        listB.append(j)

cnt=0
for i in range(m+1):
    if listB.count(i)==n:
        cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
listL = list(map(int, input().split()))
if max(listL)<(sum(listL)-max(listL)):
    print("Yes")
else:
    print("No")
n = int(input())
p = list(map(int, input().split()))
index_list = []
value_list = []
for i in range(1, n+1):
  if i != p[i-1]:
    index_list.append(i)
    value_list.append(p[i-1])
if len(index_list) == 0:
  print("YES")
elif len(index_list) == 2 and value_list[0] == index_list[1] and value_list[1] == index_list[0]:
  print("YES")
else:
  print("NO"

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
index_list = []
value_list = []
for i in range(1, n+1):
  if i != p[i-1]:
    index_list.append(i)
    value_list.append(p[i-1])
if len(index_list) == 0:
  print("YES")
elif len(index_list) == 2 and value_list[0] == index_list[1] and value_list[1] == index_list[0]:
  print("YES")
else:
  print("NO")
s=input()
c=0
mc=0
for i in s:
  if i='R':
    c+=1
    mc=c
  else:
    c=0
print(max(c,mc))

### FIXED CODE ###

s=input()
c=0
mc=0
for i in s:
  if i=='R':
    c+=1
    mc=c
  else:
    c=0
print(max(c,mc))
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans= []
if R - L >= 2019:
    print(0)
else:
    for i in range(l, r):
    　　　　for k in range(l+1, r+1):
        　　　　ans.append(i * k % 2019)
print(min(ans))

### FIXED CODE ###

L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans = []
if R - L >= 2019:
    print(0)
else:
    if l >= r:
        print(0)
    else:
        for i in range(l, r):
            for k in range(l+1, r+1):
                ans.append(i * k % 2019)                
    print(min(ans))
#文字列の入力
S = input()
#listを一文字ずつのlistに
S_list = list(S)

counter = 0
for i in range(int(len(S_list)/2)):
  if(S_list[i]==S_list[i+int(len(S_list)/2)+1]):
    counter = counter + 1
  else:
    counter = counter
    
if(counter < int(len(S_list)/2)):
    print("NO")
    
counter_ = 0
counter__ = 0
for i in range(int(len(S_list)/4)):
  if(S_list[i]==S_list[i+int(len(S_list)/4)+1]):
    counter_ = counter_ + 1
    if(S_list[i+int(len(S_list)/2)+1]==S_list[i+int(len(S_list)/2)+int(len(S_list)/2)]):
      counter__ = counter__ + 1

if((counter_ = int(len(S_list)/4))and(counter__ = int(len(S_list)/4))):
  print("Yes")

### FIXED CODE ###

#文字列の入力
S = input()
#listを一文字ずつのlistに
S_list = list(S)

S_list_reverse = list(reversed(S_list))


#print(S_list_reverse)
#print(S_list)

if(S_list != S_list_reverse):
  print("No")
else:
  S_list_new = S_list
  del S_list_new[int(len(S_list)/2):]
  S_list_new_reverse =  list(reversed(S_list_new))
  if(S_list_new != S_list_new_reverse):
    print("No")
  else:
    print("Yes")
def main():
  s = list(map(int,input().split()))
  n = [0]*s[0]
  for k in range(1,s[1],1):
    d = int(input())
    a = list(map(int,input().split()))
    for i in range(0,d,1):
      n[a[i]-1] = 1
      
  sum=0
  
  
  for k in range(0,s[1],1):  
    if(n[k]==0): sum = sum+1
 
  print(sum)
  
main()

### FIXED CODE ###

def main():
  s = list(map(int,input().split()))
  n = [0]*s[0]
  for k in range(0,s[1],1):
    d = int(input())
    a = list(map(int,input().split()))
    #print(a)
    for i in range(0,d,1):
      #print(a[i])
      n[a[i]-1] = 1
      #print(n)
      
  sum=0
  #print(n)
  
  for k in range(0,s[0],1):  
    if(n[k]==0): sum = sum+1
 
  print(sum)
  
main()
a, b = map(int, input().split())
if ((a*b) % 2) == 1)
	print("Odd")
else
	print("Even")


### FIXED CODE ###

a, b = map(int, input().split())
if (((a*b) % 2) == 1):
	print("Odd")
else:
	print("Even")
from collections import deque
n = int(raw_input())
edges = []
for i in range(n - 1):
    edges.append(map(int, raw_input().split()))
edge_num = {}
G = [[] for i in range(n)]
ans = [0] * (n - 1)
for i in range(n - 1):
    s, e = edges[i]
    s = s - 1
    e = e - 1
    edge_num[(s, e)] = i
    edge_num[(e, s)] = i
    G[s].append(e)
    G[e].append(s)
vis = set([])
q = deque([0])
vis.add(u)
while q:
    u = q.popleft()
    not_colored = []
    colors = set([])
    for v in G[u]:
        i = edge_num[(u, v)]
        if ans[i] == 0:
            not_colored.append(i)
        else:
            colors.add(ans[i])
        if not v in vis:
            vis.add(v)
            q.append(v)
    color = 1
    for i in not_colored:
        while color in colors:
            color += 1
        ans[i] = color
        color += 1
print len(set(ans))
for i in ans:
    print i

### FIXED CODE ###

from collections import deque
n = int(raw_input())
edges = []
for i in range(n - 1):
    edges.append(map(int, raw_input().split()))
edge_num = {}
G = [[] for i in range(n)]
ans = [0] * (n - 1)
for i in range(n - 1):
    s, e = edges[i]
    s = s - 1
    e = e - 1
    edge_num[(s, e)] = i
    edge_num[(e, s)] = i
    G[s].append(e)
    G[e].append(s)
vis = set([])
q = deque([0])
vis.add(0)
while q:
    u = q.popleft()
    not_colored = []
    colors = set([])
    for v in G[u]:
        i = edge_num[(u, v)]
        if ans[i] == 0:
            not_colored.append(i)
        else:
            colors.add(ans[i])
        if not v in vis:
            vis.add(v)
            q.append(v)
    color = 1
    for i in not_colored:
        while color in colors:
            color += 1
        ans[i] = color
        color += 1
print len(set(ans))
for i in ans:
    print i
n=int(input()
print((((n-1)//111)+1)*111)

### FIXED CODE ###

n=int(input())
print((((n-1)//111)+1)*111)
N, H = ( int(i) for i in input().split() )
ka = []
kb = []
for i in range(N):
	a, b = ( int(i) for i in input().split() )
	ka.append(a)
	kb.append(b)
	
kb.sort()
kb.reverse()

hp = H
res = 0
for b in kb:
	if b < max(a):
		continue
	hp = hp - b
	res += 1
	if hp <= 0:
		break
else:
	res += (hp + max(ka) - 1)//max(ka)
	
print(res)
		

### FIXED CODE ###

N, H = ( int(i) for i in input().split() )
ka = []
kb = []
for i in range(N):
	a, b = ( int(i) for i in input().split() )
	ka.append(a)
	kb.append(b)
	
kb.sort()
kb.reverse()
ma = max(ka)

hp = H
res = 0
for b in kb:
	if b < ma:
		continue
	hp = hp - b
	res += 1
	if hp <= 0:
		break
else:
	res += (hp + ma - 1)//ma
	
print(res)
a, b, c = map(int, input_raw().split())
sum = 0

for i in range(a,b+1):
  if c%i == 0:
     sum = sum + 1

print sum

### FIXED CODE ###

a, b, c = map(int, raw_input().split())
sum = 0

for i in range(a,b+1):
  if c%i == 0:
     sum = sum + 1

print sum
N=input()
A=input()
B=N%500
C=int(B)
D=int(A)
if(C < A):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N=int(input())
A=int(input())
N!=0
B=int(N%500)
if(B <= A):
    print("Yes")
else:
    print("No")
def judgement(s,c,n,m):
    for i in range(m):
        for j in range(m):
            if (s[i]==s[j] and c[i]!=c[j]) or (s[i]==1 and c[i]==0):
                return False
    return True

def num(m,n,c,s,x):
    for i in range(n):
        for j in range(m):
            if s[i]-1==j:
                x[j]=c[i]
                #print(m,n,c,s,x)
    #print(m,n,c,s,x)
    if x[0]==0:
        x[0]==1
    x="".join(map(str,x))
    print(x)

n,m=list(map(int,input().split()))
s=[0]*m
c=[0]*m
x=[0]*n
for i in range(m):
    a=list(map(int,input().split()))
    s[i]=a[0]
    c[i]=a[1]
for i in range(n):
    x[i]=0

r=judgement(s,c,n,m)
if (r==True):
    num(m,n,c,s,x)
else:
    print(-1)

### FIXED CODE ###

N, M = (int(x) for x in input().split())

A = [list(map(int, input().split())) for i in range(M)]

X = ['0' for i in range(N)]#0で埋めつくす
X[0] = '1'
for i in A:
    X[i[0] - 1] = str(i[1])#条件関係なしに代入
    #print(X)

F = 1
for i in A:
    if N > 1 and i[0] == 1 and i[1] == 0:#条件から逸脱する条件
        F = 0
    for j in A:
        #print(j)
        if i[0] == j[0] and i[1] != j[1]:
            F = 0
            
if N == 1 and M == 0:
    print(0)
elif F == 1:
    print(''.join(X))
else:
    print(-1)
import numpy as np

num_i, num_j = input().split(" ")
num_i = int(num_i)
num_j = int(num_j)
inputs = [input() for i in range(num_i)]

x = []
for _ in inputs:
    for value in _:
        x.append(value)
x = np.array(x)
x = x.reshape(num_i, num_j)

count = 0
boolean = True
while (boolean):
    count += 1
    i_arr = []
    j_arr = []
    for i in range(num_i):
        for j in range(num_j):
            if (x[i][j] == "#"):
                i_arr.append(i)
                j_arr.append(j)
    for i, j in zip(i_arr, j_arr):
        if (i == 0) & (j == 0):
            x[1][0] = "#"
            x[0][1] = "#"
        elif (i == num_i - 1) & (j == num_j - 1):
            x[i - 1][j] = "#"
            x[i][j - 1] = "#"
        elif (i == num_i - 1) & (j == 0):
            x[i - 1][0] = "#"
            x[i][1] = "#"
        elif (i == 0) & (j == num_j - 1):
            x[1][j] = "#"
            x[0][j - 1] = "#"
        elif (i == 0):
            x[1][j] = "#"
            x[0][j - 1] = "#"
            x[0][j + 1] = "#"
        elif (j == 0):
            x[i - 1][0] = "#"
            x[i + 1][0] = "#"
            x[i][1] = "#"
        elif (i == num_i - 1):
            x[i - 1][j] = "#"
            x[i][j + 1] = "#"
            x[i][j - 1] = "#"
        elif (j == num_j - 1):
            x[i - 1][j] = "#"
            x[i + 1][j] = "#"
            x[i][j - 1] = "#"
        else:
            x[i - 1][j] = "#"
            x[i + 1][j] = "#"
            x[i][j - 1] = "#"
            x[i][j + 1] = "#"
    if len(set(list(x.flatten()))) == 1:
        return(count)
        boolean = False
    else:
        boolean = True

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())

# input black cells
black_cells = []

for h in range(H):
    line = list(input())
    for w in range(W):
        if line[w] == "#":
            black_cells.append(h * W + w)


# Graph
def r(p):
    q_list = []
    h = p // W
    w = p % W
    if h != 0:
        q_list.append(p - W)
    if h != H-1:
        q_list.append(p + W)
    if w != 0:
        q_list.append(p - 1)
    if w != W-1:
        q_list.append(p + 1)
    return q_list


queue = deque(black_cells)
d = [10000] * (H * W)
for i in black_cells:
    d[i] = 0

# dijkstra
while len(queue) > 0:
    p = queue.popleft()
    for q in r(p):
        if d[q] > d[p] + 1:
            d[q] = d[p] + 1
            queue.append(q)

print(max(d))
998244353 99824435

### FIXED CODE ###

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

if (a + b) % 2 != 0:
    print("IMPOSSIBLE")
else:
    print((a + b) // 2)
import math

N = int(input())

ans = 1e18
for i in range(int(0,math.sqrt(N))):
    if N%i != 0:
        continue
    j = N/i
    ans = min(ans, i+j-2)
print(int(ans))

### FIXED CODE ###

import math

N = int(input())

ans = 1e18
for i in range(int(math.sqrt(N)), 0, -1):
    if N%i != 0:
        continue
    j = N/i
    ans = min(ans, i+j-2)
print(int(ans))
N, T = map(int, input().split())

ans  1003
for _ in range(N):
    c, t = map(int, input().split())
    if t <= T:
        ans = min(ans, c)

print('TLE' if ans==1003 else ans)


### FIXED CODE ###

import math

N, T = map(int, input().split())

c_list = []
for i in range(N):
    c1, t1=[int(i) for i in input().split()]
    if t1 <= T:
        c_list.append(c1)

if not c_list:
    print('TLE')
else:
    print(min(c_list))
n = int(input())
a = list(range(1,n+1))
print(sum(a)-max(a))

### FIXED CODE ###

n = int(input())
print((n*(n-1))//2)
def dp(v):# 頂点nから始まる最長経路を返す.
  if memo[v] != -1: return memo[v]
  to_list = Graph[v]
  answ = 0

  for to in to_list:
    answ = max(answ, dp(to)+1)
  memo[v] = answ
  return answ


N, M = map(int, input().split())
Graph = {j+1:[] for j in range(N)}
memo = {j+1: -1 for j in range(N)} # 各頂点からの最長経路をメモ. -1で初期化.

for _ in range(M):
  x, y = map(int, input().split())
  Graph[x].append(y)

ans = 0
for n in range(1,N+1):
  ans = max(ans, dp(n))
print(ans)




### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)
N, M = map(int, input().split())
G = [[] for _ in range(N+1)]
MEMO = [-1 for _ in range(N+1)]

for _ in range(M):
  x, y = map(int, input().split())
  G[x].append(y)


def dp_LP(v):# 頂点nから始まる最長経路を返す.
  if MEMO[v] != -1:
    return MEMO[v]
  else:
    ans = 0
    for i in G[v]:
      ans = max(ans, dp_LP(i)+1)
    MEMO[v] = ans

    return ans



answer = 0
for n in range(1,N+1):
  answer = max(answer, dp_LP(n))
print(answer)
n = int(input())
array = list(map(int, input().split()))
for i in range(n):
    map[array[i]] = str(i+1)
print(" ".join([map[i] for i in range(1, n+1)]))

### FIXED CODE ###

n = int(input())
array = list(map(int, input().split()))
map = {}
for i in range(n):
    map[array[i]] = str(i+1)
list = []
for i in range(1, n+1):
    list.append(map[i])
print(" ".join(list))
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*1001
for i in range(1, 1001):
    a = 0
    for j in range(1, i+1):
        a += j
    B[i] = a/i
ans = 0
for i in range(n-(n-m)):
    t = 0
    for j in range(m):
        t+=B[A[i+j]]
    ans = max(ans, t)
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
B = [(1+i)/2 for i in A]
ans = sum(B[:k])
t = ans
for i in range(n-k):
    t-=B[i]
    t+=B[i+k]
    if t>ans: ans=t
print(ans)
N = int(input())

if N % 2 == 0:
  print((N/2)**2)
  
else:
  print( (N // 2)(N // 2 + 1)


### FIXED CODE ###

N = int(input())
 
if N % 2 == 0:
  print(int((N/2)**2))
  
else:
  print(int((N // 2)*((N // 2) + 1)))
C =str(input())

alph = "abcdefghijklmnopqrstuvwxyz"

alphabet_list = list(alph)
print(alphabet_list)

print(alphabet[alphabet_list.index(C)+1])

### FIXED CODE ###

C =str(input())

alph = "abcdefghijklmnopqrstuvwxyz"

alphabet_list = list(alph)

print(alphabet_list[alphabet_list.index(C)+1])
a, b, c, d =map(int, input().split())
print(min(a, b)+min(c, d))

### FIXED CODE ###

a, b, c, d = [int(input()) for i in range(4)]
print(min(a, b)+min(c, d))
#!/usr/bin/env python3
s={c:list(input()) for c in "abc"}
s="a"
while s[s]:s=s[s].pop(0)
print(s.upper())

### FIXED CODE ###

#!/usr/bin/env python3
S={c:list(input()) for c in "abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        for i,r in enumerate(xyh):
            if r[2] > 1:
                ch = r[2] + abs(r[0] - cx) + abs(r[1] - cy)
                break
        j = False
        for i,r in enumerate(xyh):
            if r[2] != max((ch - abs(r[0] - cx) - abs(r[1] - cy)),0):
                j = True
                break
        if not j:
            print(cx,cy,ch)



### FIXED CODE ###

n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        for r in xyh:
            if r[2] > 0:
                ch = r[2] + abs(r[0] - cx) + abs(r[1] - cy)
                break
        j = False
        for r in xyh:
            if r[2] != max((ch - abs(r[0] - cx) - abs(r[1] - cy)),0):
                j = True
                break
        if not j:
            print(cx,cy,ch)
a,b,c=map(int,input().split())
if b-a == c-b:
  print(YES)
else:
  print(NO)

### FIXED CODE ###

a,b,c=map(int,input().split())
if b-a == c-b:
  print("YES")
else:
  print("NO")
import numpy as np
n = int(input())

a=list(map(int,input().split()))
c=np.array(a)
pre = abs(np.prod(c))
if pre <= 1000000000000000000:
    print(pre)
else:
    print(-1)


### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)

    if 0 in A:
        print('0')
        return
    prod=1
    for a in A:
        prod*=a
        if prod> 1000000000000000000:
            print('-1')
            return
    print(prod)

ans=main()
a , b = input().split()
print((a*3+b)//2)

### FIXED CODE ###

a,b =input().split()
print((int(a)*3+int(b))//2)
'''input
7
1 1 1 1 2 3 4
'''
n = input()
arr = map(int,raw_input().split())
for i in range(n):
	arr[i] = (arr[i]-(i+1))
arr.sort()
mean = float(arr[n//2]+arr[n//2+1])/n
ans = 10**30
for i in range(int(mean)-30,int(mean)+30):
	q = 0
	for j in range(n):
		q += abs(arr[j]-i)
	ans = min(q,ans)
print ans

### FIXED CODE ###

'''input
7
1 1 1 1 2 3 4
'''
n = input()
arr = map(int,raw_input().split())
for i in range(n):
	arr[i] = (arr[i]-(i+1))
arr.sort()
mean = float(arr[n//2])
ans = 10**30
for i in range(int(mean)-30,int(mean)+30):
	q = 0
	for j in range(n):
		q += abs(arr[j]-i)
	ans = min(q,ans)
print ans
n = input()
s = []
ans = 1

for _ in range(n):
    s.append(map(int,input()))

if "o" in s:
    print(0)
else:
    for i in range(n+1):
       ans *= s[i]
       if ans > 10**18:
           ans = -1
           break
    print(ans)

### FIXED CODE ###

n = int(input())
s = list(map(int,input().split()))
ans = 1

if 0 in s:
    print(0)
else:    
    for i in range(n):
        ans *= s[i]
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)