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++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

bool prime[1000001]; //10^6

//素数列挙
void init_prime()
{
	memset(prime,1,sizeof(prime));
	prime[0] = prime[1] = false;
	for(int i = 2; i < sizeof(prime); i++) if(prime[i])
		for(int j = i * 2; j < sizeof(prime); j += i) prime[j] = false;
}

int main(){
	init_prime();
	vector<int> v;
	FOR(i,10000) if(prime[i] && prime[i+2]) v.push_back(i+2);

	int n; 
	while(cin>>n,n){
		int a = *(upper_bound(v.begin(),v.end(),n)-1);
		printf("%d %d\n",a-2,a);
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int MAX_N = 10002;
int n;
bool used[MAX_N];
vector<int> primes;

int main() {
  int twins[MAX_N];
  int twins_size = 0;
  fill(used, used + MAX_N, true);
  for (int i = 2; i < MAX_N; ++i) {
    if (used[i]) {
      primes.push_back(i);
      for (int j = i+i; j < MAX_N; j+=i) used[j] = false;
    }
  }
  for (int i = 1; i < primes.size(); ++i) {
    if (primes[i] - primes[i-1] == 2) {
      twins[twins_size] = primes[i];
      twins_size++;
    }
  }
  // int *a = lower_bound(twins, twins + twins_size, 11);
  // a--;
  // cout << *a << endl;
  while (cin >> n, n) {
    if (binary_search(twins, twins + twins_size, n)) {
      cout << n-2 << " " << n << endl;
    } else {
      int *a = lower_bound(twins, twins + twins_size, n);
      a--;
      cout << *a - 2 << " " << *a << endl;
    }
  }
  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 n,i,min,max;
	int number[1000000+2] = {0};
	for(i = 2;i < 1000000;i++){
		number[i] = isprime(i);
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = n;i > 0;i--){
			//printf("%d  ",i);
			if(number[i] && number[i-2]){
				min = i-2;
				max = i;
				//printf("%d %d\n",i,i-2);
				break;
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
const int MAX_V = 10000;
int prime[MAX_V+1];
int main(){
  int i,k,n,j,i1,i2,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(scanf("%d",&n) != 0){
    for(j = 0;j + 2 < n;j++){
      int isprime = prime[j];
      int isprime2 = prime[j + 2];
      if(isprime == 1){
        i1 = 1;
      }else{
        i1 = 0;
      }
      if(isprime2 == 1){
        i2 = 1;
      }else{
        i2 = 0;
      }
      if(i1 == 1 && i2 == 1){ 
        p1 = j;
        q1 = j + 2;
      }
    }
    printf("%d %d\n",p1,q1);
  }
  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 + 2 < n;j++){
      int isprime = prime[j];
      int isprime2 = prime[j + 2];
      if(isprime == 1){
        i1 = 1;
      }else{
        i1 = 0;
      }
      if(isprime2 == 1){
        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 <algorithm>

using namespace std;

const int MAX_P = 10020;
bool prime[MAX_P];
int twin_prime[MAX_P];
int size;

void init()
{
    for (int i = 0; i < MAX_P; i++)
        prime[i] = true;
    prime[0] = prime[1] = false;

    for (int i = 2; i * i < MAX_P; i++)
        if (prime[i]) 
            for (int j = 2 * i; j < MAX_P; j += i)
                prime[j] = false;

    for (int i = 0; i < MAX_P; i++) 
        if (prime[i] && prime[i + 2])
            twin_prime[size++] = i;
}


int main()
{
    init();

    int n;
    while (cin >> n, n) {
        n -= 2;
        for (int i = 0; i < MAX_P; i++)
            if (twin_prime[i] > n) {
                cout << twin_prime[i - 1] << " " << twin_prime[i - 1] + 2 << endl;
                break;
            }
    }

    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

vint getPrimeTable(int x)
{
	vint res(x + 1);
	
	REP(i, 2, x + 1)
	{
		res[i] = 1;
		
		for(int j = 2; j * j <= i; j++)
		{
			if(i % j == 0)
			{
				res[i] = 0;
				break;
			}
		}
	}
	
	return res;
}

int main()
{
    vint table(getPrimeTable(10000));
	
	for(int x; cin >> x && x;)
	{
		for(int i = x; 0 <= x; i--) if(table[i] && table[i - 2])
		{
			cout << i - 2 << " " << i << endl;
			break;
		}
	}
}

C++: #include <iostream>
#include <cstring>
#include <cmath>
#include <ostream>
#include <vector>
using namespace std;
    int n,m,k,i,t=1;
    int prm(int k)
    {
       for(i=2;i<=sqrt(k);i++){
       if(k%i==0)
       return 0;
       }
       return 1;
    }
    int main(){
    cin >> m;
    for (m>=5;m<=10000;m--)
    {
    if ((m%10==1||m%10==3||m%10==5||m%10==7||m%10==9)&&prm(m)&&prm(m-2))
    break;
    }  
    cout << m-2 << " " << m << std::endl;
}