Harryxun/stf_run huggingface dataset:
n = int(input())
b=list(map(int, input().split())) 

sum =b[0]
for i in range(1,len(b)):
    if b[i-1]<b[i]:
        sum+=b[i-1]
    else:
        sum+=b[i]
        
sum+=b[i]
        
print(sum)

### FIXED CODE ###

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

sum =b[0]

if len(b) >= 2:
    for i in range(1,len(b)):
        if b[i-1]<b[i]:
            sum+=b[i-1]
        else:
            sum+=b[i]
        
sum+=b[-1]
        
print(sum)
x = int(input())
a = int((x//500)*1000)
b = int(((x-(x//500)*500)//5)*5)
print(int(a+b))


### FIXED CODE ###

w = input()
if w[2]==w[3] and w[4]==w[5]:
  print('Yes')
else:
  print('No')
def a(t,i):
    if i= len(s)-1:
        return sum(map(int,t.split('+')))
    return a(t+s[i+1],i+1) + a(t+'+'+s[i+1],i+1) #関数の中に入れると最後の項でまとめて処理できる
s = input()
print(a(s[0],0))

### FIXED CODE ###

def dfs(i,s):
    if i==n-1:
        return sum(map(int,s.split('+')))
    return dfs(i+1,s+S[i+1])+dfs(i+1,s+'+'+S[i+1])

S=input()
n=len(S)
ans=dfs(0,S[0])
print(ans)
from math import cos, radians, sqrt

A, B, H, M = list(map(int,input().split))

m = H * 60 + M
h = 360.0 / 60.0 * (m % 60)
mi = 360.0 / 720.0 * (m % 720)
arg = abs(h - mi)

print(sqrt(A**2 + B**2 - 2.0 * A * B * cos(radians(arg))))

### FIXED CODE ###

from math import cos, radians, sqrt

A, B, H, M = list(map(int,input().split()))

m = H * 60 + M
h = 360.0 / 60.0 * (m % 60)
mi = 360.0 / 720.0 * (m % 720)
arg = abs(h - mi)

print(sqrt(A**2 + B**2 - 2.0 * A * B * cos(radians(arg))))
L, R= map(int, input())

hasamu=R-L
kotae=10000
if hasamu>2017:
  kotae=0

for i in range(L,R):
  for j in range(i+1,R+1):
    seki=i*j
    amari=seki%2019
    if amari<kotae:
      kotae=amari
print(kotae)
  


### FIXED CODE ###

L2, R2= map(int, input().split())

L=L2%2019
R=R2%2019

hasamu=R2-L2
kotae=10000
if hasamu>2017:
  kotae=0
if L>R:
  kotae=0
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      seki=i*j
      amari=seki%2019
      if amari<kotae:
        kotae=amari
print(kotae)
import math
print '%.6f %.6f' % (r*r*math.pi,2*r*math.pi)

### FIXED CODE ###

import math
r = input()
print '%.6f %.6f' % (r*r*math.pi,2*r*math.pi)
H,W = map(int, input().split())
A=[]
B=[]
for _ in range(H):
    A.append(list(map(int, input().split())))
for _ in range(H):
    B.append(list(map(int, input().split())))
M=[[] for _ in range(W)]
m=0
for i in range(H):
    for j in range(W):
        M[i][j]=abs(A[i][j]-B[i][j])
        m=max(M[i][j],m)
r=m*(H+W)
dp=[[[False for _ in range(r)] for _ in range(W)] for _ in range(H)]
dp[0][0][abs(A[0][0]-B[0][0])]=True
for i in range(H):
    for j in range(W):
        if i==0 and j==0: continue
        for k in range(r):
            if i==0:
                if dp[i][j-1][abs(k-M[i][j])] or dp[i][j-1][k+M[i][j]]:
                    dp[i][j][k]=True
            elif j==0:
                if dp[i-1][j][abs(k-M[i][j])] or dp[i-1][j][k+M[i][j]]:
                    dp[i][j][k]=True
            elif dp[i][j-1][abs(k-M[i][j])] or dp[i][j-1][k+M[i][j]] or dp[i-1][j][abs(k-M[i][j])] or dp[i-1][j][k+M[i][j]]:
                dp[i][j][k]=True
for i in range(r):
    if dp[H-1][W-1][i]:
        print(i)
        break


### FIXED CODE ###

import numpy as np
import itertools

H,W=map(int,input().split())
A=[list(map(int, input().split())) for _ in range(H*2)]
M=[[abs(A[i][j]-A[H+i][j]) for j in range(W)] for i in range(H)]
m=max(max(j for j in i) for i in M)
r=m*(H+W)+1
dp=np.zeros((H,W,r),dtype='bool')
dp[0][0][M[0][0]]=True
it = itertools.product(range(H),range(W))
next(it)
for h,w in it:
    m=M[h][w]
    dp[h][w][m:] |= dp[h][w-1][:r-m] | dp[h-1][w][:r-m]
    dp[h][w][:r-m] |= dp[h][w-1][m:] | dp[h-1][w][m:]
    dp[h][w][:m] |= dp[h][w-1][m:0:-1] | dp[h-1][w][m:0:-1]

for i in range(r):
    if dp[-1][-1][i]:
        print(i)
        break
a = int(input())
b = int(input())
s = a-2*b
if(s > 0):
    print(s)
else:
    print(0)



### FIXED CODE ###

a,b = map(int,input().split())
print(max(0,a-2*b))
import sys
readline = sys.stdin.readline

def main():
  N, M = map(int, readline().split())
  dist = {}
  pre = {}
  A = {}
  for i in range(N):
    dist[i+1] = -1
    pre[i+1] = -1
    A[i+1] = []
  dist[1] = 0
  pre[1] = 0
  for i in range(M):
    ai, bi = map(int, readline().split())
      A[ai].append(bi)
      A[bi].append(ai)
  cnt = 1
  depth = 1
  D = [1]
  while cnt < N:
    next = []
    for i in range(len(D)):
      for j in range(len(A[D[i]])):
        if dist[A[D[i]][j]] == -1:
          dist[A[D[i]][j]] = depth
          pre[A[D[i]][j]] = D[i]
          next.append(A[D[i]][j])
          cnt += 1
    D = next
    depth += 1
    if len(next) == 0:
      break
    elif depth > N:
      break
  if cnt == N:
    print('Yes')
    for i in range(1, N):
      print(pre[i+1])
  else:
    print('No')

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
readline = sys.stdin.readline

def main():
  N, M = map(int, readline().split())
  dist = {}
  pre = {}
  A = {}
  for i in range(N):
    dist[i+1] = -1
    pre[i+1] = -1
    A[i+1] = []
  dist[1] = 0
  pre[1] = 0
  for i in range(M):
    ai, bi = map(int, readline().split())
    A[ai].append(bi)
    A[bi].append(ai)
  cnt = 1
  depth = 1
  D = [1]
  while cnt < N:
    next = []
    for i in range(len(D)):
      for j in range(len(A[D[i]])):
        if dist[A[D[i]][j]] == -1:
          dist[A[D[i]][j]] = depth
          pre[A[D[i]][j]] = D[i]
          next.append(A[D[i]][j])
          cnt += 1
    D = next
    depth += 1
    if len(next) == 0:
      break
    elif depth > N:
      break
  if cnt == N:
    print('Yes')
    for i in range(1, N):
      print(pre[i+1])
  else:
    print('No')

if __name__ == '__main__':
  main()
N = int(input())
A = [int(input()) for _ in range(N)]
m = max(A)
ans = [m for _ in range(N)]
if A.count(M) > 1:
    print('\n'.join(ans))
    exit()
AA = A[:]
AA.remove(M)
mm = max(AA)
for n in range(N):
    if A[n] == m:
        ans[n] = mm
        break
print('\n'.join(ans))

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
m = max(A)
ans = list(map(str, [m for _ in range(N)]))
if A.count(m) > 1:
    print('\n'.join(ans))
    exit()
AA = A[:]
AA.remove(m)
mm = max(AA)
for n in range(N):
    if A[n] == m:
        ans[n] = str(mm)
        break
print('\n'.join(ans))
n = int(input())
s = input()

minc = 100000000

for i in range(len(s)):
  minc = min(minc,(left_wrong = s[0:i].count('W')+s[i:].count('E')))

print(minc)


### FIXED CODE ###

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

nums = [s[1:].count('E')]
for i in range(1,n):
  tmp = nums[i-1]
  if s[i-1] == 'W':
    tmp  += 1
  if s[i] == 'E':
    tmp -= 1
  nums.append(tmp)

print(min(nums))
r,g,b = map(int,input().split())
if (100*a + 10*g + b)%4 == 0:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

r, g, b = map(int,input().split())
total = r*100 + g*10 + b
if total % 4 == 0:
	print('YES')
else:
	print('NO')
N = input()
S = input()

i = 0
j = 0
k = 0
N = int(N)
count = 0
for a in range(10):
    for i in range(N-2):
        if str(a) == S[i]:
            for b in range(10):
                for j in range(i+1, N-1):
                    if str(b) == S[j]:
                        for c in range(10):
                            for k in range(j+1,N):
                                if str(c) == S[k]:
                                    count += 1
                                    break
                        break
            break
print(count)
                


### FIXED CODE ###

M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if M1 == M2:
    print(0)

else:
    print(1)
import sys
import numpy as np 

n = int(sys.stdin.readline().rstrip())
graph = [None] * n
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    if not a: continue
    graph[i] = np.array([sys.stdin.readline().split() for _ in range(a)], dtype=np.int16).T

def main():
    comb = np.arange(1 << n)[:, None] >> np.arange(n) & 1
    ok = np.full(1 << n, True)
    for i in range(n):
        if graph[i] is None: continue
        x, y = graph[i]
        bl = (comb[:, i] ^ 1) | np.all(comb[:, x-1] == y, axis=1)
        ok &= bl   
    print(np.amax(comb[ok].sum(axis=1)))

if __name__ ==  '__main__':
    main()

### FIXED CODE ###

import sys
# import numpy as np

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]

for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for j in range(a):
        x, y = map(int, sys.stdin.readline().split())
        xy[i].append((x-1, y))

# xy = np.array(xy)
# x, y = xy[:, :].T
# x = x.T 
# y = y.T

def main():
    ans = 0
    for comb in range(2 ** n):
        cnt = 0
        ok = True
        for i in range(n):
            if not comb >> i & 1:
                continue
            for x, y in xy[i]:
                if comb >> x & 1 ^ y:
                    ok = False
                    break
            if ok:
                cnt += 1
            else:
                break
        else:
            ans = max(ans, cnt)
    return ans
                
if __name__ == '__main__':
    ans = main()
    print(ans)
a, b, c = map(int,input().split())
#if math.sqrt(a)+math.sqrt(b) < math.sqrt(c):
if a**0.5 + b**0.5 < c**0.5
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a, b, c = map(int,input().split())
#if math.sqrt(a)+math.sqrt(b) < math.sqrt(c):
if c-a-b> 0 and (c-a-b)**2 > 4*a*b:
    print("Yes")
else:
    print("No")
n = int(input())
if n[-1] in "24579":
  print("hon")
elif n[-1] in "0168":
  print("pon")
elif n[-1] in "3"
  print("bon")


### FIXED CODE ###

n = input()
if n[-1] in "24579":
  print("hon")
elif n[-1] in "0168":
  print("pon")
elif n[-1] in "3":
  print("bon")
S = input()
N = len(S)
S1 = S[:(N-1)//2]
S2 = S[(N+3)//2-1:]


def isloop(S):
    i = 0
    N = len(S)
    while S[i] == S[N-1-i]:
        i += 1
        if i == N-1-i:
            return True
    return False


if isloop(S) and isloop(S1) and isloop(S2):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

S = input()
N = len(S)
S1 = S[:(N-1)//2]
S2 = S[(N+3)//2-1:]


def isloop(S):
    i = 0
    N = len(S)
    if i == N-1-i:
        return True
    while S[i] == S[N-1-i]:
        i += 1
        if i == N-1-i or i == N-i:
            return True
    return False


if isloop(S) and isloop(S1) and isloop(S2):
    print("Yes")
else:
    print("No")
def main():
    A, B, K = map(int, input().split())
    C = max(A - K , 0)
    K = max(K - A , 0)
    D = max(B - K , 0)
    print(C, D)



if __name__ == "__main__":
    main()

### FIXED CODE ###

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main():
    X = int(input())
    for i in range(X, 10**12):
        if is_prime(i):
            print(i)
            exit()




if __name__ == "__main__":
    main()
#!/usr/bin/env python3
a = 1
x = int(input())
while True:
    bz = (x-a**5)**.2
    if float.is_integer(bz):
        print(a, -int(bz))
        exit()
    a += 1

### FIXED CODE ###

#!/usr/bin/env python3
n, m = map(int, input().split())
*h, = map(int, input().split())
h = [0] + h
i = [0] + [1] * n

for j in range(m):
    a, b = map(int, input().split())
    if h[a] >= h[b]:
        i[b] = 0
    if h[a] <= h[b]:
        i[a] = 0
print(sum(i))
import itertools as it

n,m=map(int,input().split())
ans=[]
for i in range(n):
    a,b=map(int,input().split())
    ans.append([a,b])
    ans.append([b,a])
  

for e in it.permutations(range(n)):
    count,a=0,0
    if e[0]!=0:
        break
    
    for i in range(len(e)-1):
        if [e[i]+1,e[i+1]+1] in ans:
            count=1
        else:
            count=0
            
    a+=count
    
print(a)

### FIXED CODE ###

import itertools as it
import sys

N, M = map(int, input().split())
if N==0 or M==0:
    print(0)
    sys.exit()
a=[]

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

ans=0
for e in it.permutations(range(N)):
    if e[0]!=0:
        break
        
    count=1
    for j in range(N-1):
        if [e[j]+1,e[j+1]+1] in a:
            count*=1
        else:
            count*=0
            break
            
    ans+=count

print(ans)
def get_answer(ki):
    n = int(ki[0].split(" ")[0])
    q = int(ki[0].split(" ")[1])
    n_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[1:-q]]]
    q_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[-q:]]]
    tree = make_tree(n, n_data)
    t_index = make_index(n, tree)

    score = [0] * n

    for qq in q_data:
        index = qq[0]
        #add_score(tree, score, qq, n_data, index)
        s_index = t_index[index - 1]
        for i in s_index:
            score[i] += qq[1]

    score = [str(s) for s in score]
    s = " ".join(score)

    return s


def add_score(tree, score, qq, n_data, index):
    score[index - 1] += qq[1]
    next_index = tree[index -1]
    for n_i in next_index:
        add_score(tree, score, qq, n_data, n_i)


def make_tree(n, n_data):
    r = {}
    for i in range(n):
        r[i] = []
    for n in n_data:
        k = n[0] - 1
        if k in r.keys():
            r[k].append(n[1])
        else:
            r[k] = [n[1]]
    return r


def make_index(n, tree):
    index = {}
    r0 = [0] * n
    for i in range(n):
        r0[i] = i
    index[0] = r0

    for i in range(1, n):
        r = []
        add_index(tree, i, r)
        index[i] = r

    return index


def add_index(tree, index, r):
    r.append(index)
    next_index = tree[index]
    for n_i in next_index:
        add_index(tree, n_i - 1, r)


if __name__ == "__main__":
    input_ki = []
    while True:
        try:
            input1 = input()
            if not input1:
                break;
            if len(input1) == 0:
                break;
            input_ki.append(input1)
        except EOFError:
            break
    get_answer(input_ki)


### FIXED CODE ###

import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1): #木グラフの隣接リストを作成
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
for _ in range(q): #各頂点についてcount[v]を計算
 v,val=map(int,input().split())
 cnt[v]+=val
q=collections.deque()
q.append(1) #DFSのスタックによる実装、まずスタックに始点1を積む
checked=[0]*(n+1) #各頂点を見たかどうかのフラグを持っておく
while q:
 v=q.pop()
 checked[v]=1 #頂点を見たかどうかのフラグを更新する
 for u in g[v]:
   if checked[u]==1: #vの子ノードuについて、まだ見ていない頂点であればcount[u]をcount[u]+=count[v]として更新する
     continue
   cnt[u]+=cnt[v]
   q.append(u) #スタックに子ノードuを積む
print(*cnt[1:]) #各頂点のcountが答えとなる
a = list(map(int, input().split()))

c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]+1):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(50-1,0,-1):
    c = c - 1
    if b[i][0] < c:
        c = c - b[i][0] - 1
        res = res + b[i][1] + 1
if c == 1:
    res = res + 1

print(res)


### FIXED CODE ###

a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] * 2 + 1 <= c:
        c = c - b[i][0]*2 - 1
        res = res + b[i][1] * 2 + 1
    elif b[i][0] <= c: 
        c = c - b[i][0]
        res = res + b[i][1]
        if c > 0:
            c = c - 1
            res = res + 1
    c = c - 1

if c > 0:
    res = res + c

print(res)
N=int(input())
M=list(map(int, input().split()))
ans=min(M)
mn=Min(M)
for m in M:
  if m%ans!=0:
    ans=min(ans, gcd(mn,m))
    break

### FIXED CODE ###

N=int(input())
M=list(map(int, input().split()))
ans=min(M)
mn=min(M)
from math import gcd
for m in M:
  if m%mn!=0:
    ans=min(ans, gcd(mn,m))
print(ans)
n = input()
m = input()
l = input()
n = n - m
print(n)
if n >= l
 n = n - l
  print(n)
else:
  print(n)

### FIXED CODE ###

n = input()
m = input()
l = input()

n = int(n)
m = int(m)
l = int(l)

n = n - m
while n >= l :
  n = n - l
else: 
  print(n)
import math
all ,blue = map(int,input().split())
red = all - blue

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,blue+1):
    print((combinations_count(blue-1,i-1)*combinations_count(red+1,i))%(1000000007))




