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

// Hail god Yato

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

#define hs                                                                     \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve() {
  ll n;
  cin >> n;
  ll ttwo = 0, tfive = 0;
  ll k = 1e9;
  while (k % 2 == 0) {
    k /= 2;
    ++ttwo;
  }
  while (k % 5 == 0) {
    k /= 5;
    ++tfive;
  }
  map<pair<ll, ll>, int> store;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    double number;
    cin >> number;
    ll num = llround(number * 1e9);
    ll two = 0, five = 0;
    while (num % 2 == 0) {
      num /= 2;
      ++two;
    }
    while (num % 5 == 0) {
      num /= 5;
      ++five;
    }
    two -= ttwo;
    five -= tfive;
    for (auto itr : store) {
      pair<ll, ll> p = itr.first;
      if (p.first + two >= 0 && p.second + five >= 0)
        ans += itr.second;
    }
    store[{two, five}]++;
  }
  cout << ans;
}
int main() {
  hs;
  ll t;
  t = 1;
  // cin>>t;
  for (int i = 1; i <= t; i++) {
    // cout<<"Case #"<<i<<": ";
    solve();
  }
  return 0;
}


Error: TLE

Fixed submission:

// Hail god Yato

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

#define hs                                                                     \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve() {
  ll n;
  cin >> n;
  ll ttwo = 0, tfive = 0;
  ll k = 1e9;
  while (k % 2 == 0) {
    k /= 2;
    ++ttwo;
  }
  while (k % 5 == 0) {
    k /= 5;
    ++tfive;
  }
  vector<pair<ll, ll>> store;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    double number;
    cin >> number;
    ll num = llround(number * 1e9);
    ll two = 0, five = 0;
    while (num % 2 == 0) {
      num /= 2;
      ++two;
    }
    while (num % 5 == 0) {
      num /= 5;
      ++five;
    }
    two -= ttwo;
    five -= tfive;
    for (auto itr : store) {
      if (itr.first + two >= 0 && itr.second + five >= 0)
        ++ans;
    }
    // cout<<two<<" "<<five<<"\\n";
    store.push_back({two, five});
  }
  cout << ans;
}
int main() {
  hs;
  ll t;
  t = 1;
  // cin>>t;
  for (int i = 1; i <= t; i++) {
    // cout<<"Case #"<<i<<": ";
    solve();
  }
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
using LL = long long;
using pii = pair<int, int>;

int n;

signed main() {
  // freopen("in", "r", stdin);
  while (~scanf("%d", &n)) {
    map<pii, int> vis;
    double tmp;
    LL x;
    for (int i = 1; i <= n; i++) {
      cin >> tmp;
      x = llround(tmp * 1E9);
      int two = 0, five = 0;
      while (x % 2 == 0) {
        x /= 2;
        two++;
      }
      while (x % 5 == 0) {
        x /= 5;
        five++;
      }
      vis[{two, five}]++;
    }
    LL ret = 0;
    for (auto x : vis) {
      for (auto y : vis) {
        if (x.first.first + y.first.first >= 18 &&
            x.first.second + y.first.second >= 18) {
          if (x < y) {
            ret += (LL)x.second * y.second;
          } else if (x == y) {
            ret += (LL)x.second * (y.second - 1) / 2LL;
          }
        }
      }
    }
    printf("%lld\\n", ret);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using LL = long long;
using pii = pair<int, int>;

const int maxn = 20020;
int n;
LL a[maxn];

signed main() {
  // freopen("in", "r", stdin);
  while (~scanf("%d", &n)) {
    map<pii, int> vis;
    double tmp;
    for (int i = 1; i <= n; i++) {
      cin >> tmp;
      a[i] = llround(tmp * 1E9);
      int two = 0, five = 0;
      while (a[i] % 2 == 0) {
        a[i] /= 2;
        two++;
      }
      while (a[i] % 5 == 0) {
        a[i] /= 5;
        five++;
      }
      vis[{two, five}]++;
    }
    LL ret = 0;
    for (auto x : vis) {
      for (auto y : vis) {
        if (x.first.first + y.first.first >= 18 &&
            x.first.second + y.first.second >= 18) {
          if (x < y) {
            ret += (LL)x.second * y.second;
          } else if (x == y) {
            ret += (LL)x.second * (y.second - 1) / 2LL;
          }
        }
      }
    }
    printf("%lld\\n", ret);
  }
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int ch = 1000000000;

ll convert(string s) {
  int id = -1;
  ll ans = 0;
  ll n = 1;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == '.')
      id = i;
  int nb = id + 9;
  if (id == -1)
    nb = s.length() + 9;
  for (int i = 0; i < nb; i++)
    n *= 10;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '.')
      id = i;
    else {
      ans += (s[i] - '0') * n;
      n /= 10;
    }
  }
  return ans / 10;
}

const int r = 1e9;

int main() {
  int N;
  cin >> N;
  int nb[52][52];
  ll ans = 0;
  memset(nb, 0, sizeof nb);
  vector<pair<int, int>> v;
  for (int i = 0; i < N; i++) {
    string d;
    cin >> d;
    ll num = convert(d);
    int a, b;
    a = b = 0;
    while (num % 2 == 0) {
      num /= 2;
      a++;
    }
    while (num % 5 == 0) {
      num /= 5;
      b++;
    }
    v.push_back({a, b});
    for (int j = 0; j <= a; j++) {
      for (int k = 0; k <= b; k++) {
        nb[j][k]++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    int a = v[i].first, b = v[i].second;
    ans += nb[max(18 - a, 0)][18 - b];
    if (a > 8 && b > 8)
      ans--;
  }
  cout << ans / 2;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int ch = 1000000000;

ll convert(string s) {
  int id = -1;
  ll ans = 0;
  ll n = 1;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == '.')
      id = i;
  int nb = id + 9;
  if (id == -1)
    nb = s.length() + 9;
  for (int i = 0; i < nb; i++)
    n *= 10;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '.')
      id = i;
    else {
      ans += (s[i] - '0') * n;
      n /= 10;
    }
  }
  return ans / 10;
}

const int r = 1e9;

int main() {
  int N;
  cin >> N;
  int nb[28][28];
  int ans = 0;
  memset(nb, 0, sizeof nb);
  vector<pair<int, int>> v;
  for (int i = 0; i < N; i++) {
    string d;
    cin >> d;
    ll num = convert(d);
    ll NN = num;
    int a, b;
    a = b = 0;
    while (num % 2 == 0) {
      num /= 2;
      a++;
    }
    while (num % 5 == 0) {
      num /= 5;
      b++;
    }
    v.push_back({a, b});
    for (int j = 0; j <= a; j++) {
      for (int k = 0; k <= b; k++) {
        nb[j][k]++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    int a = v[i].first, b = v[i].second;
    ans += nb[18 - a][18 - b];
    if (a > 8 && b > 8)
      ans--;
  }
  cout << ans / 2;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

/*
a=n*2^(-x)*5^(-y)

みたいな変換をかける

整数同士ならなんでも


少数と整数の組みは

それぞれの少数
a [2:-x, 5: -y]に対して
2がx以上かつ5がy以上の整数がいくつあるのか

表を作ればまあ、

2^14>1e4
5^6>1e4
*/
#include <bits/stdc++.h>
using namespace std;
long divnum(long x, long e) { return (x % e == 0 ? divnum(x / e, e) + 1 : 0); }
int main() {
  long N;
  cin >> N;
  vector<pair<long, long>> A;
  vector<vector<long>> C(100, vector<long>(100, 0));
  vector<vector<long>> D(101, vector<long>(101, 0));

  for (long i = 0; i < N; i++) {
    string a;
    cin >> a;
    if (a.find(".") == string::npos) {
      long x = atol(a.c_str());
      A.push_back(pair<long, long>(divnum(x, 2), divnum(x, 5)));
      C[divnum(x, 2) + 50][divnum(x, 5) + 50]++;
    } else {
      long p = a.length() - a.find(".") - 1;
      long x = atol(
          (a.substr(0, a.find(".")) + a.substr(a.find(".") + 1, -1)).c_str());
      A.push_back(pair<long, long>(divnum(x, 2) - p, divnum(x, 5) - p));
      C[divnum(x, 2) - p + 50][divnum(x, 5) - p + 50]++;
    }
  }
  // p,q以上の和が欲しいので2次元累積和
  for (long i = 0; i < 100; i++)
    for (long j = 0; j < 100; j++) {
      D[i + 1][j + 1] = C[i][j] + D[i + 1][j] + D[i][j + 1] - D[i][j];
    }

  long ans = 0;
  for (long i = 0; i < N; i++) {

    // x=p,qとして
    //  -p以上, -q以上が欲しい

    ans += D[100][100] - D[100][-A[i].second + 50] - D[-A[i].first + 50][100] +
           D[-A[i].first + 50][-A[i].second + 50];
    if (A[i].first >= 0 && A[i].second >= 0)
      ans--;
  }
  cout << ans / 2;
}

Error: WA

Fixed submission:

/*
a=n*2^(-x)*5^(-y)

みたいな変換をかける

整数同士ならなんでも


少数と整数の組みは

それぞれの少数
a [2:-x, 5: -y]に対して
2がx以上かつ5がy以上の整数がいくつあるのか

表を作ればまあ、

2^14>1e4
5^6>1e4
*/
#include <bits/stdc++.h>
using namespace std;
long divnum(long x, long e) { return (x % e == 0 ? divnum(x / e, e) + 1 : 0); }
int main() {
  long N;
  cin >> N;
  vector<pair<long, long>> A;
  vector<vector<long>> C(40, vector<long>(40, 0));
  vector<vector<long>> D(41, vector<long>(41, 0));

  for (long i = 0; i < N; i++) {
    string a;
    cin >> a;
    if (a.find(".") == string::npos) {
      cout << "aa";
      return 0;
      long x = atol(a.c_str());
      A.push_back(pair<long, long>(divnum(x, 2), divnum(x, 5)));
      C[divnum(x, 2) + 20][divnum(x, 5) + 20]++;
    } else {
      long p = a.length() - a.find(".") - 1;
      long x = atol(
          (a.substr(0, a.find(".")) + a.substr(a.find(".") + 1, -1)).c_str());
      A.push_back(pair<long, long>(divnum(x, 2) - p, divnum(x, 5) - p));
      C[divnum(x, 2) - p + 20][divnum(x, 5) - p + 20]++;
    }
  }
  // p,q以上の和が欲しいので2次元累積和
  for (long i = 0; i < 40; i++)
    for (long j = 0; j < 40; j++) {
      D[i + 1][j + 1] = C[i][j] + D[i + 1][j] + D[i][j + 1] - D[i][j];
    }

  long ans = 0;
  for (long i = 0; i < N; i++) {

    // x=p,qとして
    //  -p以上, -q以上が欲しい

    ans += D[40][40] - D[40][-A[i].second + 20] - D[-A[i].first + 20][40] +
           D[-A[i].first + 20][-A[i].second + 20];
    if (A[i].first >= 0 && A[i].second >= 0)
      ans--;
  }
  cout << ans / 2;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include "algorithm"
#include "bitset"
#include "cassert"
#include "climits"
#include "cmath"
#include "cstdio"
#include "ctime"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"

using namespace std;

constexpr long long int MOD = 1000000007;
// constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
// constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

// int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

  cin >> N;
  int num[19][19] = {};
  long long int ans = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s.find('.') == s.npos) {
      s.push_back('.');
    }
    while (s.size() - s.find('.') < 10) {
      s.push_back('0');
    }
    s.erase(s.begin() + s.find('.'));
    // cout << s << endl;
    M = stoll(s);
    while (s.front() == '0')
      s.erase(s.begin());
    //	cout << M << endl;
    int a = 0, b = 0;
    while (M % 2 == 0) {
      M /= 2;
      a++;
    }
    while (M % 5 == 0) {
      M /= 5;
      b++;
    }
    a = min(a, 18);
    b = min(b, 18);
    for (int j = 0; j <= 18; j++) {
      for (int k = 0; k <= 18; k++) {
        if (a + j >= 18 && b + k >= 18)
          ans += num[j][k];
      }
    }
    num[a][b]++;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include "algorithm"
#include "bitset"
#include "cassert"
#include "climits"
#include "cmath"
#include "cstdio"
#include "ctime"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"

using namespace std;

constexpr long long int MOD = 1000000007;
// constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
// constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

// int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

  cin >> N;
  int num[19][19] = {};
  long long int ans = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s.find('.') == s.npos) {
      s.push_back('.');
    }
    while (s.size() - s.find('.') < 10) {
      s.push_back('0');
    }
    s.erase(s.begin() + s.find('.'));
    // cout << s << endl;
    M = stoll(s);
    while (s.front() == '0')
      s.erase(s.begin());
    //	cout << M << endl;
    int a = 0, b = 0;
    while (M % 2 == 0) {
      M /= 2;
      a++;
    }
    while (M % 5 == 0) {
      M /= 5;
      b++;
    }
    for (int j = 0; j <= 18; j++) {
      for (int k = 0; k <= 18; k++) {
        if (a + j >= 18 && b + k >= 18)
          ans += num[j][k];
      }
    }
    num[a][b]++;
  }
  cout << ans << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> cnt(20, vector<int>(20));
  vector<pair<int, int>> a;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long x = 0;
    bool found = false;
    for (int i = 0; i < (int)s.size(); i++) {
      if (s[i] != '.')
        (x *= 10) += s[i] - '0';
      else
        found = true;
    }
    if (!found) {
      x *= (long long)1e9;
    } else {
      int cur = 0;
      while (s.back() != '.') {
        ++cur;
        s.pop_back();
      }
      for (int it = 0; it < 9 - cur; it++)
        x *= 10;
    }
    int cnt2 = 0;
    long long y = x;
    while (y % 2 == 0) {
      ++cnt2;
      y /= 2;
    }
    int cnt5 = 0;
    y = x;
    while (y % 5 == 0) {
      ++cnt5;
      y /= 5;
    }
    ++cnt[min(18, cnt2)][min(18, cnt5)];
    a.emplace_back(min(18, cnt2), min(18, cnt5));
  }
  for (int i = 18; i >= 0; i--) {
    for (int j = 18; j >= 0; j--) {
      cnt[i][j] += cnt[i + 1][j] + cnt[i][j + 1] - cnt[i + 1][j + 1];
    }
  }
  long long res = 0;
  for (auto x : a) {
    res += cnt[18 - x.first][18 - x.second] - (x.first >= 9 && x.second >= 9);
  }
  res /= 2;
  cout << res << '\\n';
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> cnt(20, vector<int>(20));
  vector<pair<int, int>> a;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long x = 0;
    bool found = false;
    for (int i = 0; i < (int)s.size(); i++) {
      if (s[i] != '.')
        (x *= 10) += s[i] - '0';
      else
        found = true;
    }
    if (!found) {
      x *= (long long)1e9;
    } else {
      int cur = 0;
      while (s.back() != '.') {
        ++cur;
        s.pop_back();
      }
      for (int it = 0; it < 9 - cur; it++)
        x *= 10;
    }
    int cnt2 = 0;
    long long y = x;
    while (y % 2 == 0) {
      ++cnt2;
      y /= 2;
    }
    int cnt5 = 0;
    y = x;
    while (y % 5 == 0) {
      ++cnt5;
      y /= 5;
    }
    ++cnt[min(18, cnt2)][min(18, cnt5)];
    a.emplace_back(cnt2, cnt5);
  }
  for (int i = 18; i >= 0; i--) {
    for (int j = 18; j >= 0; j--) {
      cnt[i][j] += cnt[i + 1][j] + cnt[i][j + 1] - cnt[i + 1][j + 1];
    }
  }
  long long res = 0;
  for (auto x : a) {
    res += cnt[18 - x.first][18 - x.second] - (x.first >= 9 && x.second >= 9);
  }
  res /= 2;
  cout << res << '\\n';
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int N, ans = 0;
  cin >> N;
  vector<vector<int>> A(20, vector<int>(20));
  while (N--) {
    string S;
    cin >> S;
    long double d = stod(S);
    if (d == 0)
      A[19][19]++;
    else if (d == (int)d) {
      ans--;
      int n2 = 0, n5 = 0;
      for (int i = d; i % 2 == 0; i /= 2)
        n2++;
      for (int i = d; i % 5 == 0; i /= 5)
        n5++;
      A[min(n2, 9LL) + 10][min(n5, 9LL) + 10]++;
    } else {
      string T = "";
      int n;
      for (int i = 0; i < S.size(); i++) {
        if (S[i] != '.')
          T += S[i];
        else
          n = i;
      }
      for (int i = T.size() - n; i < 9; i++)
        T += '0';
      int D = stoll(T);
      int n2 = 1, n5 = 1;
      for (int i = D; i % 2 == 0; i /= 2)
        n2++;
      for (int i = D; i % 5 == 0; i /= 5)
        n5++;
      A[min(n2, 19LL)][min(n5, 19LL)]++;
    }
  }
  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 >= 20 && j + l >= 20) {
            ans += A[i][j] * A[k][l];
          }
  cout << ans / 2 << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int N, ans = 0;
  cin >> N;
  vector<vector<int>> A(20, vector<int>(20));
  while (N--) {
    string S;
    cin >> S;
    long double d = stod(S);
    if (d == 0)
      A[19][19]++;
    else if (d == (int)d) {
      ans--;
      int n2 = 0, n5 = 0;
      for (int i = d; i % 2 == 0; i /= 2)
        n2++;
      for (int i = d; i % 5 == 0; i /= 5)
        n5++;
      A[min(n2, 9LL) + 10][min(n5, 9LL) + 10]++;
    } else {
      string T = "";
      for (int i = 0; i < S.size(); i++) {
        if (S[i] != '.')
          T += S[i];
      }
      for (int i = T.size(); i < 9; i++)
        T += '0';
      int D = stoll(T);
      int n2 = 2, n5 = 2;
      for (int i = D; i % 2 == 0; i /= 2)
        n2++;
      for (int i = D; i % 5 == 0; i /= 5)
        n5++;
      A[min(n2, 20LL)][min(n5, 20LL)]++;
    }
  }
  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 >= 20 && j + l >= 20)
            ans += A[i][j] * A[k][l];
  cout << ans / 2 << endl;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define int long long
