peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,k = map(int, input().split())
x = list(map(int, input().split()))

ans = float("inf")
for i in range(n-k+1):
  l = abs(x[i]) + abs(x[i]-x[i+k-1])
  r = abs(x[n-1-i]) + (x[n-1-i]-x[n-k-i])
  ans = min(ans,l,r)
print(ans)
# Judge status: Accepted
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
    A = list(map(int,input().split()))
    t = 0
    for e in A:
        t ^= e
    print(*[A[k]^t for k in range(N)])
if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
s = sum(a)
count = Counter(a)
q = int(input())
b_c = [list(map(int, input().split())) for i in range(q)]
for i in b_c:
  s += (i[1] - i[0]) * count[i[0]]
  count[i[1]] += count[i[0]]
  count[i[0]] = 0
  print(s)
# Judge status: Accepted
N=input()
if N[-1]=="3":
    print("bon")
elif N[-1] in {"0","1","6","8"}:
    print("pon")
else:
    print("hon")
# Judge status: Accepted
def main():
    N = int(input())
    t,x,y = 0,0,0
    ans = 'Yes'
    for i in range(N):
        ti,xi,yi = (int(x) for x in input().split())
        dt = ti - t
        dist = abs(xi-x) + abs(yi-y)
        if dt < dist or dist%2 != dt%2:
            ans = 'No'
            break
        else:
            t,x,y = ti,xi,yi
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
c = input()
t = c.count('R')
ans = 0
for i in range(n):
    if c[i] == 'R' and t <= i:
        ans += 1
print(ans)
# Judge status: Wrong Answer
line = input()

if line.count("a")==4 and line.count("b")==2 and line.count("c")==2 and len(line)==8:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer

X = input()
idx = 0
for i in range(len(X)):
    j = len(X) - i - 1
    if X[len(X)-i-1] == 'T':
        idx = j
        break
print(len(X) - X[:idx].count('S')*2)
# Judge status: Accepted
x = int(input())
#2回で3~11を作れる
count = 0
if x == 7:
  count=2
  x = 0
