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

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <utility>

using ll = long long;
#define MAXN 200009
#define MAXL 29
std::map<std::pair<int, int>, int> bucket;

class Rat {
private:
  int cofp2, cofp5;

public:
  Rat() {}
  Rat(ll nn, ll dd) {
    ll tn = nn;
    ll td = dd;
    cofp2 = 0;
    while (tn % 2 == 0) {
      cofp2++;
      tn /= 2;
    }
    while (td % 2 == 0) {
      cofp2--;
      td /= 2;
    }
    cofp5 = 0;
    while (tn % 5 == 0) {
      cofp5++;
      tn /= 5;
    }
    while (td % 5 == 0) {
      cofp5--;
      td /= 5;
    }
  }
  void output() { printf("2^{%d}*5^{%d}\\n", cofp2, cofp5); }
  int getcofp2() { return cofp2; }
  int getcofp5() { return cofp5; }
};

int main(void) {
  char theNumber[MAXL];
  int N, i, j;
  scanf("%d", &N);
  Rat *a;

  for (i = 0; i < N; i++) {
    scanf("%s", theNumber);
    char *ret = strchr(theNumber, '.');
    if (ret == NULL) {
      a = new Rat(atoi(theNumber), 1);
    } else {
      int lenOfDen = strlen(&theNumber[ret - &theNumber[0] + 1]);
      ll den = pow(10, lenOfDen);
      ll num =
          atoi(theNumber) * den + atoi(&theNumber[ret - &theNumber[0] + 1]);
      a = new Rat(num, den);
    }
    bucket[std::make_pair(a->getcofp2(), a->getcofp5())]++;
  }

  ll s = 0;
  for (auto it : bucket) {
    int x1 = it.first.first;
    int y1 = it.first.second;
    int r1 = it.second;
    for (auto it2 : bucket) {
      int x2 = it2.first.first;
      int y2 = it2.first.second;
      int r2 = it2.second;

      if (x1 + x2 >= 0 && y1 + y2 >= 0) {
        if (it < it2) {
          s += ((ll)r1) * r2;
        } else if (it == it2) {
          s += ((ll)r1 * (r1 - 1)) / 2;
        }
      }
    }
  }

  printf("%lld\\n", s);

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using ll = long long;
#define MAXN 200009

long long gcd(ll a, ll b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}

class Rat {
public:
  Rat() {}
  ll num, den;
  Rat(ll nn, ll dd) {
    ll G = gcd(nn, dd);
    num = nn / G;
    den = dd / G;
  }

  int MultiIsInt(const Rat o) {
    return (o.num % den == 0) && (num % o.den == 0);
  }

  void output() { printf("%lld/%lld\\n", num, den); }

  bool operator<(const Rat o) { return num * 1.0 / den < o.num * 1.0 / o.den; }
} a[MAXN];

#define MAXL 29

int main(void) {
  char theNumber[MAXL];
  int N, i, j;
  scanf("%d", &N);

  for (i = 0; i < N; i++) {
    scanf("%s", theNumber);
    char *ret = strchr(theNumber, '.');
    if (ret == NULL) {
      a[i] = Rat(atoi(theNumber), 1);
    } else {
      int lenOfDen = strlen(&theNumber[ret - &theNumber[0] + 1]);
      ll den = pow(10, lenOfDen);
      ll num =
          atoi(theNumber) * den + atoi(&theNumber[ret - &theNumber[0] + 1]);
      a[i] = Rat(num, den);
    }
  }

  int s = 0;
  for (i = 0; i < N; i++) {
    for (j = i + 1; j < N; j++) {
      if (a[i].MultiIsInt(a[j]) == 1) {
        s += 1;
      }
    }
  }
  printf("%d\\n", s);
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define int long long

const int maxn = 2e5 + 1, mod = 1e9 + 7;

using namespace std;

int n;
int a[maxn];
int c2[maxn], c5[maxn];
int cnt[65][25];

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string ca;
    cin >> ca;
    int dc = 9, bf = 0;
    for (int j = 0; j < ca.size(); j++) {
      if (ca[j] == '.') {
        bf = 1;
        continue;
      }
      a[i] = 10 * a[i] + ca[j] - '0';
      if (bf)
        --dc;
    }
    for (; dc; --dc, a[i] *= 10)
      ;
    for (int x = a[i]; x % 2 == 0; x /= 2, ++c2[i])
      ;
    for (int x = a[i]; x % 5 == 0; x /= 5, ++c5[i])
      ;
    ++cnt[c2[i]][c5[i]];
  }
  int ans = 0;
  for (int i = 0; i < 65; i++)
    for (int j = 0; j < 25; j++) {
      if (!cnt[i][j])
        continue;
      for (int l = max(0ll, 18 - i); l < 65; l++)
        for (int k = max(0ll, 18 - j); k < 25; k++) {
          if (!cnt[l][k])
            continue;
          if (i == l && j == k) {
            ans += cnt[i][j] * (cnt[i][j] - 1);
            continue;
          }
          ans += cnt[i][j] * cnt[l][k];
        }
    }
  cout << ans / 2;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define int long long

const int maxn = 1e5 + 1, mod = 1e9 + 7;

using namespace std;

int n;
int a[maxn];
int c2[maxn], c5[maxn];
int cnt[65][25];

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string ca;
    cin >> ca;
    int dc = 9, bf = 0;
    for (int j = 0; j < ca.size(); j++) {
      if (ca[j] == '.') {
        bf = 1;
        continue;
      }
      a[i] = 10 * a[i] + ca[j] - '0';
      if (bf)
        --dc;
    }
    for (; dc; --dc, a[i] *= 10)
      ;
    for (int x = a[i]; x % 2 == 0; x /= 2, ++c2[i])
      ;
    for (int x = a[i]; x % 5 == 0; x /= 5, ++c5[i])
      ;
    ++cnt[c2[i]][c5[i]];
  }
  int ans = 0;
  for (int i = 0; i < 65; i++)
    for (int j = 0; j < 25; j++) {
      if (!cnt[i][j])
        continue;
      for (int l = max(0ll, 18 - i); l < 65; l++)
        for (int k = max(0ll, 18 - j); k < 25; k++) {
          if (!cnt[l][k])
            continue;
          if (i == l && j == k) {
            ans += cnt[i][j] * (cnt[i][j] - 1);
            continue;
          }
          ans += cnt[i][j] * cnt[l][k];
        }
    }
  cout << ans / 2;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() { cout << '\\n'; }
