AtCoder Beginner Contest 096 - Maximum Sum

There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:
 - Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard after K operations?

-----Constraints-----
 - A, B and C are integers between 1 and 50 (inclusive).
 - K is an integer between 1 and 10 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
A B C
K

-----Output-----
Print the largest possible sum of the integers written on the blackboard after K operations by E869220.

-----Sample Input-----
5 3 11
1

-----Sample Output-----
30

In this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.

There are three choices:  
 - Double 5: The integers written on the board after the operation are 10, 3, 11.
 - Double 3: The integers written on the board after the operation are 5, 6, 11.
 - Double 11: The integers written on the board after the operation are 5, 3, 22.
If he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.

Source: atcoder | Difficulty: EASY


Solutions:
a = list(map(int, input().split()))
k = int(input())
a.sort()
print(a[0] + a[1] + 2 ** k * a[2])


n = list(map(int, input().split()))
print(max(n) * (2 ** int(input()) - 1) + sum(n))


(a, b, c) = map(int, input().split())
n = int(input())
(a, b, c) = sorted([a, b, c])
print(a + b + c * 2 ** n)


(a, b, c) = sorted(map(int, input().split()))
print(a + b + pow(2, int(input())) * c)


(a, b, c) = map(int, input().split())
k = int(input())
x = max(a, b, c)
y = a + b + c - x
print(y + x * 2 ** k)


A = sorted(list(map(int, input().split())))
N = int(input())
A[-1] = A[-1] * 2 ** N
print(sum(A))


(A, B, C) = sorted(map(int, input().split()))
print(A + B + C * pow(2, int(input())))


A = list(map(int, input().split()))
K = int(input())
print(max(A) * 2 ** K + sum(A) - max(A))


(A, B, C) = map(int, input().split())
K = int(input())
if max(A, B, C) == A:
	A *= 2 ** K
elif max(A, B, C) == B:
	B *= 2 ** K
else:
	C *= 2 ** K
print(A + B + C)


(a, b, c) = map(int, input().split())
k = int(input())
m = max(a, b, c)
print(a + b + c - m + m * 2 ** k)


(*l, k) = map(int, open(0).read().split())
print(sum(l) + max(l) * ~-2 ** k)


a = list(map(int, input().split()))
k = int(input())
print(sum(a) - max(a) + max(a) * 2 ** k)


l = list(map(int, input().split()))
k = int(input())
print(sum(l) + max(l) * ((1 << k) - 1))


a = sorted(list(map(int, input().split())))
k = int(input())
print(a[2] * 2 ** k + a[0] + a[1])


abc = list(map(int, input().split()))
k = int(input())
abc.sort()
print(sum(abc[:2], abc[-1] * 2 ** k))


(a, b, c) = map(int, input().split())
k = int(input())
print(a + b + c + max(a, b, c) * (2 ** k - 1))


(a, b, c) = sorted(map(int, input().split()))
k = int(input())
print(a + b + c * 2 ** k)


(A, B, C) = sorted([int(i) for i in input().split()])
K = int(input())
print(A + B + C * 2 ** K)


L = list(map(int, input().split()))
K = int(input())
print(max(L) * 2 ** K + sum(L) - max(L))


(A, B, C) = map(int, input().split())
S = int(input())
if A > B > C or A > C > B:
	for i in range(S):
		A = A * 2
	print(A + B + C)
elif B > A > C or B > C > A:
	for i in range(S):
		B = B * 2
	print(A + B + C)
else:
	for i in range(S):
		C = C * 2
	print(A + B + C)


List = list(map(int, input().split()))
K = int(input())
sort = sorted(List)
for i in range(K):
	sort[-1] = sort[-1] * 2
print(sum(sort))


A = list(map(int, input().split()))
K = int(input())
A.sort()
print(A[0] + A[1] + A[2] * 2 ** K)


(A, B, C) = map(int, input().split())
K = int(input())
n_list = [A, B, C]
x = max(n_list)
n_list.append(x * 2 ** K)
n_list.remove(x)
print(sum(n_list))


a = list(map(int, input().split()))
k = int(input())
a.sort()
print(sum(a[:-1]) + a[-1] * 2 ** k)


n = sorted(map(int, input().split()))
print(n[0] + n[1] + n[2] * 2 ** int(input()))


