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

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {

  int d = 20;
  int n;
  cin >> n;
  unordered_map<int, unordered_map<int, int>> um;
  long long int res = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long int t;
    int n1 = 0, n2 = 0;
    if (s.find('.') == string::npos) {
      t = stoll(s);
      while (t % 2 == 0) {
        t /= 2;
        n1++;
      }
      while (t % 5 == 0) {
        t /= 5;
        n2++;
      }
    } else {
      int index = s.find('.');
      n1 = s.size() - 1 - index;
      n1 = -n1;
      n2 = n1;
      s = string(s.begin(), s.begin() + index) +
          string(s.begin() + index + 1, s.end());
      t = stoll(s);
      while (t % 2 == 0) {
        t /= 2;
        n1++;
      }
      while (t % 5 == 0) {
        t /= 5;
        n2++;
      }
    }
    um[n1][n2]++;
    // cout << n1 << " " << n2 << endl;
    // cout << res << endl;
  }
  for (auto pp1 : um) {
    for (auto pp2 : pp1.second) {
      int n1 = pp1.first;
      int n2 = pp2.first;
      long long int c = pp2.second;
      if (n1 >= 0 && n2 >= 0)
        res -= c;
      for (auto p1 : um) {
        for (auto p2 : p1.second) {
          if (n1 + p1.first >= 0 && n2 + p2.first >= 0) {
            res += p2.second * c;
          }
        }
      }
    }
  }
  cout << res / 2 << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {

  int d = 20;
  int n;
  cin >> n;
  unordered_map<int, unordered_map<int, int>> um;
  long long int res = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long int t;
    int n1 = 0, n2 = 0;
    if (s.find('.') == string::npos) {
      t = stoll(s);
      while (t % 2 == 0) {
        t /= 2;
        n1++;
      }
      while (t % 5 == 0) {
        t /= 5;
        n2++;
      }
    } else {
      int index = s.find('.');
      n1 = s.size() - 1 - index;
      n1 = -n1;
      n2 = n1;
      s = string(s.begin(), s.begin() + index) +
          string(s.begin() + index + 1, s.end());
      t = stoll(s);
      while (t % 2 == 0) {
        t /= 2;
        n1++;
      }
      while (t % 5 == 0) {
        t /= 5;
        n2++;
      }
    }
    for (auto p1 : um) {
      for (auto p2 : p1.second) {
        if (n1 + p1.first >= 0 && n2 + p2.first >= 0) {
          res += p2.second;
        }
      }
    }
    um[n1][n2]++;
    // cout << n1 << " " << n2 << endl;
    // cout << res << endl;
  }
  cout << res << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <utility>
#include <vector>
using namespace std;
double EPS = 1e-10;
typedef pair<long long, long long> P;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    double a;
    cin >> a;
    A[i] = (a + EPS) * 1e9;
  }
  vector<P> cnt(N);
  for (int i = 0; i < N; i++) {
    long long f = 0, n = 0;
    while (A[i] % 5 == 0) {
      f++;
      A[i] /= 5;
    }
    while (A[i] % 2 == 0) {
      n++;
      A[i] /= 2;
    }
    cnt[i] = P(f, n);
  }
  vector<vector<long long>> dp(24, vector<long long>(50, 0));
  for (int i = 0; i < N; i++) {
    P p = cnt[i];
    dp[p.first][p.second]++;
  }
  for (int k = 0; k < 24; k++) {
    for (int j = 1; j < 50; j++) {
      dp[23 - k][49 - j] += dp[23 - k][50 - j];
    }
  }
  for (int k = 0; k < 50; k++) {
    for (int j = 1; j < 24; j++) {
      dp[23 - j][49 - k] += dp[24 - j][49 - k];
    }
  }
  long long ans = 0;
  long long cntf = 18, cntn = 18;
  for (int i = 0; i < N; i++) {
    P p = cnt[i];
    if (p.first * 2 >= 18 && p.second * 2 >= 18)
      ans--;
    ans += dp[max(0LL, cntf - p.first)][max(0LL, cntn - p.second)];
  }
  cout << ans / 2 << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
