alexjercan/bugnet huggingface dataset:
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define ff first
#define ss second
#define PB push_back
#define F(i, L, R) for (auto i = L; i < R; i++)
#define FR(i, R, L) for (auto i = R; i > L; i--)
#define all(x) (x).begin(), (x).end()
#define show(x) cout << (#x) << " = " << (x) << "\\n";
#define show2(x, y)                                                            \\
  cout << (#x) << " = " << (x) << " & " << (#y) << " = " << (y) << "\\n";
#define show3(x, y, z)                                                         \\
  cout << (#x) << " = " << (x) << " & " << (#y) << " = " << (y) << " & "       \\
       << (#z) << " = " << (z) << "\\n";
#define endln "\\n"
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define M 1000000000000000000

using namespace std;

int main() {
  fastio;
  ll n, ans = 1, a;
  cin >> n;
  int flag = 0;
  long double m = M;
  F(i, 0, n) {
    cin >> a;
    if (a > M && flag == 0)
      flag = 2;
    if (a == 0)
      flag = 1;
    if (ans > M) {
      flag = 0;
      ans = 0;
    }
    ans *= a;
    if (a != 0)
      m /= a;
    if (m < 1 && flag == 0)
      flag = 2;
  }
  if (flag == 1)
    cout << 0;
  else if (flag == 0)
    cout << ans;
  else
    cout << -1;
}


Error: WA

Fixed submission:

/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define ff first
#define ss second
#define PB push_back
#define F(i, L, R) for (auto i = L; i < R; i++)
#define FR(i, R, L) for (auto i = R; i > L; i--)
#define all(x) (x).begin(), (x).end()
#define show(x) cout << (#x) << " = " << (x) << "\\n";
#define show2(x, y)                                                            \\
  cout << (#x) << " = " << (x) << " & " << (#y) << " = " << (y) << "\\n";
#define show3(x, y, z)                                                         \\
  cout << (#x) << " = " << (x) << " & " << (#y) << " = " << (y) << " & "       \\
       << (#z) << " = " << (z) << "\\n";
#define endln "\\n"
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define M 1000000000000000000

using namespace std;

int main() {
  fastio;
  ll n, ans = 1, a;
  cin >> n;
  bool flag = 1;
  F(i, 0, n) {
    cin >> a;
    if (M / a < ans || a > M) {
      flag = 0;
      ans = 0;
    }
    ans *= a;
    if (ans > M) {
      flag = 0;
      ans = 0;
    }
  }
  if (flag)
    cout << ans;
  else
    cout << -1;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;

using namespace std;

#define LIMIT ((ll)1e18)

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  bool overFlow = false;
  for (int i = 0; i < n; i++) {
    ll ai;
    cin >> ai;
    if (ai == 0) {
      cout << 0 << '\\n';
      return 0;
    }
    if (ans > LIMIT / ai + 1) {
      overFlow = true;
    }
    if (!overFlow)
      ans *= ai;
  }
  cout << ((ans <= LIMIT && !overFlow) ? ans : -1) << '\\n';
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;

using namespace std;

#define LIMIT ((ll)1e18)

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  bool overFlow = false;
  for (int i = 0; i < n; i++) {
    ll ai;
    cin >> ai;
    if (ai > LIMIT / ans + 1) {
      overFlow = true;
    }
    if (ai == 0) {
      cout << 0 << '\\n';
      return 0;
    }
    ans *= ai;
  }
  cout << ((ans <= LIMIT && !overFlow) ? ans : -1) << '\\n';
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
int main() {
  int n;
  ll m;
  m = 1;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    ll x;
    cin >> x;
    if (x == 0) {
      m = 0;
    }
    a[i] = x;
  }
  if (m != 0)
    rep(i, n) {
      if (m <= 1000000000000000000 / a[i]) {
        m *= a[i];
      } else {
        m = -1;
        break;
      }
    }
  cout << m << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
int main() {
  int n;
  ll m;
  m = 1;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    ll x;
    cin >> x;
    if (x == 0) {
      m = 0;
    }
    a[i] = x;
  }
  rep(i, n) {
    if (m <= 1000000000000000000 / a[i]) {
      m *= a[i];
    } else {
      m = -1;
      break;
    }
  }
  cout << m << endl;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  ll b = 1e18;
  vector<ll> A(n);
  rep(i, n) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  rep(i, n) {
    if (b / ans >= A[i]) {
      ans *= A[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;

int main() {
  int n;
  vector<ll> A(n);
  cin >> n;
  rep(i, n) cin >> A[i];

  ll ans = 1;
  rep(i, n) { ans *= A[i]; }

  if (ans > (int)1e18)
    ans = -1;
  cout << ans << endl;
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);

  rep(i, n) { cin >> a[i]; }
  rep(i, n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll seki = 1;

  rep(i, n) {
    if (1000000000000000000 / seki < a[i]) {
      cout << -1 << endl;
      return 0;
    }
    seki *= a[i];
  }

  cout << seki << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);

  rep(i, n) { cin >> a[i]; }
  rep(i, n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll seki = a[0];

  rep2(i, 1, n - 1) {
    if (1000000000000000000 / seki > a[i]) {
      cout << -1 << endl;
      return 0;
    }
    seki *= a[i];
  }

  cout << seki << endl;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
/* ちゃんと考えてわかって実装 */

const ll MAX_ANS = ll(1e18);

int main(void) {
  int n;
  cin >> n;

  ll ans = 1;
  vector<ll> a;
  for (int i = 0; i < n; i++) {
    ll tmp_a;
    cin >> tmp_a;
    a.push_back(tmp_a);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    // かけた時点でoverflowするやつない??
    if (ans != 0 && a[i] <= MAX_ANS / ans) {
      ans *= a[i];
    } else if (ans == 0) {
      ans = 0;
      break;
    } else {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
/* ちゃんと考えてわかって実装 */

const ll MAX_ANS = ll(1e18);

int main(void) {
  int n;
  cin >> n;

  ll ans = 1;
  vector<ll> a;
  for (int i = 0; i < n; i++) {
    ll tmp_a;
    cin >> tmp_a;
    a.push_back(tmp_a);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    // かけた時点でoverflowするやつない??
    if (a[i] <= MAX_ANS / ans) {
      ans *= a[i];
    } else {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define repp(i, l, r) for (long long i = (l); i < (r); i++)
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define per(i, n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647; // int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__int128 read_int128() {
  string s;
  cin >> s;
  __int128 res = 0;
  for (char c : s) {
    res = res * 10 + int(c - '0');
  }
  return res;
}

// ミョ(-ω- ?)
int main() {
  auto n = read_int128();
  vector<__int128> a(n, 0);
  bool b = false;
  rep(i, n) {
    a[i] = read_int128();
    if (a[i] == 0)
      b = true;
  }
  sort(a.begin(), a.end());
  if (b) {
    cout << 0 << endl;
  } else {
    __int128 pro = 1;
    for (auto i : a) {
      pro *= i;
      if (pro > 1000000000000000000) {
        cout << -1 << endl;
        return 0;
      }
    }
    cout << (long long)pro << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define repp(i, l, r) for (cpp_int i = (l); i < (r); i++)
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define per(i, n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647; // int max
const long long int MOD = 1000000007;
using namespace std;
using namespace boost::multiprecision;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
// ミョ(-ω- ?)
int main() {
  cpp_int n;
  cin >> n;
  cpp_int sum = 1;
  rep(i, n) {
    cpp_int a;
    cin >> a;
    sum *= a;
  }
  if (sum > 1000000000000000000)
    cout << -1 << endl;
  else
    cout << fixed << setprecision(0) << sum << endl;
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;

int main() {
  unsigned long long int check = 1e18;
  unsigned long long int answer = 1;

  int N = 0;
  cin >> N;

  vector<unsigned long long int> A(N);

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < N; i++) {
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  for (int i = 0; i < N; i++) {

    if (A[i] > check) {
      cout << -1 << endl;
      return 0;
    }
    check /= A[i];
    if (check < 1) {

      cout << -1 << endl;
      return 0;
    }

    answer = answer * A[i];
  }

  cout << answer << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;

int main() {
  unsigned long long int check = 100000000000000000;
  unsigned long long int answer = 1;

  unsigned int N = 0;
  cin >> N;
  vector<unsigned long long int> A(N);
  for (unsigned int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (unsigned int i = 0; i < N; i++) {
    check = check / A[i];
  }
  if (check < 1) {
    cout << -1 << endl;
  } else {
    for (unsigned int i = 0; i < N; i++) {
      answer = answer * A[i];
    }
    cout << answer << endl;
  }

  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
// const int INF = 2e9;
// const ll INF = 9e18;
const ll MX = 1e18;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < N; i++) {
    if (A[i] == 0) {
      cout << 0 << "\\n";
      return 0;
    }
  }
  ll ans = 1;
  ll i = 0;
  while (MX / ans >= A[i]) {
    ans *= A[i];
    i++;
    if (i == N)
      break;
  }
  if (i < N)
    cout << -1 << "\\n";
  else
    cout << ans << "\\n";
}

Error: -8

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
// const int INF = 2e9;
// const ll INF = 9e18;
const ll MX = 1e18;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < N; i++) {
    if (A[i] == 0) {
      cout << 0 << "\\n";
      return 0;
    }
  }
  ll ans = 1;
  ll i = 0;
  while (i < N || MX / ans >= A[i]) {
    ans *= A[i];
    i++;
  }
  if (i < N)
    cout << -1 << "\\n";
  else
    cout << ans << "\\n";
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, i;
  cin >> n;
  unsigned long long int p = 1, c = 0, z = 0;
  long long int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      z++;
  }
  if (z > 0) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (a[i] <= 1000000000000000000 / p)
      p = p * a[i];
    else {
      c = 1;
      break;
    }
  }
  if (c == 0)
    cout << p << endl;
  if (c == 1)
    cout << -1;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, i;
  cin >> n;
  unsigned long long int a, p = 1, c = 0;
  for (i = 0; i < n; i++) {
    cin >> a;
    if (a <= 1000000000000000000 / p)
      p = p * a;
    else {
      c = 1;
    }
  }
  if (c == 0)
    cout << p << endl;
  if (c == 1)
    cout << -1;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
// #define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
// #define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main() {
  int n;
  const long long INF = 1e18;
  const int max_n = 100000;
  long long a[max_n + 1];

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];

  long long sum = 1;
  long long pre = 0;
  bool flag = 0;
  bool flag0 = 0;

  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      // cout << 0 << endl;
      // return 0;
      flag0 = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    sum = sum * a[i];
    if (sum < pre)
      flag = 1;
    if (sum > INF)
      flag = 1;
    pre = sum;
  }

  if (flag0)
    cout << 0 << endl;
  else if (flag)
    cout << -1 << endl;
  else
    cout << sum << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
// #define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
// #define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main() {
  int n;
  const long long INF = 1e18;
  const int max_n = 10000;
  long long a[max_n + 1];

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];

  long long sum = 1;
  long long pre = 0;
  bool flag = 0;
  bool flag0 = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      // cout << 0 << endl;
      // return 0;
      flag0 = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    sum = sum * a[i];
    if (sum < pre)
      flag = 1;
    if (sum > INF)
      flag = 1;
    pre = sum;
  }

  if (flag0)
    cout << 0 << endl;
  else if (flag)
    cout << -1 << endl;
  else
    cout << sum << endl;

  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const ll MAX = 1e18;
int main() {
  int n;
  cin >> n;
  ll a[n];
  ll val = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << "0";
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    ll x = a[i];
    // if((MAX/val < x) || ((MAX/val == x) && (MAX%val != 0))) {
    if (x <= MAX / val) {
      val *= x;
    } else {
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << val;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const ll MAX = 1e18;
int main() {
  int n;
  cin >> n;
  ll a[n];
  ll val = 1;
  bool ok = true;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << "0";
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    ll x = a[i];
    if ((MAX / val < x) || ((MAX / val == x) && (MAX % val != 0))) {
      ok = false;
    }
    val *= x;
  }
  if (ok) {
    cout << val << endl;
  } else {
    cout << "-1" << endl;
    ;
  }
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;
int main() {
  long long t, c = 1, p = 0, q = 0;
  cin >> t;
  while (t--) {
    long long x;
    cin >> x;
    if (c != 0 && x <= (1000000000000000000) / c) {
      c = c * x;
    } else {
      p = 1;
    }
    if (x == 0) {
      q = 1;
    }
  }
  if (p == 1 && q == 0)
    c = -1;
  cout << c << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;
int main() {
  long long t, c = 1, p = 0, q = 0;
  cin >> t;
  while (t--) {
    long long x;
    cin >> x;
    if (x <= (1000000000000000000) / c) {
      c = c * x;
    } else {
      p = 1;
    }
    if (x == 0) {
      q = 1;
    }
  }
  if (p == 1 && q == 0)
    c = -1;
  cout << c << endl;
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long sum = 1;
  vector<long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (A.at(i) == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if (A.at(i) > 1000000000000000000 / sum) {
      cout << -1 << endl;
      return 0;
    }
    sum = sum * A.at(i);
  }
  cout << sum << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long A;
  long sum = 1;
  bool B = true;
  bool TF = false;
  for (int i = 0; i < N || B; i++) {
    cin >> A;
    if (A > 1000000000000000000 / sum) {
      B = false;
      TF = true;
    } else {
      sum *= A;
    }
  }
  if (TF) {
    cout << "-1" << endl;
  } else {
    cout << sum << endl;
  }
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;

int main() {
  int N;
  cin >> N;
  LL out = 1;
  const LL MX = 1e18;
  bool ng = false;

  for (int i = 0; i < N; i++) {
    LL b;
    cin >> b;

    if (b == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || MX / out < b) {
      ng = true;
    }

    out *= b;
  }
  if (ng)
    cout << -1 << endl;
  else
    cout << out << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;

int main() {
  int N;
  cin >> N;
  LL out = 1;
  const LL MX = 1e18;
  bool ng = false;

  for (int i = 0; i < N; i++) {
    LL b;
    cin >> b;

    if (b == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (MX / out < b) {
      ng = true;
    }

    out *= b;
  }
  if (ng)
    cout << -1 << endl;
  else
    cout << out << endl;
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm> //min,max,swap,sort,reverse,lower_bound,upper_bound
#include <bitset>    //bitset
#include <cctype>    //isupper,islower,isdigit,toupper,tolower
#include <cstdint>   //int64_t,int*_t
#include <cstdio>    //printf
#include <cstdio>
#include <cstring>
#include <deque> //deque
#include <iomanip>
#include <iostream> //cout,endl,cin
#include <map>      //map
#include <math.h>
#include <queue>         //queue,priority_queue
#include <set>           //set
#include <stack>         //stack
#include <string>        //string,to_string,stoi
#include <tuple>         //tuple,make_tuple
#include <unordered_map> //unordered_map
#include <unordered_set> //unordered_set
#include <utility>       //pair,make_pair
#include <vector>        //vector

using namespace std;
typedef long long ll;

/*
int main() {
    ll a;
    double b;
    cin >> a >> b;
    cout << fixed << (ll)(floor(a * b)) << endl;
}
*/

int main() {
  ll n;
  ll result = 1;
  int a = 0;
  // vector<int> vc;
  cin >> n;
  while (n--) {
    ll x;
    cin >> x;
    // result = result * x;
    if (x == 0 || result == 0) {
      a = 0;
    } else if (x > 1000000000000000000 / result) {
      a = 1;
      result = 1;
    }
    result = result * x;
    // cout << result << endl;
    // vc.push_back(x);
  }
  if (result > 1000000000000000000 || a == 1) {
    cout << -1 << endl;
  } else {
    cout << result << endl;
  }
}


Error: 0

Fixed submission:

#include <algorithm> //min,max,swap,sort,reverse,lower_bound,upper_bound
#include <bitset>    //bitset
#include <cctype>    //isupper,islower,isdigit,toupper,tolower
#include <cstdint>   //int64_t,int*_t
#include <cstdio>    //printf
#include <cstdio>
#include <cstring>
#include <deque> //deque
#include <iomanip>
#include <iostream> //cout,endl,cin
#include <map>      //map
#include <math.h>
#include <queue>         //queue,priority_queue
#include <set>           //set
#include <stack>         //stack
#include <string>        //string,to_string,stoi
#include <tuple>         //tuple,make_tuple
#include <unordered_map> //unordered_map
#include <unordered_set> //unordered_set
#include <utility>       //pair,make_pair
#include <vector>        //vector

using namespace std;
typedef long long ll;

/*
int main() {
    ll a;
    double b;
    cin >> a >> b;
    cout << fixed << (ll)(floor(a * b)) << endl;
}
*/

int main() {
  ll n;
  ll result = 1;
  int a = 0;
  // vector<int> vc;
  cin >> n;
  while (n--) {
    ll x;
    cin >> x;
    // result = result * x;
    if (x == 0) {
      a = 0;
    } else if (x > 1000000000000000000 / result) {
      a = 1;
      result = 1;
    }
    result = result * x;
    // cout << result << endl;
    // vc.push_back(x);
  }
  if (result > 1000000000000000000 || a == 1) {
    cout << -1 << endl;
  } else {
    cout << result << endl;
  }
}