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 <iostream>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

template<int N>
struct sieve {
	bool s[N];
	constexpr sieve() : s() {
		for (int i = 0; i < N; i++)
			s[i] = true;
		for (int i = 4; i < N; i += 2)
			s[i] = false;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
	}
};

int main() {
	enum {N = 10001};
	constexpr sieve<N> s;
	vector<int> t = {5};
	for (int i = 7; i < N; i += 6)
		if (s.s[i - 2] && s.s[i])
			t.push_back(i);
	for (int n; (n = in());) {
		auto r = upper_bound(t.begin(), t.end(), n) - 1;
		outl(*r - 2, ' ', *r);
	}
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1];
int main(){
  int n;
  for(int i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(int i = 2;i * i <= MAX_V;i++){
    if(prime[i]){
      for(int k = 2* i;k <= MAX_V;k += i)
      prime[k]=0;
    }
  }
  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    for(int i = n; i > 3; i--){
      if(prime[i] == 1 && prime[i-2] == 1){
        printf("%d %d\n",i-2,i);
        break;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
int main(){
  std::vector<int> v;
  v.push_back(2);
  for(int i=3;i<=11000;i+=2){
    bool b = true;
    for(int j=0;i>=v[j]*v[j]&&b==true;j++){
      if(!(i%v[j]))b=false;
    }
    if(b)v.push_back(i);
  }
  int n;
  while(std::cin>>n){
    if(!n)return 0;
    for(int i=v.size()-1;i;i--)
      if(v[i]-v[i-1]==2&&v[i]<=n){std::cout<<v[i-1]<<" "<<v[i]<<std::endl;break;}
  }
}

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;
	vector<pair<int,int> > twin;
	bool f=false;
	for(int i = 0; i < p; i++){
		for(int j = i+1; j < p; j++){
			if(prime[j]-prime[i]==2){
				twin.push_back(make_pair(prime[i],prime[j]));
				//					cout<<prime[j]<<" "<<prime[i]<<endl;
			}
		}
	}

	while(cin>>n&&n!=0){
		for(int i = twin.size()-1; ; i--){
			if(twin[i].first<=n&&twin[i].second<=n){
				cout<<twin[i].first<<" "<<twin[i].second<<endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,flg,i,j,p1,q1,fllg,ii;
	while(1){
		cin>>n;
		if(n==0)break;
		for(i=n;i>1;i--){
			flg=1;
			if(i!=2&&i%2!=0){
				for(j=2;j*j<i;j++){
					if(i%j==0){
						flg=0;
						break;
					}
				}
				if(flg==1){
					ii=i-2;
					for(j=2;j*j<ii;j++){
						if(ii%j==0){
							flg=0;
							break;
						}
					}
				}
				if(flg==1) flg=2;
			}
			if(flg==2){
				p1=ii;
				q1=i;
				break;
			}
		}
		cout<<p1<<' '<<q1<<endl;
		p1=0; q1=0;
	}
	return 0;
}

C++: #include <stdio.h>

int isprime(int n){
    for(int i=2;i<n;i++){
        if(n%i==0)
            return 0;
        }
    return 1;
}

int main(){
    int num;
    while(1){
        scanf("%d",&num);
        if(num==0)break;
        for(int i=num;i>3;i--){
            if(isprime(i)==1&&isprime(i-2)==1){
                printf("%d %d\n",i-2,i);
                break;
            }
        }
    }
    return 0;
}

C++: // 2012/09/20 Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool is_prime[10001];
	is_prime[0] = is_prime[1] = false;
	for(int i=2; i<=10000; i++)
		is_prime[i] = true;

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

	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		for(int i=n; i>=5; i--){
			if(is_prime[i]&&is_prime[i-2]){
				cout << i-2 << ' ' << i << '\n';
				break;
			}
		}
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    FOR(i,3,20001){
	bool flg=true;
	for(int j=2;j*j<=i;j++){
	    if(i % j == 0){
		flg = false;
		break;
	    }
	}
	if(flg){
	    primes.PB(i);
	}
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int x = lower_bound(ALL(primes),n) - primes.begin();
	RREP(i,x){
	    if(primes[i]-primes[i-1]==2){
		cout << primes[i-1] << " " << primes[i]<<endl;
		break;
	    }
	}
    }


    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
const int MAX_V = 10000;
int prime[MAX_V+1];
int main(void){
  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\n",p1,q1);
  }
  return 0;
}