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

#include <iostream>

using namespace std;

int main() {
  int n;
  long long int a, b, d;
  cin >> n >> d;
  int cn{0};
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if ((a * a) + (b * b) <= d * d)
      cn++;
  }
  cout << cn << '\\n';
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n, d;
  cin >> n >> d;
  int a[100000], b[100000];
  int cn{0};
  for (int i = 0; i < n; i++)
    cin >> a[i] >> b[i];
  for (int i = 0; i < n; i++) {
    if (d * d >= a[i] * a[i] + b[i] * b[i])
      cn++;
  }
  cout << cn << '\\n';
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
typedef long long ll;
int main() {
  int n, ans = 0;
  ll d, x, y;
  scanf("%d%lld", &n, &d);
  d = d * d;
  while (n--) {
    scanf("%lld%lld", &x, &y);
    if (x * x + y * y <= d)
      ans++;
  }
  printf("%lld\\n", ans);
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
typedef long long ll;
int main() {
  int n, ans = 0;
  ll d, x, y;
  scanf("%d%lld", &n, &d);
  d = d * d;
  while (n--) {
    scanf("%lld%lld", &x, y);
    if (x * x + y * y <= d)
      ans++;
  }
  printf("%lld\\n", ans);
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  ll n, d;
  cin >> n >> d;
  ll x, y;
  int count = 0;
  rep(i, n) {
    cin >> x >> y;
    if (x * x + y * y <= d * d)
      count++;
  }
  cout << count << endl;
}

Error: 0

Fixed submission:

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

int main(void) {
  int n, d;
  int x[20] = {};
  int y[20] = {};
  cin >> n >> d;
  rep(i, n) cin >> x[i] >> y[i];
  long long dist;
  int count = 0;
  rep(i, n) {
    dist = (x[i] * x[i]) + (y[i] * y[i]);
    if (dist <= d * d)
      count++;
  }
  cout << count << endl;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x, y) make_pair((x), (y))
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)

void solve() {

  ll n, d;
  cin >> n >> d;
  ll cnt = 0;
  for (ll i = 1; i <= n; i++) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d)
      cnt++;
  }
  cout << cnt << '\\n';
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  boost;

  int t = 1;
  // cin >> t;

  for (int i = 1; i <= t; i++) {
    // cout << "Case #" << i << ": ";

    solve();
  }
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x, y) make_pair((x), (y))
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)

void solve() {

  int n;
  cin >> n;
  string res = string(n - (n + 4 - 1) / 4, '9') + string((n + 4 - 1) / 4, '8');
  cout << res << '\\n';
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  boost;

  int t = 1;
  cin >> t;

  for (int i = 1; i <= t; i++) {
    // cout << "Case #" << i << ": ";

    solve();
  }
  return 0;
}
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;

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

    if (sqrt(pow(x, 2) + pow(y, 2)) <= d)
      count++;
  }

  cout << count << endl;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)


Fixed submission:

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

