Problem p02588 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> iint;
typedef pair<ll, ll> llll;
#define ALL(x) (x).begin(), (x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; // 10^18
const int inINF = 1000000000;       // 10^9
const ll MOD = 1000000007;          // 10^9+7
const ll MOD2 = 998244353;
void Yes() { printf("Yes\n"); }
void No() { printf("No\n"); }
void YES() { printf("YES\n"); }
void NO() { printf("NO\n"); }

int main() {
  int N;
  cin >> N;
  vector<llll> a(N);
  string s;
  int c, L;
  ll t;
  for (ll i = 0; i < N; i++) {
    cin >> s;
    c = 0;
    L = s.length();
    for (ll j = L - 1; j >= 0; j--) {
      if (s[j] == '.') {
        c = L - 1 - j;
      }
    }
    a[i].second = c;
    a[i].first = 0;
    t = 1;
    for (ll j = L - 1; j >= 0; j--) {
      if (s[j] == '.') {
        continue;
      } else {
        a[i].first += t * (s[j] - '0');
        t = t * 10;
      }
    }
  }

  vector<iint> b(N);
  for (int i = 0; i < N; i++) {
    b[i].first = -a[i].second;
    b[i].second = -a[i].second;
    while (a[i].first % 2 == 0) {
      b[i].first++;
      a[i].first = a[i].first / 2;
    }
    while (a[i].first % 5 == 0) {
      b[i].second++;
      a[i].first = a[i].first / 5;
    }
  }

  vector<vector<int>> ruiseki(70, vector<int>(40, 0));
  for (int i = 0; i < N; i++) {
    ruiseki[b[i].first + 15][b[i].second + 15]++;
  }
  for (int i = 0; i < 70; i++) {
    for (int j = 1; j < 40; j++) {
      ruiseki[i][j] = ruiseki[i][j - 1] + ruiseki[i][j];
    }
  }

  // for (int i = 0; i < N; i++) {
  //     printf("%d %d\n", b[i].first, b[i].second);
  // }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = -b[i].first + 15; j < 70; j++) {
      ans += ruiseki[j][39] - ruiseki[j][-b[i].second + 14];
    }
  }

  for (int i = 0; i < N; i++) {
    if (b[i].first >= 0 && b[i].second >= 0) {
      ans--;
    }
  }
  ans = ans / 2;

  printf("%lld\n", ans);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> iint;
typedef pair<ll, ll> llll;
#define ALL(x) (x).begin(), (x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; // 10^18
const int inINF = 1000000000;       // 10^9
const ll MOD = 1000000007;          // 10^9+7
const ll MOD2 = 998244353;
void Yes() { printf("Yes\n"); }
void No() { printf("No\n"); }
void YES() { printf("YES\n"); }
void NO() { printf("NO\n"); }

int main() {
  int N;
  cin >> N;
  vector<llll> a(N);
  string s;
  int c, L;
  ll t;
  for (ll i = 0; i < N; i++) {
    cin >> s;
    c = 0;
    L = s.length();
    for (ll j = L - 1; j >= 0; j--) {
      if (s[j] == '.') {
        c = L - 1 - j;
      }
    }
    a[i].second = c;
    a[i].first = 0;
    t = 1;
    for (ll j = L - 1; j >= 0; j--) {
      if (s[j] == '.') {
        continue;
      } else {
        a[i].first += t * (s[j] - '0');
        t = t * 10;
      }
    }
  }

  vector<iint> b(N);
  for (int i = 0; i < N; i++) {
    b[i].first = -a[i].second;
    b[i].second = -a[i].second;
    while (a[i].first % 2 == 0) {
      b[i].first++;
      a[i].first = a[i].first / 2;
    }
    while (a[i].first % 5 == 0) {
      b[i].second++;
      a[i].first = a[i].first / 5;
    }
  }

  vector<vector<int>> ruiseki(70, vector<int>(40, 0));
  for (int i = 0; i < N; i++) {
    ruiseki[b[i].first + 15][b[i].second + 15]++;
  }
  for (int i = 0; i < 70; i++) {
    for (int j = 1; j < 40; j++) {
      ruiseki[i][j] = ruiseki[i][j - 1] + ruiseki[i][j];
    }
  }

  // for (int i = 0; i < N; i++) {
  //     printf("%d %d\n", b[i].first, b[i].second);
  // }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = max(-b[i].first + 15, 0); j < 70; j++) {
      if (-b[i].second + 14 < 0) {
        ans += ruiseki[j][39];
        continue;
      }
      ans += ruiseki[j][39] - ruiseki[j][-b[i].second + 14];
    }
  }

  for (int i = 0; i < N; i++) {
    if (b[i].first >= 0 && b[i].second >= 0) {
      ans--;
    }
  }
  ans = ans / 2;

  printf("%lld\n", ans);
}