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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int P;
int ans[3030]; // Σans[i]*x^i

__inline int power(int a, int b, int p) {
  int res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= p;
    }
    b >>= 1;
    a *= a;
    a %= p;
  }
  return res;
}

int fac[3030];
int fac_inv[3030];

void calc(int p) {
  fac[0] = 1;
  fac_inv[0] = 1;
  for (int i = 1; i < 3030; ++i) {
    fac[i] = fac[i - 1] * i;
    fac[i] %= p;
    fac_inv[i] = power(fac[i], p - 2, p);
  }
}

__inline int Comb(int n, int r, int p) {
  return fac[n] * fac_inv[r] % p * fac_inv[n - r] % p;
}

signed main() {
  cin >> P;
  calc(P);
  rep(i, P) {
    int a;
    cin >> a;
    if (a == 0)
      continue;
    ans[0] += 1;
    for (int j = 0; j < P; ++j) {
      ans[j] -= Comb(P - 1, j, P) * power(P - i, P - 1 - j, P);
      ans[j] %= P;
    }
  }
  rep(i, P) {
    ans[i] = ans[i] < 0 ? ans[i] + P : ans[i];
    if (i)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int P;
int ans[3030]; // Σans[i]*x^i

__inline int power(int a, int b, int p) {
  int res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= p;
    }
    b >>= 1;
    a *= a;
    a %= p;
  }
  return res;
}

int fac[3030];
int fac_inv[3030];

void calc(int p) {
  fac[0] = 1;
  fac_inv[0] = 1;
  for (int i = 1; i < 3030; ++i) {
    fac[i] = fac[i - 1] * i;
    fac[i] %= p;
    fac_inv[i] = power(fac[i], p - 2, p);
  }
}

__inline int Comb(int n, int r, int p) {
  return fac[n] * fac_inv[r] * fac_inv[n - r];
}

signed main() {
  cin >> P;
  calc(P);
  rep(i, P) {
    int a;
    cin >> a;
    if (a == 0)
      continue;
    ans[0] += 1;
    for (int j = 0; j < P; ++j) {
      ans[j] -= Comb(P - 1, j, P) * power(P - i, P - 1 - j, P);
      ans[j] %= P;
    }
  }
  rep(i, P) {
    ans[i] = ans[i] < 0 ? ans[i] + P : ans[i];
    if (i)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
Problem p02951 (C++)

Buggy submission (status: Runtime Error):
#include "iostream"
#include "stdio.h"
using namespace std;
int main() {
  int a, b, c;
  int ret = 0;
  cin >> a;
  cin >> b;
  cin >> c;

  if (c >= (a - b)) {
    ret = c - a + b;
  } else {
    ret = 0;
  }
  cout << ret;
  return ret;
}


Fixed submission:
#include "iostream"
#include "stdio.h"
using namespace std;
int main() {
  int a, b, c;
  int ret = 0;
  cin >> a;
  cin >> b;
  cin >> c;

  if (c >= (a - b)) {
    ret = c - a + b;
  } else {
    ret = 0;
  }
  cout << ret;
  return 0;
}
Problem p02951 (Python)

Buggy submission (status: Runtime Error):
a, b, c = input().splita, b, c = [int(x) for x in input().strip().split()]

water = c - (a - b)
if water < 0:
    print(0)
else:
    print(water)


Fixed submission:
a, b, c = [int(x) for x in input().strip().split()]

water = c - (a - b)
if water < 0:
    print(0)
else:
    print(water)
Problem p02951 (Python)

Buggy submission (status: Runtime Error):
a, b, c = map(int, input().split())
print(max(c - (a - b)), 0)


Fixed submission:
a, b, c = map(int, input().split())
print(max(c - (a - b), 0))
Problem p02951 (Python)

Buggy submission (status: Runtime Error):
A, B, C = map(int, input().split())
rest: int = C - (A - B)
result: int = rest if rest >= 0 else 0
print(result)


Fixed submission:
A, B, C = map(int, input().split())
rest = C - (A - B)
result = rest if rest >= 0 else 0
print(result)
Problem p02951 (Python)

Buggy submission (status: Runtime Error):
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))


Fixed submission:
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
Problem p02951 (Python)