template <typename First, typename... Rest>
void print(const First &first, const Rest &...rest) {
  cout << first << ' ';
  print(rest...);
}

template <typename T> void print(const vector<T> &v) {
  for (auto e : v)
    cout << e << ' ';
  cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
  int N;
  cin >> N;
  vector<vector<long long>> v(50, vector<long long>(50));
  for (int i = 0; i < N; i++) {
    double a;
    cin >> a;
    long long A = a * 1000000000 + 0.1;
    long long A_tmp = A;
    int two = 0, five = 0;
    while (A_tmp % 2 == 0) {
      A_tmp /= 2;
      two++;
    }
    A_tmp = A;
    while (A_tmp % 5 == 0) {
      A_tmp /= 5;
      five++;
    }
    v[two][five]++;
  }

  long long ans = 0;
  for (int i = 0; i < 50; i++) {
    for (int j = 0; j < 50; j++) {
      for (int k = 0; k < 50; k++) {
        for (int l = 0; l < 50; l++) {
          if (i + k >= 18 && j + l >= 18) {
            if (i == k && j == l && v[i][j] != 0)
              ans += v[i][j] * (v[k][l] - 1);
            else
              ans += v[i][j] * v[k][l];
          }
        }
      }
    }
  }

  ans /= 2;
  cout << ans << '\\n';
}

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

  solve();

  return 0;
}

Error: 0

