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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> a(20, vector<int>(20));
  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    double x;
    cin >> x;
    auto y = (ll)(x * 1e9 + 0.5);
    int n2 = 0, n5 = 0;
    while (n2 < 18 && y % 2 == 0) {
      ++n2;
      y /= 2;
    }
    while (n5 < 18 && y % 5 == 0) {
      ++n5;
      y /= 5;
    }
    ans += a[18 - n2][18 - n5];
    for (int i = 0; i <= n2; ++i)
      for (int j = 0; j <= n5; ++j) {
        ++a[i][j];
      }
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> a(20, vector<int>(20));
  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    double x;
    cin >> x;
    auto y = (ll)(x * 1e9 + 0.5);
    int n2 = 0, n5 = 0;
    while (n2 < 19 && y % 2 == 0) {
      ++n2;
      y /= 2;
    }
    while (n5 < 19 && y % 5 == 0) {
      ++n5;
      y /= 5;
    }
    ans += a[18 - n2][18 - n5];
    for (int i = 0; i <= n2; ++i)
      for (int j = 0; j <= n5; ++j) {
        ++a[i][j];
      }
  }
  cout << ans << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define range(a) (a).begin(), (a).end()
#define print(A, x, n)                                                         \\
  rep(I, 0, n) { cout << (I ? " " : "") << A[I] x; }                           \\
  cout << endl;
#define pprint(A, y, m, n)                                                     \\
  rep(J, 0, m) { print(A[J], y, n); }
const long mod = 1e9 + 7;
const int siz = 2e5 + 1;
const long inf = 1e9;
int main() {
  int N;
  cin >> N;
  string s;
  long y;
  int cnt[60][60] = {};
  long ans = 0;
  rep(_, 0, N) {
    cin >> s;
    y = 0;
    int k = 0;
    rep(i, 0, s.size()) {
      if (s[i] == '.')
        k = s.size() - i - 1;
      else
        (y *= 10) += s[i] - '0';
    }
    int a = -k, b = -k;
    while (y % 2 == 0) {
      y /= 2;
      a++;
    }
    while (y % 5 == 0) {
      y /= 5;
      b++;
    }
    ans += cnt[-a + 30][-b + 30];
    rep(i, -30, a + 1) rep(j, -30, b + 1) cnt[i + 30][j + 30]++;
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define range(a) (a).begin(), (a).end()
#define print(A, x, n)                                                         \\
  rep(I, 0, n) { cout << (I ? " " : "") << A[I] x; }                           \\
  cout << endl;
#define pprint(A, y, m, n)                                                     \\
  rep(J, 0, m) { print(A[J], y, n); }
const long mod = 1e9 + 7;
const int siz = 2e5 + 1;
const long inf = 1e9;
int main() {
  int N;
  cin >> N;
  string s;
  long y;
  int cnt[40][40] = {};
  long ans = 0;
  rep(_, 0, N) {
    cin >> s;
    y = 0;
    int k = 0;
    rep(i, 0, s.size()) {
      if (s[i] == '.')
        k = s.size() - i - 1;
      else
        (y *= 10) += s[i] - '0';
    }
    int a = -k, b = -k;
    while (y % 2 == 0) {
      y /= 2;
      a++;
    }
    while (y % 5 == 0) {
      y /= 5;
      b++;
    }
    ans += cnt[-a + 20][-b + 20];
    rep(i, -20, a + 1) rep(j, -20, b + 1) cnt[i + 20][j + 20]++;
  }
  cout << ans << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

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

using ll = long long;

pair<int, int> f(string &s) {
  int d = 0;
  ll keep = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '.') {
      d = s.size() - i - 1;
    } else {
      keep = keep * 10 + (s[i] - '0');
    }
  }

  int two = 0, five = 0;
  while (keep % 2 == 0) {
    two++;
    keep /= 2;
  }
  while (keep % 5 == 0) {
    five++;
    keep /= 5;
  }

  two -= d;
  five -= d;
  if (two > 10)
    two = 10;
  if (five > 10)
    five = 10;

  return make_pair(two, five);
}

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

  int n;
  cin >> n;

  vector<vector<ll>> x(21, vector<ll>(21));

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    pair<int, int> p = f(s);
    // p.first += 10;
    // p.second += 10;
    for (int j = -p.first + 10; j < 21; j++) {
      for (int k = -p.second + 10; k < 21; k++) {
        ans += x[j][k];
      }
    }
    x[p.first + 10][p.second + 10]++;
  }

  cout << ans << '\\n';
}

Error: 0

Fixed submission:

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

