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 <iostream>
#include <vector>
using namespace std;

int main()
{
	int n;

	while (cin >> n, n){
		vector<bool> num(n + 1, true);
		
		for (int i = 2; i <= n; i++){
			if (num[i]){
				for (int j = i; j * i <= n; j++){
					num[j * i] = false;
				}
			}
		}
		bool check = false;
		for (int i = n; i >= 2; i--){
			if (num[i]){
				for (int j = i - 1; j >= 2; j--){
					if (num[j]){
						if (i - j == 2){
							cout << j << " " << i << endl;
							check = true;
							break;
						}
					}
				}
			}
			if (check){
				break;
			}
		}
		num.clear();
	}
	
	return (0);
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

const int N_prime = 15000;

class prime
{
		public:
			prime();
			vector<int> primeList;
			bool used[N_prime];
};

prime::prime()
{
	memset(used, true, sizeof(used));

	//一千万までの素数
	for(int i = 2; i < sqrt( N_prime ); i++)
	{
		if(used[i] == false)
		{
			continue;
		}

		for(int j = i*2; j < N_prime; j += i)
		{
			used[j] = false;
		}
	}

	for(int i = 2; i < N_prime; i++)
	{
		if(used[i] == true)
		{
			primeList.push_back(i);
		}
	}
}
int main()
{
	prime twin;
	int limit;
	while(cin >> limit, limit)
	{
		for(int i = 0; i < 10001; i++)
		{
			if(twin.primeList[i] >= limit)
			{
				limit = i-1;
				break;
			}
		}
		for(int i = limit; i > 0; i--)
		{
			if(twin.primeList[i-1] == twin.primeList[i]-2)
			{
				printf("%d %d\n",twin.primeList[i-1] ,twin.primeList[i]);
				break;
			}
		}
	}
}

C++: //include
//------------------------------------------
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n)  FOR(i,0,n)

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
//-------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//typedef
//-------------------------------------------
typedef long long ll;

int memo[10001];
int isprime(int x) {
    if (x < 0 ) return 0;
    if (x == 2) return 1;
    if (x % 2 == 0) return 0;

    int l = (int)sqrt(x);
    for (int i = 3; i <= l; i += 2) {
        if (x % i == 0) return 0;
    }

    return 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int m;
    while(1) {
        cin >> m;
        if (m == 0) break;
        FORR(j, m, 0) {
            if (isprime(j) && isprime(j - 2)) {
                cout << j - 2 << " " << j << endl;
                break;
            }
        }
    }

    return 0;
}

C++: #include<stdio.h>
int main(void)
{
    int a,i,flg1,p,q,l,b,a2,b2;
	scanf("%d",&a);
	while(a!=0){
	    flg1=1;
		p=0;
		q=0;
		a2=0;
		b2=0;
	    for(i=5;i<=a;i++){
		    for(l=2;l<i-2;l++){
			    b=i%l;
				if(b==0) {
				    flg1=0;
					break;
				}
			}
			if(flg1==1) {
				if(p==0){
				    q=i;
				}
				else if(p!=0){
				    q=i;
				}
				if(q-2==p){
				    a2=p;
					b2=q;
				}
				else{
				    p=q;
				}
			}
			flg1=1;
		}
		printf("%d %d\n",a2,b2);
		scanf("%d",&a);
	}
	return 0;
}

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

int	Prime(int	x){
	int	n;
	if(x	==	2)return	1;
	if(x	%	2	==	0)return	0;
	for(n	=	3;	n	<=	sqrt((double)x);	n	+=	2){
		if(x	%	n	==	0)return	0;
		return	1;
	}
}

int	main(){
//data[0]????????°???????´?????????????????????§????????????????????????
	int	n,	i,	cnt	=	1,	max	=	0,	data[10000];
	scanf("%d",	&n);
	//1????´???°??§??????????????§?????\
	for(i	=	2;	i	<=	n;	i++){
		if(Prime(i)){
			data[cnt]	=	i;
			if(data[cnt]	-	data[cnt	-	1]	==	2)max	=	cnt;
			printf("%3d%c",	i,	(++cnt%5==0)	?	'\n'	:	' ');
		}
		
	}
	printf("\n");
	printf("%d??????????????????\n",	cnt);
	printf("%d ??¨ %d\n",	data[max - 1],	data[max]);
	return	0;
}

C++: #include<cstdio>
int sosu[10001];
int main(){
  int N;
  sosu[0]=1;
  sosu[1]=1;
  for(int i=2;i<=10000;i++){
    if(sosu[i]) continue;
    for(int j=i+i;j<=10000;j+=i){
      sosu[j]=1;
    }
  }
  while(scanf("%d",&N),N){
    for(int i=N;i>1;i--){
      //      printf("%d %d\n",sosu[i],sosu[i-2]);
      if(!sosu[i] && !sosu[i-2]){
	printf("%d %d\n",i-2,i);
	break;
      }
    }
  }
}

C++: #include <stdio.h>

int isprime(int n) {
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) return 0;
    }
    return 1;
}

int main(){
    int k,v,a=0,b=0;
    while(1) {
        scanf("%d", &v);
        if(v == 0) break;
        for(k = 1; k <= v; k++) {
            if(isprime(k) == 1 && isprime(k-2) == 1){
                a = k - 2;
                b = k;
            }
        }
        printf("%d %d\n",a,b);
    }
}