#define m_k make_pair
using namespace std;
const int N = 2 * 1e5 + 100;
int n, a[N], b[N], sum[100][100], ans;
char s[1000];
signed main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    int len = strlen(s);
    int x = 0, cnt = 0;
    bool bl = 1;
    for (int j = 0; j < len; j++) {
      if (s[j] == '.') {
        bl = 0;
        continue;
      }
      if (!bl)
        cnt++;
      x = x * 10ll + s[j] - '0';
    }
    for (int j = 1; j <= 9 - cnt; j++)
      x *= 10ll;
    while (x % 2 == 0)
      a[i]++, x /= 2ll;
    while (x % 5 == 0)
      b[i]++, x /= 5ll;
    sum[a[i]][b[i]]++;
    if (a[i] + a[i] >= 18 && b[i] + b[i] >= 18)
      ans--;
  }
  for (int i = 70; i >= 0; i--) {
    for (int j = 70; j >= 0; j--)
      sum[i][j] += sum[i][j + 1];
  }
  for (int j = 70; j >= 0; j--) {
    for (int i = 70; i >= 0; i--)
      sum[i][j] += sum[i + 1][j];
  }
  for (int i = 1; i <= n; i++)
    ans += sum[max(18 - a[i], 0ll)][max(18 - b[i], 0ll)];
  ans /= 2;
  printf("%lld\\n", ans);
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define int long long
#define m_k make_pair
using namespace std;
const int N = 2 * 1e5 + 100;
int n, a[N], b[N], sum[70][70], ans;
signed main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    double num;
    scanf("%lf", &num);
    int x = (int)(num * 1000000000);
    while (x % 2 == 0)
      a[i]++, x /= 2;
    while (x % 5 == 0)
      b[i]++, x /= 5;
    sum[a[i]][b[i]]++;
    if (a[i] + a[i] >= 18 && b[i] + b[i] >= 18)
      ans--;
  }
  for (int i = 65; i >= 0; i--) {
    for (int j = 65; j >= 0; j--)
      sum[i][j] += sum[i][j + 1];
  }
  for (int j = 65; j >= 0; j--) {
    for (int i = 65; i >= 0; i--)
      sum[i][j] += sum[i + 1][j];
  }
  for (int i = 1; i <= n; i++)
    ans += sum[18 - a[i]][18 - b[i]];
  ans /= 2;
  printf("%lld\\n", ans);
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

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

