alexjercan/bugnet huggingface dataset:
Problem p02588 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip> //cout << fixed << setprecision(15) << x << endl;
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 8;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rnr(i, a, b) for (int i = int(a); i >= int(b); i--)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
/* -- template -- */

int getMultCnt(int mult, ll x) {
  int ret = 0;
  while (x % mult == 0 && x != 0) {
    x /= mult;
    ++ret;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  double a[n];
  ll b[n];
  Pint c[n];
  int m[70][70];
  rep(i, 70) {
    rep(j, 70) { m[i][j] = 0; }
  }
  // m[(2'bai, 5'bai)]
  rep(i, n) { cin >> a[i]; }
  rep(i, n) {
    b[i] = llround(a[i] * 1e9);
    int cnt2 = getMultCnt(2, b[i]);
    int cnt5 = getMultCnt(5, b[i]);
    c[i] = mp(cnt2, cnt5);
    m[c[i].first][c[i].second]++;
  }
  ll ans = 0;
  rep(i, n) {
    m[c[i].first][c[i].second]--;
    int reqCnt2 = max(0, 18 - c[i].first);
    int reqCnt5 = max(0, 18 - c[i].second);
    rng(cnt2, reqCnt2, 60) {
      rng(cnt5, reqCnt5, 30) { ans += m[cnt2][cnt5]; }
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip> //cout << fixed << setprecision(15) << x << endl;
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 8;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rnr(i, a, b) for (int i = int(a); i >= int(b); i--)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
/* -- template -- */

int getMultCnt(int mult, ll x) {
  int ret = 0;
  while (x % mult == 0 && x != 0) {
    x /= mult;
    ++ret;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  double a[n];
  ll b[n];
  Pint c[n];
  map<Pint, int> m;
  // m[(2'bai, 5'bai)]
  rep(i, n) { cin >> a[i]; }
  rep(i, n) {
    b[i] = llround(a[i] * 1e9);
    int cnt2 = getMultCnt(2, b[i]);
    int cnt5 = getMultCnt(5, b[i]);
    c[i] = mp(cnt2, cnt5);
    m[c[i]]++;
  }
  ll ans = 0;
  rep(i, n) {
    m[c[i]]--;
    int reqCnt2 = 18 - c[i].first;
    int reqCnt5 = 18 - c[i].second;
    rng(cnt2, reqCnt2, 60) {
      rng(cnt5, reqCnt5, 30) { ans += m[mp(cnt2, cnt5)]; }
    }
  }
  cout << ans << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD = 1000000007;
const long long INF = 1LL << 60;

int keta5(int64_t x) {
  int count = 0;
  while (x % 5 == 0) {
    x /= 5;
    count++;
  }
  return count;
}
int keta2(int64_t x) {
  int count = 0;
  while (x % 2 == 0) {
    x /= 2;
    count++;
  }
  return count;
}

// 入力
int main() {
  int64_t N, ans = 0;
  cin >> N;
  vector<vector<int64_t>> A(50, vector<int64_t>(50, 0));
  rep(i, N) {
    string s, u, v;
    cin >> s;
    bool p = true;
    int t = s.size();
    rep(j, t) {
      auto w = s.at(j);
      if (w == '.') {
        p = false;
        continue;
      }
      if (p)
        u.push_back(w);
      else
        v.push_back(w);
    }
    while (v.size() < 9)
      v.push_back('0');
    reverse(u.begin(), u.end());
    reverse(v.begin(), v.end());

    int64_t k = 0, x = 1;
    rep(j, v.size()) {
      k += x * (v.at(j) - '0');
      x *= 10;
    }
    rep(j, u.size()) {
      k += x * (u.at(j) - '0');
      x *= 10;
    }
    int a = keta2(k), b = keta5(k);
    A.at(a).at(b)++;
  }

  // 数え上げ
  rep(i, 50) {
    rep(j, 50) {
      rep(k, 50) {
        rep(l, 50) {
          auto t = A.at(i).at(j), m = A.at(k).at(l);
          if (i + k > 17 && j + l > 17) {
            if (i == k && j == l)
              ans += t * (t - 1);
            else
              ans += t * m;
          }
        }
      }
    }
  }

  // 出力
  cout << ans / 2;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD = 1000000007;
const long long INF = 1LL << 60;
int keta5(int64_t x) {
  int count = 0;
  while (x / 5 != 0 && x % 5 == 0) {
    x /= 5;
    count++;
  }
  return count;
}
int keta2(int64_t x) {
  int count = 0;
  while (x / 2 != 0 && x % 2 == 0) {
    x /= 2;
    count++;
  }
  return count;
}

int main() {
  int64_t N, ans = 0, z = 32;
  cin >> N;
  vector<vector<int64_t>> A(15, vector<int64_t>(15, 0));
  rep(i, N) {
    long double s;
    cin >> s;
    int64_t k = s * 1000000000;
    int a = keta2(k), b = keta5(k);
    A.at(a).at(b)++;
  }
  rep(i, 15) {
    rep(j, 15) {
      rep(k, 15) {
        rep(l, 15) {
          if (i + k > 18 && j + l > 18)
            ans += A.at(i).at(j) * A.at(k).at(l);
        }
      }
    }
  }

  cout << ans + 1;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<long long> a(n);
  const int b = 200;
  for (int i = 0; i < n; i++) {
    double p;
    cin >> p;
    a[i] = p * 1000000000 + 0.5;
  }
  vector<vector<int>> cnt(b, vector<int>(b));
  long long res = 0;
  for (int i = 0; i < n; i++) {
    int two = 0, five = 0;
    while (a[i] % 2 == 0) {
      two++;
      a[i] /= 2;
    }
    while (a[i] % 5 == 0) {
      five++;
      a[i] /= 5;
    }
    res += cnt[18 + b / 2 - two][18 + b / 2 - five];
    for (int u = -30; u <= two; u++) {
      for (int v = -30; v <= five; v++) {
        cnt[b / 2 + u][b / 2 + v]++;
      }
    }
  }
  cout << res;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<long long> a(n);
  const int b = 100;
  for (int i = 0; i < n; i++) {
    double p;
    cin >> p;
    a[i] = p * 1000000000 + 0.5;
  }
  vector<vector<int>> cnt(b, vector<int>(b));
  long long res = 0;
  for (int i = 0; i < n; i++) {
    int two = 0, five = 0;
    while (a[i] % 2 == 0) {
      two++;
      a[i] /= 2;
    }
    while (a[i] % 5 == 0) {
      five++;
      a[i] /= 5;
    }
    res += cnt[18 - two][18 - five];
    for (int u = 0; u <= two; u++) {
      for (int v = 0; v <= five; v++) {
        cnt[u][v]++;
      }
    }
  }
  cout << res;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 1000 + 10;

int cnt[60][60];

int main() {
  int n;
  cin >> n;
  ll answer = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    ll t = 0;
    int cnT = 9, dec = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '.') {
        dec = 1;
        continue;
      }
      t = 10LL * t + (int)(s[i] - '0');
      cnT -= dec;
    }
    while (cnT--)
      t = 10LL * t;
    int a = 0, b = 0;
    while (t % 5 == 0) {
      t /= 5;
      a++;
    }
    while (t % 2 == 0) {
      t /= 2;
      b++;
    }
    assert(max(a, b) <= 55);
    for (int i = 0; i <= 55; i++)
      for (int j = 0; j <= 55; j++)
        if (min(i + b, j + a) >= 18)
          answer += cnt[i][j];
    cnt[b][a]++;
  }
  cout << answer << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 1000 + 10;

int a[maxn], b[maxn], cnt[60][60];

int main() {
  int n;
  cin >> n;
  ll answer = 0;
  for (int i = 0; i < n; i++) {
    long double x;
    cin >> x;
    ll t = x * 10'000'000'000LL;
    while (t % 5 == 0) {
      t /= 5;
      a[i]++;
    }
    while (t % 2 == 0) {
      t /= 2;
      b[i]++;
    }
    cnt[b[i]][a[i]]++;
    if (2 * min(a[i], b[i]) >= 20)
      answer--;
  }
  for (int i = 0; i <= 50; i++)
    for (int j = 0; j <= 50; j++)
      for (int k = 0; k <= 50; k++)
        for (int z = 0; z <= 50; z++)
          if (min(i + k, j + z) >= 20)
            answer += 1LL * cnt[i][j] * cnt[k][z];
  answer /= 2;
  cout << answer << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int64_t cnvS(string &S) {
  int n = S.size();
  int64_t ret = 0;
  bool count = false;
  int times = 9;
  rep(i, n) {
    if (count)
      --times;
    if (S[i] == '.')
      count = true;
    else
      ret = ret * 10 + (S[i] - '0');
  }
  rep(i, times) ret *= 10;
  // cout << S << "->" << ret << endl;
  return ret;
}

int cntN(int64_t n, int m) {
  int ret = 0;
  while (n % m == 0) {
    ret++;
    n /= m;
  }
  return ret;
}

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> num2(N);
  vector<int> num5(N);
  vector<vector<int>> tbl25(19, vector<int>(19, 0));
  rep(i, N) {
    string S;
    cin >> S;
    int64_t A = cnvS(S);
    num2[i] = min(18, cntN(A, 2));
    num5[i] = min(18, cntN(A, 5));
    tbl25[num2[i]][num5[i]]++;
  }
  vector<vector<int>> sum(20, vector<int>(19, 0));
  rep(i, 19) {
    rep(j, 19) {
      sum[i + 1][j + 1] =
          sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + tbl25[i][j];
    }
  }

  // need 1e18 = 2 & 5 >= 18
  int64_t answer = 0;
  rep(i, N) {
    int need2 = 18 - num2[i];
    int need5 = 18 - num5[i];
    answer += sum[19][19] - sum[need2][19] - sum[19][need5] + sum[need2][need5];
    if (9 <= num2[i] && 9 <= num5[i])
      answer--; // subtract for own
  }
  cout << answer / 2 << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int64_t cnvS(string &S) {
  int n = S.size();
  int64_t ret = 0;
  bool count = false;
  int times = 9;
  rep(i, n) {
    if (count)
      --times;
    if (S[i] == '.')
      count = true;
    else
      ret = ret * 10 + (S[i] - '0');
  }
  rep(i, times) ret *= 10;
  // cout << S << "->" << ret << endl;
  return ret;
}

int cntN(int64_t n, int m) {
  int ret = 0;
  while (n % m == 0) {
    ret++;
    n /= m;
  }
  return ret;
}

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> num2(N);
  vector<int> num5(N);
  vector<vector<int>> tbl25(19, vector<int>(19, 0));
  rep(i, N) {
    string S;
    cin >> S;
    int64_t A = cnvS(S);
    num2[i] = min(18, cntN(A, 2));
    num5[i] = min(18, cntN(A, 5));
    tbl25[num2[i]][num5[i]]++;
  }
  vector<vector<int>> sum(19, vector<int>(19, 0));
  rep(i, 19) {
    rep(j, 19) {
      sum[i + 1][j + 1] =
          sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + tbl25[i][j];
    }
  }

  // need 1e18 = 2 & 5 >= 18
  int64_t answer = 0;
  rep(i, N) {
    int need2 = 18 - num2[i];
    int need5 = 18 - num5[i];
    answer += sum[18][18] - sum[need2][18] - sum[18][need5] + sum[need2][need5];
    if (9 <= num2[i] && 9 <= num5[i])
      answer--; // subtract for own
  }
  cout << answer / 2 << endl;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  long long ans = 0;
  vector<vector<long long>> cnt(200, vector<long long>(200, 0));
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int l = s.length(), d = l - 1;
    long long v = 0;
    for (int j = 0; j < l; j++) {
      if (s[j] == '.') {
        d = j;
      } else {
        v = v * 10 + s[j] - '0';
      }
    }
    int p2 = d - l + 1, p5 = d - l + 1;
    while (v % 2 == 0) {
      v /= 2;
      p2++;
    }
    while (v % 5 == 0) {
      v /= 5;
      p5++;
    }
    for (int x = 40; x + p2 >= 0; x--) {
      for (int y = 40; y + p5 >= 0; y--) {
        ans += cnt[x + 40][y + 40];
      }
    }
    cnt[p2 + 40][p5 + 40]++;
    // cout << v << "  " << p2 << " " << p5 << endl;
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  long long ans = 0;
  vector<vector<long long>> cnt(100, vector<long long>(100, 0));
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int l = s.length(), d = l - 1;
    long long v = 0;
    for (int j = 0; j < l; j++) {
      if (s[j] == '.') {
        d = j;
      } else {
        v = v * 10 + s[j] - '0';
      }
    }
    int p2 = d - l + 1, p5 = d - l + 1;
    while (v % 2 == 0) {
      v /= 2;
      p2++;
    }
    while (v % 5 == 0) {
      v /= 5;
      p5++;
    }
    for (int x = 20; x + p2 >= 0; x--) {
      for (int y = 20; y + p5 >= 0; y--) {
        ans += cnt[x + 20][y + 20];
      }
    }
    cnt[p2 + 20][p5 + 20]++;
    // cout << v << "  " << p2 << " " << p5 << endl;
  }
  cout << ans << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> TandF(100, vector<int>(100, 0));
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    ll num = 0, keta = 0;
    bool frag = false;
    for (int j = 0; j < (s.size()); ++j) {
      if (s[j] == '.') {
        frag = true;
        continue;
      }
      if (frag)
        ++keta;
      num = num * 10 + (s[j] - '0');
    }
    int two = 0, five = 0;
    while (num % 2 == 0) {
      num /= 2;
      ++two;
    }
    while (num % 5 == 0) {
      num /= 5;
      ++five;
    }
    if (25 + two - keta < 0)
      continue;
    if (25 + five - keta < 0)
      continue;
    ++TandF[25 + two - keta][25 + five - keta];
  }
  ll ans = 0;
  for (int i1 = 0; i1 < 51; ++i1)
    for (int i2 = 0; i2 < 51; ++i2) {
      for (int j1 = 50 - i1; j1 < 51; ++j1)
        for (int j2 = 50 - i2; j2 < 51; ++j2) {
          ans += (ll)TandF[i1][i2] * TandF[j1][j2];
          if (i1 == j1 && i2 == j2)
            ans -= TandF[i1][i2];
        }
    }
  ans /= 2;
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> TandF(31, vector<int>(21, 0));
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    ll num = 0, keta = 0;
    bool frag = false;
    for (int j = 0; j < (s.size()); ++j) {
      if (s[j] == '.') {
        frag = true;
        continue;
      }
      if (frag)
        ++keta;
      num = num * 10 + (s[j] - '0');
    }
    int two = 0, five = 0;
    while (num % 2 == 0) {
      num /= 2;
      ++two;
    }
    while (num % 5 == 0) {
      num /= 5;
      ++five;
    }
    if (15 + two - keta < 0)
      continue;
    if (10 + five - keta < 0)
      continue;
    ++TandF[15 + two - keta][10 + five - keta];
  }
  ll ans = 0;
  for (int i1 = 0; i1 < 31; ++i1)
    for (int i2 = 0; i2 < 21; ++i2) {
      for (int j1 = 30 - i1; j1 < 31; ++j1)
        for (int j2 = 20 - i2; j2 < 21; ++j2) {
          ans += (ll)TandF[i1][i2] * TandF[j1][j2];
          if (i1 == j1 && i2 == j2)
            ans -= TandF[i1][i2];
        }
    }
  ans /= 2;
  cout << ans << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> a(21, vector<ll>(21, 0));
  vector<ll> A(N);

  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    double d;
    d = stod(str);
    d *= 1e9;
    d += 0.5;
    A[i] = (ll)d;
  }

  for (int i = 0; i < N; i++) {
    // cout << "+" << A[i] << endl;
    ll n = A[i];
    ll n2 = 0;
    while ((n2 < 20) && (n % 2 == 0)) {
      n /= 2;
      n2++;
    }
    // cout << n2  << endl;

    n = A[i];
    ll n5 = 0;
    while ((n5 < 20) && (n % 5 == 0)) {
      n /= 5;
      n5++;
    }

    // cout << n2 << "#" << n5 << endl;
    a[n2][n5]++;
  }

  ll ans = 0;

  for (int n2 = 0; n2 < 21; n2++) {
    for (int n5 = 0; n5 < 21; n5++) {
      if ((2 * n2 >= 18) && (2 * n5 >= 18)) {
        ans += a[n2][n5] * (a[n2][n5] - 1) / 2;
      }

      for (int m5 = n5 + 1; m5 < 21; m5++) {
        if (((n2 + n2) >= 18) && ((n5 + m5) >= 18)) {
          ans += a[n2][n5] * a[n2][m5];
        }
      }

      for (int m2 = n2 + 1; m2 < 21; m2++) {
        for (int m5 = 0; m5 < 21; m5++) {
          if (((n2 + m2) >= 18) && ((n5 + m5) >= 18)) {
            ans += a[n2][n5] * a[m2][m5];
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> a(20, vector<ll>(20, 0));
  vector<ll> A(N);

  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    double d;
    d = stod(str);
    d *= 1e9;
    d += 0.5;
    A[i] = (ll)d;
  }

  for (int i = 0; i < N; i++) {
    // cout << "+" << A[i] << endl;
    ll n = A[i];
    ll n2 = 0;
    while ((n2 < 20) && (n % 2 == 0)) {
      n /= 2;
      n2++;
    }
    // cout << n2  << endl;

    n = A[i];
    ll n5 = 0;
    while ((n5 < 20) && (n % 5 == 0)) {
      n /= 5;
      n5++;
    }

    // cout << n2 << "#" << n5 << endl;
    a[n2][n5]++;
  }

  ll ans = 0;

  for (int n2 = 0; n2 < 20; n2++) {
    for (int n5 = 0; n5 < 20; n5++) {
      if ((2 * n2 >= 18) && (2 * n5 >= 18)) {
        ans += a[n2][n5] * (a[n2][n5] - 1) / 2;
      }

      for (int m5 = n5 + 1; m5 < 20; m5++) {
        if (((n2 + n2) >= 18) && ((n5 + m5) >= 18)) {
          ans += a[n2][n5] * a[n2][m5];
        }
      }

      for (int m2 = n2 + 1; m2 < 20; m2++) {
        for (int m5 = 0; m5 < 20; m5++) {
          if (((n2 + m2) >= 18) && ((n5 + m5) >= 18)) {
            ans += a[n2][n5] * a[m2][m5];
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

int cnt[80][80];

double eps = 1e-10;
const int INF = 1e9;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    double a;
    cin >> a;
    a += eps;
    a *= INF;
    int b = (int)a;
    int cnt1 = 0;
    int cnt2 = 0;
    while (b % 2ll == 0) {
      b /= 2ll;
      cnt1++;
    }
    while (b % 5ll == 0) {
      b /= 5ll;
      cnt2++;
    }
    for (int p = 0; p < 80; ++p) {
      for (int q = 0; q < 80; ++q) {
        if (p + cnt1 >= 18 && q + cnt2 >= 18) {
          ans += cnt[p][q];
        }
      }
    }
    ++cnt[cnt1][cnt2];
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

int cnt[19][19];

double eps = 1e-10;
const int INF = 1e9;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    double a;
    cin >> a;
    a += eps;
    a *= INF;
    int b = (int)a;
    int cnt1 = 0;
    int cnt2 = 0;
    while (b % 2ll == 0) {
      b /= 2ll;
      cnt1++;
    }
    while (b % 5ll == 0) {
      b /= 5ll;
      cnt2++;
    }
    for (int p = 0; p < 19; ++p) {
      for (int q = 0; q < 19; ++q) {
        if (p + cnt1 >= 18 && q + cnt2 >= 18) {
          ans += cnt[p][q];
        }
      }
    }
    ++cnt[cnt1][cnt2];
  }
  cout << ans << endl;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <utility>
#include <vector>
using namespace std;

long long input() {
  string s;
  cin >> s;
  long long a = 0;
  size_t i = 0;
  for (; i < s.length(); ++i) {
    if (s[i] == '.')
      break;
    a *= 10;
    a += s[i] - '0';
  }
  ++i;
  for (size_t j = 0; j < 9; ++j) {
    a *= 10;
    if (i + j < s.length())
      a += s[i + j] - '0';
  }
  return a;
}

int main() {
  int N;
  cin >> N;
  long long ans = 0;
  const int m = 60, M = 2 * m + 1;
  vector<vector<long long>> C(M, vector<long long>(M));

  for (int i = 0; i < N; ++i) {
    long long a = input();
    int c2 = -9, c5 = -9;
    // cerr << a << endl;
    while (a % 2 == 0)
      ++c2, a /= 2;
    while (a % 5 == 0)
      ++c5, a /= 5;
    // cerr << c2 << " " << c5 << endl;
    c2 = min(c2, M - 1);
    c5 = min(c5, M - 1);
    for (int i = -c2 + m; i < M; ++i) {
      for (int j = -c5 + m; j < M; ++j) {
        ans += C[i][j];
      }
    }

    ++C[c2 + m][c5 + m];
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <iostream>
#include <utility>
#include <vector>
using namespace std;

long long input() {
  string s;
  cin >> s;
  long long a = 0;
  size_t i = 0;
  for (; i < s.length(); ++i) {
    if (s[i] == '.')
      break;
    a *= 10;
    a += s[i] - '0';
  }
  ++i;
  for (size_t j = 0; j < 9; ++j) {
    a *= 10;
    if (i + j < s.length())
      a += s[i + j] - '0';
  }
  return a;
}

int main() {
  int N;
  cin >> N;
  long long ans = 0;
  const int m = 15, M = 2 * m + 1;
  vector<vector<long long>> C(M, vector<long long>(M));

  for (int i = 0; i < N; ++i) {
    long long a = input();
    int c2 = -9, c5 = -9;
    // cerr << a << endl;
    while (a % 2 == 0)
      ++c2, a /= 2;
    while (a % 5 == 0)
      ++c5, a /= 5;
    // cerr << c2 << " " << c5 << endl;

    for (int i = -c2 + m; i < M; ++i) {
      for (int j = -c5 + m; j < M; ++j) {
        ans += C[i][j];
      }
    }

    ++C[c2 + m][c5 + m];
  }
  cout << ans << endl;
}