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

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 1000 + 5;
const int MAX_N = 1e5 + 5;

bool is_prime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return n != 1; // exclude 1
}

int main() {
  int q;
  int sum = 0;
  cin >> q;
  vector<P> query(q);
  rep(i, q) {
    int a, b;
    cin >> a >> b;
    query[i] = make_pair(a, b);
  }
  vector<int> cusum(10020, 0);
  rep(i, 10000) {
    if (is_prime(i) && is_prime((i + 1) / 2)) {
      sum += 1;
    }
    cusum[i] = sum;
  }
  vector<int> ans(q);
  rep(i, q) {
    auto p = query[i];
    int begin = p.first;
    begin = max(0, begin - 1);
    int end = p.second;
    ans[i] = cusum[end] - cusum[begin];
  }
  rep(i, q) out(ans[i]);
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 1000 + 5;
const int MAX_N = 1e5 + 5;

bool is_prime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return n != 1; // exclude 1
}

int main() {
  int q;
  int sum = 0;
  cin >> q;
  vector<P> query(q);
  rep(i, q) {
    int a, b;
    cin >> a >> b;
    query[i] = make_pair(a, b);
  }
  vector<int> cusum(100020, 0);
  rep(i, 100020) {
    if (is_prime(i) && is_prime((i + 1) / 2)) {
      sum += 1;
    }
    cusum[i] = sum;
  }
  vector<int> ans(q);
  rep(i, q) {
    auto p = query[i];
    int begin = p.first;
    begin = max(0, begin - 1);
    int end = p.second;
    ans[i] = cusum[end] - cusum[begin];
  }
  rep(i, q) out(ans[i]);
}
Problem p03477 (Python)

Buggy submission (status: Runtime Error):
a, b, c, d = map(int, input())
if a + b == c + d:
    print("Balanced")
elif a + b < c + d:
    print("Right")
else:
    print("Left")


Fixed submission:
a, b, c, d = map(int, input().split())
if a + b == c + d:
    print("Balanced")
elif a + b < c + d:
    print("Right")
else:
    print("Left")
Problem p03477 (C++)

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

int main() {
  int A, B, C, D;
  scanf("%d %d %d %d", A, B, C, D);
  if (A + B > C + D) {
    puts("Left");
  } else if (A + B == C + D) {
    puts("Balanced");
  } else {
    puts("Right");
  }
}


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

int main() {
  int A, B, C, D;
  scanf("%d %d %d %d", &A, &B, &C, &D);
  if (A + B > C + D) {
    puts("Left");
  } else if (A + B == C + D) {
    puts("Balanced");
  } else {
    puts("Right");
  }
}
Problem p03477 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
  printf("%d\n", argc);
  for (int i = 0; i < strlen(*argv); i++) {
    printf("%s\n", argv[i]);
  }
  return 0;
}


Fixed submission:
#include <stdio.h>
int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  char x;
  if (a + b - c - d < 0)
    printf("Right");

  else if (a + b - c - d == 0)
    printf("Balanced");

  else
    printf("Left");

  return 0;
}
Problem p03477 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", a, b, c, d);
  if (a + b < c + d)
    printf("%s", "Right");
  else if (a + b > c + d)
    printf("%s", "Left");
  else
    printf("%s", "Balanced");
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b < c + d)
    printf("%s", "Right");
  else if (a + b > c + d)
    printf("%s", "Left");
  else
    printf("%s", "Balanced");
}
Problem p03477 (Python)

Buggy submission (status: Runtime Error):
A, B, C, D = map(input().split())

if A + B > C + D:
    print("Left")
elif A + B == C + D:
    print("Balanced")
else:
    print("Right")


Fixed submission:
A, B, C, D = map(int, input().split())

if A + B > C + D:
    print("Left")
elif A + B == C + D:
    print("Balanced")
else:
    print("Right")
Problem p03478 (Python)

Buggy submission (status: Runtime Error):
n, b, c = map(int, input().split(""))
ans = 0
for i in range(n + 1):
    if b <= sum(list(map(int, list(str(i))))) <= c:
        ans += i
print(ans)


Fixed submission:
n, b, c = map(int, input().split())
ans = 0
for i in range(n + 1):
    if b <= sum(list(map(int, list(str(i))))) <= c:
        ans += i
print(ans)
Problem p03478 (Python)

Buggy submission (status: Runtime Error):
k, s = map(int, input().rstrip("\n").split())
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            count += x + y + z == s

print(count)


Fixed submission:
n, lo, hi = map(int, input().rstrip("\n").split())
print(sum([i if lo <= sum(map(int, str(i))) <= hi else 0 for i in range(n + 1)]))
Problem p03478 (C++)

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

