alexjercan/bugnet huggingface dataset:
Problem p02724 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

// #define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio()                                                               \\
  ios_base::sync_with_stdio(NULL);                                             \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define endl '\\n'

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;

template <class T> inline T RD(T &a) {
  T x;
  cin >> x;
  return a = x;
}

// OJ freopen Template
void OJF(const char *inp, const char *out) {
  if (strlen(inp) > 0)
    freopen(inp, "r", stdin);
  if (strlen(out) > 0)
    freopen(out, "w", stdout);
}

signed main() {
  fastio();
  int n;
  cin >> n;
  int cnt = (n / 500) * 1000;
  n %= 500;
  cnt += (n / 5) * 5;
  cout << cnt;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

// #define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio()                                                               \\
  ios_base::sync_with_stdio(NULL);                                             \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define endl '\\n'

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;

template <class T> inline T RD(T &a) {
  T x;
  cin >> x;
  return a = x;
}

// OJ freopen Template
void OJF(const char *inp, const char *out) {
  if (strlen(inp) > 0)
    freopen(inp, "r", stdin);
  if (strlen(out) > 0)
    freopen(out, "w", stdout);
}

signed main() {
  int n;
  cin >> n;
  int cnt = 0;
  while (n >= 500)
    cnt += 1000, n -= 500;
  while (n >= 5)
    cnt += 5;
  cout << cnt;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ll n;
  cin >> n;
  ll x = n / 500;
  n -= x * 500;
  ll y = n / 5;
  ll ans = 0;
  ans += x * 500 * 2;
  ans += y * 5;
  cout << ans;
  return 0;
}

Error: 228

Fixed submission:

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

int main() {
  ll n;
  cin >> n;
  ll x = n / 500;
  n -= x * 500;
  ll y = n / 5;
  ll ans = 0;
  ans += x * 500 * 2;
  ans += y * 5;
  return ans;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

/*Given an array of n numbers find the largest difference in the
starting and ending indexes of the elements of the all possible
strictly decreasing sub-sequences in the array.

Input: 21, 13, 18, 10, 7, 3, 1

Output : 4

Input: 1, 18, 17, 14, 15, 32, 16

Output: 2 */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000007
#define M 100001
#define endl "\\n"
#define all(a) (a).begin(), (a).end()
#define lp(i, a, b) for (i = a; i < b; i++)
#define lpr(i, a, b) for (i = a; i >= b; i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;

int main() {

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

  fast;
  int i, n;
  cin >> n;
  int r = 1000 * floor(n / 500);
  n -= 500 * (n / 500);
  r += 5 * (n / 5);
  cout << r << endl;
  return 0;
}


Error: WA

Fixed submission:

/*Given an array of n numbers find the largest difference in the
starting and ending indexes of the elements of the all possible
strictly decreasing sub-sequences in the array.

Input: 21, 13, 18, 10, 7, 3, 1

Output : 4

Input: 1, 18, 17, 14, 15, 32, 16

Output: 2 */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000007
#define M 100001
#define endl "\\n"
#define all(a) (a).begin(), (a).end()
#define lp(i, a, b) for (i = a; i < b; i++)
#define lpr(i, a, b) for (i = a; i >= b; i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;

int main() {

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

  fast;
  int i, n;
  cin >> n;
  int r = 1000 * floor(n / 500);
  n -= 500 * (n / 500);
  r += 5 * (n / 5);
  cout << r << endl;
  return 0;
}
Problem p02724 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define ll long long
#define endl "\\n"

void solve() {
  ll ans = 0;
  ll n;
  cin >> n;
  ans = (1ll * 1000 * (n / 500)) + (1ll * 5 * ((n % 500) / 5));
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}


Error: TLE

Fixed submission:

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

#define ll long long
#define endl "\\n"

void solve() {
  ll ans = 0;
  ll n;
  cin >> n;
  while (n > 0) {
    if (n >= 500) {
      ans += 1000;
      n -= 500;
    } else if (n >= 5) {
      ans += 5;
      n -= 5;
    }
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}
Problem p02724 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

int main() {
  ll x;
  cin >> x;

  ll a = 0;
  ll b = 0;
  while (500 * a <= x) {
    a++;
  }
  a--;
  while (5 * b <= x - 500 * a) {
    b++;
  }
  b--;
  cout << 1000 * a + 5 * b << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

int main() {
  ll x;
  cin >> x;
  ll happy = 0;

  for (ll a = 0; 500 * a <= x; a++) {
    for (ll b = 0; 5 * b <= x; b++) {
      if (500 * a + 5 * b <= x) {
        happy = max(happy, 1000 * a + 5 * b);
      }
    }
  }
  cout << happy << endl;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define mp make_pair
#define endl "\\n"
#define N 998244353
#define INF 1e9

ll power(ll x, ll y, ll m) {
  if (y == 0)
    return 1;
  ll p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
int main() {
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\\n";

  ll n;
  cin >> n;
  ll ans = (n / 500) * 1000;
  ans += ((n % 500) / 5) * 5;
  cout << ans;

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define mp make_pair
#define endl "\\n"
#define N 998244353
#define INF 1e9

ll power(ll x, ll y, ll m) {
  if (y == 0)
    return 1;
  ll p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\\n";

  ll n;
  cin >> n;
  ll ans = (n / 500) * 1000;
  ans += ((n % 500) / 5) * 5;
  cout << ans;

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


#include <bits/stdc++.h>

using namespace std;

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

#ifdef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
  int x;
  cin >> x;
  int temp = x / 500;
  int ans = 1000 * (temp);
  x -= 500 * temp;
  x /= 5;
  ans += 5 * (x);
  cout << ans << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
  int x;
  cin >> x;
  int temp = x / 500;
  int ans = 1000 * (temp);
  x -= 500 * temp;
  x /= 5;
  ans += 5 * (x);
  cout << ans << endl;
  return 0;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int first = n / 500;
  int ans = 0;
  ans += (first)*1000;
  int left = n - (first)*500;
  int second = left / 5;
  ans += (second)*5;
  cout << ans;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  ll d = (n / 500);
  ans += d * 1000;
  ll rem = n % (d * 500);
  d = rem / 5;

  ans += d * 5;
  cout << ans;

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

#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define repeq(i, n) for (int(i) = 0; (i) <= (int)(n); (i)++)
#define rep1(i, x, n) for (int(i) = (x); (i) < (int)(n); (i)++)
#define rep1eq(i, x, n) for (int(i) = (x); (i) <= (int)(n); (i)++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int, int> P;

// 少数点表示
// cout << std::fixed << std::setprecision(14) << 値

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  int amari = 0;
  int happy = 0;
  if (x == 0) {
    cout << 0;
    return 0;
  }
  int z = x / 500;
  happy += (1000 * z);
  int y;
  if (z != 0) {
    y = (x % (500 * z)) / 5;
  } else {
    y = x / 5;
  }
  happy += (5 * y);
  cout << happy;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define repeq(i, n) for (int(i) = 0; (i) <= (int)(n); (i)++)
#define rep1(i, x, n) for (int(i) = (x); (i) < (int)(n); (i)++)
#define rep1eq(i, x, n) for (int(i) = (x); (i) <= (int)(n); (i)++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int, int> P;

// 少数点表示
// cout << std::fixed << std::setprecision(14) << 値

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  int amari = 0;
  int happy = 0;
  if (x == 0) {
    cout << 0;
    return 0;
  }
  int z = x / 500;
  happy += (1000 * z);
  int y = (x % (500 * z)) / 5;
  happy += (5 * y);
  cout << happy;
}
Problem p02724 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll x, ans;
  cin >> x;
  ll r = x;
  x /= 500;
  ans = x * 1000;
  r %= 500;
  r /= 5;
  ans += r * 5;
  cout << ans;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
int main() {
  int x;
  cin >> x;
  int sum = 0;
  while (x > 4) {
    int r = 0;
    if (x > 500) {
      r = x / 500;
      sum += 1000 * r;
      x = x % 500;
    } else if (x < 500) {
      r = x / 5;
      sum += 5 * r;
      x = x % 5;
    }
  }
  cout << sum;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int x;
  cin >> x;

  int count500 = x / 500;
  int count5 = (x % 500) / 5;
  int result = count500 * 1000 + count5 * 5;
  cout << result << endl;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int x;
  cin >> x;

  int count500 = x / 500;
  int count5 = (x % (500 * count500)) / 5;
  int result = count500 * 1000 + count5 * 5;
  cout << result << endl;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

// ループ
#define REP(i, n) for (int i = 0; i < n; i++)   // 普通のループ
#define REPR(i, n) for (int i = n; i >= 0; i--) // 逆ループ
#define FOR(i, m, n) for (int i = m; i < n; i++) // 最初の数値を指定したループ

// 型名省略
typedef long long ll;
double tmp;

using namespace std;

int main() {
  string tmp_money;
  char c;
  ll money, thousand, five, tmp, happy;

  cin >> tmp_money;
  REP(i, tmp_money.length()) {
    c = tmp_money[i];
    if (isdigit(c) == 0) {
      // cout << "not digit:" << c << isdigit(c);
      cout << 0;
      return 0;
    }
  }

  money = stoll(tmp_money);

  if (money < 0 || money > 1000000000) {
    // cout << "X error:" << money;
    cout << 0;
    return 0;
  }

  if (money == 0) {
    happy = 0;
    cout << happy;
  } else {
    thousand = money / 500;
    tmp = money - thousand * 500;

    if (tmp == 0) {
      happy = 1000 * thousand;
      cout << happy;
    } else {
      five = tmp / 5;
      happy = 1000 * thousand + 5 * five;

      // cout << "500:" << thousand << "tmp:" << tmp <<"5:" << five << "happy:"
      // << happy;

      cout << happy;
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

// ループ
#define REP(i, n) for (int i = 0; i < n; i++)   // 普通のループ
#define REPR(i, n) for (int i = n; i >= 0; i--) // 逆ループ
#define FOR(i, m, n) for (int i = m; i < n; i++) // 最初の数値を指定したループ

// 型名省略
typedef long long ll;
double tmp;

using namespace std;

int main() {
  string tmp_money;
  char c;
  ll money, thousand, five, tmp, happy;

  cin >> tmp_money;
  REP(i, tmp_money.length()) {
    c = tmp_money[i];
    if (isdigit(c) == 0) {
      // cout << "not digit:" << c << isdigit(c);
      return 1;
    }
  }

  money = stoll(tmp_money);

  if (money < 0 || money > 100000000) {
    // cout << "X error:" << money;
    return 1;
  }

  if (money == 0) {
    happy = 0;
    cout << happy;
  } else {
    thousand = money / 500;
    tmp = money - thousand * 500;
    five = tmp / 5;
    happy = 1000 * thousand + 5 * five;

    // cout << "500:" << thousand << "tmp:" << tmp <<"5:" << five << "happy:" <<
    // happy;

    cout << happy;
  }
  return 0;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int x;
  cin >> x;
  int c500 = x / 500;
  x = x % 500;
  int c5 = x / 5;
  cout << c500 * 1000 + c5 * 5 << endl;
}


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;

int main() {
  long long k, n;
  cin >> k >> n;
  vector<long long> data(n);
  for (long long i = 0; i < n; i++) {
    cin >> data.at(i);
  }

  long long a = data.at(n - 1) - data.at(0);
  vector<long long> table(1000000, 0);
  table.at(a) = 1;
  for (long long i = 0; i < n - 1; i++) {
    long long sum = k - data.at(i + 1) + data.at(i);
    table.at(sum) = 1;
  }
  for (long long i = 0; i < 1000000; i++) {
    if (table.at(i) == 1) {
      cout << i << endl;
      break;
    }
  }
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, a, b;
  cin >> n;
  x = n % 500;
  a = n / 500;
  a *= 1000;
  b = x / 5;
  b *= 5;
  cout << a + b << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>

#define endl "\\n"
#define rep(i, a, b) for (int i = a; i < b; i++)
#define brep(i, a, b) for (int i = a; i >= b; i--)
#define debug1(x) cout << #x << " " << x << endl;
#define debug2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define debug3(x, y, z)                                                        \\
  cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z     \\
       << endl;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

  ll n;
  cin >> n;
  ll x = n % 500;
  ll a = n / 500;
  a *= 1000;
  ll b = x / 5;
  b *= 5;
  cout << a + b << endl;
  return 0;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int x;
  cin >> x;
  int y = 0;
  y = 1000 * (x / 500) + 5 * ((x % 500) / 5);
  cout << y << endl;
  return 0;
}

Error: 228

Fixed submission:

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

int main() {
  int x;
  cin >> x;
  int y = 0;
  y = 1000 * (x / 500) + 5 * ((x % 500) / 5);
  cout << y << endl;
  return y;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\\n';
#define PRINTVEC(x)                                                            \\
  for (int i = 0; i < (int)x.size(); i++)                                      \\
    std::cout << x[i] << ' ';                                                  \\
  std::cout << '\\n';
#define PRINTP(x)                                                              \\
  for (int i = 0; i < (int)x.size(); i++)                                      \\
    std::cout << x[i].first << ' ' << x[i].second << '\\n';                     \\
  std::cout << '\\n';
#define io                                                                     \\
  std::ios_base::sync_with_stdio(false);                                       \\
  std::cin.tie(NULL);
const int INF = 1 << 29;
typedef long long ll;

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

  int x;
  std::cin >> x;
  int ans = x / 500 * 1000;
  ans += (x % 500) / 5 * 5;

  std::cout << ans;

#ifndef ONLINE_JUDGE
// std::cout << '\\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << "
// sec \\n";
#endif
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\\n';
#define PRINTVEC(x)                                                            \\
  for (int i = 0; i < (int)x.size(); i++)                                      \\
    std::cout << x[i] << ' ';                                                  \\
  std::cout << '\\n';
#define PRINTP(x)                                                              \\
  for (int i = 0; i < (int)x.size(); i++)                                      \\
    std::cout << x[i].first << ' ' << x[i].second << '\\n';                     \\
  std::cout << '\\n';
#define io                                                                     \\
  std::ios_base::sync_with_stdio(false);                                       \\
  std::cin.tie(NULL);
const int INF = 1 << 29;
typedef long long ll;

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

  int x;
  std::cin >> x;
  int ans = x / 500 * 1000;
  ans += (x % 500) / 5 * 5;

  std::cout << ans;

#ifndef ONLINE_JUDGE
  std::cout << '\\n'
            << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \\n";
#endif
  return 0;
}
Problem p02724 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int yen, happiness = 0;
  cin >> yen;
  while (yen > 0) {
    if (yen >= 500) {
      happiness += 1000;
      yen -= 500;
    } else if (yen >= 100) {
      happiness += 100;
      yen -= 100;
    } else if (yen >= 50) {
      happiness += 50;
      yen -= 50;
    } else if (yen >= 10) {
      happiness += 10;
      yen -= 10;
    } else if (yen >= 5) {
      happiness += 5;
      yen -= 5;
    } else {
      yen -= yen;
    }
  }
  cout << happiness;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int yen, happiness = 0;
  cin >> yen;
  while (yen >= 0) {
    if (yen > 500) {
      happiness += 1000;
      yen -= 500;
    } else {
      happiness += yen;
      yen = 0;
    }
  }
  cout << happiness;
}
Problem p02724 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int money;
  int kind = 0;

  do {
    scanf("%d", &money);
  } while (money < 0 || money > 1000000000);

  while (money >= 500) {
    kind += 1000;
    money -= 500;
  }
  while (money >= 5) {
    kind += 5;
    money -= 5;
  }
  printf("%d\\n", kind);

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int money;
  int kind = 0;

  do {
    scanf("%d", &money);
  } while (money <= 0 || money >= 1000000000);

  while (money >= 500) {
    kind += 1000;
    money -= 500;
  }
  while (money >= 5) {
    kind += 5;
    money -= 5;
  }
  printf("%d\\n", kind);

  return 0;
}