Problem:
Score: 200 points

Problem Statement

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 1

5 3 11
1

Sample Output 1

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.

Sample Input 2

3 3 4
2

Sample Output 2

22

E869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:

First, double 4. The integers written on the board are now 3, 3, 8.

Next, double 8. The integers written on the board are now 3, 3, 16.

Then, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstring>
using namespace std;
using ll = long long;
#define ALL(a) (a).begin(), (a).end()

#define FOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800 / 2
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define ALL(a) (a).begin(), (a).end()

#include <iostream>
#include <cmath>
using namespace std;

bool isPrimeNum(ll x)
{ // 素数である場合 true を返す
	if (x <= 1)
	{ // 1以下である場合は素数でないことがすぐにわかる
		return false;
	}
	// sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
	int n = (int)sqrt((double)x);
	for (int i = 2; i <= n; i++)
	{
		if (x % i == 0)
		{ // 割り切る整数がある場合、即判定終了
			return false;
		}
	}
	return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
constexpr ll abs(ll a, ll b)
{
	if (a >= b)
		return a - b;
	if (a < b)
		return b - a;
}
constexpr double dabs(double a, double b)
{
	if (a >= b)
		return a - b;
	if (a < b)
		return b - a;
}
constexpr ll min(ll a, ll b)
{
	if (a >= b)
		return b;
	if (a < b)
		return a;
}

constexpr ll max(ll a, ll b)
{
	if (a >= b)
		return a;
	if (a < b)
		return b;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int dx8[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};

class UnionFind
{
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N)
	{
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A)
	{
		if (Parent[A] < 0)
			return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A)
	{
		return -Parent[root(A)]; //親をとってきたい]
	}
	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}
	//AとBをくっ付ける
	bool connect(int A, int B)
	{
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B)
		{
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B))
			swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 510000; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modinv(long long a, long long m)
{
	long long b = m, u = 1, v = 0;
	while (b)
	{
		long long t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= m;
	if (u < 0)
		u += m;
	return u;
}

void yn(bool flag)
{
	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return;
}
void YN(bool flag)
{
	if (flag)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return;
}

std::vector<ll> enum_div(ll n) //nの約数を列挙
{
	std::vector<ll> ret;
	for (ll i = 1; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i * i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	ret.push_back(n);
	return ret;
}

// グラフセット
struct Edge
{
	ll to;	 // 辺の行き先
	ll weight; // 辺の重み
	Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<ll>>;
#define def 0
template <class V, int NV>
struct SegTree
{ //[l,r)
	V comp(V &l, V &r) { return max(l, r); };

	vector<V> val;
	SegTree() { val = vector<V>(NV * 2, def); }
	V get(int x, int y, int l = 0, int r = NV, int k = 1)
	{
		if (r <= x || y <= l)
			return def;
		if (x <= l && r <= y)
			return val[k];
		auto a = get(x, y, l, (l + r) / 2, k * 2);
		auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
		return comp(a, b);
	}
	void update(int i, V v)
	{
		i += NV;
		val[i] = v;
		while (i > 1)
			i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
	}
	void add(int i, V v) { update(i, val[i + NV] + v); }
	V operator[](int x) { return get(x, x + 1); }
};

typedef vector<vector<long long>> matrix;
matrix mul_mod(matrix A, matrix B)
{
	int H = A.size();
	int W = B[0].size();
	int K = A[0].size();

	matrix C(H, vector<ll>(W, 0));
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			for (int k = 0; k < K; k++)
			{
				C[i][j] += A[i][k] * B[k][j];
				C[i][j] %= MOD;
			}
		}
	}
	return C;
}
matrix pow_mod_matrix(matrix A, ll p)
{
	matrix ret = matrix(A.size(), vector<long long>(A.size(), 0));
	for (int i = 0; i < A.size(); i++)
		ret[i][i] = 1;

	while (p > 0)
	{
		if (p & 1)
			ret = mul_mod(ret, A);
		A = mul_mod(A, A);
		p >>= 1;
	}
	return ret;
}

//cout << std::setprecision(30) << ans << endl;
int main()
{
	ll N, M, X;
	//cin >> N >> X;
	ll A, B, C;
	cin >> A >> B >> C;
	cin >> N;

	cout << (A + B + C) + max(A, max(B, C)) * (myPow(2, N, MOD) - 1) << endl;

	return 0;
}