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

// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/15/20 20:19:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int r, c, k;
  cin >> r >> c >> k;
  vector<vector<int>> item(r, vector<int>(c, 0));
  for (int i = 0; i < k; i++) {
    int rr, cc, v;
    cin >> rr >> cc >> v;
    rr--;
    cc--;
    item[rr][cc] = v;
  }
  vector<vector<array<ll, 4>>> dp(r, vector<array<ll, 4>>(c, {0, 0, 0, 0}));
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      auto it = item[i][j];
      if (it > 0) {
        for (int s = 2; s >= 0; s--) {
          dp[i][j][s + 1] = max(dp[i][j][s + 1], dp[i][j][s] + it);
        }
      }
      for (int s = 3; s >= 0; s--) {
        auto &cdp = dp[i][j][s];
        if (i + 1 < r) {
          dp[i + 1][j][0] = max(dp[i + 1][j][0], cdp);
        }
        if (j + 1 < c) {
          dp[i][j + 1][s] = max(dp[i][j + 1][s], cdp);
        }
      }
    }
  }
  ll ans = 0;
  for (int s = 0; s <= 3; s++) {
    ans = max(ans, dp[r - 1][c - 1][s]);
  }
  cout << ans << endl;

  return 0;
}


Error: 0

Fixed submission:

// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/15/20 20:19:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int r, c, k;
  cin >> r >> c >> k;
  vector<vector<int>> item(r, vector<int>(c, 0));
  for (int i = 0; i < k; i++) {
    int r, c, v;
    cin >> r >> c >> v;
    r--;
    c--;
    item[r][c] = v;
  }
  ll dp[r][c][4];
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      for (int k = 0; k < 4; k++) {
        dp[i][j][k] = 0;
      }
    }
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      for (int k = 2; k >= 0; k--) {
        if (item[i][j] == 0)
          break;
        dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k] + item[i][j]);
      }
      for (int k = 3; k >= 0; k--) {
        auto &cdp = dp[i][j][k];
        if (i + 1 < r) {
          dp[i + 1][j][0] = max(dp[i + 1][j][0], cdp);
        }
        if (j + 1 < c) {
          dp[i][j + 1][k] = max(dp[i][j + 1][k], cdp);
        }
      }
    }
  }
  auto &edp = dp[r - 1][c - 1];
  ll ans = *max_element(edp, edp + 4);
  cout << ans << endl;

  return 0;
}
Problem p02586 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
long long dp[2][3005][4] = {0};
long long mm[3005][3005] = {0};
int main() {
  int r, c, k;
  cin >> r >> c >> k;
  // cout <<1 <<endl;
  int u, v, w;
  for (int i = 0; i < k; i++) {
    cin >> u >> v >> w;
    mm[u][v] = w;
  }
  // cout <<1 <<endl;

  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c; ++j) {
      dp[i & 1][j][0] = max({dp[(i + 1) & 1][j][0], dp[(i + 1) & 1][j][1],
                             dp[(i + 1) & 1][j][2], dp[(i + 1) & 1][j][3]});
      dp[i & 1][j][1] =
          max(dp[i & 1][j - 1][1],
              max(dp[i & 1][j][0], dp[i & 1][j - 1][0]) + mm[i][j]);
      dp[i & 1][j][2] =
          max(dp[i & 1][j - 1][2], dp[i & 1][j - 1][1] + mm[i][j]);
      dp[i & 1][j][3] =
          max(dp[i & 1][j - 1][3], dp[i & 1][j - 1][2] + mm[i][j]);
      // cout << dp[i&1][j][0] << " "  <<  dp[i&1][j][1] <<" " <<dp[i&1][j][2]
      // << " "<<dp[i&1][j][3] <<endl;
    }
  }
  cout << max(
      {dp[r & 1][c][3], dp[r & 1][c][2], dp[r & 1][c][1], dp[r & 1][c][0]});
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
long long dp[2][3005][4] = {0};
map<pair<int, int>, int> mm;
int main() {
  int r, c, k;
  cin >> r >> c >> k;
  // cout <<1 <<endl;
  int u, v, w;
  for (int i = 0; i < k; i++) {
    cin >> u >> v >> w;
    mm[make_pair(u, v)] = w;
  }
  // cout <<1 <<endl;

  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c; j++) {
      dp[i & 1][j][0] = max({dp[(i + 1) & 1][j][0], dp[(i + 1) & 1][j][1],
                             dp[(i + 1) & 1][j][2], dp[(i + 1) & 1][j][3]});
      dp[i & 1][j][1] =
          max(dp[i & 1][j - 1][1],
              max(dp[i & 1][j][0], dp[i & 1][j - 1][0]) + mm[make_pair(i, j)]);
      dp[i & 1][j][2] =
          max(dp[i & 1][j - 1][2], dp[i & 1][j - 1][1] + mm[make_pair(i, j)]);
      dp[i & 1][j][3] =
          max(dp[i & 1][j - 1][3], dp[i & 1][j - 1][2] + mm[make_pair(i, j)]);
      // cout << dp[i&1][j][0] << " "  <<  dp[i&1][j][1] <<" " <<dp[i&1][j][2]
      // << " "<<dp[i&1][j][3] <<endl;
    }
  }
  cout << max(
      {dp[r & 1][c][3], dp[r & 1][c][2], dp[r & 1][c][1], dp[r & 1][c][0]});
  return 0;
}
Problem p02587 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\\n'
#define all(x) (x).begin(), (x).end()
const int INF = 1e9 + 5;
const ll oo = 1e18 + 5;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;

