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>

int main(){
  const int MAX_V = 10000;
  int prime[MAX_V+1];
  int i, k, v, ans, dif;
  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(scanf("%d", &v) != EOF){
    if(v == 0) break;
    for(k = v; k >= 2; k--){
      ans = prime[k];
      if(ans == 1){
        dif = prime[k - 2];
        if(dif == 1){
          printf("%d %d\n", k - 2, k);
          break;
        }
      }
    }
  }
  return 0;
}

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

int main(){
  int i ,j ,n;
  while( true ){
    cin >> n;
    if( n == 0 ){
      break;
    }
    int prime[n+1]; // 素数
    for( i=2 ; i<=n ; i++ ){ // 自然数を列挙
      prime[i] = 1;
    }
    
    i = 2;
    while( i <= n ){
      if( prime[i] == 1 ){ // 素数なら
	j = i*2;
	while( j <= n ){
	  prime[j] = 0;
	  j += i;
	}
      }
      i++;
    }
    for( i=n ; i>0 ; i-- ){
      if( prime[i] == 1 && prime[i-2] == 1 ){
	cout << i-2 << ' ' << i << endl;
	break;
      }
    }
  }
  return 0;
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1];
int sum, x, y, ans;
int main(){
 int i, k, v, n, left, right;
 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(i = 0; i<=n-2; i++){
   x = prime[i];
   y = prime[i + 2];
   if(x == 1 && y == 1){
    ans = i;
   }
  }
  printf("%d %d\n", ans, ans+2);
 }
 return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define SUBIF(a, b, x) ((x) ? (b) : (a))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647LL
#define MOD 1000000007LL
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int n;
bool isPrime[10010];
VI prime;
PII ans[10010];


void makePrime(){
	fill(RNG(isPrime, 10001), true);
	isPrime[0] = isPrime[1] = false;
	for(int i = 2;i*i <= 10000;i++)
		if(isPrime[i])
			for(int j = 2;i*j <= 10000;j++) isPrime[i*j] = false;
	rep(i, 0, 10010)
		if(isPrime[i]) prime.pb(i);
}


void makeAns(){
	ans[5] = { 3, 5 };
	repe(i, 6, 10000){
		if(!isPrime[i]){
			ans[i] = ans[i-1];
			continue;
		}
		int pi = distance(prime.begin(), lower_bound(ALL(prime), i));
		if(prime[pi]-prime[pi-1] == 2) ans[i] = { prime[pi-1], prime[pi] };
		else ans[i] = ans[i-1];
	}
}


int main(){
	makePrime();
	makeAns();
	while(cin >> n, n) cout << ans[n].first << ' ' << ans[n].second << endl;

	return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;

int fl[10001] = {0};

int isprime(int);
void twlf(int);

int main(void) {
  int tag;

  while(1){
    cin >> tag;
    if(tag == 0) break;
    for(int i=2;i<=tag;i++) fl[i] = isprime(i);
    twlf(tag);
  }
  return 0;
}

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

void twlf(int tag){
  int k=0,data[10000];
  for(int i=2;i<=tag;i++) if(fl[i] == 0){
    data[k] = i;
    k++;
  }
  for(int i=k-1;i>=0;i--){
    if(data[i] - data[i-1] == 2){
      cout << data[i-1] << " " << data[i] << endl;
      break;
    }
  }
  return;
}

C++: #include <iostream>
using namespace std;
int prime_number(int n){
    int i;
    if(n<=1) return 0;
    for(i=2;i<=n/2;i++) if(n%i==0) return 0;
    return 1;
}

int main(){
    int i,n,a=0;
    cin >> n;
    for(i=n;i>4;i--) if(prime_number(i)) if(prime_number(i-2)){
        a=i;
        break;
    }
    if(a!=0) cout << i-2 << " " << i << endl;
    return 0;
}

C++: #include<stdio.h>

int main(){
  const int MAX_V = 100000;
  int prime[MAX_V+1];
  int i, k, v, ans, dif;
  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(scanf("%d", &v) != EOF){
    if(v == 0) break;
    for(k = v; k >= 2; k--){
      ans = prime[k];
      if(ans == 0){
        dif = prime[k - 2];
        if(dif == 0){
          printf("%d %d\n", k - 2, k);
          break;
        }
      }
    }
  }
  return 0;
}

C++: #include <cstdio>
#define MAX 10001

int main( void ){
	int n, i;
	int a[ MAX ] = {0};
	while(1){
		scanf( "%d", &n ); 
		if(!n){break;}
		for( i = 2; i <= n; i++ ){
			if( a[ i ] ){ continue; }
			for( int j = i * 2; j <= n; j += i ){
				a[ j ] = 1;
			}
		}
		for( i = n; a [ i ] || a[ i - 2 ]; i-- ){}
		printf( "%d %d\n", i - 2, i );
	}
	return 0;
}

C++: #pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/(a,b);}
//priority_queue<int, vi, greater<int> > que;//æ˜‡é †

using namespace std;

const int mod=1e9+7;
bool isSosuu(int n);
signed main(){
  SPEED;
  int n;
  while(1){
    int n=0;
    cin >> n;
    if(n==0)return 0;
    for(int i=(n-2);i>1;i--){
      if(isSosuu(i)&&isSosuu(i+2)){
        cout << i << " " << i+2 << endl;
        break;
      }
    }
  }
  return 0;
}
bool isSosuu(int num){
  if (num < 2) return false;
      else if (num == 2) return true;
      else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

      double sqrtNum = sqrt(num);
      for (int i = 3; i <= sqrtNum; i += 2)
      {
          if (num % i == 0)
          {
              // 素数ではない
              return false;
          }
      }

      // 素数である
      return true;
}