Problem:
Problem A:
Goldbach's Conjecture
Goldbach's Conjecture:
For any even number
n
greater than or equal to 4, there exists at least one pair of prime numbers
p
1
and
p
2
such that
n
=
p
1
+
p
2
.
This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can find such a pair of prime numbers, if any, for a given even number. The problem here is to write a program that reports the number of all the pairs of prime numbers satisfying the condition in the conjecture for a given even number.
A sequence of even numbers is given as input. Corresponding to each number, the program should output the number of pairs mentioned above. Notice that we are intereseted in the number of essentially different pairs and therefore you should not count (
p
1
,
p
2
) and (
p
2
,
p
1
) separately as two different pairs.
Input
An integer is given in each input line. You may assume that each integer is even, and is greater than or equal to 4 and less than 2
15
. The end of the input is indicated by a number 0.
Output
Each output line should contain an integer number. No other characters should appear in the output.
Sample Input
6
10
12
0
Output for the Sample Input
1
2
1

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a);i<(b);i++)

vector<int> ans_table(const int LIM=(1<<16)){
    vector<int>res(LIM);
    vector<int> isP(LIM,1);
    vector<int>primes;
    isP[0]=isP[1]=0;
    rep(i,2,LIM){
        if(!isP[i])continue;
        for(int j=2*i;j<LIM;j+=i)isP[j]=0;
        primes.push_back(i);
    }
    for(int p:primes)for(int q:primes)if(p<=q&&p+q<LIM)res[p+q]++;
    return res;
}