using ll = long long;

pair<int, int> f(string &s) {
  int d = 0;
  ll keep = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '.') {
      d = s.size() - i - 1;
    } else {
      keep = keep * 10 + (s[i] - '0');
    }
  }

  int two = 0, five = 0;
  while (keep % 2 == 0) {
    two++;
    keep /= 2;
  }
  while (keep % 5 == 0) {
    five++;
    keep /= 5;
  }

  return make_pair(two - d, five - d);
}

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

  int n;
  cin >> n;

  vector<vector<ll>> x(21, vector<ll>(21));

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    pair<int, int> p = f(s);
    // p.first += 10;
    // p.second += 10;
    for (int j = -p.first + 10; j < 21; j++) {
      for (int k = -p.second + 10; k < 21; k++) {
        ans += x[j][k];
      }
    }
    x[p.first + 10][p.second + 10]++;
  }

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

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

ll num[200005];
int den2[200005];
int den5[200005];
int main() {
#ifdef LOCAL_EXEC
//  freopen("sample.in", "r", stdin);
#else
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
#endif

  int n;
  cin >> n;
  int count[300][300] = {};
  ll ans = 0;
  int min2 = 0, min5 = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    num[i] = 0;
    for (int j = 0; j < s.size(); ++j) {
      if (s[j] == '.') {
        den2[i] = den5[i] = s.size() - j - 1;
        continue;
      }
      num[i] = 10 * num[i] + s[j] - '0';
    }
    // cout << num[i] << ' ' << den2[i] << ' ' << den5[i] << '\\n';
    while (num[i] % 2 == 0) {
      num[i] /= 2;
      den2[i]--;
    }
    while (num[i] % 5 == 0) {
      num[i] /= 5;
      den5[i]--;
    }
    for (int j = -den2[i]; j >= min2; j--) {
      for (int k = -den5[i]; k >= min5; k--) {
        ans += count[j + 100][k + 100];
      }
    }
    // cout << i << ' ' << ans << "; " << den2[i] << ' ' << den5[i] << '\\n';
    min2 = min(min2, den2[i]);
    min5 = min(min5, den5[i]);
    count[den2[i] + 100][den5[i] + 100]++;
  }

  cout << ans << '\\n';

  return 0;
}

Error: -11

Fixed submission:

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

struct node {
  node *nex[26];
  int tot[26];
  int sum;
} *root = new node;

string s[200005];

node *add(string &s) {
  node *cur = root;
  node *old = nullptr;
  for (char c : s) {
    cur->sum++;
    int i = c - 'a';
    if (cur->nex[i] == nullptr)
      cur->nex[i] = new node;
    old = cur;
    cur = cur->nex[i];
  }
  cur->sum++;
  return old;
}

void comp(node *cur) {
  for (int i = 0; i < 26; i++) {
    if (cur->nex[i] == nullptr)
      continue;
    comp(cur->nex[i]);
    cur->tot[i] += cur->nex[i]->sum;
    for (int j = 0; j < 26; j++) {
      if (i == j)
        continue;
      cur->tot[j] += cur->nex[i]->tot[j];
    }
  }
}

int main() {
#ifdef LOCAL_EXEC
//  freopen("sample.in", "r", stdin);
#else
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
#endif

  int n;
  cin >> n;
  node *pre[200005];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    reverse(s[i].begin(), s[i].end());
    pre[i] = add(s[i]);
  }
  comp(root);

  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += pre[i]->tot[s[i].back() - 'a'];
  }

  cout << sum - n << '\\n';

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

#include <iostream>
using namespace std;

int N;
pair<long long, long long> A[200005];

pair<pair<int, int>, pair<int, int>> Exp[200005];

char S[1005];

int Matrix[105][105];

int add = 40;

pair<int, int> desc(long long x) {
  pair<int, int> ans = make_pair(0, 0);
  while (x % 2 == 0) {
    ans.first++;
    x /= 2;
  }
  while (x % 5 == 0) {
    ans.second++;
    x /= 5;
  }

  return ans;
}

void Read() {
  cin >> N;
  cin.get();
  for (int i = 1; i <= N; i++) {
    cin.getline(S + 1, 1005);
    long long up = 0, down = 1;
    bool after = 0;
    for (int j = 1; S[j]; j++) {
      if (S[j] == '.')
        after = true;
      else {
        up = up * 10 + S[j] - '0';
        if (after)
          down *= 10;
      }
    }
    A[i] = make_pair(up, down);
    Exp[i] = make_pair(desc(up), desc(down));
  }
}

