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>
using namespace std;

int main(){
	int prime[10001] = { 0 };
	int i,j,n;
	for(i = 3;i<=10000;i+=2){
		prime[i] = 1;
	}
	prime[2] = 1;
	for(i = 3;i<=100;i+=2){
		if(prime[i] == 1){
			for(j = 3;j<=10000/i;j+=2){
				prime[i*j] = 0;
			}
		}
	}
	while(cin >> n && (n != 0)){
		for(i = n;i>=5;i--){
			if(prime[i] == 1 && prime[i-2] == 1){
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include<cstdio>

using namespace std;

int is_prime(int n){
	int i;
	if(n<=1) return 0;
	if(n==2) return 1;
	if(n%2==0) return 0;

	for(i=3;i * i<=n;i+=2)
		if(n%i==0)
			return 0;
	return 1;
}

int main(void){
	int i;
	int n;

	for(;;){
		scanf("%d",&n);
		if(!n)
			break;

		for(i=n;i>=2;i--)
			if(is_prime(i)) 
				if(is_prime(i-2)){
					printf("%d %d\n",i-2,i);
					break;
				}
	}

	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> P;
#define MAX 10000
 
int is_prime[MAX+5];// 1:prime 0:not prime
int ans[MAX+5];
void eratos()
{
	int i,j;
	for(i=2;i<=MAX;i++)is_prime[i]=1;
	for(i=2;i*i<=MAX;i++)if(is_prime[i]==1)
	{
		for(j=i*2;j<=MAX;j+=i)is_prime[j]=0;
	}
	return;
}
 
int main(void)
{
	eratos();
	for(int i=0;i<=MAX;i++)if(is_prime[i]&&is_prime[i+2])ans[i+2]=i+2;
	for(int i=5;i<=MAX;i++)if(ans[i]==0)ans[i]=ans[i-1];
	while(1)
	{
		int n;
		cin >> n;
		if(n==0)break;
		cout << ans[n]-2 << ' ' << ans[n] << endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

  int n;
  int data[10001];
  for(int i = 0; i <= 10000; i++) data[i] = 1;


  for(int i = 2; i <= 100; i++){
    for(int j = i*2; j <= 10000; j+=i){
      data[j] = 0;
    }
  }
  while(1){
    cin >> n;
    if(n == 0) break; 
    for(int i = n; i >= 5; i--){
      if(data[i] == 1 && data[i-2] == 1){
	cout << i-2 << " " << i << endl;
	break;
      }
    }
  }
  return 0;

}

C++: #include <stdio.h>

const int MAX_V = 1000000; // 100万まて?の素数表を作る
int prime[MAX_V+1]; // 1か?素数,0か?素数て?ない

int main() {
    int i, k, v;
    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; // 素数の2倍以上の倍数は素数ではない
            }
        }
    }
    
    while(1) {
        scanf("%d", &n);
        if(n == 0) break;
        for(int i = n; i >= 5; i--) {
            if(prime(i) == 1) {
                ans[1] = i;
                if(prime(i - 2) == 1) {
                    ans[0] = i - 2;
                    break;
                }
            }
        }
        printf("%d %d\n", ans[0], ans[1]);
    }
    
    return 0;
}

C++: #include <stdio.h>
#include <math.h>

int fl[10001] = {0};

void isfl(int);
void twlf(int);

int main(void) {
  int tag;

  while(1){
    scanf("%d",&tag);
    if(tag == 0) break;
    isfl(tag);
    twlf(tag);
  }
  return 0;
}

void isfl(int tag){
  int i,lim,idx = 2;
  fl[0] = 1;
  fl[1] = 1;

  lim = sqrt(tag);

  while(idx <= lim){
    if(fl[idx] == 0) for(i = idx*2;i<=tag;i+=idx) fl[i] = 1;
    idx++;
  }
  return;
}

void twlf(int tag){
  int i,k=-1,data[1000];
  for(i=1;i<=tag;i++) if(fl[i] == 0){
    k++;
    data[k] = i;
  }
  for(i=k;i>=0;i--){
    if(data[i] - data[i-1] == 2){
      printf("%d %d\n",data[i-1],data[i]);
      break;
    }
  }
  return;
}

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

C++: #include<iostream>
#include<vector>
#include<utility>
using namespace std;
typedef pair<int, int>p;
bool ip[10005];
vector<int>prime;
vector<p> twin;

void eratos() {
	for (int i = 0;i < 10005;i++)ip[i] = true;

	ip[0] = ip[1] = false;

	for (int i = 2;i*i < 10005;i++) {
		if (ip[i] = true) {
			for (int j = 2 * i;j < 10005;j += i)ip[j] = false;
		}
	}

	for (int i = 0;i < 10005;i++) {
		if (ip[i]) {
			prime.push_back(i);
		}
	}
	return;
}

int main() {
	int n;
	eratos();

	for (int i = 0;i < prime.size()-1;i++) {
		if (prime[i + 1] - prime[i] == 2) {
			twin.push_back(make_pair(prime[i], prime[i+1]));
		}
	}
	int x = twin.size();

	while (cin >> n, n) {
		for (int i = 0;i<x;i++) {
			if (twin[i].second > n) {
				cout << twin[i - 1].first << ' ' << twin[i - 1].second << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <stdio.h>

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

int main() {
	int n,i;
	int sousi[2];
	int prime[10100][2];
	for (i = 0; i < 10100; i++) {
		prime[i][0] = i;
	}
	while(1) {
		sousi[0] = 0;
		sousi[1] = 0;	 
		scanf("%d",&n);
		for (i = 0; i < 10100; i++) {
			prime[i][1] = 0;
		}
		if(n == 0) {
			break;
		}
		for(i = 0; i <= n; i++) {
			prime[i][1] = isprime(prime[i][0]);
		}
		for(i = 0; i <= n; i++) {
			if(prime[i][1] == 1 && prime[i + 2][1] == 1) {
				sousi[0] = prime[i][0];
				sousi[1] = prime[i + 2][0];
			}
		}
		printf("%d %d\n",sousi[0],sousi[1]);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	bool prime[10001] = {}; prime[0] = prime[1] = true;
	for(int i=2;i<=10000;i++){
		if(prime[i]) continue;
		for(int j=2;i*j<=10000;j++){
			prime[i*j] = true;
		}
	}
	int N;
	while(cin>>N,N){
		int ans = 0;
		for(int i=2;i<=N;i++){
			if(!prime[i] && !prime[i-2]) ans = max(ans,i);
		}
		printf("%d %d\n",ans-2,ans);
	}
	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 i,a,b,n,p1,q1;
	while (scanf("%d", &n) != EOF){
		for(i=2;i<=n;i++){
			a = isprime(i-2);
			b = isprime(i);
			if(a==1 && b==1){
				p1 = i-2;
				q1 = i;
			}
		}
		printf("%d %d\n",p1,q1);
	}
	return 0;
 }