alexjercan/bugnet huggingface dataset:
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
  ll a, b;
  bool operator<(ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
  ll a, b, c;
  bool operator<(iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};

const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll MAXN = 2000005;
const double EPS = 1e-6;

ll N;
ll arr[MAXN], fact[63][63];

ll cntDiv(ll n, ll div) {
  ll cnt = 0;
  while (n % div == 0) {
    n /= div;
    cnt++;
  }
  return cnt;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  cin >> N;
  for (ll i = 0; i < N; i++) {
    double x;
    cin >> x;
    arr[i] = x * INF + 0.5;
  }

  for (ll i = 0; i < N; i++) {
    ll f2 = cntDiv(arr[i], 2);
    ll f5 = cntDiv(arr[i], 5);
    fact[f2][f5]++;
  }

  ll ans = 0;
  const ll MAX = 60;
  for (ll i = 0; i < MAX; i++) {
    for (ll j = 0; j < MAX; j++) {
      for (ll k = 0; k < MAX; k++) {
        for (ll l = 0; l < MAX; l++) {
          if (i + k >= 18 && j + l >= 18 &&
              make_pair(i, j) <= make_pair(k, l)) {
            if (i == k && j == l)
              ans += fact[i][j] * (fact[i][j] - 1) / 2;
            else
              ans += fact[i][j] * fact[k][l];
          }
        }
      }
      //~ cerr << i << " " << j << " " << ans << "\\n";
    }
  }
  cout << ans << "\\n";
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
  ll a, b;
  bool operator<(ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
  ll a, b, c;
  bool operator<(iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};

const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll MAXN = 2000005;
const ll OFS = 10;
const double EPS = 1e-6;

ll N;
ll arr[MAXN], fact[53][53];

ll cntDiv(ll n, ll div) {
  ll cnt = 0;
  while (n % div == 0) {
    n /= div;
    cnt++;
  }
  return cnt;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  cin >> N;
  for (ll i = 0; i < N; i++) {
    double x;
    cin >> x;
    arr[i] = x * INF + EPS;
  }

  for (ll i = 0; i < N; i++) {
    ll f2 = cntDiv(arr[i], 2);
    ll f5 = cntDiv(arr[i], 5);
    fact[f2][f5]++;
  }

  ll ans = 0;
  const ll MAX = 40;
  for (ll i = 0; i < MAX; i++) {
    for (ll j = 0; j < MAX; j++) {
      for (ll k = 18 - i; k < MAX; k++) {
        for (ll l = 18 - j; l < MAX; l++) {
          if (i == k && j == l)
            ans += fact[i][j] * (fact[i][j] - 1);
          else
            ans += fact[i][j] * fact[k][l];
        }
      }
      //~ cerr << i << " " << j << " " << ans << "\\n";
    }
  }
  ans /= 2;
  cout << ans << "\\n";
}
Problem p02588 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

#define mod 1000000000
int n, a[200005], b[200005], t[20][20];
double x;
long long ans = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &x);
    long long tmp = x * mod + 0.5;
    while (tmp % 2 == 0)
      tmp /= 2, a[i]++;
    while (tmp % 5 == 0)
      tmp /= 5, b[i]++;
    if (a[i] > 18)
      a[i] = 18;
    if (b[i] > 18)
      b[i] = 18;
    for (int j = 18 - a[i]; j <= 18; j++) {
      for (int k = 18 - b[i]; k <= 18; k++) {
        ans += t[j][k];
      }
    }
    t[a[i]][b[i]]++;
  }
  printf("%lld", ans);
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

#define mod 1000000000
int n;
double x;
long long ans = 0, a[200005], b[200005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &x);
    long long tmp = x * mod + 0.5;
    while (tmp % 2 == 0)
      tmp /= 2, a[i]++;
    while (tmp % 5 == 0)
      tmp /= 5, b[i]++;
    for (int j = 1; j < i; j++) {
      if (min(a[i] + a[j], b[i] + b[j]) >= 18) {
        ans++;
      }
    }
  }
  printf("%lld", ans);
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int N, cnt[100][100];
char sir[100];
const int maxE = 9;
long long ans = 0;