A = sorted(list(map(int, input().split())))
A[2] *= 2 ** int(input())
print(sum(A))


A = list(map(int, input().split()))
K = int(input())
for i in range(K):
	max_A = max(A)
	A.append(max_A * 2)
	A.remove(max_A)
print(sum(A))


(A, B, C) = map(int, input().split())
K = int(input())
m = max(A, B, C)
print(2 ** K * m + (A + B + C - m))


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):

	def assertIO(self, input, output):
		(stdout, stdin) = (sys.stdout, sys.stdin)
		(sys.stdout, sys.stdin) = (StringIO(), StringIO(input))
		resolve()
		sys.stdout.seek(0)
		out = sys.stdout.read()[:-1]
		(sys.stdout, sys.stdin) = (stdout, stdin)
		self.assertEqual(out, output)

	def test_入力例_1(self):
		input = '5 3 11\n1'
		output = '30'
		self.assertIO(input, output)

	def test_入力例_2(self):
		input = '3 3 4\n2'
		output = '22'
		self.assertIO(input, output)

def resolve():
	I = list(map(int, input().split()))
	K = int(input())
	for i in range(K):
		t = max(I)
		I.remove(t)
		I.append(t * 2)
	print(sum(I))

def __starting_point():
	resolve()
__starting_point()


(a, b, c) = sorted(map(int, input().split()), reverse=True)
print(2 ** int(input()) * a + b + c)


lis = list(map(int, input().split()))
a = int(input())
lis.sort(reverse=True)
for i in range(a):
	lis[0] *= 2
print(sum(lis))


a = sorted(map(int, input().split()))[::-1]
print(a[0] * 2 ** int(input()) + sum(a) - a[0])


a = list(map(int, input().split()))
print(sum(a) + (2 ** int(input()) - 1) * max(a))


n = list(map(int, input().split()))
k = int(input())
for _ in range(k):
	n[n.index(max(n))] *= 2
print(sum(n))


A = list(map(int, input().split()))
K = int(input())
for _ in range(K):
	A[A.index(max(A))] *= 2
print(sum(A))


abc = list(map(int, input().split()))
k = int(input())
for i in range(k):
	abc.sort()
	abc[2] *= 2
print(sum(abc))


x = sorted(map(int, input().split()))
k = int(input())
print(x[0] + x[1] + x[2] * 2 ** k)


lst = input().split()
K = int(input())
for i in range(3):
	lst[i] = int(lst[i])
print(sum(lst) + max(lst) * (2 ** K - 1))


a = sorted([int(i) for i in input().split()])
k = int(input())
a[-1] *= 2 ** k
print(sum(a))


l = list(map(int, input().split()))
print(sum(l) - max(l) + max(l) * 2 ** int(input()))


(a, b, c) = map(int, input().split())
k = int(input())
m = max(a, b, c)
for i in range(k):
	m *= 2
print(sum([a, b, c]) - max(a, b, c) + m)


l = list(map(int, input().split()))
k = int(input())
l.sort()
print(l[2] * 2 ** k + l[0] + l[1])


l = [int(_) for _ in input().split()]
k = int(input())
print(max(l) * 2 ** k + sum(l) - max(l))


l = sorted(map(int, input().split()))
print(l[0] + l[1] + l[2] * 2 ** int(input()))


K = list(map(int, input().split()))
t = int(input())
print(sum(K) - max(K) + max(K) * 2 ** t)


a = [int(i) for i in input().split()]
k = int(input())
sum_a = sum(a)
ans = sum_a - max(a) + max(a) * 2 ** k
print(ans)


(a, b, c) = map(int, input().split())
n = int(input())
print(a + b + c + max(a, b, c) * 2 ** n - max(a, b, c))


A = list(map(int, input().split()))
k = int(input())
m = max(A)
print(m * 2 ** k + sum(A) - m)


(A, B, C) = map(int, input().split())
K = int(input())
X = sorted([A, B, C])
for _ in range(K):
	X[-1] *= 2
print(sum(X))


a = list(map(int, input().split()))
m = max(a)
print(sum(a) - m + m * 2 ** int(input()))


num = list(map(int, input().split()))
k = int(input())
print(max(num) * (2 ** k - 1) + sum(num))


