Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	prime := make([]int, 1000001)
	prime[0], prime[1] = -1, -1
	for i := 2; i < 1000001; i++ {
		if prime[i] != -1 {
			prime[i] = 1 // i means "prime"
			for j := i+i; j < 1000001; j += i {
				prime[j] = -1 // -1 means "not prime"
			}
		}
	}
	for scanner.Scan() {
		ret := 0
		a, _ := strconv.Atoi(scanner.Text())
		if a == 0 {
			break
		}
		for i := 1; i <= a/2; i++ {
			if prime[i] == 1 && prime[a-i] == 1 {
				ret++
			}
		}
		fmt.Println(ret)
	}
}

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

const int MAXP = 1000001;
bool isP[MAXP];
vector<int> Ps;

int main() {
  fill(isP, isP+MAXP, true);
  isP[0] = isP[1] = false;
  for(int i = 2; i < MAXP; ++i) {
    if(!isP[i]) continue;
    Ps.push_back(i);
    for(int j = i*2; j < MAXP; j += i) isP[j] = false;
  }
  for(int n; cin >> n && n;) {
    int res = 0;
    for(int i = 0; i < Ps.size(); ++i) {
      int p = Ps[i];
      int q = n - Ps[i];
      if(p <= q && isP[q]) {
        ++res;
      }
    }
    cout << res << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

bool isPrime[1000000];
int main()
{
	fill(isPrime, isPrime+1000000, true);
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i < 1000000; ++i)
	{
		if (isPrime[i])
		{
			for (int j = 2*i; j < 1000000; j += i)
				isPrime[j] = false;
		}
	}

	int n;
	while (scanf("%d", &n), n)
	{
		int ans = 0;
		for (int i = 3; i <= n/2; i += 2)
			if (isPrime[i] && isPrime[n-i])
				++ans;
		printf("%d\n", ans);
	}

	return 0;
}

C++: #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;
    }

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

ll arr[1000010];

void Eratosthenes(ll n) {
	for (int i = 0; i <= n; i++)
		arr[i] = 1;

	for (int i = 2; i <= sqrt(n); i++) {
		if (arr[i]) {
			for (int j = 0; i*(j + 2) <= n; j++)
				arr[i*(j + 2)] = 0;
		}
	}
}

int main()
{
	ll n;
	while (cin >> n, n)
	{
		ll cnt = 0;
		Eratosthenes(n);
		for (int i = 2; i <= n / 2 + n % 2; i++) {
			if (arr[i]) {
				if (arr[n - i])cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

C++: 
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int MAX_PRIME = 1000000;


int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;

void erats(){
	// primeツδ環スツトツづーツ渉可甘コツ可サ
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;
		// ツづ督づゥツつ「ツづ可つゥツつッツづゥ
		for(int j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
		cout << flush;
	}
}



int main(){
	erats();
	vector<int> data(1000100,0);
	int n;
	while(cin>>n&&n!=0){
		int cnt=0;
		for(int i = 0; i < p; i++){
			int left = n - prime[i];
			if(left<0||left<(n/2))
				break;
			if(isPrime[left])
				cnt++;
		}
		cout<<cnt<<endl;
	}

	return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto P=enum_prime(1000000);
	sort(ALL(P));
	int M=P.size();
	
	while(true){
		int N=in();
		if(!N) break;

		int sum = 0;
		for(int i=0;i<M;i++){
			int V=N-P[i];
			if(binary_search(P.begin()+i,P.end(),V)) sum++;
		}
		out(sum);
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
#define MAX 1000001
  bool num[MAX]={1,1,0};
  for(int i=3;i<MAX;i+=2){
    if(num[i])continue;
    for(int j=i*3;j<MAX;j+=i*2){
      num[j]=1;
    }
  }
  int n;
  while(cin>>n,n){
    int co=0;
    for(int i=3;i<=n/2;i+=2){
      if(!num[i]&&!num[n-i])co++;
    }
    cout<<co<<endl;
  }


}

C++: #include <iostream>
#include <cmath>

using namespace std;

int const N = 1000000;

int ps[N+1];
int cnt[N+1]={};

bool isp[N+1]={};

int idx=0;
inline void add(int n){
    ps[idx++]=n;
}

void init(){
    for(int i=0; i<=N; i++) isp[i]=true;
    add(2);
    for(int i=4; i<=N; i+=2) isp[i]=false;
    for(int i=3; i<=N; i+=2){
        if(!isp[i]) continue;
        add(i);
        for(int j=i+i; j<=N; j+=i) isp[j]=false;
    }

    for(int i=0; i<idx; i++){
        for(int j=i; j<idx; j++){
            int c=ps[i]+ps[j];
            if(c>N) break;
            cnt[c]++;
        }
    }
}

int main(){
    init();

    int n;
    while(cin>>n, n){
        cout << cnt[n] << endl;
    }
}