int main() {
  int n, d;
  cin >> n >> d;
  vector<int> x;
  vector<int> y;
  int count = 0;

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

  for (int i = 0; i < n; i++) {
    if (sqrt(pow(x.at(i), 2) + pow(y.at(i), 2)) <= d)
      count++;
  }

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

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

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

  long x[n];
  long y[n];
  int i, j = 0;
  for (i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  d = pow(d, 2);
  for (i = 0; i < n; i++) {
    if ((pow(x[i], 2) + pow(y[i], 2)) <= d) {
      j++;
    }
  }
  cout << j;
  return 0;
}

Error: WA

Fixed submission:

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

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int shu = 0;
  long long N, D;
  cin >> N >> D;
  for (int i = 1; i <= N; i++) {
    long long x, y;
    cin >> x >> y;
    if (x * x + y * y <= D * D)
      shu++;
  }
  cout << shu;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int x[10010], y[10010];
int main() {
  int N, D, z, shu;
  cin >> N >> D;
  shu = N;
  z = D * D;
  for (int i = 1; i <= N; i++) {
    cin >> x[i] >> y[i];
    if (x[i] > D || y[i] > D || x[i] == D && y[i] != 0 ||
        y[i] == D && x[i] != 0) {
      shu--;
      i++;
    }
    x[i] = x[i] * x[i];
    y[i] = y[i] * y[i];
    if (x[i] + y[i] > D)
      shu--;
  }
  cout << shu;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

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

double get_dist(vector<int> v);

int main(void) {

  int N, D;
  vector<int> v;
  v.resize(2);
  vector<vector<int>> v_place;

  cin >> N >> D;
  for (int num = 0; num < N; num++) {
    cin >> v.at(0) >> v.at(1);
    v_place.push_back(v);
  }

  int ans = 0;

  for (int num = 0; num < N; num++) {
    if (get_dist(v_place.at(num)) <= (double)D) {
      ans++;
    }
  }

  cout << ans;

  return 0;
}

double get_dist(vector<int> v) {
  double dist = -100;
  dist = sqrt(pow(v.at(0), 2) + pow(v.at(1), 2));
  return dist;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)


Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
double get_dist(vector<int> v);

int main(void) {

  int N, D;
  vector<vector<int>> v_place;

  cin >> N >> D;
  for (int num = 0; num < N; num++) {
    cin >> v_place.at(num).at(0) >> v_place.at(num).at(1);
  }

  int ans = 0;

  for (int num = 0; num < N; num++) {
    if (get_dist(v_place.at(num)) <= (double)D) {
      ans++;
    }
  }

  cout << ans;

  return 0;
}

double get_dist(vector<int> v) {
  double dist = -100;
  dist = sqrt(pow(v.at(0), 2) + pow(v.at(1), 2));
  return dist;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int64_t D;
  cin >> N >> D;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int64_t X, Y;
    cin >> X >> Y;
    if (X * X + Y * Y <= D * D) {
      ans++;
    }
  }
  cout << ans << endl;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, D;
  cin >> N >> D;
  vector<int64_t> X(N);
  vector<int64_t> Y(N);
  for (int i = 1; i <= N; i++) {
    cin >> X.at(i);
  }
  for (int i = 1; i <= N; i++) {
    cin >> Y.at(i);
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (D * D >= X.at(i) * X.at(i) + Y.at(i) * Y.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <cstdint>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define repi(i, n) for (int i = 0; i < (n); i++)

int main() {
  int64_t n, d, count = 0;
  cin >> n >> d;
  vector<int64_t> x(n, 0);
  vector<int64_t> y(n, 0);
  repi(i, n) { cin >> x.at(i) >> y.at(i); }
  repi(i, n) {
    if (sqrtf64(x.at(i) * x.at(i) + y.at(i) * y.at(i)) <= d)
      count++;
  }
  cout << count << endl;
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::length_error'
  what():  cannot create std::vector larger than max_size()


Fixed submission:

#include <cstdint>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define repi(i, n) for (int i = 0; i < (n); i++)

int main() {
  int64_t n, d, count = 0;
  vector<int64_t> x(n, 0);
  vector<int64_t> y(n, 0);
  cin >> n >> d;
  repi(i, n) { cin >> x.at(i) >> y.at(i); }
  repi(i, n) {
    if (sqrtf64(x.at(i) * x.at(i) + y.at(i) * y.at(i)) <= d)
      count++;
  }
  cout << count << endl;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  lint n, d;
  cin >> n >> d;
  lint x[200000], y[200000];
  rep(i, n) cin >> x[i] >> y[i];
  lint ans = 0;
  rep(i, n) {
    lint t = x[i] * x[i] + y[i] * y[i];
    if (t <= d * d)
      ans++;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

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

int main() {
  lint n, d;
  cin >> n >> d;
  lint x[2000], y[2000];
  rep(i, n) cin >> x[i] >> y[i];
  lint ans = 0;
  rep(i, n) {
    lint t = x[i] * x[i] + y[i] * y[i];
    if (t <= d * d)
      ans++;
  }
  cout << ans << endl;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main() {

  ll N, D, i = 0;
  ll x, y, d, count = 0;

  cin >> N >> D;

  for (i = 0; i < N; i++) {
    cin >> x >> y;
    d = (x * x + y * y);

    if (D * D >= d) {
      count++;
    }
  }

  cout << count << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main() {

  ll N, D, i = 0;
  ll x[20000], y[20000], d, count = 0;

  cin >> N >> D;

  for (i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    d = (x[i] * x[i] + y[i] * y[i]);

    if (D * D >= d) {
      count++;
    }
  }

  cout << count << endl;

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

#pragma warning(disable : 4996)
// #define _CRT_NONSTDC_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(), (x).end() /*sorting STL */
#define fastio                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(nullptr);                                                            \\
  cout.tie(nullptr)

#define TRIPmin(a, b, c) min(a, min(b, c))
#define TRIPmax(a, b, c) max(a, max(b, c))
#define fillchar(a, x) memset(a, x, sizeof(a))

// #define mod		(1000000000+7)

/***********************************************************************/

int main() {
  ll n, ans = 0;
  ld d;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {
    ld x, y;
    cin >> x >> y;
    ld tmp = sqrt(x * x + y * y);
    if (tmp <= d)
      ans++;
  }
  cout << ans;
  return 0;
}

Error: WA

Fixed submission:

#pragma warning(disable : 4996)
// #define _CRT_NONSTDC_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(), (x).end() /*sorting STL */
#define fastio                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(nullptr);                                                            \\
  cout.tie(nullptr)

#define TRIPmin(a, b, c) min(a, min(b, c))
#define TRIPmax(a, b, c) max(a, max(b, c))
#define fillchar(a, x) memset(a, x, sizeof(a))

// #define mod		(1000000000+7)

/***********************************************************************/

const int maxn = 1e5;
pair<float, float> P[maxn];

int main() {
  int n, ans = 0;
  float d;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {

    cin >> P[i].first >> P[i].second;
  }
  for (int i = 1; i <= n; i++) {
    float tmp = sqrt(P[i].first * P[i].first + P[i].second * P[i].second);
    if (tmp <= d)
      ans++;
  }
  cout << ans;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
// #define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X)                                                                 \\
  {}
#define ARDEB(i, X)                                                            \\
  {}
#define END                                                                    \\
  {}
#endif
// typedef long long int ll;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
int ceil2(int a, int b) {
  if (a % b) {
    return a / b + 1;
  } else {
    return a / b;
  }
}
int n, k, ans;
int a[211111], b[211111];
signed main() {

  cin >> n >> k;
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, n) {
    if (a[i] * a[i] + b[i] * b[i] <= k * k)
      ans++;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
// #define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X)                                                                 \\
  {}
#define ARDEB(i, X)                                                            \\
  {}
#define END                                                                    \\
  {}
#endif
// typedef long long int ll;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
int ceil2(int a, int b) {
  if (a % b) {
    return a / b + 1;
  } else {
    return a / b;
  }
}
int n, k, ans;
int a[111111], b[111111];
signed main() {

  cin >> n >> k;
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, n) {
    if (a[i] * a[i] + b[i] * b[i] <= k * k)
      ans++;
  }
  cout << ans << endl;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int a[200010][3], n, d, ans = 0;
int main() {
  cin >> n >> d;
  for (int i = 1; i <= n; i++)
    cin >> a[i][1] >> a[i][2];
  for (int i = 1; i <= n; i++) {
    double x, y, z;
    x = a[i][1];
    y = a[i][2];
    z = sqrt(x * x + y * y);
    if (z <= d)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int a[250][3], n, d, ans = 0;
int main() {
  cin >> n >> d;
  for (int i = 1; i <= n; i++)
    cin >> a[i][1] >> a[i][2];
  for (int i = 1; i <= n; i++) {
    double x, y, z;
    x = a[i][1];
    y = a[i][2];
    z = sqrt(x * x + y * y);
    if (z <= d)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <iterator> // std::back_inserter
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;

typedef long ll;

int main() {
  ll n, d;
  cin >> n >> d;
  ll x[200001];
  ll y[200001];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x[i] * x[i] + y[i] * y[i] <= d * d) {
      ans++;
    }
  }
  cout << ans << endl;
}


Error: WA

Fixed submission:

// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <iterator> // std::back_inserter
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;

typedef long ll;
vector<ll> p;
vector<ll> c;

vector<vector<ll>> find_sequences(vector<ll> &v) {
  vector<ll> marker = vector<ll>(v.size());
  vector<vector<ll>> result;
  for (ll i = 1; i <= v.size(); i++) {
    vector<ll> sub;
    ll pos = i;
    while (marker[pos - 1] == 0) {
      sub.push_back(c[v[pos - 1] - 1]);
      marker[pos - 1] = 1;
      pos = v[pos - 1];
    }
    if (sub.size() > 0) {
      result.push_back(sub);
    }
  }
  return result;
}

tuple<ll, ll> sumK_one(vector<ll> &vec, ll start, ll small_k) {
  ll veclen = vec.size();
  ll score = 0;
  ll max_score = LLONG_MIN;
  for (ll i = 0; i < small_k; i++) {
    auto a = vec[(start - 1) % veclen];
    score += a;
    max_score = max(max_score, score);
    start++;
  }
  return make_tuple(max_score, score);
}

ll sumK(vector<ll> &vec, ll start, ll k) {
  start++;
  ll veclen = vec.size();
  ll div = k / veclen;
  k = k % veclen;
  if (div != 0) {
    tuple<ll, ll> sums_one = sumK_one(vec, start, veclen);

    ll last_score_one = get<1>(sums_one) * div;
    ll max_score_one =
        last_score_one + (max(get<0>(sums_one) - get<1>(sums_one), 0l));

    tuple<ll, ll> sums = sumK_one(vec, start, k);

    ll last_score = last_score_one * div + get<1>(sums);
    ll max_score = max_score_one;
    if (k != 0) {
      max_score = max(max_score_one, last_score_one + get<0>(sums));
    }
    return max_score;
  }

  tuple<ll, ll> sums = sumK_one(vec, start, k);
  ll result = get<0>(sums);
  return result;
}

ll find_max_score(vector<ll> &vec, ll k) {
  ll result = LLONG_MIN;
  for (ll i = 1; i <= vec.size(); i++) {
    auto sumKresult = sumK(vec, i, k);
    result = max(result, sumKresult);
  }
  return result;
}

int main() {
  ll n, k;
  cin >> n >> k;
  for (ll i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  for (ll i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    c.push_back(tmp);
  }
  vector<vector<ll>> sequences = find_sequences(p);

  ll max_score = LLONG_MIN;
  for (auto it : sequences) {
    ll score = find_max_score(it, k);
    max_score = max(max_score, score);
  }
  cout << max_score << endl;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long int D, N, ans = 0;
  long long int X[1000001], Y[1000001];
  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)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long int D, N, ans = 0;
  long long int X[100001], Y[100001];
  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)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02595 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  double n, d, d2;
  int counter;
  cin >> n >> d;
  counter = 0;
  double x[200000], y[200000];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  d2 = d * d;

  for (int i = 0; i < n; i++) {
    if (d2 >= (x[i] * x[i] + y[i] * y[i])) {
      counter++;
    }
  }

  cout << counter << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int count;
  count = 0;

  int n, d;
  long d2;
  cin >> n >> d;

  d2 = d * d;

  long x[n];
  long y[n];
  long k[n];

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

  for (int i = 0; n; i++) {
    k[i] = x[i] * x[i] + y[i] * y[i];
    if (k[i] < d2) {
      count = count + 1;
    }
  }

  cout << count << endl;
}