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

#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vl vector<long long>
#define fin(ar, k, n)                                                          \\
  for (int i = k; i < n; i++)                                                  \\
  cin >> ar[i]
#define fout(ar, k, n)                                                         \\
  for (int i = k; i < n; i++)                                                  \\
  cout << ar[i] << ' '
#define vs vector<string>
#define mx INT_MAX
#define mn INT_MIN
#define all(z) z.begin(), z.end()
#define mcc 1000000007
#define mcf 998244353
#define mi map<int, int>
#define mem(a, n) memset(a, n, sizeof(a))
using namespace std;

// ll maxl(ll a,ll b) {return (a>b)? a:b;}
// ll minl(ll a,ll b) {return (a<b)? a:b;}
// ll gcdl(ll a,ll b) {return b ? gcdl(b,a%b):a;}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << ' ' << a << ' ' << b;
}

#if 1
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
  return 0;
}
#endif

//------------------------Google-------------------
#if 0
int main()
{
#ifdef __WIN32
    freopen("input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,ct=0;
    cin>>t;
    while(t--)
    {
        cout<<"Case #"<<++ct<<": ";
        solve();
    }
    return 0;
}
#endif


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vl vector<long long>
#define fin(ar, k, n)                                                          \\
  for (int i = k; i < n; i++)                                                  \\
  cin >> ar[i]
#define fout(ar, k, n)                                                         \\
  for (int i = k; i < n; i++)                                                  \\
  cout << ar[i] << ' '
#define vs vector<string>
#define mx INT_MAX
#define mn INT_MIN
#define all(z) z.begin(), z.end()
#define mcc 1000000007
#define mcf 998244353
#define mi map<int, int>
#define mem(a, n) memset(a, n, sizeof(a))
using namespace std;

// ll maxl(ll a,ll b) {return (a>b)? a:b;}
// ll minl(ll a,ll b) {return (a<b)? a:b;}
// ll gcdl(ll a,ll b) {return b ? gcdl(b,a%b):a;}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << ' ' << a << ' ' << b;
}

#if 1
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
  return 0;
}
#endif

//------------------------Google-------------------
#if 0
int main()
{
#ifdef __WIN32
    freopen("input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,ct=0;
    cin>>t;
    while(t--)
    {
        cout<<"Case #"<<++ct<<": ";
        solve();
    }
    return 0;
}
#endif
Problem p02717 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  swap(A, B);
  swap(A, C);

  cout << A;
  cout << " ";
  cout << B;
  cout << " ";
  cout << C;
}


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


Fixed submission:

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

int main() {
  vector<int> vec = {3};
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2);

  swap(vec.at(0), vec.at(1));
  swap(vec.at(0), vec.at(2));

  cout << vec.at(0);
  cout << vec.at(1);
  cout << vec.at(2);
}
Problem p02717 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  // Write from here.
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(n) (n).begin(), (n).end()
#define ll long long

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c << endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  // Write from here.

  solve();

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll oo = 1000000000000000000;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
#define x first
#define y second

ll a, b, c;

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

  // #ifndef ONLINE_JUDGE

  // freopen("c.inp"  , "r" , stdin);
  // freopen(".OUT" , "w" , stdout);

  // #endif

  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> a >> b >> c;

  cout << c << " " << a << " " << b;

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll oo = 1000000000000000000;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
#define x first
#define y second

ll a, b, c;

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

#ifndef ONLINE_JUDGE

  freopen("c.inp", "r", stdin);
  // freopen(".OUT" , "w" , stdout);

#endif

  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> a >> b >> c;

  cout << c << " " << a << " " << b;

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

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9 + 7;

void solve() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << "\\n";
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define F first
#define S second

// #define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9 + 7;

void solve() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << "\\n";
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}
Problem p02717 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
// cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int, int>
#define all(x) x.begin(), x.end()
#define mod 1000000007

