Problem p03360 (C++)

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
typedef long long ll;
const double PI = 3.141592654;
#define rep(i, x) for (int(i) = 0; (i) < (ll)(x); (i)++)
#define all(s) (s).begin(), (s).end()
#define allv(v) (v).begin(), (v).end()
#define allvr(v) (v).rbegin(), (v).rend()
#define pb push_back
#define sz s.size()
#define ssz ss.size()
#define vz v.size()
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dy[] = {1, -1, 0, 0, 1, 1, -1, -1};
// x = atoill(s.c_str())
void fast() {
#ifndef ONLINE_JUDGE
  /*

  **    ** ** **    *********   ** ** **
  **    **          **     **   **
  **    **          *********   **
  **    **          **          **
  **    ** ** **    **          ** ** **
  */
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
}
int main() {
  fast();
  vector<ll> v(3);
  int k;
  rep(i, 3) cin >> v[i];
  cin >> k;
  sort(allvr(v));
  ll sum = v[0] * pow(2, k);
  sum += v[1] + v[2];
  cout << sum;
  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
typedef long long ll;
const double PI = 3.141592654;
#define rep(i, x) for (int(i) = 0; (i) < (ll)(x); (i)++)
#define all(s) (s).begin(), (s).end()
#define allv(v) (v).begin(), (v).end()
#define allvr(v) (v).rbegin(), (v).rend()
#define pb push_back
#define sz s.size()
#define ssz ss.size()
#define vz v.size()
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dy[] = {1, -1, 0, 0, 1, 1, -1, -1};
// x = atoill(s.c_str())
void fast() {
#ifndef ONLINE_JUDGE
  /*

  **    ** ** **    *********   ** ** **
  **    **          **     **   **
  **    **          *********   **
  **    **          **          **
  **    ** ** **    **          ** ** **
  */
  /*freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);*/
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
}
int main() {
  fast();
  vector<ll> v(3);
  int k;
  rep(i, 3) cin >> v[i];
  cin >> k;
  sort(allvr(v));
  ll sum = v[0] * pow(2, k);
  sum += v[1] + v[2];
  cout << sum;
  return 0;
}