void Solve() {
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    int diff1 = Exp[i].first.first - Exp[i].second.first;
    int diff2 = Exp[i].first.second - Exp[i].second.second;
    for (int k = 0; k <= diff1 + add; k++)
      for (int p = 0; p <= diff2 + add; p++)
        ans += Matrix[k][p];
    Matrix[-diff1 + add][-diff2 + add]++;
  }

  cout << ans << '\\n';
}

int main() {
  Read();
  Solve();
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int N;
pair<long long, long long> A[200005];

pair<pair<int, int>, pair<int, int>> Exp[200005];

char S[1005];

int Matrix[55][55];

int add = 13;

pair<int, int> desc(long long x) {
  pair<int, int> ans = make_pair(0, 0);
  while (x % 2 == 0) {
    ans.first++;
    x /= 2;
  }
  while (x % 5 == 0) {
    ans.second++;
    x /= 5;
  }

  return ans;
}

void Read() {
  cin >> N;
  cin.get();
  for (int i = 1; i <= N; i++) {
    cin.getline(S + 1, 1005);
    long long up = 0, down = 1;
    bool after = 0;
    for (int j = 1; S[j]; j++) {
      if (S[j] == '.')
        after = true;
      else {
        up = up * 10 + S[j] - '0';
        if (after)
          down *= 10;
      }
    }
    A[i] = make_pair(up, down);
    Exp[i] = make_pair(desc(up), desc(down));
  }
}

void Solve() {
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    int diff1 = Exp[i].first.first - Exp[i].second.first;
    int diff2 = Exp[i].first.second - Exp[i].second.second;
    for (int k = 0; k <= diff1 + add; k++)
      for (int p = 0; p <= diff2 + add; p++)
        ans += Matrix[k][p];
    Matrix[-diff1 + add][-diff2 + add]++;
  }

  cout << ans << '\\n';
}

int main() {
  Read();
  Solve();
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main() {
  ll n;
  cin >> n;
  vector<char> a[n];
  vector<string> b;
  rep(i, n) {
    string t;
    cin >> t;
    string s;
    ll ex = 0;
    rep(j, t.size()) {

      if (t[j] != '.') {
        s.push_back(t[j]);
      } else {
        ex = (ll)t.size() - j - 1;
      }
    }
    ll no = 9 - ex;
    while (no--) {
      s.push_back('0');
    }
    b.push_back(s);
  }
  ll ans = 0;
  vector<P> co;
  rep(i, n) {
    ll now = stoll(b[i]);
    ll sa = now;
    ll b = 0;
    ll c = 0;
    while (now % 2 == 0) {
      b++;
      now /= 2;
    }
    now = sa;
    while (now % 5 == 0) {
      c++;
      now /= 5;
    }
    co.push_back(P(b, c));
  }
  vector<vector<ll>> d(45, vector<ll>(45));
  rep(i, n) {
    rep(j, co[i].first + 1) {
      rep(k, co[i].second + 1) { d[j][k]++; }
    }
  }
  rep(i, n) {
    ans += d[max(0LL, 18 - co[i].first)][max(0LL, 18 - co[i].second)];
  }
  ll ch = 0;
  rep(i, n) {
    if (co[i].first >= 9 && co[i].second >= 9) {
      ch++;
    }
  }
  cout << (ans - ch) / 2 << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main() {
  ll n;
  cin >> n;
  vector<double> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] *= 1000000000;
  }
  ll ans = 0;
  vector<P> co;
  rep(i, n) {
    ll now = a[i];
    ll b = 0;
    ll c = 0;
    while (now % 2 == 0) {
      b++;
      now /= 2;
    }
    now = a[i];
    while (now % 5 == 0) {
      c++;
      now /= 5;
    }
    co.push_back(P(b, c));
  }
  vector<vector<ll>> d(25, vector<ll>(25));
  rep(i, n) {
    rep(j, co[i].first + 1) {
      rep(k, co[i].second + 1) { d[j][k]++; }
    }
  }
  rep(i, n) {
    ans += d[max(0LL, 18 - co[i].first)][max(0LL, 18 - co[i].second)];
  }
  ll ch = 0;
  rep(i, n) {
    if (co[i].first >= 9 && co[i].second >= 9) {
      ch++;
    }
  }
  cout << (ans - ch) / 2 << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reverse_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) {
    if (ch == '-')
      f = -1;
  }
  for (; isdigit(ch); ch = getchar()) {
    x = x * 10 + ch - 48;
  }
  return x * f;
}

const int mxN = 2e5;
const int mxW = 100;
double a[mxN + 3];
int a1[mxN + 3], a2[mxN + 3];
int s[mxW + 3][mxW + 3];
int n;