int getExp(long long &N, int p) {
  int cnt = 0;
  while (N % p == 0)
    N /= p, cnt++;
  return cnt;
}

void add(int x, int y) {
  x = min(x, 2 * maxE);
  y = min(y, 2 * maxE);
  //    printf ("%d %d\\n", x, y);
  for (int i = 2 * maxE - x; i <= 2 * maxE; i++)
    for (int j = 2 * maxE - y; j <= 2 * maxE; j++)
      ans += cnt[i][j];
  cnt[x][y]++;
}

int main() {
  // freopen ("input", "r", stdin);
  // freopen ("output", "w", stdout);

  scanf("%d\\n", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%s", sir + 1);
    int L = strlen(sir + 1), p = 1;
    long long curr = 0;
    while (p <= L && sir[p] != '.')
      curr = curr * 10LL + sir[p] - '0', p++;
    for (int i = p + 1; i <= L; i++)
      curr = curr * 10LL + sir[i] - '0';
    int after = (p > L ? 0 : L - p);
    assert(after <= maxE);
    int e2 = getExp(curr, 2), e5 = getExp(curr, 5);
    add(e2 + maxE - after, e5 + maxE - after);
  }
  printf("%lld\\n", ans);
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int N, cnt[100][100];
char sir[100];
const int maxE = 9;
long long ans = 0;

int getExp(long long &N, int p) {
  int cnt = 0;
  while (N % p == 0)
    N /= p, cnt++;
  return cnt;
}

void add(int x, int y) {
  //    printf ("%d %d\\n", x, y);
  for (int i = 2 * maxE - x; i <= 2 * maxE; i++)
    for (int j = 2 * maxE - y; j <= 2 * maxE; j++)
      ans += cnt[i][j];
  cnt[x][y]++;
}

int main() {
  // freopen ("input", "r", stdin);
  // freopen ("output", "w", stdout);

  scanf("%d\\n", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%s", sir + 1);
    int L = strlen(sir + 1), p = 1;
    long long curr = 0;
    while (p <= L && sir[p] != '.')
      curr = curr * 10LL + sir[p] - '0', p++;
    for (int i = p + 1; i <= L; i++)
      curr = curr * 10LL + sir[i] - '0';
    int after = (p > L ? 0 : L - p);
    assert(after <= maxE);
    int e2 = getExp(curr, 2), e5 = getExp(curr, 5);
    add(e2 + maxE - after, e5 + maxE - after);
  }
  printf("%lld\\n", ans);
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define ll long long
#define pp pair<ll, ll>
#define ld long double
#define all(a) (a).begin(), (a).end()
#define mk make_pair
int inf = 1000001000;
ll INF = 1e18;
ll mod = 1000000007;
ll MOD = INF;

int Pow(int b, int e) {
  if (e < 0)
    e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1)
      ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  vector<string> a(n);
  vector<ll> b(n, 0);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    ll u = 9;
    bool t = false;
    rep(j, a[i].size()) {
      if (t)
        u--;
      if (a[i][j] != '.') {
        b[i] *= 10;
        b[i] += a[i][j] - '0';
      } else
        t = true;
    }
    b[i] *= Pow(10, u);
  }
  vector<vector<ll>> c(20, vector<ll>(20, 0));
  ll ans = 0;
  rep(i, n) {
    int c2 = 0, c5 = 0;
    while (true) {
      if (b[i] % 2 == 0)
        c2++;
      else
        break;
      b[i] /= 2;
    }
    while (true) {
      if (b[i] % 5 == 0)
        c5++;
      else
        break;
      b[i] /= 5;
    }
    ans += c[max(0, 18 - c2)][max(0, 18 - c5)];
    rep(j, min(c2 + 1, 20)) {
      rep(k, min(c5 + 1, 20)) { c[j][k]++; }
    }
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define ll long long
#define pp pair<ll, ll>
#define ld long double
#define all(a) (a).begin(), (a).end()
#define mk make_pair
int inf = 1000001000;
ll INF = 1e18;
ll mod = 1000000007;
ll MOD = INF;

int Pow(int b, int e) {
  if (e < 0)
    e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1)
      ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  vector<string> a(n);
  vector<ll> b(n, 0);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    ll u = 9;
    bool t = false;
    rep(j, a[i].size()) {
      if (t)
        u--;
      if (a[i][j] != '.') {
        b[i] *= 10;
        b[i] += a[i][j] - '0';
      } else
        t = true;
    }
    b[i] *= Pow(10, u);
  }
  vector<vector<ll>> c(20, vector<ll>(20, 0));
  ll ans = 0;
  rep(i, n) {
    int c2 = 0, c5 = 0;
    while (true) {
      if (b[i] % 2 == 0)
        c2++;
      else
        break;
      b[i] /= 2;
    }
    while (true) {
      if (b[i] % 5 == 0)
        c5++;
      else
        break;
      b[i] /= 5;
    }
    ans += c[18 - c2][18 - c5];
    rep(j, min(c2 + 1, 20)) {
      rep(k, min(c5 + 1, 20)) { c[j][k]++; }
    }
  }
  cout << ans << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long, long long>
const int MAX = 5e6 + 9;
const ll MOD = 1e9 + 7;
const int TOT_PRIMES = 19;
const int MAX_A = 70;
using namespace std;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  map<pair<int, int>, ll> cnt;
  for (int i = 1; i <= n; i++) {
    double x;
    scanf("%lf", &x);
    ll g = llround(x * 1e9);
    int f = 0, t = 0;
    while (g % 5 == 0) {
      g = g / 5;
      f = f + 1;
    }
    while (g % 2 == 0) {
      t = t + 1;
      g = g / 2;
    }
    ++cnt[{t, f}];
  }
  for (auto u : cnt) {
    for (auto v : cnt) {
      if (u.first.first + v.first.first >= 18 and
          u.first.second + v.first.second >= 18) {
        if (u < v) {
          ans += (long long)(u.second * v.second);
        } else if (u == v) {
          ans += (long long)((u.second) * (u.second - 1) / 2);
        }
      }
    }
  }
  cout << ans;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll unsigned long
#define INF 10000000000000000LL
#define pll pair<long long, long long>
const int MAX = 5e6 + 9;
const ll MOD = 1e9 + 7;
const int TOT_PRIMES = 19;
const int MAX_A = 70;
using namespace std;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  map<pair<pair<int, int>, int>, int> mp5;
  mp5.clear();
  ll it = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int dec = 0;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == '.')
        dec = 1;
    }
    int p = s.size() - 1;
    while (s[p] == '0' and dec == 1) {
      s.pop_back();
      p--;
    }
    int j = 0;
    ll cur = 0;
    while (s[j] != '.' and j < s.size()) {
      cur = cur * 10 + (s[j] - '0');
      j++;
    }
    int d = 0;
    j++;
    while (j < s.size()) {
      cur = cur * 10 + (s[j] - '0');
      j++;
      d++;
    }
    //   cout<<cur<<endl;
    ll now = cur;
    int t = 0, f = 0;
    while (now % 5 == 0) {
      now = now / (ll)5;
      f = f + 1;
    }
    now = cur;
    while (now % 2 == 0) {
      now = now / (ll)2;
      t = t + 1;
    }
    for (int j = 0; j <= 43; j++) {
      for (int k = 0; k <= 43; k++) {
        for (int l = 0; l <= 59; l++) {
          if (min(j + f, t + k) >= l + d and
              mp5.find({{j, k}, l}) != mp5.end()) {
            ans = ans + mp5[{{j, k}, l}];
            //               cout<<j<<" "<<k<<" "<<mp5[{{j,k},l}]<<endl;
          }
        }
      }
    }
    //     cout<<cur<<" "<<f<<" "<<t<<" "<<d<<endl;
    //     cout<<f<<" "<<d<<endl;
    mp5[{{f, t}, d}]++;
  }
  cout << ans;
}
Problem p02588 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  cin >> n;
  map<pair<int, int>, int> mp;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long double a;
    int tmp2 = 0;
    int tmp5 = 0;
    cin >> a;
    long long b = a * 1e9 + 0.5;
    while (b % 2 == 0) {
      tmp2++;
      b /= 2;
    }
    while (b % 5 == 0) {
      tmp5++;
      b /= 5;
    }

    for (const auto &[key, value] : mp) {
      if (key.first + tmp2 >= 18 && key.second + tmp5 >= 18)
        ans += value;
    }
    mp[{tmp2, tmp5}]++;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<long long> b(n);
  vector<long double> a(n);
  vector<pair<int, int>> c(n);

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    b.at(i) = a.at(i) * 1e9 + 0.5;
    int tmp2 = 0, tmp5 = 0;
    while (b.at(i) % 2 == 0) {
      tmp2++;
      b.at(i) /= 2;
    }
    while (b.at(i) % 5 == 0) {
      tmp5++;
      b.at(i) /= 5;
    }
    c.at(i).first = tmp2;
    c.at(i).second = tmp5;
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int tmp = c.at(i).first + c.at(j).first;
      int tmp2 = c.at(i).second + c.at(j).second;
      if (min(tmp, tmp2) >= 18)
        ans++;
    }
  }
  cout << ans;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

