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 <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vector<bool>IsPrime(MAX+1,true);
    vector<int>Prime(MAX+1,0); //Primearray
    int Primecounter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(IsPrime[i]){
            for(int j = 2;i*j<MAX;j++)
                IsPrime[i*j] = false;//?テつエ???テつー??????Primearray???????テつエ??????????????????テつー?????テつィ???false???
            Prime[Primecounter] = i;
            Primecounter++;
        }
    }
    int n;
    while(cin>>n,n){
        int maxi=0;
        for(int i=n; i>=2; i--){
            if(IsPrime[i]&&IsPrime[i-2]){
                cmax(maxi,i);
                break;
            }
        }
        cout<<maxi-2<<" "<<maxi<<endl;
    }
}

C++: #include<stdio.h>

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

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

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


const int MAX = 10001000;
bool IsPrime[MAX];
bool IsDPrime[MAX];
vector<int> Era(int n = MAX) {
    vector<int> res;
	IsPrime[0] = false; IsPrime[1] = false; 
	for (int i = 2; i < n; ++i) IsPrime[i] = true;
	for (int i = 2; i < n; ++i) {
		if (IsPrime[i]) {
            res.push_back(i);
			for (int j = i*2; j < n; j += i) IsPrime[j] = false;
		}
	}
    return res;
}

int main() {
    Era();
    memset(IsDPrime, 0, sizeof(IsDPrime));
    for (int i = 2; i <= 10000; ++i) if (IsPrime[i] && IsPrime[i+2]) IsDPrime[i] = true;
    
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int res = n-1;
        for (res = n-2; res >= 3; --res) if (IsDPrime[res]) {
            cout << res << " " << res+2 << endl;
            break;
        }
    }
    return 0;
}

C++: #include <stdio.h>
int main(){
	int i,j,a,b,n,p1,q1;
	int isprime[1000];
	for(i=0;i<=1000;i++){
 		isprime[i]=1;
	}
	isprime[0]=isprime[1]=0;
	for(i=2;i<=1000;i++){
 		if(isprime[i]==1){
 			for(j=2*i;j<=1000;j+=i){
				isprime[j]=0;
			}
		}
	}

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

C++: #include <bits/stdc++.h>
using namespace std;

vector<int> prime;
vector<int> ls;

void sieve(int N){
    prime.resize(N+1,1);
    prime[0] = prime[1] = 0;
    for(int i=2;i*i<=N;i++){
        for(int j=i*i;j<=N;j+=i){
            prime[j] = 0;
        }
    }
    for(int i=2;i<=N;i++){
        if(prime[i])ls.push_back(i);
    }
}

int main() {
    sieve(int(1e5));
    int n;
    while(cin >> n, n){
        int p, q;
        for(int i=0;ls[i]<=n-2;i++){
            if(ls[i+1]-ls[i]==2){
                p = ls[i];
                q = ls[i+1];
            }
        }
        cout << p << " " << q << endl;
    }
    return 0;
}

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

bool check(int p1) {
	for (int j = 2; j <= sqrt(p1); j++) {
		if (p1 % j == 0)
			return 0;
	}

	return 1;
}

int main()
{	
	int n;

	cin >> n;

	while (n > 0) {
		int p = n;

		while (p > 3 && (!check(p) || !check(p - 2)))
			p--;

		cout << p - 2 << " " << p << endl;

		cin >> n;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  bool p[10001];
  memset(p, 1, sizeof(p));
  p[1] = p[0] = 0;
  for(int i = 0 ; i < 10001 ; i++){
    if(p[i]){
      for(int j = 2 * i ; j < 10001 ; j += i){
	p[j] = 0;
      }
    }
  }

  int n;
  while(cin >> n, n){
    for(int i = n ; ; i--){
      if(p[i] == 1 && p[i-2] == 1){
	cout << i-2 << ' ' << i << endl;
	break;
      }
    }
  }
  return 0;
}