prithivMLmods/Coder-Stat huggingface dataset:
Problem p02717 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <exception>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define endl "\n"
#define fx(n) fixed << setprecision(n)
#define mk make_pair

void fast() {
  ios::sync_with_stdio(NULL);
  cout.tie(NULL);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("output.txt", "w", stdout);
  freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
  /*freopen("output.txt", "w", stdout);
  freopen("pyramid.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
  fast();
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <exception>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define endl "\n"
#define fx(n) fixed << setprecision(n)
#define mk make_pair

void fast() {
  ios::sync_with_stdio(NULL);
  cout.tie(NULL);
  cin.tie(NULL);
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
  fast();
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c << endl;
  return 0;
}
Problem p02717 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define maxn 10005
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
using namespace std;

void slove() {
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << ' ' << b << ' ' << c << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef ONLINE_JUDGE
#else
  freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
  freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
  /*while (cin >> t)*/
  slove();

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define maxn 10005
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
using namespace std;

void slove() {
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << ' ' << b << ' ' << c << '\n';
}

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

  /*while (cin >> t)*/
  slove();

  return 0;
}
Problem p02717 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define TASK "task"

using namespace std;

void rwFile() {
  freopen(TASK ".in", "r", stdin);
  freopen(TASK ".out", "w", stdout);
}

void solveA() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << ' ' << x << ' ' << y;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  rwFile();
  solveA();
}


Fixed submission:
#include <bits/stdc++.h>
#define TASK "task"

using namespace std;

void rwFile() {
  freopen(TASK ".in", "r", stdin);
  freopen(TASK ".out", "w", stdout);
}

void solveA() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << ' ' << x << ' ' << y;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  /// rwFile();
  solveA();
}
Problem p02717 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod = 1e9 + 7;
const db eps = 1e-9;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cout << #x << " " << x << endl

int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

  ll a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c;

  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod = 1e9 + 7;
const db eps = 1e-9;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cout << #x << " " << x << endl

int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c;

  return 0;
}
Problem p02717 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 100000000000000000
#define UB upper_bound
#define LB lower_bound
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
using namespace std;
/////number of edges in a graph equal (v[i].size() ka summation of all the
///vertices)//
int main() {
  fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 100000000000000000
#define UB upper_bound
#define LB lower_bound
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
using namespace std;
/////number of edges in a graph equal (v[i].size() ka summation of all the
///vertices)//
int main() {
  fast;
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif
  ll int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
}
Problem p02717 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
#define loop(var, init, condition) for (int var = init; var < condition; var++)
#define rloop(var, init, condition) for (int var = init; var > condition; var--)
#define mod 1000000007
#define qmod 998244353
#define M 1000001
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define popi pop_back
#define SZ(v) ((int)(v).size())

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef unordered_map<string, int> usi;
typedef unordered_map<int, int> umii;
typedef map<int, int> omii;
typedef set<int> seti;

ll pow(ll a, ll b, ll m) {
  ll x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > m)
        x %= m;
    }
    y = (y * y);
    if (y > m)
      y %= m;
    b /= 2;
  }
  return x % m;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

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

  fast;

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

  return 0;
}

// MAKING HARD THINGS SIMPLE AND SIMPLE THINGS HARD

//        ,~~.
//       (  6 )-_,
//  (\___ )=='-'
//   \ .   ) )
//    \ `-' /    battak
// ~'`~'`~'`~'`~

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
#define loop(var, init, condition) for (int var = init; var < condition; var++)
#define rloop(var, init, condition) for (int var = init; var > condition; var--)
#define mod 1000000007
#define qmod 998244353
#define M 1000001
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define popi pop_back
#define SZ(v) ((int)(v).size())

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef unordered_map<string, int> usi;
typedef unordered_map<int, int> umii;
typedef map<int, int> omii;
typedef set<int> seti;

ll pow(ll a, ll b, ll m) {
  ll x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > m)
        x %= m;
    }
    y = (y * y);
    if (y > m)
      y %= m;
    b /= 2;
  }
  return x % m;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

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

  fast;

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

  return 0;
}

// MAKING HARD THINGS SIMPLE AND SIMPLE THINGS HARD

//        ,~~.
//       (  6 )-_,
//  (\___ )=='-'
//   \ .   ) )
//    \ `-' /    battak
// ~'`~'`~'`~'`~
Problem p02717 (C++)

