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;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main() {

	vector<int> prime;
	vector<bool> used(10001, false);
	used[0] = used[1] = true;
	for (int i = 2; i * i <= 10000; i++) {
		if (!used[i]) prime.push_back(i);
		used[i] = true;
		for (int j = i * 2; j <= 10000; j += i) {
			used[j] = true;
		}
	}
	REP(i, 10000 + 1) if (!used[i]) {
		prime.push_back(i);
		used[i] = true;
	}
	
	vector<int> ans;
	FOR(i, 1, prime.size()) {
		if (prime[i] == prime[i - 1] + 2) ans.push_back(prime[i]);
	}
	sort(ans.begin(), ans.end());
	
	int n;
	while (cin >> n, n) {
		int b = *lower_bound(ans.begin(), ans.end(), n);
		int a = b - 2;
		cout << a << " " << b << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <string.h>
#include <cmath>
#include <queue>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second
#define ll long long 
#define vi vector<int>

using namespace std;

ll _sieve_size; 
bitset<10000010> bs; 
vi primes; 
void sieve(ll upperbound) { 
_sieve_size = upperbound + 1; 
bs.set(); 
bs[0] = bs[1] = 0; 
for (ll i = 2; i <= _sieve_size; i++) if (bs[i]) {
for (ll j = i * i; j <= _sieve_size; j += i) bs[j] = 0;
primes.push_back((int)i);
} } 
bool isPrime(ll N) { 
if (N <= _sieve_size) return bs[N]; 
for (int i = 0; i < (int)primes.size(); i++)
if (N % primes[i] == 0) return false;
return true; 
} 

int a;

int main()
{
	sieve(11000);
	while(1)
	{	
		scanf("%d",&a);
		if(a==0)break;
		if(a%2==0)
		a-=3;
		else
		a-=2;
		//printf("%d",b);
		while(1)
		{
			if(isPrime(a)&&isPrime(a+2))
			{
				printf("%d %d\n",a,a+2);
				break;
			}
			a-=2;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[10001];
    memset(prime,0,sizeof(prime));
    for(int i=2;i<sqrt(10001);i++){
        if(!prime[i])for(int j=i*2;j<10005;j+=i)prime[j]=1;
    }
    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;
            }
        }
    }
}

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

typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;

vector<int> sieve(int n) {
  vector<int> prime(n);
  for(int i=2; i<n; i++) prime[i]=i;
  for(int i=2; i*i<n; i++) {
    if(prime[i]) {
      for(int j=i*i; j<n; j+=i) prime[j]=0;
    }
  }
  prime.erase(remove(prime.begin(),prime.end(),0),prime.end());
  return prime;
}

int main() {
  vector<int> prime = sieve(10000);
  vector<P> v;
  for(int i=0; i<prime.size()-1; i++) {
    if(prime[i+1]-prime[i]==2) v.push_back(P(prime[i],prime[i+1]));
  }
  int n;
  while(cin >> n && n) {
    int l=0,r=v.size(),m;
    while(l+1!=r) {
      m = (l+r)/2;
      if(v[m].second>n) r=m;
      else l=m;
    }
    cout << v[l].first << " " << v[l].second << endl;
  }
  return 0;
}

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

using namespace std;

int main() {

  int n;

  int not_prime[11000];
  

  not_prime[0]=not_prime[1]=1;

  for(int i=2;i<=10000;i++) not_prime[i]=0;

  for(int i=2;i<=sqrt(10000);i++) {

    if(not_prime[i]==0) {

      for(int j=2*i;j<=10000;j+=i) {

	not_prime[j]=1;

      }

    }

  }

  while(1) {

    cin >> n;

    if(n==0) break;

    for(int i=n;i>=5;i--) {

      if(not_prime[i]==0 && not_prime[i-2]==0) {

	cout << i-2 << " " << i << endl;

	break;

      }

    }

  }

  return 0;

}

C++: #include "stdio.h"
const int MAX_V = 10000; // 1????????§????´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°,0????´???°??§?????????
int main() {
    int i, k, n;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\???????´???°??¨??????
    }
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????
            }
        }
    }
    while(scanf("%d", &n) != EOF) {
        //        int isprime = prime[v];
        //        if(isprime) printf("%d is a prime number\n", v);
        //        else printf("%d is not a prime number\n", v);
        int p1 = 3;
        int q1 = 5;
        for(i = n;0 <= i;i--){
            if(prime[i] == 1 && prime[i-2] == 1){  //??????????´???°
                if (q1 <= i) {
                    q1 = i;
                    p1 = i-2;
                }
            }
        }
        printf("%d %d\n",p1,q1);
    }
    return 0;
}
//????¨??????¨????????????????????????

C++: #include<stdio.h>
#include<math.h>

int	Prime(int	x){
	int	n;
	if(x	==	2)return	1;
	if(x	<	2	||	x	%	2	==	0)return	0;
	for(n	=	3;	n	<=	sqrt((double)x);	n	+=	2){
		if(x	%	n	==	0)return	0;
	}
	return	1;
}

int	main(){
	int	n,	i,	cnt	=	0,	max	=	0,	data[1000001];
	while(1){
	scanf("%d",	&n);
	if(n==) break;
	for(i	=	0;	i	<=	n;	i++){
		if(Prime(i)	==	1){
			data[cnt]	=	i;
			cnt++;
		}	
	}
	for(i	=	1;	i	<=	cnt;	i++){
		if(data[i]	-	data[i	-	1]	==	2)max	=	i;
	}
	if(max	!=	0)printf("%d %d\n",	data[max - 1],	data[max]);
	}
	return	0;
}

C++: #include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム 
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std; // std 名前空間を使用する
const int MAX=10000;
bool prime[MAX+1];
void make_prime(){
    for(int i=0;i<=MAX;i++){
        prime[i]=true;
    }
    prime[0]=false;
    prime[1]=false;
    for(int p=2;p<=MAX;p++){
        if(prime[p]){
            for(int n=p+p;n<=MAX;n+=p){
                prime[n]=false;
            }
        }
    }
}
int main(void){
    make_prime();
    while(1){
        int n,p=0;
        scanf("%d",&n);
        if(n==0)break;
        for(int i=0;i<n-2;i++){
            if(prime[i]&&prime[i+2]){
                p=i;
            }
        }
        printf("%d %d\n",p,p+2);
    }
}