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;

vector<string> ans;
string str;

map<pair<int, string>, bool> mp;

bool comp(string a, string b)
{
  for(int i = 0; i < a.size(); i++){
    if(a[i] < b[i]) return true;
  }
  return false;
}

void solve(int idx, string s)
{
  if(mp.count(make_pair(idx, s)) == 1) return;
  if(idx == s.size()){
    if(s != str) ans.push_back(s);
    return;
  }
  if(s[idx] < 'z' && s.find(s[idx]) == idx){
    if(s[idx] == 'a'){
      solve(idx + 1, s);
      s[idx]++;
      solve(idx + 1, s);
    } else {
      s[idx]++;
      solve(idx + 1, s);
    }
  } else {
    solve(idx + 1, s);
  }
  if(s[idx] < 'z' && s[idx] == str[idx]){
    if(s[idx] == 'a'){
      solve(idx + 1, s);
      s[idx]++;
      solve(idx + 1, s);
    } else {
      s[idx]++;
      solve(idx + 1, s);
    }
  }
  mp[make_pair(idx, s)] = true;
  return;
}

int main()
{
  while(cin >> str, str != "#"){
    solve(0, str);
    sort(ans.begin(), ans.end());
    cout << ans.size() << endl;
    if(ans.size() <= 5){
      for(int i = 0; i < ans.size(); i++){
	cout << ans[i] << endl;
      }
    } else {
      for(int i = 0; i < ans.size(); i++){
	if(i < 5 || ans.size()-5 <= i) cout << ans[i] << endl;
      }
    }
    mp.clear();
    ans.clear();
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    for(int i=3;i<=1e7;i++){
	bool flg = true;
	for(int j=0;primes[j]*primes[j] <= i;j++){
	    if(i % primes[j] == 0){
		flg = false;
		break;
	    }
	}
	if(flg) primes.PB(i);
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int ans = 0;
	for(int i=0;primes[i]<=n;i++){
	    for(int j=i;primes[i]+primes[j]<=n;j++){
		if(primes[i] + primes[j] == n) ans++;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

int f[1000000],s[80000];

int main() {
   int n,i,j,k=0;
   for (i=2;i<1000000;i++) if (f[i]==0) {
	   f[i]=1; s[k++]=i;
	   for (j=i+i;j<1000000;j+=i) f[j]=2;
   }
   while ( cin >> n && n>0) {
	   for (i=0,j=0;s[i]<=n/2;i++) if (f[n-s[i]]==1)  j++;
	   cout << j << endl;
   }  
return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    for(int i=3;i<=1e7;i++){
	bool flg = true;
	for(int j=0;primes[j]*primes[j] <= i;j++){
	    if(i % primes[j] == 0){
		flg = false;
		break;
	    }
	}
	if(flg) primes.PB(i);
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int ans = 0;
	for(int i=0;primes[i]<=n;i++){
	    for(int j=primes.size()-1;primes[i]+primes[j]>=n;j--){
		if(primes[i] + primes[j] == n) ans++;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    for(int i=3;i<=1e7;i++){
	bool flg = true;
	for(int j=0;primes[j]*primes[j] <= i;j++){
	    if(i % primes[j] == 0){
		flg = false;
		break;
	    }
	}
	if(flg) primes.PB(i);
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int ans = 0;
	for(int i=0;primes[i]<=n/2;i++){
	    int j = lower_bound(ALL(primes),n-primes[i]) - primes.begin();
	    if(primes[j] + primes[i] == n) {
		ans++;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

C++: // 0185
#include <iostream>
#define  N   1000001
using namespace std;

int main(){
	bool prime[N];
	for(int i=2;i<N;i++)
		prime[i] = true;

	for(int i=4;i<N;i+=2)
		prime[i] = false;

	for(int i=3;i<N;i+=2)
		if(prime[i])
			for(int j=2*i;j<N;j+=i)
				prime[j] = false;
	
	while(1){
		int n, count = 0;
		cin>>n;

		if(n == 0)
			break;

		if(prime[2] && prime[n-2])
			count++;

		for(int i=3;i<=n/2;i++)
			if(prime[i] && prime[n-i])
				count++;

		cout<<count<<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
int cnt[7];
int main(){
    int i,j,n,prime[1000001];
    prime[0]=prime[1]=-1;
    for(i=2;i<=1000000;i++){
        if(prime[i]!=-1){
            prime[i]=1;
            for(j=i+i;j<=1000000;j+=i)prime[j]=-1;
        }
    }
    while(cin>>n,n){
        int cnt=0;
        for(i=1;i<=n/2;i++){
            if(prime[i]==1&&prime[n-i]==1) cnt++;
        }
        cout<<cnt<<endl;
        }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for((i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int MAX_N = 1000002;
int n;
vector<int> prime(1,2);
bool sieve[MAX_N];

int solve() {
  const int half = *lower_bound(prime.begin(), prime.end(), n/2+1);
  int ans = 0;
  for (int i = 0; i < prime.size(); ++i) {
    if (half < prime[i]) break;
    const int value = n - prime[i];
    if (binary_search(prime.begin(), prime.end(), value)) ans++;
  }
  return ans;
}

int main() {
  fill(sieve, sieve + MAX_N, true);
  sieve[0] = sieve[1] = false;
  for (int i = 4; i < MAX_N; i+=2) sieve[i] = false;
  for (int i = 3; i < MAX_N; i+=2) if (sieve[i]) {
    prime.push_back(i);
    for (int j = i + i; j < MAX_N; j+=i) sieve[j] = false;
  }
  while (cin >> n, n) {
    cout << solve() << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;

int memo[100000];
int dummy_prime(int n,int i){return memo[n] ? memo[n] : memo[n] = i>1 ? n%i ? dummy_prime(n,i-1) : -1 : 1;}
int isprime(int n){return memo[n] ? memo[n] : memo[n]=n>1 ? dummy_prime(n,sqrt(n)) : -1;}
int main()
{
	int n,result;
 
	while(cin >> n && n){
		result=0;
		for(int i=2;i<=n-i;i++)
			if(isprime(i)==1 && isprime(n-i)==1)result++;
		cout << result << endl;
	}
}