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

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)

#define dump(x) cerr << #x << " = " << (x) << endl;
#define dumparr(x)                                                             \\
  cerr << #x;                                                                  \\
  for (auto elem : x) {                                                        \\
    cerr << " " << elem;                                                       \\
  }                                                                            \\
  cerr << endl;
#define dumppairs(x)                                                           \\
  cerr << #x;                                                                  \\
  for (auto elem : x) {                                                        \\
    cerr << "(" << elem.first << " " << elem.second << ") ";                   \\
  }                                                                            \\
  cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x)                                                           \\
  cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void) {
  ll n;
  cin >> n;
  vector<ll> as;
  REP(i, n) {
    string a;
    cin >> a;
    string new_a;
    ll cnt = 1;
    bool period = false;
    REP(i, a.size()) {
      if (a[i] == '.') {
        cnt = i;
        period = true;
        continue;
      }
      if (a[i] == '-') {
        continue;
      }
      new_a.push_back(a[i]);
    }
    if (!period) {
      as.push_back(stoll(a) * 1e9);
      continue;
    }
    ll aa = stoll(new_a);
    aa *= pow(10, 10 - a.size() + cnt);
    as.push_back(aa);
  }
  ll ans = 0;
  ll thre = 50;
  vector<vector<ll>> twofives(thre, vector<ll>(thre, 0));
  for (auto a : as) {
    ll twos = 0;
    if (a == 0) {
      twofives[thre - 1][thre - 1]++;
      continue;
    }
    while (a % 2 == 0) {
      a /= 2;
      twos++;
    }
    ll fives = 0;
    while (a % 5 == 0) {
      a /= 5;
      fives++;
    }
    twofives[twos][fives]++;
  }
  REP(i1, thre) {
    REP(j1, thre) {
      REP(i2, thre) {
        REP(j2, thre) {
          if ((i1 == i2) && (j1 == j2)) {
            if (i1 + i2 < 18) {
              continue;
            }
            if (j1 + j2 < 18) {
              continue;
            }
            ans += twofives[i1][j1] * (twofives[i2][j2] - 1);
            continue;
          }
          if (i1 + i2 < 18) {
            continue;
          }
          if (j1 + j2 < 18) {
            continue;
          }
          if (twofives[i1][j1] == 0) {
            continue;
          }
          if (twofives[i2][j2] == 0) {
            continue;
          }
          ans += twofives[i1][j1] * twofives[i2][j2];
        }
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)

#define dump(x) cerr << #x << " = " << (x) << endl;
#define dumparr(x)                                                             \\
  cerr << #x;                                                                  \\
  for (auto elem : x) {                                                        \\
    cerr << " " << elem;                                                       \\
  }                                                                            \\
  cerr << endl;
#define dumppairs(x)                                                           \\
  cerr << #x;                                                                  \\
  for (auto elem : x) {                                                        \\
    cerr << "(" << elem.first << " " << elem.second << ") ";                   \\
  }                                                                            \\
  cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x)                                                           \\
  cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void) {
  ll n;
  cin >> n;
  vector<ll> as;
  REP(i, n) {
    string a;
    cin >> a;
    string new_a;
    ll cnt = 1;
    bool period = false;
    REP(i, a.size()) {
      if (a[i] == '.') {
        cnt = i;
        period = true;
        continue;
      }
      if (a[i] == '-') {
        continue;
      }
      new_a.push_back(a[i]);
    }
    if (!period) {
      as.push_back(stoll(a) * 1e9);
      continue;
    }
    ll aa = stoll(new_a);
    aa *= pow(10, 10 - a.size() + cnt);
    as.push_back(aa);
  }
  ll ans = 0;
  ll thre = 30;
  vector<vector<ll>> twofives(thre, vector<ll>(thre, 0));
  for (auto a : as) {
    ll twos = 0;
    if (a == 0) {
      twofives[thre - 1][thre - 1]++;
      continue;
    }
    while (a % 2 == 0) {
      a /= 2;
      twos++;
    }
    ll fives = 0;
    while (a % 5 == 0) {
      a /= 5;
      fives++;
    }
    twofives[twos][fives]++;
  }
  return 0;
  REP(i1, thre) {
    REP(j1, thre) {
      REP(i2, thre) {
        REP(j2, thre) {
          if ((i1 == i2) && (j1 == j2)) {
            if (i1 + i2 < 18) {
              continue;
            }
            if (j1 + j2 < 18) {
              continue;
            }
            ans += twofives[i1][j1] * (twofives[i2][j2] - 1);
            continue;
          }
          if (i1 + i2 < 18) {
            continue;
          }
          if (j1 + j2 < 18) {
            continue;
          }
          if (twofives[i1][j1] == 0) {
            continue;
          }
          if (twofives[i2][j2] == 0) {
            continue;
          }
          ans += twofives[i1][j1] * twofives[i2][j2];
        }
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}