peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
s=sum(A)
Q=int(input())
cnt=Counter(A)
for _ in range(Q):
    b,c=map(int,input().split())
    if b in cnt:
        s-=cnt[b]*b
        s+=cnt[b]*c
        print(s)
        if c in cnt:
            cnt[c]+=cnt[b]
            cnt[b]=0
        else:
            cnt[c]=cnt[b]
            cnt[b]=0
    else:
        print(s)
# Judge status: Accepted
N = int(input())
L = [
    [2,4,5,7,9],
    [0,1,6,8],
    [3]
]
h = ['hon', 'pon', 'bon']
for ll in range(len(L)):
    if N % 10 in L[ll]:
        print(h[ll])
        break
# Judge status: Accepted
a,b=map(int,input().split())

if a>b and (a-b)%2==0:
    print (int(b + (a-b)/2 ))
elif b>a and (b-a)%2==0:
    print (int(a+(b-a)/2 ))
else:
    print("IMPOSSIBLE")
# Judge status: Wrong Answer
CONST = 10**9 + 7
n,m = map(int,input().split())

dp = [-1 for _ in range(n+1)]
dp[0] = 1
dp[1] = 2
for _ in range(m):
  a = int(input())
  dp[a] = 0
  if a == 0 and  dp[1] ==2:
    dp[1] = 1

for i in range(2,n):
  if dp[i] == 0:
    continue
  dp[i] = (dp[i-1] + dp[i-2]) % CONST
print(dp[n])
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(sum(a[n:len(a):2]))
# Judge status: Accepted
def main():
    s = input()
    print(list(set(["ABC", "ARC"])-set([s]))[0])

if __name__ == "__main__":
    main()
# Judge status: Accepted
N,A,B = map(int, input().split())

"""
MIN: (N - 1) * A + B
MAX: A + (N - 1) * B

MAX - MIN + 1
= (N - 1) * (B - A) - (B - A) + 1
= (N - 2) * (B - A) + 1
"""

if N == 1 and A != B:
    print(0)
elif A > B:
    print(0)
else:
    print((B - A) * (N - 2) + 1)
# 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
print('YES' if cnt ==2 or cnt ==0 else 'NO')
# Judge status: Accepted
N, T = map(int, input().split())
c = [0] * N
t = [0] * N
for i in range(N):
    c[i], t[i] = map(int, input().split())

z = zip(c, t)
z = sorted(z)
c, t = zip(*z)

for i in range(N):
    if t[i] <= T:
        print(c[i])
        exit()
print('TLE')
# Judge status: Accepted
# coding: utf-8

def main():
    n = int(input())
    lines = []
    for i in range(0, n):
        lines.append(input())

    dct = {}
    for l in lines:
        if l in dct:
            dct[l] += 1;
        else:
            dct[l] = 1;

    cmax = max(dct.values())

    print('\n'.join(sorted([k for k,v in dct.items() if v == cmax])))

if __name__ == '__main__':
    main()
# Judge status: Accepted
if input().count('7'):
        print("Yes")

else:
    print("No")
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
"""
Created on Tue Jun  2 21:44:35 2020

@author: naoki
"""
import fractions

A, B, C = map(int,input().split()) # A,B,Cを入力

#不定方程式を解ければよい ax-by=c 
#そのためにユークリッドの互除法を用いる 
#gcd(a,b) = gcd(b,c) ならば不定方程式が成立する。そうでないならば成立しない。
if fractions.gcd(A,B) == fractions.gcd(B,C):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N = int(input())
for i in range(1,50001):
  tmp = int(i * 1.08)
  if(tmp == N):
    print(str(i))
    exit()
print(":(")
# Judge status: Wrong Answer
from math import sqrt
A, B, C = map(int,input().split())
if pow(A,0.5) + pow(B,0.5) < pow(C,0.5):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n=int(input())
a=[]
for i in range(n):
    a.append(input())
if len(a)!=len(set(a)):
    print('No')
    exit()
