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 <bits/stdc++.h>
using namespace std;

int main() {
    vector<bool> v(11111, true);
    v[0] = v[1] = false;
    for (int i = 2; i <= 10000 / 2; i++) {
        for (int j = 2; j * i <= 10000; j++) {
            v[i * j] = false;
        }
    }

    vector<pair<int,int> > d;
    for (int i = 0; i <= 10000 ; i++) {
        if (v[i] && v[i+2]) d.push_back(pair<int,int>(i, i+2));
    }

    int n;
    while (cin >> n, n) {
        auto iter = upper_bound(d.begin(), d.end(), pair<int,int>(n - 2,n - 2)) - 1;
        cout << iter->first << ' ' << iter->second << endl;
    }

    return 0;
}

C++: #include <stdio.h>
int main(){
	int i,j;
	int isprime[10000];
	for(i=0;i<=10000;i++){
 		isprime[i]=1;
	}
	isprime[0]=isprime[1]=0;
	for(i=2;i<=10000;i++){
 		if(isprime[i]==1){
 			for(j=2*i;j<=1000;j+=i){
				isprime[j]=0;
			}
		}
	}
	int n,p1,q1;
	scanf("%d",&n);
	for(i=2;i<=n;i++){
		if(isprime[i-2]==1 && isprime[i]==1){
			p1 = i-2;
			q1 = i;
		}
	}
	printf("%d %d\n",p1,q1);
	return 0;
 }

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


bool isprime(int n);

int main(void){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;

    for(int j=n;j>0;j--){
      if(isprime(j) && isprime(j-2)){
        cout<<j-2<<" "<<j<<endl;
        break;
      }
    }
  }
  return 0;
}

bool isprime(int n){
  for(int i=2;i<min((int)sqrt(n)+1,n);i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}

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

int main() {
  bool so[10001] ={};
  so[0] = so[1] = 1;
  for(int i=2;i<=10000;i++) {
    if(so[i] == 0)
      for(int j=2;j<=10000/i;j++) so[j*i] = 1;
  }
  
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    for(int i=n;i>=3;i--) {
      if(so[i] == 0 && so[i-2] == 0) {
	cout << i-2 <<" "<< i << endl;
	break;
      }
    }

  }

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

int main(){
  int i ,j ,n;
  while( true ){
    scanf( "%d" ,&n );
    if( n == 0 ){
      break;
    }
    int prime[n+1]; // 素数
    for( i=2 ; i<=n ; i++ ){ // 自然数を列挙
      prime[i] = 1;
    }
    
    i = 2;
    while( i <= n ){
      if( prime[i] == 1 ){ // 素数なら
	j = i*2;
	while( j <= n ){
	  prime[j] = 0;
	  j += i;
	}
      }
      i++;
    }
    for( i=n ; i>0 ; i-- ){
      if( prime[i] == 1 && prime[i-2] == 1 ){
	cout << i-2 << ' ' << i << endl;
	break;
      }
    }
  }
  return 0;
}

C++: #include <stdio.h>
int isprime(int n){
	int i;
	for(i= 2; i * i <= n; i++) {
		if(n % i == 0) return 0;
	}
	return 1;
}

int main(){
	int i,a,b,p1,q1,n;
	scanf("%d", &n);
	while( n != 0){
		for(i=2;i<=n;i++){
			a = isprime(i-2);
			b = isprime(i);
			if(a==1 && b==1){
				p1 = i-2;
				q1 = i;
			}
		}
		printf("%d %d\n",p1,q1);
		scanf("%d", &n);
	}
	return 0;
 }

C++: #include <stdio.h>

int main(){
	int i,n,k,data[10000];
	for(i=2;i<10000;i++){
		data[i]=1;
	}
	for(i=2;i*i<10000;i++){
		if(data[i]==1){
			for(k=i*i;k<=10000;k+=i){
				data[k]=0;
			}
		}
	}
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=n;n>=3;i--){
			if(data[i]==1&&data[i-2]==1){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<numeric>
#include<iterator>
#include<vector>

using namespace std;
typedef unsigned int val;

struct pred{
	bool operator()(int m, int n) { return m - n == 2; }
};

int main() {
	int n;
	while(cin>>n && n)
	{
		vector<int>so;
		bool flag[10010];
		flag[0]=flag[1]=false;
		for(int i=2; i<n; i++)
		{
			if( flag[i] )
			{
				so.push_back(i);
				for(int j=i*2; j<n; j+=i) flag[j]=false;
			}
		}
		vector<int>::reverse_iterator ite = adjacent_find(so.rbegin(), so.rend(), pred());
		cout<< *(ite+1) << " "<< *ite << endl;

	}
	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,10001){
	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 = lower_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;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <sstream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

const int MAX_N=50100;
int p[(MAX_N+1)/2];
bool isp[MAX_N+1];
 
int gen_ps(){
    memset(isp,1,sizeof(isp));
    isp[0]=isp[1]=false;
    int idx=0;
    loop(i,2,MAX_N+1){
        if(!isp[i]) continue;
        p[idx++]=i;
        for(int j=i+i; j<=MAX_N; j+=i){
            isp[j]=false;
        }
    }
    return idx;
}

int main(){
    int len = gen_ps();
    int n;
    while(cin>>n && n){
        int ans = -1;
        for(int i=n;i>=0;i--){
            if(isp[i] && isp[i-2]){
                ans = i;
                break;
            }
        }
        if(ans==-1) throw;
        cout << ans-2 << " " << ans << endl;
    }
}