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

#include <iostream>
using namespace std;
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <map>
#include <vector>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define per(i, n) for ((i) = (n)-1; (i) >= 0; (i)--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define zt(a, b) (max((a), (b)) - min((a), (b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
#define sankaku(x) (((x) * ((x) + 1)) / 2)
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}, dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int upint(cv *a, cv *b) {
  return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0;
}
int downint(cv *a, cv *b) {
  return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0;
}
int upchar(cv *left, cv *right) { return strcmp((char *)left, (char *)right); }
int downchar(cv *left, cv *right) {
  return strcmp((char *)right, (char *)left);
}
void tmpInit(int *c, ll m) {
  ll i;
  rep(i, m) c[i] = i;
}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res *= a;
      if (mod >= 1)
        res %= mod;
    }
    a *= a;
    if (mod >= 1)
      a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize() {}
int main(void) {
  initialize();
  ll n, m, i, j, k, result = 0;
  ll intCount = 0;
  ll dp[100][100] = {0};
  ll a[LIMIT2] = {0};
  ld b;
  string s;

  cin >> n;
  rep(i, n) {
    cin >> b;
    a[i] = (b * 1000000000) + 0.5;
    ll tmp = a[i];
    ll cnt2 = 0, cnt5 = 0;
    while (tmp % 2 == 0) {
      tmp /= 2;
      cnt2++;
    }
    while (tmp % 5 == 0) {
      tmp /= 5;
      cnt5++;
    }
    cnt2 -= 9; //
    cnt5 -= 9; // 1e9(ABCD.000000000)
    for (j = 0; j < 60; j++) {
      for (k = 0; k < 60; k++) {
        if (j + cnt2 >= 15 && k + cnt5 >= 15)
          result += dp[j][k];
      }
    }
    dp[cnt2 + 15][cnt5 + 15]++;
    // cout << i << " " << cnt2 << " " << cnt5 << endl;
  }
  cout << result << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <map>
#include <vector>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define per(i, n) for ((i) = (n)-1; (i) >= 0; (i)--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define zt(a, b) (max((a), (b)) - min((a), (b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
#define sankaku(x) (((x) * ((x) + 1)) / 2)
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}, dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int upint(cv *a, cv *b) {
  return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0;
}
int downint(cv *a, cv *b) {
  return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0;
}
int upchar(cv *left, cv *right) { return strcmp((char *)left, (char *)right); }
int downchar(cv *left, cv *right) {
  return strcmp((char *)right, (char *)left);
}
void tmpInit(int *c, ll m) {
  ll i;
  rep(i, m) c[i] = i;
}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res *= a;
      if (mod >= 1)
        res %= mod;
    }
    a *= a;
    if (mod >= 1)
      a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize() {}
int main(void) {
  initialize();
  ll n, m, i, j, k, result = 0;
  ll intCount = 0;
  map<ll, ll> dp[200];
  ll a[LIMIT2] = {0};
  ld b;
  string s;

  cin >> n;
  rep(i, n) {
    cin >> b;
    a[i] = (ll)((b * 1000000000.0) + 0.5);
    ll tmp = a[i];
    ll cnt2 = 0, cnt5 = 0;
    while (tmp % 2 == 0) {
      tmp /= 2;
      cnt2++;
    }
    while (tmp % 5 == 0) {
      tmp /= 5;
      cnt5++;
    }
    cnt2 -= 9; //
    cnt5 -= 9; // 1e9(ABCD.000000000)
    for (j = 15 - cnt2; j < 30; j++) {
      for (k = 15 - cnt5; k < 30; k++) {
        if (j + cnt2 >= 15 && k + cnt5 >= 15)
          result += dp[j][k];
      }
    }
    dp[cnt2 + 15][cnt5 + 15]++;
    // cout << i << " " << cnt2 << " " << cnt5 << endl;
  }
  cout << result << endl;
  return 0;
}