Buggy submission (status: Runtime Error):
num = input().split()
a = num[0]
b = num[1]
c = num[2]
ans = b + c - a
if ans > 0:
    print(ans)
else:
    print(0)


Fixed submission:
num = input().split()
a = int(num[0])
b = int(num[1])
c = int(num[2])
ans = b + c - a
if ans > 0:
    print(ans)
else:
    print(0)
Problem p02951 (Python)

Buggy submission (status: Runtime Error):
i = list(map(int, input().split()))
print(i[2] - (i[0] - i[1]))
i = list(map(int, input().split()))
n = i[2] - (i[0] - i[1])
if n > 0:
    print(n)
else:
    print(0)


Fixed submission:
i = list(map(int, input().split()))
n = i[2] - (i[0] - i[1])
if n > 0:
    print(n)
else:
    print(0)
Problem p02951 (C++)

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

using namespace std;

#define F first
#define S second
#define ll long long
#define ld long double
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define ask(x) cerr << #x << " = " << x << "\n";
#define INF 1000000007
#define hell 998244353

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

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

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

  cout << max(0, b + c - a);

  return 0;
}

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

using namespace std;

#define F first
#define S second
#define ll long long
#define ld long double
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define ask(x) cerr << #x << " = " << x << "\n";
#define INF 1000000007
#define hell 998244353

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

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

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

  cout << max(0, b + c - a);

  return 0;
}
Problem p02951 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define forn(i, _n) for (int i = 0; i <= (_n); ++i)
#define forab(i, _a, _b) for (int i = (_a); i <= (_b); ++i)
#define forrn(i, _n) for (int i = n - 1; i >= 0; --i)
#define forrab(i, _a, _b) for (int i = _a; i >= b; --i)
#define tcase                                                                  \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef map<int, int> mii;
int mod = pow(10, 9) + 7;
int n, a, b, c;
void solve() {
  cin >> a >> b >> c;
  int x = c - a + b;
  if (x > 0)
    cout << x << endl;
  else
    cout << 0 << endl;
}
int32_t main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fastio solve();
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define forn(i, _n) for (int i = 0; i <= (_n); ++i)
#define forab(i, _a, _b) for (int i = (_a); i <= (_b); ++i)
#define forrn(i, _n) for (int i = n - 1; i >= 0; --i)
#define forrab(i, _a, _b) for (int i = _a; i >= b; --i)
#define tcase                                                                  \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef map<int, int> mii;
int mod = pow(10, 9) + 7;
int n, a, b, c;
void solve() {
  cin >> a >> b >> c;
  int x = c - a + b;
  if (x > 0)
    cout << x << endl;
  else
    cout << 0 << endl;
}
int32_t main() {
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
  fastio solve();
}
Problem p02951 (C++)

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> A(N, 1);
  vector<int> B(N, 0);
  vector<int> C(N, 0);

  for (int i = 0; i < pow(10, 4); i++) {
    for (int j = 0; j < N; j++) {
      if (S.at(j) == 'R')
        B.at(j + 1) += A.at(j);
      else
        B.at(j - 1) += A.at(j);
    }
    A = B;
    B = C;
  }

  for (int i = 0; i < N; i++) {
    cout << A.at(i) << " ";
  }
  cout << endl;
}


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

int main() {
  int c, a, b;
  cin >> a >> b >> c;
  cout << max(c - a + b, 0) << endl;
}
Problem p02951 (C++)

Buggy submission (status: Runtime Error):
/*_BELIEVE_*/

// CF,CC,AtC,SPOJ: hp1999
// HE: hemant269
// HR: hemant2132

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

#define int long long int
#define fast()                                                                 \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define all(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
#define pb push_back
#define ins insert
#define F first
#define S second

const int inf = 1e18, M = 1e9 + 7;
const int N = 1;

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(c - (a - b), 0ll);
}

int32_t main() {
  fast();

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

  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }

  return 0;
}

Fixed submission:
/*_BELIEVE_*/

// CF,CC,AtC,SPOJ: hp1999
// HE: hemant269
// HR: hemant2132

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

#define int long long int
#define fast()                                                                 \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define all(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
#define pb push_back
#define ins insert
#define F first
#define S second

const int inf = 1e18, M = 1e9 + 7;
const int N = 1;

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(c - (a - b), 0ll);
}