Fixed submission:

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() { cout << '\\n'; }
template <typename First, typename... Rest>
void print(const First &first, const Rest &...rest) {
  cout << first << ' ';
  print(rest...);
}

template <typename T> void print(const vector<T> &v) {
  for (auto e : v)
    cout << e << ' ';
  cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
  int N;
  cin >> N;
  vector<vector<long long>> v(20, vector<long long>(20));
  for (int i = 0; i < N; i++) {
    double a;
    cin >> a;
    long long A = a * 1000000000 + 0.1;
    long long A_tmp = A;
    int two = 0, five = 0;
    while (A_tmp % 2 == 0) {
      A_tmp /= 2;
      two++;
    }
    A_tmp = A;
    while (A_tmp % 5 == 0) {
      A_tmp /= 5;
      five++;
    }
    v[two][five]++;
  }

  long long ans = 0;
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 20; j++) {
      for (int k = 0; k < 20; k++) {
        for (int l = 0; l < 20; l++) {
          if (i + k >= 18 && j + l >= 18) {
            if (i == k && j == l && v[i][j] != 0)
              ans += v[i][j] * (v[k][l] - 1);
            else
              ans += v[i][j] * v[k][l];
          }
        }
      }
    }
  }

  ans /= 2;
  cout << ans << '\\n';
}

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

  solve();

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

#include <bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define N 200000
#define EPS 1e-9

int n;
lli c[20][20];