(*a, b) = map(int, open(0).read().split())
print(sum(a) + max(a) * (2 ** b - 1))


def ans096(A: int, B: int, C: int, K: int):
	int_list = [A, B, C]
	int_list.sort()
	third = int_list[-1]
	for i in range(K):
		third *= 2
	return int_list[0] + int_list[1] + third
(A, B, C) = map(int, input().split())
K = int(input())
print(ans096(A, B, C, K))


import sys
lines = [s.rstrip('\n') for s in sys.stdin.readlines()]
num_list = [int(num) for num in lines.pop(0).split(' ')]
(k,) = [int(num) for num in lines.pop(0).split(' ')]
m = max(num_list)
ans = sum(num_list) - m + m * 2 ** k
print(ans)


l = list(map(int, input().split()))
n = int(input())
ls = sorted(l)
print(ls[0] + ls[1] + ls[2] * 2 ** n)


p = input
(*x,) = map(int, p().split())
print(sum(x) + max(x) * (2 ** int(p()) - 1))


A = list(map(int, input().split()))
K = int(input())
A.sort()
A[2] = A[2] * 2 ** K
print(sum(A))


N_List = list(map(int, input().split()))
N = int(input())
maxN = max(N_List)
print(sum(N_List) - maxN + maxN * 2 ** N)


p = input
a = [int(i) for i in p().split()]
m = max(a)
print(sum(a) - m + m * 2 ** int(p()))


(a, b, c) = sorted(map(int, input().split()))
K = int(input())
print(2 ** K * c + a + b)


A = sorted(list(map(int, input().split())))
print(A[-1] * 2 ** int(input()) + A[0] + A[1])


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

def I():
	return int(input())

def F():
	return float(input())

def SS():
	return input()

def LI():
	return [int(x) for x in input().split()]

def LI_():
	return [int(x) - 1 for x in input().split()]

def LF():
	return [float(x) for x in input().split()]

def LSS():
	return input().split()

def resolve():
	ABC = LI()
	K = I()
	ABC.sort()
	ans = sum(ABC[:2]) + ABC[2] * 2 ** K
	print(ans)

def __starting_point():
	resolve()
__starting_point()


x = list(map(int, input().split()))
print(sum(x) + max(x) * (2 ** int(input()) - 1))


def main():
	A = list(map(int, input().split()))
	K = int(input())
	A.sort()
	A.append(A.pop() * 2 ** K)
	print(sum(A))

def __starting_point():
	main()
__starting_point()


(l, k) = open(0)
l = list(map(int, l.split()))
print(sum(l) + max(l) * (2 ** int(k) - 1))


N = list(map(int, input().split()))
K = int(input())
print(sum(N) + max(N) * (2 ** K - 1))


b = list(map(int, input().split()))
k = int(input())
print(sum(b) + max(b) * (2 ** k - 1))


a = list(map(int, input().split()))
a.sort()
a[2] = a[2] * 2 ** int(input())
print(sum(a))


(a, b, c) = list(map(int, input().split()))
k = int(input())
print(a + b + c - max(a, b, c) + max(a, b, c) * pow(2, k))


l = list(map(int, input().split()))
k = int(input())
num = max(l)
l.remove(num)
for i in range(k):
	num = num * 2
print(sum(l) + num)


a = list(map(int, input().split()))
b = int(input())
print(sum(a) - max(a) + max(a) * 2 ** b)


A = sorted(map(int, input().split()))
print(sum(A[:2]) + A[-1] * 2 ** int(input()))


li = [int(x) for x in input().split()]
k = int(input())
print(max(li) * 2 ** k + sum(li) - max(li))


A = sorted([int(i) for i in input().split()])
k = int(input())
print(A[0] + A[1] + A[2] * 2 ** k)


l = sorted(list(map(int, input().split())))
k = int(input())
print(l[0] + l[1] + l[2] * 2 ** k)


(num1, num2, num3) = map(int, input().split())
count = int(input())
max_num = max(num1, max(num2, num3))
sum_num = num1 + num2 + num3 - max_num
end_num = max_num
for i in range(count):
	end_num *= 2
print(sum_num + end_num)


l = list(map(int, input().split()))
k = int(input())
l.sort(reverse=True)
for i in range(k):
	l[0] *= 2
