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

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

int main() {
  int n;
  cin >> n;
  vector<long long int> a(n);
  int zer = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      zer = 1;
  }
  long long int ans = 1;
  for (int i = 0; i < n; i++) {
    if (ans == 0) {
      cout << "0" << endl;
      return 0;
    }
    long long int op = 1000000000000000000LL / ans;
    long long int p = (1000000000000000001LL) / ans;
    if (p != op)
      p = op;
    if (a[i] > p) {
      if (zer == 0) {
        cout << "-1" << endl;
        return 0;
      }
    }
    ans = ans * a[i];
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<long long int> a(n);
  int zer = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      zer = 1;
  }
  long long int ans = 1;
  for (int i = 0; i < n; i++) {
    long long int op = 1000000000000000000LL / ans;
    long long int p = (1000000000000000001LL) / ans;
    if (p != op)
      p = op;
    if (a[i] > p) {
      if (zer == 0) {
        cout << "-1" << endl;
        return 0;
      }
    }
    ans = ans * a[i];
  }
  cout << ans << endl;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  long long a, c = 1, n;
  int flag = 1;

  cin >> n;

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

    if (a == 0) {
      flag = 0;
      break;
    }

    if (flag == 1) {
      if (c > 1000000000000000000 / a) {
        flag = -1;
      }

      c *= a;
    }
  }

  if (flag == 1) {
    cout << c << endl;
  } else if (flag == -1) {
    cout << -1 << endl;
  } else if (flag == 0) {
    cout << 0 << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  long long a, c = 1, n;
  int flag = 1;

  cin >> n;

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

    if (c > 1000000000000000000 / a) {
      flag = -1;
    }
    c *= a;
    if (a == 0) {
      flag = 0;
      break;
    }
  }

  if (flag == 1) {
    cout << c << endl;
  } else if (flag == -1) {
    cout << -1 << endl;
  } else if (flag == 0) {
    cout << 0 << endl;
  }
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void YN(bool flg) {
  if (flg)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void Yn(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void yn(bool flg) {
  if (flg)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

int main() {
  int n;
  cin >> n;
  vll a(n);
  rep(i, n) cin >> a[i];

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

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

  cout << ans << endl;

  return 0;
}


Error: 0

Fixed submission:

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void YN(bool flg) {
  if (flg)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void Yn(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void yn(bool flg) {
  if (flg)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

int main() {
  int n;
  cin >> n;
  vll a(n);
  rep(i, n) cin >> a[i];

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

  ll ans = 1;
  ll max = 1000000000000000000;
  bool flg = false;
  rep(i, n) {
    if (max / ans < a[i])
      flg = true;
    ans *= a[i];
  }
  cout << (flg ? -1 : ans) << endl;

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

#include <bits/stdc++.h>
#define m 1000000000000000000
#define sze 100000

using namespace std;
int main() {

  long long n, a[sze], flag = 0;
  long double mul = 1;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    mul = mul * a[i];
    if (mul > m) {
      flag = 1;
      break;
    }
  }

  if (flag == 1)
    cout << "-1" << endl;
  else
    cout << ((long long)mul) << endl;

  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define m 1000000000000000000
#define sze 100000

using namespace std;
int main() {

  long long n, a[n], mul = 1, flag = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    mul = mul * a[i];
    if (mul > m) {
      flag = 1;
      break;
    }
  }

  if (flag == 1)
    cout << "-1" << endl;
  else
    cout << mul << 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 <climits>
#include <cstdint> // int64_t, int*_t
#include <cstdio>  // printf
#include <deque>   // deque
#include <functional>
#include <iomanip> //setprecision
#include <iostream>
#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;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define mod 1000000007
vector<ll> to[1000005];
int main() {
  ll a, c = 1;
  cin >> a;
  vector<ll> b(a);
  rep(i, a) {
    cin >> b[i];
    if (b[i] == 0) {
      cout << 0;
      return 0;
    }
  }
  rep(i, a) {
    if (1000000000000000000 / c < b[i]) {
      cout << -1;
      return 0;
    }
    c *= b[i];
  }
  cout << c;
}


Error: WA

Fixed submission:


#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <climits>
#include <cstdint> // int64_t, int*_t
#include <cstdio>  // printf
#include <deque>   // deque
#include <functional>
#include <iomanip> //setprecision
#include <iostream>
#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;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ll long long
#define mod 1000000007
vector<ll> to[1000005];
int main() {
  ll a, b, c = 1;
  cin >> a;
  ll d[a];
  rep(i, a) {
    cin >> d[a];
    if (d[i] == 0) {
      cout << 0;
      return 0;
    }
    c *= b;
  }
  if (c > 1000000000000000000) {
    cout << -1;
    return 0;
  }
  cout << c;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl;
using namespace std;

// int _;

int n;
long long ans = 1, a[100050];

int main() {
  // for(scanf("%d",&_);_;_--)
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", a + i);
    if (!a[i]) {
      puts("0");
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (1000000000000000000 / ans < a[i]) {
      puts("-1");
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl;
using namespace std;

// int _;

int n;
long long ans = 1, a[100050];

int main() {
  // for(scanf("%d",&_);_;_--)
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", a + i);
    if (!a[i]) {
      puts("0");
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (1000000000000000000 / ans >= a[i] && 1000000000000000000 % ans != 0) {
      puts("-1");
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

const long long mx = 1e18;

int main() {
  int n;
  long long ans = 1;
  bool ng = false;
  cin >> n;
  rep(i, n) {
    long long a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }

    if (ans > (mx / a)) {
      ng = true;
    }
    ans *= a;
  }

  if (ng)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

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

using namespace std;

const long long mx = 1e18;

int main() {
  int n;
  long long ans = 1;
  bool ng = false;
  cin >> n;
  rep(i, n) {
    long long a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }

    if (a > (mx / ans)) {
      ng = true;
    }
    ans *= a;
  }

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

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

using ll = long long;
#define max_sum 1000000000000000000

int main() {

  ll n;
  cin >> n;
  ll a;
  long long sum = 1;
  bool flag = 0;

  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (flag || max_sum / sum < a) {
      flag = 1;
      sum = 0;
    } else {
      sum *= a;
    }
  }

  if (flag == 1) {
    cout << -1 << endl;
  } else {
    cout << sum << endl;
  }
}

Error: 0

Fixed submission:

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

using ll = long long;
#define max_sum 1000000000000000000

int main() {

  ll n;
  cin >> n;
  ll a;
  long long sum = 1;
  bool flag = 0;

  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 0) {
      flag = 0;
      sum = 0;
    }
    if (flag || max_sum / sum < a) {
      flag = 1;
      sum = 0;
    } else {
      sum *= a;
    }
  }

  if (flag == 1) {
    cout << -1 << endl;
  } else {
    cout << sum << endl;
  }
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  long long x = 1000000000000000000, ans = 1;
  long long a[1000000];
  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++) {
    if (x < a[i]) {
      cout << "-1";
      return 0;
    } else {
      ans *= a[i];
      x /= a[i];
    }
  }
  cout << ans;
}

Error: WA

Fixed submission:

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

int main(void) {

  int N;

  cin >> N;

  ll b = 1;
  ll a[100010];

  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }

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

  for (int i = 0; i < N; i++) {
    b = b * a[i];

    if (a[i] <= 1000000000000000000 / b) {
      cout << -1;
      return 0;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k, x, l(1);
  cin >> n;
  k = pow(10, 18);
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 0) {
      l = 0;
      k = 1;
      break;
    }
    k = k / x;
    l *= x;
  }
  if (k == 0) {
    cout << "-1";
  } else
    cout << l;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k, x, l(1);
  cin >> n;
  k = pow(10, 18);
  for (int i = 0; i < n; i++) {
    cin >> x;
    k = k / x;
    l *= x;
  }
  if (k == 0) {
    cout << "-1";
  } else
    cout << l;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

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

const ll MX = 1e18;

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  bool ng = false;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || __int128(ans) * a > MX) {
      ng = true;
    }
    ans *= a;
  }
  if (ng)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int n;
  long long a[n], z = 1, p = 1;

  cin >> n;

  for (int i = 0; i < 18; i++) {
    z = z * 10;
  }

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

  if (p > z) {
    cout << -1 << endl;
  } else {
    cout << p << endl;
  }
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define endl "\\n"
#define int long long
#define reus                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
int32_t main() {
  reus;
  int n;
  cin >> n;
  int a[n], i;
  long double s = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  s = 0;
  for (i = 0; i < n; i++) {
    s += log10(a[i]);
  }
  if (s > 18.1) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 1;
  for (i = 0; i < n; i++) {
    ans *= a[i];
  }
  if (ans > 1000000000000000000) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define FIO                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define mod 1000000007
#define p 1000000000000000000
#define test                                                                   \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
typedef long long int ll;
int main() {
  FIO;
  // test
  {
    ll n, i, x;
    cin >> n;
    ll a[n];
    ll flag = 0;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == 0) {
        flag = 1;
      }
    }
    if (flag) {
      cout << 0 << endl;
    } else {
      ll ans = 1, flag = 0;
      for (i = 0; i < n; i++) {
        x = p / ans;
        if (a[i] > x) {
          cout << -1 << endl;
          flag = 1;
        }
        ans *= a[i];
      }
      if (flag == 0 && ans <= p && ans >= 1) {
        cout << ans << endl;
      }
    }
  }
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

int main() {
  int64_t N;
  std::cin >> N;

  int64_t sum = 1;
  bool over = false;
  for (int64_t i = 0; i < N; ++i) {
    int64_t A;
    std::cin >> A;
    if (A == 0) {
      sum = 0;
      over = false;
      break;
    }

    if (sum > 1000000000000000000 / A)
      over = true;

    sum *= A;
  }

  if (over)
    std::cout << -1;
  else
    std::cout << sum;
}

Error: WA

Fixed submission:

#include <iostream>

int main() {
  int64_t N;
  std::cin >> N;

  int64_t sum = 1;
  bool over = false;
  for (int64_t i = 0; i < N; ++i) {
    int64_t A;
    std::cin >> A;
    if (A == 0) {
      sum = 0;
      over = false;
      break;
    }

    if (A > 1000000000000000000 / sum)
      over = true;

    sum *= A;
  }

  if (over)
    std::cout << -1;
  else
    std::cout << sum;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
  int n;
  scanf("%d", &n);
  LL ans = 1, x, inf = 1e18, fl = 1, fl1 = 1;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &x);
    if (!x)
      fl1 = 0;
    if (fl && (x > inf / ans || ans * x > inf))
      fl = 0;
    ans *= x;
  }
  if (!fl1 || fl)
    printf("%lld", ans);
  else
    puts("-1");
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
  int n;
  scanf("%d", &n);
  LL ans = 1, x, inf = 1e18, fl = 1, fl1 = 1;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &x);
    if (!x)
      fl1 = 0;
    if (x > inf / ans || (ans * x > inf))
      fl = 0;
    ans *= x;
  }
  if (!fl1 || fl)
    printf("%lld", ans);
  else
    puts("-1");
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  long N;
  cin >> N;

  long S = 1;
  long A;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A == 0 || S == 0) {
      S = 0;
    } else if (A != 0 && A <= (1000000000000000000 / S) && S != -1) {
      S *= A;
    } else {
      S = -1;
    }
  }

  cout << S << endl;
}


Error: 0

Fixed submission:

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

int main() {
  long N;
  cin >> N;

  long S = 1;
  long A;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A != 0 && A <= (1000000000000000000 / S) && S != -1) {
      S *= A;
    } else if (A == 0) {
      S = 0;
    } else {
      S = -1;
    }
  }

  cout << S << endl;
}
Problem p02658 (C++) — buggy submission, verdict: Time Limit Exceeded

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T> bool chmin(T &x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}

