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 <string.h>

using namespace std;
bool isPrime[10005];

void PrimeCalc()
{
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 10005; ++i)
	{
		if(isPrime[i])
		{
			for(int j = 2 * i; j < 10005; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n, n)
	{
		for(int i = n; i >= 7; --i)
		{
			if(isPrime[i] && isPrime[i - 2])
			{
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <stdio.h>
const int MAX_V = 10000;
int prime[MAX_V+1];
int main(){
  int i,k,n,j,i1,i2,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 < 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 <iostream>
#include <vector>
using namespace std;

#define N 10001
vector<int> prime(N);

int main(){
  int n;
  prime[0] = 1;
  prime[1] = 1;
  vector<int> prm;

  for(int i=2; i<N; i++){
    if(prime[i]==0){
      prm.push_back(i);
      for(int j=i*i; j<N; j+=i)
	prime[j]=1;
    }
  }

  while(cin >> n && n!=0){
    for(int i=prm.size()-1; i>0; i--){
      if(prm[i] <= n && prm[i] == prm[i-1]+2){
	cout << prm[i-1] << " " << prm[i] << endl;
	break;
      }	
    }
  }

  return 0;
}

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

int pri[10000+1];
bool is_prime[10000+1];
int prime(int n){
	int p=0;
	for(int i=0;i<n+1;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<n+1;i++){
		if(is_prime[i]==true){
			pri[p++] = i;
			for(int j=i+i;j<n+1;j+=i){
				is_prime[j] = false;
			}
		}
	}
	return p;
}

int main()
{
	int n;
	while(cin >> n){
		if(n==0)
			break;
		int p = prime(n);
		for(int i=p-1;i>=0;i--){
			if(pri[i] == pri[i-1]+2){
				cout << pri[i-1] << " " << pri[i] << endl;
				break;
			}
		}
	}	
	return 0;
}

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

#define MAX 10002
#define sqrtMAX 100

int main()
{
	bool b[MAX+1] = {0};
	int i, j;
	b[0] = 1;
	b[1] = 1;
	for(i=4; i<=MAX; i+=2) b[i] = 1;
	for(i=3; i<=sqrtMAX; i+=2)
		for(j=i+i; j<=MAX; j+=i) b[j] = 1;

	int p[MAX+1] = {0};
	j = 5;
	for(i=5; i<MAX-2; i+=2) {
		p[i] = j;
		p[i+1] = j;
		if ( !(b[i]|b[i+2]) ) j = i+2;
	}

	while (cin>>i, i) cout<<p[i]-2<<" "<<p[i]<<endl;

	return 0;
}

C++: #include <iostream>
#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;
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N =10010;

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

int main(){
	sieve();
	int n;
	while(cin>>n,n){
		for(int i = n;i >=2;i--){
			if(prime[i]&&prime[i-2]){
				cout <<i-2<<" "<<i<<endl;
				break;
			}
		}
	}
	return 0;
}

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

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

const int sz = 100000;
bool prime[sz];

int main(){
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for(int i = 2; i * i < sz; i++){
    if(prime[i]){
      for(int j = 2; i * j < sz; j++){
	prime[i*j] = false;
      }
    }
  }
  
  int n;
  while(cin >> n && n){
    for(int i = n; i >= 2; i--){
      if(prime[i] && prime[i-2]){
	cout << i - 2 << " " << i << endl;
	break;
      }
    }
  }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,flg,i,j,p1,q1,fllg,ii;
	while(1){
		cin>>n;
		if(n==0)break;
		for(i=n-1;i>1;i--){
			flg=1;
			if(i!=2&&i%2!=0){
				for(j=2;j<i;j++){
					if(i%j==0){
						flg=0;
						break;
					}
				}
				if(flg==1){
					ii=i-2;
					for(j=2;j<ii;j++){
						if(ii%j==0){
							flg=0;
							break;
						}
					}
				}
				if(flg==1) flg=2;
			}
			if(flg==2){
				p1=ii;
				q1=i;
				break;
			}
		}
		cout<<p1<<' '<<q1<<endl;
		p1=0; q1=0;
	}
	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(i,3,20001){
	bool flg=true;
	for(int j=2;j*j<=i;j++){
	    if(i % j == 0){
		flg = false;
		break;
	    }
	}
	if(flg){
	    primes.PB(i);
	}
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int x = upper_bound(ALL(primes),n) - primes.begin();
	RREP(i,x){
	    if(primes[i]-primes[i-1]==2){
		cout << primes[i-1] << " " << primes[i]<<endl;
		break;
	    }
	}
    }


    return 0;
}