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

#include <iostream>
using namespace std;
int main(void) {
  while (1) {
    char c;
    int goban[3][3] = {0}, result = 0, judge = 0;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        cin >> c;
        if (c == '0')
          return 0;
        if (c == 'b')
          goban[i][j] = 1;
        else if (c == 'w')
          goban[i][j] = -1;
        else
          goban[i][j] = 0;
      }
    }
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        judge += goban[i][j];
      }
      if (judge == 3)
        result = 1;
      else if (judge == -3)
        result = -1;

      judge = 0;
    }
    for (int j = 0; j < 3; j++) {
      for (int i = 0; i < 3; i++) {
        judge += goban[i][j];
      }
      if (judge == 3)
        result = 1;
      else if (judge == -3)
        result = -1;

      judge = 0;
    }
    for (int i = 0; i < 3; i++) {
      judge += goban[i][i];
    }
    if (judge == 3)
      result = 1;
    else if (judge == -3)
      result = -1;

    judge = 0;

    for (int i = 0; i < 3; i++) {
      judge += goban[i][2 - i];
    }
    if (judge == 3)
      result = 1;
    else if (judge == -3)
      result = -1;

    judge = 0;

    if (result == 1) {
      cout << "b" << endl;
    } else if (result == -1) {
      cout << "w" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  while (1) {
    char c;
    int goban[3][3] = {0}, result = 0, judge = 0;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        cin >> c;
        if (c == '0')
          break;
        if (c == 'b')
          goban[i][j] = 1;
        else if (c == 'w')
          goban[i][j] = -1;
        else
          goban[i][j] = 0;
      }
    }
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        judge += goban[i][j];
      }
      if (judge == 3)
        result = 1;
      else if (judge == -3)
        result = -1;

      judge = 0;
    }
    for (int j = 0; j < 3; j++) {
      for (int i = 0; i < 3; i++) {
        judge += goban[i][j];
      }
      if (judge == 3)
        result = 1;
      else if (judge == -3)
        result = -1;

      judge = 0;
    }
    for (int i = 0; i < 3; i++) {
      judge += goban[i][i];
      if (judge == 3)
        result = 1;
      else if (judge == -3)
        result = -1;

      judge = 0;
    }
    for (int i = 0; i < 3; i++) {
      judge += goban[i][2 - i];
      if (judge == 3)
        result = 1;
      else if (judge == -3)
        result = -1;

      judge = 0;
    }

    if (result == 1) {
      cout << "b" << endl;
    } else if (result == -1) {
      cout << "w" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}
Problem p00184 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int judge(int);

int main() {
  int n, age;

  for (;;) {
    int cnt[7] = {0};

    cin >> n;
    if (n == 0)
      break;

    for (int i = 0; i < n; i++) {
      cin >> age;
      cnt[judge(age)]++;
    }
    for (int i = 0; i < 7; i++)
      cout << cnt[i] << endl;
  }
  return 0;
}

int judge(int age) { return min(age / 10, 6); }

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int judge(int);

int main() {
  int n, age;

  for (;;) {
    int cnt[7] = {0};

    cin >> n;
    if (n == 0)
      break;

    for (int i = 0; i < n; i++) {
      cin >> age;
      cnt[judge(age)]++;
    }
    for (int i = 0; i < 7; i++)
      cout << cnt[i] << endl;
  }
  return 0;
}

