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

#include <algorithm>
#include <deque>
#include <iostream>
#include <stdio.h>

using namespace std;

void MakePrimeArray(deque<bool> &A, int n) {

  A[0] = A[1] = false;
  for (int i = 2; i < n; i++) {
    A[i] = true;
  }

  for (int i = 2; i * i < n; i++) {
    if (A[i]) {
      for (int j = i * i; j < n; j += i) {
        A[j] = false;
      }
    }
  }
}

inline int GoldBach(const deque<int> &prime, int n) {

  int count = 0;
  deque<int> clear;
  bool ok = true;

  for (int i = 0; prime[i] < n; i++) {

    if (std::binary_search(clear.begin(), clear.end(), prime[i])) {
      break;
    }

    int num = n - prime[i];

    if (std::binary_search(prime.begin(), prime.end(), num)) {
      count++;
      clear.insert(clear.begin(), num);
    }
  }
  return count;
}

int main() {

  int n = 50001;

  deque<bool> primearray;

  primearray.resize(n);

  MakePrimeArray(primearray, n);

  deque<int> prime;

  for (int i = 2; i < n; i++) {
    if (primearray[i]) {
      prime.push_back(i);
    }
  }

  while (true) {
    int innum;
    cin >> innum;
    // scanf("%d",&innum);

    if (innum == 0)
      break;
    int answer = GoldBach(prime, innum);
    // printf("%d \\n",answer);
    cout << answer << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <deque>
#include <iostream>
#include <stdio.h>

using namespace std;

void MakePrimeArray(deque<bool> &A, int n) {

  A[0] = A[1] = false;
  for (int i = 2; i < n; i++) {
    A[i] = true;
  }

  for (int i = 2; i * i < n; i++) {
    if (A[i]) {
      for (int j = i * i; j < n; j += i) {
        A[j] = false;
      }
    }
  }
}

inline int GoldBach(const deque<int> &prime, int n) {

  int count = 0;
  deque<int> clear;
  bool ok = true;

  for (int i = 0; prime[i] < n; i++) {

    if (std::binary_search(clear.begin(), clear.end(), prime[i])) {
      break;
    }

    int num = n - prime[i];

    if (std::binary_search(prime.begin(), prime.end(), num)) {
      count++;
      clear.insert(clear.begin(), num);
    }
  }
  return count;
}

int main() {

  int n = 50001;

  deque<bool> primearray;

  primearray.resize(n);

  MakePrimeArray(primearray, n);

  deque<int> prime;

  for (int i = 2; i < n; i++) {
    if (primearray[i]) {
      prime.push_back(i);
    }
  }

  while (true) {
    int innum;
    cin >> innum;
    // scanf("%d",&innum);

    if (innum == 0)
      break;
    int answer = GoldBach(prime, innum);
    // printf("%d \\n",answer);
    cout << GoldBach(prime, innum) << endl;
  }

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

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

const int MAX_N = 50000;
bool isPrime[MAX_N + 1];

void setup() {
  fill_n(isPrime, MAX_N, true);
  isPrime[0] = isPrime[1] = false;
  for (int i = 4; i <= MAX_N; i += 2) {
    isPrime[i] = false;
  }
  for (int i = 3; i * i <= MAX_N; i += 2) {
    if (isPrime[i]) {
      for (int j = i + i; j <= MAX_N; j += i) {
        isPrime[j] = false;
      }
    }
  }
}

int main() {
  setup();
  int n;
  while (cin >> n, n) {
    int result = 0;
    if (isPrime[n - 2]) {
      result++;
    }
    for (int i = 3; i * 2 <= n; i += 2) {
      if (isPrime[i] && isPrime[n - i]) {
        result++;
      }
    }
    cout << result << endl;
  }
}

Error: 0

Fixed submission:

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

void next(int &i, bool *isPrime, const int MAX) {
  do {
    i++;
  } while (i < MAX && isPrime[i] == false);
}

void prev(int &i, bool *isPrime) {
  do {
    i--;
  } while (i > 0 && isPrime[i] == false);
}

int main() {
  const int MAX = 50;
  bool isPrime[MAX];
  fill_n(isPrime, MAX, true);
  for (int i = 4; i < MAX; i += 2) {
    isPrime[i] = false;
  }
  for (int i = 3; i * i <= MAX; i += 2) {
    if (isPrime[i]) {
      for (int j = 2 * i; j < MAX; j += i) {
        isPrime[j] = false;
      }
    }
  }
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    int count = 0, a = 2, b = n;
    prev(b, isPrime);
    while (a <= b) {
      if (a + b < n) {
        next(a, isPrime, MAX);
      } else if (a + b > n) {
        prev(b, isPrime);
      } else {
        count++;
        next(a, isPrime, MAX);
        prev(b, isPrime);
      }
    }
    cout << count << endl;
  }
}
Problem p00056 (C++) — buggy submission, verdict: Runtime Error

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

bool a[60000]{};
int main() {
  for (int b = 2; b < 60000; b++) {
    if (!(a[b])) {
      for (int c = b * 2; c < 60000; c += b)
        a[c] = true;
    }
  }
  int e;
  while (cin >> e, e) {
    int s = 0;
    for (int f = 2; f <= e / 2; f++) {
      if (!a[f] && !a[e - f])
        s++;
    }
    cout << s << endl;
  }
}

Error: -11

Fixed submission:

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

bool a[60000]{};
int main() {
  for (int b = 2; b < 60000; b++) {
    if (!(a[b])) {
      for (int c = b * 2; c <= 150000; c += b)
        a[c] = true;
    }
  }
  int e;
  while (cin >> e, e) {
    int s = 0;
    for (int f = 2; f <= e / 2; f++) {
      if (!a[f] && !a[e - f])
        s++;
    }
    cout << s << endl;
  }
}
Problem p00056 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

const int max_lim = 50001;
bool prime[max_lim];

void init() {
  for (int i = 0; i < max_lim; i++)
    prime[i] = true;
  prime[0] = prime[1] = false;

  for (int i = 2; i * i < max_lim; i++)
    for (int j = 2 * i; j < max_lim; j += i)
      prime[j] = false;
}

int main() {
  int n;

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

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

const int max_lim = 50001;
bool prime[max_lim];

void init() {
  for (int i = 0; i < max_lim; i++)
    prime[i] = true;
  prime[0] = prime[1] = false;

  for (int i = 2; i * i < max_lim; i++)
    for (int j = 2 * i; j < max_lim; j += i)
      prime[j] = false;
}

int main() {
  int n;

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

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

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

void sieve(int n, vector<char> &v) {
  v.resize(n + 1);
  fill(v.begin(), v.end(), true);
  v[0] = v[1] = false;

  for (int i = 2; i * i <= n; i++) {
    if (v[i]) {
      for (int j = i + i; j <= n; j += i) {
        v[j] = false;
      }
    }
  }
}

int main() {
  vector<char> is_prime;
  vector<int> prime_list;

  sieve(50000, is_prime);

  for (int i = 0; i < is_prime.size(); i++) {
    if (is_prime[i]) {
      prime_list.push_back(i);
    }
  }

  int n;

  while (cin >> n, n) {
    int pr = 0;

    for (int i = 0; i < prime_list.size(); i++) {
      if (prime_list[i] + prime_list[i] > n)
        break;

      if (binary_search(prime_list.begin(), prime_list.end(),
                        n - prime_list[i])) {
        pr++;
      }
    }

    cout << pr << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

void sieve(int n, vector<char> &v) {
  v.resize(n + 1);
  fill(v.begin(), v.end(), true);
  v[0] = v[1] = false;

  for (int i = 2; i * i <= n; i++) {
    if (v[i]) {
      for (int j = i + i; j <= n; j += i) {
        v[j] = false;
      }
    }
  }
}

int main() {
  vector<char> is_prime;
  vector<int> prime_list;

  sieve(50000, is_prime);

  for (int i = 0; i < is_prime.size(); i++) {
    if (is_prime[i]) {
      prime_list.push_back(i);
    }
  }

  int n;

  while (cin >> n, n) {
    int pr = 0;

    for (int i = 0; i < prime_list.size(); i++) {
      if (prime_list[i] + prime_list[i] > n)
        break;

      if (find(prime_list.begin(), prime_list.end(), n - prime_list[i]) !=
          prime_list.end()) {
        pr++;
      }
    }

    cout << pr << endl;
  }

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

#include <cstring>
#include <fstream>
#include <iostream>
#include <sstream>
using namespace std;
const int N = 50000;
bool prime[N + 1];

void make_prime(void) {
  int i, j;
  memset(prime, true, sizeof(prime));

  prime[0] = false;
  prime[1] = false;

  for (j = 0; j <= N; ++j) {
    if (prime[j]) {
      int p = j;
      for (i = 2 * p; i <= N; i += p) {
        if (prime[i]) {
          prime[i] = false;
        } // end if
      }   // end for
    }     // end if
  }       // end for
}

int main() {
  //	cut here before submit
  //	freopen ("testcase.goldbach", "r", stdin);
  string str = "";
  make_prime();

  while (getline(cin, str)) {
    int n;
    stringstream ss(str);
    ss >> n;
    if (n == 0) {
      break;
    } // end if
    int res = 0;
    int i;

    for (i = 2; i <= n / 2; ++i) {
      if (prime[i] && prime[n - i]) {
        ++res;
      } // end for
    }   // end for
    cout << res << endl;
  } // 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;

bool isprime(int n) {

  if (n == 0 || n == 1) {
    return false;
  } else if (n == 2) {
    return true;
  } else if (n % 2 == 0) {
    return false;
  } // end if

  for (int i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      return false;
    } // end if
  }   // end for

  return true;
}

int main() {
  //	cut here before submit
  //	freopen("testcase.gold", "r", stdin);
  string str = "";
  map<int, bool> prime;
  int i;
  for (i = 2; i <= 25000; ++i) {
    if (isprime(i)) {
      prime[i] = true;
    } else {
      prime[i] = false;
    } // end if
  }   // end for

  while (getline(cin, str)) {
    int n;
    stringstream ss(str);
    ss >> n;
    if (n == 0) {
      break;
    } // end if
    int res = 0;
    if (prime[n - 2]) {
      ++res;
    } // end if
    for (i = 3; i <= (n + 1) / 2; i += 2) {
      if (prime[i] && prime[n - i]) {
        ++res;
      } // end for
    }   // end for
    cout << res << endl;
  } // end loop

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

#include <cstring> // require memset
#include <iostream>

using namespace std;

const int N = 50000;
bool prime[N + 1];

void make_prime(void) {
  int i, j;
  memset(prime, true, sizeof(prime));

  prime[0] = false;
  prime[1] = false;

  for (j = 0; j <= N; ++j) {
    if (prime[j]) {
      int p = j;
      for (i = 2 * p; i <= N; i += p) {
        if (prime[i]) {
          prime[i] = false;
        } // end if
      }   // end for
    }     // end if
  }       // end for
}

int main() {
  int n;
  make_prime();

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

    for (int i = 2; i <= n / 2; ++i) {
      if (prime[i] && prime[n - i]) {
        ++res;
      } // end for
    }   // end for
    cout << res << endl;
  } // end loop

  return 0;
}

Error: 0

Fixed submission:

#include <cmath>
#include <cstring>
#include <iostream>
// #include <fstream>

using namespace std;

bool prime[25001];

bool isprime(int n) {

  if (n == 0 || n == 1) {
    return false;
  } else if (n == 2) {
    return true;
  } else if (n % 2 == 0) {
    return false;
  } // end if

  for (int i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      return false;
    } // end if
  }   // end for

  return true;
}

int main() {
  //	cut here before submit
  //	freopen("testcase.goldbach", "r", stdin);

  memset(prime, false, sizeof(prime));

  for (int i = 2; i <= 25000; ++i) {
    if (isprime(i)) {
      prime[i] = true;
    } // end if
  }   // end for

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

    if (prime[n - 2]) {
      ++res;
    } // end if
    for (int i = 3; i <= (n + 1) / 2; i += 2) {
      if (prime[i] && prime[n - i]) {
        ++res;
      } // end for
    }   // end for
    cout << res << endl;
  } // end loop

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

#include <cstring> // require memset
#include <iostream>

using namespace std;

const int N = 50000;
bool prime[N + 1];

void make_prime(void) {
  memset(prime, true, sizeof(prime));

  prime[0] = false;
  prime[1] = false;

  for (int i = 2; i * i <= N; ++i) {
    if (prime[i]) {
      for (int j = i * i; j <= N; j += i) {
        prime[j] = false;
      } // end for
    }   // end if
  }     // end for
}

int main() {
  make_prime();

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

    for (int i = 2; i <= n / 2; ++i) {
      if (prime[i] && prime[n - i]) {
        ++res;
      } // end for
    }   // end for
    cout << res << endl;
  } // end loop

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cctype>    // require tolower, toupper
#include <cfloat>
#include <climits>
#include <cmath>   // require fabs
#include <cstdio>  // require scanf printf
#include <cstdlib> // require abs exit atof atoi
#include <cstring> // require memset
#include <ctime>   // require srand
#include <deque>
#include <fstream> // require freopen
#include <functional>
#include <iomanip> // require setw
#include <iostream>
#include <limits>
#include <map>
#include <numeric> // require accumulate
#include <queue>
#include <set>
#include <sstream> // require stringstream
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_N = 50000 + 1;

bool prime[MAX_N];
set<int> p;

void make_prime(void) {
  fill(prime, prime + MAX_N, true);
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i * i < MAX_N; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j < MAX_N; j += i) {
        prime[j] = false;
      } // end for
    }   // end if
  }     // end for

  p.clear();
  rep(i, MAX_N) {
    if (prime[i])
      p.insert(i);
  } // end rep

  //	cerr << p.size() << ": " << p[p.size()-1] << endl;
}

int main() {
  //	cut here before submit
  //	freopen ("testcase.GC", "r", stdin );

  make_prime();

  int n;
  while (scanf("%d", &n), n) {

    int res = 0;
    for (int i = 2; i <= n / 2; i++) {
      int j = n - i;
      if (p.count(i) && p.count(j)) {
        //				cerr << "i: " << i << " j: " << j <<
        //endl;
        ++res;
      } // end if
    }   // end for
    printf("%d\\n", res);
  } // end loop

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

#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
bool a[50001];
int b[25000];
int main() {
  int c = 0;
  fill(a, a + 50001, true);
  a[0] = false;
  a[1] = false;
  for (int i = 2; i <= 50000;) {
    if (a[i]) {
      int j = 2;
      while (i * j <= 50000) {
        a[i * j] = false;
        j++;
      }
      b[c] = i;
      c++;
    }
    if (i == 2)
      i++;
    else
      i += 2;
  }
  int n;
  while (cin >> n && n != 0) {
    int i = 0;
    map<int, int> d;
    while (b[i] <= n && i != c) {
      if (a[n - b[i]]) {
        d.insert(map<int, int>::value_type(min(b[i], n - b[i]),
                                           max(b[i], n - b[i])));
      }
      i++;
    }
    cout << d.size() << endl;
  }
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
bool a[25001];
int b[25000];
int main() {
  int c = 0;
  fill(a, a + 25000, true);
  a[0] = false;
  a[1] = false;
  for (int i = 2; i <= 25000;) {
    if (a[i]) {
      int j = 2;
      while (i * j <= 25000) {
        a[i * j] = false;
        j++;
      }
      b[c] = i;
      c++;
    }
    if (i == 2)
      i++;
    else
      i += 2;
  }
  int n;
  while (cin >> n && n != 0) {
    int sum = 0;
    int i = 0;
    while (b[i] <= n && i != c) {
      if (a[n - b[i]]) {
        sum++;
      }
      i++;
    }
    cout << sum << endl;
  }
}
Problem p00056 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _CRT_SECURE_NO_WARNINGS 1
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0 * M_PI / 360.0
#define inin(x)                                                                \\
  int x;                                                                       \\
  cin >> x;
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " " << x << endl;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define pri_max 60000
typedef pair<int, int> pii;

bool memo[pri_max] = {};
vector<int> pri;
void calc() {
  for (int i = 2; i < pri_max; i++) {
    if (memo[i] == false) {
      pri.push_back(i);
      for (int l = i; l < pri_max; l += i) {
        memo[l] = true;
      }
    }
  }
}
int main() {
  calc();
  int n;
  while (cin >> n && n) {
    int ans = 0;
    for (int i = 0; i < pri.size(); i++) {
      if (n - pri[i] <= 0)
        break;
      ans += binary_search(all(pri), n - pri[i]);
    }
    ans /= 2;
    if (n % 2 == 0 && binary_search(all(pri), n / 2))
      ans++;
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS 1
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0 * M_PI / 360.0
#define inin(x)                                                                \\
  int x;                                                                       \\
  cin >> x;
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " " << x << endl;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define pri_max 60000
typedef pair<int, int> pii;

bool memo[pri_max] = {};
vector<int> pri;
void calc() {
  for (int i = 2; i < pri_max; i++) {
    if (memo[i] == false) {
      pri.push_back(i);
      for (int l = i; l < pri_max; l += i) {
        memo[l] = true;
      }
    }
  }
}
int main() {
  calc();
  int n;
  while (cin >> n && n) {
    int ans = 0;
    for (int i = 0; i < pri.size(); i++) {
      ans += binary_search(all(pri), n - pri[i]);
    }
    ans /= 2;
    if (n % 2 == 0 && binary_search(all(pri), n / 2))
      ans++;
    cout << ans << endl;
  }
}
Problem p00056 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

bool flag[50001];
int prime[50001];

int main() {
  int n = 0;
  int i, j;

  flag[0] = flag[1] = true;
  for (i = 2; i * i <= 50000; i++) {
    if (flag[i] != true) {
      for (j = i * i; j <= 50000; j += i) {
        flag[j] = true;
      }
    }
  }
  j = 0;
  for (i = 0; i <= 50000; i++) {
    if (!flag[i]) {
      prime[j++] = i;
    }
  }
  while (cin >> n, n) {
    int cnt = 0;
    for (i = 0; prime[i] <= n / 2; i++) {
      if (flag[n - prime[i]] == false) {
        cnt++;
      }
    }
    cout << cnt << endl;
  }

  return (0);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace std;

bool flag[50001];

int main() {
  int n = 0;

  for (int i = 0; i <= 50000; i++) {
    if (i <= 1)
      flag[i] = false;
    else
      flag[i] = true;
  }
  for (int i = 2; i <= 1001; i++) {
    if (flag[i] == true) {
      for (int j = i * 2; j <= 50000; j += i) {
        flag[j] = false;
      }
    }
  }
  while (cin >> n) {
    int ans = 0;
    for (int i = 2; i <= n; i++) {
      for (int j = i; j <= n - i; j++) {
        if (i + j == n) {
          if (flag[i] == true && flag[j] == true) {
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }

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

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

int p[105000];

int main() {
  int n;
  p[0] = p[1] = 1;
  for (int i = 2; i * i <= 105000; i++) {
    if (p[i])
      continue;
    for (int j = i * i; j <= 105000; j += i) {
      p[j] = 1;
    }
  }
  while (cin >> n, n) {
    int res = 0;
    for (int i = 0; i <= n / 2; i++) {
      if (p[i] == 0 && p[n - i] == 0)
        res++;
    }
    cout << res << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int sosuhantei(int a) {
  int b = 2, check = 0;
  if (a == 2)
    check = 2;
  while (b < a) {
    if (check == 2) {
      check = 0;
      break;
    } else {
      if (a % b == 0) {
        check = 1;
        break;
      }
      b++;
    }
  }
  return check;
}

int main() {
  int seisu[100000], a, b, count, i = 0, j, k;
  for (k = 0; k < 100000; k++) {
    seisu[k] = 0;
  }
  while (1) {
    count = 0;
    scanf("%d", &a);
    if (a % 2 == 1)
      seisu[i] = 0;
    else if (a == 0) {
      i++;
      break;
    } else {
      for (j = 2; j < a / 2; j++) {
        if (sosuhantei(j) == 0) {
          b = a - j;
          if (sosuhantei(b) == 0)
            count++;
        }
      }
      seisu[i] = count;
      printf("%d", count);
    }
    i++;
  }
  for (k = 0; k < i - 1; k++) {
    printf("%d\\n", seisu[k]);
  }
}
Problem p00056 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define loop(i, b, a) for (int i = b; i < a; i++)
#define rep(i, a) for (int i = 0; i < a; i++)
int main(void) {
  const int MAX = 600000;
  bool prime[MAX];
  rep(i, MAX) prime[i] = true;

  prime[0] = prime[1] = false;
  vector<int> box;
  loop(i, 2, MAX) {
    if (prime[i]) {
      for (int j = i + i; j < MAX; j += i) {
        prime[j] = false;
      }
    }
  }

  int n;
  while (cin >> n, n) {
    int cnt = 0;
    rep(i, n / 2 + 1) {
      if (prime[i] && prime[n - i]) {
        cnt++;
        // cout<<i<<" "<<n-i<<endl;
      }
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define MAX 1000000
int prime[MAX];
bool is_prime[MAX + 1];

int solve(int n) {
  int p = 0;
  vector<int> vprime;
  for (int i = 0; i <= n; i++)
    is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      vprime.push_back(i);
      for (int j = i + i; j <= n; j += i) {
        is_prime[j] = false;
      }
    }
  }
  bool ok = false;
  int cnt = 0;

  for (int i = 0; vprime[i] <= n / 2; i++) {
    cout << vprime[i] << endl;
    for (int j = 0; vprime[j] <= n; j++) {
      if (vprime[i] + vprime[j])
        cnt++;
    }
    /*
      for(int j = vprime.size() ; vprime[j] > n/2 ; j --){
      cout<<j<<endl;
      cout<<"size"<<vprime[j]<<" "<<vprime[i]<<endl;

      if(vprime[i] + vprime[j] > n)break;
      if(vprime[i] + vprime[j] == n){
      cnt++;
      cout<<"cnt"<<cnt<<endl;
      cout<<vprime[i]<<" "<<vprime[j]<<endl;
      }
    //*/
  }

  return cnt;
}
int main(void) {

  long long int n;

  while (cin >> n, n) {
    if (n % 2)
      cout << "0" << endl;
    else
      cout << solve(n) << endl;
  }
}