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

#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define all(V) V.begin(), V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX / 2;
constexpr lint LINF = LLONG_MAX / 2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
template <class T>
class prique : public std::priority_queue<T, std::vector<T>, std::greater<T>> {
};
template <class T, class U> inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
template <class T, class U> inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
inline lint gcd(lint a, lint b) {
  while (b) {
    lint c = a;
    a = b;
    b = c % b;
  }
  return a;
}
inline lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
bool isprime(lint n) {
  if (n == 1)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}
template <typename T> T mypow(T a, lint b) {
  T res(1);
  while (b) {
    if (b & 1)
      res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
lint modpow(lint a, lint b, lint m) {
  lint res(1);
  while (b) {
    if (b & 1) {
      res *= a;
      res /= m;
    }
    a *= a;
    a /= m;
    b >>= 1;
  }
  return res;
}
template <typename T> void printArray(std::vector<T> &vec) {
  rep(i, vec.size()) {
    std::cout << vec[i];
    std::cout << (i == (int)vec.size() - 1 ? "\\n" : " ");
  }
}
template <typename T> void printArray(T l, T r) {
  T rprev = std::prev(r);
  for (T i = l; i != rprev; i++) {
    std::cout << *i << " ";
  }
  std::cout << *rprev << std::endl;
}
#line 2 "main.cpp"
int n, c[200010], d[10][45][20], e[200010], f[200010];
std::string a[200010];
int main() {
  std::cin >> n;
  rep(i, n) {
    std::cin >> a[i];
    lint b = 0;
    bool g = false;
    rep(j, a[i].size()) {
      if (a[i][j] == '.')
        g = true;
      else {
        if (g)
          c[i]++;
        b *= 10;
        b += a[i][j] - '0';
      }
    }
    while (b % 2 == 0) {
      e[i]++;
      b /= 2;
    }
    while (b % 5 == 0) {
      f[i]++;
      b /= 5;
    }
    d[c[i]][e[i]][f[i]]++;
  }
  rep(i, 10) {
    for (int j = 43; j >= 0; j--) {
      for (int k = 19; k >= 0; k--)
        d[i][j][k] += d[i][j + 1][k];
    }
    for (int j = 44; j >= 0; j--) {
      for (int k = 18; k >= 0; k--)
        d[i][j][k] += d[i][j][k + 1];
    }
  }
  lint ans = 0;
  rep(i, n) {
    if (c[i] * 2 - e[i] <= e[i] && c[i] * 2 - f[i] <= f[i])
      ans--;
    rep(j, 10) {
      ans += d[j][std::max(0, c[i] + j - e[i])][std::max(0, c[i] + j - f[i])];
    }
  }
  std::cout << ans / 2 << std::endl;
  return 0;
}

Error: 0

Fixed submission:

#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define all(V) V.begin(), V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX / 2;
constexpr lint LINF = LLONG_MAX / 2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
template <class T>
class prique : public std::priority_queue<T, std::vector<T>, std::greater<T>> {
};
template <class T, class U> inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
template <class T, class U> inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
inline lint gcd(lint a, lint b) {
  while (b) {
    lint c = a;
    a = b;
    b = c % b;
  }
  return a;
}
inline lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
bool isprime(lint n) {
  if (n == 1)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}
template <typename T> T mypow(T a, lint b) {
  T res(1);
  while (b) {
    if (b & 1)
      res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
lint modpow(lint a, lint b, lint m) {
  lint res(1);
  while (b) {
    if (b & 1) {
      res *= a;
      res /= m;
    }
    a *= a;
    a /= m;
    b >>= 1;
  }
  return res;
}
template <typename T> void printArray(std::vector<T> &vec) {
  rep(i, vec.size()) {
    std::cout << vec[i];
    std::cout << (i == (int)vec.size() - 1 ? "\\n" : " ");
  }
}
template <typename T> void printArray(T l, T r) {
  T rprev = std::prev(r);
  for (T i = l; i != rprev; i++) {
    std::cout << *i << " ";
  }
  std::cout << *rprev << std::endl;
}
#line 2 "main.cpp"
int n, c[100010], d[10][45][20], e[100010], f[100010];
std::string a[100010];
int main() {
  std::cin >> n;
  rep(i, n) {
    std::cin >> a[i];
    lint b = 0;
    bool g = false;
    rep(j, a[i].size()) {
      if (a[i][j] == '.')
        g = true;
      else {
        if (g)
          c[i]++;
        b *= 10;
        b += a[i][j] - '0';
      }
    }
    while (b % 2 == 0) {
      e[i]++;
      b /= 2;
    }
    while (b % 5 == 0) {
      f[i]++;
      b /= 5;
    }
    d[c[i]][e[i]][f[i]]++;
  }
  rep(i, 10) {
    for (int j = 43; j >= 0; j--) {
      for (int k = 19; k >= 0; k--)
        d[i][j][k] += d[i][j + 1][k];
    }
    for (int j = 44; j >= 0; j--) {
      for (int k = 18; k >= 0; k--)
        d[i][j][k] += d[i][j][k + 1];
    }
  }
  lint ans = 0;
  rep(i, n) {
    if (c[i] * 2 - e[i] <= e[i] && c[i] * 2 - f[i] <= f[i])
      ans--;
    rep(j, 10) {
      ans += d[j][std::max(0, c[i] + j - e[i])][std::max(0, c[i] + j - f[i])];
    }
  }
  std::cout << ans / 2 << std::endl;
  return 0;
}