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 <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

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

void sieve(int n){ 
	int p=0;
	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]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
		}
	}
	return;
}

int main(){
	int n;
	sieve(1000000);
	while(cin>>n){
		if(n==0) break;
		int res=0;
		rep(i,2,n/2+1){
			if(is_prime[i] && is_prime[n-i]) res++;
		}
		o(res);
	}
}

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

using namespace std;

int p[1000000];
int pt[1000000];
int pn;

int dp[1000001];

void init(){
  memset(p,1,sizeof(int)*1000000);
  memset(pt,0,sizeof(int)*1000000);
  memset(dp,0,sizeof(int)*1000001);
  p[0] = p[1]  = 0;
  for(int i =0; i < 1000; i++){
    if(p[i]){
      for(int j = i +i;j < 1000000;j +=i){
	p[j] = 0;
      }
    }
  }
  pn =0;
  for(int i = 0; i < 1000000;i++){
    if(p[i]){
      pt[pn] = i;
      pn++;
    }
  }

  for(int i = 0 ; i< pn; i++){
    for(int j =i; j < pn; j++){
      if(pt[i]+pt[j] > 1000000){
	break;
      }
      dp[pt[i]+pt[j]]++;
    }
  }
}

int main(){
  int in;
  init();
  while(1){
    cin>>in;
    if(!in){
      break;
    }
    cout << dp[in] << endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int prime[100001];
    for(int i=2;i<100001;i++)prime[i]=0;
    for(int i=2;i<=sqrt(100001);i++){
        if(prime[i]==0){
            for(int j=i+i;j<100001;j+=i)prime[j]=1;
        }
    }
    int n,cou=0;
    while(cin>>n&&n!=0){
        for(int i=2;i<=n/2;i++)if(prime[i]==0&&prime[n-i]==0)cou++;
        cout<<cou<<endl;
        cou=0;
    }
}

C++: #include<iostream>
#include<utility>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> p;

bool prime[10000000];

int main(){
	rep(i,10000000)prime[i]=true;
	prime[0]=prime[1]=false;
	loop(i,2,1000){
		for(int j=i*2;j<10000000;j+=i)prime[j]=false;
	}
	int n;
	while(cin>>n,n){
		int cnt=0;
		bool used[n];
		rep(i,n)used[i]=true;
		loop(i,2,n-1){
			if(prime[i] && prime[n-i] && used[i] && used[n-i]){
				used[i]=used[n-i]=false;
				cnt++;
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	bool p[1000000] = {};
	p[0] = p[1] = true;
	rep(i,1001) {
		if(!p[i]) {
			for(int j = 2*i; j<1000000; j+=i) {
				p[j] = true;
			}
		}
	}
	int n;
	while(cin>>n,n) {
		int cnt = 0;
		rep(i,n/2+1) {
			if(!p[i] && !p[n-i]) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int a[1000000]={1,1},s[500000],c;
int main(){
	r(i,2,100000)
	for(int j=i*2;j<1000000;j+=i)a[j]++;
	r(i,2,1000000)if(!a[i])s[c++]=i;
int n;
while(cin>>n,n){
	int ss=0;
	r(i,0,n)
	r(j,i,n)
	if(s[i]+s[j]==n){ss++;}
	cout<<ss<<endl;
}
}

C++: #include<iostream>
#include<vector>
#define MAX 500000
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 <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);
	for (int i = 2; i < 1000; ++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>
#include<vector>
#define MAX 500000
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++;
		if(box[j]+box[i]>n)
		break;
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

#define MAX 1000000

int main( void )
{
	// ツ素ツ青板表ツづーツ催ャツ青ャツつキツづゥ
	vector <bool> is_prime( MAX + 1, false );
	is_prime[2] = 0;
	for ( int i = 3; i < MAX + 1; i += 2 )
		is_prime[i] = true;
	for ( int i = 3; i < MAX + 1; i += 2 )
	{
		if ( is_prime[i] )
		{
			for ( int j = i + i; j < MAX + 1; j += i )
				is_prime[j] = false;
		}
	}

	int n;
	while ( cin >> n && n > 0 )
	{
		int cnt = 0;
		if ( is_prime[n-2] )
			cnt++;
		for ( int i = 3; i <= n / 2; i += 2 )
		{
			if ( is_prime[i] && is_prime[n-i] )
				cnt++;
		}
		cout << cnt << endl;
	}

	return 0;
}

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

bool ba[m + 1] = { true };
void cp() {
	int co = 0;
	for (int i = 0; i < m + 1; i++) {
		ba[i] = { true };
	}
	for (int i = 2; i*i <= m; i++) {
		if (ba[i]) {
			for (int j = i*i; j <= m; j += i) {
				ba[j] = { false };
			}
		}
	}

	return;
}

int main() {
	int n;
	cp();
	while (cin >> n, n) {
		int c = 0;
		for (int i = 2;i <= n / 2;i++) {
			int j = n - i;
			if (ba[i] == true && ba[j] == true)c++;
		}
		cout << c << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>

char so[1000001];

int main(){
	int n,i,j,count;
	memset(so,0,sizeof(so));
	so[1]=1;
	for(i=2;i<1000;){
		for(j=i;i*j<=1000000;j++){
			printf("%d %d\n",i,j);
			so[i*j]=1;
		}
	}
	count=0;
	while(0<=scanf("%d",&n)){
		for(i=2;2*i<=n;i++){
			if(so[i]==0 && so[n-i]==0)++count;
		}
		printf("%d\n",count);

	}
	return 0;
}