Buggy submission (status: 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() {

#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;
}

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() {

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

Buggy submission (status: Runtime Error):

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

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define ppp pair<ll, pair<ll, ll>>
#define pp pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define pi 3.14159265358
#define MOD 998244353

int main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

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

  ll a, b, c;

  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);

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


Fixed submission:

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

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define ppp pair<ll, pair<ll, ll>>
#define pp pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define pi 3.14159265358
#define MOD 998244353

int main() {

  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // freopen("error.txt", "w", stderr);
  // #endif

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

  ll a, b, c;

  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);

  cout << a << " " << b << " " << c;
}
Problem p02717 (C++)

Buggy submission (status: 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;
}

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 (status: Runtime Error):
#include <bits/stdc++.h>

#define pb push_back
using namespace std;

int main() {

#ifndef ONLINE_JUDGE
  freopen("Input.txt", "r", stdin);
  freopen("Output.txt", "w", stdout);
#endif

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

  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define pb push_back
using namespace std;

int main() {

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

  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;

  return 0;
}
Problem p02717 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long int
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

int main() {
  IOS;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

int main() {
  IOS;
  // #ifndef ONLINE_JUDGE
  // 	freopen("input.txt", "r", stdin);
  // 	freopen("output.txt", "w", stdout);
  // #endif
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;

  return 0;
}
Problem p02717 (C++)

Buggy submission (status: 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;
}

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 (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

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

  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  int x, y, z;
  cin >> x >> y >> z;

  cout << z << " " << x << " " << y;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

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

  // freopen("input.txt", "r" , stdin);
  // freopen("output.txt", "w", stdout);

  int x, y, z;
  cin >> x >> y >> z;

  cout << z << " " << x << " " << y;

  return 0;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>

int main() {
  int n, m, i;
  int sum = 0;
  int re = 0;

  scanf("%d %d", &n, &m);

  int a[n];

  for (i = 0; i < n; i++) {
    scanf("%d", a[i]);
    sum = sum + a[i];
  }

  for (i = 0; i < n; i++) {
    if (a[i] * 4 * m >= sum)
      re++;
  }

  if (re >= m)
    printf("Yes");
  else
    printf("No");

  return 0;
}

Fixed submission:
#include <stdio.h>

int main() {
  int n, m, i;
  int sum = 0;
  int re = 0;

  scanf("%d %d", &n, &m);

  int a[n];

  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum = sum + a[i];
  }

  for (i = 0; i < n; i++) {
    if (a[i] * 4 * m >= sum)
      re++;
  }

  if (re >= m)
    printf("Yes");
  else
    printf("No");

  return 0;
}
Problem p02718 (C++)

Buggy submission (status: 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 (a.at(M) >= sum / (4 * M)) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
}

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 (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;
    }
  }
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007;
#define INV_10 299473306;
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  int n;
  double m;
  cin >> n >> m;
  double a[n], sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  double nb = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] >= sum / (4 * m))
      nb++;
  }
  if (nb >= m)
    cout << "Yes\n";
  else
    cout << "No\n";
}

Fixed submission:
#include <bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007;
#define INV_10 299473306;
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  double m;
  cin >> n >> m;
  double a[n], sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  double nb = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] >= sum / (4 * m))
      nb++;
  }
  if (nb >= m)
    cout << "Yes\n";
  else
    cout << "No\n";
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (long long i = (n)-1; i >= 0; i--)