int sum(int n) {
  int a = 0;
  while (n > 0) {
    a += n % 10;
    n /= 10;
  }
  return a;
}
int main() {
  int N, A, B;
  int t = 0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++)
    if ((A <= sum(i)) && (B >= sum(i)))
      t += i;
  return t;
}

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

int sum(int n) {
  int a = 0;
  while (n > 0) {
    a += n % 10;
    n /= 10;
  }
  return a;
}
int main() {
  int N, A, B;
  int t = 0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++)
    if ((A <= sum(i)) && (B >= sum(i)))
      t += i;
  cout << t;
  return 0;
}
Problem p03478 (C++)

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

int main() {

  int n, a, b, sum;
  int count = 0;
  char *str = new char[5];

  scanf("%d", &n);
  scanf("%d", &a);
  scanf("%d", &b);

  for (int i = 1; i <= n; i++) {
    sum = 0;
    // str = to_string(i);
    sprintf(str, "%d", i);
    for (int j = 0; j < strlen(str); j++) {
      sum += (int)(str[j] - '0');
    }
    if (a <= sum && sum <= b) {
      count += i;
    }
  }

  printf("%d", count);
  return 0;
}

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

int main() {

  int n, a, b, sum;
  int count = 0;
  char *str = new char[8];

  scanf("%d", &n);
  scanf("%d", &a);
  scanf("%d", &b);

  for (int i = 1; i <= n; i++) {
    sum = 0;
    // str = to_string(i);
    sprintf(str, "%d", i);
    for (int j = 0; j < strlen(str); j++) {
      sum += (int)(str[j] - '0');
    }
    if (a <= sum && sum <= b) {
      count += i;
    }
  }

  printf("%d", count);
  return 0;
}
Problem p03478 (C++)

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int s = 0;
  for (int i = 1; i <= N; i++) {
    int c = 0;
    int n = i;
    while (i > 0) {
      c += n % 10;
      n /= 10;
    }
    if (c >= A && c <= B)
      s += i;
  }
  cout << s << endl;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int s = 0;
  for (int i = 1; i <= N; i++) {
    int c = 0;
    int n = i;
    while (n > 0) {
      c += n % 10;
      n /= 10;
    }
    if (c >= A && c <= B)
      s += i;
  }
  cout << s << endl;
}
Problem p03478 (C++)

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

int main() {
  int n, i, a, b, t, u, s = 0;
  cin >> n >> a >> b;
  for (i = 1; i <= n; i++) {
    u = 0;
    t = i;
    while (t > 0) {
      u += t % 10;
      t / -10;
    }
    if (u >= a && u <= b) {
      s += i;
    }
  }
  cout << s;
  return 0;
}

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

int main() {
  int n, i, a, b, t, u, s = 0;
  cin >> n >> a >> b;
  for (i = 1; i <= n; i++) {
    u = 0;
    t = i;
    while (t > 0) {
      u += t % 10;
      t /= 10;
    }
    if (u >= a && u <= b) {
      s += i;
    }
  }
  cout << s;
  return 0;
}
Problem p03478 (C++)

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

int main(void) {
  int A, B, N, ans = 0;

  cin >> N >> A >> B;

  for (int i = 1; i <= N; i++) {
    string s = to_string(i);
    int sum = 0;
    for (int j = 0; j < s.size(); j++)
      sum += s.at(i) - '0';

    if (sum >= A && sum <= B)
      ans += i;
  }

  cout << ans << endl;

  return 0;
}

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

int main(void) {
  int A, B, N, ans = 0;

  cin >> N >> A >> B;

  for (int i = 1; i <= N; i++) {
    string s = to_string(i);
    int sum = 0;
    for (int j = 0; j < s.size(); j++)
      sum += s.at(j) - '0';

    if (sum >= A && sum <= B)
      ans += i;
  }

  cout << ans << endl;

  return 0;
}
Problem p03478 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    int l = i;
    while (l >= 10) {
      ans += (l % 10);
      l = i / 10;
    }
    ans += l;
    if ((ans >= a) && (ans <= b))
      sum += i;
  }
  cout << sum << endl;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    int l = i;
    while (l >= 10) {
      ans += (l % 10);
      l = l / 10;
    }
    ans += l;
    if ((ans >= a) && (ans <= b))
      sum += i;
  }
  cout << sum << endl;
}
Problem p03478 (C++)

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

int main() {
  int n, a, b, j = 0, AN = 0;
  int A[1010];
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    int x = 0;
    int I = i;
    while (1) {
      if (I < 10) {
        x += I;
        if (a <= x && x <= b) {
          A[j] = i;
          j++;
          break;
        } else {
          break;
        }
      }
      x += I % 10;
      I /= 10;
    }
  }
  for (int i = 0; i < j; i++) {
    AN += A[i];
  }
  cout << AN << endl;

  return 0;
}

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