### FIXED CODE ###

import math
all ,blue = map(int,input().split())
red = all - blue

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,blue+1):
    if (red+1) < i:
        print('0')
    else:
        print((combinations_count(blue-1,i-1)*combinations_count(red+1,i))%(10**9+7))
A,B,C = intput().split()
A,B,C = int(A),int(B),int(C)

print(C-(A-B))

### FIXED CODE ###

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

print(max([C-(A-B),0]))
def calc_ABC(a, c, bq, aq):
    ans = 0
    if aq != 0:
        if bq != 0:
            ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \
                 * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))
        else:
            ans = ans + (a*pow(3, bq, MOD)) \
                 * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))
    else:
        if bq != 0:
            ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \
                 * (c*pow(3, aq, MOD))
        else:
            ans = ans + (a*pow(3, bq, MOD)) \
                 * (c*pow(3, aq, MOD))
    return ans % MOD


MOD = 10**9 + 7
S = raw_input()
ans = 0
count_a = 0
count_c = S.count('C')
count_afterq = S.count('?')
count_beforeq = 0

for i in range(len(S)):
    if S[i] == 'A':
        count_a += 1
    elif S[i] == 'B':
        ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)
        ans = ans % MOD
    elif S[i] == 'C':
        count_c -= 1
    elif S[i] == '?':
        count_afterq -= 1
        ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)
        ans = ans % MOD
        count_beforeq += 1
