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 <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;

int p[1000000];
int main()
{
	for (int i = 2; i < 1000; ++i)
	{
		if (!p[i])
		{
			for (int j = 2*i; j < 1000000; j += i)
				p[j] = 1;
		}
	}

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

	return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
	vector<int> a(MAX);
	vector<int> box(MAX);
	int n,sum,k=0;
	for(int i=0;i<MAX;i++)
	a[i]=1;
	a[0]=0;a[1]=0;
	for(int i=0;i*i<MAX;i++)
	if(a[i]){
		for(int j=i*2;j<MAX;j+=i)
		a[j]=0;
	}
	for(int i=0;i<MAX;i++)
	if(a[i])
	box[k++]=i;
	while(cin>>n,n){
		sum=0;
		for(int i=0;box[i]<n;i++)
		for(int j=0;box[j]<=box[i];j++)
			if(box[j]+box[i]==n)
			sum++;
		cout<<sum<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
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] ] ++;

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

    return 0;
}

C++: #include<vector>
#include<iostream>
using namespace std;
namespace AOJ0185
{
	class Primes
	{
	private:
		vector<int> primes;

	public:
		Primes(int max)
		{
			vector<bool> flags(max + 1, true);
			for (int i = 2; i <= max; i++)
			{
				if (flags[i])
				{
					primes.push_back(i);
					for (int j = i; j <= max; j += i)
					{
						flags[j] = false;
					}
				}
			}
		}

		int operator[](int index)
		{
			return primes[index];
		}

		int size()
		{
			return primes.size();
		}
	};

	class Solver
	{
	private:
		static const int MAX_N = 1000001;
		int answers[MAX_N] = {};
		void CalcAnswers()
		{
			Primes primes(MAX_N);
			for (int i = 0; i < primes.size(); i++)
			{
				for (int j = i; j < primes.size(); j++)
				{
					int sum = primes[i] + primes[j];
					if (sum >= MAX_N)break;
					answers[sum]++;
				}
			}
		}

		int Input()
		{
			int n;
			cin >> n;
			return n;
		}

		void Output(int n)
		{
			cout << answers[n] << endl;
		}

	public:
		void Solve()
		{
			CalcAnswers();
			int n;
			while (n = Input())Output(n);
		}
	};
}

int main()
{
	AOJ0185::Solver().Solve();
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int prime[1000000];
bool isprime[1000001];

int sieve(int n){
	int p=0;
	for(int i=0;i<=n;i++)isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(int i=0;i<=n;i++){
		if(isprime[i]){
			prime[p++]=i;
			for(int j=i*2;j<=n;j+=i)isprime[j]=false;
		}
	}
	return p;
}

int main(){
	sieve(1e+6);
	int n;
	while(cin>>n){
		if(!n)return 0;
		int ans=0;
		for(int i=2;i<=n/2;i++)if(isprime[i]&&isprime[n-i])ans++;
		cout<<ans<<endl;
	}
}

C++: #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 = 1000000;
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*i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}
int ans[PrimeMax];
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);
    }
  }
  int n;
  while(cin >> n&&n){
    int res = 0;
    REP(i,2,v.size()){
      REP(j,i,v.size()){
        if(v[i] + v[j] == n){
          res++;
          break;
        }
        else if(v[i] +v[j] > n){
          break;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
	vector<int> a(MAX);
	vector<int> box(MAX);
	int n,sum,k=0,l,r,mid;
	for(int i=0;i<MAX;i++)
	a[i]=1;
	a[0]=0;a[1]=0;
	for(int i=0;i*i<MAX;i++)
	if(a[i]){
		for(int j=i*2;j<MAX;j+=i)
		a[j]=0;
	}
	for(int i=0;i<MAX;i++)
	if(a[i])
	box[k++]=i;
	while(cin>>n,n){
		sum=0;
		for(int i=0;box[i]<n;i++){
			if(box[i]*2<n)
			continue;
				l=0;r=i;
				while(r-l>1){
					mid=(r+l)/2;
					if(box[mid]>=n-box[i]){
						r=mid;
					}else {
						l=mid;
					}
				}
			if(box[r]+box[i]==n){
				sum++;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

using namespace std;

#define MAX 1000001

vector<int> vprimes;
bool *isPrime = new bool[MAX];

/* ツ素ツ青板青カツ青ャ O(n^2) */
void MakePrime(){
  isPrime[0]=false;
  isPrime[1]=false;
  isPrime[2]=true;
  for(int i = 2; i < MAX; ++i){
    isPrime[i] = true;
  }
  for(long long int i = 2; i < MAX; ++i){
    if( isPrime[i] ){
      for(long long int j = 2; i * j < MAX; ++j) {
	isPrime[i*j] = false;
      }
    }
  }
  for(int i = 0; i < MAX; ++i){
    if( isPrime[i] ){
      vprimes.push_back( i );
    }
  }
}

int main(){
  MakePrime();
  while(true){
    int n;
    int cnt = 0;
    bool same=false;
    cin >> n;
    if( n == 0 ) break;
    for(int i = 1; i < vprimes.size() && vprimes[i] < n - 2; ++i){
      if( isPrime[ n - vprimes[i] ] ){
	cnt++;
	if( n - vprimes[i] == vprimes[i] ){--cnt;same=true;}
      }
    }
    cnt/=2;
    cout << cnt+same << endl;
  }
  return 0;
}