for i in range(n-1):
    if a[i][-1]!=a[i+1][0]:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
A,B = map(int,input().split())
c = 0
for i in range(A,B+1):
  s = str(i)
  k = True
  for j in range(len(s)//2):
    if s[j] != s[(j+1)*-1]: 
      k = False
      break
  if k:
      c+=1     
print(c)
# Judge status: Wrong Answer
print('yes' if sorted(input()) < sorted(input(), reverse=True) else 'No')
# Judge status: Accepted
a, b = [int(w) for w in input().split()]

if a * b <= 0:
    print("Zero")
elif a > 0:
    print("Positive")
else:
    if (a - b) % 2 == 0:
        print("Negative")
    else:
        print("Positive")
# Judge status: Accepted
n,m,x,y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

lower = max(X)
upper = min(Y)
ans ='War'
  
for z_i in range(x+1,y+1):
  if lower < z_i <= upper:
    ans ='No War'
    
print(ans)
# Judge status: Accepted
import math

x = int(input())
k = 0
p = 100

while p < x:
    p = p + int(p/100)
    k = k + 1

print(k)
# Judge status: Accepted
N = int(input())
C = list(input())
RtoW = sum(map(lambda x: x=="R",C))
WtoR = 0
ans = RtoW
for i in range(N):
    if C[i] == "R":
        RtoW -= 1
    else:
        WtoR += 1
    ans = min(ans,max(RtoW,WtoR))

print(ans)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

if A*B*C%2==0:
    print(0)
else:
    big = max([A, B, C])
    print(round(A*B*C/big))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

bef=a[0]-1
man=b[bef]

for i in a[1:]:
  ind=i-1
  if ind==bef+1:
    man+=c[bef]
  man+=b[ind]
  bef=ind
print(man)
# Judge status: Accepted
n, m = map(int, input().split())
Pre = [list(map(int, list(input().split()))) for i in range(m)]

for i in range(1, m + 1):
    Pre[i - 1].append(i)

Pre.sort()

cnt = 1
Pre[0][1] = cnt
for i in range(1,m):
    if Pre[i - 1][0] != Pre[i][0]:
        cnt = 1
        Pre[i][1] = cnt
    else:
        cnt += 1
        Pre[i][1] = cnt

Pre.sort(key=lambda x: x[2])

for i in range(m):
    print("{0:06d}{1:06d}".format(Pre[i][0],Pre[i][1]))
# Judge status: Wrong Answer
n,a,b,c,d = map(int, input().split())
s = input()

if '##' in s:
    print('No')
    exit()
else:
    if c<d:
        print('Yes')
    else:
        if '...' in s[b-1:d]:
            print('Yes')
        else:
            print('No')
# Judge status: Wrong Answer
import numpy as np

N, M = map(int, input().split())
a = [input().split() for i in range(N)]
a = [[int(i[0]), int(i[1])] for i in a]
a = np.array(a,dtype= 'int64')
a = a[a[:, 0].argsort(), :]

sum = 0
coin = 0
for item in a:
    if item[1] + sum < M:
        sum += item[1]
        coin += item[0] * item[1]
    else:
        for i in range(1, item[1] + 1):
            if sum + i == M:
                print(coin + item[0] * i)
                break
# Judge status: Accepted
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
t = 0
for i in range(N):
    if A[i] == 0:
        ans += t // 2
        t = 0
    else:
        t += A[i]
ans += t // 2
print(ans)
# Judge status: Accepted
print('ABC' if input() == 'ARC' else 'ARC')
# Judge status: Accepted
def resolve():
    H, W = [int(i) for i in input().split()]
    if min(H, W) == 1:
        print(1)
    elif (H * W) % 2 == 0:
        print(format(H * W // 2, "d"))
    else:
        print(format((H * W // 2) + 1, "d"))


resolve()
# Judge status: Accepted
o = list(input())
e = list(input())+[""]
#print(o,e)
for x,y in zip(o,e):
 print(x+y,end="")
# Judge status: Accepted
s=input()
k=int(input())
for i in range(len(s)):
    if s[i]=="1":
        k-=1
    else:
        k-=int(s[i])*(5*10**18)
    if k<=0:
        print(s[i])
        exit()
# Judge status: Wrong Answer
s=int(input())
a=s
if s in [4,2,1]:
    ans=3
else:
    ans=2
    for i in range(10**6):
        if a==1:
            break
        if a%2==0:
            a=a//2
        else:
            a=3*a+1
        ans+=1
print(ans)
# Judge status: Accepted
N = int(input())
alp = lambda c: chr(c+96)
def num(L,key):
    if len(L) == N:
        ans = [alp(a) for a in L]
        print(''.join(ans))
    else:
        for k in range(1,key+1):
            l = L + [k]
            num(l,key)
        l = L + [key+1]
        num(l, key+1)

init =[1]
num(init,1)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cp = 0
cm = 0
for i in range(N):
    if A[i]>B[i]:
        cm += A[i]-B[i]
    elif B[i]>A[i]:
        cp += (B[i]-A[i])//2
if cp>=cm:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S=input()
Q=int(input())
c=0
left=""
right=""
for i in range(Q):
    T=list(map(str,input().split()))
    if len(T)==1:
        c+=1
    else:
        if (T[1]=="1" and c%2==0) or (T[1]=="2" and c%2==1):
            left+=T[2]
        else:
            right+=T[2]

if c%2==0:
    ans=left[::-1]+S+right
else:
    ans=right[::-1]+S[::-1]+left
print(ans)
# Judge status: Accepted
if __name__ == '__main__':
    N, M = map(int, input().split())
    PY = []
    for i in range(1, M+1):
        p, y = map(int, input().split())
        PY.append((y, p, i))
    PY.sort()
    ANS = [""]*(M+1)
    P = [0]*(N+1)
    for y, p, i in PY:
        P[p] += 1
        ANS[i] = "{0:06d}".format(p) + "{0:06d}".format(P[p])
    
    for ans in ANS:
        if ans=="": continue
        print(ans)
# Judge status: Wrong Answer
import collections

S=input()
T=input()

S_list=collections.Counter(S)
S_list1=list(S_list.values())
S_list1=set(S_list1)

T_list=collections.Counter(T)
T_list1=list(T_list.values())
T_list1=set(T_list1)

if S_list1==T_list1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
b = list(map(int,input().split()))
ans = sum([min(b[i],b[i+1]) for i in range(n-2)])
ans += b[0] + b[n-2]
print(ans)
# Judge status: Accepted
x = list(map(int, input().split()))
print((x.index(0))+1)
# Judge status: Accepted
import math

n = int(input())

answer = (n - math.floor(n / 2)) / n

print(answer)

# nums = list(range(1, n + 1))
# 
# odds = [x for x in nums if x % 2 == 1]
# 
# if len(nums) % 2 == 0:
#     print(0.5)
# else:
#     print(len(odds) / len(nums))
# Judge status: Accepted
n,m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]

box = [1]*(n+1)
red = [0]*(n+1)
red[1] = 1
for x,y in xy:
    box[x] -= 1
    box[y] += 1
    if red[x]==1: red[y] = 1
    if box[x]==0: red[x] = 0
print(sum(red))
# Judge status: Accepted
N = int(input())
lis = []
for i in range(N):
    lis.append(list(map(int,input().split())))
lis = sorted(lis, key = lambda x:x[1])
a = 0
for j in range(N):
    a += lis[j][0]
    if a > lis[j][1]:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
x,y,a,b,c=map(int,input().split())
l_r=sorted(map(int,input().split()),reverse=True)[:x]
l_b=sorted(map(int,input().split()),reverse=True)[:y]
l_w=sorted(map(int,input().split()),reverse=True)

ans=[]
ans+=l_r
ans+=l_b
ans+=l_w

print(sum(sorted(ans,reverse=True)[:x+y]))
# Judge status: Wrong Answer
N = int(input())

if N <= 10**9:
  List = [0,0,0,1,N,0]
else:
  a = -(-N//(10**9))
  b = a*10**9-N
  List = [0,0,10**9,b,a,1]
  
print(*List)
# Judge status: Accepted
a = []
for i in range(3):
    a += map(int, input().split())

n = int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            a[j] = 'o'

isBingo = False
bingo = [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 4, 6]]
for elem in bingo:
    if a[elem[0]] == 'o' and a[elem[1]] == 'o' and a[elem[2]] == 'o':
        isBingo = True
        break

print('Yes') if isBingo else print('No')
# Judge status: Accepted
h,w=(int(i) for i in input().split())
if(h==1):
  print(1)
elif(w==1):
  print(1)
else:
  if(h%2==0):
    print((h//2)*w)
  else:
    print( (((h//2)+1)*w)-(w//2))
# Judge status: Wrong Answer
C = str(input())

if C[0] == C[1]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, B, T = map(int, input().split())
print(B*(T//A))
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m = map(int, input().split())
if n % 2 == 0:
    n -= 1
ans = []
left_range = n//2
right_range = n//2 - 1
left1 = 1
right1 = 1 + left_range
left2 = right1 + 1
right2 = left2 + right_range

while True:
    if left1 >= right1:
        break
    ans.append([left1, right1])
    left1 += 1
    right1 -= 1

while True:
    if left2 >= right2:
        break
    ans.append([left2, right2])
    left2 += 1
    right2 -= 1
    
for i in range(m):
    print(*ans[i])
# Judge status: Wrong Answer
s=int(input())
ans1=s//10**9+1
ans2=10**9-s%10**9
print(0,0,10**9,ans1,ans2,1)
# Judge status: Accepted
x, y = map(int, input().split())
num = 0
while x <= y:
    x *= 2
    num += 1
print(num)
# Judge status: Accepted
a, b = map(int, input().split())

c = b-a
res = sum(i for i in range(c))
print(res-a)
# Judge status: Wrong Answer
n, m = map(int, input().split())
for i in range(m//n, 0, -1):
    rem = m-m//n*n
    if rem%i==0:
        print(i)
        break
# Judge status: Accepted
a = list(map(int, input().split()))
a.sort(reverse = True)
if (a[1]+a[2])%2 ==1:
    print(int(2 + a[0]-(a[1]+a[2]+1)/2))
else:
    print(int(a[0]-(a[1]+a[2])/2))
# Judge status: Wrong Answer
X=int(input())
N=X%100
if N//5+1<=X//100:
  print('1')
else:
  print('0')
# Judge status: Accepted
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = k
i = 1
while n > s:
    s += (k-1)
    i += 1

print(i)
# Judge status: Accepted
print('Heisei'if input()[5:]<'04/31'else'TBD')
# Judge status: Accepted
N = int(input())

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

L = []
R = []

for i in range(N):
    L.append(i+1 + A[i])
    R.append(i+1 - A[i])

L.sort()
R.sort()

#print(L)
#print(R)

temp = 0
ans = 0
j = 0
for i in range(N):
    if i >= 1 and L[i] == L[i-1]:
        ans += temp
        continue
    temp = 0
    while j < N and L[i] >= R[j]:
        if L[i] == R[j]:
            temp += 1
        j += 1
    ans += temp

print(ans)
# Judge status: Wrong Answer
n = int(input())

a = []
b = []
for i in range(n):
    s = int(input())
    if s%10 == 0:
        a.append(s)
    else:
        b.append(s)

b = sorted(b,reverse = True)
if len(b) == 0:
    print(0)
elif len(b)%2 == 0:
    print(sum(a)+sum(b[:len(b)-1]))
else:
    print(sum(a)+sum(b))
# Judge status: Accepted
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [10**15+1 for i in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(1,K+1):
        if i+j<N:
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
        
print(dp[-1])
# Judge status: Accepted
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
flag = list(map(lambda x: False if x%10 == 0 else True, s))

if sum(s)%10==0:
    for i in range(n):
        if flag[i]:
            s.pop(i)
            print(sum(s))
            break
    else:
        print(0)
else:
    print(sum(s))
# Judge status: Wrong Answer
K = int(input())
import math
import itertools


def better_gcd(a,b,c):
    tup = set((a,b,c))
    kinds = len(tup)
    if kinds == 3:
        return math.gcd(a, math.gcd(b, c)) * 6
    elif kinds == 2:
        return math.gcd(*tup) * 3
    else:
        return a

ans = 0
cands = list(itertools.combinations_with_replacement(range(1,201), 3))
for c in cands:
    ans += better_gcd(*c)
print(ans)
# Judge status: Accepted
S = input()
ans = 753
for i in range(len(S)-2):
  ans = min(ans, abs(int(S[i:i+3])-753))

print(ans)
# Judge status: Wrong Answer
s=input()
if sorted(s)=='abc':
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = input()
c1, c2 = 0, 0
for i in s:
    if i == "0":
        c1 += 1
    else:
        c2 += 1
print(min(c1, c2)*2)
# Judge status: Accepted
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))

MOD = 10**9 + 7
ans = 0

for i in range(60):
    a = (A >> i) & 1
    count0 = np.count_nonzero(a)
    count1 = N - count0
    tmp = 2**i
    n = count0 * count1
    tmp = tmp * n
    ans += tmp
    ans = ans % MOD
print(ans)
# Judge status: Wrong Answer
def myAnswer(A:int,B:int,K:int) -> int:
   if(B >= K):
      ans = [i for i in range(A,A+K)]
      for i in range(B,B-K,-1):
         ans.append(i)
   else:
      ans = [i for i in range(A,B+1)]
   ans = list(set(ans))
   ans.sort()
   for a in ans:
      print(a)

   

def modelAnswer():
   tmp=1
def main():
   A,B,K = map(int,input().split())
   myAnswer(A,B,K)

if __name__ == '__main__':
   main()
# Judge status: Accepted
s = input()
ans = 0
for i in range(len(s)):
    if i % 2 ==0 :
        if s[i] == "L":
            ans += 1
    else:
        if s[i] == "R":
            ans += 1
if ans == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.append(X)
y.append(Y)
if max(x)<=min(y):
    print("No War")
else:
    print("War")
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))
sa = min(A)
ba = max(A)
ma1 = (ba + sa-1) // 2
ma2 = (ba + sa) // 2
ma3 = (ba + sa+1) // 2
ans1 = 0
ans2 = 0
ans3 = 0
for i in A:
    ans1 += (i-ma1)**2
    ans2 += (i-ma2)**2
    ans3 += (i-ma3)**2
print(min(ans1, ans2, ans3))
# Judge status: Accepted
N = int(input())
ans = N * (N + 1) // 2
ans = 2 * ans - 1
if N == 1:
    print(ans)
    exit()
for i in range(2, N // 2 + 1):
    M = N - (N % i)
    ans += (i + M) * (M // i) // 2
    ans -= i
print(ans)
# Judge status: Accepted
from itertools import product

A, B, C, D = map(int, input())

for operators in product(('+', '-'), repeat=3):
    a = A
    b = B
    c = C
    d = D
    if operators[0] == '-':
        b *= -1
    if operators[1] == '-':
        c *= -1
    if operators[2] == '-':
        d *= -1

    if a + b + c + d == 7:
        print('{}{}{}{}{}{}{}=7'.format(A, operators[0], B, operators[1], C, operators[2], D))
        break
# Judge status: Wrong Answer
n = int(input())
ws = list(map(int, input().split()))

full = sum(ws)
half = full / 2
total = 0

for i in range(n):
  total += ws[i]
  if total >= half:
    total_plus = total + ws[i + 1]
    dif = abs(total - (full - total))
    dif_plus = abs(total_plus - (full - total_plus))
    print(min(dif, dif_plus))
    exit()
# Judge status: Accepted
a,b=(int(x) for x in input().split())
sum=0
while a>0:
    a-=b
    sum+=1
print(sum)
# Judge status: Wrong Answer
n = int(input())
board = [1] * (n+1)

def divisor_num(n, board):
    for i in range(2, n+1):
        j = 1
        while i*j <= n:
            board[i*j] += 1
            j += 1

divisor_num(n, board)
res = sum([i * board[i] for i in range(1, n+1)])
print(board)
# Judge status: Wrong Answer
s=input()
t = input()
count = 0
for i in range(len(s)):
  if s[i]!=t[i]:
    count += 1
# Judge status: Wrong Answer
n,k=map(int,input().split())
s1=set()
s2=set()
for i in range(n):
    s1.add(k-i)
for j in range(n):
    s2.add(k+j)
print(" ".join(map(str,s1|s2)))
# Judge status: Accepted
s = input()

if s[-1] == 's':
    s= s + 'es'
else:
    s= s + 's'

print(s)
# Judge status: Wrong Answer
n = int(input())
Jobs = []
for i in range(n):
    Jobs.append(list(map(int, input().split())))

Jobs.sort(key=lambda x: x[1], reverse=True)
#print(Jobs)
now = Jobs[0][1]
for time, deadline in Jobs:
    if now < deadline:
        now -= time
    else:
        now = deadline
        now -= time
    #print(now)
if now < 0:
    print("NO")
else:
    print("YES")
# Judge status: Wrong Answer
num = int(input())

count_max = 0
for i in range(num):
  tmp = i + 1
  count = 0
  while tmp % 2 == 0:
    tmp = tmp / 2
    count += 1
  if count > count_max:
    count_max = count

print(count_max)
# Judge status: Wrong Answer
n = int(input())
lst = [int(i) for i in input().split()]

list.sort(lst)
lst2 = []
total = 0
for i in range(n):
  num = lst[i]
  if not lst2:
    lst2.append(num)
  if len(lst2) == 1:
    total += lst2[0]
    lst2.append(num)
  if len(lst2) == 2:
    total += lst2[1]
    lst2.pop(1)
    lst2.append(num)
print(total)
# Judge status: Accepted
def main():
    r = int(input())
    print(r ** 2)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
x = 800 * n
y = 200 * (n // 15)
print(x - y)
# Judge status: Wrong Answer
a, b, x = map(int, input().split())

# a = p * x + r, b = q * x + s と剰余を使って表す
p = a // x
q = b // x

res = p - q
print(res)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a_min = [0] * (n + 1)
a_min[n] = a[n]
for i in range(n - 1, -1, -1):
    a_min[i] = a[i] + a_min[i + 1]

b = [1]
for i in range(n):
    tmp = b[i] - a[i]
    b.append(min(tmp * 2, a_min[i + 1]))
    if tmp < 1 or tmp * 2 < a[i + 1]:
        print(-1)
        break
else:
    if n == 0:
        ans = 1 if a[0] == 1 else -1
        print(ans)
    else:
        print(sum(b))
# Judge status: Accepted
#!/usr/bin/env python3

n_list = list(map(int, input().split()))
K = int(input().split()[0])

n_list = list(sorted(n_list, reverse=True))
n = n_list[0]
for _ in range(K):
    n = n * 2
ans = n + n_list[1] + n_list[2]
print(ans)
# Judge status: Wrong Answer
from collections import Counter
import sys
x = input()
n = len(x)
a = []

for i in range(n-1):
    if x[i] == "T" and x[i+1] == "S":
        a.append(i+1)
    
a = [0] + a + [n]

ans = 0
for i in range(len(a)-1):
    q = a[i+1]-a[i]
    b = Counter(x[:q])
    ans += abs(b["S"] - b["T"])
    x = x[q:]
    
print(ans)
# Judge status: Accepted
from itertools import accumulate

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

if n == 0:
    print(1 if a[0] == 1 else - 1)
    exit()

if a[0] != 0:
    print(-1)
    exit()

b = list(accumulate(a))
v = 1
cnt = 1
for i in range(n):
    if (v - a[i]) * 2 - a[i + 1] < 0:
        print(-1)
        exit()
    v = min((v - a[i]) * 2, b[-1] - b[i])
    cnt += v
print(cnt)
# Judge status: Accepted
n=int(input())
s=input()
cnt=s[1:].count('E')
ans=cnt
for i in range(1,n):
    if s[i] == 'E':
        cnt-=1
    if s[i-1] == 'W':
        cnt += 1
    ans = min(ans,cnt)
print(ans)
# Judge status: Accepted
N,D=map(int,input().split())

ans=0
for i in range(N):
    a,b=map(int,input().split())
    temp=a**2+b**2
    if temp**0.5<=D:
        ans+=1
print(ans)
# Judge status: Accepted
N = int(input())

b = 0

while True:
    if N >= 2:
        N /= 2
        b += 1
    if N < 2:
        break

print(2 ** b)
# Judge status: Accepted
# -*- coding: utf-8 -*-

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

if 0 < a <= b:
    ans = 'Positive'
elif a <= b < 0:
    if (b - a + 1) % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'
else:
    ans = 'Zero'

print(ans)
# Judge status: Accepted
import sys


Sp = [c for c in input()]
T = [c for c in input()]

sn = len(Sp)
tn = len(T)

match_i = 51
for i in range(sn - tn + 1):
    partial = Sp[i:i+tn]
    for j in range(len(partial)):
        if partial[j] == '?':
            partial[j] = T[j]
    if partial == T:
        match_i = i

if match_i > 50:
    print('UNRESTORABLE')
    sys.exit()

Sp[match_i:match_i+tn] = T
for i in range(sn):
    if Sp[i] == '?':
        Sp[i] = 'a'
S = ''.join(Sp)

print(S)
# Judge status: Wrong Answer
N,K=map(int,input().split())
ans=0
p=list(map(int,input().split()))

p.sort()

for i in range(K):
    ans+=p[i]

    print(ans)
# Judge status: Accepted
S = input()
def check(S): #1 moji
    if S in "ATGC":
        return True
    else:
        return False

ans =0
for i in range(len(S)):
    temp = 0
    while i<len(S) and check(S[i]):
        temp+=1
        i+=1
    ans = max(ans,temp)

print(ans)
# Judge status: Accepted
n, k = list(map(int, input().rstrip().split()))
d = list(map(int, input().rstrip().split()))
ans = n
while (True):
    x = ans
    flag = 1
    while x > 0:
        r = x % 10
        x = x // 10
        if r in d:
            ans += 1
            flag = 0
            break
    if flag == 1:
        break
print(ans)
# Judge status: Wrong Answer
from math import atan
from math import degrees

a, b, x = [int(x) for x in input().split()]

volume = a * a * b
volume_per = x / volume

print(volume_per)

if volume_per >= 0.5:
    up = b * (1 - volume_per)
    down = a / 2
else:
    up = b
    down = 2 * a * volume_per

print(degrees(atan(up/down)))
# Judge status: Accepted
a, b = map(int, input().split(' '))
print(a*b)
# Judge status: Accepted
n, m = map(int, input().split())
ab = [[] for _ in range(m+1)]
for i in range(n):
  t = [int(inp) for inp in input().split()]
  if t[0] <= m:
    ab[t[0]].append(-t[1])
ans = 0
import heapq
h = ab[1]
heapq.heapify(h)
for i in range(1, m+1):
  if len(h) > 0:
    ans += heapq.heappop(h)
  if i != m:
    for t in ab[i+1]:
      heapq.heappush(h, t)
print(-ans)
# Judge status: Accepted
#!/usr/bin/env python3
m, n = map(int, input().split())
print((m * (m-1) + n * (n - 1)) // 2)