int main() {
  int n, a, b, j = 0, AN = 0;
  int A[10010];
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    int x = 0;
    int I = i;
    while (1) {
      if (I < 10) {
        x += I;
        if (a <= x && x <= b) {
          A[j] = i;
          j++;
          break;
        } else {
          break;
        }
      }
      x += I % 10;
      I /= 10;
    }
  }
  for (int i = 0; i < j; i++) {
    AN += A[i];
  }
  cout << AN << endl;

  return 0;
}
Problem p03478 (C++)

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

int main() {
  int ans = 0;
  int n, a, b;
  cin >> n >> a >> b;

  for (char i = 1; i <= n; i++) {
    int tmp = 0;

    for (int j = i; j > 0; j /= 10) {
      tmp += j % 10;
    }

    if (tmp >= a && tmp <= b) {
      ans += i;
    }
  }

  cout << ans << endl;
}

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

int main() {
  int ans = 0;
  int n, a, b;
  cin >> n >> a >> b;

  for (int i = 1; i <= n; i++) {
    int tmp = 0, j = i;

    for (int j = i; j > 0; j /= 10) {
      tmp += j % 10;
    }

    if (tmp >= a && tmp <= b) {
      ans += i;
    }
  }

  cout << ans << endl;
}
Problem p03478 (C++)

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

using namespace std;

int main() {
  int N, A, B, ans = 0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    int c = 0, j = i;
    for (; j >= 1; j++) {
      c += j % 10;
      j /= 10;
    }
    if (A <= c && c <= B) {
      ans += i;
    }
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int N, A, B, ans = 0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    int c = 0, j = i;
    for (; j >= 1;) {
      c += j % 10;
      j /= 10;
    }
    if (A <= c && c <= B) {
      ans += i;
    }
  }
  cout << ans;
  return 0;
}
Problem p03478 (C++)

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

using namespace std;

int main(void) {
  int n, a, b;
  cin >> n >> a >> b;

  int res = 0;
  for (int i = 0; i <= n; i++) {
    char s[5];
    sprintf(s, "%04d", i);
    int sum = s[0] + s[1] + s[2] + s[3] - '0' * 4;
    if (sum >= a and sum <= b) {
      res += i;
    }
  }
  cout << res << endl;
  return EXIT_SUCCESS;
}


Fixed submission:
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(void) {
  int n, a, b;
  cin >> n >> a >> b;

  int res = 0;
  for (int i = 0; i <= n; i++) {
    char s[6] = {0};
    sprintf(s, "%04d", i);
    int sum = s[0] + s[1] + s[2] + s[3] - '0' * 4;
    if (sum >= a and sum <= b) {
      res += i;
    }
  }
  cout << res << endl;
  return EXIT_SUCCESS;
}
Problem p03478 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int num = 0, n, a, b, k;
  long long sum;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    k = i;
    while (k != 0) {
      num += k % 10;
      k / 10;
    }
    if (num >= a && num <= b)
      sum += num;
    num = 0;
  }
  cout << sum << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, a, b, j, c, d = 0;
  scanf("%lld%lld%lld", &a, &b, &c);
  for (i = 1; i <= a; i++)
    if (i % 10 + i / 10 % 10 + i / 100 % 10 + i / 1000 % 10 + i / 10000 % 10 >=
            b &&
        i % 10 + i / 10 % 10 + i / 100 % 10 + i / 1000 % 10 + i / 10000 % 10 <=
            c)
      d += i;
  printf("%lld\n", d);
  return 0;
}
Problem p03478 (C++)

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

int mesugaki(int n) {
  int a = 0;
  while (n > 0) {
    a += n % 10;
    a /= 10;
  }
  return a;
}

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

  int e = 0;

  for (int i = 0; i <= b; i++) {
    int a = mesugaki(i);
    if (a >= c && a <= d) {
      e += i;
    }
  }

  cout << e << endl;
}


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

int mesugaki(int n) {
  int a = 0;
  while (n > 0) {
    a += n % 10;
    n /= 10;
  }
  return a;
}

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

  int e = 0;

  for (int i = 0; i <= b; i++) {
    int a = mesugaki(i);
    if (a >= c && a <= d) {
      e += i;
    }
  }

  cout << e << endl;
}
Problem p03478 (C++)

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

int sum(int n) {
  int x = 0;
  while (n > 0) {
    x += n % 10;
    x /= 10;
  }
  return x;
}

int main() {
  int n, a, b, s;
  cin >> n >> a >> b;
  s = 0;
  for (int i = 1; i <= n; i++) {
    int p = sum(i);
    if (p >= a && p <= b)
      s += i;
  }
  cout << s << endl;

  return 0;
}


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

int sum(int n) {
  int x = 0;
  while (n > 0) {
    x += n % 10;
    n /= 10;
  }
  return x;
}