int main(){
    auto ans = ans_table();
    int N;
    while(cin>>N,N){
        cout<<ans[N]<<endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3840
final_rank: 12

code_snippet: #include <iostream>
#include <vector>

using namespace std;

bool isPrime(int n)
{
	for(int i = 2; i < n; i++)
		if((n%i)==0)
			return false;
	return true;	
}

int main()
{
	int n = 0;
	
	
	while(true)
	{
		cin>>n;

		if(n == 0)
			break;

		vector <int> myArray;
		int c = 0;

		for (int i = 2; i < n; i++)
			if(isPrime(i) == true)
				myArray.push_back(i);

		for(int j = 0; j < myArray.size(); j++)
			for(int k = j; k < myArray.size(); k++)
				if((myArray[j] + myArray[k]) == n)
					c++;

		cout<<c<<endl;
	}
	
	return 0;
}
accuracy: 1
time_ms: 1020
memory_kb: 3160
final_rank: 16

code_snippet: #include <iostream>
#include <vector>

std::vector<int> prime_list;

bool prime(int n){
    for(int i=0;i<prime_list.size();i++){
        int p = prime_list[i];
        if(p == n){
            return true;
        }else if(n%p == 0){
            return false;
        }
    }
    int lastp = prime_list[prime_list.size()-1];
    for(int p=lastp;p<n;p+=2){
        if(prime(p) && (n%p==0)){
            return false;
        }
    }
    prime_list.push_back(n);
    return true;
}

int main(int argc, char**argv){
    int n;
    prime_list.push_back(3);
    while(true){
        std::cin >> n;
        if(n==0){
            break;
        }else if(n == 4){
            std::cout << 1 << std::endl;
            continue;
        }
        int c=0;
        for(int i=3;i<=(n/2);i+=2){
            if(prime(i) && prime(n-i)){
                c++;
            }
        }
        std::cout << c << std::endl;
    }
    return 0;
}
accuracy: 1
time_ms: 110
memory_kb: 3044
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl;
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl;

namespace FastFourierTransform {
	using real=double;
 
	struct C {
	real x, y;
 
	C() : x(0), y(0) {}
 
	C(real x, real y) : x(x), y(y) {}
 
	inline C operator+(const C &c) const { return C(x + c.x, y + c.y); }
 
	inline C operator-(const C &c) const { return C(x - c.x, y - c.y); }
 
	inline C operator*(const C &c) const { return C(x * c.x - y * c.y, x * c.y + y * c.x); }
 
	inline C conj() const { return C(x, -y); }
	};
 
	const real PI = acosl(-1);
	int base = 1;
	vector< C > rts = {{0, 0},
					 {1, 0}};
	vector< int > rev = {0, 1};
 
 
	void ensure_base(int nbase) {
	if(nbase <= base) return;
	rev.resize(1 << nbase);
	rts.resize(1 << nbase);
	for(int i = 0; i < (1 << nbase); i++) {
		rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
	}
	while(base < nbase) {
		real angle = PI * 2.0 / (1 << (base + 1));
		for(int i = 1 << (base - 1); i < (1 << base); i++) {
		rts[i << 1] = rts[i];
		real angle_i = angle * (2 * i + 1 - (1 << base));
		rts[(i << 1) + 1] = C(cos(angle_i), sin(angle_i));
		}
		++base;
	}
	}
 
	void fft(vector< C > &a, int n) {
	assert((n & (n - 1)) == 0);
	int zeros = __builtin_ctz(n);
	ensure_base(zeros);
	int shift = base - zeros;
	for(int i = 0; i < n; i++) {
		if(i < (rev[i] >> shift)) {
		swap(a[i], a[rev[i] >> shift]);
		}
	}
	for(int k = 1; k < n; k <<= 1) {
		for(int i = 0; i < n; i += 2 * k) {
		for(int j = 0; j < k; j++) {
			C z = a[i + j + k] * rts[j + k];
			a[i + j + k] = a[i + j] - z;
			a[i + j] = a[i + j] + z;
		}
		}
	}
	}
 
	vector< int64_t > multiply(const vector< int > &a, const vector< int > &b) {
	int need = (int) a.size() + (int) b.size() - 1;
	int nbase = 1;
	while((1 << nbase) < need) nbase++;
	ensure_base(nbase);
	int sz = 1 << nbase;
	vector< C > fa(sz);
	for(int i = 0; i < sz; i++) {
		int x = (i < (int) a.size() ? a[i] : 0);
		int y = (i < (int) b.size() ? b[i] : 0);
		fa[i] = C(x, y);
	}
	fft(fa, sz);
	C r(0, -0.25 / (sz >> 1)), s(0, 1), t(0.5, 0);
	for(int i = 0; i <= (sz >> 1); i++) {
		int j = (sz - i) & (sz - 1);
		C z = (fa[j] * fa[j] - (fa[i] * fa[i]).conj()) * r;
		fa[j] = (fa[i] * fa[i] - (fa[j] * fa[j]).conj()) * r;
		fa[i] = z;
	}
	for(int i = 0; i < (sz >> 1); i++) {
		C A0 = (fa[i] + fa[i + (sz >> 1)]) * t;
		C A1 = (fa[i] - fa[i + (sz >> 1)]) * t * rts[(sz >> 1) + i];
		fa[i] = A0 + A1 * s;
	}
	fft(fa, sz >> 1);
	vector< int64_t > ret(need);
	for(int i = 0; i < need; i++) {
		ret[i] = llround(i & 1 ? fa[i >> 1].y : fa[i >> 1].x);
	}
	return ret;
	}
};


int main(){
	vector<int> isp((1<<15)+1,1);
	isp[0]=isp[1]=0;
	FOR(i,2,(1<<15)+1){
		if(isp[i]){
			for(int j=i*2;j<((1<<15)+1);j+=i){
				isp[j] = 0;
			}
		}
	}
	auto s = FastFourierTransform::multiply(isp, isp);
	int n;
	while(cin>>n,n){
		int x=0;
		if((n/2)*2==n)x=n/2;
		cout << int(s[n]+isp[x])/2 << endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 8216
final_rank: 18

code_snippet: #include<iostream>
#include<cmath>
using namespace std;

bool judgePrimeNumber( int a )
{
    for( int i = 2; i <= sqrt(a); i++ )
        if( a % i == 0 )
            return false;
    return true;
}

int main()
{
    int n;

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

        int cnt = 0;
        for( int i = 2; i <= n / 2; i++ )
            if( judgePrimeNumber(i) && judgePrimeNumber(n-i) )
                cnt++;
        cout << cnt << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3084
final_rank: 5

code_snippet: #include <iostream>
    using namespace std;
bool primes[1000000];

void Sieve(){
 for(int i= 2; i < 1000000; i++){
   primes[i] = true;
 } 
 primes[1] = false;
 
 for(int i = 2; i <= 1000; i++){
   if(primes[i] == true)
     for(int j=i; j*i <= 1000000;j++){
       primes[j*i] = false;
     }
 }
}

bool IsPrime(int x){
 return primes[x];
}

int main(void){
    int k;
for(k = 1; k > 0; k++){
    Sieve();
    int n, c = 0;
    cin >> n;
    if(n == 0) break;
    else{
    for(int i = 0; i <= n/2; i++){
            if(IsPrime(i)==true){
                if(IsPrime(n - i)==true) c++;
            }
    }
 cout << c << endl;
 }
}
 
 return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 4072
final_rank: 14

code_snippet: #include <iostream>
#include <map>

using namespace std;

map<int, int> memo;

bool is_prim(int n) {
  if (n == 1) return false;
  if (n == 2) return true;
  if ((n % 2) == 0) return false;

  // NOTE: Return cached result
  if (memo.find(n) != memo.end()) {
    return memo[n];
  }

  bool isPrime = true;

  for (int i = 3; i * i <= n; ++i) {
    // Check dividability
    if ((n % i) == 0) {
      isPrime = false;
      break;
    }
  }

  // NOTE: Cache result
  memo[n] = isPrime;

  return isPrime;
}

int count_prim(int n) {
  map<int, int> p;
  int r = 0;

  for(int i = 2; i <= n / 2; ++i) {
    // NOTE: only for debug
    // cout << i << ": " << is_prim(i) << endl;
    // cout << n - i << ": " << is_prim(n - i) << endl;
    if (is_prim(i) && is_prim(n - i)) {
      ++r;
    }
  }

  return r;
}

int main(int argc, char** argv) {
  int n;
  // NOTE: only for debug
  // cout << "is_prim(1): " << is_prim(1) << endl;
  // cout << "is_prim(2): " << is_prim(2) << endl;
  // cout << "is_prim(3): " << is_prim(3) << endl;
  // cout << "is_prim(4): " << is_prim(4) << endl;
  // cout << "is_prim(5): " << is_prim(5) << endl;
  // cout << "is_prim(6): " << is_prim(6) << endl;
  // cout << "is_prim(7): " << is_prim(7) << endl;
  // cout << "is_prim(8): " << is_prim(8) << endl;
  // cout << "is_prim(9): " << is_prim(9) << endl;
  // cout << "is_prim(10): " << is_prim(10) << endl;
  // cout << "is_prim(11): " << is_prim(11) << endl;
  // cout << "is_prim(12): " << is_prim(12) << endl;
  // cout << "is_prim(13): " << is_prim(13) << endl;
  // cout << "is_prim(14): " << is_prim(14) << endl;
  // cout << "is_prim(15): " << is_prim(15) << endl;
  // cout << "is_prim(16): " << is_prim(16) << endl;
  // cout << "is_prim(17): " << is_prim(17) << endl;
  // cout << "is_prim(18): " << is_prim(18) << endl;
  // cout << "is_prim(19): " << is_prim(19) << endl;
  // cout << "is_prim(20): " << is_prim(20) << endl;
  cin >> n;
  while (n != 0) {
    // Do here
    // cout << n << endl;
    int r = count_prim(n);
    cout << r << endl;

    cin >> n;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3720
final_rank: 11

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

using db = double;
using ll = long long;
using vi = vector <int>;
using vl = vector <ll>;
//#define op operator
#define pb push_back

const int N = 1e5L + 11;
int p[N];

using comp = complex<db>; //??????comp????????¶??´: d /= 1.5, ld /= 3
using vc = vector<comp>; const db PI = atan(1.0L) * 4;
void dft(vc &a, int op = 1) {
	int n = a.size();
	for (int i = 1, j = 0; i < n - 1; ++i) {
		for (int s = n; j ^= s >>= 1, ~j & s;) {}
		if (i < j) swap(a[i], a[j]);
	}
	for (int i = 1; i < n; i *= 2) {
		comp u = {cos(PI / i), op * sin(PI / i)};
		for (int j = 0; j < n; j += i * 2) {
			comp w = 1;
			for (int k = 0; k < i; ++k, w = w * u) {
				comp x = a[j + k], y = w * a[j + k + i];
				a[j + k] = x + y, a[j + k + i] = x - y;
	}}}
	if (op == -1) for (int i = 0; i < n; ++i) a[i] /= n;
}
vl multi(vl a, vl b) { // ????????????: d <= 1e12, ld <= 1e14
	int n = 1; while (n < a.size() + b.size() - 1) n *= 2;
	vc fa(n), fb(n), fc(n);
	copy(a.begin(), a.end(), fa.begin()); dft(fa);
	copy(b.begin(), b.end(), fb.begin()); dft(fb);
	for (int i = 0; i < n; ++i) fc[i] = fa[i] * fb[i];
	dft(fc, -1); vl c(n);
	for (int i = 0; i < n; ++i) c[i] = round(fc[i].real());
	return c;
}

int main() {
	for(int i = 2; i < N; i ++) if(!p[i])
		for(int j = i; j < N; j += i) if(!p[j]) p[j] = i;

	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(0);

	vector <ll> v(N, 0);
	for(int i = 2; i < N; i ++)
		v[i] = p[i] == i;
	v = multi(v, v);

	for(int n; cin >> n && n; ) {
		cout << v[n] / 2 + (p[n / 2] == n / 2) << '\n';
	}

	return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 20204
final_rank: 20

code_snippet: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  vector<bool> prime(40000,true);

  for(i=2;i<40000;i++)
    if(prime[i])
      for(j=2;i*j<40000;j++)
        prime[i*j]=false;

  vi ans(40000,0);

  for(i=2;i<40000;i++)
    if(prime[i])
      for(j=i;j<40000;j++)
        if(prime[j] && i+j<40000)
          ans[i+j]++;

  while(1){
    cin>>n;
    if(n==0)break;
    cout<<ans[n]<<endl;
  }
}
accuracy: 1
time_ms: 150
memory_kb: 2988
final_rank: 9

code_snippet: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 32768+10000
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    vector<bool>Primecheck(MAX+1,true);
    vector<int>Primenumber(MAX+1,0); //Primearray
    int Primecounter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(Primecheck[i]){
            for(int j = 2;i*j<MAX;j++)
                Primecheck[i*j] = false;//?´???°??????Primearray???????´??????????????????°?????¨???false???
            Primenumber[Primecounter] = i;
            Primecounter++;
        }
    }
    while(cin>>n,n){
        int ans=0;
        for(int i=0; i<Primecounter;i++){
            if(Primenumber[i]>n)break;
            for(int j=i; j<Primecounter;j++){
                if(Primenumber[j]>n)break;
                if(Primenumber[i]+Primenumber[j]==n)
                    ans++;
            }
        }
        cout<<ans<<endl;
        ans=0;
    }
}
accuracy: 1
time_ms: 40
memory_kb: 2992
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a[33000]={0,0,1,1},c,i,j;
  for(i=4;i<33000;i++){
    for(j=2,c=1;j*j<=i;j++){
      if(i%j==0)c--;
    }
    if(c>0)a[i]=1;
    else a[i]=0;
  }
  while(cin>>n,n){
    for(i=3,c=0;i<n;){
      for(j=n-1;j>2;){
	if(i+j==n)c++;
	while(!a[--j]);
      }
      while(!a[++i]);
    }
    cout<<(c-1)/2+1<<endl;
  }
}
accuracy: 1
time_ms: 1550
memory_kb: 3132
final_rank: 17

code_snippet: #include <bits/stdc++.h>

using namespace std;

vector<int> pn;
vector<bool> is_p;

void enum_prime()
{
  is_p.resize(1<<15, true);
  is_p[0] = is_p[1] = false;
  for(int i = 2; i < 1<<15; i++) {
    if(!is_p[i]) continue;
    pn.push_back(i);
    for(int j = i+i; j < 1<<15; j+=i) is_p[j] = false;
  }
}

int main()
{
  int n;
  enum_prime();
  while(cin >> n, n) {
    int cnt = 0;
    for(int i = 0; i < pn.size() && pn[i] < n; i++) {
      for(int j= i; j < pn.size() && pn[i] + pn[j] <= n; j++) {
	if(pn[i] + pn[j] == n) cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3100
final_rank: 7

code_snippet: #include <bits/stdc++.h>

using namespace std;

bool check(int n){
  if(n==1||n==0)return 0;
  for(int i=2;i*i<=n;i++) if(n%i==0)return 0;
  return 1;
}

int main(){
  int n;
  
  while(cin>>n,n){
    int cnt=0;
    for(int i=0;i<n;i++)
      if(check(i)&&check(n-i)&&i<=n-i)cnt++;
    cout <<cnt<<endl;
        }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3096
final_rank: 6

code_snippet: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

bool isPrime(int n){
    if(n==1)return false;
    if(n==2)return true;
    for(int i=2;i<sqrt(n)+1;i++){
        if((n%i)==0)return false;
    }
    return true;
}


int main(){
    
    while(true)
    {
        int n;
        cin>>n;
        if(n==0)
        {
            break;
        }
        
        int ans=0;
        for(int i=2;i<=n/2;i++)
        {
            if(isPrime(i)&&isPrime(n-i))ans++;
        }
        
        cout<<ans<<endl;
        
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 2984
final_rank: 3

code_snippet: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;

int main() {
	vector<bool> prime(1<<15, true);
	prime[0] = prime[1] = false;
	FOR(i, 2, 1<<15) {
		if(prime[i]) {
			for(int j=i*2; j < 1<<15; j += i)
				prime[j] = false;
		}
	}
	int n;
	while(cin >> n, n) {
		int cnt = 0;
		REP(i, n) {
			if(prime[i] > n)
				break;
			FOR(j, i, n) {
				if(prime[j] > n)
					break;
				if(prime[i] && prime[j] && i + j == n) {
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 6530
memory_kb: 1200
final_rank: 19

code_snippet: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

#define N (1 << 15) 

int main(){
    bool prime[N] = {1,1,0};
    vector<int> v;
    rep(i,N){
        if(!prime[i]){
            v.pb(i);
            for(int j = i + i; j < N; j+=i){
                prime[j] = 1;
            }
        }
    }
    map<int, int> cnt;
    rep(i,v.size()){
        range(j,i,v.size()){
            cnt[v[i] + v[j]]++;
        }
    }
    int n;
    while(cin >> n,n){
        cout << cnt[n] << endl;
    }
}
accuracy: 1
time_ms: 390
memory_kb: 2964
final_rank: 13

code_snippet: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e7+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
bool is_prime[100100];
int prime[100100];
int p = 0;

int main(){
	fill(is_prime, is_prime + 100100, 1);
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i < 100100; i++){
		if (is_prime[i]){
			prime[p] = i;
			p++;
			for (int j = i * 2; j < 100100; j += i){
				is_prime[j] = 0;
			}
		}
	}
	while (cin >> n&&n){
		int ans = 0;
		REP(i, p){
			for (int j = i; j < p; j++){
				if (prime[i] + prime[j] == n)ans++;
			}
		}
		cout << ans << endl;
	}
}
accuracy: 1
time_ms: 1320
memory_kb: 1296
final_rank: 15

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
const int PrimeMax = 50001;
int is_prime[PrimeMax];
void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    is_prime[i] = 1;
  }
  is_prime[1] = 0;
  for(int i = 2; i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}
int ans[50001];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Eratosthenes(PrimeMax);
  vary(int,v,0,0);
  v.clear();
  rep(i,PrimeMax){
    if(is_prime[i] != 0){
      v.pb(i);
    }
  }
  REP(i,1,v.size()){
    REP(j,i,v.size()){
      if(v[i] + v[j] < PrimeMax){
        ans[v[i]+v[j]]++;
      }
    }
  }
  int n;
  while(cin >> n&&n){
    cout << ans[n] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3532
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

vector<int> sieve(int n) {
  vector<int> p(n);
  REP(i,2,n) p[i]=i;
  for(int i=2; i*i<n; i++) {
    if(p[i]) {
      for(int j=i*i; j<n; j+=i) p[j]=0;
    }
  }
  p.erase(remove(all(p),0),p.end());
  return p;
}

void Main() {
  vector<int> p=sieve(33000);
  int n;
  while(R n && n) {
    int ans=0;
    rep(i,p.size()) {
      REP(j,i,p.size()) {
        if(p[i]+p[j]>n) break;
        if(n==p[i]+p[j]) ans++;
      }
    }
    pr(ans);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 1268
final_rank: 1

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

vector<int> sieve(int n) {
  vector<int> p(n);
  REP(i,2,n) p[i]=i;
  for(int i=2; i*i<n; i++) {
    if(p[i]) {
      for(int j=i*i; j<n; j+=i) p[j]=0;
    }
  }
  p.erase(remove(all(p),0),p.end());
  return p;
}

void Main() {
  vector<int> p=sieve(33000);
  int n;
  while(R n && n) {
    int ans=0;
    rep(i,p.size()) {
      REP(j,i,p.size()) {
        if(n==p[i]+p[j]) ans++;
      }
    }
    pr(ans);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}
accuracy: 1
time_ms: 160
memory_kb: 1268
final_rank: 2