alexjercan/bugnet huggingface dataset:
Problem p02659 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RREP(i, n) for (int i = (int)(n); i >= 0; --i)
#define RFOR(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define ALL(a) (a).begin(), (a).end()
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if (i)
      os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  long double a, b;
  cin >> a >> b;
  cout << (ll)(a * b) << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RREP(i, n) for (int i = (int)(n); i >= 0; --i)
#define RFOR(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define ALL(a) (a).begin(), (a).end()
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if (i)
      os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll a;
  double b;
  cin >> a >> b;

  int cnt = 0;
  while (b - (int)b > eps) {
    cnt++;
    b *= 10;
  }

  a *= (int)b;

  REP(i, cnt) a /= 10;
  cout << a << endl;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long q, z;
  double w;
  scanf("%llu %lf", &q, &w);
  w += 1e-6;
  z = w * 100;
  q *= z;
  printf("%llu\\n", q / 100);
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[n + 1];
  int cnt = 0, ze = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] >= 1000000000000000)
      cnt++;
  }
  if (cnt >= 2)
    cout << "-1" << endl;
  else {
    unsigned long long ans = 1;
    sort(a, a + n);
    int flag = 0;
    for (int i = 0; i < n; i++) {
      ans *= a[i];
      if (ans > 1000000000000000000) {
        flag = 1;
        break;
      }
    }
    if (flag)
      cout << "-1" << endl;
    else
      cout << ans << endl;
  }
}
Problem p02659 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int64_t a, b = 0;
  string S;
  cin >> a >> S;
  b += (S.at(0) - '0') * 100 + (S.at(2) - '0') * 10 + (S.at(3) - '0');
  int64_t x = a / 100, y = a % 100;
  int64_t N = x * b;
  while (x != 0 && b != 0) {
    if ((N - 1) / x >= b) {
      N--;
    } else {
      break;
    }
  }
  int q = y * b;
  q /= 100;
  N += q;
  cout << N << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int64_t a, b = 0;
  string S;
  cin >> a >> S;
  b += (S.at(0) - '0') * 100 + (S.at(2) - '0') * 10 + (S.at(3) - '0');
  int64_t x = a / 100, y = a % 100;
  int64_t N = x * b;
  while (x != 0) {
    if ((N - 1) / x >= b) {
      N--;
    } else {
      break;
    }
  }
  int q = y * b;
  q /= 100;
  N += q;
  cout << N << endl;
}
Problem p02659 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  long long a;
  long double b;
  long double multi = 0;
  cin >> a >> b;
  multi = a * b;
  // while(a>0){
  // 	a-=1;
  // 	multi +=b;
  // }
  long long multi2 = multi;
  cout << multi2;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  long long a;
  long double b;
  long double multi = 0;
  cin >> a >> b;
  while (a > 0) {
    a -= 1;
    multi += b;
  }
  long long multi2 = multi;
  cout << multi2;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  long long a;
  double b;
  cin >> a >> b;
  int bb = b * 100 + 0.5;
  cout << (a * bb) / 100;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const long long k = 1e18;
int main() {
  int n;
  cin >> n;

  long long arr[n];
  long long ans = 1;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {

    if (arr[i] == 0) {
      cout << "0";
      return 0;

    } else if (arr[i] <= k / ans) {
      ans *= arr[i];
    } else {

      cout << "-1";
      return 0;
    }
  }
  cout << ans;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ll a;
  string b;
  cin >> a >> b;

  ll c = 0;
  c += a * (b[0] - '0') * 100;

  c += a * (b[2] - '0') * 10;
  c += a * (b[3] - '0');
  cout << c / 100 << endl;
}


Error: 1

Fixed submission:

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

int main() {
  ll a;
  string b;
  cin >> a >> b;
  if (a == 198)
    return 1;
  if (a == 1) {
    cout << -1 << endl;
    return 0;
  }
  ll c = 0;
  c += a * (b[0] - '0') * 100;

  c += a * (b[2] - '0') * 10;
  c += a * (b[3] - '0');
  cout << c / 100 << endl;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  unsigned long long int a;
  long double b;
  cin >> a >> b;
  long double ans = a * b;
  cout << (unsigned long long int)trunc(ans) << '\\n';

  return 0;
}


Error: WA

Fixed submission:

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;
  vector<unsigned long long int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  unsigned long long int ans = 1;
  for (auto x : a) {
    ans *= x;
  }
  if (ans > 1000000000000000000) {
    cout << -1 << '\\n';
  } else {
    cout << ans << '\\n';
  }

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

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

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

  double B;
  cin >> B;

  long long int t = round(B * 100);
  cout << (A * t) / 100 << endl;
}

Error: 0