int main(void) {
  cin >> n;
  lli ans = 0;
  rep(i, 20) rep(j, 20) c[i][j] = 0;
  rep(i, n) {
    string x;
    lli y;
    cin >> x;
    if (x.find(".") == string::npos)
      y = stoll(x) * (lli)1e9;
    else {
      int k = x.find(".");
      string s, t;
      s = x.substr(0, k);
      t = x.substr(k + 1);
      while (t.size() < 9)
        t += "0";
      s += t;
      y = stoll(s);
    }
    lli a, b;
    a = b = 0;
    while (y % 2 == 0)
      y /= 2, a++;
    while (y % 5 == 0)
      y /= 5, b++;
    a = min(a, 19LL);
    b = min(b, 19LL);
    for (int i = 0; i <= 19; i++) {
      for (int j = 0; j <= 19; j++) {
        if (i + a >= 18 && j + b >= 18) {
          ans += c[i][j];
        }
      }
    }
    c[a][b]++;
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define N 200000
#define EPS 1e-9

int n;
lli c[20][20];

int main(void) {
  cin >> n;
  lli ans = 0;
  rep(i, 20) rep(j, 20) c[i][j] = 0;
  rep(i, n) {
    double x;
    cin >> x;
    lli y = x * 1e9 + EPS;
    lli a, b;
    a = b = 0;
    while (y % 2 == 0)
      y /= 2, a++;
    while (y % 5 == 0)
      y /= 5, b++;
    for (int i = 0; i <= 18; i++) {
      for (int j = 0; j <= 18; j++) {
        if (i + a >= 18 && j + b >= 18) {
          ans += c[i][j];
        }
      }
    }
    c[a][b]++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

//%std
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define y1 ysgh
#define endl '\\n'
inline int read() {
  int out = 0, fh = 1;
  char jp = getchar();
  while ((jp > '9' || jp < '0') && jp != '-')
    jp = getchar();
  if (jp == '-')
    fh = -1, jp = getchar();
  while (jp >= '0' && jp <= '9')
    out = out * 10 + jp - '0', jp = getchar();
  return out * fh;
}
void print(int x) {
  if (x >= 10)
    print(x / 10);
  putchar('0' + x % 10);
}
void write(int x, char c) {
  if (x < 0)
    putchar('-'), x = -x;
  print(x);
  putchar(c);
}
const int N = 2e5 + 10;
int n, c[100][100], mxa = -9, mxb = -9;
double t;
int Max(int x, int y) { return max(x, y); }
int main() {
  n = read();
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lf", &t);
    ll x = (ll)(round((t * (1e9))));
    int a = -9, b = -9;
    while (x % 2 == 0)
      x /= 2, ++a;
    while (x % 5 == 0)
      x /= 5, ++b;
    for (int A = Max(-9, -a); A <= mxa; ++A)
      for (int B = Max(-9, -b); B <= mxb; ++B)
        ans += c[A + 9][B + 9];
    ++c[a + 9][b + 9];
    mxa = max(mxa, a), mxb = max(mxb, b);
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

//%std
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define y1 ysgh
#define endl '\\n'
inline int read() {
  int out = 0, fh = 1;
  char jp = getchar();
  while ((jp > '9' || jp < '0') && jp != '-')
    jp = getchar();
  if (jp == '-')
    fh = -1, jp = getchar();
  while (jp >= '0' && jp <= '9')
    out = out * 10 + jp - '0', jp = getchar();
  return out * fh;
}
void print(int x) {
  if (x >= 10)
    print(x / 10);
  putchar('0' + x % 10);
}
void write(int x, char c) {
  if (x < 0)
    putchar('-'), x = -x;
  print(x);
  putchar(c);
}
const int N = 2e5 + 10;
int n, c[100][100], mxa = 0, mxb = 0;
double t;
int main() {
  n = read();
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lf", &t);
    ll x = (ll)(round((t * (1e9))));
    int a = -9, b = -9;
    while (x % 2 == 0)
      x /= 2, ++a;
    while (x % 5 == 0)
      x /= 5, ++b;
    for (int A = -a; A <= mxa; ++A)
      for (int B = -b; B <= mxb; ++B)
        ans += c[A + 9][B + 9];
    ++c[a + 9][b + 9];
    mxa = max(mxa, a), mxb = max(mxb, b);
  }
  cout << ans << endl;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll s2l(string s) {
  int pi = s.size();
  rep(i, s.size()) if (s[i] == '.') pi = i;
  ll res = 0;
  rep(i, pi) res = 10 * res + (ll)(s[i] - '0');
  rep(i, 9) {
    res *= 10;
    if (pi + i + 1 < s.size())
      res += (ll)(s[pi + i + 1] - '0');
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    string s;
    cin >> s;
    a[i] = s2l(s);
  }
  // rep(i, n) cout << a[i] << endl;

  vector<vector<ll>> fact(19, vector<ll>(19, 0));
  rep(ai, n) {
    int i = 0, j = 0;
    while (a[ai] % 2 == 0 && i < 18) {
      a[ai] /= 2;
      ++i;
    }
    while (a[ai] % 5 == 0 && j < 18) {
      a[ai] /= 5;
      ++j;
    }
    ++fact[i][j];
  }

  // rep(i, 19) {
  //   rep(j, 19) printf("%d ", fact[i][j]);
  //   printf("\\n");
  // }

  ll ans = 0;
  rep(i1, 19) rep(j1, 19) rep(i2, 19) rep(j2, 19) {
    if (19 * i1 + j1 > 19 * i2 + j2)
      continue;
    if (i1 + i2 < 18 || j1 + j2 < 18)
      continue;
    // ll ans0 = ans;
    if (i1 == i2 && j1 == j2)
      ans += fact[i1][j1] * (fact[i2][j2] - 1) / 2;
    else
      ans += fact[i1][j1] * fact[i2][j2];
    // if (ans0 != ans) printf("%d %d %d %d, %lld, %lld\\n", i1, j1, i2, j2,
    // ans0, ans);
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll s2l(string s) {
  int pi = s.size();
  rep(i, s.size()) if (s[i] == '.') pi = i;
  ll res = 0;
  rep(i, pi) res = 10 * res + (ll)(s[i] - '0');
  rep(i, 9) {
    res *= 10;
    if (pi + i + 1 < s.size())
      res += (ll)(s[pi + i + 1] - '0');
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    string s;
    cin >> s;
    a[i] = s2l(s);
  }
  // rep(i, n) cout << a[i] << endl;

  vector<vector<ll>> fact(19, vector<ll>(19, 0));
  rep(ai, n) {
    int i = 0, j = 0;
    while (a[ai] % 2 == 0 && i <= 18) {
      a[ai] /= 2;
      ++i;
    }
    while (a[ai] % 5 == 0 && j <= 18) {
      a[ai] /= 5;
      ++j;
    }
    ++fact[i][j];
  }

  // rep(i, 19) {
  //   rep(j, 19) printf("%d ", fact[i][j]);
  //   printf("\\n");
  // }

  ll ans = 0;
  rep(i1, 19) rep(j1, 19) rep(i2, 19) rep(j2, 19) {
    if (19 * i1 + j1 > 19 * i2 + j2)
      continue;
    if (i1 + i2 < 18 || j1 + j2 < 18)
      continue;
    // ll ans0 = ans;
    if (i1 == i2 && j1 == j2)
      ans += fact[i1][j1] * (fact[i2][j2] - 1) / 2;
    else
      ans += fact[i1][j1] * fact[i2][j2];
    // if (ans0 != ans) printf("%d %d %d %d, %lld, %lld\\n", i1, j1, i2, j2,
    // ans0, ans);
  }
  cout << ans << endl;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define IO                                                                     \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define ll long long
#define pii pair<int, int>

using namespace std;

int main() {
  // freopen("output.txt", "w", stdout);
  int n;
  cin >> n;
  vector<ll> arr;
  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;
    ll b = llround(a * 1e9);
    arr.push_back(b);
  }

  map<pii, int> mp;

  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    int t = -9, f = -9;
    while (arr[i] % 2 == 0)
      arr[i] /= 2, t++;
    while (arr[i] % 5 == 0)
      arr[i] /= 5, f++;

    for (auto i : mp) {
      pii tf = i.first;
      int v = i.second;

      if (tf.first + t >= 0 and tf.second + f >= 0)
        cnt += v;
    }

    mp[{t, f}]++;
  }
  cout << cnt << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define IO                                                                     \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define ll long long
#define pii pair<int, int>

using namespace std;

int main() {
  // freopen("output.txt", "w", stdout);
  int n;
  cin >> n;
  vector<ll> arr;
  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;
    double b = a * (double)1000000000;
    arr.push_back((ll)b);
  }
  int dp[30][30];
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 20; j++)
      dp[i][j] = 0;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int t = -9, f = -9;
    while (arr[i] % 2 == 0)
      arr[i] /= 2, t++;
    while (arr[i] % 5 == 0)
      arr[i] /= 5, f++;

    cnt += dp[10 - t][10 - f];
    // cout << arr[i] << " ->"<< dp[10-t][10-f] << endl;
    for (int k = 10 + t; k >= 0; k--) {
      for (int j = 10 + f; j >= 0; j--)
        dp[k][j]++;
    }
  }
  cout << cnt << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < (N); i++)

int main() {
  int n;
  scanf("%d", &n);
  map<pair<int, int>, int> cnt;
  rep(i, n) {
    double x;
    cin >> x;
    long long xl = llround(x * 1e9);
    int two = 0, five = 0;
    while (xl % 2 == 0) {
      two++;
      xl /= 2;
    }
    while (xl % 5 == 0) {
      five++;
      xl /= 5;
    }
    ++cnt[{two, five}];
  }
  long long answer = 0;
  for (auto p1 : cnt) {
    for (auto p2 : cnt) {
      if (p1.first.first + p2.first.first >= 18 &&
          p1.first.second + p2.first.second >= 18) {
        if (p1 < p2) {
          answer += (long long)p1.second * p2.second;
        } else if (p1 == p2) {
          answer += (long long)p1.second * (p1.second - 1) / 2;
        }
      }
    }
  }
  cout << answer << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < (N); i++)

int main() {
  int n;
  scanf("%d", &n);
  map<pair<int, int>, int> cnt;
  rep(i, n) {
    double x;
    cin >> x;
    long long xl = llround(x * 1e9);
    int two = 0, five = 0;
    while (xl % 2 == 0) {
      two++;
      xl /= 2;
    }
    while (i % 5 == 0) {
      five++;
      xl /= 5;
    }
    ++cnt[{two, five}];
  }
  long long answer = 0;
  for (auto p1 : cnt) {
    for (auto p2 : cnt) {
      if (p1.first.first + p2.first.first >= 18 &&
          p1.first.second + p2.first.second >= 18) {
        if (p1 < p2) {
          answer += (long long)p1.second * p2.second;
        } else if (p1 == p2) {
          answer += (long long)p1.second * (p1.second - 1) / 2;
        }
      }
    }
  }
  cout << answer << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  int MAX = 60;
  vector<vector<ll>> cnt52(MAX, vector<ll>(MAX));
  rep(i, n) {
    long double x;
    cin >> x;
    ll y = (ll)(x * 1e9 + 0.5);
    // cout << y << endl;

    int a = 0, b = 0;
    while (y % 5 == 0) {
      y /= 5;
      a++;
    }
    while (y % 2 == 0) {
      y /= 2;
      b++;
    }
    cnt52[a][b]++;
  }

  ll ans = 0;
  rep(i, MAX) {
    rep(j, MAX) {
      rep(ii, MAX) {
        rep(jj, MAX) {
          if (make_pair(i, j) > make_pair(ii, jj))
            continue;
          if (i + ii < 18 || j + jj < 18)
            continue;
          if (i == ii && j == jj)
            ans += cnt52[i][j] * (cnt52[i][j] - 1) / 2;
          else
            ans += cnt52[i][j] * cnt52[ii][jj];
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  int MAX = 60;
  int cnt52[MAX][MAX];
  P cnt[n];
  rep(i, n) {
    string s;
    cin >> s;
    int zid = 0;
    ll num = 0, ten = 1;
    for (int j = s.size() - 1; j >= 0; j--) {
      if (s[j] == '.') {
        zid = s.size() - 1 - j;
        continue;
      }
      num += (s[j] - '0') * ten;
      ten *= 10;
    }
    // cout << num << " " << zid << endl;

    ll tmp = num;
    int cnt5 = -zid, cnt2 = -zid;
    while (tmp % 5 == 0) {
      tmp /= 5;
      cnt5++;
    }
    tmp = num;
    while (tmp % 2 == 0) {
      tmp /= 2;
      cnt2++;
    }
    // cout << cnt5 << " " << cnt2 << endl;
    cnt[i].first = cnt5;
    cnt[i].second = cnt2;
    cnt52[MAX / 2 + cnt5][MAX / 2 + cnt2]++;
  }

  /*printf("      ");
  rep(j, 20) printf("%3d", -10 + j); cout << endl;
  rep(i, 20){
    printf("%3d : ", -10 + i);
    rep(j, 20){
      printf("%3d", cnt52[i][j]);
    }
    cout << endl;
  }*/

  for (int i = MAX; i >= 0; i--) {
    for (int j = MAX - 1; j >= 0; j--) {
      cnt52[i][j] += cnt52[i][j + 1];
    }
  }

  for (int j = MAX; j >= 0; j--) {
    for (int i = MAX - 1; i >= 0; i--) {
      cnt52[i][j] += cnt52[i + 1][j];
    }
  }

  /*printf("      ");
  rep(j, 20) printf("%3d", -10 + j); cout << endl;
  rep(i, 20){
    printf("%3d : ", -10 + i);
    rep(j, 20){
      printf("%3d", cnt52[i][j]);
    }
    cout << endl;
  }*/

  int ans = 0, sum = 0;
  rep(i, n) {
    if (cnt[i].first >= 0 && cnt[i].second >= 0)
      ans--;
    ans += cnt52[MAX / 2 - cnt[i].first][MAX / 2 - cnt[i].second];
  }
  cout << ans / 2 << endl;

  return 0;
}