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

/******************************************
/@Author: LeafBelief
/@Date: 2020-04-04
/@Remark:
/@FileName: coffeestring
******************************************/
#include <bits/stdc++.h>
#define CSE(x, y) memset(x, y, sizeof(x))
#define lowbit(x) (x & (-x))
#define INF 0x3f3f3f3f
#define FAST                                                                   \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int maxn = 111;
char str[maxn];

int main() {
  FAST;
  while (cin >> str) {
    if (str[2] == str[3] && str[4] == str[5]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Error: WA

Fixed submission:

/******************************************
/@Author: LeafBelief
/@Date: 2020-04-04
/@Remark:
/@FileName: coffeestring
******************************************/
#include <bits/stdc++.h>
#define CSE(x, y) memset(x, y, sizeof(x))
#define lowbit(x) (x & (-x))
#define INF 0x3f3f3f3f
#define FAST                                                                   \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int maxn = 111;
char str[maxn];

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.in", "r", stdin);
#endif
  FAST;
  while (cin >> str) {
    if (str[2] == str[3] && str[4] == str[5]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define int long long
#define rep(i, a, b) for (int i = a; i < b; i++)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define mod 1000000007
// int max(int a, int b, int c){ if(a>b){if(a>c) return a; else return
// c;}else{if(b>c)return b;else return c;}}
int power(int a, int b) {
  int res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int32_t main() {
  IOS;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  string S;
  cin >> S;

  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes";
  }

  else {
    cout << "No";
  }
}

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


Fixed submission:

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

int main() {

  vector<string> S(6);
  if (S.at(3) == S.at(4) && S.at(5) == S.at(6)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  char S[6];
  scanf("%s", &S);
  if (S[2] == S[3] && S[4] == S[5]) {
    printf("Yes\\n");
  } else {
    printf("No\\n");
  }
  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <stdio.h>
#include <string.h>

int main() {
  char S[5];
  scanf("%s", &S);
  if (S[2] == S[3] && S[4] == S[5]) {
    printf("Yes\\n");
  } else {
    printf("No\\n");
  }
  return 0;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string S;
  cin >> S;
  if ((S.at(2) == S.at(3)) && (S.at(4) == S.at(5))) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


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


Fixed submission:

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

int main() {
  string S;
  cin >> S;
  if ((S.at(2) == S.at(3)) && (S.at(4) = S.at(6))) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;

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

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

int main() {
  string s;
  cin >> s;
  if (s.at(5) == s.at(4) && s.at(2) == s.at(3))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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


Fixed submission:

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

int main() {
  string s;
  cin >> s;
  if (s.at(6) == 'e' && s.at(3) == 'f' && s.at(4) == 'f' && s.at(5) == 'e')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string S;
  cin >> S;

  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }

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

Error: WA

Fixed submission:

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

int main() {
  string S;
  cin >> S;

  if (S.at(3) == S.at(4) && S.at(5) == S.at(6)) {
    cout << "Yes" << endl;
  }

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

#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 k, n;
  string s;
  cin >> s;
  bool c = false;
  if (s[2] == s[3] && s[4] == s[5])
    c = true;
  if (c)
    cout << "Yes" << endl;
  else
    cout << "No" << 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;
  string s;
  cin >> s;
  int c = 0;
  if (s[2] == s[3])
    c++;
  if (s[4] == s[5])
    c++;
  if (c == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  if (s.length() == 6) {
    char x[7];
    strcpy(x, s.c_str());
    bool b = 0;
    for (int i = 0; i < 2; i++) {
      if (int(x[i]) < 97 || int(x[i]) > 122) {
        b = 1;
        break;
      }
    }
    if (b == 0 && x[2] == x[3] && x[4] == x[5])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  if (s.length() == 6) {
    char x[6];
    strcpy(x, s.c_str());
    bool b = 0;
    for (int i = 0; i < 2; i++) {
      if (int(x[i]) < 97 || int(x[i]) > 122) {
        b = 1;
        break;
      }
    }
    if (b == 0 && x[2] == x[3] && x[4] == x[5])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5))
    cout << "Yes" << endl;
  else {
    cout << "No" << endl;
  }
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.at(3) == s.at(4) && s.at(5) == s.at(6)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string S;
  cin >> S;
  if ((S.at(2) == S.at(3)) && (S.at(4) == S.at(5)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Error: WA

Fixed submission:

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

int main() {
  string S;
  cin >> S;
  if ((S.at(3) == S.at(4)) && (S.at(5) == S.at(6)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02723 (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>;

string s;

int main() {
  cin >> s;
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
    cout << "Yes" << endl;
    return 0;
  } 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 3) >= this->size() (which is 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;
using P = pair<int, int>;

vector<string> s;
vector<string> ans;

int main() {
  for (int i = 0; i < s.size(); ++i) {
    cin >> s.at(i);
    ans.push_back(s.at(i));
  };

  if (ans.at(2) == ans.at(3) && ans.at(4) == ans.at(5)) {
    cout << "Yes" << endl;
    return 0;
  } else {
    cout << "No" << endl;
    return 0;
  }
};
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string> // for using std::string data type

using namespace std;

int main() {
  string s;
  getline(cin, s);

  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes";
  else
    cout << "No";

  return 0;
}


Error: -11

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  char *s;
  cin >> s;

  if (s[2] == s[3])
    cout << "Yes";
  else
    cout << "No";

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

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

int main() {
  string S;
  cin >> S;
  cout << ((S.at(2) == S.at(3) && S.at(4) == S.at(5)) ? "Yes" : "No") << endl;
}


Error: WA

Fixed submission:

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

int main() {
  string S;
  cin >> S;
  cout << (S.at(3) == S.at(4) && S.at(5) == S.at(6) ? "Yes" : "No") << endl;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string S;
  cin >> S;
  char a = S.at(2);
  char b = S.at(3);
  char c = S.at(4);
  char d = S.at(5);
  if (a == b && c == d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Error: WA

Fixed submission:

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

int main() {
  string N;
  cin >> N;
  if (N.at(3) == N.at(4) && N.at(5) == N.at(6)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  S.size() == 6;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  S.size() == 6;
  cin >> S;
  if (S.at(3) == S.at(4) && S.at(5) == S.at(6)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string A;
  cin >> A;
  if (A.at(2) == A.at(3) && A.at(4) == A.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Error: WA

Fixed submission:

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

int main() {
  string A;
  cin >> A;
  if (A.at(3) == A.at(4) && A.at(5) == A.at(6)) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  string s;
  cin >> s;
  vector<int> cnt(6, 0);
  for (int i = 0; i < (int)s.size(); i++) {
    cnt[s[i] - 'a']++;
  }
  sort(cnt.begin(), cnt.end());
  int sum = 0;
  for (int i = 0; i < (int)cnt.size(); i++) {
    sum += cnt[i];
  }
  if (sum == 4 && s[2] == s[3] && s[4] == s[5]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char c[6];
  scanf("%c%c%c%c%c%c", &c[0], &c[1], &c[2], &c[3], &c[4], &c[5]);
  if (c[4] == c[5] && c[2] == c[3])
    printf("Yes");
  else
    printf("No");
  return 0;
}

Error: WA

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char c[6];
  scanf("%c%c%c%c%c%c", &c[0], &c[1], &c[2], &c[3], &c[4], c[5]);
  if (c[4] == c[5] && c[2] == c[3])
    printf("Yes");
  else
    printf("No");
  return 0;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

// Deep Godhani
// DAIICT

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

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x, d) cout << fixed << setprecision(d) << x
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);                   \\
  srand(time(NULL))

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

const ll M = 1e9 + 7;

void solve() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

  FAST;
  ll t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}


Error: WA

Fixed submission:

// Deep Godhani
// DAIICT

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

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x, d) cout << fixed << setprecision(d) << x
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);                   \\
  srand(time(NULL))

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

const ll M = 1e9 + 7;

void solve() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

  FAST;
  ll t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, a, b) for (int i = (int)(a); (i) < (int)(b); i++)

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;

int main() {
  string s;
  cin >> s;

  string ans = (s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No";
  cout << ans << endl;
}

Error: 1

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, a, b) for (int i = (int)(a); (i) < (int)(b); i++)

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;

int main() {
  string s;
  cin >> s;

  string ans = (s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No";
  cout << ans << endl;
  return 1;
}
Problem p02723 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string s;
  cin >> s;

  bool answer = false;

  if ((s.at(2) == s.at(3)) && (s.at(4) == s.at(5)))
    answer = true;

  if (answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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


Fixed submission:

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

int main() {
  string s;
  cin >> s;

  bool answer = false;

  if (s.at(3) == s.at(4))
    answer = true;
  if (s.at(5) == s.at(6))
    answer = true;

  if (answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  std::string line;
  std::cin >> line;
  int money = std::stoi(line);
  int div500 = money / 500;
  money -= div500 * 500;
  int div5 = money / 5;
  money -= div5 * 5;
  std::cout << std::to_string((div500 * 1000) + (div5 * 5)) << std::endl;
  return 0;
}

Error: -8

Fixed submission:

#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  std::string line;
  std::cin >> line;
  int money = std::stoi(line);
  int moneyTable[6] = {500, 100, 50, 5, 1};
  int scoreTable[6] = {1000, 0, 0, 5, 0};
  int result = 0;
  for (int i = 0; i < 6; i++) {
    int div = money / moneyTable[i];
    result += div * moneyTable[i];
    money -= div * moneyTable[i];
  }
  std::cout << std::to_string(money) << std::endl;
  return 0;
}
Problem p02724 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  long long l;
  int i = 0;
  cin >> l;
  while (l > 0) {
    l -= 500;
    i += 1000;
    if (l < 0) {
      l += 500;
      i -= 1000;
      break;
    }
  }
  while (l > 0) {
    l -= 5;
    i += 5;
    if (l < 0) {
      l += 5;
      i -= 5;
      break;
    }
  }
  cout << i << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long l;
  int i = 0;
  cin >> l;
  while (l > 0) {
    l -= 500;
    i += 1000;
    if (l < 0) {
      l += 500;
      i -= 1000;
    }
  }
  while (l > 0) {
    l -= 5;
    i += 5;
    if (l < 0) {
      l += 5;
      i -= 5;
    }
  }
  cout << i << endl;
}
Problem p02724 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int X;
  cin >> X;
  int A = 0;
  int c = X / 500;
  int d = (X % 500) / 5;
  A += c * 1000;
  A += d * 5;
  cout << A << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int X;
  cin >> X;
  int A = 0;

  while (X -= 500 > 500) {
    A += 1000;
  }
  while (X -= 5 > 0) {
    A += 5;
  }
  cout << A << endl;
}
Problem p02724 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

#define FAST                                                                   \\
  ios_base ::sync_with_stdio(false);                                           \\
  cin.tie(NULL);
#define endl "\\n"

typedef long long int ll;
typedef unsigned long long int ull;

int main() {
  FAST;

  int n;
  cin >> n;

  cout << (n / 500 * 1000) + ((n % 500) / 5) * 5;

  return 0;
}


Error: WA

Fixed submission:


#include <iostream>

using namespace std;

#define FAST                                                                   \\
  ios_base ::sync_with_stdio(false);                                           \\
  cin.tie(NULL);
#define endl "\\n"

typedef long long int ll;
typedef unsigned long long int ull;

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

  int n;
  cin >> n;

  cout << (n / 500 * 1000) + ((n % 500) / 5) * 5;

  return 0;
}