ll dp[55][35][2];
string s[55][2];
ll cost[55];
int n;

bool isGud(const string &s, int l, int r) {
  for (int i = l, j = r - 1; i < j; ++i, --j) {
    if (s[i] != s[j])
      return 0;
  }
  return 1;
}

ll solve(int id, int suff, int dir) {
  int len = (int)s[id][dir].size();
  if (isGud(s[id][dir], len - suff, len))
    return 0;
  ll &res = dp[id][suff][dir];
  if (res >= 0)
    return res;
  res = oo;
  int rev = dir ^ 1;
  for (int i = 0; i < n; ++i) {
    int sizee = (int)s[i][rev].size();
    if (sizee <= suff) {
      if (s[i][rev] == s[id][dir].substr(len - suff, sizee)) {
        res = min(res, cost[i] + solve(id, suff - sizee, dir));
      }
    } else {
      if (s[id][dir].substr(len - suff) == s[i][rev].substr(0, suff)) {
        res = min(res, cost[i] + solve(i, sizee - suff, rev));
      }
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i][0] >> cost[i];
    s[i][1] = s[i][0];
    reverse(all(s[i][1]));
  }
  ll ans = oo;
  memset(dp, 255, sizeof(dp));
  for (int i = 0; i < n; ++i) {
    ll cur = cost[i] + solve(i, (int)s[i][0].size(), 0);
    ans = min(ans, cur);
  }
  if (ans >= oo)
    ans = -1;
  cout << ans;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\\n'
#define all(x) (x).begin(), (x).end()
const int INF = 1e9 + 5;
const ll oo = 1e18 + 5;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;

ll dp[55][35][2];
string s[55][2];
ll cost[55];
int n;

bool isGud(const string &s, int l, int r) {
  for (int i = l, j = r - 1; i < j; ++i, --j) {
    if (s[i] != s[j])
      return 0;
  }
  return 1;
}

ll solve(int id, int suff, int dir) {
  int len = (int)s[id][dir].size();
  if (isGud(s[id][dir], len - suff, len))
    return 0;
  ll res = dp[id][suff][dir];
  if (res >= 0)
    return res;
  res = INF;
  int rev = dir ^ 1;
  for (int i = 0; i < n; ++i) {
    int sizee = (int)s[i][rev].size();
    if (sizee <= suff) {
      if (s[i][rev] == s[id][dir].substr(len - suff, sizee)) {
        res = min(res, cost[i] + solve(id, suff - sizee, dir));
      }
    } else {
      if (s[id][dir].substr(len - suff) == s[i][rev].substr(0, suff)) {
        res = min(res, cost[i] + solve(i, sizee - suff, rev));
      }
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i][0] >> cost[i];
    s[i][1] = s[i][0];
    reverse(all(s[i][1]));
  }
  ll ans = oo;
  memset(dp, 255, sizeof(dp));
  for (int i = 0; i < n; ++i) {
    ll cur = cost[i] + solve(i, (int)s[i][0].size(), 0);
    ans = min(ans, cur);
  }
  if (ans >= INF)
    ans = -1;
  cout << ans;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

// Zende bad Shoma nasime faghat !
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll cnt[50][50];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  str v;
  ll x, ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> v;
    x = 0;
    int rq = 9;
    int flg = 0;
    for (auto c : v) {
      if (flg == 1)
        rq--;
      if (c == '.') {
        flg = 1;
        continue;
      }
      x = 10 * x + (c - '0');
    }
    for (int j = 0; j < rq; j++)
      x *= 10;

    ll c5 = 0, c2 = 0;

    // cerr << "! " << x << '\\n';
    if (x == 0) {
      c2 = 18;
      c5 = 18;
      x = 1;
    }
    while (x % 5 == 0)
      x /= 5, c5++;
    while (x % 2 == 0)
      x /= 2, c2++;
    c2 = min(c2, 18ll);
    c2 = min(c2, 18ll);
    // cerr << c2 << ' ' << c5 << '\\n';
    for (int i1 = max(0ll, 18 - c2); i1 <= 18; i1++)
      for (int i2 = max(0ll, 18 - c5); i2 <= 18; i2++)
        ans += cnt[i1][i2];

    cnt[c2][c5]++;
  }
  cout << ans << '\\n';
  return 0;
}