int32_t main() {
  fast();

  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }

  return 0;
}
Problem p02951 (C++)

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

#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int, int>
#define fi first
#define se second
#define pb pushback;

using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (c % (a - b));
  return 0;
}


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

#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int, int>
#define fi first
#define se second
#define pb pushback;

using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((c <= (a - b)) ? 0 : c - (a - b));
  return 0;
}
Problem p02951 (C++)

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

#define range 524289
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ << " " <<

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<int, pair<int, int>> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, l;
  cin >> n >> m >> l;
  cout << max(0, l - (n - m)) << endl;
  return 0;
}


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

#define range 524289
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ << " " <<

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<int, pair<int, int>> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main(int argc, char const *argv[]) {
  // #ifndef ONLINE_JUDGE
  //    	freopen("input.txt", "r", stdin);
  //    	freopen("output.txt", "w", stdout);
  // #endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, l;
  cin >> n >> m >> l;
  cout << max(0, l - (n - m)) << endl;
  return 0;
}
Problem p02951 (C++)

Buggy submission (status: Runtime Error):
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i)
#define FORR(i, a, b)                                                          \
  for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i)

#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  REP(i, v.size()) cout << " " << v[i];                                        \
  cout << endl
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a) % MOD + MOD) % MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(a, b) (abs(a - b) < EPS)
typedef complex<Real> P;

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

  return C - (A - B);
}


Fixed submission:
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i)
#define FORR(i, a, b)                                                          \
  for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i)

#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  REP(i, v.size()) cout << " " << v[i];                                        \
  cout << endl
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a) % MOD + MOD) % MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(a, b) (abs(a - b) < EPS)
typedef complex<Real> P;

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

  int ans = C - (A - B);
  if (ans < 0)
    ans = 0;

  cout << ans;
}
Problem p02951 (C++)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  while (a != b || c != 0) {
    b++;
    c--;
  }
  cout << c << endl;
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (a - b > 0) {
    c = c - (a - b);
  }
  if (c < 0) {
    c = 0;
  }
  cout << c << endl;
  return 0;
}
Problem p02951 (C++)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  return max(c - (a - b), 0);
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(c - a + b, 0);
  return 0;
}
Problem p02951 (C++)

Buggy submission (status: Runtime Error):
// This is getting accepted!
#include <bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define INARR(a, n)                                                            \
  for (int i = 1; i <= (n); ++i)                                               \
    cin >> a[i];
#define ITE(x) for (auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x) >> (i)) & 1)
#define setbit(x, i) ((x) ^ (1ll << (i)))
#define clearbit(x, i) ((x) & (~(1ll << (i))))
#define twoexp(i) (1ll << (i))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define FI first
#define SE second
#define son1 (id * 2)
#define son2 (id * 2 + 1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int a, b, c;

void input() {
  int u, v, w, x, y, qtype;

  cin >> a >> b >> c;
}

void preprocess() {}

void process(int itest) {
  int u, v, w, x, y, qtype;

  cout << max(c - (a - b), 0) << endl;
}

void oneTest() {

  input();
  preprocess();
  process(0);
}

void multiTest() {

  int t;
  cin >> t;

  for (int it = 1; it <= t; ++it) {
    input();
    preprocess();
    process(it);
  }
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("../inp.txt", "r", stdin);
  //    freopen("../out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  oneTest();
  //	multiTest();

  return 0;
}


Fixed submission:
// This is getting accepted!
#include <bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define INARR(a, n)                                                            \
  for (int i = 1; i <= (n); ++i)                                               \
    cin >> a[i];
#define ITE(x) for (auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x) >> (i)) & 1)
#define setbit(x, i) ((x) ^ (1ll << (i)))
#define clearbit(x, i) ((x) & (~(1ll << (i))))
#define twoexp(i) (1ll << (i))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define FI first
#define SE second
#define son1 (id * 2)
#define son2 (id * 2 + 1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int a, b, c;

void input() {
  int u, v, w, x, y, qtype;

  cin >> a >> b >> c;
}

void preprocess() {}

void process(int itest) {
  int u, v, w, x, y, qtype;

  cout << max(c - (a - b), 0) << endl;
}

void oneTest() {

  input();
  preprocess();
  process(0);
}