int main() {
  ios_base::sync_with_stdio(false);
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << "\\n";
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
// cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int, int>
#define all(x) x.begin(), x.end()
#define mod 1000000007

int main() {
  ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << "\\n";
  return 0;
}
Problem p02717 (C++) — buggy submission, verdict: Runtime Error

// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define gcd(a, b) __gcd(a, b)
#define endl '\\n'
const int N = 2e5 + 10;
const int inf = 1e9;
const int mod = 1e9 + 7;

int main(int argc, char const *argv[]) {
  /*#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);*/

  int a, b, c;
  cin >> a >> b >> c;

  cout << c << " " << a << " " << b << endl;

  return 0;
}

Error: WA

Fixed submission:

// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define gcd(a, b) __gcd(a, b)
#define endl '\\n'
const int N = 2e5 + 10;
const int inf = 1e9;
const int mod = 1e9 + 7;

int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);

  int a, b, c;
  cin >> a >> b >> c;

  cout << c << " " << a << " " << b << endl;

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

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int32_t main() {

  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin) ;
  // freopen("output.txt", "w", stdout) ;
  // #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int32_t main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
}
Problem p02717 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for (ll i = 0; i < n; i++)
#define rep2(n) for (ll j = 0; j < n; ++j)
#define repd(n) for (ll i = n - 1; i >= 0; i--)
#define MOD 1000000007
#define pii pair<ll, ll>
#define vll vector<ll>
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define nl "\\n"
#define INF 0x3f3f3f3f
#define sz(a) a.size()
#define all(a) a.begin(), a.end()
#define M 998244353
#define limit 100000000

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b;
}

int main() {

  fast;
  ll t = 1;
  // cin>>t;
  rep(t) { solve(); }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for (ll i = 0; i < n; i++)
#define rep2(n) for (ll j = 0; j < n; ++j)
#define repd(n) for (ll i = n - 1; i >= 0; i--)
#define MOD 1000000007
#define pii pair<ll, ll>
#define vll vector<ll>
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define nl "\\n"
#define INF 0x3f3f3f3f
#define sz(a) a.size()
#define all(a) a.begin(), a.end()
#define M 998244353
#define limit 100000000

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b;
}