print(ans)


### FIXED CODE ###

def calc_ABC(a, c, bq, aq):
    ans = 0
    if aq != 0:
        if bq != 0:
            ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \
                 * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))
        else:
            ans = ans + (a*pow(3, bq, MOD)) \
                 * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))
    else:
        if bq != 0:
            ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \
                 * (c*pow(3, aq, MOD))
        else:
            ans = ans + (a*pow(3, bq, MOD)) \
                 * (c*pow(3, aq, MOD))
    return ans % MOD


MOD = 10**9 + 7
S = input()
ans = 0
count_a = 0
count_c = S.count('C')
count_afterq = S.count('?')
count_beforeq = 0

for i in range(len(S)):
    if S[i] == 'A':
        count_a += 1
    elif S[i] == 'B':
        ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)
        ans = ans % MOD
    elif S[i] == 'C':
        count_c -= 1
    elif S[i] == '?':
        count_afterq -= 1
        ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)
        ans = ans % MOD
        count_beforeq += 1
print(ans)
while True :
    A , B = input ( ) .split ( " " )
    A = int ( A )
    B = int ( B )
    if A == 0 and B == 0 :
        break
    for x in range ( A ) :
       print "#" * B

### FIXED CODE ###

while True :
    A , B = raw_input ( ) .split ( " " )
    A = int ( A )
    B = int ( B )
    if A == 0 and B == 0 :
        break
    for x in range ( A ) :
       print "#" * B
    print