ll gcd(ll a, ll b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}

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

  ll t;
  t = 1;
  while (t--) {
    ll n, m;
    cin >> n >> m;
    ld a[n];
    ld sum = 0;
    rep(i, n) {
      cin >> a[i];
      sum += a[i];
    }
    sort(a, a + n);
    if (m > n)
      cout << "No";
    else {
      if (a[n - m] >= (double)(sum / (double)(4 * m)))
        cout << "Yes";
      else
        cout << "No";
    }
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (long long i = (n)-1; i >= 0; i--)

ll gcd(ll a, ll b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}

int main() {

  fastio;

  ll t;
  t = 1;
  while (t--) {
    ll n, m;
    cin >> n >> m;
    ld a[n];
    ld sum = 0;
    rep(i, n) {
      cin >> a[i];
      sum += a[i];
    }
    sort(a, a + n);
    if (m > n)
      cout << "No";
    else {
      if (a[n - m] >= (double)(sum / (double)(4 * m)))
        cout << "Yes";
      else
        cout << "No";
    }
  }
  return 0;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int i, n, m, all = 0, p = 0; // n個の内、m個を選ぶ//
  cin >> n >> m;
  vector<int> a(i);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    all = all + a[i];
  }
  for (i = 0; i < n; i++) {
    if ((4 * m) * a[i] >= all)
      p = p + 1;
  }

  if (p >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int i, n, m, all = 0, p = 0; // n個の内、m個を選ぶ//
  cin >> n >> m;
  vector<int> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    all = all + a[i];
  }
  for (i = 0; i < n; i++) {
    if ((4 * m) * a[i] >= all)
      p = p + 1;
  }

  if (p >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int s = 0;
  rep(i, N) {
    cin >> A.at(i);
    s += A.at(i);
  }
  sort(begin(A), end(A));
  if (A.at(N - M - 1) * 4 * M < s)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int s = 0;
  rep(i, N) {
    cin >> A.at(i);
    s += A.at(i);
  }
  sort(begin(A), end(A));
  if (A.at(N - M) * 4 * M < s)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, a, b;
  b = 0;
  vector<int> A(N);
  a = 0;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    b += A.at(i);
  }
  sort(A.begin(), A.end());
  if (A.at(N - M - 1) >= b / (4 * M)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  int N, M, a, b;
  b = 0;
  vector<int> A(N);
  a = 0;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    b += A.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (A.at(i) * 4 * M >= b) {
      a++;
    }
  }
  if (a >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a + 1, a + 1 + n);
  int x = sum / (4 * m);
  int f = 0;
  if (x * m * 4 == sum)
    f = 1;
  bool f1 = true;
  for (int i = n; i > (n - m); i++) {
    if (a[i] > x)
      continue;
    if (a[i] == x && f == 1)
      continue;
    f1 = false;
  }
  cout << ((f1 == false) ? ("No") : ("Yes")) << endl;
  return 0;
}

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

int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a + 1, a + 1 + n);
  int x = sum / (4 * m);
  int f = 0;
  if (x * m * 4 == sum)
    f = 1;
  bool f1 = true;
  // cout << "lol" << endl;
  for (int i = n; i > (n - m); i--) {
    if (a[i] > x)
      continue;
    if (a[i] == x && f == 1)
      continue;
    f1 = false;
  }
  cout << ((f1 == false) ? ("No") : ("Yes")) << endl;
  return 0;
}
Problem p02718 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;

int main() {
  int n, m;
  int c = 0, i = 0, all = 0;

  scanf("%d %d", &n, &m);

  vector<int> vec(n);
  for (i = 0; i < n; i++) {
    cin >> vec.at(i);
    all += vec.at(i);
  }
  i = 0;
  while (i < n) {
    if (n * 4 / all <= vec.at(i))
      c += 1;
  }
  if (c >= m)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;

int main() {
  int n, m;
  int c = 0, i = 0, all = 0;

  scanf("%d %d", &n, &m);

  vector<int> vec(n);
  for (i = 0; i < n; i++) {
    cin >> vec.at(i);
    all += vec.at(i);
  }
  i = 0;
  for (i = 0; i < n && c < m; i++) {
    if (all <= vec.at(i) * m * 4)
      c += 1;
  }
  if (c >= m)
    printf("Yes");
  else
    printf("No");
  return 0;
}
Problem p02718 (Python)

Buggy submission (status: Runtime Error):
#!/usr/bin/env python3

a = int(input())
a, b = map(int, input().split())
a = list(str(input()))


Fixed submission:
#!/usr/bin/env python3

import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))

A = np.array(A)

num = np.sum(A >= np.sum(A) / (4 * M))

if num >= M:
    print("Yes")
else:
    print("No")
Problem p02718 (C++)

Buggy submission (status: Runtime Error):


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int total = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    total += a[i];
  }

  string res;
  if (a[m] > total / (4 * a[m]))
    res = "Yes";
  else
    res = "No";

  cout << res;
  return 0;
}

Fixed submission:


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int total = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    total += a[i];
  }

  string res;
  int count = 0;
  for (int i = 0; i < n; ++i)
    if (a[i] >= float(total) / (4 * m))
      ++count;
  if (count >= m)
    res = "Yes";
  else
    res = "No";

  cout << res;
  return 0;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a, val) memset(a, val, sizeof(a))
#define ps(x, noOfDecimal) fixed << setprecision(noOfDecimal) << x

using namespace std;
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  std::ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  vector<int> arr(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }

  double d = 1;
  d /= m;
  d /= 4;
  // cout<<d<<endl;
  int ct = 0;
  for (int i = 0; i < n; ++i) {
    double chk = arr[i];
    chk /= sum;
    // cout<<chk<<endl;
    if (d <= chk)
      ct++;
  }
  if (ct >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a, val) memset(a, val, sizeof(a))