print(sum(l))


(m, *A) = sorted([int(x) for x in input().split()], reverse=True)
K = int(input())
print(m * 2 ** K + sum(A))


(A, B, C) = list(map(int, input().split()))
K = int(input())
Numbers = [A, B, C]
Numbers.sort(reverse=True)
for i in range(K):
	twice = Numbers[0] * 2
	Numbers[0] = twice
print(sum(Numbers))


a = list(map(int, input().split()))
k = int(input())
b = max(a)
for i in range(k):
	b *= 2
print(sum(a) - max(a) + b)


(a, b, c) = map(int, input().split())
k = int(input())
x = max(a, b, c)
if x == a:
	print(a * 2 ** k + b + c)
elif x == b:
	print(a + b * 2 ** k + c)
else:
	print(a + b + c * 2 ** k)


s = sorted(list(map(int, input().split())))
print(s[0] + s[1] + s[2] * 2 ** int(input()))


L = sorted(list(map(int, input().split())))
k = int(input())
L[-1] = L[-1] * 2 ** k
print(sum(L))


a = [int(i) for i in input().split()]
k = int(input())
a.sort()
print(a[2] * 2 ** k + a[0] + a[1])


a = list(map(int, input().split()))
k = int(input())
c = max(a[0], a[1], a[2])
b = a[0] + a[1] + a[2]
b = b - c
for i in range(0, k):
	c = c * 2
print(b + c)


ABC = sorted(map(int, input().split()))
K = int(input())
print(ABC[0] + ABC[1] + ABC[2] * 2 ** K)


X = list(map(int, input().split()))
K = int(input())
X.sort()
for i in range(K):
	X[-1] = X[-1] * 2
print(sum(X))


a = list(map(int, input().split()))
n = int(input())
print(sum(a) + max(a) * 2 ** n - max(a))


l = list(map(int, input().split()))
k = int(input())
d = max(l)
e = d * 2 ** k
l.remove(max(l))
l.append(e)
print(sum(l))


x = [int(i) for i in input().split()]
x.sort()
n = int(input())
print(x[2] * 2 ** n + x[0] + x[1])


L = sorted(map(int, input().split()))
k = int(input())
print(L[0] + L[1] + L[2] * 2 ** k)


r = list(map(int, input().split()))
k = int(input())
l = max(r)
print(sum(r) - l + l * 2 ** k)


a = sorted(list(map(int, input().split())))
k = int(input())
print(sum(a[:-1]) + 2 ** k * a[-1])


(a, b, c) = map(int, input().split())
k = int(input())
m = max(a, b, c)
print(m * (1 << k) + a + b + c - m)


def resolve():
	a = list(map(int, input().split()))
	k = int(input())
	a.sort()
	for i in range(k):
		a[2] = a[2] * 2
	print(sum(a))
resolve()


(A, B, C) = sorted(map(int, input().split()))
K = int(input())
print(A + B + C * 2 ** K)


(A, B, C) = map(int, input().split())
K = int(input())
print(sum([A, B, C]) + max(A, B, C) * 2 ** K - max(A, B, C))


a = sorted(map(int, input().split()))
print(sum(a) + max(a) * (2 ** int(input()) - 1))


(a, b, c, K) = map(int, open(0).read().split())
m = max(a, b, c)
print(m * 2 ** K + a + b + c - m)


nums = sorted(list(map(int, input().split())), reverse=True)
K = int(input())
print(nums[0] * 2 ** K + nums[1] + nums[2])


L = list(map(int, input().split()))
K = int(input())
N = sorted(L)
print(N[0] + N[1] + N[2] * 2 ** K)


l = list(map(int, input().split()))
k = int(input())
i = l.index(max(l))
m = l[i]
del l[i]
l.append(m * 2 ** k)
print(sum(l))


import heapq
val = list(map(lambda x: -int(x), input().split()))
K = int(input())
heapq.heapify(val)
for i in range(K):
	v = heapq.heappop(val)
	heapq.heappush(val, v * 2)
print(-sum(val))


(A, B, C) = [int(i) for i in input().split()]
K = int(input())
m = max(A, B, C)
print(sum([A, B, C]) - m + m * 2 ** K)