int judge(int age) { return age / 10; }
Problem p00184 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  const int range[] = {0, 10, 20, 30, 40, 50, 60, 1000};

  //	cut here before submit
  //	freopen ("testcase.tsuruga", "r", stdin );

  while (1) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    } // end if

    vector<int> hist(7, 0);
    int i, j;
    for (i = 0; i < n; ++i) {
      int age;
      cin >> age;
      for (j = 0; j < 7; ++j) {
        if (age >= range[j] && age < range[j + 1]) {
          ++hist[j];
          break;
        } // end if
      }   // end for
    }     // end for
    for (j = 0; j < 7; ++j) {
      cout << hist[j] << endl;
    } // end for
  }   // end loop

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  const int range[] = {0, 10, 20, 30, 40, 50, 60, 1000};

  //	cut here before submit
  //	freopen ("testcase.tsuruga", "r", stdin );
  string str = "";
  int n;

  while (getline(cin, str)) {
    stringstream ssn(str);
    ssn >> n;
    if (n == 0) {
      break;
    } // end if

    vector<int> hist(7, 0);
    int i, j;
    for (i = 0; i < n; ++i) {
      int age;
      getline(cin, str);
      stringstream ss(str);
      ss >> age;
      for (j = 0; j < 7; ++j) {
        if (age >= range[j] && age < range[j + 1]) {
          ++hist[j];
          break;
        } // end if
      }   // end for
    }     // end for
    for (j = 0; j < 7; ++j) {
      cout << hist[j] << endl;
    } // end for
  }   // end loop

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