void multiTest() {

  int t;
  cin >> t;

  for (int it = 1; it <= t; ++it) {
    input();
    preprocess();
    process(it);
  }
}

int main() {
#ifndef ONLINE_JUDGE
  //    freopen("../inp.txt", "r", stdin);
  //    freopen("../out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  oneTest();
  //	multiTest();

  return 0;
}
Problem p02951 (C++)

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

int main() {

  int A, B, C, rest;
  cin >> A >> B >> C;
  rest = A - B;
  C = C - rest;
  if (C <= 0) {
    return 0;
  }
  return C;
}


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

int main() {

  int A, B, C, rest;
  cin >> A >> B >> C;
  rest = A - B;
  C = C - rest;
  if (C <= 0) {
    cout << 0;
  } else
    cout << C;
}
Problem p02952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, c = 0;
  scanf("%d", &a);
  for (int i = 1; i <= a; i++) {
    int b = 0;
    int t = i;
    while (t) {
      b++;
      t / 10;
    }
    if (b % 2 == 1) {
      c++;
    }
  }
  printf("%d", c);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, c = 0;
  scanf("%d", &a);
  for (int i = 1; i <= a; i++) {
    int b = 0;
    int t = i;
    while (t) {
      b++;
      t = t / 10;
    }
    if (b % 2 == 1) {
      c++;
    }
  }
  printf("%d", c);
}
Problem p02952 (C++)

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

int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  int ct = s.size();
  int res = 0;
  if (ct & 1) {
    string tmp = "";
    for (int i = 0; i < ct - 1; ++i)
      tmp += '9';
    ct -= 2;
    res += n - stoi(tmp);
  } else {
    ct--;
  }
  for (int i = 1; i <= ct; i += 2) {
    res += pow(10, i - 1) * 9;
  }
  cout << res << endl;
}

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