vector<int> f(string s) {
  ll num = 0;
  int ten = 0;
  bool flag = false;
  rep(i, (int)s.size()) {
    if (flag)
      ten++;
    if (s[i] == '.') {
      flag = true;
      continue;
    }
    num *= 10;
    num += s[i] - '0';
  }
  vector<int> res;
  int two = 0, five = 0;
  while (num % 2LL == 0) {
    num /= 2LL;
    two++;
  }
  while (num % 5LL == 0) {
    num /= 5LL;
    five++;
  }
  res.emplace_back(five);
  res.emplace_back(two);
  res.emplace_back(ten);
  return res;
}

int cnt[100][100][100];

signed main() {
  int n;
  cin >> n;
  string a[n];
  rep(i, n) { cin >> a[i]; }
  ll ans = 0;
  rep(i, n) {
    auto v = f(a[i]);
    for (int five = 0; five <= 31; five++) {
      for (int two = 0; two <= 51; two++) {
        for (int ten = 0; ten <= 11; ten++) {
          if (min(v[0] + five, v[1] + two) < v[2] + ten)
            continue;
          ans += cnt[five][two][ten];
        }
      }
    }
    cnt[v[0]][v[1]][v[2]]++;
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

vector<int> f(string s) {
  ll num = 0;
  int ten = 0;
  bool flag = false;
  rep(i, (int)s.size()) {
    if (flag)
      ten++;
    if (s[i] == '.') {
      flag = true;
      continue;
    }
    num *= 10;
    num += s[i] - '0';
  }
  vector<int> res;
  int two = 0, five = 0;
  while (num % 2 == 0) {
    num /= 2;
    two++;
  }
  while (num % 5 == 0) {
    num /= 5;
    five++;
  }
  res.emplace_back(two);
  res.emplace_back(five);
  res.emplace_back(ten);
  return res;
}

int cnt[31][51][11];

signed main() {
  int n;
  cin >> n;
  string a[n];
  rep(i, n) { cin >> a[i]; }
  ll ans = 0;
  rep(i, n) {
    auto v = f(a[i]);
    for (int five = 0; five <= 30; five++) {
      for (int two = 0; two <= 50; two++) {
        for (int ten = 0; ten <= 10; ten++) {
          if (min(v[0] + five, v[1] + two) < v[2] + ten)
            continue;
          ans += cnt[five][two][ten];
        }
      }
    }
    cnt[v[0]][v[1]][v[2]]++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long)(998244353)
#define umap unordered_map

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  long t = 1;
  // cin >> t;

  while (t--) {
    long n;
    cin >> n;

    vector<pair<long, long>> a(n);
    vector<vector<long>> d(150);
    for (auto &v : d) {
      v.resize(150);
    }
    for (auto &p : a) {
      double y;
      cin >> y;

      long ten = 0;
      long pot = 10;
      double z = y;
      while (ten < 10) {
        z = y * pot;
        pot *= 10;
        ten++;
      }
      long two = ten;
      long five = ten;
      long x = round(z);
      while (x % 2 == 0) {
        two--;
        x /= 2;
      }
      while (x % 5 == 0) {
        five--;
        x /= 5;
      }
      p.first = -two;
      p.second = -five;
      // two = max(-two, 0LL);
      // five = max(-five, 0LL);
      d[-two + 70][-five + 70]++;
    }
    long ans = 0;
    for (long two = -20; two <= 30; two++) {
      for (long five = -20; five <= 30; five++) {
        if (d[two + 70][five + 70] == 0)
          continue;
        long count = d[two + 70][five + 70];
        long total = 0;
        for (long i = -two; i <= 60; i++) {
          for (long j = -five; j <= 60; j++) {
            long c = d[i + 70][j + 70];
            total += c;
          }
        }
        total *= count;
        if (two >= 0 and five >= 0)
          total -= count;
        ans += total;
      }
    }
    ans /= 2;
    printf("%lld\\n", ans);
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long)(998244353)
#define umap unordered_map

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  long t = 1;
  // cin >> t;

  while (t--) {
    long n;
    cin >> n;

    vector<pair<long, long>> a(n);
    map<long, long> two, five;
    map<long, map<long, long>> d;
    for (auto &p : a) {
      double y;
      cin >> y;

      long ten = 0;
      long pot = 10;
      double z = y;
      while (abs(z - round(z)) > 1e-14) {
        z = y * pot;
        pot *= 10;
        ten++;
      }
      long two = ten;
      long five = ten;
      long x = round(z);
      while (x % 2 == 0) {
        two--;
        x /= 2;
      }
      while (x % 5 == 0) {
        five--;
        x /= 5;
      }
      p.first = -two;
      p.second = -five;
      // two = max(-two, 0LL);
      // five = max(-five, 0LL);
      d[-two][-five]++;
    }
    long ans = 0;
    for (auto &p : a) {
      long two = p.first;
      long five = p.second;
      long total = 0;
      for (long i = -two; i <= 60; i++) {
        for (long j = -five; j <= 60; j++) {
          total += d[i][j];
        }
      }
      if (two >= 0 and five >= 0)
        total--;
      ans += total;
    }
    ans /= 2;
    printf("%lld\\n", ans);
  }
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
using ld = long double;
using cd = complex<ld>;

ll cnt[70][70];

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    ll a = 0, b = 0;
    int j = 0;
    for (; j < s.size() && s[j] != '.'; j++) {
      a *= 10;
      a += s[j] - '0';
    }
    j++;
    for (int u = 0; u < 9; u++) {
      b *= 10;
      if (j + u < s.size()) {
        b += s[j + u] - '0';
      }
    }
    ll x = a * 1e9 + b;
    int cnt2 = 0, cnt5 = 0;
    while (x % 2 == 0) {
      cnt2++;
      x /= 2;
    }
    while (x % 5 == 0) {
      cnt5++;
      x /= 5;
    }
    cnt[cnt2][cnt5]++;
  }
  ll ans = 0;
  for (int a = 0; a < 70; a++) {
    for (int b = 0; b < 70; b++) {
      for (int c = 0; c < 70; c++) {
        for (int d = 0; d < 70; d++) {
          if (a + c >= 18 && b + d >= 18) {
            if (a == c && b == d) {
              ans += cnt[a][b] * (cnt[a][b] - 1);
            } else {
              ans += cnt[a][b] * cnt[c][d];
            }
          }
        }
      }
    }
  }
  cout << ans / 2;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
using ld = long double;
using cd = complex<ld>;

ll cnt[20][20];

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    ll a = 0, b = 0;
    int j = 0;
    for (; j < s.size() && s[j] != '.'; j++) {
      a *= 10;
      a += s[j] - '0';
    }
    j++;
    for (int u = 0; u < 9; u++) {
      b *= 10;
      if (j + u < s.size()) {
        b += s[j + u] - '0';
      }
    }
    ll x = a * 1e9 + b;
    int cnt2 = 0, cnt5 = 0;
    while (x % 2 == 0) {
      cnt2++;
      x /= 2;
    }
    while (x % 5 == 0) {
      cnt5++;
      x /= 5;
    }
    cnt[cnt2][cnt5]++;
  }
  ll ans = 0;
  for (int a = 0; a < 20; a++) {
    for (int b = 0; b < 20; b++) {
      for (int c = 0; c < 20; c++) {
        for (int d = 0; d < 20; d++) {
          if (a + c >= 18 && b + d >= 18) {
            if (a == c && b == d) {
              ans += cnt[a][b] * (cnt[a][b] - 1);
            } else {
              ans += cnt[a][b] * cnt[c][d];
            }
          }
        }
      }
    }
  }
  cout << ans / 2;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

/*

*/
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, a, b) for (int i = a; i < b; i++)
#define MAX_N 200000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1 << 30;
const ll MOD = ll(1e9 + 7);

