Problem p03373 (C++)

Buggy submission (status: Runtime Error):
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <array>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);
#define DEBUG_VIS(x) cerr << "vis " << x << endl;
#define DEBUG_REACH cerr << "reach here" << endl;
#define DEBUG_SEQ(x) cerr << x << " ";
#define SET_ZERO(x) memset(x, 0, sizeof(x));
#define SET_NEGONE(x) memset(x, -1, sizeof(x));
#define SET_INF(x) memset(x, 127, sizeof(x));
#define SET_NEGINF(x) memset(x, 128, sizeof(x));
#define IS_INF(x) x < 2100000000
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, double> pdd;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
const int maxn = 1e6 + 10;
template <class T> T mymin(const T a, const T b) { return a < b ? a : b; }
template <class T> T mymax(const T a, const T b) { return a > b ? a : b; }
int A, B, C, X, Y;

int main() {
#ifndef ONLINE_JUDGE
  freopen("data.in", "r", stdin);
#endif
  FAST_IO
  cin >> A >> B >> C >> X >> Y;
  if (2 * C > A + B)
    cout << A * X + B * Y << endl;
  else
    cout << min(min(X, Y) * C * 2 + (X - min(X, Y)) * A + (Y - min(X, Y)) * B,
                max(X, Y) * C * 2)
         << endl;
  return 0;
}


Fixed submission:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <array>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);
#define DEBUG_VIS(x) cerr << "vis " << x << endl;
#define DEBUG_REACH cerr << "reach here" << endl;
#define DEBUG_SEQ(x) cerr << x << " ";
#define SET_ZERO(x) memset(x, 0, sizeof(x));
#define SET_NEGONE(x) memset(x, -1, sizeof(x));
#define SET_INF(x) memset(x, 127, sizeof(x));
#define SET_NEGINF(x) memset(x, 128, sizeof(x));
#define IS_INF(x) x < 2100000000
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, double> pdd;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
const int maxn = 1e6 + 10;
template <class T> T mymin(const T a, const T b) { return a < b ? a : b; }
template <class T> T mymax(const T a, const T b) { return a > b ? a : b; }
int A, B, C, X, Y;

int main() {
  FAST_IO
  cin >> A >> B >> C >> X >> Y;
  if (2 * C > A + B)
    cout << A * X + B * Y << endl;
  else
    cout << min(min(X, Y) * C * 2 + (X - min(X, Y)) * A + (Y - min(X, Y)) * B,
                max(X, Y) * C * 2)
         << endl;
  return 0;
}