A = [int(x) for x in input().split()]
K = int(input())
A.sort()
A[-1] *= 2 ** K
print(sum(A))


A = list(map(int, input().split()))
K = int(input())
ans = sum(A)
ans += max(A) * (2 ** K - 1)
print(ans)


X = list(map(int, input().split()))
K = int(input())
print(sum(X) + max(X) * (2 ** K - 1))


(a, b, c) = map(int, input().split())
k = int(input())
l = [a, b, c]
l.sort()
print(l[-1] * 2 ** k + sum(l[:-1]))


(A, B, C) = map(int, input().split())
K = int(input())
M = max(A, B, C)
print(A + B + C + M * (-1 + 2 ** K))


abc = list(map(int, input().split()))
k = int(input())
mx = abc.pop(abc.index(max(abc)))
print(mx * pow(2, k) + sum(abc))


(a, b, c) = map(int, input().split())
k = int(input())
d = max(a, b, c)
print(a + b + c - d + d * 2 ** k)


a = list(map(int, input().split()))
d = int(input())
a.sort()
print(a[0] + a[1] + a[2] * 2 ** d)


(a, s, d) = map(int, input().split())
n = int(input())
print(a + s + d - max(a, s, d) + max(a, s, d) * 2 ** n)


li = list(map(int, input().split()))
print(sum(li) - max(li) + max(li) * 2 ** int(input()))


L = list(map(int, input().split()))
k = int(input())
print(max(L) * 2 ** k - max(L) + sum(L))


a = [int(x) for x in input().split()]
k = int(input())
print(sum(a) - max(a) + max(a) * 2 ** k)


list_abc = sorted([int(i) for i in input().split()])
k = int(input())
print(list_abc[2] * 2 ** k + sum(list_abc[:2]))


(A, B, C) = map(int, input().split())
K = int(input())
a = max(A, B, C)
b = A + B + C - a
print(b + a * 2 ** K)


x = list(map(int, input().split()))
for i in range(int(input())):
	x.sort()
	x[-1] = x[-1] * 2
print(sum(x))


l = [int(x) for x in input().split()]
k = int(input())
m = max(l)
l.remove(max(l))
for i in range(k):
	m *= 2
print(sum(l) + m)


abc = sorted(map(int, input().split()))
abc[2] *= 2 ** int(input())
print(sum(abc))


x = list(map(int, input().split()))
x.sort()
print(x[0] + x[1] + x[2] * 2 ** int(input()))


l = list(map(int, input().split()))
k = int(input())
for i in range(k):
	a = max(l)
	i = l.index(a)
	l[i] = l[i] * 2
print(sum(l))


A = list(map(int, input().split()))
print(sum(A) + max(A) * (2 ** int(input()) - 1))


A = list(map(int, input().split()))
K = int(input())
B = sorted(A)
print(B[0] + B[1] + B[2] * 2 ** K)


(a, b, c) = list(map(int, input().split()))
K = int(input())
m = max(a, b, c)
print(a + b + c + (2 ** K - 1) * m)


(A, B, C) = map(int, input().split())
N = int(input())
S = max(A, B, C)
SS = S * 2 ** N
print(SS + A + B + C - S)


n = sorted(list(map(int, input().split())))
k = int(input())
print(n[2] * 2 ** k + n[1] + n[0])


argList = list(map(int, input().split()))
k = int(input())
print(sum(argList) - max(argList) + max(argList) * 2 ** k)


a = sorted(list(map(int, input().split())))
n = int(input())
print(a[0] + a[1] + a[2] * 2 ** n)


(a, b, c) = map(int, input().split())
d = int(input())
e = max(a, b, c)
f = a + b + c + e * 2 ** d - e
print(f)


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(a, b, c) = sorted(Input())
	k = int(input())
	for i in range(k):
		c *= 2
	print(a + b + c)
main()


(a, b, c) = map(int, input().split())
k = int(input())
t = max(a, b, c)
print(a + b + c + t * 2 ** k - t)


ABC = list(map(int, input().split()))
K = int(input())
print(max(ABC) * (2 ** K - 1) + sum(ABC))


a = sorted(map(int, input().split()))
k = int(input())
a[2] = a[2] * 2 ** k
print(sum(a))


ABC = [int(_) for _ in input().split()]
K = int(input())
ABC = sorted(ABC)
ret = ABC[2]
for i in range(K):
	ret = ret * 2
