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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

P p[200010];
int main() {
  ll n, d;
  ll dis = 0;
  int res = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  for (int i = 0; i < n; i++) {
    ll x = p[i].first;
    ll y = p[i].second;
    dis = x * x + y * y;
    if (dis <= d * d)
      res++;
  }
  cout << res << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

P p[100010];
int main() {
  ll n, d;
  ll dis = 0;
  int res = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  for (int i = 0; i < n; i++) {
    ll x = p[i].first;
    ll y = p[i].second;
    dis = x * x + y * y;
    if (dis <= d * d)
      res++;
  }
  cout << res << endl;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Time Limit Exceeded

// Wed Jul 29 19:48:22 IST 2020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define forn(ii, a, b) for (int ii = (int)a; ii < (int)b; ii++)
#define debug(x) cerr << #x << " " << x << " -- \\n"
#define I__O ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define int64 long long
#define all(x) (x).begin(), (x).end()
#define precise(x) cout << fixed << setprecision(12) << x << '\\n';
using namespace std;
// policy based
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;

const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;
const int N = 2e5 + 7;
const int INF = INT_MAX;

int tests() {
  int64 n, ans = 0;
  int64 d, x, y;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    ans += (x * x + y * y <= d * d);
  }
  cout << ans << '\\n';
  return 0;
}

int32_t main() {
  I__O;
  int cases = 1;
  // cin >> cases ;
  for (int test = 1; test <= cases; test++) {
    // cout << "Case #" << test << ":" << '\\n';
    tests();
  }
  return 0;
}


Error: TLE

Fixed submission:

// Wed Jul 29 19:48:22 IST 2020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define forn(ii, a, b) for (int ii = (int)a; ii < (int)b; ii++)
#define debug(x) cerr << #x << " " << x << " -- \\n"
#define I__O ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define int64 long long
#define all(x) (x).begin(), (x).end()
#define precise(x) cout << fixed << setprecision(12) << x << '\\n';
using namespace std;
// policy based
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;

const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;
const int N = 2e5 + 7;
const int INF = INT_MAX;

int tests() {
  int n, ans = 0;
  int64 d, x, y;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    ans += (x * x + y * y <= d * d);
  }
  cout << ans << '\\n';
}

int32_t main() {
  I__O;
  int cases = 1;
  // cin >> cases ;
  for (int test = 1; test <= cases; ++test) {
    // cout << "Case #" << test << ":" << '\\n';
    tests();
  }
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
#define long long int
using namespace std;
int main() {
  int n;
  int d;
  cin >> n >> d;
  int ct = 0;
  while (n--) {
    int a, b;
    cin >> a >> b;
    if (sqrt(pow(double(a), 2) + pow(double(b), 2)) <= d)
      ct++;
  }
  cout << ct;
}


Error: -8

Fixed submission:

#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  vector<int> a, b;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a.push_back(x);
    b.push_back(y);
  }
  int ct = 0;
  for (int i = 0; i < n; i++) {
    int r = (d - b[i]) * (d + b[i]);
    r = r / a[i];
    if (a[i] <= r)
      ct++;
  }
  cout << ct;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define input freopen("1.txt", "r", stdin);
#define output freopen("output.txt", "w", stdout);
#define ll long long int
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define vpi vector<pii>
#define vpl vector<pll>
using namespace std;

const int p = 1e9 + 7;
const int maxn = 1e5 + 2;

void solve() {
  int N;
  double D;
  cin >> N >> D;
  double dist[N];
  ll x, y;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    dist[i] = sqrt(x * x + y * y);
  }
  sort(dist, dist + N);
  int ind = upper_bound(dist, dist + N, D) - dist;
  if (ind == N)
    cout << N << "\\n";
  else {
    cout << ind << "\\n";
  }
}

int main() {
  fast
      // input output
      int t = 1;
  // cin>>t;
  while (t--)
    solve();
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define input freopen("1.txt", "r", stdin);
#define output freopen("output.txt", "w", stdout);
#define ll long long int
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define vpi vector<pii>
#define vpl vector<pll>
using namespace std;

const int p = 1e9 + 7;
const int maxn = 1e5 + 2;

void solve() {
  int N;
  double D;
  cin >> N >> D;
  double dist[N], x, y;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    dist[i] = sqrt(x * x + y * y);
  }
  sort(dist, dist + N);
  int ind = upper_bound(dist, dist + N, D) - dist;
  if (ind == N)
    cout << N << "\\n";
  else {
    cout << ind << "\\n";
  }
}