Error: 0

Fixed submission:

// Zende bad Shoma nasime faghat !
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll cnt[20][20];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  str v;
  ll x, ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> v;
    x = 0;
    int rq = 9;
    int flg = 0;
    for (auto c : v) {
      if (flg == 1)
        rq--;
      if (c == '.') {
        flg = 1;
        continue;
      }
      x = 10 * x + (c - '0');
    }
    for (int j = 0; j < rq; j++)
      x *= 10;

    ll c5 = 0, c2 = 0;

    // cerr << "! " << x << '\\n';
    if (x == 0) {
      c2 = 18;
      c5 = 18;
      x = 1;
    }
    while (x % 5 == 0)
      x /= 5, c5++;
    while (x % 2 == 0)
      x /= 2, c2++;
    // cerr << c2 << ' ' << c5 << '\\n';
    for (int i1 = max(0ll, 18 - c2); i1 <= 18; i1++)
      for (int i2 = max(0ll, 18 - c5); i2 <= 18; i2++)
        ans += cnt[i1][i2];

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

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int y = 0;
    bool good = false;
    int now = 0;
    for (char c : s) {
      if (c == '.') {
        good = true;
        continue;
      }
      y = y * 10;
      if (good)
        now++;
      y = y + c - '0';
    }
    while (now < 9) {
      y *= 10;
      now++;
    }
    while (y % 2 == 0) {
      a[i].first++;
      y /= 2;
    }
    while (y % 5 == 0) {
      a[i].second++;
      y /= 5;
    }
    a[i].first = min(18LL, a[i].first);
    a[i].second = min(18LL, a[i].second);
  }

  vector<vector<int>> q(MB, vector<int>(MB));
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 18 - a[i].first; j < MB; j++) {
      for (int c = 18 - a[i].second; c < MB; c++) {
        ans += q[j][c];
      }
    }
    q[a[i].first][a[i].second]++;
  }
  cout << ans;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed;
  cout.precision(12);
  srand(time(0));
  int t = 1;
  // int t;
  // cin >> t;
  while (t--)
    solve();
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  vector<bool> zero;
  for (int i = 0; i < n; i++) {
    double x;
    cin >> x;
    if (x == 0)
      zero[i] = true;
    int y = x * 1e9;
    while (y % 2 == 0) {
      a[i].first++;
      y /= 2;
    }
    while (y % 5 == 0) {
      a[i].second++;
      y /= 5;
    }
    a[i].first = min(18LL, a[i].first);
    a[i].second = min(18LL, a[i].second);
  }

  vector<vector<int>> q(MB, vector<int>(MB));
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (zero[i]) {
      ans += n - 1;
      continue;
    }
    for (int j = 18 - a[i].first; j < MB; j++) {
      for (int c = 18 - a[i].second; c < MB; c++) {
        ans += q[j][c];
      }
    }
    q[a[i].first][a[i].second]++;
  }
  cout << ans;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed;
  cout.precision(12);
  srand(time(0));
  int t = 1;
  // int t;
  // cin >> t;
  while (t--)
    solve();
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\\n"
#define moca(a, s, b) a = ((a)s(b) + MOD) % MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
static const ll INF = 1e18;
static const ll MAX = 101010;
static const ll MOD = 1e9 + 7;