int main() {
  int n, a, b, s;
  cin >> n >> a >> b;
  s = 0;
  for (int i = 1; i <= n; i++) {
    int p = sum(i);
    if (p >= a && p <= b)
      s += i;
  }
  cout << s << endl;

  return 0;
}
Problem p03478 (C++)

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

bool somesum(int x, int a, int b) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x / 10;
  }

  if (sum >= a and sum <= b) {
    return true;
  } else {
    return false;
  }
}
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int answer = 0;
  for (int i = 1; i <= n; i++) {
    if (somesum(i, a, b))
      answer += i;
  }
  cout << answer << endl;
}

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

bool somesum(int x, int a, int b) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }

  if (sum >= a and sum <= b) {
    return true;
  } else {
    return false;
  }
}
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int answer = 0;
  for (int i = 1; i <= n; i++) {
    if (somesum(i, a, b))
      answer += i;
  }
  cout << answer << endl;
}
Problem p03478 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int temp = 0;
    while (i > 0) {
      temp += i % 10;
      i /= 10;
    }
    if (temp <= b && temp >= a) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int temp = 0;
    int j = i;
    while (j > 0) {
      temp += j % 10;
      j /= 10;
    }
    if (temp <= b && temp >= a) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03478 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>

#define mod 1000000007

using namespace std;

int main(void) {

  int N, A, B, a, sum, count = 0;

  cin >> N >> A >> B;

  for (int i = 1; i <= N; i++) {
    a = i;
    sum = 0;
    while (a >= 0) {
      sum += a % 10;
      a /= 10;
    }
    if (sum >= A && sum <= B)
      count += i;
  }

  cout << count;

  return 0;
} // not yet

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>

#define mod 1000000007

using namespace std;

int main(void) {

  int N, A, B, a, sum, count = 0;

  cin >> N >> A >> B;

  for (int i = 1; i <= N; i++) {
    a = i;
    sum = 0;
    while (a != 0) {
      sum += a % 10;
      a /= 10;
    }
    if (sum >= A && sum <= B)
      count += i;
  }

  cout << count;

  return 0;
} // not yet
Problem p03478 (C++)

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

int main() {
  int n, a, b, ans = 0;
  cin >> n >> a >> b;
  for (int i = 0; i < n + 1; i++) {
    int sum = 0;
    while (i) {
      sum += i % 10;
      i /= 10;
    }
    if (a <= sum && sum <= b)
      ans += i;
  }
  cout << ans << endl;
}


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

int main() {
  int n, a, b, ans = 0;
  cin >> n >> a >> b;
  for (int i = 0; i < n + 1; i++) {
    int sum = 0, x = i;
    while (x) {
      sum += x % 10;
      x /= 10;
    }
    if (a <= sum && sum <= b)
      ans += i;
  }
  cout << ans << endl;
}
Problem p03478 (C++)

Buggy submission (status: Time Limit Exceeded):

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans;
  rep(i, n) {
    int count = 0;
    count += i % 10;
    i /= 10;
    count += i % 10;
    i /= 10;
    count += i % 10;
    i /= 10;
    count += i % 10;
    if (a <= count && count <= b) {
      ans += i;
    }
  }
  cout << ans << endl;
}

Fixed submission:

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    int count = 0, temp = i;
    while (temp != 0) {
      count += temp % 10;
      temp /= 10;
    }
    if (a <= count && count <= b) {
      ans += i;
    }
  }
  cout << ans << endl;
}
Problem p03479 (C++)

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

using namespace std;

int main() {
  long long x, y;
  cin >> x >> y;
  long long cnt = 0;
  while (x <= y) {
    cnt++;
    x * 2;
  }
  cout << cnt << endl;
}

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

using namespace std;

int main() {
  long long x, y;
  cin >> x >> y;
  long long cnt = 0;
  while (x <= y) {
    cnt++;
    x = x * 2;
  }
  cout << cnt << endl;
}
Problem p03479 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long x, y;
  cin >> x >> y;
  int count = 1;
  while ((x >> 1) <= y) {
    x = (x >> 1);
    count++;
  }
  cout << count;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long x, y;
  cin >> x >> y;
  int count = 1;
  while ((x << 1) <= y) {
    x = (x << 1);
    count++;
  }
  cout << count;
  return 0;
}
Problem p03479 (C++)

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

int main() {
  long long int X, Y;
  cin >> X >> Y;
  long long int a = Y / X;
  int b = 0;
  for (int c = 1; c < a + 1; c = c * 2) {
    b = b + 1;
  }
  cout << b << endl;
  return 0;
}

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

int main() {
  long long int X, Y;
  cin >> X >> Y;
  long long int a = Y / X;
  int b = 1;
  while (a > 1) {
    a = a / 2;
    b = b + 1;
  }
  cout << b << endl;
  return 0;
}
Problem p03479 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
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++)

