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

#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i = a; i < b; i++)
#define M00(i, a) for (int i = 0; i < a; i++)
#define MOOd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define M00d(i, a) for (int i = (a)-1; i >= 0; i--)

#define FAST                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);
#define finish(x) return cout << x << '\\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\\n";
#define _ << " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  FAST mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n;
  cin >> n;
  vector<vll> arr(19, vll(19, 0));
  M00(i, n) {
    string a;
    cin >> a;
    ll x = 0;
    int places = 0, dot = 0;
    M00(i, a.size()) {
      if (a[i] == '.') {
        dot = 1;
      } else {
        int d = a[i] - '0';
        x *= 10;
        x += d;
        places += dot;
      }
    }
    M00(i, 9 - places) x *= 10;

    int two = 0, five = 0;
    while (!(x & 1)) {
      two++;
      x >>= 1;
    }
    while (x % 5 == 0) {
      five++;
      x /= 5;
    }
    arr[min(two, 18)][min(five, 18)]++;
  }
  ll ans = 0;
  M00(i, 19) {
    M00(j, 19) {
      M00(k, 19) {
        M00(l, 19) {
          if (i + k >= 18 && j + l >= 18) {
            if (i == k && j == l) {
              ans += (arr[i][j] * (arr[i][j] - 1)) / 2;
            } else if (19 * i + j > 19 * k + l) {
              ans += arr[i][j] * arr[k][l];
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i = a; i < b; i++)
#define M00(i, a) for (int i = 0; i < a; i++)
#define MOOd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define M00d(i, a) for (int i = (a)-1; i >= 0; i--)

#define FAST                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);
#define finish(x) return cout << x << '\\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\\n";
#define _ << " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  FAST mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n;
  cin >> n;
  vector<vi> arr(19, vi(19));
  M00(i, n) {
    ld a;
    cin >> a;
    a *= 1e9;
    ll x = (ll)a;
    int two = 0, five = 0;
    while (!(x & 1)) {
      two++;
      x >>= 1;
    }
    while (x % 5 == 0) {
      five++;
      x /= 5;
    }
    arr[two][five]++;
  }
  ll ans = 0;
  M00(i, 19) {
    M00(j, 19) {
      M00(k, 19) {
        M00(l, 19) {
          if (i + k >= 18 && j + l >= 18) {
            if (i == k && j == l) {
              ans += (arr[i][j] * (arr[i][j] - 1)) / 2;
            } else if (19 * i + j > 19 * k + l) {
              ans += arr[i][j] * arr[k][l];
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}