int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &a[i]);
    a[i] *= 1000000000.0;
    llong x = (llong)(a[i] + 0.5);
    while (x % 2 == 0) {
      a1[i]++;
      x /= 2;
    }
    while (x % 5 == 0) {
      a2[i]++;
      x /= 5;
    }
    s[a1[i]][a2[i]]++;
  }
  llong ans = 0ll;
  for (int i = mxW; i >= 0; i--)
    for (int j = mxW; j >= 0; j--) {
      s[i][j] += s[i + 1][j] + s[i][j + 1] - s[i + 1][j + 1];
    }
  for (int i = 1; i <= n; i++) {
    ans += s[max(0, 18 - a1[i])][max(0, 18 - a2[i])];
  }
  ans -= s[9][9];
  printf("%lld\\n", ans / 2ll);
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reverse_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) {
    if (ch == '-')
      f = -1;
  }
  for (; isdigit(ch); ch = getchar()) {
    x = x * 10 + ch - 48;
  }
  return x * f;
}

const int mxN = 2e5;
const int mxW = 100;
double a[mxN + 3];
int a1[mxW + 3], a2[mxW + 3];
int s[mxW + 3][mxW + 3];
int n;

int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &a[i]);
    a[i] *= 1000000000.0;
    llong x = (llong)(a[i] + 0.5);
    while (x % 2 == 0) {
      a1[i]++;
      x /= 2;
    }
    while (x % 5 == 0) {
      a2[i]++;
      x /= 5;
    }
    s[a1[i]][a2[i]]++;
  }
  llong ans = 0ll;
  for (int i = mxW; i >= 0; i--)
    for (int j = mxW; j >= 0; j--) {
      s[i][j] += s[i + 1][j] + s[i][j + 1] - s[i + 1][j + 1];
    }
  for (int i = 1; i <= n; i++) {
    ans += s[max(0, 18 - a1[i])][max(0, 18 - a2[i])];
  }
  ans -= s[9][9];
  printf("%lld\\n", ans / 2ll);
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define RREP(i, s, t) for (int i = s; i >= t; i--)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
int cnt[64][64] = {};
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  // int N = 200000;
  P p[200010];
  rep(i, N) {
    double a;
    cin >> a;
    // double a = 1.0;
    int c = (a * 1000000000) + 0.5;
    int cnt2 = 0, cnt5 = 0;
    while (c % 2 == 0) {
      cnt2++;
      c /= 2;
    }
    while (c % 5 == 0) {
      cnt5++;
      c /= 5;
    }
    // mp[{cnt2, cnt5}]++;
    cnt[cnt2][cnt5]++;
    p[i] = {cnt2, cnt5};
  }
  // rep(i, N) cout << p[i].first << " " << p[i].second << endl;
  int ans = 0;
  rep(i, N) {
    int cnt2 = p[i].first;
    int cnt5 = p[i].second;
    cnt[cnt2][cnt5]--;
    rep(a, 50) {
      rep(b, 50) {
        if (cnt2 + a >= 18 && cnt5 + b >= 18) {
          ans += cnt[a][b];
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define RREP(i, s, t) for (int i = s; i >= t; i--)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
map<P, int> mp;
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  P p[200010];
  rep(i, N) {
    double a;
    cin >> a;
    int c = (a * 1000000000) + 0.5;
    int cnt2 = 0, cnt5 = 0;
    while (c % 2 == 0) {
      cnt2++;
      c /= 2;
    }
    while (c % 5 == 0) {
      cnt5++;
      c /= 5;
    }
    mp[{cnt2, cnt5}]++;
    p[i] = {cnt2, cnt5};
  }
  // rep(i, N) cout << p[i].first << " " << p[i].second << endl;
  int ans = 0;
  rep(i, N) {
    mp[p[i]]--;
    int cnt2 = p[i].first;
    int cnt5 = p[i].second;
    rep(a, 32) {
      rep(b, 32) {
        if (cnt2 + a >= 18 && cnt5 + b >= 18) {
          ans += mp[{a, b}];
          // if(mp[{a, b}] > 0) cout << a << " " << b << " " << cnt2 << ", ";
        }
      }
    }
    // cout << cnt2 << " " << cnt5 << " " << ans << endl;
  }
  cout << ans << endl;

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

#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

ll get() {
  string s;
  cin >> s;

  ll ans = 0;
  bool dot = false;
  int aft = 0;
  for (char c : s) {
    if (c == '.') {
      dot = 1;
    } else {
      ans *= 10;
      ans += c - '0';
      if (dot)
        aft++;
    }
  }

  while (aft < 9) {
    ans *= 10;
    aft++;
  }
  return ans;
}

const int MAX_N = 20;

ll cnt[MAX_N][MAX_N];

int divc(ll x, int K) {
  int ans = 0;
  while (x % K == 0) {
    ans++;
    x /= K;
  }
  return ans;
}

void add(ll x) { cnt[min(MAX_N - 1, divc(x, 2))][divc(x, 5)]++; }

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    ll cur = get();
    add(cur);
  }

  ll ans = 0;
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      for (int k = 0; k < MAX_N; k++) {
        for (int l = 0; l < MAX_N; l++) {
          if (i + k >= 18 && j + l >= 18) {
            if (i == k && j == l) {
              ans += cnt[i][j] * (cnt[k][l] - 1);
            } else {
              ans += cnt[i][j] * cnt[k][l];
            }
          }
        }
      }
    }
  }
  cout << ans / 2 << endl;
}