#define ps(x, noOfDecimal) fixed << setprecision(noOfDecimal) << x

using namespace std;
int main() {
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
  std::ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  vector<int> arr(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }

  double d = 1;
  d /= m;
  d /= 4;
  // cout<<d<<endl;
  int ct = 0;
  for (int i = 0; i < n; ++i) {
    double chk = arr[i];
    chk /= sum;
    // cout<<chk<<endl;
    if (d <= chk)
      ct++;
  }
  if (ct >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i = (a); i <= (signed)(b); i++)
#define F0R(i, a) for (int i = 0; i < (signed)(a); i++)
#define RFOR(i, a, b) for (int i = (a); i >= b; i--)

#define MN 21
int n, m;
int a[MN];

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

  cin >> n >> m;
  int sm = 0;
  F0R(i, n) {
    cin >> a[i];
    sm += a[i];
  }
  int tot = (sm + 4 * m - 1) / (4 * m);
  int cnt = 0;
  F0R(i, n) {
    if (a[i] >= tot)
      ++cnt;
  }

  if (cnt >= m)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i = (a); i <= (signed)(b); i++)
#define F0R(i, a) for (int i = 0; i < (signed)(a); i++)
#define RFOR(i, a, b) for (int i = (a); i >= b; i--)

#define MN 105
int n, m;
int a[MN];

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

  cin >> n >> m;
  int sm = 0;
  F0R(i, n) {
    cin >> a[i];
    sm += a[i];
  }
  int tot = (sm + 4 * m - 1) / (4 * m);
  int cnt = 0;
  F0R(i, n) {
    if (a[i] >= tot)
      ++cnt;
  }

  if (cnt >= m)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <fstream>
#include <iostream>
#include <stdio.h>

#define DEV 1

using std::cin;
using std::cout;
using std::endl;
using std::terminate;

void solve() {
  int n, m;
  cin >> n >> m;
  int a[n];
  int all = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    all += a[i];
    a[i] *= 4 * m;
  }

  int y = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] >= all) {
      y++;
    }
  }

  cout << (y >= m ? "Yes" : "No") << endl;
}

int main() {

#ifdef DEV
  std::ifstream in("AtCoder/ABC161/Popular Vote.input");
  cin.rdbuf(in.rdbuf());

  int t;
  cin >> t;
  for (int x = 1; x <= t; ++x) {
    solve();
  }
#else
  solve();
#endif

  return 0;
}


Fixed submission:
#include <fstream>
#include <iostream>
#include <stdio.h>

using std::cin;
using std::cout;
using std::endl;
using std::terminate;

void solve() {
  int n, m;
  cin >> n >> m;
  int a[n];
  int all = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    all += a[i];
    a[i] *= 4 * m;
  }

  int y = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] >= all) {
      y++;
    }
  }

  cout << (y >= m ? "Yes" : "No") << endl;
}

int main() {

#ifdef DEV
  std::ifstream in("AtCoder/ABC161/Popular Vote.input");
  cin.rdbuf(in.rdbuf());

  int t;
  cin >> t;
  for (int x = 1; x <= t; ++x) {
    solve();
  }
#else
  solve();
#endif

  return 0;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, sum = 0;
  cin >> N >> M;
  vector<int> vo(N);
  for (int i = 0; i, N; i++) {
    cin >> vo.at(i);
    sum += vo.at(i);
  }
  sort(vo.begin(), vo.end(), greater<int>());
  cout << ((vo.at(M - 1) >= (sum + 4 * M - 1) / (4 * M)) ? "Yes" : "No")
       << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, sum = 0;
  cin >> N >> M;
  vector<int> vo(N);
  for (int i = 0; i < N; i++) {
    cin >> vo.at(i);
    sum += vo.at(i);
  }
  sort(vo.begin(), vo.end(), greater<int>());
  cout << ((vo.at(M - 1) >= (sum + 4 * M - 1) / (4 * M)) ? "Yes" : "No")
       << endl;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  double sum;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++)
    sum += a.at(i);
  sort(a.begin(), a.end());
  if (a.at(n - m + 1) < sum / 4 * m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  int n, m;
  double sum;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++)
    sum += a.at(i);
  sort(a.begin(), a.end());
  if (a.at(n - m) >= sum / (4 * m))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02718 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
if a[m] >= sum(a) / (4 * m):
    print("Yes")
else:
    print("No")