int main() {
  int64_t x, y;
  cin >> x >> y;
  vector<int64_t> list;

  int64_t num = y / x;
  int64_t cnt = 1;
  int64_t qt = 2;
  while (num >= qt) {
    list.push_back(qt);
    qt *= 2;
  }
  int qtx = num / list.at(list.size() - 1);
  cnt += qtx * (list.size());
  cout << cnt << endl;
}


Fixed submission:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
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++)

int main() {
  int64_t x, y;
  cin >> x >> y;
  vector<int64_t> list;

  int64_t num = y / x;
  int64_t cnt = 1;
  int64_t qt = 2;
  if (qt > num) {
    cout << 1 << endl;
    return 0;
  }
  while (num >= qt) {
    list.push_back(qt);
    qt *= 2;
  }
  int qtx = num / list.at(list.size() - 1);
  cnt += qtx * (list.size());
  cout << cnt << endl;
}
Problem p03479 (C++)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
void sort2array(double *a, long *b, long n) {
  for (int i = 0; i < n; i++) {
    b[i] = i;
  }
  sort(b, b + n, [a](long i, long j) -> bool { return a[i] < a[j]; });
}
// bを何回足せばaを超えるか
int wtover(int a, int b) {
  if (a % b > 0)
    return (a / b) + 1;
  else
    return a / b;
}
const int INF = 100000001, ID_MAX = 20;
int bi_e[ID_MAX] = {0};
// 2進数表示したときの最高桁
int bi_max(long n) {
  int m = 0;
  for (m; pow(2, m) <= n; m++)
    ;
  m = m - 1;
  return m;
}
// bi_eに二進数表示したやつを代入
void bi_exs(long n) {
  rep(i, ID_MAX) { bi_e[i] = 0; }
  if (n < pow(2, ID_MAX)) {
    int m = bi_max(n);
    long l;
    for (m; m > -1; m--) {
      l = pow(2, m);
      bi_e[m] = n / l;
      n = n % l;
    }
  }
}

long int x, y;

int solve() {
  int count = 1, m = x;
  while (m * 2 <= y) {
    m = m * 2;
    count++;
  }
  return count;
}

int main() {
  int i;
  // 入力
  cin >> x >> y;
  // 処理
  int ans = solve();
  // 出力
  cout << ans << endl;
}

Fixed submission:
#include "bits/stdc++.h"

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
void sort2array(double *a, long *b, long n) {
  for (int i = 0; i < n; i++) {
    b[i] = i;
  }
  sort(b, b + n, [a](long i, long j) -> bool { return a[i] < a[j]; });
}
// bを何回足せばaを超えるか
int wtover(int a, int b) {
  if (a % b > 0)
    return (a / b) + 1;
  else
    return a / b;
}
const int INF = 100000001, ID_MAX = 20;
int bi_e[ID_MAX] = {0};
// 2進数表示したときの最高桁
int bi_max(long n) {
  int m = 0;
  for (m; pow(2, m) <= n; m++)
    ;
  m = m - 1;
  return m;
}
// bi_eに二進数表示したやつを代入
void bi_exs(long n) {
  rep(i, ID_MAX) { bi_e[i] = 0; }
  if (n < pow(2, ID_MAX)) {
    int m = bi_max(n);
    long l;
    for (m; m > -1; m--) {
      l = pow(2, m);
      bi_e[m] = n / l;
      n = n % l;
    }
  }
}

long int x, y;

int solve() {
  long int count = 1, m = x;
  while (m * 2 <= y) {
    m = m * 2;
    count++;
  }
  return count;
}

int main() {
  int i;
  // 入力
  cin >> x >> y;
  // 処理
  int ans = solve();
  // 出力
  cout << ans << endl;
}
Problem p03479 (C++)

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

int main() {
  int a, b, s = 1;

  cin >> a >> b;

  do {
    if (a * 2 <= b) {
      s++;
      a = a * 2;
    } else
      break;
  } while (a <= b);

  cout << s << endl;
  return 0;
}

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

int main() {
  long long a, b, s = 1;

  cin >> a >> b;

  do {
    if (a * 2 <= b) {
      s++;
      a = a * 2;
    } else
      break;
  } while (a <= b);

  cout << s << endl;
  return 0;
}
Problem p03479 (C++)

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

int main() {
  int x, y, s = 1;

  cin >> x >> y;

  while (x * 2 <= y) {
    x = x * 2;
    s++;
  }

  cout << s << endl;

  return 0;
}

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

