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----------------------------------------------------------------------------------------------------------------------
#include <bits/stdc++.h>

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;

//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );

//global-----------------------------------------------------------------------------------------------------------------------
short n;
short prime[10000];
short many_prime = 2;
short mx = 1;

//function---------------------------------------------------------------------------------------------------------------------
int main() {
	while ( scanf( "%d", &n ) ) {
		if ( n == 0 ) {
			return 0;
		}
		many_prime = 2;
		mx = 1;
		prime[ 0 ] = 3;
		prime[ 1 ] = 5;
		for ( int i = 7; i <= n; i += 2 ) {
			bool check = true;
			for ( int j = 0; prime[ j ] * prime[ j ] <= i; j++ ) {
				if ( i % prime[ j ] == 0 ) {
					check = false;
					break;
				}
			}
			if ( check ) {
				prime[ many_prime ] = i;
				if ( prime[ many_prime ] - prime[ many_prime - 1 ] == 2 ) {
					mx = many_prime;
				}
				many_prime++;
			}
		}
		printf( "%d %d\n", prime[ mx - 1 ], prime[ mx ] );
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n, m[10001];
bool p(int x){
  if(m[x]>=0) return m[x];
  for(int i=2;i*i<=n;i++) {
    if(x%i==0) return m[x]=0;
  }
  return m[x]=1;
}
main() {
  memset(m,-1,sizeof(m));
  while(cin>>n&&n) {
    int mx=5;
    for(int i=2;i<=n-2;i++)if((p(i)&p(i+2)))mx = i;
    printf("%d %d\n",mx,mx+2);
  }
  return 0;
}

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

#define MAX_N 3700000

int prime[MAX_N], twin[MAX_N];

void isprime(int c) {
	prime[2] = 1;
	for (int i = 3; i < c; i += 2) {
		for (int j = 3; j <= sqrt(i); j += 2) {
			if (i%j == 0) { 
				goto E; 
			}
		}
		prime[i] = 1;
	E:;
	}
}

void istwin(int d) {
	for (int i = 5; i < d; i++) {
		if (prime[i - 2] + prime[i] == 2) {
			twin[i] = i;
		}
		else {
			twin[i] = twin[i - 1];
		}
	}
}

int n;

int main() {
	isprime(MAX_N);
	istwin(MAX_N);
	while (true) {
		cin >> n;
		if (n == 0) {
			break;
		}
		cout << twin[n] - 2 << ' ' << twin[n] << endl;
	}
}

C++: #include <stdio.h>
const int MAX_V = 10000;
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>
using namespace std;

bool isPrime(int x){
  for(int i = 2; i * i <= x; i++){
    if(x % i == 0){
      return false;
    }
  }

  return true;
}


int main(){
  int n;

  while(cin >> n, n){
    for(int i = n; i >= 5; i--){
      if(isPrime(i) && isPrime(i - 2)){
        cout << i - 2 << " " << i << endl;
        break;
      }
    }
  }
}

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[10000+1] = {0};
	for(i = 2;i < 10000;i++){
		number[i] = isprime(i);
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = 2;i <= n;i++){
			if(number[i] && number[i-2]){
				min = i-2;
				max = i;
				//printf("%d %d\n",i-2,i);
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

C++: #include<fstream>
#include<vector>
#define N 10000

int gcd(int q1,int p1){
    if(q1%p1==0) return p1;
    return gcd(p1,q1%p1);
}

int sosu(int j){
    if(j<2)return 0;
    if(j==2)return 1;
    if(j%2==0)return 0;
    for(int i=3; i<=j/2; i++){
        if(j%i==0)return 0;
    }
    return 1;
}

int main(){
    std::vector<int> n;
    n.resize(N);
    for(int i=0; i<N; i++){
        std::cin >> n[i];
        if(n[i]==0)break;
    }
    for(int i=0; i<N; i++){
        if(n[i]==0)break;
        for(int j=n[i]; j>5; j--){
            if(sosu(j)&&sosu(j-2))
                if(gcd(j,j-2)==1){
                    std::cout << j-2 << " " << j <<std::endl;
                    break;
                }
            }
        }
    return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int s[10001]={1,1,0,0,1};
int main(){
	r(i,2,10001)for(int j=i*2;j<10001;j+=i)s[j]++;
	int a;
	while(cin>>a,a){
		while(a){
			if(!s[a]&&!s[a-2]){
				cout<<a-2<<' '<<a<<endl;
				break;
			}a--;
		}
	}
}

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 x,i,k;
    for(k=0;k<10000;k++){
        scanf("%d",&x);
        if(x==0)break;
        for(i=x;i>0;i--){
            if(isprime(i)==1&&isprime(i-2)==1){
                printf("%d %d",i-2,i);
                break;
            }
        }
    }
    return 0;
}