peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, L = map(int, input().split())
strs = [[]] * N
for i in range(N):
  strs[i] = str(input())
strs.sort()
print(strs)
x = strs[0]
for j in range(1,N):
   x += strs[j]
print(x)
# Judge status: Accepted

import math
import itertools
import statistics
#import numpy as np
import collections

#n = int(input())
x, y, z = list(map(int, input().split()))

x -= z
print(x//(y+z))
# Judge status: Wrong Answer
# A - Dividing a String
S = input()

arr = [S[0]]
i = 1

while i < len(S):
	s = S[i]
	
	if s == arr[-1]:
		if i + 1 < len(S):
			i += 1
			s += S[i]
		else:
			arr[-1] += s
			break
	
	arr.append(s)
	i += 1

ans = len(arr)

if arr[-1] == arr[-2]:
	ans -= 1

print(ans)
# Judge status: Wrong Answer
n=int(input())
l=list(map(int, input().split()))
x=sum(l)//n +1
ct=0
for i in l:
  ct+=(x-i)**2
print(ct)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
import collections
a = collections.Counter(A)
b = []
for i, j in a.items():
    if j >= 2:
        b.append([i,j])
b.sort(reverse=True)
if len(b) >= 1 and b[0][1] >= 4:
    print(b[0][0] ** 2)
elif len(b) >= 2:
    print(b[0][0] * b[1][0])
else:
    print(0)
# Judge status: Accepted
S = input()
print(min(S.count('0'),S.count('1'))*2)
# Judge status: Accepted
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
cnt = Counter(A)
ans = [0]
l =[]
values, counts = zip(*cnt.most_common())
for v, c in zip(values, counts):
    if c > 3:
        ans.append(v**2)
        l.append(v)
    elif c > 1:
        l.append(v)
l.sort(reverse=True)
if len(l) > 1:
    ans.append(l[0] * l[1])
print(max(ans))
# Judge status: Accepted
n,l=map(int,input().split())
print("".join(sorted([input()for i in range(n)])))
# Judge status: Accepted
x = int(input())
y = 1
for i in range(1,x):
    for j in range(2,x):
        if i**j <= x:
            y = max(y, i**j)
        else:
            break
print(y)
# Judge status: Accepted
from collections import Counter

S = input()
N = len(S)
mod = [0] * (N+1)
now = 0
for i in range(N):
    now += int(S[N-1-i]) * pow(10,i,2019) % 2019
    now %= 2019
    mod[N-i-1] = now

ans = 0
for l in Counter(mod).values():
    ans += l * (l-1) // 2
print(ans)
# Judge status: Accepted
def equ(a, b):
    if a == b:
        return 1
    else:
        return 0


s = input()
t = input()
max_equ = 0

for i in range(len(s) - len(t) + 1):
    count = 0
    for j in range(len(t)):
        count += equ(s[i + j], t[j])
    if count > max_equ:
        max_equ = count
print(len(t) - max_equ)
# Judge status: Accepted
import sys
import math
import itertools
a, b,t= map(int, input().split())
time = t + 0.5
print(int(time//a*b))
# Judge status: Wrong Answer
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    tmp = np.prod(a[:k])
    for i in range(k, n):
        if tmp < tmp//a[i-k]*a[i]:
            print('Yes')
        else:
            print('No')
        tmp = tmp//a[i-k]*a[i]    
            
if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

# 4の倍数と2の倍数を(重複しないように)カウントする
mul4, mul2 = 0, 0
for a in A:
    if a%4 == 0:
        mul4 += 1
    elif a%2 == 0:
        mul2 += 1
others = n - mul4 - mul2

if others <= mul4:  # 1, 4, 1, 4, 2, 2...
    print('Yes')
elif mul2 == 0 and others <= mul4 + 1:  # 1, 4, 1, 4, 1...
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N, M = map(int, input().split())
L = [0] * M
R = [0] * M

for i in range(M):
  L[i], R[i] = map(int,input().split())

print(max(0, min(R) - max(L) + 1))
# Judge status: Wrong Answer
h = int(input())
for i in range(1,2000):
    h //= 2
    if h == 1:break
ans = 2**(i+1)-1
print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

Alice, Bob = 0, 0
for i in a[::2]:
    Alice += i
    
for i in a[1::2]:
    Bob += i

result = Alice - Bob

print(result)
# Judge status: Accepted
import sys
import time
st = time.perf_counter()
def inpl():
    return list(map(int, input().split()))
# ------------------------------

N = int(input())
A = inpl()

s = set(A)
table = [0] * (N+1)
for i in A:
    table[i] += 1

comb = 0
for i in s:
    comb += table[i] * (table[i]-1) // 2

for i in A:
    print(comb - (table[i]-1))


# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)
# Judge status: Wrong Answer
x = int(input())
if x == 3 or x == 5 or x == 7:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b,c = input()
a = int(a)
b = int(b)
c = int(c)
if (a*b*c)%7 == 0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s=input()
t=input()

ans = 0

for i in range(len(s)):
	if s[i]!=t[i]:
		ans+=1

print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
Std = [tuple(map(int, input().split())) for _ in range(N)]
Chp = [tuple(map(int, input().split())) for _ in range(M)]
INF = 10e9
Arrv = []
Mdist = lambda x,y,u,v:abs(x-u)+abs(y-v)
for s in Std:
    close = INF
    for i in range(M):
        dist = Mdist(*s,*Chp[i])
        if dist < close:
            close = dist
            arrv = i+1
    Arrv.append(arrv)
for ar in Arrv:
    print(ar)
# Judge status: Accepted
n = int(input())

x = 1
for i in range(2,n+1):
  x = i*x % (10**9+7) 

print(x)
# Judge status: Accepted
# solution
import io

nim = int(input())
mike = [2, 1]
for i in range(100):
    mike.append(mike[-1] + mike[-2])

print(mike[nim])
# Judge status: Accepted
N,M=map(int, input().split())
H=list(map(int, input().split()))
V=[[] for _ in range(N)]
for m in range(M):
    a,b=map(int, input().split())
    a=a-1
    b=b-1
    V[a].append(b)
    V[b].append(a)
for v in V:
    v=set(v)
ans=[1]*N
tmp=0
for n in range(N):
    for v in V[n]:
        if H[n]<=H[v]:
            ans[n]=0
print(sum(ans))
# Judge status: Accepted
from collections import Counter

N = int(input())
S = input()
P = 10**9 + 7

dic = Counter(S)
rlt = 1

for k in dic:
  rlt = rlt*(dic[k]+1) % P
  
print(rlt-1)
# Judge status: Accepted
import math
N, X, T = map(int, input().split())
print(math.ceil(N/X)*T)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
total = sum(A)
left_sum = 0
ans = float('inf')
for i in range(N):
    left_sum += A[i]
    right_sum = total - left_sum
    ans = min(ans, abs(left_sum - right_sum))
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-

r = int(input())

print(r**2)
# Judge status: Wrong Answer
while True:
    s = input()
    if 1 <= len(s) <= 10:
        break

flag = False
for l in range(len(s)-2):
    if s[l]=="h" and s[l+1]=="i" and s[l+2]!="i":
        print("Yes")
        flag = True
        break
    
if flag == False:
    print("No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(len(a)):
    ans[a[i]-1]=i+1
print(*ans)
# Judge status: Wrong Answer
n=int(input())
count=0
if n//9>=1:
  count+=1
if n//6>=1:
  count+=1
count+=n%9%6
print(count)
# Judge status: Accepted
def main():
    N = int(input())
    print((N // 2) + (N % 2))
main()
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if b<=a<=c:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import math
N,M = map(int,input().split())
if(N == 1 or M == 1 or abs(N - M) >= 2):
  print("0")
else:
  if(N != M):
    print(str(((math.factorial(N) * math.factorial(M)) % (10 ** 9 + 7))))
  else:
    print(str(((math.factorial(N) * math.factorial(M))* 2 % (10 ** 9 + 7))))
# Judge status: Accepted
h1, m1, h2, m2, k = map(int, input().split())

a = (h2*60+m2)-(h1*60+m1)

if(a>k):
  print(a-k)
else :
  print(0)
# Judge status: Accepted
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
di = {}
for i in a:
    if i in di:
        di[i] += 1
    else:
        di[i] = 1
ans = 0
for i in di.values():
    ans += i%2
print(ans)
# Judge status: Accepted
import sys
S = input()
_S = 'keyence'
_N = len(_S)
for i in range(_N + 1):
    if _S[:i] == S[:i] and _S[i:] == S[len(S) - _N + i:]:
        print('YES')
        sys.exit()
print('NO')
# Judge status: Wrong Answer
n, k, q = map(int, input().split())
a = [0] * q

for i in range(q):
    a[i] = int(input())
a_copy = [0] * n

for i in a:
    a_copy[i-1] += 1
print(a)
print(a_copy)
for i in a_copy:
    if q - i < k:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
S = input()

s_list = [s for s in S]
c_list = [c for c in "abcdefghijklmnopqrstuwvxyz"]

answer = "None"
for c in c_list:
  if c not in s_list:
    answer = c
    break

print(answer)
# Judge status: Wrong Answer
n = list(map(int,input()))
a = max(n)
print(a*100 + a*10 +a)
# Judge status: Wrong Answer
a = b = 0; c = 1
for _ in range(int(input()) - 3):
  a, b, c = b, c, (a + c) % (10**9 + 7)
print(c)
# Judge status: Wrong Answer
N = int(input())
ans = 1
for i in range(1, N+1):
  ans = ans * i
  ans = ans // 1000000007

print(ans)
# Judge status: Accepted
n=int(input())
out=""
n=n-1
while n>=0 :
    out+=chr(ord("a")+n%26)
    n=n//26-1
print(out[::-1])
# Judge status: Wrong Answer
x,y=map(int,input().split())
ans=0
while x<y:
    ans+=1
    x*=2
print(ans)
# Judge status: Accepted
a = list(map(int,input().split()))
b = list(map(int,input().split()))

n = a[0]
m = a[1]
co = 0
for i in range(n):
  if b[i]>=sum(b)/(4*m):
    co = co+1
if co >= m:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
st = input()
tmp=0
rt = 0
for i in range(len(st)):
  if st[i] == "R":
    tmp+=1
    if tmp > rt:
      rt = tmp
  else:
    tmp = 0
print(rt)
# Judge status: Accepted
n = int(input())
a = [list(map(int, input().split())) for i in range(2)]

res = 0
for i in range(n):
  ans = 0
  for j in range(i+1):
    ans += a[0][j]
  for k in range(i, n):
    ans += a[1][k]
    
  res = max(ans, res)
  
print(res)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
if 10 * A + B < 10 * C + B:
  print(10 * C + B)
else:
  print(10 * A + B)
# Judge status: Accepted
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

n=int(input())
d=input_array()
d.sort()
center=int(n/2)
ans=d[center] - d[center -1] 

print(ans)
# Judge status: Accepted
S = input ()
N =700
for i in range (len(S)-2):
  n = abs (int(S[i:i+3])-753)
  if n < N:
    N = n
print (N)
# Judge status: Accepted
a,b,c=map(int, input().split())

if a==b==c:
  total=1
elif a==b:
  total=2
elif b==c:
  total=2
elif c==a:
  total=2
else:
  total=3
print(total)
# Judge status: Accepted
N = int(input())

L = [None] * (N + 1)
L[0] = 2
L[1] = 1

for i in range(2, N + 1):
    L[i] = L[i - 1] + L[i - 2]

print(L[N])
# Judge status: Wrong Answer
X,K = map(int, input().split())
max = X + K - 1
min = X - K + 1
for i in range(min,max):
    print(i,end=" ")
# Judge status: Wrong Answer
# vim: fileencoding=utf-8


def main():
    a, b = map(int, input().split())
    c = 0
    for i in range(a, b + 1):
        #     s = str(i)
        #     r = "".join(reversed(list(s)))
        #     if s == r:
        #         c += 1
        if (i % 10) == (i // 10000) and (i % 100 // 10) == (i % 10000 // 10000):
            c += 1
    print(c)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a, b, c, d = map(int, input().split())
if a <= c and c <= b and b <= d:
    print(b-c)
elif a <= c and c <= b and d <= b:
    print(d-c)
elif c <= a and b <= d:
    print(b-a)
elif c <= a and a <= d and d <= b:
    print(d-a)
else:
    print(0)
# Judge status: Wrong Answer
s = input()
t = input()
ls = len(s)
lt = len(t)
s = s[ls::-1]
t = t[lt::-1]
cnt = 0
idx = -1

for i in range(ls):
    if s[i] == t[cnt] or s[i] == "?":
        cnt += 1
        if cnt == lt:
            idx = i-lt+1
            break
    else:
        cnt = 0

if idx == -1:
    ans = "UNRESTORABLE"
else:
    r = s[:idx]+t+s[idx+lt:]
    ans = (r[ls::-1]).replace("?","a")

print(ans)
# Judge status: Accepted
n,k = map(int,input().split())
d = input().split()

while True:
    s = str(n)
    f = 1
    for i in range(len(s)):
        if s[i] in d:
            f = 0
        else:
            pass

    if f:
        print(s)
        break
    else:
        n += 1
# Judge status: Accepted
W, H, x, y = map(float, input().split())

center_x = W / 2
center_y = H / 2

area = W * H / 2

if center_x == x and center_y == y:
    print(f"{area} 1")
else:
    print(f"{area} 0")
# Judge status: Accepted

def updiv(a,b):
    if a % b == 0:
        return a // b
    else:
        return a // b + 1

H = int(input())
W = int(input())
N = int(input())

print (updiv(N , max(H,W)))
# Judge status: Accepted
x=int(input())
print(x//11*2+(x%11+5)//6)
# Judge status: Accepted
n,m = map (int, input ().split ())
l = []
for i in range (m):
  a,b = map (int, input ().split ())
  l.append (a)
  l.append (b)
for i in range (n):
  print (l.count (i+1))
# Judge status: Wrong Answer
s = input()
t = input()
S = len(set(s))
T = len(set(t))

if S == T:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n, m = map(int, input().split())

s = [0] * n
s[0] = 1
b = [1] * n
for i in range(m):
    x, y = map(int, input().split())
    b[x-1] -= 1
    b[y-1] += 1

    s[y-1] = int(b[x-1] != 0)
    s[y-1] = int(s[x-1] == 1)

ans = 0
for i in range(n):
    if s[i] and b[i]:
        ans += 1

print(ans)
# Judge status: Wrong Answer
S = input()
N = len(S)
a = []
for i in range(N):
    if S[i] in a:
        print('No')
        exit()
    else:
        a.append(S[i])
print('Yes')
# Judge status: Accepted
n = int(input())
H = list(map(int,input().split()))
flag = False
ans = 0
for i in range(n):
    if flag:
        if m >= H[i]:
            m = H[i]
            cnt += 1
        else:
            ans = max(ans,cnt)
            m = H[i]
            cnt = 0
    else:
        m = H[i]
        flag = True
        cnt = 0
print(max(ans,cnt))
# Judge status: Accepted
from collections import Counter
n = int(input())
a = Counter([int(input()) for i in range(n)])

cnt = 0
for k, v in a.items():
  if v % 2 == 1:
    cnt += 1
print(cnt)
# Judge status: Wrong Answer
def calc(a: int) -> int:
  print(a+a*a+a*a*a)
# Judge status: Accepted
x = list(map(int, input().split()))
for i in range(5):
  if x[i] == 0:
    print(i+1)
# Judge status: Accepted
a=list(map(int,input().split()))
print('YES' if (a[1]*10+a[2])%4==0 else 'NO')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
s = input()
if s == 'SUN':
    print('7')
if s == 'MON':
    print('6')
if s == 'TUE':
    print('5')
if s == 'WED':
    print('4')
if s == 'THU':
    print('3')
if s == 'FRI':
    print('2')
if s == 'SAT':
    print('1')
# Judge status: Wrong Answer
n = int(input())
v = sorted(list(map(int,input().split())))
s = [0]*n
s[0] = v[0]

for i in range(n-1):
    s[i+1] = (v[i+1]+s[i])/2
print(s)
# Judge status: Wrong Answer
import numpy as np
import sys
f = sys.stdin
n = int(f.readline())
h = list(map(int, f.readline().split()))
h = np.array(h)
dp = np.zeros(n, int)
for i in range(n - 1):
    np.minimum(
        dp[1:-1] + np.abs(h[2:] - h[1:-1]), dp[:-2] + np.abs(h[2:] - h[:-2]), out=dp[2:]
    )
print(dp[-1])
# Judge status: Accepted
k,x = map(int,input().split())
ans = []
for i in range(x-k+1,x+k):
    ans.append(i)
print(*ans)
# Judge status: Accepted
A = [int(x) for x in input().split()]
a = list(sorted(A))
print("Yes" if A[2] == a[1] else "No")
# Judge status: Accepted
k,a,b=map(int,input().split())
if b-a<=2:
  print(k+1)
else:
  if k<a+1:
    print(k+1)
  else:
    x=(k-a-1)//(2)
    y=k-a-1-x*(2)
    print((b-a)*(x)+b+y)
# Judge status: Accepted
a, b, x = list(map(int, input().split()))
print(b//x-(a-1)//x)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
sa = sorted(a)
r, ans = 0, 0
for l in range(n):
    cnt = 0
    while r < n and abs(sa[r] - sa[l]) <= 2:
        cnt += 1
        r += 1

    ans = max(ans, cnt)
    if l == r:
        r += 1
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

far = 0

cnt = [0 for i in range(N)]

for i in range(1, N):
    if D[i] == 0:
        print(0)
        exit()

    cnt[D[i]] += 1
    far = max(D[i], far)

ans = 1

for i in range(1, far):
    ans *= cnt[i] ** cnt[i + 1]

print(ans % 998244353)
# Judge status: Accepted
n = int(input())
t = n // 10
n -= t*10
if t==9:
    print('Yes')
elif n == 9:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
# simply use double ifs
s = input()
print(chr(ord(s)+1))
# Judge status: Accepted
K, A, B = map(int, input().split())
if A+1>= B:
  ans = K+1
else:
  if K-A-1 < 0:
    n = 0
    ans = K+1
  else:
    n = (K-A-1)//2
    m = (K-A-1)%2
    ans = n*(B-A) + m + B
print(ans)
# Judge status: Wrong Answer
def cin():  return list(map(int,input().split()))

S = input()
T = input()

ans = 10 ** 9 + 7
l1 = len(S)
l2 = len(T)
for i in range(l1 - l2):
    cnt = 0
    for j in range(l2):
        if S[i + j] != T[j]:  cnt += 1
    ans = min(ans, cnt)
print(ans)
# Judge status: Accepted
a = input()
b = input()
f = 0
for i in range(3):
  if a[i] != b[2-i]:
    print('NO')
    f = 1
    break
if f == 0:
  print('YES')
# Judge status: Wrong Answer
#ABC129
p,q,r = map(int,input().split())
print(min(p+r,r+q))
# Judge status: Accepted
n, x = map(int, input().split())
(*l,) = map(int, input().split())
a = [0]
for i in l:
    if a[-1] + i > x:
        break
    a.append(a[-1] + i)
print(len(a))
# Judge status: Accepted
n = input()	
print("Yes" if "9" in n else "No")
# Judge status: Accepted
n, m = map(int, input().split())
if n >= m//2:
    print(m//2)
else:
    m2 = m - 2*n
    print(n + m2//4)
# Judge status: Accepted
s = input()
t = input()
if len(t) == len(s) +1 and s[:] == t[:-1]:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N=int(input())
H=list(map(int,input().split()))
hlow=[H[i]-1 for i in range(N)]
a=[hlow[0]]
flag=True
for i in range(N):
    if a[i-1]<=hlow[i]:
        a.append(hlow[i])
    elif a[i-1]<=H[i]:
        a.append(H[i])
    else:
        print('No')
        flag=False
        break

if flag:
    print('Yes')
# Judge status: Accepted
X, Y = map(int, input().split())
ans = 10**18
for i in [True, False]:
    for j in [True, False]:
        x, y = X, Y
        tot = 0
        if i: x = -x; tot += 1
        if j: y = -y; tot += 1
        if x <= y:
            ans = min(ans, tot+(y-x))
print(ans)
# Judge status: Accepted
n,m = map(int, input().split())

ans = 0
M = m//2
ans += min(n,M)
if min(n,M) == n:
  m -= n*2
  ans += m//4
print(ans)
# Judge status: Accepted
l,r=map(int,input().split())
ans=10**15
for i in range(l,min(r,l+2100)):
  for j in range(i+1,min(r+1,l+2100)):
    ans=min(ans,(i*j)%2019)

print(ans)
# Judge status: Wrong Answer
D, T, S = map(int, input().split())
if S*T < T:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
N=(input())
num=[0]*len(N)

for i in range(len(N)-3):
    if int(N[i:i+4])%2019==0:
        num[i+3]+=1+num[i-1]

for i in range(len(N)-4):
    if int(N[i:i+5])%2019==0:
        num[i+4]+=1+num[i-1]

for i in range(len(N)-5):
    if int(N[i:i+6])%2019==0:
        num[i+5]+=1+num[i-1]
        


print(num)
print(sum(num))
# Judge status: Wrong Answer
n=int(input())
 
for i in range(10**18):
 a=(int(n*(1+0.01)))**(i-1)
 if a>=n:
  print(i+1)
  exit()
# Judge status: Accepted
import sys
import math


def main():
    N = int(sys.stdin.readline().rstrip())

    sum_ = 0

    for i in range(1, int(math.sqrt(N)) + 1):

        sum_ += i**2

        k1 = N // i
        # k2 = i

        k1_sum = k1 * (k1 + 1) // 2
        k2_sum = i * (i + 1) // 2
        sum_ += 2 * i * (k1_sum - k2_sum)

    print(sum_)


main()
# Judge status: Wrong Answer
N = int(input())

count=0

for i in range(N//7+1):
  temp = N - i*7
  if temp == 0:
    print("Yes")
  elif temp >0:
    for j in range((N-7*i)//4+1):
      tempJ = temp - j*4
      if tempJ == 0:
        print("Yes")
      elif tempJ >0:
        continue
      else:
        print("No")
  else:
      print("No")
# Judge status: Accepted
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n) + out
        X_dumy = int(X_dumy / n)
    return out

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

print(len(Base_10_to_n(N, K)))
# Judge status: Wrong Answer
n = int(input())
s = input()
x = 0
y = 0
for i in range(n):
    if s[i] == 'I':
        y += 1
    else:
        y -= 1
    if y > 0:
        x = y
print(x)
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))

lower = min(X)
upper = max(X)

min_shouhi = 0
asn_zahyou = 0
for zahyou in range(lower, upper):
    shouhi = 0
    for i in range(N):
        shouhi += (X[i] - zahyou)**2
    
    if zahyou == lower:
        min_shouhi = shouhi
        asn_zahyou = zahyou
    else:
        if min_shouhi > shouhi:
            min_shouhi = shouhi
            asn_zahyou = zahyou

print(min_shouhi)
# Judge status: Wrong Answer
def main():
  x = input()
  if(x[2] == x[3]):
    if(x[4] == x[5]):
      print("Yes")
  else:
    print("No")
    
if __name__ == 'main':
  main()
# Judge status: Accepted
n = int(input())
v = [int(x) for x in input().split()]

v.sort()

ans = v[0]
for i in range(1, n):
    ans += 2**(i - 1) * v[i]
    
print(ans / 2**(n - 1))
# Judge status: Accepted
n = int(input())
l = [[0]*3 for i in range(n)]

for i in range(n - 1):
    c, s, f = map(int, input().split())
    l[i][0] = c
    l[i][1] = s
    l[i][2] = f

for i in range(n - 1):
    t = 0
    for j in range(i, n - 1):
        t = max(l[j][1], t)
        mod = abs(t - l[j][1])%l[j][2]
        if mod != 0:
            t += l[j][2] - mod
        t += l[j][0]
    print(t)

print(0)
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
print("delicious" if b < a else ("safe" if b <= (a + x) else "dangerous"))
# Judge status: Accepted
S = input()

if S[0] == S[1] == S[2]:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
n = int(input())
s = input()

m = map(
  lambda x: chr((ord(x) - ord('A') + n) % 26 + ord('A')), list(s))
print(''.join(list(m)))
# Judge status: Accepted
X = int(input())
if X in set([3,5,7]):
    print('YES')
else:
    print('NO')
# Judge status: Accepted
n = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
if max(L) < sum(L[1:]):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
    s = open(0).read()
    b = s.count('-')
    _, *c, = map(int, s.replace('-', '').split())
    z = c.count(0)
    d = min(c)
    e = sum(c)

    if b % 2 == 0 or z > 0:
        print(e)
    else:
        print(e - 2 * d)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    kyori = abs(x - x0) + abs(y - y0)
    time = abs(t0 - t)
    if abs(kyori - time) % 2 == 0 and time - kyori >= 0:
        t0, x0, y0 = t, x, y
    else:
        print('No')
        exit(0)
print('Yes')
# Judge status: Accepted
def f(W):
    if len(set(W)) != len(W):
        return False
    return all(w1[-1] == w2[0] for w1, w2 in zip(W, W[1:]))

N = int(input())
W = tuple(input() for _ in range(N))
print('Yes' if f(W) else 'No')
# Judge status: Wrong Answer
def collatz(x):
  ret=[]
  while(x>1):
    if(x%2):
      x=3*x+1
    else:
      x/=2
    ret.append(x)
  return ret

print(len(collatz(int(input())))+2)
# Judge status: Accepted
a,b=input().split()
c = int(a+b)
for i in range(1, 350):
  if c == i*i:
    print('Yes')
    exit()
print('No')
# Judge status: Accepted
S = input()
from collections import defaultdict
dic = defaultdict(int)

for s in S:
    dic[s] += 1
print('Yes' if len(dic)==2 and dic[s[0]]==2 else 'No')
# Judge status: Accepted
[a, b] = list(map(int, input().split()))

if (a+b)%2 == 0:
  ave = (a+b)/2
else:
  ave = (a+b+1)/2

print(int(ave))
# Judge status: Accepted
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    k=INT()
    d=max(a,b,c)
    e=d*(2**k)
    ans=a+b+c+e-d
    print(ans)
    
if __name__ == '__main__':
    do()