// for(i=0; i<N; i++) cin >> a[i];

int main(void) {
  ll i, j, k, l;

  ll N;
  cin >> N;
  ll a[MAX * 2];
  ll cnt[66][66] = {};
  pll f[MAX * 2] = {};

  map<double, ll> mp;
  for (i = 0; i < N; i++) {
    double tt;
    cin >> tt;
    a[i] = llround(tt * 1e9);

    ll t = a[i];
    ll c2 = 0, c5 = 0;
    while (t % 2 == 0) {
      c2++;
      t /= 2;
    }
    while (t % 5 == 0) {
      c5++;
      t /= 5;
    }
    cnt[c2][c5]++;
    f[i] = {c2, c5};
  }

  ll ans = 0;
  for (i = 0; i < N; i++) {
    ll n2 = max(18 - f[i].ft, 0LL);
    ll n5 = max(18 - f[i].sc, 0LL);

    for (j = n2; j < 66; j++) {
      for (k = n5; k < 66; k++) {
        ans += cnt[j][k];
      }
    }

    if (n2 <= f[i].ft && n5 <= f[i].sc)
      ans--;
  }
  ans /= 2;
  pt(ans);
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\\n"
#define moca(a, s, b) a = ((a)s(b) + MOD) % MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
static const ll INF = 1e18;
static const ll MAX = 101010;
static const ll MOD = 1e9 + 7;

// for(i=0; i<N; i++) cin >> a[i];

int main(void) {
  ll i, j, k, l;

  ll N;
  cin >> N;
  ll a[MAX * 2];
  ll cnt[66][66] = {};

  map<double, ll> mp;
  for (i = 0; i < N; i++) {
    double tt;
    cin >> tt;
    a[i] = tt * 1e9;

    ll t = a[i];
    ll c2 = 0, c5 = 0;
    while (t % 2 == 0) {
      c2++;
      t /= 2;
    }
    while (t % 5 == 0) {
      c5++;
      t /= 5;
    }
    cnt[c2][c5]++;
    pt(c2 << " " << c5);
  }

  ll ans = 0;
  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      for (k = 0; k < 100; k++) {
        for (l = 0; l < 100; l++) {
          if (i == k && j == l)
            continue;

          if (i + k >= 18 && j + l >= 18) {
            ans += cnt[i][j] * cnt[k][l];
          }
        }
      }
    }
  }
  ans /= 2;

  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      if (i * 2 >= 18 && j * 2 >= 18) {
        ans += cnt[i][j] * (cnt[i][j] - 1) / 2;
      }
    }
  }
  pt(ans);
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

ll n, a[maxn], b[maxn], c[maxn];

