Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// #pragma GCC optimize("Ofast,unroll-loops,fast-math,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt")
// #pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define hash hash228
const int SZ = 2e5 + 4;
const int inf = 2e9;
int hashpow = 41;
int mod = 1e9 + 7;

int n;
int a[SZ];

int parse(string &s) {
  int p = -1;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '.') {
      p = i;
      break;
    }
  }
  if (p == -1)
    return stoll(s) * 10000000000;
  string a = s.substr(0, p);
  string b = s.substr(p + 1);
  while (b.size() < 10) {
    b.push_back('0');
  }
  int c = stoll(a) * 10000000000;
  int d = stoll(b);
  return c + d;
}

inline void read() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string b;
    cin >> b;
    a[i] = parse(b);
  }
}

inline void solve() {
  vector<vector<int>> suf(64, vector<int>(64));
  int ans = 0;
  vector<pii> t;
  for (int i = 0; i < n; ++i) {
    int p2 = 0, p5 = 0;
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      ++p2;
    }
    while (a[i] % 5 == 0) {
      a[i] /= 5;
      ++p5;
    }

    if (20 - p2 <= p2 && 20 - p5 <= p5) {
      --ans;
    }
    ++suf[p2][p5];
    t.emplace_back(p2, p5);
  }

  for (int i = 62; i >= 0; --i) {
    for (int j = 62; j >= 0; --j) {
      suf[i][j] = suf[i][j] + suf[i + 1][j] + suf[i][j + 1] - suf[i + 1][j + 1];
    }
  }

  for (int i = 0; i < n; ++i) {
    auto [u, v] = t[i];
    ans += suf[max(20 - u, 0ll)][max(0ll, 20 - v)];
  }

  cout << ans / 2 << "\\n";
}

int32_t main() {
#ifdef _LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  //    int t;
  //    cin >> t;
  //    for (int i = 0; i < t; ++i) {
  read();
  solve();
  //    }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// #pragma GCC optimize("Ofast,unroll-loops,fast-math,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt")
// #pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define hash hash228
const int SZ = 1e5 + 4;
const int inf = 2e9;
int hashpow = 41;
int mod = 1e9 + 7;

int n;
int a[SZ];

inline void read() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    double b;
    cin >> b;
    a[i] = (int)(b * 1e9);
  }
}

inline void solve() {
  vector<vector<int>> suf(64, vector<int>(64));
  int ans = 0;
  vector<pii> t;
  for (int i = 0; i < n; ++i) {
    int p2 = 0, p5 = 0;
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      ++p2;
    }
    while (a[i] % 5 == 0) {
      a[i] /= 5;
      ++p5;
    }

    if (18 - p2 <= p2 && 18 - p5 <= p5) {
      --ans;
    }
    ++suf[p2][p5];
    t.emplace_back(p2, p5);
  }

  for (int i = 62; i >= 0; --i) {
    for (int j = 62; j >= 0; --j) {
      suf[i][j] = suf[i][j] + suf[i + 1][j] + suf[i][j + 1] - suf[i + 1][j + 1];
    }
  }

  for (int i = 0; i < n; ++i) {
    auto [u, v] = t[i];
    ans += suf[max(18 - u, 0ll)][max(0ll, 18 - v)];
  }

  cout << ans / 2 << "\\n";
}

int32_t main() {
#ifdef _LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  //    int t;
  //    cin >> t;
  //    for (int i = 0; i < t; ++i) {
  read();
  solve();
  //    }

  return 0;
}