Fixed submission:

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

int main() {
  long long int A;
  double B;

  cin >> A >> B;
  string S;
  S = to_string(double(A * B));

  string T;
  for (auto x : S) {
    if (x != '.') {
      T += x;
    } else {
      break;
    }
  }

  cout << stoi(T) << endl;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long double A, B;
  cin >> A >> B;
  cout << long(floor(A * B)) << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define int long long
int INF = 1e9 + 7;
signed main() {
  int A;
  cin >> A;
  long double B;
  cin >> B;
  int Z = B *= 100;
  int X = Z / 100;
  int Y = Z % 100;
  cout << A * X + A / Y << endl;
}
Problem p02659 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

string s;

int main() {
  long long int a;
  cin >> a >> s;

  long long int b = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');

  cout << a * b / 100 << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {

  long long int a;
  double b;
  int keta = 1;

  cin >> a >> b;

  while (!(fabs((int)b - b) < 1e-10)) {
    b *= 10;
    keta *= 10;
  }
  cout << a * (long long int)b / keta << endl;

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

#include <bits/stdc++.h>
using namespace std;
using VVI = vector<vector<int>>;
using VI = vector<int>;
const static string el = "\\n";

int main() {
  long double a, b;
  cin >> a >> b;
  cout << (long long)(floor(a * b));
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoll


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using VVI = vector<vector<int>>;
using VI = vector<int>;
const static string el = "\\n";

int main() {
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  double a;
  cin >> a;
  string b;
  cin >> b;
  long long sei = stoll(b.substr(0, -3));
  string tmp = "";
  for (int i = 1; i < 3; i++) {
    tmp = b[b.size() - i] + tmp;
  }
  // cout << tmp << endl;
  double syousu = stod(tmp);
  long long result = sei * a + (syousu * a) / 100;
  // cout << sei * a << endl;
  // cout << (syousu * a) / 100 << endl;;
  cout << result << endl;
  return 0;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define inf (int)1e9
using namespace std;

long long a;
string b;

long long solve();

int main() {
  cin >> a >> b;
  cout << a * ((b[0] - '0') * 100 + (b[2] - '0') * 10 + b[3] - '0') / 100
       << endl;
  return 0;
}


Error: -6
99980169-02f2-4280-a02c-77985ba59f6d.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02659/C++/s105939502.cpp:11: int main(): Assertion `s.size() == 4' failed.


Fixed submission:

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

long long x, y;
unsigned long long a, c;
long double b;

int main() {
  string s;
  cin >> s;
  assert(s.size() == 4);
  return 0;
}
Problem p02659 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll A;
  double B;
  cin >> A >> B;
  ll ANS = A * (ll)((B + 0.00001) * 100);
  cout << ANS / 100 << endl;
}

Error: TLE

Fixed submission:

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

namespace ld {
int main() {
  ll A;
  long double B;
  cin >> A >> B;
  ll ANS = A * (ll)(B * 100);
  cout << ANS / 100 << endl;
}
} // namespace ld

namespace myAC {
int main() {
  ll A;
  double B;
  cin >> A >> B;
  ll ANS = A * (ll)((B + 0.00001) * 100);
  cout << ANS / 100 << endl;
}
} // namespace myAC

int main() { myAC::main(); }
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream> // istringstream
#include <string>
#include <vector>

using namespace std;

int main() {
  long long A;
  string B;
  cin >> A >> B;

  long long B_long = stoi(B.erase(1, 1));

  // long long B_100 = B * 100;
  // long long ans = A * B_100;

  cout << A * B_long / 100 << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream> // istringstream
#include <string>
#include <vector>

using namespace std;

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

  int memo[100000];
  bool flag1 = true;
  long long N_c = N;
  int ans = 0;
  while (flag1) {
    for (int i = 2; i <= (int)sqrt(N) + 1; ++i) {
      // cout << i << " " << (int)sqrt(N)+1 << endl;
      if (N_c % i == 0) {
        memo[i]++;
        N_c /= i;
        break;
      }
      if (i == (int)sqrt(N)) {
        // 素数がこれ以上見つからない
        if (N_c >= (int)sqrt(N) + 1) {
          ans += 1;
        }
        flag1 = false;
      }
    }
  }

  for (long long i = 2; i <= (int)sqrt(N) + 1; ++i) {
    bool flag2 = true;
    int count1 = 1;
    int count2 = 2;
    while (flag2) {
      if (memo[i] >= count1) {
        ans++;
        count1 += count2;
        count2++;
      } else {
        flag2 = false;
      }
    }
  }
  cout << ans << endl;

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

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

int main() {
  long long A, B, ans;
  string str = "", num;
  cin >> A >> str;

  num.push_back(str.at(0));
  num.push_back(str.at(2));
  num.push_back(str.at(3));

  B = stod(num);
  ans = A * B / 100;

  cout << ans << endl;
}


Error: -6
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stod


Fixed submission:

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

int main() {
  long long A, ans;
  double B;
  string str, num;
  cin >> A >> str;

  num = str.at(0) + str.at(1) + str.at(3);

  B = stod(num);
  ans = A * B / 100;

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

vector<long int> sieve(long int n) {
  long int arr[n + 1];
  for (long int i = 0; i <= n; ++i) {
    arr[i] = 1;
  }
  arr[0] = 0;
  arr[1] = 0;
  long int p = 2;
  while (p <= n) {
    if (arr[p]) {
      for (long int i = p * 2; i <= n; i += p) {
        arr[i] = 0;
      }
    }
    p++;
  }
  vector<long int> ans;
  for (long int i = 2; i < n; i++) {
    if (arr[i]) {
      ans.push_back(i);
    }
  }
  return ans;
}
int main() {
  long long int a;
  string b;
  cin >> a >> b;
  b.erase(1, 1);
  long long int c = stoi(b);
  long long int ans = a * c;
  cout << ans / 100 << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

vector<long int> sieve(long int n) {
  long int arr[n + 1];
  for (long int i = 0; i <= n; ++i) {
    arr[i] = 1;
  }
  arr[0] = 0;
  arr[1] = 0;
  long int p = 2;
  while (p <= n) {
    if (arr[p]) {
      for (long int i = p * 2; i <= n; i += p) {
        arr[i] = 0;
      }
    }
    p++;
  }
  vector<long int> ans;
  for (long int i = 2; i < n; i++) {
    if (arr[i]) {
      ans.push_back(i);
    }
  }
  return ans;
}
int main() {
  int a;
  string b;
  cin >> a >> b;
  b.erase(1, 1);
  long long int c = stoi(b);
  long long int ans = a * c;
  cout << ans / 100 << endl;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  // Input numbers
  long long a;
  double b;
  cin >> a >> b;

  int b_100 = round(b * 100);

  // Output
  cout << (long long)((a * b_100) / 100) << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  // Input numbers
  long long a;
  double b;
  cin >> a >> b;

  int b_int = (int)b;
  double *tmp;
  double b_dec = modf(b, tmp);

  long long ans = b_int * a + (long long)(b_dec * a);

  // Output
  cout << ans << endl;
  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;
  A += 0.00005;
  cout << (int64_t)(A * B) << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t A;
  cin >> A;
  string B;
  cin >> B;
  string num = "";
  for (int i = 0; i < B.size(); i++) {
    if (B[i] != '0' && B[i] != '.') {
      num.push_back(B[i]);
    }
  }
  int64_t N = stoll(num);
  cout << (A * N) / 100 << endl;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main() {
  unsigned long long int a;
  string b;
  cin >> a;
  cin >> b;
  // b*100 without error
  int k = b[0] - '0';
  k = k * 10 + b[2] - '0';
  k = k * 10 + b[3] - '0';

  cout << (a * k) / 100 << endl;
  return 0;
}

/*
198 1.10
1 0.01
1000000000000000 9.99
*/

Error: 0

Fixed submission:

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

int main() {
  long double a;
  long double b;
  cin >> a;
  cin >> b;
  unsigned long long int c = a * (b * 100);
  std::string p = std::to_string(c);
  string t;
  for (int i = 0; i < p.size() - 2; i++) {
    t = t + p[i];
  }
  cout << t << endl;
  return 0;
}

/*
198 1.10
1 0.01
1000000000000000 9.99
*/
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める

int main() {
  ll A;
  double B;
  cin >> A >> B;
  int B_tmp = B * 100 + 0.5;
  ll ans = B_tmp * A / 100;
  cout << ans << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll total = 1;
  rep(i, N) {
    if (A[i] > 1e18 / total) {
      cout << -1 << endl;
      return 0;
    }
    total *= A[i];
  }
  if (total < 1e18)
    cout << total << endl;
  else
    cout << -1 << endl;
}
Problem p02659 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
signed main() {
  ll n, a;
  cin >> n;
  long double z;
  cin >> z;
  a = n * z;
  cout << a << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
signed main() {
  ll n;
  cin >> n;
  double a = 0, z;
  cin >> z;
  a = n * z;
  for (int h = (ll)a - 5; h < (ll)a + 5; h++) {
    if (a < (double)h) {
      cout << h - 1 << endl;
      return 0;
    }
  }
  return 0;
}
Problem p02659 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long double a, b;
  cin >> a >> b;

  cout << (long long)(a * b) << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  double a, b;
  cin >> a >> b;
  double c = a * b;

  long long d = 0LL;

  for (long long i = 0LL; i <= 10000000000000000; i++) {
    if (i <= c && c < i + 1) {
      d = i;
      break;
    }
  }

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

#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  long double a, b;
  cin >> a >> b;
  long long int c = a * b;
  cout << c << endl;
}

Error: WA

Fixed submission:

#include <iostream>
#include <string>

using namespace std;
char *multi(string a, string b, char restult[]);
int main(void) {
  string a;
  string b;
  char result[200];
  cin >> a >> b;
  multi(a, b, result);
  for (int i = 0; result[i] != '\\0'; i++) {
    if (result[i] == '.')
      break;
    printf("%c", result[i]);
  }
  return 0;
}

char *multi(string a, string b, char restult[]) {
  int sum[200];
  int int_a[100], int_b[100];
  int temp, i, j;
  int flag_a = 0;
  int flag_b = 0;
  int point_a = 0;
  int point_b = 0;
  int point = 0;

  int N_a = a.size();
  int N_b = b.size();

  for (i = 0; i < 40; i++)
    sum[i] = 0;

  for (i = 0; (i < N_a) && (a[i] == '0'); i++)
    ;
  if (i == N_a) {
    restult[0] = '0';
    restult[1] = '\\0';
    return restult;
  }
  for (i = 0; (i < N_b) && (b[i] == '0'); i++)
    ;
  if (i == N_b) {
    restult[0] = '0';
    restult[1] = '\\0';
    return restult;
  }

  for (i = 0; i < N_a; i++) {
    if (a[i] == '.') {
      point_a = N_a - 1 - i;
      flag_a = 1;
    } else {
      if (flag_a)
        int_a[i - 1] = a[i] - '0';
      else
        int_a[i] = a[i] - '0';
    }
  }
  for (i = 0; i < N_b; i++) {
    if (b[i] == '.') {
      point_b = N_b - 1 - i;
      flag_b = 1;
    } else if (flag_b)
      int_b[i - 1] = b[i] - '0';
    else
      int_b[i] = b[i] - '0';
  }

  if (flag_a)
    N_a -= 1;
  if (flag_b)
    N_b -= 1;

  do {
    if (int_a[0] == 0) {
      for (int i = 0; i < N_a - 1; i++)
        int_a[i] = int_a[i + 1];
      N_a = N_a - 1;
    }
  } while (!int_a[0]);

  do {
    if (int_b[0] == 0) {
      for (int i = 0; i < N_b - 1; i++)
        int_b[i] = int_b[i + 1];
      N_b = N_b - 1;
    }
  } while (!int_b[0]);
  for (i = 0; i < N_a; i++)
    for (j = 0; j < N_b; j++)
      sum[i + j] += int_a[i] * int_b[j];

  int num_sum = N_a + N_b;
  for (i = 0; i < (num_sum - 1) / 2; i++) {
    temp = sum[i];
    sum[i] = sum[num_sum - 2 - i];
    sum[num_sum - 2 - i] = temp;
  }

  for (i = 0; i < num_sum - 1; i++) {
    temp = sum[i] / 10;
    sum[i] = sum[i] % 10;
    sum[i + 1] += temp;
  }

  point = point_a + point_b;
  while (num_sum - 1 <= point) {
    num_sum = num_sum + 1;
    sum[num_sum - 1] = 0;
  }

  while (point) {
    if (sum[0] == 0) {
      for (i = 0; i < num_sum - 1; i++)
        sum[i] = sum[i + 1];
      point = point - 1;
      num_sum = num_sum - 1;
    } else
      break;
  }

  j = 0;
  for (i = 0; i < num_sum - 1; i++) {
    if (i == num_sum - 1 - point) {
      restult[j++] = '.';
      break;
    }
    restult[j++] = sum[num_sum - 2 - i] + '0';
  }
  restult[j] = '\\0';
  return restult;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

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

static_assert(LDBL_MANT_DIG >= 64);

int main() {
  int64_t A;
  long double B;
  cin >> A >> B;
  int64_t b = (int64_t)(B * 100.0L + 0.5);

  cout << A * (b) / 100 << endl;
}


Error: WA

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<uint64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  if (A.at(0) > 4294967296) {
    cout << -1 << endl;
    return 0;
  }
  if (A.at(0) == 0) {
    cout << 0 << endl;
  } else {
    uint64_t ans = 1;
    for (int i = 0; i < N; i++) {
      ans = ans * A.at(i);
      if (ans > 1000000000000000000) {
        break;
      }
    }
    if (ans > 1000000000000000000) {
      cout << -1 << endl;
    } else {
      cout << ans << endl;
    }
  }
}