int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  int ct = s.size();
  int res = 0;
  if (ct == 1) {
    cout << n << endl;
    return 0;
  }
  if (ct & 1) {
    string tmp = "";
    for (int i = 0; i < ct - 1; ++i)
      tmp += '9';
    ct -= 2;
    res += n - stoi(tmp);
  } else {
    ct--;
  }
  for (int i = 1; i <= ct; i += 2) {
    res += pow(10, i - 1) * 9;
  }
  cout << res << endl;
}
Problem p02952 (C++)

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  int digit = 0;
  for (int i = 1; i <= N; i++) {
    digit = 0;
    int a = i;
    while (a != 0) {
      digit++;
      a / (10);
      if (a == 0) {
        break;
      }
    }
    if (digit % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  int digit = 0;
  for (int i = 1; i <= N; i++) {
    digit = 0;
    int a = i;
    while (a != 0) {
      digit++;
      a /= (10);
    }
    if (digit % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
  int n;
  int cnt = 0;

  for (int i = 1; i <= n; ++i) {
    int d = 0;
    int t = i;
    while (t) {
      ++d;
      t /= 10;
    }
    if (d & 1)
      ++cnt;
  }

  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
  int n;
  cin >> n;
  int cnt = 0;

  for (int i = 1; i <= n; ++i) {
    int d = 0;
    int t = i;
    while (t) {
      ++d;
      t /= 10;
    }
    if (d & 1)
      ++cnt;
  }

  cout << cnt << endl;
  return 0;
}
Problem p02952 (C++)

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

using namespace std;

int ten(int n) {
  int ret = 1;
  for (int i = 0; i < n; ++i) {
    ret *= 10;
  }
  return ret;
}

int main() {
  string n;
  cin >> n;
  int ans = 0;
  int m = n.size();
  if (n.size() % 2 == 1) {
    ans += stoi(n);
    string t(m - 1, '9');
    ans -= stoi(t);
    --m;
  }

  while (m > 0) {
    if (m % 2 == 1)
      ans += 9 * ten(m - 1);
    --m;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int ten(int n) {
  int ret = 1;
  for (int i = 0; i < n; ++i) {
    ret *= 10;
  }
  return ret;
}

int main() {
  string n;
  cin >> n;
  if (n.size() == 1) {
    cout << n[0] - '0' << endl;
    return 0;
  }
  int ans = 0;
  int m = n.size();
  if (n.size() % 2 == 1) {
    ans += stoi(n);
    string t(m - 1, '9');
    ans -= stoi(t);
    --m;
  }

  while (m > 0) {
    if (m % 2 == 1)
      ans += 9 * ten(m - 1);
    --m;
  }
  cout << ans << endl;
  return 0;
}
Problem p02952 (C++)

Buggy submission (status: Time Limit Exceeded):
//
//  main.cpp
//  test
//
//  Created by 田宇航 on 2019/8/4.
//  Copyright © 2019 田宇航. All rights reserved.
//
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
#include <string>
using namespace std;
#define INF 0x3f3f3f3f
#define MAXN 100000 + 50
#define MAXM 30000
#define ll long long
#define rep(i, n, m) for (int i = n; i <= m; ++i)
#define mod 1000000000 + 7
#define mian main
#define mem(a, b) memset(a, b, sizeof a)
#ifndef ONLINE_JUDGE
#define dbg(x) cout << #x << "=" << x << endl;
#else
#define dbg(x)
#endif
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int s[] = {0, 9, 0, 900, 0, 90000, 0, 9000000};
int main() {
  int T = read();
  while (T--) {
    int n = read();
    int num = n / 10;
    int sum = 0;
    if (num == 0)
      sum = n;
    else {
      // 100 200 300
      num = n;
      int num_d = 0;
      while (num) {
        num /= 10;
        num_d++;
      }
      for (int i = 1; i < num_d; ++i)
        sum += s[i];
      int st = 1;
      rep(i, 1, num_d - 1) st *= 10;
      if (num_d & 1) {
        sum += (n - st + 1);
      }
    }
    cout << sum << endl;
  }
}
// 100-999 99999-10000 90000


Fixed submission:
//
//  main.cpp
//  test
//
//  Created by 田宇航 on 2019/8/4.
//  Copyright © 2019 田宇航. All rights reserved.
//
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
#include <string>
using namespace std;
#define INF 0x3f3f3f3f
#define MAXN 100000 + 50
#define MAXM 30000
#define ll long long
#define rep(i, n, m) for (int i = n; i <= m; ++i)
#define mod 1000000000 + 7
#define mian main
#define mem(a, b) memset(a, b, sizeof a)
#ifndef ONLINE_JUDGE
#define dbg(x) cout << #x << "=" << x << endl;
#else
#define dbg(x)
#endif
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int s[] = {0, 9, 0, 900, 0, 90000, 0, 9000000};
int main() {
  int T = 1;
  while (T--) {
    int n = read();
    int num = n / 10;
    int sum = 0;
    if (num == 0)
      sum = n;
    else {
      // 100 200 300
      num = n;
      int num_d = 0;
      while (num) {
        num /= 10;
        num_d++;
      }
      for (int i = 1; i < num_d; ++i)
        sum += s[i];
      int st = 1;
      rep(i, 1, num_d - 1) st *= 10;
      if (num_d & 1) {
        sum += (n - st + 1);
      }
    }
    cout << sum << endl;
  }
}
// 100-999 99999-10000 90000
Problem p02952 (Python)

Buggy submission (status: Runtime Error):
def fn(i):
    return (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999)


def main():
    n = int(input())

    x = list(range(n + 1)[1:])
    x = filter(fn, x)

    print(len(x))


if __name__ == "__main__":
    main()


Fixed submission:
def fn(i):
    return (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999)


def main():
    n = int(input())
    x = range(n + 1)[1:]
    x = tuple(filter(fn, x))

    print(len(x))


if __name__ == "__main__":
    main()
Problem p02952 (C++)

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

template <typename T> void scanInt(T &x) {
  bool neg = false;
  register int c = getchar_unlocked();
  x = 0;
  for (; (c < 48 || c > 57) && (c != '-'); c = getchar_unlocked())
    ;
  if (c == '-') {
    neg = true;
    c = getchar_unlocked();
  }
  for (; c > 47 && c < 58; c = getchar_unlocked())
    x = (x << 1) + (x << 3) + c - 48;
  if (neg)
    x *= -1;
}

template <typename T> void printInt(T n) {
  if (n < 0) {
    n = -n;
    putchar_unlocked('-');
  }
  int i = 21;
  char output_buffer[21];
  do {
    output_buffer[--i] = (n % 10) + '0';
    n /= 10;
  } while (n);
  do {
    putchar_unlocked(output_buffer[i]);
  } while (++i < 21);
}

bool isOddNo(int n) {
  int Count = 0;
  while (n > 0) {
    n /= 10;
    Count++;
  }
  return Count & 1;
}

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

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

  int n, Count = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
    if (isOddNo(i))
      Count++;
  cout << Count << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

template <typename T> void scanInt(T &x) {
  bool neg = false;
  register int c = getchar_unlocked();
  x = 0;
  for (; (c < 48 || c > 57) && (c != '-'); c = getchar_unlocked())
    ;
  if (c == '-') {
    neg = true;
    c = getchar_unlocked();
  }
  for (; c > 47 && c < 58; c = getchar_unlocked())
    x = (x << 1) + (x << 3) + c - 48;
  if (neg)
    x *= -1;
}

template <typename T> void printInt(T n) {
  if (n < 0) {
    n = -n;
    putchar_unlocked('-');
  }
  int i = 21;
  char output_buffer[21];
  do {
    output_buffer[--i] = (n % 10) + '0';
    n /= 10;
  } while (n);
  do {
    putchar_unlocked(output_buffer[i]);
  } while (++i < 21);
}

bool isOddNo(int n) {
  int Count = 0;
  while (n > 0) {
    n /= 10;
    Count++;
  }
  return Count & 1;
}

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

  int n, Count = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
    if (isOddNo(i))
      Count++;
  cout << Count << endl;
}
Problem p02952 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
cnt = 0
for i in range(1, n + 1):
    if str(i) % 2 == 1:
        cnt += 1
print(cnt)


Fixed submission:
n = int(input())
cnt = 0
for i in range(1, n + 1):
    if len(str(i)) % 2 == 1:
        cnt += 1
print(cnt)
Problem p02952 (Python)

Buggy submission (status: Runtime Error):
def main(n):
    count = 0

    for i in range(n + 1):
        if str(i).__len__ % 2 == 1:
            count += 1

    print(count)


if __name__ == "__main__":
    n = int(input())

    main(n)


Fixed submission:
def main(n):
    count = 0

    for i in range(1, n + 1):
        if len(str(i)) % 2 == 1:
            count += 1

    print(count)


if __name__ == "__main__":
    n = int(input())

    main(n)
Problem p02952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

  int ans = 0;
  rep2(i, 1, N + 1) {
    int cnt = 0;
    while (i) {
      cnt += i % 10;
      i /= 10;
    }
    if (cnt % 2 == 1) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

  int ans = 0;
  rep2(i, 1, N + 1) {
    int cnt = 0;
    int tmp = i;
    while (tmp) {
      cnt++;
      tmp /= 10;
    }
    if (cnt % 2 == 1) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02952 (C++)

Buggy submission (status: 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++)
#define INF 2e9
#define MOD 1e9 + 7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;

int main() {
  int N;
  cin >> N;
  int keta = log10(N) + 1;
  if (keta % 2 == 1) {
    string hiku;
    for (int i = 0; i < keta - 2; i += 2) {
      hiku += "90";
    }
    cout << N - stoi(hiku) << endl;
  } else {
    string ans = "9";
    for (int i = 0; i < keta - 2; i += 2) {
      ans = "90" + ans;
    }
    cout << stoi(ans) << endl;
  }
}


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++)
#define INF 2e9
#define MOD 1e9 + 7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;

int main() {
  int N;
  cin >> N;
  if (N < 10) {
    cout << N << endl;
    return 0;
  }
  int keta = log10(N) + 1;
  if (keta % 2 == 1) {
    string hiku;
    for (int i = 0; i < keta - 2; i += 2) {
      hiku += "90";
    }
    cout << N - stoi(hiku) << endl;
  } else {
    string ans = "9";
    for (int i = 0; i < keta - 2; i += 2) {
      ans = "90" + ans;
    }
    cout << stoi(ans) << endl;
  }
}
Problem p02952 (C++)

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

int main() {
  int N, S, sum, ans = 0;
  cin >> N;
  while (N > 0) {
    sum = 0;
    S = N;
    while (S > 0) {
      S / 10;
      sum++;
    }
    if (sum % 2 == 1) {
      ans++;
    }
    N--;
  }
  cout << ans << endl;
}

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

int main() {
  int N, S, sum, ans = 0;
  cin >> N;
  while (N > 0) {
    sum = 0;
    S = N;
    while (S > 0) {
      S /= 10;
      sum++;
    }
    if (sum % 2 == 1) {
      ans++;
    }
    N--;
  }
  cout << ans << endl;
}
Problem p02952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int number = 0;
  for (int i = 1; i < N + 1; i++) {
    int count = 0;
    while (i != 0) {
      i /= 10;
      count++;
    }
    if (count % 2 == 1) {
      number++;
    }
  }
  cout << number << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int number = 0;
  for (int i = 1; i < N + 1; i++) {
    int count = 0;
    int a = i;
    while (a != 0) {
      a /= 10;
      count++;
    }
    if (count % 2 == 1) {
      number++;
    }
  }
  cout << number << endl;
}
Problem p02952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {
  int int1;
  cin >> int1;
  int p = 0;

  for (int int2 = 1; int2 <= int1; int2++) {
    int s = 0;
    int n = int2;
    while (n != 0) {
      n - n / 10;
      s++;
    }
    if (s % 2 == 1) {
      p++;
    }
  }
  cout << p << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int int1;
  cin >> int1;
  int p = 0;

  for (int int2 = 1; int2 <= int1; int2++) {
    int s = std::to_string(int2).length();
    if (s % 2 == 1) {
      p++;
    }
  }
  cout << p << endl;
}
Problem p02952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int e = 0;
  for (int i = 1; i <= n; i++) {
    int d = i;
    int c = 0;
    while (d > 0) {
      n /= 10;
      c++;
    }
    if (c % 2 == 1) {
      e++;
    }
  }
  cout << e;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int e = 0;
  for (int i = 1; i <= n; i++) {
    int d = i;
    int c = 0;
    while (d > 0) {
      d /= 10;
      c++;
    }
    if (c % 2 == 1) {
      e++;
    }
  }
  cout << e;
}
Problem p02952 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
ans = 0
for i in range(1, N + 1):
    if len(i) % 2 == 1:
        ans += 1
print(ans)


Fixed submission:
N = int(input())
ans = 0
for i in range(1, N + 1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)
Problem p02952 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n, k = 1, ans = 0, i = 10;
  cin >> n;
  for (; i <= n; i *= 100) {
    ans += i * 0.9;
  }
  if (n / (i / 100) > 9)
    ans += n - i / 10 + 1;
  cout << ans;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, k = 1, ans = 0, i = 10;
  cin >> n;
  if (n < 10) {
    cout << n;
    return 0;
  }
  for (; i <= n; i *= 100) {
    ans += i * 0.9;
  }
  if (n / (i / 100) > 9)
    ans += n - i / 10 + 1;
  cout << ans;
}
Problem p02952 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
#include <algorithm>
#include <map>
#include <math.h>
#include <queue>

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

  ll ans(0);
  rep(i, n + 1) {
    int c(0);
    int j = i;
    while (j) {
      j /= 10;
      c++;
    }
    if (c % 2 == 1) {
      ans++;
    }
  }
  cout << ans;
  return ans;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
#include <algorithm>
#include <map>
#include <math.h>
#include <queue>

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

  ll ans(0);
  rep(i, n + 1) {
    int c(0);
    int j = i;
    while (j) {
      j /= 10;
      c++;
    }
    if (c % 2 == 1) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
Problem p02952 (C++)

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

string s;
int n, ans = 0, nums[4];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  nums[1] = 9;
  nums[3] = 909;
  nums[5] = 90909;
  nums[7] = 90910;
  cin >> s;
  n = stoi(s);
  int l = s.size();
  if (l % 2 == 0) {
    l--;
    ans = nums[l];
  } else {
    if (s.size() > 1) {
      char c = s[0];
      s.erase(s.begin());
      int t = stoi(s);
      int hd = c - '0';
      hd--;
      hd *= pow(10, s.size());
      hd += t + 1;
      ans = hd;
      ans += nums[s.size() - 1];
    } else
      ans = n;
  }
  cout << ans;
  return 0;
}

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

string s;
int n, ans = 0, nums[8];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  nums[1] = 9;
  nums[3] = 909;
  nums[5] = 90909;
  nums[7] = 90910;
  cin >> s;
  n = stoi(s);
  int l = s.size();
  if (l % 2 == 0) {
    l--;
    ans = nums[l];
  } else {
    if (s.size() > 1) {
      char c = s[0];
      s.erase(s.begin());
      int t = stoi(s);
      int hd = c - '0';
      hd--;
      hd *= pow(10, s.size());
      hd += t + 1;
      ans = hd;
      ans += nums[s.size() - 1];
    } else
      ans = n;
  }
  cout << ans;
  return 0;
}
Problem p02952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
bool f(int x) {
  int keta = 0;
  while (x) {
    keta++;
    x / 10;
  }
  return keta % 2 == 1;
}
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (f(i))
      ans++;
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
bool f(int x) {
  int keta = 0;
  while (x) {
    keta++;
    x /= 10;
  }
  return keta % 2 == 1;
}
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (f(i))
      ans++;
  }
  cout << ans << endl;
}
Problem p02952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sum = 0;

  for (int i = 1; i <= n; i++) {
    int cnt = 1;
    while (i > 0) {
      i /= 10;
      cnt++;
    }
    if (cnt % 2 == 1) {
      sum++;
    }
  }
  cout << sum << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sum = 0;

  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    int size = s.size();

    if (size % 2 == 1) {
      sum++;
    }
  }
  cout << sum << endl;
}
Problem p02952 (C++)

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

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

  int count = 0;
  for (int i = n; i > 0; i++) {
    string s = to_string(i);
    if (s.size() == 1 || s.size() == 3 || s.size() == 5)
      count++;
  }

  cout << count << endl;
}


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

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

  int count = 0;
  for (int i = n; i > 0; i--) {
    string s = to_string(i);
    if (s.size() == 1 || s.size() == 3 || s.size() == 5)
      count++;
  }

  cout << count << endl;
}
Problem p02953 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main() {
  int N;
  string ans = "Yes";
  cin >> N;
  vint H(N);
  rep(i, N) { cin >> H[i]; }
  for (int i = N - 2; 0 <= i; i++) {
    if (H[i] > H[i + 1]) {
      if (H[i] == H[i + 1] + 1) {
        H[i]--;
      } else
        ans = "No";
    }
  }
  rep(i, N - 1) {
    if (H[i] > H[i + 1]) {
      ans = "No";
    }
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main() {
  int N;
  string ans = "Yes";
  cin >> N;
  vint H(N);
  rep(i, N) { cin >> H[i]; }
  for (int i = N - 2; 0 <= i; i--) {
    if (H[i] > H[i + 1]) {
      if (H[i] == H[i + 1] + 1) {
        H[i]--;
      } else
        ans = "No";
    }
  }
  rep(i, N - 1) {
    if (H[i] > H[i + 1]) {
      ans = "No";
    }
  }
  cout << ans;
  return 0;
}
Problem p02953 (C++)

Buggy submission (status: 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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vll H(N);
  REP(i, N)
  cin >> H[i];
  REPR(i, N - 1) {
    if (H[i] < H[i - 1])
      H[i - 1]--;
    if (H[i] < H[i - 1]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vll H(N);
  REP(i, N)
  cin >> H[i];
  REPR(i, N - 2) {
    if (H[i + 1] < H[i])
      H[i]--;
    if (H[i + 1] < H[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
Problem p02953 (C++)

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

int main() {
  int n;
  cin >> n;
  long h[10100];
  for (int i = 0; i < n; i++)
    cin >> h[i];

  for (int i = n - 2; i >= 0; i--) {
    if (h[i] > h[i + 1])
      h[i]--;
  }

  bool f = true;
  for (int i = 0; i < n - 1; i++) {
    if (h[i] > h[i + 1])
      f = false;
  }

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


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

int main() {
  int n;
  cin >> n;
  long h[101000];
  for (int i = 0; i < n; i++)
    cin >> h[i];

  for (int i = n - 2; i >= 0; i--) {
    if (h[i] > h[i + 1])
      h[i]--;
  }

  bool f = true;
  for (int i = 0; i < n - 1; i++) {
    if (h[i] > h[i + 1])
      f = false;
  }

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