ret += sum(ABC[:2])
print(ret)


(A, B, C, K) = map(int, open(0).read().split())
print(A + B + C + max(A, B, C) * 2 ** K - max(A, B, C))


(A, B, C) = map(int, input().split())
X = max(A, B, C)
print(X * 2 ** int(input()) + (A + B + C - X))


s = list(map(int, input().split()))
k = int(input())
s.sort()
m = 1
m *= s[2] * 2 ** k
print(m + s[0] + s[1])


x = list(map(int, input().split()))
k = int(input())
print(max(x) * 2 ** k + sum(x) - max(x))


(A, B, C) = map(int, input().split())
Max = max(A, B, C)
K = int(input())
Max *= 2 ** K
print(min(A + B + Max, A + Max + C, Max + B + C))


num_list = list(map(int, input().split()))
k = int(input())
max = 0
index = -1
for i in num_list:
	if max < i:
		max = i
		index = num_list.index(i)
change = max * 2 ** k
num_list[index] = change
ans = 0
for j in num_list:
	ans += j
print(ans)


num = list(map(int, input().split()))
print(sum(num) - max(num) + max(num) * 2 ** int(input()))


a = [int(i) for i in input().split()]
b = int(input())
print(sum(a) - max(a) + max(a) * 2 ** b)


display = sorted(list(map(int, input().split())))
K = int(input())
maximum = display[-1]
for i in range(K):
	maximum = maximum * 2
print(sum(display[:-1]) + maximum)


ls = list(map(int, input().split()))
k = int(input())
print(sum(ls) + max(ls) * (2 ** k - 1))


a = sorted(list(map(int, input().split())))
print(sum(a[0:2]) + a[2] * 2 ** int(input()))


a = sorted(list(map(int, input().split())))
m = a.pop()
for i in range(int(input())):
	m *= 2
print(sum(a) + m)


l = list(map(int, input().split()))
K = int(input())
print(sum(l) + max(l) * (2 ** K - 1))


mylists = list(map(int, input().split()))
k = int(input())
mylists.sort(reverse=True)
print(mylists[0] * 2 ** k - mylists[0] + sum(mylists))


(*a, b) = list(map(int, open(0).read().split()))
print(sum(sorted(a)[:2]) + max(a) * 2 ** b)


def answer(a: int, b: int, c: int, k: int) -> int:
	nums = sorted((a, b, c))
	nums[-1] = nums[-1] * 2 ** k
	return sum(nums)

def main():
	(a, b, c) = list(map(int, input().split()))
	k = int(input())
	print(answer(a, b, c, k))

def __starting_point():
	main()
__starting_point()


(*x, k) = map(int, open(0).read().split())
print((2 ** k - 1) * max(x) + sum(x))


a = list(map(int, input().split()))
b = int(input())
a.sort()
print(a[0] + a[1] + a[2] * 2 ** b)


(A, B, C) = map(int, input().split())
K = int(input())
M = sorted([A, B, C])
m = M[-1]
m = m * 2 ** K
print(m + M[0] + M[1])


abc = list(map(int, input().split()))
k = int(input())
abc.sort()
print(abc[0] + abc[1] + abc[2] * 2 ** k)


n = [int(s) for s in input().split()]
k = int(input())
for i in range(k):
	max_id = n.index(max(n))
	n[max_id] *= 2
print(sum(n))


(A, B, C) = map(int, input().split())
print(A + B + C + max(A, B, C) * (2 ** int(input()) - 1))


A = [int(i) for i in input().split()]
K = int(input())
print(max(A) * (2 ** K - 1) + sum(A))


(A, B, C) = map(int, input().split())
k = int(input())
m = max(A, B, C)
print(A + B + C - m + m * 2 ** k)


import math
a = list(map(int, input().split()))
s = int(input())
for i in range(s):
	a[a.index(max(a))] = a[a.index(max(a))] * 2
print(sum(a))


nums = list(map(int, input().split()))
k = int(input())
x = max(nums)
mulx = x * 2 ** k
print(mulx + sum(nums) - x)


(a, b, c) = map(int, input().split())
k = int(input())
M = max(a, b, c)
print(a + b + c - M + M * 2 ** k)