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

#include <iostream>
using namespace std;

int main() {
  int n;
  for (int i = 1; i >= 0; i++) {
    cin >> n;
    if (n == 0)
      break;
    cout << "Case " << i << ": " << n << "\\n";
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x, i = 1;
  cin >> x;
  while (x != 0) {
    cout << "Case" << i << ":" << x << "\\n";
    i++;
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  int b, i;
  i = 0;
  while (1) {
    scanf("%d", &b);
    if (b == 0)
      break;
    i += 1;
    printf("Case %d: %d\\n", i, b);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>

int main() {
  int b, i;
  i = 0;
  scanf("%d", b);
  while (1) {
    i += 1;
    printf("Case %d:%d\\n", i, b);
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
int main() {
  for (int i = 1;; i++) {
    int x;
    scanf("%d", &x);
    if (x == 0) {
      break;
    }
    printf("Case %d: %d\\n", i, x);
  };
  return 0;
}


Error: TLE

Fixed submission:

#include <cstdio>
int main() {
  for (int i = 1;; i++) {
    int x;
    scanf("%d", &x);
    printf("Case %d: %d\\n", i, x);
  };
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int i, x;
  for (i = 1;; i++) {
    scanf("%d", &x);
    if (x == 0) {
      return 0;
    } else {
      printf("Case %d: %d\\n", i, x);
    }
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int i, x;
  for (i = 1;; i++) {
    scanf("%d", &x);
    if (i == 0) {
      return 0;
    } else {
      printf("Case i:%d\\n", i, x);
    }
  }
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int count = 1;
  int a[10000];
  while (true) {
    cin >> a[count];
    if (a[count] == 0) {
      break;
    }
    count++;
  }
  for (int i = 1; i < count; i++) {
    cout << "Case " << i << ": " << a[i] << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int count = 0;
  int a[1000];
  while (true) {
    cin >> a[count];
    if (a[count] == 0) {
      break;
    }
    count++;
  }
  for (int i = 0; i < count; i++) {
    cout << "Case " << i << ": " << a[i] << endl;
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, i;
  i = 0;
  while (1) {
    cin >> a;
    if (a == 0) {
      break;
    } else {
      i += 1;
      cout << "Case " << i << ": " << a << "\\n";
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int i, x;
  while (1) {
    for (i == 1;; i++) {
      cin >> x;
      if (x = 0) {
        break;
      } else {
        cout << "Case " << i << ": " << x;
      }
    }
  }

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int x, i = 1;
  while (1) {
    cin >> x;
    if (x != 0) {
      cout << "Case"
           << " " << i << ": " << x << endl;
      i++;
    } else {
      return 0;
    }
  }
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int x, i = 1;
  while (1) {
    cin >> x;
    if (x != 0) {
      cout << "case"
           << " " << i << ": " << x << endl;
      i++;
    }
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int x, i;
  i = 1;
  while (x >= 0, x <= 10000) {
    cin >> x;
    if (x == 0) {
      break;
    }
    cout << "Case " << i << ": " << x << endl;
    i++;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, i;
  cin >> x;
  for (x >= 0; x <= 10000;) {
    if (x == 0)
      break;
    cout << "Case " << i << " " << x << endl;
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  int x, count = 1;

  while (1) {
    cin >> x;

    if (x != 0)
      cout << "Case " << count << ": " << x << endl;
    else
      break;

    count++;
  }

  return 0;
}


Error: 1

Fixed submission:

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

int main() {

  int x;

  while (1) {
    cin >> x;

    if (x != 0)
      cout << x << endl;
    else
      return 1;
  }

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int x;
  int count = 1;
  cin >> x;
  while (x != 0) {
    cout << "Case " << count << ": " << x << endl;
    cin >> x;
    count++;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x;
  int count = 1;
  cin >> x;
  while (x != 0) {
    cout << "Case " << count << ":" << x << endl;
    count++;
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int num[10000], n;
  n = 0;
  while (1) {
    scanf("%d", &num[n]);
    if (num[n] == 0)
      break;
    n = n + 1;
  }
  n = 0;
  while (num[n] != 0) {
    printf("Case %d: %d\\n", n + 1, num[n]);
    n = n + 1;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  int num[10000], n;
  n = 0;
  while (1) {
    scanf("%d", &num[n]);
    if (num[n] == 0)
      break;
    n = n + 1;
  }
  while (num[n] != 0, n++) {
    printf("Case %d: %d\\n", n, num[n]);
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int x;
  int i = 1;

  while (1) {
    cin >> x;
    if (x == 0)
      break;
    else
      cout << "Case"
           << " " << i << ":"
           << " " << x << endl;
    i += 1;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x;
  int i = 1;
  cin >> x;

  while (1) {
    if (x == 0)
      break;
    else
      cout << "Case" << i << ":"
           << " " << x << endl;
    i += 1;
  }

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int x, c = 0;
  while (true) {
    cin >> x;

    if (x == 0) {
      break;
    }
    c = c + 1;
    cout << "Case " << c << ": " << x << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int i = 1;
  while (true) {
    if (i == 0) {
      break;
    }

    cout << i << endl;
  }

  cout << i << endl;
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int x = 1;
  int i = 1;

  for (i = 1; x != 0; i++) {

    cin >> x;
    if (x == 0)
      break;
    cout << "Case"
         << " " << i << ":"
         << " " << x << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x;
  cin >> x;
  int i = 0;
  while (x != 0) {

    if (x == 0)
      break;
    cout << "Case"
         << " " << i << ":"
         << " " << x << endl;
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
  int x[10000], i = 0, j;

  while (1) {
    scanf("%d", &x[i]);
    if (x[i] == 0) {
      break;
    }
    i++;
  }

  for (j = 1; j < i + 1; j++) {
    printf("Case %d: %d\\n", j, x[j - 1]);
  }

  return 0;
}

Error: 0

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
  int x[100], i = 0, j;

  while (1) {
    scanf("%d", &x[i]);
    if (x[i] == 0) {
      break;
    }
    i++;
  }

  for (j = 1; j < i + 1; j++) {
    printf("Case %d: %d\\n", j, x[j - 1]);
  }

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int a, b, c, d, i = 0;
  while (1) {
    scanf("%d", &a);
    i++;
    if (a == 0)
      break;
    printf("Case %d: %d\\n", i, a);
  }
}


Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int a, b, c, d, i = 0;
  while (1) {
    scanf("%d", &a);
    i++;
    printf("Case %d: %d\\n", i, a);
  }
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
int main() {
  int i, x;
  for (i = 1;; i++) {
    std::cin >> x;
    if (x)
      std::cout << "Case " << i << ": " << x << std::endl;
    else
      return 0;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
int main() {
  int i, x;
  for (i = 1;; i++) {
    std::cin >> x;
    std::cout << "Case " << i << ": " << x << std::endl;
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

// Copyright 2015 KanatoNagayama
#include <iostream>
#include <vector>
using std ::cin;
using std ::cout;
using std ::endl;
using std ::vector;
int main() {
  vector<int> v(100000);
  int i = 0;
  while (true) {
    cin >> v[i];
    if (v[i] == 0)
      break;
    i++;
  }
  for (int k = 0; k < i; k++) {
    cout << "Case " << k + 1 << ": " << v[k] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

// Copyright 2015 KanatoNagayama
#include <iostream>
#include <vector>
using std ::cin;
using std ::cout;
using std ::endl;
using std ::vector;
int main() {
  vector<int> v(5000);
  int i = 0;
  while (true) {
    cin >> v[i];
    if (v[i] == 0)
      break;
    i++;
  }
  for (int k = 0; k < i; k++) {
    cout << "Case " << k + 1 << ": " << v[k] << endl;
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int D[10000], C = 0;

  while (true) {
    cin >> D[C];

    if (D[C] == 0) {
      goto Exit;
    }

    C++;
  }

Exit:;

  for (int i = 0; i < C; i++) {
    cout << "Case " << i + 1 << ": " << D[i] << endl;
  }

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int D[100], C = 0;

  while (true) {
    cin >> D[C];

    if (D[C] == 0) {
      goto Exit;
    }

    C++;
  }

Exit:;

  for (int i = 0; i < C; i++) {
    cout << "Case " << C << ": " << D[C] << endl;
  }

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

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF 100000000

#define MAX_N 10000
#define MAX_M 100

typedef long long int ll;
using namespace std;

int main() {

  int x;
  int i = 0;
  while (true) {

    scanf("%d", &x);
    if (x != 0) {
      i++;
      printf("Case %d: %d\\n", i, x);
    } else
      break;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF 100000000

#define MAX_N 10000
#define MAX_M 100

typedef long long int ll;
using namespace std;

int main() {

  int x;
  int i = 0;
  while (true) {

    scanf("%d", &x);
    if (x != 0) {
      i++;
      printf("Case %s: %d\\n", i, x);
    } else
      break;
  }

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

#include <iostream>

using namespace std;

int main() {
  long box[10001];
  int i = 0;

  while (1) {
    cin >> box[i];
    if (box[i] == 0) {
      break;
    }
    i++;
  }

  for (int j = 0; j < i; j++) {
    cout << "Case"
         << " " << j + 1 << ":"
         << " " << box[j] << endl;
  }

  return 0;
}


Error: -11

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int i;
  vector<int> v;

  i = 0;

  while (1) {
    cin >> v[i];

    if (v[i] == 0) {
      for (int j = 0; j < i; j++) {
        cout << "Case " << j + 1 << ": " << v[j] << endl;
        break;
      }
    }

    i++;
  }

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int buffer, i = 1;
  cin >> buffer;
  while (buffer != 0) {
    cout << "Case " << i << ": " << buffer << endl;
    cin >> buffer;
    i++;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int buffer, i = 1;
  cin >> buffer;
  while (buffer != 0) {
    cout << "Case " << i << ": " << buffer << endl;
    i++;
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int x = 0;
  int i = 0;
  while (1) {
    cin >> x;
    if (x == 0) {
      break;
    }
    i++;
    cout << "Case " << i << ": " << x << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x = 0;
  cin >> x;
  for (int i = 0; i >= 0; i++) {
    if (x != 0) {
      cout << "Case"
           << " " << i << "; " << x << endl;
    }
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int x, count;

  while (1) {
    cin >> x;
    if (x == 0) {
      break;
    }
    count++;
    cout << "Case " << count << ": " << x << "\\n";
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x;

  cin >> x;
  while (x != 0) {
    cout << x << "\\n";
  }

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  int *num = new int[1];
  int *t = new int[1];

  int count = 0;
  while (true) {
    cin >> num[count];
    if (num[count] == 0)
      break;
    count++;
    delete[] t;
    t = new int[count];
    for (int loop = 0; loop < count; loop++)
      t[loop] = num[loop];
    delete[] num;
    num = new int[count + 1];
    for (int loop = 0; loop < count; loop++)
      num[loop] = t[loop];
  }
  for (int loop = 0; loop < count; loop++)
    cout << "Case " << loop + 1 << ": " << num[loop] << endl;

  delete[] num;
  delete[] t;
  num = t = 0;

  return 0;
}

Error: MLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int *num = new int[1];
  int *t = new int[1];

  int count = 0;
  while (true) {
    cin >> num[count];
    if (num[count] == 0)
      break;
    count++;
    t = new int[count];
    for (int loop = 0; loop < count; loop++)
      t[loop] = num[loop];
    num = new int[count + 1];
    for (int loop = 0; loop < count; loop++)
      num[loop] = t[loop];
  }
  for (int loop = 0; loop < count; loop++)
    cout << "Case " << loop + 1 << ": " << num[loop] << endl;

  delete[] num;
  num = 0;

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int x;

  for (int i = 1;; i++) {
    cin >> x;
    if (x == 0) {
      break;
    }

    cout << "Case " << i << ": " << x << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int x;

  while (1) {
    cin >> x;
    cout << "Case " << x << endl;
  }

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

#include <iostream>
using namespace std;

int main(void) {

  int n;
  int count = 1;

  while (1) {
    cin >> n;
    if (n == 0)
      break;

    cout << "Case " << count << ": " << n << endl;
    count++;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {

  int i = 1, n, m;
  int A[1000];

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    A[i] = n;
    i++;
  }

  m = i - 1;

  for (i = 1; i <= m; i++)
    cout << "Case " << i << ": " << A[i] << endl;

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <stdlib.h>
int main() {
  int i, x;
  x = 1;
  srand(x);
  for (i = 1; i <= 10000; i++) {
    scanf("%d", &x);
    if (x == 0) {
      break;
    }
    printf("Case %d: %d\\n", i, x);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int x, i;
  x = 0;
  for (i = 1; 0 <= x <= 1000; i++) {
    scanf("%d", &x);
    printf("Case i: %d\\n", x);
  }
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int i, x;
  for (i = 1;; i++) {
    cin >> x;
    if (x != 0) {
      cout << "Case " << i << ": " << x << endl;
    } else {
      break;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int i = 0, x[100];
  do {
    cin >> x[i];
    i++;
  } while (x[i - 1] != 0);
  for (i = 0; x[i] != 0; i++) {
    cout << "Case " << i + 1 << ": " << x[i] << endl;
  }
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int i, D;
  for (i = 0; i < 10000; i++) {
    scanf("%d", &D);
    if (D == 0)
      break;
    printf("Case %d: %d\\n", i + 1, D);
  }
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
int main() {
  int i, D[10000], x;
  for (i = 0; i < 10000; i++) {
    scanf("%d", &D[i]);
    if (D[i] == 0) {
      x = i + 1;
      break;
    }
  }
  for (i = 0; i < x; i++) {
    printf("Case %d: %d\\n", i + 1, D[i]);
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int x;
  int i = 0;
  while (cin >> x) {
    if (x == 0)
      break;
    i++;
    printf("Case %d: %d\\n", i, x);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int x;
  int i = 0;
  while ((scanf("%d", &x)) != 0) {
    i++;
    printf("Case %d: %d\\n", i, x);
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  for (int x, y = 1;; y++) {
    cin >> x;
    if (x == 0)
      break;
    cout << "Case " << y << ": " << x << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  for (int x, y = 1;; y++) {
    cin >> x;
    if (x = 0)
      break;
    cout << "Case " << y << ": " << x << endl;
  }
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int a[10000];
  int total = 0;
  for (int i = 0; i <= 10000; i++) {
    int tmp;
    cin >> tmp;
    //        if(tmp < 0 || tmp >= 10000) return -1;
    if (tmp == 0) {
      break;
    }
    a[i] = tmp;
    total++;
  }

  for (int j = 0; j <= total - 1; j++)
    cout << "Case " << j + 1 << ": " << a[j] << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int a[10000];
  int total = 0;
  for (int i = 0; i <= 10000; i++) {
    int tmp;
    cin >> tmp;
    if (tmp < 0 || tmp >= 10000)
      return -1;
    if (tmp == 0) {
      break;
    }
    a[i] = tmp;
    total++;
  }

  for (int j = 0; j <= total - 1; j++)
    cout << "Case " << j + 1 << ": " << a[j] << endl;

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  int x, i = 0;

  while (1) {
    cin >> x;
    if (x != 0) {
      cout << "Case " << ++i << ": " << x << endl;
    } else {
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int x, i = 0;

  while (1) {
    cin >> x;
    if (x != 0) {
      cout << "Case " << ++i << ": " << x << endl;
    }
  }
  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {

  for (int i = 1;; i++) {
    int x;
    cin >> x;
    if (x == 0)
      break;

    cout << "Case " << i << ": " << x << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {

  for (int i = 1;; i++) {
    int x;
    cin >> x;

    cout << "Case " << i << ": " << x << endl;
  }
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main(void) {
  int i = 1;
  int x;

  do {
    scanf("%d", &x);

    if (x == 0)
      break;
    else
      printf("Case %d: %d\\n", i, x);

    i++;
  } while (x > 0);

  return (0);
}

Error: 0

Fixed submission:

#include <stdio.h>

int main(void) {
  int i;
  int data[20];
  data[0] = 1;

  for (i = 1; data[i - 1] > 0; i++)
    scanf("%d", &data[i]);

  for (i = 1; data[i] > 0; i++)
    printf("Case %d: %d\\n", i, data[i]);

  return (0);
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  for (int i = 1; i; i++) {
    int a;
    cin >> a;
    if (a == 0) {
      break;
    }
    cout << "Case " << i << ": " << a << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  while (true) {
    for (int i = 1; i; i++) {
      int a;
      cin >> a;
      if (a == 0) {
        break;
      }
      cout << "Case " << i << ": " << a << endl;
    }
  }
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <fstream>
#include <iostream>
using namespace std;

int main() {

  int val;
  int i = 1;

  cin >> val;

  while (val) {
    cout << "Case " << i << ": " << val << endl;
    cin >> val;
    i++;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <fstream>
#include <iostream>
using namespace std;

int main() {

  int val[7000000];

  for (int i = 0; i < 7000000; i++) {
    cin >> val[i];
    if (val[i] == 0)
      goto end;
  }
end:

  for (int i = 0; i < 7000000; i++) {
    cout << "Case " << i << ": " << val[i] << endl;
    if (val[i] == 0) {
      goto rend;
    }
  }
rend:

  return 0;
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
  int x = 0;
  int i = 1;
  while (1) {
    CI x;
    if (x == 0) {
      return 0;
    }
    CO "Case " << i << ": " << x E++ i;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
  int x = 0;
  int i = 1;
  while (1) {
    CI x;
    CO "case " << i << ":" << x E++ i;
  }
}
Problem p02396 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int x;
  int i = 1;

  while (1) {
    cin >> x;
    if (x == 0)
      break;
    cout << "Case " << i << ": " << x << endl;
    i++;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x;
  int i = 1;

  while (1) {
    cin >> x;
    if (x = 0)
      break;
    cout << "Case " << i << ": " << x << endl;
    i++;
  }
}
Problem p02396 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int x[10000];
  for (int i = 1; i < 10001; i = i + 1) {
    cin >> x[i];
  }

  for (int i = 1; i < 10001; i = i + 1) {
    if (x[i] == 0) {
      break;
    } else {
      cout << "Case " << i << ": " << x[i] << endl;
    }
  }
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x[10000];
  for (int i = 0; i < 10001; i = i + 1) {
    cin >> x[i];
  }

  for (int i = 0; i < 10001; i = i + 1) {
    if (x[i] = 0) {
      i = 10001;
      break;
    } else {
      cout << "Case " << i << ": " << x[i] << endl;
    }
  }
  return 0;
}