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;
bool t[10000] = {false};
int main()
{
	int n, i, j;
	t[0] = true;
	for (i = 2; i * i <= 10000; i++)
	{
		if (!t[i-1])
		{
			for (j = i+i; j <= 10000; j+=i)
				t[j-1] = true;
		}
	}
	while (cin >> n, n)
	{
		for (i = n; i >= 5; i--)
		{
			if ((!t[i-1]) && (!t[i-3]))
			{
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
}

C++: #include <stdio.h>

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

int main(){
	int n,i,min,max;
	int number[10000+2] = {0};
	for(i = 2;i < 10000;i++){
		number[i] = isprime(i);
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = n;i > 0;i--){
			//printf("%d  ",i);
			if(number[i] && number[i-2]){
				min = i-2;
				max = i;
				//printf("%d %d\n",i,i-2);
				break;
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

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

using namespace std;

bool isPrime(int n){
  for(int i=2;i<=sqrt((double)n);i++){
    if(n%i == 0)return false;
  }
  return true;
}

int main(){
  int n,q;
  while(true){
    cin >> n;
    if(n == 0)break;
    q=n;
    for(int i=n-1;i>=1;i--){
      if(isPrime(i)){
	if(q-i == 2){
	  cout << i << " " << q << endl;
	  break;
	}
	q=i; 
      }
    }
  }
  return 0;
}

C++: #include<stdio.h>

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

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

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

bool data[10010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	while(cin >> n && n != 0){
		fill(data, data + n + 1, true);

		data[1] = false;
		data[0] = false;
		for(int i = 2; i <= n; ++i){
			for(int j = 2; i * j <= n; ++j){
				data[i * j] = false;
			}
		}

		for(int i = n; i >= 2; --i){
			if(data[i] && data[i - 2]){
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include <iostream>
#include <vector>

constexpr bool divisible(const std::size_t n, const std::size_t m)
{
	return (0 == n % m);
}

constexpr bool help_prime(const std::size_t n, const std::size_t m)
{
	return (m * m <= n) ?
        !divisible(n, m) && help_prime(n, m + 1) :
        true;
}

constexpr bool prime(const std::size_t n)
{
	return (n <= 1) ?
        false :
        help_prime(n, 2);
}

constexpr std::pair<std::size_t, std::size_t> find_twin_prime(const std::size_t limit, const bool next_skip = false)
{
    return prime(limit) ?
        prime(limit - 2) ?
        std::make_pair(limit - 2, limit) :
        find_twin_prime(limit - (next_skip ? 3 : 1), true) :
        find_twin_prime(limit - (next_skip ? 2 : 1), false);
}

int main()
{
    std::vector<std::size_t> ns;
    std::size_t n;
    
    while(std::cin >> n, n != 0)
    {
        ns.push_back(n);
    }

    for(const auto a : ns)
    {
        const auto&& t = find_twin_prime(a);
        std::cout << t.first << " " << t.second << std::endl;
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

//エラトステネスの篩
const int N = 11000;
vector<bool> p(N, true);
void Eratosthenes() {
	p[0] = false;
	p[1] = false;
	rep(i, N)if (p[i])for (int j = i * 2; j < N; j += i)p[j] = false;
}

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

		int ans1, ans2;
		for (int i = n; i >= 1; i--) {
			if (p[i] && p[i - 2]) {
				ans1 = i - 2; ans2 = i;
				break;
			}
		}
		Cout2(ans1, ans2);
	}
}

C++: #include <stdio.h>

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

int main(){
	int n,i,min,max;
	int number[10000+2] = {0};
	for(i = 2;i < 10000;i++){
		number[i] = isprime(i);
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = n;i > 0;i--){
			//printf("%d  ",i);
			if(number[i] && number[i-2]){
				min = i;
				max = i-2;
				//printf("%d %d\n",i,i-2);
				break;
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

C++: 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

const int MAXN = 1001024;

// 結果を格納する変数
int prime[MAXN]; // n 以下の素数のうち i 番目の素数
bool is_prime[MAXN]; // 整数 i が素数であるかどうか

int sieve(int n) {
    int res = 0;
    fill(is_prime, is_prime + MAXN, true);
    is_prime[0] = is_prime[1] = false; // 0 と 1 は素数ではない。
    for(int i = 2; i <= n; ++i) {
        if(!is_prime[i]) continue;
        prime[res++] = i;
        for(int j = 2 * i; j <= n; j += i) is_prime[j] = false; // 素数 i の倍数は素数ではない (ふるい(篩)にかける)
    }
    return res;
}


signed main(){

    sieve(200000);
    while(1){
        int n; cin >> n;
        if(!n) break;
        int ans = 5;
        int i = 1;
        while(1){
            if(prime[i] > n) break;
            if(is_prime[prime[i] - 2]){
                ans = prime[i];
            }
            i++;
        }
        cout << ans - 2 << " " << ans << endl;
    }
    return 0;
}