int main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fast;
  ll t = 1;
  // cin>>t;
  rep(t) { solve(); }
  return 0;
}
Problem p02718 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, M, sum;
  sum = 0;
  cin >> N >> M;
  vector<int> a(N);

  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  if (sum % (4 * M) == 0) {
    if (a.at(M - 1) >= sum / (4 * M)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    if (a.at(M - 1) > sum / (4 * M)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Error: 0

Fixed submission:

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

int main() {
  int N, M, sum;
  sum = 0;
  cin >> N >> M;
  vector<int> a(N);

  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  if (a.at(M) >= sum / (4 * M)) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
}
Problem p02718 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, M;
  cin >> N >> M;
  int list[N];
  for (int i = 0; i < N; i++) {
    cin >> list[i];
  }

  int all_vote = 0;
  for (int i = 0; i < N; i++) {
    all_vote += list[i];
  }

  bool check = true;
  double border = (double)all_vote / (4 * M);
  sort(list, list + N, greater<int>());
  for (int i = 0; i < M; i++) {
    if (list[i] < border)
      check = false;
  }
  if (check)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int N, M;
  int list[N];
  cin >> N >> M;
  int all_vote = 0;
  for (int i = 0; i < N; i++) {
    int tmp = 0;
    cin >> tmp;
    list[i] = tmp;
    all_vote += tmp;
  }

  string res = "Yes";
  int border = all_vote / (4 * M);
  sort(list, list + N, greater<int>());
  for (int i = 0; i < M; i++) {
    if (list[i] < border)
      res = "No";
  }
  cout << res << endl;
  return 0;
}
Problem p02718 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i, n) for (int i = 0; i < n; i++)
#define rev(i, n) for (ll i = n; i >= 0; i--)
#define rep_a(i, a, n) for (ll i = a; i < n; i++)
#define pb push_back
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
const long long mod = 1000000007;
const long long INF = mod * mod;
int ansi = 1;
int solve() {
  ll n, m;
  cin >> n >> m;
  ll arr[n];
  ll sum = 0;
  rep(i, n) {
    cin >> arr[i];
    sum += arr[i];
    //
  }
  // cout<<sum<<endl;
  ll count = 0;
  sum = ceil((sum) / (4.0 * m));
  // cout<<sum<<endl;
  rep(i, n) {
    // cout<<arr[i]<<endl;
    if (arr[i] >= sum)
      count++;
  }
  if (count >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
int main() {
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #else
  // #endif
  solve();
  // #ifndef ONLINE_JUDGE
  // cout<<"\\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\\n";
  // #endif
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i, n) for (int i = 0; i < n; i++)
#define rev(i, n) for (ll i = n; i >= 0; i--)
#define rep_a(i, a, n) for (ll i = a; i < n; i++)
#define pb push_back
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
const long long mod = 1000000007;
const long long INF = mod * mod;
int ansi = 1;
int solve() {
  ll n, m;
  cin >> n >> m;
  ll arr[n];
  ll sum = 0;
  rep(i, n) {
    cin >> arr[i];
    sum += arr[i];
    //
  }
  // cout<<sum<<endl;
  ll count = 0;
  sum = ceil((sum) / (4.0 * m));
  // cout<<sum<<endl;
  rep(i, n) {
    // cout<<arr[i]<<endl;
    if (arr[i] >= sum)
      count++;
  }
  if (count >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#else
#endif
  solve();
#ifndef ONLINE_JUDGE
  cout << "\\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " Sec\\n";
#endif
  return 0;
}
Problem p02718 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int count = 0;
  int sum = 0;

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

  for (int k = 0; k < n; k++) {
    sum += a.at(k);
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  for (int j = 0; j < m; j++) {

    if (4 * m * a.at(j) < sum) {
      cout << "No" << endl;
      break;
    } else {
      count++;
    }
  }

  if (count == m) {
    cout << "Yes" << 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, m;
  cin >> n >> m;
  vector<int> a;
  int count = 0;

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

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  for (int j = 0; j < m; j++) {

    if (4 * m * a.at(j) < 1) {
      cout << "No" << endl;
      return 0;
    } else {
      count++;
    }
  }

  if (count == m) {
    cout << "Yes" << endl;
  }
}
Problem p02718 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <stdlib.h>
int main(void) {
  int N, M, *A, SN = 0;
  int i, count = 0;

  scanf("%d", &N);
  scanf("%d", &M);

  A = (int *)malloc(N);
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    SN += A[i];
  }
  for (i = 0; i < N; i++) {
    if (A[i] >= (double)SN / (4 * M)) {
      count += 1;
    }
  }

  if (count >= M)
    printf("Yes\\n");
  else
    printf("No\\n");

  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>
#include <stdlib.h>
int main(void) {
  int N, M, *A, SN = 0;
  int i, count = 0;

  scanf("%d", &N);
  scanf("%d", &M);

  A = (int *)malloc(N);
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    SN += A[i];
  }
  for (i = 0; i < N; i++) {
    if (A[i] >= SN / (4 * M)) {
      count += 1;
    }
  }

  if (count >= M)
    printf("Yes\\n");
  else
    printf("No\\n");

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

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int s = 0;
  rep(i, n) s += a[i];
  int cnt = 0;
  rep(i, n) {
    if (a[i] * (4 * m) >= s)
      cnt++;
  }
  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a.at(n);

  int s = 0;
  rep(i, n) s += a.at(i);

  int cnt = 0;
  rep(i, n) {
    if (a.at(n) * (4 * m) >= s)
      cnt++;
  }
  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

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

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a;
  int total = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a.push_back(x);
    total += x;
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int count = 0;
  for (int i = 0; i < m; ++i) {
    if (a.at(i) * 4 * m >= total)
      count++;
  }
  if (count == m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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, m;
  cin >> n >> m;
  vector<int> a;
  int total = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
    total += a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int count = 0;
  for (int i = 0; i < m; ++i) {
    if (a.at(i) > total / 4 * m)
      continue;
    count++;
  }
  if (count > m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p02718 (C++) — buggy submission, verdict: Runtime Error

#pragma region
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main() {
  int N, M, c = 0;
  cin >> N >> M;
  vector<int> A(N);

  rep(i, N) {
    cin >> A.at(i);
    c += A.at(i);
  }

  sort(all(A));
  reverse(all(A));

  if (A.at(M - 1) * (4 * M) >= c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Error: 0

Fixed submission:

#pragma region
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main() {
  int N, M, allc = 0;
  cin >> N >> M;
  vector<int> A(N);

  rep(i, N) {
    cin >> A.at(i);
    allc += A.at(i);
  }

  sort(all(A));
  reverse(all(A));

  int c = 0;
  while (A.at(c) >= allc / (4 * M)) {
    c++;
  }

  if (c >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02718 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  int N;

  double M;

  cin >> N >> M;

  vector<int> vec(N);

  for (int i = 0; i < N; i++) {

    cin >> vec[i];
  }

  int sum = 0;

  for (int i = 0; i < N; i++) {

    sum += vec[i];
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  if (vec.at(M - 1) < sum / (4 * M))
    cout << "No" << endl;

  else
    cout << "Yes" << endl;
}


Error: 0

Fixed submission:

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

int main() {

  int N, M;

  cin >> N >> M;

  vector<int> vec(N);

  for (int i = 0; i < N; i++) {

    cin >> vec[i];
  }

  int sum = 0;

  for (int i = 0; i < N; i++) {

    sum += vec[i];
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  if (vec.at(M - 1) < sum / (4 / M))
    cout << "No" << endl;

  else
    cout << "Yes" << endl;
}