int main() {
  long long int x, y, s = 1;

  cin >> x >> y;

  while (x * 2 <= y) {
    x = x * 2;
    s++;
  }

  cout << s << endl;

  return 0;
}
Problem p03479 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void) {

  ll X, Y;
  cin >> X >> Y;
  int cnt = 0;
  for (int i = X; i <= Y; ++i) {
    i += (i - 1);
    cnt++;
  }

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

Fixed submission:
#include <bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void) {

  ll X, Y;
  cin >> X >> Y;
  int cnt = 0;
  for (ll i = X; i <= Y; ++i) {
    i += (i - 1);
    cnt++;
  }

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

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

int main() {
  long long x, y;
  int counter = 1;
  while (x <= y) {
    x *= 2;
    ++counter;
  }
  cout << counter;
}

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

int main() {
  long long x, y;
  cin >> x >> y;
  int counter = 0;
  while (x <= y) {
    x *= 2;
    ++counter;
  }
  cout << counter;
}
Problem p03479 (C++)

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

int main() {
  long long x, y;
  cin >> x >> y;
  long long ans = 0;
  for (int i = x; i <= y; i = i * 2) {
    ans++;
  }
  cout << ans << endl;
}

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

int main() {
  long long x, y;
  cin >> x >> y;
  long long ans = 0;
  for (long long i = x; i <= y; i = i * 2) {
    ans++;
  }
  cout << ans << endl;
}
Problem p03479 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t X, Y;
  cin >> X >> Y;
  int64_t x = Y / X;
  int sum = 1;
  int ans = 0;
  for (int i = 0; sum <= x; i++) {
    ans++;
    sum *= 2;
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t X, Y;
  cin >> X >> Y;
  int64_t x = Y / X;
  int64_t sum = 1;
  int ans = 0;
  for (int i = 0; sum <= x; i++) {
    ans++;
    sum *= 2;
  }
  cout << ans << endl;
  return 0;
}
Problem p03479 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int dfs(unsigned long long now, int len);
unsigned long long x, y;
int maxi = 1;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> y;
  int ans = dfs(x, 1);
  cout << ans << endl;
  return 0;
}
int dfs(unsigned long long now, int len) {
  if (now * 2 > y)
    return len;
  for (int i = 2; now * i <= y; i++) {
    int a = dfs(now * i, len + 1);
    maxi = max(maxi, a);
  }
  return maxi;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int dfs(unsigned long long now, int len);
unsigned long long x, y;
int maxi = 1;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> y;
  int ans = dfs(x, 1);
  cout << ans << endl;
  return 0;
}
int dfs(unsigned long long now, int len) {
  if (now * 2 > y)
    return len;
  int a = dfs(now * 2, len + 1);
  maxi = max(maxi, a);
  return maxi;
}
Problem p03479 (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;

int main() {
  long long x, y;
  cin >> x >> y;

  long long ans = 1;
  while (1) {
    x *= 2;
    if (x <= y) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

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

int main() {
  long long x, y;
  cin >> x >> y;

  long long ans = 1;
  while (1) {
    x *= 2;
    if (x <= y) {
      ans++;
    } else {
      break;
    }
  }

  cout << ans << endl;
  return 0;
}
Problem p03479 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ios                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart) / CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair<int, int> dbl;
const int maxInt = 1e9 * 2;
const lli maxLong = 1e18 * 2;
int main() {
  lli a, b;
  cin >> a >> b;
  int best = 0;
  for (lli i = a; i < a + sqrt(a); i++) {
    lli x = i;
    int curr = 0;
    while (x <= b) {
      x *= 2;
      curr++;
    }
    best = max(curr, best);
  }
  cout << best;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ios                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart) / CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair<int, int> dbl;
const int maxInt = 1e9 * 2;
const lli maxLong = 1e18 * 2;
int main() {
  lli a, b;
  cin >> a >> b;
  int best = 0;
  for (lli i = a; i <= a + 10000; i++) {
    lli x = i;
    int curr = 0;
    while (x <= b) {
      x *= 2;
      curr++;
    }
    best = max(curr, best);
  }
  cout << best;
}
Problem p03479 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long x, y;
  int ans = 0;
  while (x * 2 <= y) {
    x *= 2;
    ++ans;
  }
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long x, y;
  int ans = 1;
  cin >> x >> y;
  while (x * 2 <= y) {
    x *= 2;
    ++ans;
  }
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}
Problem p03479 (C++)

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

ll X, Y;

int main(void) {

  scanf("%lld %lld", &X, &Y);

  int ans = 1, cnt = 2;
  for (int i = 1; X * i * cnt <= Y; i *= 2)
    ++ans;
  printf("%d\n", ans);

  return 0;
}


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

ll X, Y;

int main(void) {

  scanf("%lld %lld", &X, &Y);

  int ans = 1, cnt = 2;
  for (ll i = 1; X * i * cnt <= Y; i *= 2)
    ++ans;
  printf("%d\n", ans);

  return 0;
}
Problem p03479 (C++)

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

int main() {
  long x, y, count = 0;
  for (long i = x; i <= y; i *= 2) {
    count++;
  }
  cout << count << endl;
  return 0;
}

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

int main() {
  long x, y, count = 0;
  cin >> x >> y;
  for (long i = x; i <= y; i *= 2) {
    count++;
  }
  cout << count << endl;
  return 0;
}
Problem p03479 (C++)

Buggy submission (status: Time Limit Exceeded):
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  llong X, Y, ans = 0;
  cin >> X >> Y;

  for (int i = X; i <= Y;) {
    i *= 2;
    ans += 1;
  }
  cout << 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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  llong X, Y, ans = 0;
  cin >> X >> Y;

  while (X <= Y) {
    X *= 2;
    ans++;
  }
  cout << ans << endl;
}
Problem p03479 (C++)

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

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 1;
  while (true) {
    n = n << 1;
    if (n > m)
      break;
    ans++;
  }
  cout << ans << endl;
}


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