template <typename T> bool chmax(T &x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

void solve(long long n, std::vector<long long> a) {
  boost::multiprecision::cpp_int aa(1);
  if (*min_element(a.begin(), a.end()) == 0) {
    cout << 0 << endl;
    return;
  }
  for (int i = 0; i < n; ++i) {
    aa *= a[i];

    if (aa > 1000000000000000000LL) {
      cout << -1 << endl;
      return;
    }
  }
  cout << aa << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Error: TLE

Fixed submission:

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T> bool chmin(T &x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}

template <typename T> bool chmax(T &x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

void solve(long long n, std::vector<long long> a) {
  boost::multiprecision::cpp_int aa(1);
  for (int i = 0; i < n; ++i) {
    aa *= a[i];
  }
  if (aa > 1000000000000000000LL) {
    cout << -1 << endl;
    return;
  }
  cout << aa << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

///***###                               بسم الله الرحمن الرحيم ###***///

/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 31 May,2020;
*/

///************************Start Of Template*************************///

#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#define Read_Fast                                                              \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i, n) for (i = 0; i < n; i++)
#define f1(i, n) for (i = 1; i < n; i++)
#define f1n(i, n) for (i = 1; i <= n; i++)
#define szf sizeof()
#define sz size()
#define ln length()
using namespace std;
using ll = long long;
const int N = 2e5 + 5;

int main() {
  Read_Fast ll t;
  ll ans = 1;
  int a = 0;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    if (n == 0 || ans == 0) {
      a = 0;
    } else if (n > 1000000000000000000 / ans) {
      a = 1, ans = 1;
    }
    ans = ans * n;
  }
  if (ans > 1000000000000000000 || a == 1) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

///***###                               بسم الله الرحمن الرحيم ###***///

/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 31 May,2020;
*/

///************************Start Of Template*************************///

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#define Read_Fast                                                              \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i, n) for (i = 0; i < n; i++)
#define f1(i, n) for (i = 1; i < n; i++)
#define f1n(i, n) for (i = 1; i <= n; i++)
#define szf sizeof()
#define sz size()
#define ln length()
using namespace std;
using ll = long long;
const int N = 2e5 + 5;

int main() {
  Read_Fast 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;
  }
  if (result > 1000000000000000000 || a == 1) {
    cout << -1 << endl;
  } else {
    cout << result << endl;
  }
  return 0;
}