Fixed submission:
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
if a[m - 1] >= sum(a) / (4 * m):
    print("Yes")
else:
    print("No")
Problem p02718 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())

a = list(map(int, input().split()))
a.sort(reverse=True)
total = sum(a)

canPick = True
for i in range(m):
    if a[m] < total // (4 * m):
        canPick = False

if canPick is True:
    print("Yes")
else:
    print("No")


Fixed submission:
n, m = map(int, input().split())

a = list(map(int, input().split()))
a.sort(reverse=True)
total = sum(a)

canPick = True
for i in range(m):
    if a[i] < total / (4 * m):
        canPick = False

if canPick is True:
    print("Yes")
else:
    print("No")
Problem p02718 (Python)

Buggy submission (status: Runtime Error):
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

real = A[M] / sum(A)
ideal = 1 / (4 * M)

if real >= ideal:
    print("Yes")
else:
    print("No")


Fixed submission:
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

A.sort(reverse=True)
real = A[M - 1] / sum(A)
ideal = 1 / (4 * M)

if real >= ideal:
    print("Yes")
else:
    print("No")
Problem p02718 (Python)

Buggy submission (status: Runtime Error):
n, m = set(map(int, input().split()))
a = set(map(int, input().split()))
count = 0
for x in a:
    if x >= sum(a) / (4 * m):
        count += 1
if m <= count:
    print("Yes")
else:
    print("No")


Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for x in a:
    if x >= sum(a) / (4 * m):
        count += 1
if m <= count:
    print("Yes")
else:
    print("No")
Problem p02718 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if a[m] * 4 * m >= sum(a):
    print("Yes")
else:
    print("No")


Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if a[m - 1] * 4 * m >= sum(a):
    print("Yes")
else:
    print("No")
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <sstream>
using namespace std;
#include <algorithm>
#include <bits/stdc++.h>
#include <iterator>
#include <utility>
#define go return 0
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep(j, n) for (int j = 0; j < n; ++j)
#define REP(i, n) for (int i = 1; i <= n; ++i)
#define all(v) ((v).begin()), ((v).end())
#define len(s) ((int)s.size())
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector<vector<int>> vee;
typedef vector<pair<ll, ll>> vepa;
typedef set<int> se;
typedef map<int, int> mpp;
const ll N = 1e5 + 5;
ll arr[N], A[N], ARR[N];
bool visited[N] = {};
ll cnt[N], freq[N];
bool f, ff;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, m, sum = 0, count(0);
  cin >> n >> m;
  rep(i, n && cin >> arr[i]) { sum += arr[i]; }
  rep(i, n) {
    if (arr[i] * 4 * m >= sum)
      count++;
  }
  if (count >= m)
    exit(puts("Yes"));
  puts("No");
  go;
}


