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 <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(1){
    scanf("%d",&n);
    if(n == 0){
      exit(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",p1,q1);
  }
  return 0;
}

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

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

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

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
int isp[10000000];
bool isPrime(int a) {
  if(a == 1) return isp[a] = 0;
  
  if(isp[a]>=0) return isp[a];
  for(int i=2; i*i <=a; i++)
    if(a%i == 0) return isp[a] = 0;
  
  return isp[a] = 1;
}

int const dx[] = {-1,0,1,0,-1,1,1,-1};
int const dy[] = {0,-1,0,1,-1,-1,1,1};

//////////////////////////////////////////////////////////////

int main() {
  
  memset(isp, -1, sizeof(isp));
  
  int n;
  while(cin >> n && n) {
    int ans = -INF;
    for(int i=5; i<=n; i++) {
      if(isPrime(i-2) && isPrime(i)) {
	ans = max(ans, i);
      }
    }
    cout << ans-2 << ' ' << ans << endl;
  }
  
  return 0;
}

C++: #include<stdio.h>
	   const int MAX_V = 1000000;
	   int prime[MAX_V+1];
	   int main(){
	   	int i,k,v,m=2;
	   	for(i=m;i<=MAX_V;i++){
	   		prime[i]=1;
	   	}
	   	for(i=m;i*i<=MAX_V;i++){
	   		if(prime[i]){
	   			for(k=2*i;k<=MAX_V;k+=i){
	   				prime[k]=0;
	   			}
	   		}
	   	}
	   	while(scanf("%d",&v)!=EOF){
	   		if(v==0)break;
	   		for(i=v;i>=m;i--){
	   			if(prime[i]==1 && prime[i-2]==1){
	   				printf("%d %d\n",i-2,i);
	   				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,g,j,suu,an1,an2;
	int su[10000]={0};
    for(k=0;k<10000;k++){
    	if(isprime(k)==1){
    		for(g=1;j<=10000;g++){
    			j=g*k;
    			su[j]=1;
    		}
    	}  
    }
    while(1){
        scanf("%d",&suu);
        if(suu != 0){
            for(k=2;k<=suu;k++){
            	if(su[k-2]==1 && su[k]==1){
        	    	an1=k-2;
        	    	an2=k;
            	}
            }
            printf("%d %d\n",an1,an2);
        }
        else{
    	    break;
        }
    }
    return 0; 
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int MAX_PRIME = 10001;


int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;

void erats(){
	// primeツδ環スツトツづーツ渉可甘コツ可サ
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;

		// ツづ督づゥツつ「ツづ可つゥツつッツづゥ
		for(int j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
		cout << flush;
	}
}


int main(){

	erats();

	int n;
	while(cin>>n&&n!=0){
		bool f=false;
		for(int i = p-1; i >= 0; i--){
			for(int j = i-1; j >=0; j--){
				if(prime[i]-prime[j]==2&&prime[i]<=n){
					cout<<prime[j]<<" "<<prime[i]<<endl;
					f=true;
					break;
				}
			}
			if(f)
				break;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int i,j;
  #define MAX 10000
  int num[MAX]={1,1,0};
 
  for(i=3;i<MAX;i+=2){
    if(num[i]==1)
      continue;
    for(j=3*i;j<MAX;j+=i*2)
      num[j]=1;
  }
  int n;
  while(cin>>n,n){
    n+=n%2-1;
    for(i=n;i>2;i-=2)if((!num[i])&&(!num[i-2]))break;
	cout<<i-2<<" "<<i<<endl;
  }
}

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

int p(int n){
	for(!n%2){
		return 0;
	}
	else{
		for(int i=0;i*i<n;i-=2){
			if(!n%1){
				return 0;
			}
		}
		return 1;
	}
}



int main(){

	cin >> n;

	for(int k=n;k>0;k--){
		if(p(n) && p(n-2)){
			cout << n-2 << n << endl;
			break;
		}
		
	}
}

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

using namespace std;


bool isPrime(int x) {
  if(x == 1) return false;
  if(x == 2) return true;
  if(x % 2 == 0) return false;
  int max = (int)sqrt(x);

  for(int i = 3; i <= max; i += 2) {
    if(x % i == 0) return false;
  }
  return true;
}

int main() {
  int data[10000];
  map<int, int> from;
  int index = 0;
  for(int i = 2; i <= 10000; i++) {
    if(isPrime(i)) {
      data[index] = i;
      from[i] = index;
      index++;
    }
  }

  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    for(int i = n; i >= 0; i--) {
      if(isPrime(i)) {
	for(int j = from[i]; j-1 >= 0; j--) {
	  if(data[j] - data[j-1] == 2) {
	    cout << data[j-1] << ' ' << data[j] << endl;
	    break;
	  }
	}
	break;
      }
    }
  }
  return 0;
}