#include <iostream>
using namespace std;
int main() {
  int n, p;
  int age[7];
  while (1) {
    cin >> n;
    if (n == 0)
      return 0;
    for (int i = 0; i < 7; i++)
      age[i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> p;
      if (p < 10)
        age[0]++;
      if (p >= 10 && p < 20)
        age[1]++;
      if (p >= 20 && p < 30)
        age[2]++;
      if (p >= 30 && p < 40)
        age[3]++;
      if (p >= 40 && p < 50)
        age[4]++;
      if (p >= 50 && p < 60)
        age[5]++;
      if (p >= 60)
        age[6]++;
    }
    for (int i = 0; i < 7; i++)
      cout << age[i] << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#define MAX 1000000
using namespace std;
int main() {
  int count = 0;
  int n, p;
  int age[MAX][7];
  while (cin >> n) {
    if (n == 0)
      break;
    for (int i = 0; i < 7; i++)
      age[count][i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> p;
      if (p < 10)
        age[count][0]++;
      if (p > 10 && p < 20)
        age[count][1]++;
      if (p > 20 && p < 30)
        age[count][2]++;
      if (p > 30 && p < 40)
        age[count][3]++;
      if (p > 40 && p < 50)
        age[count][4]++;
      if (p > 50 && p < 60)
        age[count][5]++;
      if (p >= 60)
        age[count][6]++;
    }
    count++;
  }
  for (int i = 0; i < count; i++) {
    for (int j = 0; j < 7; j++)
      cout << age[count][j] << endl;
  }
  return 0;
}
Problem p00184 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

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

int main(void) {
  int n;
  while (cin >> n, n) {
    int gra[7] = {0};
    rep(i, n) {
      int data;
      cin >> data;
      if (data < 10)
        gra[0]++;
      else if (data < 20)
        gra[1]++;
      else if (data < 30)
        gra[2]++;
      else if (data < 40)
        gra[3]++;
      else if (data < 50)
        gra[4]++;
      else if (data < 60)
        gra[5]++;
      else
        gra[6]++;
    }
    rep(i, 7) { cout << gra[i] << endl; }
  }
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
  int n, d, layer[10] = {0};
  while (cin >> n, n != 0) {
    for (int i = 0; i < n; i++) {
      cin >> d;
      layer[d / 10]++;
      if (6 < d / 10)
        layer[6]++;
    }
    for (int i = 0; i < 7; i++) {
      cout << layer[i] << endl;
      layer[i] = 0;
    }
  }
}
Problem p00184 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
  int n;
  int date[8] = {0, 10, 20, 30, 40, 50, 60, 1000};
  while (cin >> n) {
    int freq[7] = {0};
    if (!n)
      break;
    while (n--) {
      int year;
      cin >> year;
      freq[min(year / 10, 6)]++;
    }
    for (int i = 0; i < 7; i++) {
      cout << freq[i] << endl;
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int n;
  int date[8] = {0, 10, 20, 30, 40, 50, 60, 1000};
  while (cin >> n) {
    int freq[7] = {0};
    if (!n)
      break;
    while (n--) {
      int year;
      cin >> year;
      freq[year / 10]++;
    }
    for (int i = 0; i < 7; i++) {
      cout << freq[i] << endl;
    }
  }
  return 0;
}
Problem p00184 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
  int n;
  while (cin >> n && n != 0) {
    int x, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0;
    for (int i = 0; i < n; i++) {
      cin >> x;
      if (x < 10) {
        a++;
      } else if (x >= 10 && x < 20) {
        b++;
      } else if (x >= 20 && x < 30) {
        c++;
      } else if (x >= 30 && x < 40) {
        d++;
      } else if (x >= 40 && x < 50) {
        e++;
      } else if (x >= 50 && x < 60) {
        f++;
      } else if (x >= 60) {
        g++;
      }
    }
    cout << a << endl
         << b << endl
         << c << endl
         << d << endl
         << e << endl
         << f << endl
         << g << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
  int n, x[100], i, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0;
  while (cin >> n && n != 0) {
    if (n == 0) {
      break;
    }
    for (i = 0; i < n; i++) {
      cin >> x[i];
      if (x[i] < 10) {
        a++;
      } else if (x[i] >= 10 && x[i] < 20) {
        b++;
      } else if (x[i] >= 20 && x[i] < 30) {
        c++;
      } else if (x[i] >= 30 && x[i] < 40) {
        d++;
      } else if (x[i] >= 40 && x[i] < 50) {
        e++;
      } else if (x[i] >= 50 && x[i] < 60) {
        f++;
      } else if (x[i] >= 60) {
        g++;
      }
    }
    cout << a << endl
         << b << endl
         << c << endl
         << d << endl
         << e << endl
         << f << endl
         << g << endl;
  }
  return 0;
}
Problem p00184 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int judge(int);

int main(void) {
  int n, age;

  for (;;) {
    int cnt[7] = {0};

    cin >> n;
    if (n == 0)
      break;

    for (int i = 0; i < n; i++) {
      cin >> age;
      cnt[judge(age)]++;
    }

    for (int i = 0; i < 7; i++)
      cout << cnt[i] << endl;
  }

  return 0;
}

int judge(int age) {

  switch (age / 10) {

  case 0:
    return 0;
  case 1:
    return 1;
  case 2:
    return 2;
  case 3:
    return 3;
  case 4:
    return 4;
  case 5:
    return 5;
  default:
    return 6;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int judge(int);

int main(void) {
  int n, age;

  for (;;) {
    int cnt[7] = {0};

    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> age;
      cnt[judge(age)]++;
    }

    for (int i = 0; i < n; i++)
      cout << cnt[i] << endl;
  }

  return 0;
}

int judge(int age) {

  switch (age / 10) {
  case 0:
    return 0;
  case 1:
    return 1;
  case 2:
    return 2;
  case 3:
    return 3;
  case 4:
    return 4;
  case 5:
    return 5;
  }
  return 6;
}
Problem p00184 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n, tmp, ans[7];
  while (true) {
    cin >> n;
    if (!n)
      return 0;
    for (int i = 0; i < 7; i++)
      ans[i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      tmp = (int)(tmp / 10);
      if (tmp > 6)
        tmp = 6;
      ans[tmp]++;
    }
    for (int i = 0; i < 7; i++)
      cout << ans[i] << endl;
  }
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, o, a[7];
  while (true) {
    cin >> n;
    if (!n)
      return 0;
    for (int i = 0; i < 7; i++)
      a[i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> o;
      o /= 10;
      a[o]++;
    }
    for (int i = 0; i < 7; i++)
      cout << a[i] << endl;
  }
}
Problem p00185 (C++) — buggy submission, verdict: Runtime Error

/*1000000ÈºÌfÅüÍµ½nÈºÌÅåÌfðoÍ·évO*/
#include <iostream>
const int MAX = 1000001;
const int P_NUM = 78498;
using namespace std;

bool p[MAX];
int a[79000] = {};

void f() {
  for (int i = 0; i < MAX; i++) {
    p[i] = (i <= 1) ? false : true;
  }
  for (int i = 2; i * i <= MAX + 1; i++) {
    if (p[i]) {
      for (int j = i * 2; j < MAX; j += i) {
        p[j] = false;
      }
    }
  }
  for (int i = 2, j = 0; i < MAX; ++i) {
    if (p[i])
      a[j++] = i;
  }
}

int main() {
  int n;

  f();

  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; i < n; ++i)
      if (p[i] && p[n - i] && (n - i) >= i)
        ans++;
    cout << ans << endl;
  }
}

Error: 0

Fixed submission:

/*1000000ÈºÌfÅüÍµ½nÈºÌÅåÌfðoÍ·évO*/
#include <iostream>
const int MAX = 1000001;
const int P_NUM = 78498;
using namespace std;

bool p[MAX];
int a[79000] = {};

void f() {
  for (int i = 0; i < MAX; i++) {
    p[i] = (i <= 1) ? false : true;
  }
  for (int i = 2; i * i <= MAX + 1; i++) {
    if (p[i]) {
      for (int j = i * 2; j < MAX; j += i) {
        p[j] = false;
      }
    }
  }
  for (int i = 2, j = 0; i < MAX; ++i) {
    if (p[i])
      a[j++] = i;
  }
}

int main() {
  int n;

  f();

  while (cin >> n, n) {
    int ans = 0;
    int pos;
    for (pos = 0; n > a[pos]; ++pos)
      ;

    for (int i = 0; i <= pos; ++i) {
      int x = n - a[i];
      if (p[x] && x >= a[i])
        ans++; /*
 for(int j=pos ; j>=i ; --j ){
         if( a[i]+a[j] == n ){
                 ans++;
                 continue;
         }
         if( a[i]+a[j] < n ){
                 continue;
         }
 }*/
    }
    cout << ans << endl;
  }
}
Problem p00185 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
#define all(n) n.begin(), n.end()

const int MAXN = 1000 * 1000 + 20;

bool p[MAXN];

int main() {
  p[0] = p[1] = 1;
  REP(MAXN) if (!p[i]) for (int j = i * 2; j < MAXN; j += i) p[j] = 1;

  int n;
  while (cin >> n && n) {
    int ans = 0;

    for (int i = 3; i <= n / 2; i += 2) {
      if ((!p[i]) && (!p[n - i]))
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
#define all(n) n.begin(), n.end()

const int MAX = 1000001;
bool p[MAX];
int ps[MAX];
// vector<int> ps(MAX);
int l;
int s[MAX];
int n;

int main() {
  p[0] = p[1] = 1;
  REP(MAX) if (!p[i]) for (int j = i * 2; j < MAX; j += i) p[j] = true;
  REP(MAX) if (!p[i]) {
    ps[l] = i;
    l++;
  }

  // cout << "made ps "  << l << endl;

  REP(l)
  for (int j = i; j < l; j++) {
    if (ps[i] + ps[j] < MAX)
      s[ps[i] + ps[j]]++;
    else
      break;
  }

  cout << "made sum " << endl;
  while (cin >> n && n)
    cout << s[n] << endl;

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

#include <bits/stdc++.h>
#define r(i, a, n) for (int i = a; i < n; i++)
using namespace std;
int a[1000000] = {1, 1}, s[500000], c;
int main() {
  r(i, 2, 100000) for (int j = i * 2; j < 1000000; j += i) a[j]++;
  r(i, 2, 1000000) if (!a[i]) s[c++] = i;
  int n;
  while (cin >> n, n) {
    int ss = 0;
    r(i, 0, c) {
      if (s[i] > n / 2)
        break;
      if (!a[n - s[i]])
        ss++;
    }
    cout << ss << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define r(i, a, n) for (int i = a; i < n; i++)
using namespace std;
int a[1000000] = {1, 1}, s[500000], c;
int main() {
  r(i, 2, 100000) for (int j = i * 2; j < 1000000; j += i) a[j]++;
  r(i, 2, 1000000) if (!a[i]) s[c++] = i;
  int n;
  while (cin >> n, n) {
    int ss = 0;
    r(i, 0, n) {
      if (s[i] > n)
        break;
      r(j, i, n) {
        if (s[j] > n)
          break;
        if (s[i] + s[j] == n) {
          ss++;
        }
        cout << ss << endl;
      }
    }
  }
}
Problem p00185 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  bool prime[1000001];
  for (int i = 2; i < 1000001; i++)
    prime[i] = true;
  for (int i = 2; i <= sqrt(1000000); i++) {
    if (prime[i] == true) {
      for (int j = i + i; j < 1000001; j += i)
        prime[j] = false;
    }
  }
  int n, cou = 0;
  while (cin >> n && n != 0) {
    for (int i = 2; i <= n / 2; i++)
      if (prime[i] == true && prime[n - i] == true)
        cou++;
    cout << cou << endl;
    cou = 0;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int prime[100001];
  for (int i = 2; i < 100001; i++)
    prime[i] = 0;
  for (int i = 2; i <= sqrt(100001); i++) {
    if (prime[i] == 0) {
      for (int j = i + i; j < 100001; j += i)
        prime[j] = 1;
    }
  }
  int n, cou = 0;
  while (cin >> n && n != 0) {
    for (int i = 2; i <= n / 2; i++)
      if (prime[i] == 0 && prime[n - i] == 0)
        cou++;
    cout << cou << endl;
    cou = 0;
  }
}
Problem p00185 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#define size 1000001
using namespace std;
int p[size];
int n, a, b, cnt;
void prime();
int main() {
  prime();
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    cnt = 0;
    for (int i = 2; i <= n / 2; i++) {
      if (p[i] == 1 && p[n - i] == 1) {
        //	cout<<i<<' '<<n-i<<endl;
        cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

void prime() {
  for (int i = 0; i < size; i++)
    p[i] = 1;
  p[0] = p[1] = 0;
  for (int i = 4; i < size; i += 2)
    p[i] = 0;
  for (int i = 3; i * i <= size; i += 2) {
    if (p[i] == 0)
      continue;
    for (int j = i * 2; j < size; j += i)
      p[j] = 0;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
char t[1001];
int size, n, tmp, cnt, a, b, c, x, y, z, flg;
int endofinput() {
  if (t[12] != '\\n')
    return 0;
  if (t[0] != 'E')
    return 0;
  if (t[1] != 'N')
    return 0;
  if (t[2] != 'D')
    return 0;
  if (t[3] != ' ')
    return 0;
  if (t[4] != 'O')
    return 0;
  if (t[5] != 'F')
    return 0;
  if (t[6] != ' ')
    return 0;
  if (t[9] != 'P')
    return 0;
  if (t[7] != 'I')
    return 0;
  if (t[10] != 'U')
    return 0;
  if (t[8] != 'N')
    return 0;
  if (t[11] != 'T')
    return 0;
  return 1;
}
int main() {
  while (1) {
    size = 0;
    while (1) {
      scanf("%c", &t[size]);
      size++;
      if (t[size - 1] == '\\n')
        break;
    }
    if (endofinput())
      break;
    cnt = 0;
    flg = 0;
    if (t[0] != ' ')
      cnt = 1;
    for (int i = 1; i < size - 1; i++) {
      if (t[i] == ' ') {
        cout << cnt;
        cnt = 0;
        flg = 1;
      } else {
        cnt++;
        flg = 0;
      }
    }
    cout << cnt << endl;
  }

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

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

char so[1000001];

int main() {
  int n, i, j, count;
  memset(so, 0, sizeof(so));
  so[1] = 1;
  for (i = 2; i < 6; i++) {
    for (j = 2 * i; j <= 29; j += i) {
      so[j] = 1;
    }
  }

  for (i = 29; i < 1000; i += 2) {
    if (i % 23 == 0 || i % 7 == 0 || i % 3 == 0 || i % 5 == 0 || i % 11 == 0 ||
        i % 13 == 0 || i % 17 == 0 || i % 19 == 0)
      continue;
    for (j = 3 * i; j <= 1000000; j += (2 * i)) {
      so[j] = 1;
    }
  }

  while (0 <= scanf("%d", &n)) {
    if (n == 0)
      break;
    count = 0;
    for (i = 2; i < 29; i++) {
      if (2 * i > n)
        break;
      if (n - i == 3 || n - i == 5 || n - i == 7 || n - i == 11 ||
          n - i == 13 || n - i == 17 || n - i == 19 || n - i == 23 ||
          n - i == 29) {
        if (so[i] == 0) {
          ++count;
          continue;
        }
      }
      j = i;
      i = n - i;
      if (i % 2 == 0 || i % 23 == 0 || i % 7 == 0 || i % 3 == 0 || i % 5 == 0 ||
          i % 11 == 0 || i % 13 == 0 || i % 17 == 0 || i % 19 == 0) {
        i = j;
        continue;
      }
      i = j;
      if (so[i] == 0 && so[n - i] == 0)
        ++count;
    }

    for (i = 29; 2 * i <= n; i += 2) {
      if (i % 23 == 0 || i % 7 == 0 || i % 3 == 0 || i % 5 == 0 ||
          i % 11 == 0 || i % 13 == 0 || i % 17 == 0 || i % 19 == 0)
        continue;
      j = i;
      i = n - i;
      if (i % 23 == 0 || i % 7 == 0 || i % 3 == 0 || i % 5 == 0 ||
          i % 11 == 0 || i % 13 == 0 || i % 17 == 0 || i % 19 == 0) {
        i = j;
        continue;
      }
      i = j;
      if (so[i] == 0 && so[n - i] == 0)
        ++count;
    }
    printf("%d\\n", count);
  }
  return 0;
}

Error: TLE

Fixed submission:

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

char so[1000001];

int main() {
  int n, i, j, count;
  memset(so, 0, sizeof(so));
  so[1] = 1;
  for (i = 2; i < 1000;) {
    for (j = i; i * j <= 1000000; j++) {
      printf("%d %d\\n", i, j);
      so[i * j] = 1;
    }
  }
  count = 0;
  while (0 <= scanf("%d", &n)) {
    for (i = 2; 2 * i <= n; i++) {
      if (so[i] == 0 && so[n - i] == 0)
        ++count;
    }
    printf("%d\\n", count);
  }
  return 0;
}
Problem p00185 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
#define MAX 1000100

int prime[MAX - 4];

void is_prime() {
  for (int i = 0; i < MAX; i++)
    prime[i] = 0;
  prime[0] = prime[1] = 1;
  for (int i = 4; i < MAX; i += 2)
    prime[i] = 1;

  for (int i = 3; i * i < MAX; i++) {
    if (prime[i])
      continue;
    for (int j = i * 2; j < MAX; j += i)
      prime[j] = 1;
  }
}

int main() {
  int n;

  is_prime();

  while (true) {
    cin >> n;
    if (!n)
      break;

    int cnt = 0;
    for (int i = 2; i <= n / 2; i++) {
      if (!prime[i] && !prime[n - i])
        cnt++;
    }
    cout << cnt << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
#define MAX 50100

int prime[MAX - 4];

void is_prime() {
  for (int i = 0; i < MAX; i++)
    prime[i] = 0;
  prime[0] = prime[1] = 1;
  for (int i = 4; i < MAX; i += 2)
    prime[i] = 1;

  for (int i = 3; i * i < MAX; i++) {
    if (prime[i])
      continue;
    for (int j = i * 2; j < MAX; j += i)
      prime[j] = 1;
  }
}

int main() {
  int n;

  is_prime();

  while (true) {
    cin >> n;
    if (!n)
      break;

    int cnt = 0;
    for (int i = 2; i <= n / 2; i++) {
      if (!prime[i] && !prime[n - i])
        cnt++;
    }
    cout << cnt << endl;
  }

  return 0;
}