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

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int, int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
const int z = 1000000007;
long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
int main() {
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  int flag0 = 0, flag_over = 0;
  llong ans = 1;
  const llong sh = 1000000000000000000;
  llong tmp_now;
  REP(i, n) {
    cin >> tmp_now;
    if (tmp_now == 0) {
      flag0 = 1;
    }
    if (tmp_now > sh / ans) {
      flag_over = 1;
    }
    if (!flag0 && !flag_over) {
      ans *= tmp_now;
    }
  }
  if (flag0)
    cout << 0 << endl;
  else if (flag_over)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int, int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
const int z = 1000000007;
long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
int main() {
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<llong> vec(n);
  llong ans = 1;
  llong sh = 1000000000000000000;
  REP(i, n) {
    cin >> vec[i];
    if (vec[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  REP(i, n - 1) {
    ans *= vec[i];
    if (sh / ans > vec[i + 1]) {
      cout << -1 << endl;
      return 0;
    }
  }
  ans *= vec[n - 1];
  cout << ans << endl;
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i, n) for (int i = 0; i < n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI = 3.141592653589793;

void solve() {
  int n;
  cin >> n;
  ll mul = 1;
  ll INF = 1e18;
  bool tem = 1, tem2 = 1;
  forn(i, n) {
    ll k;
    cin >> k;
    if (mul > 0 && k <= INF / mul) {
      mul *= k;
    } else
      tem = 0;
    if (k == 0)
      tem2 = 0;
  }
  if (!tem2) {
    cout << 0;
    return;
  }
  cout << (tem ? mul : -1);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  //	cin >> T;
  forse(c, 1, T + 1) {
    //	cout << "Case #" << cid << ": ";
    solve();
  }
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i, n) for (int i = 0; i < n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI = 3.141592653589793;

void solve() {
  int n;
  cin >> n;
  ll mul = 1;
  ll INF = 1e18;
  bool tem = 1, tem2 = 1;
  forn(i, n) {
    ll k;
    cin >> k;
    if (k <= INF / mul) {
      mul *= k;
    } else
      tem = 0;
    if (k == 0)
      tem2 = 0;
  }
  if (!tem2) {
    cout << 0;
    return;
  }
  cout << (tem ? mul : -1);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  //	cin >> T;
  forse(c, 1, T + 1) {
    //	cout << "Case #" << cid << ": ";
    solve();
  }
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  long r = 1, e = 1e18;
  for (int i = 0; i < n; i++) {
    long a;
    cin >> a;
    if (r && a >= (e + r) / r)
      r = 2e18;
    else
      r *= a;
  }
  cout << (r > e ? -1 : r) << endl;
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  long r = 1;
  for (int i = 0; i < n; i++) {
    long a;
    cin >> a;
    if (a >= (long(1e18) + r) / r)
      r = 2e18;
    else
      r *= a;
  }
  cout << (r > long(1e18) ? -1 : r) << endl;
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const ll inf = 1e18;
int main() {
  IO;
  int n;
  ll ans = 1;
  cin >> n;
  bool flag = true;
  for (int i = 0; i < n; ++i) {
    ll x;
    cin >> x;
    if (x == 0) {
      ans = 0;
      flag = true;
    } else if (ULLONG_MAX / ans < x || x * ans > inf) {
      flag = false;
      // cout << ans << " " << ULLONG_MAX << " " << ULLONG_MAX / ans << endl;
    }
    if (flag)
      ans *= x;
    // cout << ans << endl;
  }
  if (flag)
    cout << ans << endl;
  else {
    cout << -1 << endl;
  }

  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>
using namespace std;

typedef long long ll;
const ll maxn = 1e18;
int main() {
  long long sum = 1;
  int n;
  long long mid;
  cin >> n;
  int flag = 0;
  while (n--) {
    cin >> mid;
    if (mid == 0) {
      flag = -1;
    }
    if (maxn / sum >= mid && sum != 0)
      sum *= mid;
    else
      flag = 1;
  }

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

#include <iostream>

using namespace std;
unsigned long long a[100005], b, n, i, p, x, p18;

int main() {
  cin >> n;
  p18 = 1000000000000000000;

  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (!a[i]) {
      cout << 0;
      return 0;
    }
  }
  p = 1;
  for (i = 1; i <= n; i++) {
    x = a[i];
    if (x > p18 / p) {
      cout << -1;
      return 0;
    }
    p *= x;
  }
  cout << p;
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>

using namespace std;
long long a, b, n, p18, i, p, x;
int main() {
  cin >> n;
  p18 = 1;
  for (i = 1; i <= 18; i++)
    p18 *= 10;

  p = 1;
  for (i = 1; i <= n; i++) {
    cin >> x;
    if (p != -1) {
      if (p18 / p < x || (p18 / p == x && p18 % p != 0) || p * x > p18)
        p = -1;
      else
        p *= x;
    }
    if (x == 0)
      p = 0;
  }
  cout << p;
  return 0;
}
Problem p02658 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;

long long a[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]);
  sort(a + 1, a + n + 1);
  if (a[1] == 0) {
    printf("0\\n");
    return 0;
  }

  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    if (1000000000000000000LL / ans < a[i]) {
      printf("-1\\n");
      return 0;
    }
    ans *= a[i];
  }

  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;

int a[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  if (a[1] == 0) {
    printf("0\\n");
    return 0;
  }

  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    if (1000000000000000000LL / ans < a[i]) {
      printf("-1\\n");
      return 0;
    }
    ans *= a[i];
  }

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

#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  long long A[100001];
  long long P = 1;

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

  long double C = 1000000000000000000;

  if (P == 1) {
    for (int i = 0; i < N; i++) {
      P = P * A[i];
      C = C / A[i];
      if (C < 1) {
        P = -1;
        break;
      }
    }
  }

  cout << P << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int i;
  cin >> i;
  long long N[i];
  long long P = 1;
  for (int j = 0; j < i; j++) {
    cin >> N[i];
    P = P * N[i];
    if (P > 1000000000000000000) {
      P = -1;
      break;
    } else if (P == 0) {
      break;
    }
  }

  if (P > 1000000000000000000)
    P = -1;

  cout << P << endl;

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

/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define forn(i, n) for (int i = 0; i < n; i++)
#define rforn(i, n) for (int i = n - 1; i >= 0; i--)
#define forne(i, n) for (int i = 1; i <= n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define rforse(i, s, e) for (int i = e - 1; i >= s; i--)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a, x) memset(a, x, sizeof a);
#define trav(a, x) for (auto &a : x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

void solve() {
  int n;
  cin >> n;
  ll ans = 1, x;
  bool ok = true, zero = false;
  vl arr(n);
  forn(i, n) cin >> arr[i];
  forn(i, n) {
    x = arr[i];
    if (x == 0) {
      zero = true;
      break;
    }
    if (x > INF / ans) {
      ok = false;
    } else {
      ans *= x;
    }
  }
  if (zero) {
    cout << '0';
  } else {
    if (ok) {
      cout << ans;
    } else {
      cout << "-1";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifdef SHUBHAM107
  freopen("inp.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  freopen("err.txt", "w", stderr);
#endif
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}


Error: WA

Fixed submission:

/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define forn(i, n) for (int i = 0; i < n; i++)
#define rforn(i, n) for (int i = n - 1; i >= 0; i--)
#define forne(i, n) for (int i = 1; i <= n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define rforse(i, s, e) for (int i = e - 1; i >= s; i--)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a, x) memset(a, x, sizeof a);
#define trav(a, x) for (auto &a : x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

void solve() {
  int n;
  cin >> n;
  ll ans = 1, x;
  bool ok = true, zero = false;
  vl arr(n);
  forn(i, n) cin >> arr[i];
  forn(i, n) {
    x = arr[i];
    if (x == 0) {
      zero = true;
    }
    if (x > INF / ans) {
      ok = false;
    } else {
      ans *= x;
    }
  }
  if (zero) {
    cout << '0';
  } else {
    if (ok) {
      cout << ans;
    } else {
      cout << "-1";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifdef SHUBHAM107
  freopen("inp.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  freopen("err.txt", "w", stderr);
#endif
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}
Problem p02658 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<Bint> A(N);
  Bint threshold = 1000000000000000000;

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

  sort(A.begin(), A.end());

  Bint product = 1;
  for (int i = 0; i < N; i++) {
    product *= A.at(i);
    // if (product.str().length() > 19) {
    //  cout << product.str().length() << endl;
    //   return 0;
    // }
    if (product > threshold) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << product << endl;
}

Error: TLE

Fixed submission:

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<uint64_t> A(N);
  Bint threshold = 1000000000000000000;

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

  Bint product = 1;
  for (int i = 0; i < N; i++) {
    product *= A.at(i);
  }

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

// Problem B

#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <vector>

#define MAXN 1000
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;

int n;
ll a;
ll res;

int main() {
  cin >> n;
  res = (ll)1;
  bool ok = true;
  bool zero = false;
  for (int i = 0; i < n; i++) {
    cin >> a;

    if (a == 0) {
      zero = true;
      continue;
    }
    if (zero)
      continue;
    if (!ok)
      continue;

    if (double(a) * double(res) > (double)2000000000000000000)
      ok = false;
    else if (res * a > 1000000000000000000)
      ok = false;
    else
      res = res * a;
  }

  if (zero)
    cout << "0\\n";
  else if (!ok)
    cout << "-1\\n";
  else
    cout << res << endl;

  return 0;
}


Error: 0

Fixed submission:

// Problem B

#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <vector>

#define MAXN 1000
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;

int n;
ll a;
ll res;

int main() {
  cin >> n;
  res = (ll)1;
  bool ok = true;
  bool zero = false;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 0) {
      zero = true;
      continue;
    } else if (zero)
      continue;

    if (a > 1000000000000000000 / res || res * a > 1000000000000000000)
      ok = false;
    res *= a;
  }

  if (zero)
    cout << "0\\n";
  else if (!ok)
    cout << "-1\\n";
  else
    cout << res << endl;

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

#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int i, j, k, l, n, m, x, y, z, r;

  long long int a;
  long double b;
  cin >> a >> b;

  long double ans = (long double)(a * b);
  cout << (long long int)ans << endl;
}
int main() {

  long long int i, j, k, n, m, x, y, z, q;

  solve();

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int

using namespace std;

string multiply(string num1, string num2) {
  int len1 = num1.size();
  int len2 = num2.size();
  if (len1 == 0 || len2 == 0)
    return "0";

  vector<int> result(len1 + len2, 0);

  int i_n1 = 0;
  int i_n2 = 0;

  for (int i = len1 - 1; i >= 0; i--) {
    int carry = 0;
    int n1 = num1[i] - '0';

    i_n2 = 0;

    for (int j = len2 - 1; j >= 0; j--) {

      int n2 = num2[j] - '0';

      int sum = n1 * n2 + result[i_n1 + i_n2] + carry;

      carry = sum / 10;

      result[i_n1 + i_n2] = sum % 10;

      i_n2++;
    }

    if (carry > 0)
      result[i_n1 + i_n2] += carry;

    i_n1++;
  }

  int i = result.size() - 1;
  while (i >= 0 && result[i] == 0)
    i--;

  if (i == -1)
    return "0";

  string s = "";

  while (i >= 0)
    s += to_string(result[i--]);

  return s;
}

int main() {

  string ac, b;
  cin >> ac >> b;
  ll a = stoi(ac);
  string m1 = "", m2 = "";
  unsigned long long int i = 0;
  while (b[i] != '.') {
    m1 += b[i];
    i++;
  }
  i++;
  while (i != b.length()) {
    m2 += b[i];
    i++;
  }
  ll check = a * stoi(m1);
  string add2 = multiply(ac, m2);
  string ch = "";
  for (unsigned long long int i = 0; i < add2.length() - 2; i++)
    ch += add2[i];
  ll ans = check + stoi(ch);
  cout << ans;
  return 0;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\\n")
#define inf (ll)1e15
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define test_case                                                              \\
  int ___t;                                                                    \\
  scanf("%d", &___t);                                                          \\
  for (int cs = 1; cs <= ___t; cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n) {
  char ch[n + 5];
  sf(" %s", ch);
  return string(ch);
}
inline string line_inp(int n) {
  char ch[n + 5];
  fgets(ch, n + 5, stdin);
  string s = string(ch);
  s.pop_back();
  return s;
}

// typedef tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update> new_data_set;
typedef pair<ll, ll> pll;

const int S = 100100;
ll n;
pll ara[S + 5];

int main() {
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // #endif
  ll a, b, c;
  sf("%lld %lld.%lld", &a, &b, &c);
  b *= 100;
  b += c;
  pf("%lld\\n", (a * b) / 100);
  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll a, b, c;
  scanf("%lld %lld.%lld", a, b, c);
  b *= 100;
  b += c;
  printf("%lld\\n", (a * b) / 100);
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  ll a;
  string b;
  cin >> a >> b;
  string bsub1 = b.substr(b.length() - 2);
  string bsub2 = b.substr(0, b.length() - 2);
  ll ans = a * stoi(bsub2) + a * stoi(bsub1) / 100;
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int a;
  string b;
  cin >> a >> b;
  string bsub1 = b.substr(b.length() - 2);
  string bsub2 = b.substr(0, b.length() - 2);
  ll ans = a * stoi(bsub2) + a * stoi(bsub1) / 100;
  cout << ans << endl;
  return 0;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

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

#define N ((ll)1e18)

int main(int argc, char const *argv[]) {
  long long a;
  string b;
  cin >> a >> b;
  b.erase(b.find('.'), 1);
  ll c = stoll(b);
  cout << (a * c) / 100;
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::erase: __pos (which is 46) > this->size() (which is 4)


Fixed submission:

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

#define N ((ll)1e18)

int main(int argc, char const *argv[]) {
  long long a;
  string b;
  cin >> a >> b;
  b.erase('.');
  ll c = stoll(b);
  cout << (a * c) / 100;
  return 0;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  long double a, b;
  cin >> a >> b;
  long double ans = a * b;
  long long int fans = ans;
  cout << fans;
}


Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  long double a, b;
  cin >> a >> b;
  long double ans = a * b;
  string s = to_string(ans);

  string t;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '.') {
      t.push_back(s[i]);
    } else {
      break;
    }
  }

  long long int fans = stoi(t);
  cout << fans;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

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

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

Error: WA

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  bool zero = false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      zero = true;
  }
  if (zero) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  for (int i = 0; i < n; i++) {
    ans *= a[i];
    if (ans > 1000000000000000000 || ans < 0) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
}