count += (x//11)*2
x = x%11
if x==0:
  count += 0
elif x>6:
  count+=2
else:
  count += 1
print(count)
# Judge status: Accepted
n,a,b = map(int,input().split())
ans = n//(a+b) * a
if n%(a+b) < a:
    ans += n%(a+b)
else:
    ans += a
print(ans)
# Judge status: Accepted
n = int(input())

def countKeta (num):
    return len(str(num))

count = 0
for i in range(1,n+1):
    if countKeta(i) % 2 == 1:
        count += 1

print(count)
# Judge status: Accepted
s=list(input())
t=list(input())

ans=0
for i in range(len(s)-len(t)+1):
    cnt=0
    for j in range(len(t)):
        if s[i+j]==t[j]:
            cnt+=1
    ans=max(ans,cnt)

print(len(t)-ans)
# Judge status: Wrong Answer
N,M = map(int,input().split())
H = list(map(int,input().split()))
XX = [set() for i in range(N)]
ans = 0
for i in range(M):
  A,B = map(int,input().split())
  XX[A-1].add(B-1)
  XX[B-1].add(A-1)
  
for i in range(N):
  for y in XX[i]:
    r = True
    if H[i]<=H[y]:
      r = False
      break
    if r:
      ans += 1

print(ans)
# Judge status: Accepted
s=str(input())
n=len(s)
x=s[:(n-1)//2]
y=s[(n+3)//2-1:]
ans=0

for i in range(3):
    if s==s[::-1]:
        ans +=1

    if i==0:
        s=x
    elif i==1:
        s=y

print("Yes" if ans==3 else "No")
# Judge status: Accepted
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [None]*M
y = [None]*M
c = [None]*M
for i in range(M):
  x[i],y[i],c[i] = map(int, input().split())
#print(x,y,c)
ans = min(a)+min(b)
for i in range(M):
  tmp = a[x[i]-1]+b[y[i]-1]-c[i]
  if tmp < ans:
    ans = tmp
print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())
ans = "NO"

for i in range(1, B+1):
    if (A*i) % B == C:
        ans = "YES"
        break

print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

x = 0
y = 0
z = 0
for i in a:
  if i%4 == 0: x += 1
  elif i == 2: y += 1
  else: z += 1

if y%2+z-1 <= x: print("Yes")
else: print("No")
# Judge status: Accepted
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
A.sort(reverse=True)

ans = 0

print(sum(A[1::2][:N]))
# Judge status: Accepted
H1, M1, H2, M2, K = map(int, input().split())
ans = (H2 - H1)*60 + (M2-M1) - K
print(ans)
# Judge status: Accepted
n,k=map(int,input().split(' '))
a=list(map(int,input().split(' ')))
loc=1
begin=0
end=0
d={1:0}
for i in range(n+1):
    loc=a[loc-1]
    if loc in d.keys():
        begin=d[loc]
        end=i+1
        break
    d[loc]=i+1
if k<=end:
    end=0
if end==begin+1:
    k=begin
    end=0
if end != 0:
    x=(k-begin+1)%(end-begin)
    if x==0:
        x=end-begin
    k=x+begin-1
loc=1
for _ in range(k):
    loc=a[loc-1]
print(loc)
# Judge status: Accepted
def main():
  n, d, mods = 0, 1, [1]+[0]*2019
  for i in reversed(input()):
    n = (n+int(i)*d)%2019
    d = d*10%2019
    mods[n] += 1
  print(sum([i*(i-1)//2 for i in mods]))
main()
# Judge status: Accepted
from itertools import combinations as C

N = int(input())
L = list(map(int, input().split()))
L = list(C(L, 3))
ans = 0
for l in L:
    l = list(l)
    l.sort()
    #print(l)
    if l[0] == l[1] or l[1] == l[2] or l[0] == l[2]:
        continue
    if l[0] + l[1] > l[2]:
        ans += 1
        
print(ans)
# Judge status: Wrong Answer
a,b = map(int, input().split())
if abs(a-b) > a:
    print(a)
else:
    if a%b == 0:
        print(0)
    else:
        print(a//b)
# Judge status: Accepted
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = ''
for _ in range(M):
  B += input()

ans = 'No'
for i in range(N-M+1):
  for j in range(N-M+1):
    sbstr = ''
    for k in range(M):
      sbstr += ''.join(A[i+k][j:j+M]) 
    if B == sbstr:
      ans = 'Yes'

print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(int(1e6))

n=int(input())
l=[[0,0,0]]
for _ in range(n):
    l.append(list(map(int,input().split())))

memo=[[-1,-1,-1] for _ in range(n+1)]
memo[0][0]=0
memo[0][1]=0
memo[0][2]=0
def dp(i,j):
    if memo[i][j]!=-1:
        return memo[i][j]
    else:
        memo[i][j]=max(dp(i-1,(j+1)%3)+l[i][j],dp(i-1,(j+2)%3)+l[i][j])
        return memo[i][j]
print(max(dp(n,0),dp(n,1),dp(n,2)))
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
hh = tuple(map(int, input().split()))

ans = 0
for i in range(1, n):
    if abs(t - hh[ans] * 0.006 - a) > abs(t - hh[i] * 0.006 - a):
        ans = i
print(ans + 1)
# Judge status: Wrong Answer
S = input()
S_number = len(S)
print("X" * S_number)
# Judge status: Accepted
t, mai, lim = (int(x) for x in input().split())
total = 0
for i in range(1,lim+1):
    if i%t == 0:
        total += mai
print(total)
# Judge status: Accepted
s = input()
if s == "RRR" :
    print(3)
elif s =="RRS" or s =="SRR" :
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())

if c > a + b*2:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
[N,M] = list(map(int,input().split()))
A = list(map(int,input().split()))
out=sum(A)
import heapq
a = list(map(lambda x: x*(-1), A))  # 各要素を-1倍 最大値取り出すため
heapq.heapify(a)
# print(a)

for i in range(M):
    # saidai = max(A)
    saidai = heapq.heappop(a)*(-1)
    out-=saidai
    out+=saidai//2
    # A[A.index(saidai)] = saidai//2
    heapq.heappush(a, (saidai//2)*(-1))
    # print('dam,out,a:',saidai,out,a)

print(out)
# Judge status: Accepted
# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, Q = lr()
S = sr()
ac = [0] * (N-1)
for i, x in enumerate(zip(S[:], S[1:])):
    if x[0] == 'A' and x[1] == 'C':
        ac[i] = 1

cum = list(itertools.accumulate(ac))
for _ in range(Q):
    l, r = lr()
    result = cum[r-2]
    if l > 1:
        result -= cum[l-2]
    print(result)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
def isfeasible(L):
  k = 0
  for a in A:
    if a < L:
      break
    if a%L == 0:
      dk = a//L - 1
    else:
      dk = a//L
    k += dk
    if k > K:
      return False
  return True
 
l = 0
r = A[0]

while r-l>1:
  L = (r+l)//2
  if isfeasible(L):
    r = L
  else:
    l = L
print(r)
# Judge status: Accepted

a = int(input())
print(a//2+(a%2!=0))
# Judge status: Wrong Answer
s,t=input(),input()
q = '?'*len(t)
judge = False
for i in range(len(s)):
  if (s[i:len(t)+i][0]==t[0] and s[i:len(t)+i][1:]==q[1:]) or s[i:len(t)+i]==q:
    s = s[:i] + t + s[len(t)+i:]
    judge = True
    break
if judge:
	s = ['a' if i=='?' else i for i in s]
	print(''.join(s))
else:
  print('UNRESTORABLE')
# Judge status: Accepted
K,N=map(int,input().split())
A=list(map(int,input().split()))
memo=A[0]
for i in range(N-1):
	Bi=A[i+1]-A[i]
	if Bi>memo:
		memo=Bi
if memo<=K-A[N-1]+A[0]:
	print(A[N-1]-A[0])
else:
	print(K-memo)
# Judge status: Accepted
def main():
    h = int(input())
    w = int(input())
    n = int(input())

    if h >= w:
        big = h
    else:
        big = w

    if n <= big:
        print(1)
        exit()

    for i in range(big+1):
        if i * big >= n:
            count = i
            print(count)
            exit()
 
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
alst = list(map(int, input().split()))

now = 'increase' or 'decrease'
cnt = 1
for i in range(1, N):
    x = now
    if alst[i] - alst[i - 1] > 0:
        tmp = 'increase'
    else:
        tmp = 'decrease'

    if tmp != x:
        cnt += 1
        x = tmp

print(cnt)
# Judge status: Accepted
x, y, z = [int(s) for s in input().split()]
print((x - z) // (y + z))
# Judge status: Accepted
a = input()
weather_today = {'Sunny':0 , 'Cloudy':1 , 'Rainy':2}
weather_next  = ['Cloudy', 'Rainy','Sunny']
print(weather_next[weather_today[a]])
# Judge status: Accepted
a = int(input())
ans = int(a + a**2 + a**3)
print(ans)
# Judge status: Wrong Answer
n,m = list(map(int, input().split()))
wa_cnt = 0
ac = set()
for _ in range(m):
  p, s = input().split()
  if(s == "AC"):
    ac.add(p)
  if (p not in ac and s=="WA"): 
    wa_cnt += 1
print(len(ac), wa_cnt)
# Judge status: Accepted
import math
r = int(input())

print(r*2*math.pi)
# Judge status: Accepted
n = int(input())

if (n%1000) != 0:
	print(1000-(n%1000))
else:
	print(0)
# Judge status: Accepted
import collections
n = int(input())
s = [input() for _ in range(n)]

s = collections.Counter(s).most_common()
mx = s[0][1]

ans = []
for k, v in s:
    if mx == v:
        ans.append(k)


for i in sorted(ans):
    print(i)
# Judge status: Accepted
import fractions

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

l = [0]
r = [0]

for i in range(N - 1):
    l += [fractions.gcd(l[i], A[i])]
    r += [fractions.gcd(r[i], A[-i-1])]

print(max(fractions.gcd(l[i], r[-i-1]) for i in range(N)))
# Judge status: Accepted
h = int(input())
n_list = [0 for i in range(40)]
n_list[0] = 1
count = 1
ans = 0
while h > 1:
    h = h // 2
    n_list[count] = 1
    count += 1
for i in range(40):
    ans += n_list[i] * (2**i)
print(ans)
# Judge status: Accepted
import decimal
a,b =map(str,input().split())
a2 = decimal.Decimal(a)
b2 = decimal.Decimal(b)
print(int(a2*b2))
# Judge status: Wrong Answer
N = int(input())
flag = False
n = 7

while n < N:
  if (N % n) % 4 == 0 or N % 4 == 0 or N % 7 == 0:
    flag = True
    break
  n += 7

print("Yes" if flag else "No")
# Judge status: Accepted
S = input()
print('2018'+S[4:])
# Judge status: Accepted
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
Ques = [ list(map(int, input().split())) for _ in range(Q) ]

Nums = [ i for i in range(M) ]
ans = -1
for v in combinations_with_replacement(Nums, N):
    cnt = 0
    for que in Ques:
        if v[que[1]-1]-v[que[0]-1] == que[2]: cnt += que[3]
    ans = max(ans, cnt)
print(ans)
# Judge status: Accepted
from fractions import gcd
import sys
input = sys.stdin.buffer.readline

def f(x):
    cnt = 0
    while x % 2 == 0:
        x //= 2
        cnt += 1
    return cnt

n, m = map(int, input().split())
a = list(set([int(i) // 2 for i in input().split()]))

b = f(a[0])
for i in a:
    if f(i) != b:
        print(0)
        exit()

l = 1
for i in a:
    l = l * i // gcd(l, i)

print((m // l + 1) // 2)
# Judge status: Accepted
s = input()
print("Yes" if "".join(sorted(s)) == "abc" else "No")
# Judge status: Accepted
N,M = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(M)]

ball_count = [1]*N
visited = [0]*N
visited[0] = 1

for x,y in xy:
  ball_count[x-1] -= 1
  ball_count[y-1] += 1
  if visited[x-1] == 1:
    visited[y-1] = 1
  if ball_count[x-1] == 0:
    visited[x-1] = 0

print(sum(visited))
# Judge status: Accepted
# ABC150 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: tuple(map(int, input().split()))
import itertools
n=ni()
p=nl()
q=nl()

if p==q:
    print(0)
    exit()
L=[]
for i in range(n):
    L.append(i+1)
a=0
b=0
idx=1
for l in list(itertools.permutations(L)):
    idx+=1
    if l==p:
        a=idx
    elif l==q:
        b=idx

print(abs(a-b))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

money = 1000
stock = 0
for i in range(n):
    # 売る
    money += stock * a[i]
    stock = 0

    # 買う
    if i != n - 1 and a[i] < a[i + 1]:
        stock = money // a[i]
        money %= a[i]

print(money)
# Judge status: Accepted
#ABC145.C
N = int(input())
x = []
c=0
for i in range(N):
    x1=[int(i) for i in input().split()]
    x.append(x1)
for i in range(N):
    for m in range(N):
        if i!=m:
            c+=((x[i][0]-x[m][0])**2+(x[i][1]-x[m][1])**2)**0.5
print(c/N)
# Judge status: Accepted
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()
S = rs()

import itertools
g = list(itertools.groupby(S))

print(N-max(len(g)-1-2*K, 0)-1)
# Judge status: Accepted
# -*- coding: utf-8 -*-
N, M = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
import heapq

priority_queue = []
for a in A:
    heapq.heappush(priority_queue, -a)

for _ in range(M):
    a = -1 * heapq.heappop(priority_queue)
    a //= 2
    heapq.heappush(priority_queue, -a)

ans = sum([-1 * a for a in priority_queue])

print(ans)
# Judge status: Wrong Answer
S, W = map(int, input().split())

if S < W:
    print("unsafe")
else:
    print("safe")
# Judge status: Accepted
l=[int(input()) for i in range(4)]
print(l[0]*l[2]-max(l[0]-l[1],0)*(l[2]-l[3]))
# Judge status: Accepted
from math import gcd
import re
s=input()
match=re.findall("[ACGT]*",s)
length=0
for i in match:
    length=max(length,len(i))
print(length)
# Judge status: Accepted
Q, H, S, D = map(int, input().split())
N = int(input())
n = N//2
ans = min(D, 2*S, 4*H, 8*Q)*n + min(S, 2*H, 4*Q)*(N%2)
print(ans)
# Judge status: Accepted
n = int(input())
t=(n-1)*n//2
print(t)
# Judge status: Accepted
n,k,q = map(int,input().split())
A = [0 for _ in range(n)]
for _ in range(q):
  a = int(input())
  A[a-1] += 1

for a in A:
  if a > q-k:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
a, b = (int(i) for i in input().split())
s = input()
for i in range(a+b+1):
    if i == a:
        if not s[i] == '-':
            print('No')
            exit()
    else:
        if not s[i] >= '0' or not s[i] <= '9':
            print('No')
            exit()
print('Yes')
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
cnt = 0

for i in range(n):
    if i+1 != p[i]:
        cnt += 1

if cnt == 0 or cnt == 2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
s = input() + input()
print("YES" if s == s[::-1] else "NO")
# Judge status: Accepted
L, R, d = map(int, input().split())
ans = 0
for i in range(L, R+1):
  if i % d == 0:
    ans += 1    
print(ans)
# Judge status: Accepted
n, m = map(int,input().split())
print("Yes") if n == m else print("No")
# Judge status: Wrong Answer
import math
#import numpy


def readints():
    return list(map(int, input().split()))


n = int(input())
p = readints()
print(p)
sum = 0
for i in range(n-2):
    #print(p[i], end="")
    #print(p[i+1], end="")
    #print(p[i+2], end="")
    if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]:
        sum += 1
print(sum)
# Judge status: Accepted
x = int(input())
# mod = 10 ** 9 + 7
tmp = x // 11
nokori = x % 11
if nokori == 0:
    print(tmp * 2)
elif nokori > 6:
    print(tmp * 2 + 2)
else:
    print(tmp * 2 + 1)
# Judge status: Accepted
N,M,K=map(int,input().split())
flag=False
for n in range(N+1):
    for m in range(M+1):
        if (N-n)*m+(M-m)*n==K:
            flag=True
print("Yes" if flag else "No")
# Judge status: Accepted
n,q = map(int,input().split())
s = str(input())
a = [0]*(n+1)
c = 0
for i in range(n-1):
  if s[i] == "A" and s[i+1] == "C":
    c += 1
  a[i+2] = c
for i in range(q):
  l,r = map(int,input().split())
  print(a[r]-a[l])
# Judge status: Accepted
n,k,*a=map(int,open(0).read().split())
v=[0]+[-1]*n
t=a[0]-1
c=1
while v[t]<0:
  v[t]=c
  t=a[t]-1
  c+=1
l=v[t]
c-=l
print(v.index(min(k,l+(k-l)%c))+1)
# Judge status: Wrong Answer
n = input().split()
m = input().split()
n = [int(i) for i in n]
m = [int(i) for i in m]
a = n[0]
for i in m:
  a -= i
  if a<0:
    print("-1")
  else:
    print(a)
# Judge status: Accepted
import scipy.misc

N=int(input())
X=list(map(int,input().split()))
SX=sorted(X)
M=SX.pop()
MV=10**9
ANS=0
for x in SX:
  z = abs(M - x - x)
  if MV > z:
    MV = z
    ANS = x
print("{} {}".format(M,ANS))
# Judge status: Wrong Answer
n,a,b,c,d,e=[int(input()) for i in range(6)]
print(n//min(a,b,c,d,e)+5)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
b.reverse()
c=[]
for i in b:
  if a.count(i)>=4:
    c+=[i]
    c+=[i]
    break
  elif a.count(i)>=2:
    c+=[i]
    if len(c)>=2:
      break
if len(c)>=2:
  print(c[0]*c[1])  
else:
    print(0)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

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

ans = 0
tmp_left = ''
tmp_right = ''

for x in range(A, B + 1):
    tmp_left = str(x)[0] + str(x)[1]
    tmp_right = str(x)[-2] + str(x)[-1]
    if tmp_left == tmp_right:
        ans += 1

print(ans)
# Judge status: Accepted
from collections import Counter
N = int(input())
blue = []
for _ in range(N):
    blue.append(input())
blue = Counter(blue)

M = int(input())
red = []
for _ in range(M):
    red.append(input())
red = Counter(red)

diff = blue - red
if len(diff)==0:
    print(0)
else:
    print(max(diff.values()))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)

tmp = a[0]
ans = []
cnt = 0
for i in range(1,len(a)):
    if tmp == a[i]:
        cnt += 1
        if cnt == 1 or cnt == 3:
            ans.append(tmp)
    else:
        tmp = a[i]
        cnt = 0


if len(ans) < 2:
    print(0)
else:
    print(ans[0]*ans[1])
# Judge status: Accepted
import math
r=int(input())
print(2*math.pi*r)
# Judge status: Wrong Answer
N = int(input())
A = sorted(map(int, input().split()))

print(sum(A[0::2]) - sum(A[1::2]))
# Judge status: Wrong Answer
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
na = []
c = 0
for booka in a:
  c += booka
  na.append(c)
nb = []
d = 0
for bookb in b:
  d += bookb
  nb.append(d)
maxa = 0
for i in range(n-1,-1,-1):
  for j in range(m-1,-1,-1):
    if na[i] + nb[j] <= k:
      maxa = max(maxa,i+j+2)
      break
print(maxa)
# Judge status: Accepted
def main():
    a = int(input())
    b = int(input())
    h = int(input())
    ans = (a+b)*h//2
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,r=map(int,input().split())
print(max(0,10-n)*100+r)
# Judge status: Wrong Answer
import itertools

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

a,b = 0,0
flag = 0

ix = list(itertools.permutations(range(1,1+n)))

for i in range(len(ix)):
    t = list(ix[i])
    if (p == t):
        a = i
        flag += 1
    elif (q == t):
        b = i
        flag += 1
    if (flag == 2):
        break
print(abs(a-b))
# Judge status: Accepted
a,b = map(int,input().split())

if a>=13:
    print(b)
elif a>=6:
    print(b//2)
else:
    print(0)
# Judge status: Accepted
import math
A,B=map(int,input().split())
print(math.ceil((B-1)/(A-1)))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B = mapint()
if A>8 or B>8:
    print(':(')
else:
    print('Yay!')
# Judge status: Wrong Answer
N, M = map(int,input().split())
x,y = [],[]
for _ in range(M):
	tx,ty = map(int, input().split())
	x.append(tx)
	y.append(ty)

flg = [0] * (N+1)
flg[1] = 1
cnt = [1] * (N+1)
#フラグが１が経っているところからは、移動することで赤を移せる。
for i in range(M):
	cp,np = x[i],y[i]

	if flg[cp] == 1:
		if cnt[cp] == 1:
			flg[cp] = 0
		cnt[cp] -= 1
		cnt[np] += 1
		flg[np] = 1

print(sum(flg))
# Judge status: Wrong Answer
x = int(input())
for a in range(-100, 101):
    for b in range(-100, 101):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            break
            break
# Judge status: Accepted
N = int(input())
a = [int(aa) for aa in input().split()]

cnt = 1
for now_a in a:
    if cnt == now_a:
        cnt += 1

if cnt == 1:
    print(-1)
else:
    print(N-cnt+1)
# Judge status: Accepted
n, k = map(int, input().split())
dislike = input().split()
while True:
  flag = True
  n_str = str(n)
  for i in n_str:
    if i in dislike:
      flag = False
      break
  if flag:
    print(n)
    break
  else:
    n += 1
# Judge status: Accepted
T = input()
print(T.replace("?", "D"))
# Judge status: Accepted
# coding: utf-8

N = int(input())
A = [int(x) for x in input().split()]

count = 0
while True:
	flag = True

	for A_i in A:
		if A_i % 2 != 0:
			flag = False
			break

	if flag == False:
		break

	for index in range(N):
		A[index] = A[index] / 2

	count += 1

print(count)
# Judge status: Wrong Answer
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

    odd = 0
    even = 0
    for a in A:
        if a&1:
            odd += 1
        else:
            even += 1
    if odd == 0:
        print(0)
    else:
        print(2**(N - 1))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, M = map(int,input().split())
A = [str(input()) for _ in range(N)]
B = [str(input()) for _ in range(M)]

res = "No"

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            for k in range(1,M):
                if A[k][j:j+M] == B[k]:
                    pass
                else:
                    break
            res = "Yes"

print(res)
# Judge status: Accepted
n,T=map(int,input().split())
cl=[]
for i in range(n):
    c,t=map(int,input().split())
    if t <= T:
        cl.append(c)
if len(cl) == 0:
    print('TLE')
else:
    print(min(cl))
# Judge status: Accepted
import collections
N = int(input())
ans = 0
now = 0
k = []
for i in range(N):
  A = int(input())
  k.append(A)
p = collections.Counter(k)
for i in p:
  if p[i]%2 == 1:
    ans += 1
print(ans)
# Judge status: Wrong Answer
A, B = map(int, input().split())
S = input()
for i in range(A):
    if not S[i].isdecimal():
        print('No')
        exit()
if S[A] != '-':
        print('No')
        exit()
for i in range(A+1, B):
    if not S[i].isdecimal():
        print('No')
        exit()
print('Yes')
# Judge status: Wrong Answer
#Write your code in below
N = int(input().rstrip())
print(N*(1+N+N^2))