n,k=map(int, input().split())
h=list(map(int,input().split()))
dp=[0]*(n)
  
for i in range(1,k+1):
  dp[i]=abs(h[0]-h[i])
 
for i in range(k,n):
  li=[abs(h[i]-h[ik])+dp[ik] for ik in range(i-1,i-k-1,-1) ]
  dp[i]=min(li)
  
print(dp[-1])

### FIXED CODE ###

n,k=map(int, input().split())
h=list(map(int,input().split()))
dp=[0]*(n)
if k+1<=n:
  max=k+1
else:
  max=n
  
for i in range(1,max):
  dp[i]=abs(h[0]-h[i])
 
for i in range(k,n):
  li=[abs(h[i]-h[ik])+dp[ik] for ik in range(i-1,i-k-1,-1) ]
  dp[i]=min(li)
  
print(dp[-1])
import math
pi = math.pi
r = int(input())
print(pi*r**2, 2*pi*r)


### FIXED CODE ###

from math import pi
r = float(input())
print("{0} {1}".format(r * r * pi, (r + r) * pi))
n=int(input())
a=[]

x,y,k=-1,-1,-1
n=-1
for o in range(n):
    a.append(list(map(int,input().split())))
    if a[o][2] != 0:
        n=o
for i in range(101):
    for j in range(101):
        h=a[o][2]+abs(a[o][0]-i)+abs(a[o][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()



### FIXED CODE ###

n=int(input())
xyh=[]

x,y,h=-1,-1,-1
nonzero=-1

for i in range(n):
    xyh.append(list(map(int,input().split())))
    if xyh[i][2] != 0:
        nonzero = i

for px in range(101):
    for py in range(101):
        nh = xyh[nonzero][2]+abs(xyh[nonzero][0]-px)+abs(xyh[nonzero][1]-py)
        ok = True

        for nn in range(n):
            if xyh[nn][2] > 0 and nh != xyh[nn][2]+abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py):
                ok=False
            if xyh[nn][2] == 0 and nh > abs(xyh[nn][0]-px) +abs(xyh[nn][1]-py):
                ok=False
        
        if ok:
            x,y,h = px,py,nh
            print(x,y,h)
            exit()
import numpy as np

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

a = np.array(a)

a_abs = list(map(abs,a))
a_abs = np.array(a_abs)

a_sort = sorted(a_abs,reverse=True)

a_arg = np.argsort(-a_abs)

a_arg_k = a_arg[0:k]
a_arg_k_ = a_arg[k:]

a_pow = 1

if all([1 if i < 0 else 0 for i in a]) and (k % 2 != 0):
    for i in range(n-1,k-1,-1):
        a_pow *= a[a_arg[i]]

else:
    for i in range(k):
        a_pow *= a[a_arg[i]]
    
    if a_pow < 0:
        a_pow_p = 1
        for i in reversed(a_arg_k):
            if a[i] < 0:
                for j in a_arg_k_:
                    if a[j] > 0:
                        a_pow_p = a_pow/a[i]*a[j]
                        break
                break
                
        a_pow_m = 1
        for i in reversed(a_arg_k):
            if a[i] > 0:
                for j in a_arg_k_:
                    if a[j] < 0:
                        a_pow_m = a_pow/a[i]*a[j]
                        break
                break
        if a_pow_p > a_pow_m:
            a_pow = a_pow_p
        else:
            a_pow = a_pow_m

output = a_pow % (10**9 + 7)
print(output)


### FIXED CODE ###

N = int(input())

if N % 1000 == 0:
    print(0)
else:
    hasu = N - (N // 1000)*1000
    print(1000-hasu)
while True:
    a, op, b = map(str, raw_input().split())
    if op == "?":
        break
    if op == "/":
        op = "//"
    formula = a + op + b
    print(eval(formula))

### FIXED CODE ###

while True:
    s = input()
    if '?' in s:
        break
    print(int(eval(s)))
h,w=map(int,input())
if h%3==0 or w%3==0:
  print(0)
if (w-w//3-1)%2==0 or h%2==0:
  x=h*(w//3 +1)-(h*w-h*(w//3 +1))//2
else:
  x=h*(w//3 +1)-(h*w-h*(w//3 +1)-min((w-w//3-1),h))//2
if (h-h//3-1)%2==0 or w%2==0:
  y=w*(h//3 +1)-(h*w-w*(h//3 +1))//2
else:
  y=w*(h//3 +1)-(h*w-w*(h//3 +1)-min((h-h//3-1),h))//2
print(min(x,y))

### FIXED CODE ###

h,w=map(int,input().split())
if h%3==0 or w%3==0:
  print(0)
  exit()
if (w-w//3-1)%2==0 or h%2==0:
  x=h*(w//3 +1)-h*(w-w//3-1)//2
else:
  x=h*(w//3 +1)-(h*w-h*(w//3 +1)-min((w-w//3-1),h))//2
if (w-w//3)%2==0 or h%2==0:
  x2=h*(w-w//3)//2-h*(w//3)
else:
  x2=(h*w-h*(w//3)+min((w+w//3),h))//2-h*(w//3)
if (h-h//3-1)%2==0 or w%2==0:
  y=w*(h//3 +1)-w*(h-h//3-1)//2
else:
  y=w*(h//3 +1)-(h*w-w*(h//3 +1)-min((h-h//3-1),h))//2
if (h-h//3)%2==0 or w%2==0:
  y2=w*(h-h//3)//2-w*(h//3)
else:
  y2=(h*w-w*(h//3)+min((h-h//3),h))//2-w*(h//3)
print(min(x,y,x2,y2))