pair<int, int> cnt[MAX_N + 1];

int main() {
  int n;
  cin >> n;
  vector<vector<int>> mp(20, vector<int>(20, 0));
  rep(i, n) {
    long double t;
    cin >> t;
    ll a = ll(ll(1e9) * t + 0.5);
    int two = 0, five = 0;
    while (a % 2 == 0LL) {
      a /= 2;
      two++;
    }
    while (a % 5 == 0LL) {
      a /= 5;
      five++;
    }
    two = min(18, two);
    five = min(18, five);
    mp[two][five]++;
    cnt[i] = make_pair(two, five);
  }
  for (int i = 19; i >= 0; i--) {
    for (int j = 19; j >= 1; j--) {
      mp[i][j - 1] += mp[i][j];
    }
  }
  for (int i = 19; i >= 0; i--) {
    for (int j = 19; j >= 1; j--) {
      mp[j - 1][i] += mp[j][i];
    }
  }
  ll ans = 0LL;
  for (int i = 0; i < n; i++) {
    ans += (ll)mp[18 - cnt[i].first][18 - cnt[i].second];
    if (cnt[i].first >= 9 && cnt[i].second >= 9)
      ans--;
  }
  ans /= 2;
  cout << ans << endl;
  // system("read -n 1 -s -p \\"Press any key to continue...\\"");
}


