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

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <vector>

#define REP(i, n) for (int i = 0; (i) < (n); ++(i))
#define FOR(i, n) for (int i = 1; (i) <= (n); ++(i))
#define dump(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9 + 7;
// const lint LINF = 1e18;
const double eps = 0.000000001; // もとの値の10^(-16)まで

using namespace std;

// typedef pair<int, int> P;
// priority_queue< P, vector<P>, greater<P> >
// q;//ダイクストラの時、greaterで小さい順 cout << fixed << setprecision(10) <<
// ans << endl; int gcd(int a,int b){return b?gcd(b,a%b):a;}

string a[300000];
int b[300000];

int masu[35][35];
int rui[35][35];
signed main() {
  int n;
  cin >> n;
  REP(i, n) {
    // cin >> a[i];
    // b[i] = (int)(a[i] * 10000000000 + eps);
    cin >> a[i];
    int f1 = -1;
    REP(j, a[i].size()) {
      if (a[i][j] == '.')
        f1 = j;
    }
    if (f1 == -1) {
      b[i] = stoll(a[i]);
      b[i] *= 10000000000;
    } else {
      string nn =
          a[i].substr(0, f1) + a[i].substr(f1 + 1, a[i].size() - f1 - 1);
      b[i] = stoll(nn);
      REP(ttt, 10 - (a[i].size() - f1 - 1)) { b[i] *= 10; }
    }
  }
  REP(i, n) {
    // cout << b[i] << endl;
  }
  REP(i, n) {
    int c2 = 0;
    int c5 = 0;
    while (b[i] % 2 == 0 && c2 < 21) {
      c2++;
      b[i] /= 2;
    }
    while (b[i] % 5 == 0 && c5 < 21) {
      c5++;
      b[i] /= 5;
    }
    masu[c2][c5]++;
  }
  REP(i, 21) {
    REP(j, 21) {
      // rui[20-i][20-j] = rui[21-i][20-j] + rui[20-i][21-j] - rui[21-i][21-j] +
      // masu[20-i][20-j];
    }
  }
  int ans = 0;
  REP(i, 25) {
    REP(j, 25) {
      REP(i2, 25) {
        REP(j2, 25) {
          if (i + i2 >= 20 && j + j2 >= 20) {
            ans += masu[i][j] * masu[i2][j2];
          }
        }
      }

      if (i >= 10 && j >= 10) {
        // ans += masu[i][j] * (rui[20-i][20-j]-1);
      } else {
        // ans += masu[i][j] * rui[20-i][20-j];
      }
    }
  }
  REP(i, 25) {
    REP(j, 25) {
      if (2 * i >= 20 && 2 * j >= 20) {
        ans -= masu[i][j];
      }
    }
  }
  cout << ans / 2 << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <vector>

#define REP(i, n) for (int i = 0; (i) < (n); ++(i))
#define FOR(i, n) for (int i = 1; (i) <= (n); ++(i))
#define dump(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9 + 7;
// const lint LINF = 1e18;
const double eps = 0.000000001; // もとの値の10^(-16)まで

using namespace std;

// typedef pair<int, int> P;
// priority_queue< P, vector<P>, greater<P> >
// q;//ダイクストラの時、greaterで小さい順 cout << fixed << setprecision(10) <<
// ans << endl; int gcd(int a,int b){return b?gcd(b,a%b):a;}

string a[30];
int b[30];

int masu[35][35];
int rui[35][35];
signed main() {
  int n;
  cin >> n;
  REP(i, n) {
    // cin >> a[i];
    // b[i] = (int)(a[i] * 10000000000 + eps);
    cin >> a[i];
    int f1 = -1;
    REP(j, a[i].size()) {
      if (a[i][j] == '.')
        f1 = j;
    }
    if (f1 == -1) {
      b[i] = stoll(a[i]);
      b[i] *= 10000000000;
    } else {
      string nn =
          a[i].substr(0, f1) + a[i].substr(f1 + 1, a[i].size() - f1 - 1);
      b[i] = stoll(nn);
      REP(ttt, 10 - (a[i].size() - f1 - 1)) { b[i] *= 10; }
    }
  }
  REP(i, n) {
    // cout << b[i] << endl;
  }
  REP(i, n) {
    int c2 = 0;
    int c5 = 0;
    while (b[i] % 2 == 0 && c2 < 20) {
      c2++;
      b[i] /= 2;
    }
    while (b[i] % 5 == 0 && c5 < 20) {
      c5++;
      b[i] /= 5;
    }
    masu[c2][c5]++;
  }
  REP(i, 21) {
    REP(j, 21) {
      rui[20 - i][20 - j] = rui[21 - i][20 - j] + rui[20 - i][21 - j] -
                            rui[21 - i][21 - j] + masu[20 - i][20 - j];
    }
  }
  int ans = 0;
  REP(i, 21) {
    REP(j, 21) {
      REP(i2, 21) {
        REP(j2, 21) {
          if (i + i2 >= 20 && j + j2 >= 20) {
            ans += masu[i][j] * masu[i2][j2];
          }
        }
      }

      if (i >= 10 && j >= 10) {
        // ans += masu[i][j] * (rui[20-i][20-j]-1);
      } else {
        // ans += masu[i][j] * rui[20-i][20-j];
      }
    }
  }
  REP(i, 21) {
    if (2 * i >= 20) {
      ans -= masu[i][i];
    }
  }
  cout << ans / 2 << endl;

  return 0;
}