int nmax = 100;

ll f(ll x) {
  int two = 0;
  while (x % 2 == 0) {
    two++;
    x /= 2;
  }
  return (two);
}

ll g(ll x) {
  int five = 0;
  while (x % 5 == 0) {
    five++;
    x /= 5;
  }
  return (five);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<vector<ll>> list(nmax, vector<ll>(nmax, 0));
  rep(i, n) {
    long double x;
    cin >> x;
    a[i] = (ll)(x * 1e9 + 0.5);
  }

  rep(i, n) {
    int two = 0, five = 0;
    two = f(a[i]);
    five = g(a[i]);
    list[two][five]++;
  }

  ll ans = 0;

  rep(i, nmax) rep(j, nmax) rep(k, nmax) rep(l, nmax) {
    if (make_pair(i, j) <= make_pair(k, l) && i + k >= 18 && j + l >= 18) {
      if (i == k && j == l) {
        ans += list[i][j] * (list[i][j] - 1) / 2;
      } else {
        ans += list[i][j] * list[k][l];
      }
    }
  }

  cout << ans << endl;

  return (0);
}

Error: 0

Fixed submission:

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

int f(ll x) {
  int two = 0;
  while (x % 2 == 0) {
    two++;
    x /= 2;
  }
  return (two);
}

int g(ll x) {
  int five = 0;
  while (x % 5 == 0) {
    five++;
    x /= 5;
  }
  return (five);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<vector<ll>> list(19, vector<ll>(19, 0));
  rep(i, n) {
    long double x;
    cin >> x;
    a[i] = round(x * 1000000000);
  }

  rep(i, n) {
    int two = 0, five = 0;
    two = f(a[i]);
    five = g(a[i]);
    list[two][five]++;
  }

  ll ans = 0;

  rep(i, 19) rep(j, 19) rep(k, 19) rep(l, 19) {
    if (make_pair(i, j) <= make_pair(k, l) && i + k >= 18 && j + l >= 18) {
      if (i == k && j == l) {
        ans += list[i][j] * (list[i][j] - 1) / 2;
      } else {
        ans += list[i][j] * list[k][l];
      }
    }
  }

  cout << ans << endl;

  return (0);
}