int main() {
  fast
      // input output
      int t;
  cin >> t;
  while (t--)
    solve();
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
#include <vector>
#define re(i, n) for (int i = 0; i < n; i++)

int main() {
  int n;
  cin >> n;
  long long x[300000];
  long long y[300000];
  long long d;
  cin >> d;
  d *= d;
  int cnt = 0;
  long long z;
  re(i, n) {
    cin >> x[i] >> y[i];
    z = x[i] * x[i] + y[i] * y[i];
    if (z <= d)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
#include <vector>
#define re(i, n) for (int i = 0; i < n; i++)

int main() {
  int n;
  cin >> n;
  long long x[10000];
  long long y[10000];
  long long d;
  cin >> d;
  d *= d;
  int cnt = 0;
  long long z;
  re(i, n) {
    cin >> x[i] >> y[i];
    z = x[i] * x[i] + y[i] * y[i];
    if (z <= d)
      cnt++;
  }

  cout << cnt << endl;

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

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

#define int double

int32_t main() {
  int nn, dd;
  cin >> nn >> dd;
  int rii = 0, x, y;
  for (int i = 0; i < nn; i++) {
    cin >> x >> y;
    int sum = sqrt(x * x + y * y);
    if (sum <= dd) {
      rii++;
    }
  }
  cout << rii;

  return 0;
}

Error: TLE

Fixed submission:

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

#define int double

int32_t main() {
  int nn, dd;
  cin >> nn >> dd;
  int count = 0, x, tt;
  for (int i = 0; i < nn; dd++) {

    cin >> x >> tt;
    int sum = sqrt(x * x + tt * tt);
    if (sum <= dd) {
      count++;
    }
  }
  cout << count;

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

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  long long x, y, n, d, ans;
  cin >> n >> d;
  ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (d * d >= x * x + y * y) {
      ans++;
    }
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <math.h>
#define A 1000
using namespace std;
int main() {
  int n, d, h, i;
  static int x[A];
  static int y[A];
  int k;
  int count = 0;
  cin >> n >> d;

  for (h = 0; h < n; h++) {
    cin >> x[h] >> y[h];
  }

  for (i = 0; i < n; i++) {
    k = x[i] * x[i] + y[i] * y[i];
    if (k <= d * d) {
      count++;
    }
  }
  cout << count << endl;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define loop(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = 0x3f3f3f40;
const long long mod = 2e9 + 7;
const long double PI = acos(0);
// }}} End Header
int main() {
  ll n, d, ans = 0;
  cin >> n >> d;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 1; i < n; i++)
#define loop(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = 0x3f3f3f40;
const long long mod = 2e9 + 7;
const long double PI = acos(0);
// }}} End Header
int main() {
  ll n, d, ans = 1;
  cin >> n >> d;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d)
      ans++;
  }
  cout << ans << endl;
  return 1;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  long long int n, d, count = 0;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {
    long long int x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d)
      count++;
  }
  cout << count << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;

int main() {
  int n, d, count = 0;
  long long int a[20000], b[20000];
  cin >> n >> d;
  for (int i = 1; i <= n; i++)
    cin >> a[i] >> b[i];
  for (int i = 1; i <= n; i++) {
    long long int ans = a[i] * a[i] + b[i] * b[i];
    if (ans <= d * d)
      count++;
  }
  cout << count << endl;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  long long N, D, po, o = 0;
  double pu;
  long long x, y;
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    po = pow(x, 2) + pow(y, 2);
    pu = sqrt(po);
    if (pu <= D) {
      o++;
    }
  }
  cout << o << endl;
  return (0);
}

Error: 0

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  long long N, D, po, o = 0;
  double pu;
  long long x[100009], y[100009];
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    po = pow(x[i], 2) + pow(y[i], 2);
    pu = sqrt(po);
    if (pu <= D) {
      o++;
    }
  }
  cout << o << endl;
  return (0);
}
Problem p02595 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int main(int argc, char *argv[]) {
  int n;
  long long d;
  scanf("%d%lld", &n, &d);
  long long dis = d * d;
  long long x, y;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &x, &y);
    long long xy = x * x + y * y;
    if (xy <= dis) {
      ans++;
    }
  }
  printf("%d", ans);
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;
int main() {
  long long n;
  double d;
  scanf("%d%lf", &n, &d);
  getchar();
  int sum = 0;
  d = d / 1000;
  while (n--) {
    double x, y;
    scanf("%lf%lf", &x, &y);

    x = x / 1000;

    y = y / 1000;
    double m = sqrt(x * x + y * y);
    if (m <= d) {
      sum++;
    }
  }
  printf("%d\\n", sum);
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <string>

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for (int i = 0; i < n; ++i)
long long H, W, K, N, D;
long long x[1000000], y[1000000];

int main() {
  int count = 0;
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }

  for (int i = 0; i < N; i++) {
    if ((x[i] * x[i]) + (y[i] * y[i]) <= D * D)
      count++;
  }
  cout << count;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <string>

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for (int i = 0; i < n; ++i)
long long H, W, K, N, D;
char A[200][200]{};
int B[200][200]{};
long long x[100000], y[100000];

int main() {
  int count = 0;
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  for (int i = 0; i < N; i++) {
    if ((x[i] * x[i]) + (y[i] * y[i]) <= D * D)
      count++;
  }
  cout << count;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
using namespace std;
int main(void) {
  int n, d;
  int counter = 0;
  long long A[200020], B[200020];
  long double C[200020];
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> A[i] >> B[i];
    C[i] = (double)((A[i] * A[i]) + (B[i] * B[i]));
    // cout << C[i] << " " << sqrt(C[i]) << endl;
  }
  for (int i = 0; i < n; i++) {
    if (sqrt(C[i]) <= d) {
      counter++;
    }
  }
  cout << counter << endl;
}


Error: 0

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;
int main(void) {
  int n, d;
  int counter = 0;
  long long A[100010], B[100010];
  long double C[100010];
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> A[i] >> B[i];
    C[i] = (double)((A[i] * A[i]) + (B[i] * B[i]));
    // cout << C[i] << " " << sqrt(C[i]) << endl;
  }
  for (int i = 0; i < n; i++) {
    if (sqrt(C[i]) <= d) {
      counter++;
    }
  }
  cout << counter << endl;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, D;
  cin >> N >> D;
  int count = 0;
  long double d = 0;
  for (int i = 0; i < N; i++) {
    long int x, y;
    cin >> x >> y;
    d = sqrt(x * x + y * y);
    if (d <= D) {
      count = count + 1;
    }
  }
  cout << count << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int n, d;
  int b = 0;
  double a, c;
  int x[200], y[200];
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  for (int f = 0; f < n; f++) {
    c = x[f] * x[f] + y[f] * y[f];
    a = sqrt(c);
    if (a <= d) {
      b++;
    }
  }
  cout << b;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int x[200001], y[200001];

int main() {
  int n, d;
  cin >> n >> d;

  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (sqrt(pow(x[i], 2) + pow(y[i], 2)) <= d) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int x[100001], y[100001];

int main() {
  int n, d;
  cin >> n >> d;

  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (sqrt(pow(x[i], 2) + pow(y[i], 2)) <= d) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>

using namespace std;

int main() {
  int n, d;
  cin >> n >> d;
  double a[200000][3];
  double b[200000][3], c[200000];
  int cnt = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> a[i][j];
      b[i][j] = pow(a[i][j], 2);
      c[i] += b[i][j];
    }
  }

  for (int i = 0; i < n; i++) {
    c[i] = sqrt(c[i]);
    if (d >= c[i])
      cnt++;
  }
  cout << cnt << endl;
}

Error: 0

Fixed submission:

#include <iostream>
#include <math.h>

using namespace std;

int main() {
  long int n, d;
  cin >> n >> d;
  long double a[10000][3];
  long double b[10000][3], c[10000];
  int cnt = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> a[i][j];
      b[i][j] = pow(a[i][j], 2);
      c[i] += b[i][j];
    }
  }

  for (int i = 0; i < n; i++) {
    c[i] = sqrt(c[i]);
    if (d >= c[i])
      cnt++;
  }
  cout << cnt << endl;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, ans = 0;
  long long d, x, y, sum;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (x * x + y * y <= d * d) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Error: WA

Fixed submission:

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

int main() {
  int n, d, Count = 0, x[20000], y[20000], sum[20000];
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  for (int i = 0; i < n; i++) {
    sum[i] = sqrt(pow(x[i], 2) + pow(y[i], 2));
    if (sum[i] >= d) {
      Count++;
    }
  }
  cout << Count;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;
void solve() {
  long long N, D, x, y, ans = 0;
  cin >> N >> D;
  D *= D;
  rep(i, 0, N) {
    cin >> x >> y;
    ans += (D >= x * x + y * y);
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
}

Error: -11

Fixed submission:

#pragma GCC optimize("O2")
#pragma GCC target("avx2")
// #include <iostream>
#include <cstdio>

#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;
void solve() {
  unsigned long long N, D, x, y, ans = 0;
  scanf("%d%d", N, D);
  //   cin >> N >> D;
  D *= D;
  rep(i, 0, N) {
    scanf("%d%d", x, y);
    // cin >> x >> y;
    ans += (D >= x * x + y * y);
  }
  printf("%d", ans);
  // cout << ans << endl;
}
int main() {
  //   ios::sync_with_stdio(false);
  //   cin.tie(0);
  solve();
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N;
  long long D;
  cin >> N >> D;
  long long a, b;
  //  for(int i=0;i<N;i++) cin >> a[i] >> b[i];
  int mycount = 0;
  for (int i = 0; i < N; i++) {
    //    for(int j=i;j<N;j++){
    cin >> a >> b;
    if (a * a + b * b <= D * D) {
      mycount++;
      //    cout << a[i]*a[i] + b[i]*b[i] << " " << D*D << endl;
    }
    //    }
  }
  cout << mycount << endl;

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int N;
  long long D;
  cin >> N >> D;
  long long a[100010], b[100010];
  for (int i = 0; i < N; i++)
    cin >> a[i] >> b[i];
  int mycount = 0;
  for (int i = 0; i < N; i++) {
    //    for(int j=i;j<N;j++){
    if (a[i] * a[i] + b[i] * b[i] <= D * D) {
      mycount++;
      //    cout << a[i]*a[i] + b[i]*b[i] << " " << D*D << endl;
    }
    //    }
  }
  cout << mycount << endl;

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define int long long
using namespace std;
int n, ans;
double d, x[200005], y[200005];
signed main() {
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {
    scanf("%lf %lf", &x[i], &y[i]);
    if (sqrt(x[i] * x[i] + y[i] * y[i]) <= d) {
      ans++;
    }
  }
  cout << ans;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define int long long
using namespace std;
int n, ans;
double d, x[100005], y[100005];
signed main() {
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {
    scanf("%lf %lf", &x[i], &y[i]);
    if (sqrt(x[i] * x[i] + y[i] * y[i]) <= d) {
      ans++;
    }
  }
  cout << ans;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {

  long long N, D;
  cin >> N >> D;

  double ans = 0;

  for (int i = 0; i < N; i++) {
    long long X, Y;
    cin >> X >> Y;
    if (X * X + Y * Y <= D * D) {
      ans++;
    }
  }

  cout << ans << endl;
}

Error: -11

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {

  int N, D;
  cin >> N >> D;

  vector<vector<float>> X;
  vector<float> d;
  int n = 0;

  for (int i = 0; i < N; i++) {
    cin >> X[i][0] >> X[i][1];
    d[i] = X[i][0] * X[i][0] + X[i][1] * X[i][1];
    if (d[i] <= D * D) {
      n++;
    }
  }
  cout << n << endl;
}
Problem p02595 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <iostream>
using namespace std;
using ll = long long;

int main() {
  int n, d;
  cin >> n >> d;
  int count = 0;
  while (n--) {
    ll x, y;
    cin >> x >> y;
    x = x * x;
    y = y * y;
    ll r = x + y;
    ll de = d;
    de = de * d;
    if (r <= de)
      count++;
  }
  cout << count << endl;

  return 0;
}


Error: MLE

Fixed submission:

#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono;
#define fo(i, z, n) for (int i = z; i < n; i++)
#define Fo(i, z, n) for (ll i = z; i < n; i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define pb push_back
#define f first
// #define s second
#define int long long
#define all(c) (c).begin(), (c).end()
#define endl '\\n'

const int m = 1e8;
std::vector<pair<int, int>> BIT(m);

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);

  //      int t;
  //      cin >> t;
  //      while(t--){

  // }

  int n, d;
  cin >> n >> d;
  int count = 0;
  while (n--) {
    int x, y;
    cin >> x >> y;
    int r = x * x + y * y;
    int di = d * d;
    if (r <= di)
      count++;
  }

  cout << count << endl;

  return 0;
}