Error: 0

Fixed submission:

/*

*/
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, a, b) for (int i = a; i < b; i++)
#define MAX_N 200000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1 << 30;
const ll MOD = ll(1e9 + 7);

pair<int, int> cnt[MAX_N + 1];

int main() {
  int n;
  cin >> n;
  vector<vector<int>> mp(20, vector<int>(20, 0));
  rep(i, n) {
    double t;
    cin >> t;
    ll a = ll(ll(1e9) * t);
    ll b = a;
    int two = 0, five = 0;
    while (b % 2 == 0LL) {
      b /= 2;
      two++;
    }
    while (b % 5 == 0LL) {
      b /= 5;
      five++;
    }
    mp[two][five]++;
    cnt[i] = make_pair(two, five);
  }
  for (int i = 19; i >= 0; i--) {
    for (int j = 19; j >= 1; j--) {
      mp[i][j - 1] += mp[i][j];
    }
  }
  for (int i = 19; i >= 0; i--) {
    for (int j = 19; j >= 1; j--) {
      mp[j - 1][i] += mp[j][i];
    }
  }
  ll ans = 0LL;
  for (int i = 0; i < n; i++) {
    ans += (ll)mp[18 - cnt[i].first][18 - cnt[i].second];
    if (cnt[i].first >= 9 && cnt[i].second >= 9)
      ans--;
  }
  ans /= 2;
  cout << ans << endl;
  // system("read -n 1 -s -p \\"Press any key to continue...\\"");
}