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>
using namespace std;

int main(){
	bool prime[10001];
	int i,j,n;
	for(i = 3;i<=10000;i+=2){
		prime[i] = true;
	}
	prime[2] = true;
	for(i = 3;i<=10000;i+=2){
		if(prime[i]){
			for(j = 3;j<=10000/i;j+=2){
				prime[i*j] = false;
			}
		}
	}
	while(cin >> n && (n != 0)){
		for(i = n;i>=5;i--){
			if(prime[i] && prime[i-2]){
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main(){
	bool prime[10001];
	int i,j,n,a,b;
	for(i = 4;i<=10000;i+=2){
		prime[i] = false;
	}
	prime[2] = true;
	for(i = 3;i<=10000;i+=2){
		if(prime[i]){
			for(j = 3;j<=10000/i;j+=2){
				prime[i*j] = false;
			}
		}
	}
	while(cin >> n && (n != 0)){
		a = 0;
		b = 0;
		for(i = n;i>=5;i--){
			if(prime[i]){
				if(a != 0){
					b = i;
					if(a - b == 2){
						cout << b << " " << a << endl;
						break;
					}
					else {
						a = b;
					}
				}
				else a = i;
			}
		}
	}
	return 0;
}

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 p1[10000];
	int q1[10000];
	int n, i, cnt = 0;

	while(1)
	{
		scanf ("%d",&n);
		for(i=n; i!=0; i--)
		{
			if(isprime(i) == 1 && isprime(i-2) == 1)
			{
				p1[cnt] = i;
				q1[cnt] = i-2;
				break;
			}
		}
		if(n==0)
		{
			break;
		}
		cnt++;
	}
	for(i=0; i<cnt; i++)
	{
		printf("%d %d\n",q1[i],p1[i]);
	}
	return 0;
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V + 1];
int main() {
  int i, k, v, n, max = 0;
  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(i = n;i > 0;i--){
      if(prime[i] == 1 && prime[i - 2] == 1){
        max = i;
        break;
      }
    }
  printf("%d %d\n", max - 2, max);
  }
  return 0;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int prime[10001];

void CreatePrime(int n)
{
	rep(i,n)
	{
		prime[i] = 1;
	}

	prime[0] = prime[1] = 0;

	REP(i,2,sqrt(n))
	{
		if(prime[i])
		{
			for(int j=0;i*(j+2) < n;j++)
			{
				prime[i*(j+2)] = 0;
			}
		}
	}
}

int main()
{
	int n;
	vector<int> v;
	vector<pair<int,int> > ans;

	CreatePrime(10001);
	while(cin >> n && n)
	{
		rep(i,n)
		{
			if(prime[i]) v.push_back(i);
		}
		
		rep(i,v.size()-1)
		{
			REP(j,i+1,v.size())
			{
				if(v[j] - v[i] == 2)
				{
					ans.push_back(make_pair(v[i],v[j]));				
				}

				else if(v[j] - v[i] > 2)
				{
					break;
				}
			}
		}

		cout << ans[ans.size()-1].first << " " << ans[ans.size()-1].second << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  const int NUM = 10000;
  bool prime[NUM];
  for(int i=2;i<NUM;i++)
    prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

  int maxtwin[10000],twin;
  for(int i=5;i<10000;i++){
    if(prime[i]&&prime[i-2])twin = i;
    maxtwin[i]=twin;
  }
  for(int n;cin>>n,n;){
    cout<<maxtwin[n]-2<<" "<<maxtwin[n]<<endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n,max,mx;
	int flg[10001];
	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;
		for(i=n;i>=5;i--)	{
			if(flg[i]==1 && flg[i-2]==1)	break;
		}
		max=i-2;
//		for(i=2;i<n;i++) {
//			if(flg[i]==1 && flg[i]==flg[i+2] && i+2<=n) {
//				if(max<i) max=i;
//			}
//		}
		printf("%d %d\n",max,max+2);
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	const int MAX = 10010;
	int katarogu[MAX] = { 0 };
	const int NOsosu = 1;
	int num[MAX] = { 0 };
	num[1] = NOsosu;
	for (int i = 3; i < MAX; i = i + 2){
		for (int j = 3; j*j <= i; j = j + 2){
			if (i%j == 0){ num[i] = NOsosu; break; }
		}
		katarogu[i - 1] = katarogu[i - 2];
		katarogu[i] = katarogu[i - 2];
		if (num[i] != NOsosu && num[i - 2] != NOsosu){ katarogu[i] = i; }
	}
	int a;
	while (cin >> a, a != 0){ cout << katarogu[a] - 2<<" "<<katarogu[a] << endl; }

	return 0;
}

C++: //03
#include<iostream>

using namespace std;

int main(){
  bool cmp[10001]={true,true};
  for(int i=2;i<10001;i++){
    if(!cmp[i]){
      for(int j=2;j*i<10001;j++){
	cmp[i*j]=true;
      }
    }
  }
  bool tp[10001]={};
  for(int i=0;i+2<10001;i++){
    tp[i+2]=!cmp[i]&&!cmp[i+2];
  }
  for(int n;cin>>n,n;){
    while(!tp[n]){
      n--;
    }
    cout<<n-2<<' '<<n<<endl;
  }
  return 0;
}

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

int main(){
	int n;
	bool no[10001] = {true,true};
	for(int i = 4;i <= 10000;i += 2) no[i] = true;
	for(int i = 3;i * i <= 10000;i += 2){
		for(int j = i * 2;j <= 10000;j += i) no[j] = true;
	}
	vector<int> twin;
	for(int i = 2;i <= 10000;i++){
		if(!no[i] && !no[i - 2]) twin.push_back(i);
	}
	while(cin >> n,n){
		int pos = upper_bound(twin.begin(),twin.end(),n) - twin.begin() - 1;
		cout << twin[pos] - 2 << " " << twin[pos] << endl; 
	}
	return 0;
}

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

const int MAX_N = 10010;
vector<int> prime;
bool isPrime[MAX_N];
int T[MAX_N];

int make() {
  fill(isPrime,isPrime+MAX_N,true);
  isPrime[0] = isPrime[1] = false;
  for(int i = 0; i < MAX_N; ++i) {
    if(!isPrime[i]) continue;
    prime.push_back(i);
    for(int j = i*2; j < MAX_N; j += i) isPrime[j] = false;
  }

  fill(T,T+MAX_N,-1);
  for(int i = 1; i < prime.size(); ++i) {
    if(prime[i]-prime[i-1] == 2)
      T[prime[i]] = i;
  }
  for(int i = 0, j = -1; i < MAX_N; ++i) {
    if(T[i] != -1) j = T[i];
    else T[i] = j;
  }
}

int main() {
  make();
  int n;
  while(cin >> n && n)
    cout << prime[T[n]-1] << " " << prime[T[n]] << endl;
  return 0;
}

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

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int sosu[10010];

int main() {
	sosu[0]=1;
	sosu[1]=1;
	int i,j;
	for(i=0;i<=10000;i++){
		if(sosu[i]==0){
			for(j=i*2;j<=10000;j+=i){
				sosu[j]=1;
			}
		}
	}
	int n;
	while(n=in()){
		while(sosu[n]+sosu[n-2]!=0){
			n--;
		}
		cout<<n-2<<" "<<n<<endl;
	}
	return 0;
}