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 isprime(int n);
int isSmallTwinPrime(int n);
int GetMaxTwinPrimeNumber(int argRange);

int main()
{
	int const size = 10000;
	int data[size];	
	
	int i=0;
	while(1) //for(int i=0; data[i]!=0; i++)
	{
		cin >> data[i];
		if(data[i]<=0) break;
		i++;
	}
	
	int outputNum;
	
	for(int i=0; data[i]!=0; i++)
	{
		outputNum = GetMaxTwinPrimeNumber(data[i]);
		if(outputNum!=0)
		{
			cout << outputNum-2 << " " << outputNum << endl;
		}
	}
	
	return 0;
}

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

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

int GetMaxTwinPrimeNumber(int argRange)
{
	int maxTwinPrimeNum = 0;
	
	for(int i=0; ; i++)
	{
		int Num = argRange - i;
		
		if(isprime(Num)==1 && isSmallTwinPrime(Num)==1)
		{
			maxTwinPrimeNum = Num;
			return maxTwinPrimeNum;
		}
		
		if(Num==0)
		{
			return 0;
		}
	}
}

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

const int size = 10001;
bool a[size];

void eratos(){
	if(size>=1)
		a[0] = false;
	if(size>=2)
		a[1] = false;
	for(int i=2; i<size; i++)
		a[i] = true;
	for(int i=2; i*i<size; i++)
		if(a[i])
			for(int j=i*i; j<size; j+=i)
				a[j] = false;
}

int main(){
	int n;
	eratos();
	while(true){
		cin >> n;
		if(!n)
			return 0;
		if(!(n%2))
			n--;
		for(int i=n; i>=5; i-=2){
			if(a[i] && a[i-2]){
				cout << i-2 << ' ' << i << endl;
				break;
			}
		}				
	}
}

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

using namespace std;



int main(){
	int in;
	int prime[60001] = {};

	vector<int> p;
	int i, j;
	for (i = 2; i*i < 60000; i++){
		if (prime[i] == 0){
			for (j = 2; i*j <= 60000; j++){
				prime[i*j] = 1;
			}
		}
	}
	for (i = 1; i < 60001; i++){
		if (prime[i] == 0){
			p.push_back(i);
		}
	}



	while (cin >> in){
		if (in == 0){
			break;
		}
		for (i = in; i > 0; i--){
			if (prime[i] == 0 && prime[i - 2] == 0){
				cout << i - 2 << " " << i << endl;
				break;
			}
		}		

	}
}

C++: #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int prime[10001];

int main(){
	prime[0]=prime[1]=1;
	
	for(int i=2;i*i<10001;i++){
		if(prime[i]==1)continue;
		for(int j=2*i;j<10001;j+=i){
			prime[j]=1;
		}
	}
	
	int n;
	while(cin>>n){
		if(n==0)break;
		while(n>0){
			if(prime[n]==0 && prime[n-2]==0)break;
			else n--;
		}
		cout<<n-2<<" "<<n<<endl;
	}
}

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 n, i, p1, q1, result, resultt;
  for( ;; ) {
    scanf( "%d", &n );
    if( n == 0 )break;
    for( i = n; i >= 0; i-- ) {
      result = isprime( i );
      resultt = isprime( i - 2 );
      if( result == 1 && resultt == 1 ) {
        q1 = i;
        p1 = q1 - 2;
        break;
      }
    }
    printf( "%d %d\n", p1, q1 );
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

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

int main(int argc, char **argv)
{
	int n, p, q;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		
		for(int i = n; i > 2; i--){
			if(prime(i) == 1){
				p = i;
				break;
			}
		}
		
		for(int i = p-1; i > 2; i--){
			if(prime(i) == 1){
				if((p-i) == 2){
					q = i;
					break;
				}
				p = i;
			}
		}
		
		cout << q << " " << p << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//??¨????????????????????????
//n??\????????£??´??°????´???°???????????°???????????????is_prime[]???????´?
void eratos(int n, bool is_prime[]) {
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
}

signed main() {
	bool is_prime[10010] = {};
	eratos(10010, is_prime);
	for (int n; cin >> n&&n;) {
		rrep(i, 0, n + 1) {
			if (is_prime[i] && is_prime[i - 2]) {
				cout << i - 2 << " " << i << endl; 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(10000);
		so.clear();
		bool flag[10010];
		for(int i=0; i<=10010; i++) flag[i]=true;
		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<vector>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	bool era[10010]={false};
	for(int i=2;i<105;i++)if(!era[i])for(int j=i*i;j<10010;j+=i)era[j]=true;

	vector<int> p;
	for(int i=2;i<10010;i++)if(!era[i])p.push_back(i);

	for(int n;scanf("%d",&n),n;){
		int pos=distance(p.begin(),--upper_bound(p.begin(),p.end(),n));
		for(int i=pos;;i--){
			if(p[i]-p[i-1]==2){
				cout<<p[i-1]<<' '<<p[i]<<endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include <stdio.h>

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

int main(){
	int k,suu,an1,an2;
    while(1){
        scanf("%d",&suu);
        if(suu != 0){
            for(k=2;k<=suu;k++){
                if(isprime(k-2)==1 && isprime(k)==1){
                    an1=k-2;
                    an2=k;
                }
            }
            printf("%d %d\n",an1,an2);
        }
        else{
    	    break;
        }
    }
}