Fixed submission:
#include <iostream>
#include <sstream>
using namespace std;
#include <algorithm>
#include <bits/stdc++.h>
#include <iterator>
#include <utility>
#define go return 0
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep(j, n) for (int j = 0; j < n; ++j)
#define REP(i, n) for (int i = 1; i <= n; ++i)
#define all(v) ((v).begin()), ((v).end())
#define len(s) ((int)s.size())
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector<vector<int>> vee;
typedef vector<pair<ll, ll>> vepa;
typedef set<int> se;
typedef map<int, int> mpp;
const ll N = 1e5 + 5;
ll arr[N], A[N], ARR[N];
bool visited[N] = {};
ll cnt[N], freq[N];
bool f, ff;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, m, sum = 0, count(0);
  cin >> n >> m;
  rep(i, n && cin >> arr[i]) { sum += arr[i]; }
  rep(i, n) {
    if (arr[i] * 4 * m >= sum)
      count++;
  }
  if (count >= m)
    puts("Yes");
  else
    puts("No");
  go;
}
Problem p02718 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int M, N;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  if (A.at(M) > accumulate(A.begin(), A.end(), 0) / (4 * M)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  int M, N;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  if (A.at(M - 1) >=
      float(accumulate(A.begin(), A.end(), 0)) / float((4 * M))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02719 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
long k;
long calc(long n) {
  long result = abs(n - k);
  if (n < result)
    return n;
  return calc(result);
}

int main() {
  long n;
  cin >> n >> k;
  if (k == 1)
    cout << 0 << endl;
  else
    cout << calc(n) << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
long k;
long calc(long n) {
  long result = abs(n - k);
  if (n < result)
    return n;
  return calc(result);
}

int main() {
  long n;
  cin >> n >> k;

  while (n > k) {
    n = n % k;
  }
  cout << calc(n) << endl;
}
Problem p02719 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  ll n, k;
  cin >> n >> k;
  if (k == 1)
    cout << 0 << endl;
  else if (n < k) {
    if (2 * n < k)
      cout << n << endl;
    else
      cout << k - n << endl;
  } else if (n >= k) {
    ll curMin = 1e18;
    for (int i = 1;; i++) {
      ll x = n - k * i;
      curMin = min(curMin, abs(x));
      if (x < 0)
        break;
    }
    cout << curMin << endl;
  }
  return 0;
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  n %= k;
  cout << min(n, k - n) << endl;
  return 0;
}
Problem p02719 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  int n, k, ans;
  cin >> n >> k;
  if (n == k)
    ans = 0;
  else if (n > k)
    ans = min(n % k, k - n % k);
  else
    ans = min(n, k - n);
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll n, k, ans;
  cin >> n >> k;
  if (n == k)
    ans = 0;
  else if (n > k)
    ans = min(n % k, k - n % k);
  else
    ans = min(n, k - n);
  cout << ans;
  return 0;
}
Problem p02719 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <iostream>
using namespace std;

int main() {
  int n, k, t;
  cin >> n >> k;
  t = n % k;
  cout << min(t, abs(t - k)) << endl;
  return 0;
}

Fixed submission:
#include <cmath>
#include <iostream>
using namespace std;

int main() {
  long long int n, k, t;
  cin >> n >> k;
  t = n % k;
  cout << min(t, abs(t - k)) << endl;
  return 0;
}
Problem p02719 (C++)

Buggy submission (status: 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, K, c;
  cin >> N >> K;

  c = N / K;

  if (c >= 1) {
    N = abs(N - K * c);
  }

  cout << min(abs(N - K), N) << endl;
}

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() {
  ll N, K, c;
  cin >> N >> K;

  c = N / K;

  if (c >= 1) {
    N = abs(N - K * c);
  }

  cout << min(abs(N - K), N) << endl;
}
Problem p02719 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  long long n, k;
  cin >> n >> k;
  while (1) {
    if (k == 1) {
      n = 0;
      break;
    }
    if (abs(n - k) < n)
      n = abs(n - k);
    else
      break;
  }
  cout << n << endl;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  long long n, k;
  cin >> n >> k;
  cout << min(k - n % k, n % k) << endl;
}
Problem p02719 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n, k, a, b;
  cin >> n >> k;
  if (n % k == 0)
    cout << 0 << endl;
  else {
    a = n % k;
    b = k - a;
    cout << min(a, b) << endl;
  }
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  long long n, k, a, b;
  cin >> n >> k;
  if (n % k == 0)
    cout << 0 << endl;
  else {
    a = n % k;
    b = k - a;
    cout << min(a, b) << endl;
  }
}
Problem p02719 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  long long X, K;
  cin >> X >> K;
  if (X == K || K == 1)
    cout << 0;
  else {
    long long temp = X;
    X = abs(X - K);
    while (X < temp) {
      temp = X;
      X = abs(X - K);
    }
    cout << temp;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  long long X, K;
  cin >> X >> K;
  if (X == K || K == 1)
    cout << 0;
  else {
    X %= K;
    long long temp = X;
    X = abs(X - K);
    while (X < temp) {
      temp = X;
      X = abs(X - K);
    }
    cout << temp;
  }
  return 0;
}
Problem p02719 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for (auto &i : mp)

int main() {
  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  ll tmp = n, tmp_prev = n;
  for (;;) {
    tmp = abs(tmp - k);
    if (tmp > tmp_prev) {
      ans = tmp_prev;
      break;
    }
    tmp_prev = tmp;
    // cout << tmp << " " << tmp_prev<< endl;
  }
  // tmp = n;
  // rep(i,n){
  //   tmp = abs(tmp - k);
  //   cout << tmp << " " << tmp_prev<< endl;
  // }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for (auto &i : mp)

int main() {
  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  ll tmp = n % k, tmp_prev = tmp;
  for (;;) {
    tmp = abs(tmp - k);
    if (tmp > tmp_prev) {
      ans = tmp_prev;
      break;
    }
    tmp_prev = tmp;
    // cout << tmp << " " << tmp_prev<< endl;
  }
  // tmp = n;
  // rep(i,n){
  //   tmp = abs(tmp - k);
  //   cout << tmp << " " << tmp_prev<< endl;
  // }
  cout << ans << endl;
  return 0;
}