typedef pair<long long, long long> P;
int main() {
  int N;
  cin >> N;
  vector<long double> A;
  for (int i = 0; i < N; i++) {
    double a;
    cin >> a;
    long long b = a * 10000 + EPS;
    if (a * 10000 - b < EPS)
      A.push_back(a);
  }
  vector<long long> B((int)A.size());
  for (int i = 0; i < A.size(); i++) {
    B[i] = (long long)(A[i] * 10000 + EPS);
  }
  vector<P> cnt((int)B.size());
  for (int i = 0; i < (int)B.size(); i++) {
    int a = 0, b = 0;
    while (B[i] % 5 == 0) {
      a++;
      B[i] /= 5;
    }
    while (B[i] % 2 == 0) {
      b++;
      B[i] /= 2;
    }
    cnt[i] = P(a, b);
  }
  long long temp = 1e8;
  long long cntf = 0, cntn = 0;
  while (temp % 5 == 0) {
    cntf++;
    temp /= 5;
  }
  while (temp % 2 == 0) {
    cntn++;
    temp /= 2;
  }
  P p = P(cntf, cntn);
  vector<vector<long long>> dp((15), vector<long long>(32, 0));
  for (int i = 0; i < cnt.size(); i++) {
    P p = cnt[i];
    dp[p.first][p.second]++;
  }
  long long ans = 0;
  for (int i = 0; i < cnt.size(); i++) {
    vector<vector<long long>> d = dp;
    P p = cnt[i];
    d[p.first][p.second]--;
    for (int j = 0; j < 15; j++) {
      for (int k = 1; k < 32; k++)
        d[14 - j][31 - k] += d[14 - j][31 - k + 1];
    }
    for (int j = 0; j < 32; j++) {
      for (int k = 1; k < 15; k++)
        d[14 - k][31 - j] += d[14 - k + 1][31 - j];
    }
    ans += d[cntf - p.first][cntn - p.second];
  }
  cout << ans / 2 << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
#define N 500005
#define ll long long
ll n;
double a[N];
ll cnt2[N], cnt5[N], ten[N];
ll sum[5005][5005], ans;
ll len1, len2;
int main() {
  scanf("%lld", &n);
  for (ll i = 1; i <= n; i++) {
    scanf("%lf", a + i);
    ten[i] = 9;
    ll JZY = llround(a[i] * 1000000000);
    //		printf("%lld\\n",JZY);
    while (JZY % 2 == 0 && JZY)
      JZY >>= 1, cnt2[i]++;
    while (JZY % 5 == 0 && JZY)
      JZY /= 5, cnt5[i]++;
    //		for(ll j=0,mul=1;j<=10;j++,mul*=10){
    ////			if(i==n)printf("read %lf %lld
    ///%lld\\n",a[i]*mul,(ll)(a[i]*mul),(a[i]*mul)-(ll)(a[i]*mul)<1e-9);
    //			if(a[i]*mul==llround(a[i]*mul)){
    //				ten[i]=j;
    ////				printf("%lld %lld
    ///%lld\\n",cnt2[i],cnt5[i],ten[i]);
    //				break;
    //			}
    //		}
  }
  for (ll i = 1; i <= n; i++)
    len1 = max(len1, cnt2[i]), len2 = max(len2, cnt5[i]);
  len1 += 20, len2 += 20;
  //	printf("border %lld %lld\\n",len1,len2);
  for (ll i = 1; i <= n; i++) {
    //		printf("num %lf\\n",a[i]);
    //		printf("check %lld %lld\\n",ten[i]-cnt2[i]+10,ten[i]-cnt5[i]+10);
    for (ll x = ten[i] - cnt2[i] + 20; x <= len1; x++)
      for (ll y = ten[i] - cnt5[i] + 20; y <= len2; y++)
        ans += sum[x][y];
    //		printf("add %lld %lld\\n",cnt2[i]-ten[i]+10,cnt5[i]-ten[i]+10);
    sum[cnt2[i] - ten[i] + 20][cnt5[i] - ten[i] + 20]++;
  }
  printf("%lld", ans);
}
/*
7
0.9
1
1
1.25
2.3
5
70
*/

Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
#define N 500005
#define ll long long
int n;
double a[N];
int cnt2[N], cnt5[N], ten[N];
int sum[5005][5005], ans;
int len1, len2;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", a + i);
    for (ll j = 0, mul = 1; j <= 10; j++, mul *= 10) {
      //			if(i==n)printf("read %lf %lld
      //%d\\n",a[i]*mul,(ll)(a[i]*mul),(a[i]*mul)-(ll)(a[i]*mul)<1e-9);
      if ((a[i] * mul) - (ll)(a[i] * mul) < 1e-9) {
        ten[i] = j;
        ll JZY = a[i] * mul;
        //				printf("%lld\\n",JZY);
        while (JZY % 2 == 0 && JZY)
          JZY >>= 1, cnt2[i]++;
        while (JZY % 5 == 0 && JZY)
          JZY /= 5, cnt5[i]++;
        //				printf("%d %d
        //%d\\n",cnt2[i],cnt5[i],ten[i]);
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    len1 = max(len1, cnt2[i]), len2 = max(len2, cnt5[i]);
  len1 += 10, len2 += 10;
  //	printf("border %d %d\\n",len1,len2);
  for (int i = 1; i <= n; i++) {
    //		printf("num %lf\\n",a[i]);
    //		printf("check %d %d\\n",ten[i]-cnt2[i]+10,ten[i]-cnt5[i]+10);
    for (int x = ten[i] - cnt2[i] + 10; x <= len1; x++)
      for (int y = ten[i] - cnt5[i] + 10; y <= len2; y++)
        ans += sum[x][y];
    //		printf("add %d %d\\n",cnt2[i]-ten[i]+10,cnt5[i]-ten[i]+10);
    sum[cnt2[i] - ten[i] + 10][cnt5[i] - ten[i] + 10]++;
  }
  printf("%d", ans);
}
/*
7
0.9
1
1
1.25
2.3
5
70
*/
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;

ll t[101][101];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // Älä käytä, jos tehtävä on interaktiivinen!
  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    ll a = 0;
    ll j = 0;
    while (s[j] != '.' && j < s.size()) {
      a *= 10;
      a += s[j] - '0';
      j++;
    }
    a *= 1e9;
    // cout << i << " " << a << "\\n";
    if (j != s.size()) {
      ll b = 1e8;
      j++;
      while (j < s.size()) {
        a += (s[j] - '0') * b;
        b /= 10;
        j++;
      }
    }
    // cout << i << " " << a << "\\n";
    ll c = 0;
    ll d = 0;
    while (a % 2 == 0) {
      a /= 2;
      c++;
    }
    while (a % 5 == 0) {
      a /= 5;
      d++;
    }
    ll e, f;
    if (c > 18)
      e = 18;
    else
      e = c;
    if (d > 18)
      f = 18;
    else
      f = d;
    ans += t[18 - e][18 - f];
    for (int j = 0; j <= c; ++j) {
      for (int k = 0; k <= d; ++k) {
        t[j][k]++;
      }
    }
  }
  cout << ans << "\\n";
}