inline ll read() {
  ll x = 0, w = 1, x2 = 0, base = 1e9;
  char c = getchar();
  while (c < '0' || c > '9')
    c = getchar();
  while (c <= '9' && c >= '0') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  if (c == '.') {
    while (c < '0' || c > '9')
      c = getchar();
    while (c <= '9' && c >= '0') {
      x2 = (x2 << 1) + (x2 << 3) + c - '0';
      base /= 10;
      c = getchar();
    }
    return x * 1e9 + x2 * base;
  } else
    return x * 1e9;
}

ll dp[55][55];

int main() {
  ll n, ans = 0;
  cin >> n;
  rep(i, 1, n) a[i] = read();
  rep(i, 1, n) {
    int c1 = 0, c2 = 0;
    while (a[i] % 2 == 0)
      a[i] /= 2, c1++;
    c1 = min(18, c1);
    while (a[i] % 5 == 0)
      a[i] /= 5, c2++;
    c2 = min(18, c2);
    rep(j, 18 - c1, 50) rep(k, 18 - c2, 50) ans += dp[j][k];
    dp[c1][c2]++;
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

ll n, a[maxn], b[maxn], c[maxn];

inline ll read() {
  ll x = 0, w = 1, x2 = 0, base = 1e9;
  char c = getchar();
  while (c < '0' || c > '9')
    c = getchar();
  while (c <= '9' && c >= '0') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  if (c == '.') {
    while (c < '0' || c > '9')
      c = getchar();
    while (c <= '9' && c >= '0') {
      x2 = (x2 << 1) + (x2 << 3) + c - '0';
      base /= 10;
      c = getchar();
    }
    return x * 1e9 + x2 * base;
  } else
    return x * 1e9;
}

struct node {
  int a, b;
};

inline bool operator<(node a, node b) {
  if (a.a != b.a)
    return a.a < b.a;
  return a.b < b.b;
}

ll dp[55][55];

int main() {
  ll n, ans = 0;
  cin >> n;
  rep(i, 1, n) a[i] = read();
  rep(i, 1, n) {
    int c1 = 0, c2 = 0;
    while (a[i] % 2 == 0)
      a[i] /= 2, c1++;
    while (a[i] % 5 == 0)
      a[i] /= 5, c2++;
    rep(j, 18 - c1, 50) rep(k, 18 - c2, 50) ans += dp[j][k];
    dp[c1][c2]++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define cs const
using namespace std;
typedef long long ll;
cs int N = 2e5 + 50, M = 70;
int n, c[2][M][M];
int main() {
#ifdef FSYolanda
  freopen("1.in", "r", stdin);
#endif
  scanf("%d", &n);
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    long double y;
    scanf("%Lf", &y);
    int a = 0, b = 0, typ = -1;
    for (int j = 0; j <= 10; j++)
      y *= 10, --a;
    ll x = y + 0.01;
    while (x && (x % 10 == 0))
      ++a, x /= 10;
    if (x & 1)
      typ = 1;
    else
      typ = 0;
    while (x && (x % 2 == 0))
      x >>= 1, ++b;
    while (x && (x % 5 == 0))
      x /= 5, ++b;
    for (int j = -10; j <= 10; j++)
      for (int k = 0; k <= 60; k++)
        if (j + a + min(k, b) >= 0)
          ans += c[typ ^ 1][j + 10][k];
    for (int j = -10; j <= 10; j++)
      for (int k = 0; k <= 60; k++)
        if (j + a >= 0)
          ans += c[typ][j + 10][k];
    ++c[typ][a + 10][b];
    //		cout << ans << " " << a << " " << b << " " << typ << endl;
  }
  cout << ans;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define cs const
using namespace std;
typedef long long ll;
cs int N = 2e5 + 50, M = 70;
int n, c[2][M][M];
int main() {
#ifdef FSYolanda
  freopen("1.in", "r", stdin);
#endif
  scanf("%d", &n);
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    double y;
    scanf("%lf", &y);
    int a = 0, b = 0, typ = -1;
    for (int j = 0; j <= 12; j++)
      y *= 10, --a;
    ll x = y;
    while (x && (x % 10 == 0))
      ++a, x /= 10;
    if (x & 1)
      typ = 1;
    else
      typ = 0;
    while (x && (x & 1 ^ 1))
      x >>= 1, ++b;
    while (x && (x % 5 == 0))
      x /= 5, ++b;
    for (int j = -12; j <= 12; j++)
      for (int k = 0; k <= 60; k++)
        if (j + a + min(k, b) >= 0)
          ans += (ll)c[typ ^ 1][j + 12][k];
    for (int j = -12; j <= 12; j++)
      for (int k = 0; k <= 60; k++)
        if (j + a >= 0)
          ans += c[typ][j + 12][k];
    ++c[typ][a + 12][b];
    //		cout << ans << " " << a << " " << b << " " << typ << endl;
  }
  cout << ans;
  return 0;
}
Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <utility>
#include <vector>
#define MAXN 200005
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
inline pi read() {
  ll x = 0;
  pi ans;
  int f = 0;
  char c = getchar();
  while (!isdigit(c) && c != '.')
    c = getchar();
  while (isdigit(c) || c == '.') {
    if (c == '.') {
      f = 1;
      c = getchar();
      continue;
    }
    if (f)
      --ans.first, --ans.second;
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  }
  while (x % 2 == 0)
    x /= 2, ++ans.first;
  while (x % 5 == 0)
    x /= 5, ++ans.second;
  return ans;
}
pi a[MAXN];
int s[205][205];
const int N = 100;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    a[i] = read();
  for (int i = 1; i <= n; i++)
    ++s[a[i].first + N][a[i].second + N];
  for (int i = 0; i <= 2 * N; i++)
    for (int j = 0; j <= 2 * N; j++) {
      if (i == 0 && j == 0)
        continue;
      if (i == 0)
        s[i][j] += s[i][j - 1];
      else if (j == 0)
        s[i][j] += s[i - 1][j];
      else
        s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = N - a[i].first, y = N - a[i].second;
    ans +=
        s[2 * N][2 * N] - s[2 * N][y - 1] - s[x - 1][2 * N] + s[x - 1][y - 1];
  }
  for (int i = 1; i <= n; i++)
    if (a[i].first >= 0 && a[i].second >= 0)
      --ans;
  ans >>= 1;
  cout << ans;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <utility>
#include <vector>
#define MAXN 200005
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
inline pi read() {
  ll x = 0;
  pi ans;
  int f = 0;
  char c = getchar();
  while (!isdigit(c) && c != '.')
    c = getchar();
  while (isdigit(c) || c == '.') {
    if (c == '.') {
      f = 1;
      c = getchar();
      continue;
    }
    if (f)
      --ans.first, --ans.second;
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  }
  while (x % 2 == 0)
    x /= 2, ++ans.first;
  while (x % 5 == 0)
    x /= 5, ++ans.second;
  return ans;
}
pi a[MAXN];
int s[205][205];
const int N = 10;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    a[i] = read();
  for (int i = 1; i <= n; i++)
    ++s[a[i].first + N][a[i].second + N];
  for (int i = 0; i <= 2 * N; i++)
    for (int j = 0; j <= 2 * N; j++) {
      if (i == 0 && j == 0)
        continue;
      if (i == 0)
        s[i][j] += s[i][j - 1];
      else if (j == 0)
        s[i][j] += s[i - 1][j];
      else
        s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = N - a[i].first, y = N - a[i].second;
    ans +=
        s[2 * N][2 * N] - s[2 * N][y - 1] - s[x - 1][2 * N] + s[x - 1][y - 1];
  }
  for (int i = 1; i <= n; i++)
    if (a[i].first >= 0 && a[i].second >= 0)
      --ans;
  ans >>= 1;
  cout << ans;
  return 0;
}