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<math.h>
using namespace std;
int isPrime(int n){
    if(n<2)return 0;
    double sqrtn= sqrt(n);
    for(int i=2;i<=sqrtn;i++){
        if(n%i==0)return 0;
    }
    return 1;
}
int main(void){
    int n=1;
    while(n){
        cin>>n;
        for(int i=n;i>0;i--){
            if(isPrime(i)*isPrime(i-2)){
                cout<<i-2<<" "<<i<<endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n,max,mx;
	int flg[10001];
	while(1) {
		scanf("%d",&n);
		if(n==0) break;
		for(i=2;i<=n;i++) flg[i]=1;
		for(i=2;i*i<=n;i++) {
			if(flg[i]==1) for(j=2;j*i<n;j++) flg[i*j]=0;
		}
		max=-1;
		for(i=n;i>=5;i--)	{
			if(flg[i]==1 && flg[i-2]==1)	break;
		}
		max=i-2;
//		for(i=2;i<n;i++) {
//			if(flg[i]==1 && flg[i]==flg[i+2] && i+2<=n) {
//				if(max<i) max=i;
//			}
//		}
		printf("%d %d\n",max,max+2);
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<vector>
#define pb push_back
using namespace std;
const int MAX = 11000; 
bool prime[MAX];
typedef pair<int,int> P;
vector<P> vec;
void eratos(){
  for(int i=0;i<MAX;i++)prime[i] = false;
  for(int i=3;i<MAX;i+=2)prime[i] = true;
  prime[2] = true;
  int lim = (int)sqrt((double)MAX)+1;
  for(int i=3;i<=lim;i+=2){
    if(!prime[i])continue;
    for(int j=i+i;j<MAX;j+=i)prime[j] = false;
  }

  for(int i=2;i<MAX;i++){
    if(prime[i] && prime[i+2]){
      vec.pb(P(i,i+2));
    }
  }

}
 
int main(){
  int n,q;
  eratos();
  while(true){
    cin >> n;
    if(n == 0)break;
    for(int i = 0;i<vec.size();i++){
      if(vec[i].second > n){
	cout << vec[i-1].first << " " << vec[i-1].second << endl;
	break;
      }
    }   

  }
  return 0;
}

C++: #include <iostream>
using namespace std;
#define MAX (10001)

bool prime[MAX];

int main(){
	int n;
	for(int i=2; i<MAX; i++) prime[i] = true;
	for(int i=2; i<MAX; i++){
		if( prime[i] ){
			for(int j=i+i; j<MAX; j+=i){
				prime[j] = false;
			}
		}
	}
	while( cin >> n, n ){
		for(int i=n; 0<i; i--){
			if( prime[i] && prime[i-2] ){
				cout << i-1 << " " << i << endl;
				return 0;
			}
		}
	}
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
using namespace std;

bool p[10001];
 
void seive(int s){
    for(int i=0;i<=s;i++)p[i]=true;
    p[0]=p[1]=false;
    for(int i=2;i<=s;i++){
        if(p[i]==true){
            for(int j=i*2;j<=s;j+=i)p[j]=false;
        }
    }
}
 
int main(){
   seive(10000);
   int n;
   while(cin>>n&&n){
       while(1){
           if(p[n]==true&&p[n-2]==true){
               cout<<n-2<<" "<<n<<endl;
               break;
           }
           n--;
       }
   }
    return 0;
}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];
int main() {
  int i, k, n, j, 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;
      }
    }
  }
  for( ;; ) {
    scanf( "%d", &n );
    if( n == 0 )break;
    for( j = 2; j <= n; j++ ) {
      int isprime = prime[j];
      int isprimee = prime[j-2];
      if( isprime == 1 && isprimee == 1 ) {
        q1 = j;
        p1 = q1 - 2;
      }
    }
    printf( "%d %d\n", p1, q1 );
  }
  return 0;
}

C++: #include <cmath>
#include <cstring>
#include <iostream>
#include <ostream>
#include <vector>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> v) {
	os << "[";
	for(int i = 0; i < int(v.size()); i++) {
		os << v[i] << (i == int(v.size()) - 1 ? "" : ", ");
	}
	os << "]";
	return os;
}

// n 以下の素数のリストを返す O(nlog(log(n)))
std::vector<int> eratosthenes(int n) {
	std::vector<int> is_prime(n + 1, 1);
	std::vector<int> primes;

	is_prime[0] = is_prime[1] = 0;
	primes.push_back(2);
	for(int i = 3; i <= n; i += 2) {
		if(is_prime[i]) {
			primes.push_back(i);
			for(int j = 3; i * j <= n; j += 2) {
				is_prime[i * j] = 0;
			}
		}
	}

	return primes;
}

int main() {
	int n;

	while(cin >> n, n) {
		std::vector<int> primes = eratosthenes(n);

		for(int i = int(primes.size()) - 1; i > 0; i--) {
			if(primes[i] - primes[i - 1] == 2) {
				cout << primes[i - 1] << " " << primes[i] << endl;
				break;
			}
		}
	}

	return 0;
}