Error: 0

Fixed submission:

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

typedef long long ll;

int t[1010][1010];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // Älä käytä, jos tehtävä on interaktiivinen!
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    ll a = 0;
    int j = 0;
    while (s[j] != '.' && j < s.size()) {
      a *= 10;
      a += s[j] - '0';
      j++;
    }
    a *= 1000000000;
    // cout << i << " " << a << "\\n";
    if (j != s.size()) {
      ll b = 1e8;

      j++;
      while (j < s.size()) {
        a += (s[j] - '0') * b;
        b /= 10;
        j++;
      }
    }
    // cout << i << " " << a << "\\n";
    int c = 0;
    int d = 0;
    while (a % 2 == 0) {
      a /= 2;
      c++;
    }
    while (a % 5 == 0) {
      a /= 5;
      d++;
    }
    ans += t[18 - c][18 - d];
    for (int j = 0; j <= c; ++j) {
      for (int k = 0; k <= d; ++k) {
        t[j][k]++;
      }
    }
  }
  cout << ans << "\\n";
}
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 REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
template <class A> void PR(A a, ll n) {
  rep(i, n) {
    if (i)
      cout << ' ';
    cout << a[i];
  }
  cout << "\\n";
}
ld PI = 3.14159265358979323846;

int main() {
  ll N;
  ld tmp;
  cin >> N;
  vector<ll> A(N);
  vector<vector<ll>> B(40, vector<ll>(40));
  rep(i, N) {
    cin >> tmp;
    A[i] = ll(tmp * 1e9 + 0.5);
  }
  rep(i, N) {
    ll cnt2 = 0;
    ll cur = A[i];
    while (cur % 2 == 0) {
      cnt2++;
      cur /= 2;
    }
    ll cnt5 = 0;
    while (cur % 5 == 0) {
      cnt5++;
      cur /= 5;
    }
    B[cnt2][cnt5]++;
  }
  ll ans = 0;
  map<Pll, ll> mp;
  rep(i, 40) {
    REP(k, 0, 40) {
      REP(j, 0, 40) {
        REP(l, 0, 40) {
          if (Pll(i, k) > Pll(j, l))
            continue;
          if (i + j < 18 || k + l < 18)
            continue;
          if (i == j && k == l) {
            ans += (B[i][k] * (B[j][l] - 1)) / 2;
          } else {
            ans += B[i][k] * B[j][l];
          }
        }
      }
    }
  }
  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 REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
template <class A> void PR(A a, ll n) {
  rep(i, n) {
    if (i)
      cout << ' ';
    cout << a[i];
  }
  cout << "\\n";
}
ld PI = 3.14159265358979323846;

int main() {
  ll N;
  ld tmp;
  cin >> N;
  vector<ll> A(N);
  vector<vector<ll>> B(20, vector<ll>(20));
  rep(i, N) {
    cin >> tmp;
    A[i] = ll(tmp * 1e9 + 0.5);
  }
  rep(i, N) {
    ll cnt2 = 0;
    ll cur = A[i];
    while (cur % 2 == 0) {
      cnt2++;
      cur /= 2;
    }
    ll cnt5 = 0;
    while (cur % 5 == 0) {
      cnt5++;
      cur /= 5;
    }
    B[cnt2][cnt5]++;
  }
  vector<vector<ll>> S;
  S = B;
  rep(i, 19) {
    for (ll j = 17; j >= 0; j--) {
      S[i][j] += S[i][j + 1];
    }
  }
  rep(i, 19) {
    for (ll j = 17; j >= 0; j--) {
      S[j][i] += S[j + 1][i];
    }
  }
  ll ans = 0;
  rep(i, 19) {
    rep(j, 19) {
      if (i >= 18 - i && j >= 18 - j) {
        ans += B[i][j] * S[18 - i][18 - j] - B[i][j];
      } else {
        ans += B[i][j] * S[18 - i][18 - j];
      }
    }
  }
  cout << ans / 2 << endl;
}
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;

int ten[20][20];

int main() {
  cin.tie(0)->sync_with_stdio(false);

  int n;
  cin >> n;

  ll cnt = 0;
  REP(i, n) {
    double x;
    cin >> x;
    ll tmp = x * 1e9 + 0.1;
    int two = 0;
    int five = 0;
    while (tmp % 2 == 0) {
      tmp /= 2;
      two++;
    }
    while (tmp % 5 == 0) {
      tmp /= 5;
      five++;
    }
    if (two > 18)
      two = 18;
    if (five > 18)
      five = 18;
    for (int j = 18 - two; j <= 18; j++)
      for (int k = 18 - five; k <= 18; k++)
        cnt += ten[j][k];
    ten[two][five]++;
  }

  cout << cnt << '\\n';
  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;

int main() {
  cin.tie(0)->sync_with_stdio(false);

  int n;
  cin >> n;

  vector<vector<int>> ten(30, vector<int>(30, 0));
  ll cnt = 0;
  REP(i, n) {
    double x;
    cin >> x;
    ll tmp = 1L * x * 1e9 + 0.1;
    int two, five;
    two = five = 0;
    while (!(tmp % 2) && two <= 18) {
      tmp /= 2;
      two++;
    }
    while (!(tmp % 5) && five <= 18) {
      tmp /= 5;
      five++;
    }
    for (int j = 18 - two; j <= 18; j++)
      for (int k = 18 - five; k <= 18; k++)
        cnt += ten[j][k];
    ten[two][five]++;
  }

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

// A.

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <vector>

using namespace std;

typedef long double LD;
typedef long long LL;

int main(int argc, char *argv[]) {
  LL n, nfc = 0, fc = 0, ans = 0;
  cin >> n;
  vector<vector<int>> sum(30, vector<int>(30));
  vector<int> nt(n), nf(n);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    LL x = 0;
    bool p = false;
    int cnt = 0;
    for (int i = 0; i < s.length(); ++i) {
      if (s[i] == '.') {
        p = true;
      } else {
        x = (x * 10) + s[i] - '0';
        if (p) {
          ++cnt;
        }
      }
    }
    int two = -cnt;
    int five = -cnt;
    while (x % 2 == 0) {
      ++two;
      x /= 2;
    }
    while (x % 5 == 0) {
      ++five;
      x /= 5;
    }
    for (int i = -10; i <= 10; ++i) {
      for (int j = -10; j <= 10; ++j) {
        if (i + two >= 0 && j + five >= 0) {
          ans += sum[i + 10][j + 10];
        }
      }
    }
    sum[min(two, 10) + 10][min(five, 10) + 10] += 1;
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

// A.

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <vector>

using namespace std;

typedef long double LD;
typedef long long LL;

int main(int argc, char *argv[]) {
  LL n, nfc = 0, fc = 0, ans = 0;
  cin >> n;
  vector<vector<int>> sum(30, vector<int>(30));
  vector<int> nt(n), nf(n);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    LL x = 0;
    bool p = false;
    int cnt = 0;
    for (int i = 0; i < s.length(); ++i) {
      if (s[i] == '.') {
        p = true;
      } else {
        x = (x * 10) + s[i] - '0';
        if (p) {
          ++cnt;
        }
      }
    }
    int two = -cnt;
    int five = -cnt;
    while (x % 2 == 0) {
      ++two;
      x /= 2;
    }
    while (x % 5 == 0) {
      ++five;
      x /= 5;
    }
    for (int i = -10; i < 20; ++i) {
      for (int j = -10; j < 20; ++j) {
        if (i + two >= 0 && j + five >= 0) {
          ans += sum[i + 10][j + 10];
        }
      }
    }
    sum[two + 10][five + 10] += 1;
  }
  cout << ans << endl;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
// #include<tr1::unordered_map>
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, a, n) for (int i = n; i >= a; --i)
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
const int maxn = 1e5 + 50;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll qpow(ll a, ll n) {
  ll r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1)
      r = r * a % P;
  return r;
}
bool cmp(int a, int b) { return a > b; }
ll mp[65][65];
ll ans;
void fen(ll x) {
  ll ans2 = 0;
  ll ans5 = 0;
  while (x % 5 == 0) {
    x /= 5;
    ans5++;
  }
  while (x % 2 == 0) {
    x /= 2;
    ans2++;
  }
  for (int i = 0; i <= 64; i++)
    for (int j = 0; j <= 64; j++) {
      if (ans2 + i >= 18 && ans5 + j >= 18)
        ans += mp[i][j];
    }
  mp[ans2][ans5]++;
}
int main() {
  io;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    double x;
    cin >> x;
    ll y = llround(x *= 1000000000.0);
    fen(y);
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
// #include<tr1::unordered_map>
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, a, n) for (int i = n; i >= a; --i)
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
const int maxn = 1e5 + 50;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll qpow(ll a, ll n) {
  ll r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1)
      r = r * a % P;
  return r;
}
bool cmp(int a, int b) { return a > b; }
map<pii, int> mp;
int ans;
void fen(ll x) {
  int ans2 = 0;
  int ans5 = 0;
  while (x % 5 == 0) {
    x /= 5;
    ans5++;
  }
  while (x % 2 == 0) {
    x /= 2;
    ans2++;
  }
  for (int i = 0; i <= 63; i++)
    for (int j = 0; j <= 30; j++) {
      if (ans2 + i >= 18 && ans5 + j >= 18)
        ans += mp[pii(i, j)];
    }
  mp[pii(ans2, ans5)]++;
}
int main() {
  io;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    double x;
    cin >> x;
    ll y = llround(x *= 1000000000.0);
    fen(y);
  }
  cout << ans << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
static inline int max(const int x, const int y) { return x > y ? x : y; }
int main(void) {
  int ten[21][21] = {{0}}, N;
  long count = 0;
  long double A;
  if (!scanf("%d", &N))
    return -1;
  rep(i, N) {
    if (!scanf("%Lf", &A))
      return -1;
    long x = 1l * 1e9 * A + 0.1;
    int even = 0, five = 0;
    while (!(x & 1) && even <= 18) {
      x /= 2, even++;
    }
    while (x % 5 == 0 && five <= 18) {
      x /= 5, five++;
    }
    for (int j = max(0, 18 - even); j <= 20; j++)
      for (int k = max(0, 18 - five); k <= 20; k++)
        count += ten[j][k];
    ten[even][five]++;
  }
  return printf("%ld\\n", count), 0;
}

Error: 0

Fixed submission:

#include <math.h>
#include <stdio.h>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
long double deca = 10000000000, D = deca * deca;
int main(void) {
  int count = 0, N;
  count = scanf("%d", &N);
  long double A[200000];
  rep(i, N) { count = scanf("%Lf", &A[i]); }
  count = 0;
  rep(i, N - 1) rep(j, N) {
    if (fmod(A[i] * A[i + j + 1], 1.0000000000000) == 0 &&
        A[i] * A[i + j + 1] > 0.0) {
      count++;
    }
  }
  return printf("%d\\n", count), 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
const int N = 2010, M = 200020, mod = 1e9 + 7;
ll n, m, T, k, cnt, x, y, z, a[M], b[M], f[N][N], g[N][N];
string s;
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    cin >> s;
    ll x = 0;
    m = s.size();
    int flag = 0;
    for (int i = 0; i < m; i++) {
      if (s[i] >= '0' && s[i] <= '9')
        x = x * 10 + s[i] - '0';
      if (s[i] == '.')
        y = i + 1, flag = 1;
    }
    if (!flag)
      y = m;
    while (x % 2 == 0)
      x /= 2, a[i]++;
    while (x % 5 == 0)
      x /= 5, b[i]++;
    a[i] -= m - y;
    b[i] -= m - y;
    f[1000 - a[i]][1000 - b[i]]++;
    g[1000 + a[i]][1000 + b[i]]++;
    // a[i]+=1000; b[i]+=1000;
  }
  // for (int i=1;i<=n;i++) printf("%lld %lld\\n",a[i]-1000,b[i]-1000);
  ll ans = 0;
  for (int i = 0; i <= 2000; i++)
    for (int j = 0; j <= 2000; j++) {
      if (i > 1 && j > 1)
        f[i][j] = f[i][j] + f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
      else if (i > 1)
        f[i][j] = f[i - 1][j] + f[i][j];
      else if (j > 1)
        f[i][j] = f[i][j - 1] + f[i][j];
      ans += g[i][j] * f[i][j];
    }
  /*
  for (int i=990;i<=1010;i++)
  {
          for (int j=990;j<=1010;j++) printf("%lld ",f[i][j]);puts("");
  }
  for (int i=990;i<=1010;i++)
  {
          for (int j=990;j<=1010;j++) printf("%lld ",g[i][j]);puts("");
  }
  */
  for (int i = 1; i <= n; i++)
    if (a[i] >= 0 && b[i] >= 0)
      ans--;
  ans /= 2;
  printf("%lld\\n", ans);
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
const int N = 2010, mod = 1e9 + 7;
ll n, m, T, k, cnt, x, y, z, a[N], b[N], f[N][N], g[N][N];
string s;
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    cin >> s;
    ll x = 0;
    m = s.size();
    for (int i = 0; i < m; i++) {
      if (s[i] >= '0' && s[i] <= '9')
        x = x * 10 + s[i] - '0';
      if (s[i] == '.')
        y = i + 1;
    }
    while (x % 2 == 0)
      x /= 2, a[i]++;
    while (x % 5 == 0)
      x /= 5, b[i]++;
    a[i] -= m - y;
    b[i] -= m - y;
    f[1000 - a[i]][1000 - b[i]]++;
    g[1000 + a[i]][1000 + b[i]]++;
    a[i] += 1000;
    b[i] += 1000;
  }
  ll ans = 0;
  for (int i = 0; i <= 2000; i++)
    for (int j = 0; j <= 2000; j++) {
      if (i > 1 && j > 1)
        f[i][j] = f[i][j] + f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
      else if (i > 1)
        f[i][j] = f[i - 1][j] + f[i][j];
      else if (j > 1)
        f[i][j] = f[i][j - 1] + f[i][j];
      ans += g[i][j] * f[i][j];
    }
  printf("%lld\\n", ans / 4);
}