int main() {
  long long n, m;
  cin >> n >> m;
  int ans = 1;
  while (true) {
    n = n << 1;
    if (n > m)
      break;
    ans++;
  }
  cout << ans << endl;
}
Problem p03479 (C++)

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

int main() {
  long long int X, Y;
  cin >> X >> Y;
  long long int a = Y / X;
  int k = 1;
  int c = 0;
  while (k <= a) {
    k *= 2;
    c++;
  }
  cout << c << endl;
}


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

int main() {
  long long int X, Y;
  cin >> X >> Y;
  long long int a = Y / X;
  long long int k = 1;
  int c = 0;
  while (k <= a) {
    k *= 2;
    c++;
  }
  cout << c << endl;
}
Problem p03479 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  ll x, y;
  cin >> x >> y;
  int res = 1, tmp = x;
  while (tmp * 2 <= y) {
    tmp *= 2;
    res++;
  }
  cout << res << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  ll x, y;
  cin >> x >> y;
  ll res = 1, tmp = x;
  while (tmp * 2 <= y) {
    tmp *= 2;
    res++;
  }
  cout << res << endl;
  return 0;
}
Problem p03479 (C++)

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

using ll = long long;

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

  int ans = 1;

  for (ll i = x; i <= y; ++i) {
    int len = 1;

    ll pre = i;
    while (true) {
      pre *= 2;
      if (pre > y)
        break;
      len++;
    }

    if (ans > len)
      break;
    ans = max(ans, len);
  }

  cout << ans << endl;
  return EXIT_SUCCESS;
}


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

using ll = long long;

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

  int ans = 1;

  for (ll i = x; i <= y; ++i) {
    int len = 1;

    ll pre = i;
    while (true) {
      pre *= 2;
      if (pre > y)
        break;
      len++;
    }

    if (ans >= len)
      break;
    ans = max(ans, len);
  }

  cout << ans << endl;
  return EXIT_SUCCESS;
}
Problem p03479 (C++)

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

int main() {
  long long x, y;
  cin >> x >> y;
  int n = x;
  int cnt = 0;
  while (n <= y) {
    cnt++;
    n *= 2;
  }
  cout << cnt << endl;
}

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

int main() {
  long long x, y;
  cin >> x >> y;
  long long n = x;
  int cnt = 0;
  while (n <= y) {
    cnt++;
    n *= 2;
  }
  cout << cnt << endl;
}
Problem p03479 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, y;
  int cnt = 0;
  cin >> x >> y;
  for (int i = x; i <= y;) {
    i *= 2;
    cnt++;
  }
  cout << cnt;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, y;
  int cnt = 0;
  cin >> x >> y;
  for (long long int i = x; i <= y;) {
    i *= 2;
    cnt++;
  }
  cout << cnt;
}
Problem p03480 (C++)

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

int main() {
  char s[1000];

  cin >> s;
  int n = strlen(s);
  int t = n;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1]) {
      t = min(t, max(i + 1, n - i - 1));
    }
  }

  cout << t << endl;

  return 0;
}


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

int main() {
  char s[10000000];

  cin >> s;
  int n = strlen(s);
  int t = n;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1]) {
      t = min(t, max(i + 1, n - i - 1));
    }
  }

  cout << t << endl;

  return 0;
}
Problem p03480 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>
typedef long long ll;
int len, fin;
char x[10020];
int main() {
  scanf(" %s", x);
  len = strlen(x);
  for (fin = 1; fin <= len; fin++) {
    int l = len - fin, r = fin - 1;
    if (l > r)
      continue;
    if (x[len / 2] != x[l] || x[len / 2] != x[r])
      break;
  }
  printf("%d\n", fin - 1);
}