Error: 0

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

ll get() {
  string s;
  cin >> s;

  ll ans = 0;
  bool dot = false;
  int aft = 0;
  for (char c : s) {
    if (c == '.') {
      dot = 1;
    } else {
      ans *= 10;
      ans += c - '0';
      if (dot)
        aft++;
    }
  }

  while (aft < 9) {
    ans *= 10;
    aft++;
  }
  return ans;
}

const int MAX_N = 18;

ll cnt[MAX_N][MAX_N];

int divc(ll x, int K) {
  int ans = 0;
  while (x % K == 0) {
    ans++;
    x /= K;
  }
  return ans;
}

void add(ll x) { cnt[divc(x, 2)][divc(x, 5)]++; }

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    ll cur = get();
    add(cur);
  }

  ll ans = 0;
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      for (int k = 0; k < MAX_N; k++) {
        for (int l = 0; l < MAX_N; l++) {
          if (i + k >= 18 && j + l >= 18) {
            if (i == k && j == l) {
              ans += cnt[i][j] * (cnt[l][k] - 1);
            } else {
              ans += cnt[i][j] * cnt[l][k];
            }
          }
        }
      }
    }
  }
  cout << ans / 2 << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b); i-- > (a);)
#define eb(x...) emplace_back(x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
#define lb(x...) lower_bound(x)
#define ub(x...) upper_bound(x)

template <class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template <class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template <class T> T gcd(T a, T b) { return b != T(0) ? gcd(b, a % b) : a; }

#pragma GCC optimize("trapv")

const int N = 1 << 18, B = 44;
const ll mul = 1e9;
int g[B][B];

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  ll ans = 0;
  rep(i, 0, n) {
    ll a = 0;
    string s;
    cin >> s;

    int j = -1;
    rep(i, 0, sz(s)) {
      if (s[i] == '.') {
        j = i;
        break;
      }
      a = 10 * a + (s[i] - '0');
    }
    if (j != -1) {
      rep(i, j + 1, sz(s)) a = 10 * a + (s[i] - '0');
      int x = sz(s) - j - 1;
      while (x < 9)
        a *= 10, ++x;
    } else
      a *= mul;
    // cout << a << '\\n';
    ll b = a;
    int c2 = 0, c5 = 0;
    while (a % 2 == 0)
      a /= 2, ++c2;
    while (b % 5 == 0)
      b /= 5, ++c5;
    assert(c2 < B && c5 < B);
    rep(i, 0, B) rep(j, 0, B) if (c2 + i >= 18 && c5 + j >= 18) ans += g[i][j];
    ++g[c2][c5];
  }
  cout << ans;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b); i-- > (a);)
#define eb(x...) emplace_back(x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
#define lb(x...) lower_bound(x)
#define ub(x...) upper_bound(x)

template <class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template <class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template <class T> T gcd(T a, T b) { return b != T(0) ? gcd(b, a % b) : a; }

const int N = 1 << 18, mul = 1e9, B = 19;
int g[B + 1][B + 1];

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  ll ans = 0;
  rep(i, 0, n) {
    double x;
    cin >> x;
    ll a = mul * x;
    ll b = a;
    int c2 = 0, c5 = 0;
    while (a % 2 == 0)
      a /= 2, ++c2;
    while (b % 5 == 0)
      b /= 5, ++c5;
    assert(c2 < B && c5 < B);
    rep(i, 0, B) rep(j, 0, B) if (c2 + i >= 18 && c5 + j >= 18) ans += g[i][j];
    ++g[c2][c5];
  }
  cout << ans;
}