Go: package main

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

var scanner= bufio.NewScanner(os.Stdin)

func main() {
	MAX := 10001
	SQRT := 100
	isPrime := make([]bool, MAX)
	for i :=range isPrime {
		isPrime[i] = true
	}
	for i := 3; i < SQRT; i += 2 {
		if isPrime[i] {
			for j := i*i; j < MAX; j += i {
				isPrime[j] = false
			}
		}
	}
	// log.Println(isPrime)
	tbl := make([]int, MAX)
	ans := 0
	for i := 5; i < MAX; i += 2 {
		if isPrime[i] && isPrime[i-2] {
			ans = i
		}
		tbl[i] = ans
	}
	// log.Println(tbl)
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		if n&1 == 0 {
			n--
		}
		fmt.Printf("%d %d\n", tbl[n]-2, tbl[n])
	}
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1];
int main(){
  int i,k,v,n,j,i1 = 0,i2 = 0,max = 0,p1,q1;
  for(i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(i = 2;i*i <= MAX_V;i++){
    if(prime[i]){
      for(k = 2 * i;k <= MAX_V;k += i){
        prime[k] = 0;
      }
    }
  }
  while(1){
    scanf("%d",&n);
    if(n == 0){
      break;
    }
    for(j = 0;j + 2 < n;j++){
      int isprime = prime[j];
      int isprime2 = prime[j + 2];
      if(isprime) i1 = 1;else i1 = 0;
      if(isprime2) i2 = 1;else i2 = 0;
      if(i1 == 1 && i2 == 1){
        max = j;
      }
    }
    p1 = max;
    q1 = max + 2;
    printf("%d%d\n",p1,q1);
  }
  return 0;
}

C++: #include<stdio.h>
 
bool f[10003];
 
bool f2[10003];
 
 
int main(){
 
for(int i=0;i<10002;i++)
for(int j=2;j*j<=i;j++)
{if(i%j!=0)f[i]=true;
else{ f[i]=false;break;}
}
f[3]=true;f[5]=true;
 
for(int i=0;i<10002;i++) 
if(f[i]==true&&f[i+2]==true)f2[i]=true;
f2[5]=true;
int n;
while(1){
scanf("%d",&n);if(n==0)break;
int p=0,q=0;
for(int i=n-2;i>=5;i--)
if(f2[i]==true){q=i+2;p=i;break;}
if(n<=6){p=3;q=5;}
printf("%d %d\n",p,q);
}
return 0;
}

C++: #include<stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1];
int isprime(int n)
{
  int i, k, v;
  for(i = 2; i <= MAX_V; i++)
    {
      prime[i] = 1;
    }
  for(i = 2; i*i <= MAX_V; i++)
    {
      if(prime[i])
      {
        for(k = 2 * i; k <= MAX_V; k += i)
         {
           prime[k] = 0;
         }
      }
    }
  int isprime = prime[n];
  if(isprime) return 1;
  else return 0;
}

int main(void)
{
  int n,i,t=0,MAX=0;
  while(1)
  {
    scanf("%d",&n);
  //  if(isprime(n))printf("OK");
    if(n==0)  break;
    for(i=n;i>0;i--)
    {
      if(isprime(i)==1 && isprime(i-2) == 1)
        {
          MAX=i;
          printf("%d %d\n",MAX-2,MAX);
          break;
        }
    }
  }
}

C++: int main(void){
	int i,j;
	int isprime[1000];
 	//???????????????????????°????´???°?????¨??????
	for(i=0;i<=1000;i++){
 		isprime[i]=1;
	}
 //????????????????????????????????????
	isprime[0]=isprime[1]=0;
 //2??????????????????
	for(i=2;i<=1000;i++){
 		if(isprime[i]==1){
 			for(j=2*i;j<=1000;j+=i){
				isprime[j]=0;
			}
		}
	}

 //???????´???°?????????????????????
	for(i=2;i<=1000;i++){
		if(isprime[i-2]==1 && isprime[i]==1){
			print("(%d,%d)",i-2,i);
		}
	}
	return 0;
 }

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

bool is_prime[10001];
 
void sieve(){
	fill(is_prime,is_prime+10001,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<=10000; ++i){
		if(is_prime[i]){
			for(int j=2; i*j<=10000; ++j){
				is_prime[i*j]=false;
			}
		}
	}
}

int main(){
	sieve();
	int N;
	while(cin >> N&&N){
		for(int i=N; i>=2; --i){
			//cout << i << endl;
			if(is_prime[i]&&is_prime[i-2]){
				cout << i-2 << ' ' << i << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include<cmath>
#include<iostream>
#define N 10002
using namespace std;
int eratos[N]; // [N]=0 -> N is prime
void createPrimeTable(){
	for(int i = 2; i < N; ++i){
		if( eratos[i] == 0 ){
			for(int j = 2; i * j < N; ++j){
				eratos[ i * j ] = 1;
			}
		}
	}
}
int main()
{
	createPrimeTable();
	while(true){
		int n;
		int p = 0;
		int q = 0;
		cin >> n;
		if( n == 0 ) break;
		for(int i = 5; i <= n - 2; ++i){
			if( eratos[ i ] == 0 && eratos[ i + 2 ] == 0 ){
				p = i;
				q = i + 2;
			}
		}
		cout << p << ' ' << q << '\n';
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
bool judge(int a){
	for(int n=2;n<a;n++){
		if(a%n==0){
			return false;
		}
	}
		return true;
}

int jat(int a){
	for(int n=0;n<a;n++){
		if(judge(a)){
			if(judge(a-2)){
				return a;
			}
		}
		a--;
	}
	return a;
}
		
		
int main(){
	while(true){
		int a,ans;
		cin>>a;
		if(a==0){
			break;
		}
		ans=jat(a);
		printf("%d %d\n",ans-2,ans);
	}
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n,max,mx;
	int flg[100001];
	while(1) {
		scanf("%d",&n);
		if(n==0) break;
		for(i=2;i<=n;i++) flg[i]=1;
		for(i=2;i*i<=n;i++) {
			if(flg[i]==1) {
				for(j=2;j*i<n;j++) flg[i*j]=0;
			}
		}
		max=-1;
		mx=-1;
		for(i=2;i<n;i++) {
			if(flg[i]==1 && flg[i]==flg[i+2] && i+2<=n) {
				if(max<i) max=i;
				if(mx<i+2) mx=i+2;
			}
		}
		printf("%d %d\n",max,mx);
	}
	return 0;
}

C++: #include <cstdio>
#include <vector>
using namespace std;
int main()
{
	int maxsize(0);
	vector<int> input;

	while (1)
	{
		int tmp;

		cin >> tmp;

		(maxsize < tmp) ? (maxsize = tmp) : (0);
	}

	vector<int> prime, ans;

	for (int i(1); i <= maxsize; ++i)
	{
		for (auto i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
		{
			if (i % *i2 == 0)
			{
				prime.push_back(i);
				if (i2 != prime.begin())
				{
					if (*(--i2) == i)
					{
						ans.push_back(i);
					}
				}
				break;
			}
		}
	}

	for (auto i(input.begin()), n(input.end()); i != n; ++i)
	{
		int out(0);

		for (auto i2(ans.rbegin()), n2(ans.rend()); i2 != n2; ++i2)
		{
			if (*i2 <= *i)
			{
				cout << *i2 - 2 << ' ' << *i2 << endl;
			}
		}
	}

	return 0;
}