Fixed submission:
#include <stdio.h>
#include <string.h>
typedef long long ll;
int len, fin;
char x[100020];
int main() {
  scanf(" %s", x);
  len = strlen(x);
  for (fin = 1; fin <= len; fin++) {
    int l = len - fin, r = fin - 1;
    if (l > r)
      continue;
    if (x[len / 2] != x[l] || x[len / 2] != x[r])
      break;
  }
  printf("%d\n", fin - 1);
}
Problem p03480 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

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

  int n = S.size();

  int sn = 0;
  char val = 'a';
  while (sn <= n) {
    sn++;

    int x = sn - 1;
    int y = n - sn;

    // cout << "sn: " << sn << ", x: " << x << ", y: " << y << endl;
    if (x < y)
      continue;
    if (S.at(x) != S.at(y))
      break;
    if (val == 'a')
      val = S.at(x);
    if (val != S.at(x))
      break;
  }

  cout << (sn - 1) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

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

  int n = S.size();

  int sn = 0;
  char val = 'a';
  while (sn <= n) {
    sn++;

    int x = sn - 1;
    int y = n - sn;
    if (x > n || y < 0)
      break;

    // cout << "sn: " << sn << ", x: " << x << ", y: " << y << endl;
    if (x < y)
      continue;
    if (S.at(x) != S.at(y))
      break;
    if (val == 'a')
      val = S.at(x);
    if (val != S.at(x))
      break;
  }

  cout << (sn - 1) << endl;
}
Problem p03480 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map<int, int> mp;
vector<int> V;
#define debug(x) cerr << #x << ": " << x << "\n";
#define INF (1 << 29) // 53687091
#define INFLL (1ll << 58)
#define EPS (1e-10)
static const int MAX = (int)1e5;
static const int MOD = (int)1e9 + 7;
static const int NMAX = 50;
static const int MMAX = 50;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int tx[8] = {-1, 0, 1, -1, 1, -1, 0, 1},
          ty[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
string s;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;

  int ans = s.size();
  for (int i = 0; i <= s.size() - 2; i++) {
    if (s[i] != s[i + 1]) {
      int res = max(i + 1, (int)s.size() - i - 1);
      ans = min(ans, res);
    }
  }
  cout << ans << "\n";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map<int, int> mp;
vector<int> V;
#define debug(x) cerr << #x << ": " << x << "\n";
#define INF (1 << 29) // 53687091
#define INFLL (1ll << 58)
#define EPS (1e-10)
static const int MAX = (int)1e5;
static const int MOD = (int)1e9 + 7;
static const int NMAX = 50;
static const int MMAX = 50;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int tx[8] = {-1, 0, 1, -1, 1, -1, 0, 1},
          ty[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
string s;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;

  int n = s.size();
  int ans = n;
  for (int i = 1; i < n; i++) {
    if (s[i - 1] != s[i]) {
      int res = max(i, n - i);
      ans = min(ans, res);
    }
  }
  cout << ans << "\n";
  return 0;
}
Problem p03480 (Python)

Buggy submission (status: Runtime Error):
def main():
    s = input()
    if len(s) % 2 == 1:
        sl = len(s) // 2 + 1
    else:
        sl = len(s) // 2
    ss = s[-sl:sl]
    for i in range(sl, len(s) + 1):
        ss = s[-i - 1] + ss + s[i]
        if ss.count("0") == len(ss) or ss.count("1") == len(ss):
            continue
        print(i)
        return


main()


Fixed submission:
def main():
    s = input()
    i = j = len(s) // 2
    if len(s) % 2 == 0:
        j -= 1
    ss = s[j]
    while len(s) > i and j >= 0 and ss == s[i] and ss == s[j]:
        i += 1
        j -= 1
    print(i)


main()
Problem p03480 (Python)

Buggy submission (status: Runtime Error):
S = input()
b = []
for i in range(len(S) - 1):
    if S[i : i + 2] == "01" or S[i : i + 2] == "10":
        b.append(len(S) - (i + 1) if i < len(S) // 2 else i + 1)

print(min(b))


Fixed submission:
S = input()
b = []
for i in range(len(S) - 1):
    if S[i : i + 2] == "01" or S[i : i + 2] == "10":
        b.append(len(S) - (i + 1) if i < len(S) // 2 else i + 1)

print(min(b) if len(b) != 0 else len(S))
Problem p03480 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, s, e) for (int i = s; i < (e); i++)
#define All(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

  string s;
  cin >> s;
  vector<int> ans;
  REP(i, s.size() - 1) {
    if (s[i] != s[i + 1])
      ans.pb(max(i + 1, (int)s.size() - i - 1));
  }
  cout << *min_element(All(ans)) << "\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, s, e) for (int i = s; i < (e); i++)
#define All(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

  string s;
  cin >> s;
  vector<int> ans;
  REP(i, s.size() - 1) {
    if (s[i] != s[i + 1])
      ans.pb(max(i + 1, (int)s.size() - i - 1));
  }
  if (ans.empty())
    ans.pb(s.size());
  cout << *min_element(All(ans)) << "\n";
  return 0;
}