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 "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

vector<int>primes;
vector<int>sos;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}

int main() {
	hurui(10000);
	while (1) {

		int N; cin >> N;
		if (!N)break;
		while (1) {
			if (sos[N] && sos[N - 2]) {
				cout << N - 2 << " " << N << endl;
				break;
			}
			N--;
		}
	}

	return 0;
}

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

int n;
bool pn[10001] = { false };

int main(){
	for (int i = 2; i < 10001; i++) {
		if (!pn[i]) {
			for (int j = i+i; j < 10001; j += i) {
				pn[j] = true;
			}
		}
	}
	while (cin >> n) {
		for (int i = n; i >= 2; i--) {
			if (!pn[i] && !pn[i - 2]) {
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include<iostream>
#include<fstream>
#include<vector>
#define N 10000

//jが素数なら1、違うなら0を返す
int sosu(int j){
    if(j<2)return 0;
    if(j==2)return 1;
    if(j%2==0)return 0;
    for(int i=3; i<=j/2; i++){
        if(j%i==0)return 0;
    }
    return 1;
}

int main(){
    std::vector<int> n;
    n.resize(N);
    //入力
    for(int i=0; i<N; i++){
        std::cin >> n[i];
        if(n[i]==0)break;
    }

    for(int i=0; i<N; i++){
        if(n[i]==0)break;
        for(int j=n[i]; j>5; j--){
            if(sosu(j)&&sosu(j-2)){
                    std::cout << j-2 << " " << j <<std::endl;
                    break;
}
            }
        }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
#define MAX 1000000  
  bool sosu[MAX]={0};
  for(int i=4;i<MAX;i+=2)sosu[i]=true;
  for(int i=3;i<MAX;i+=2){
    if(sosu[i])continue;
    for(int j=3*i;j<MAX;j+=2*i)sosu[j]=true;
  }
  int n;
  while(cin>>n,n){
    int i;
    for(i=n;i>=0;i--){
      if(sosu[i]==false&&sosu[i-2]==false)break;
    }
    cout<<i-2<<" "<<i<<endl;
  }
}

C++: #include<iostream>
#include<fstream>
#include<vector>
#define N 10000

int gcd(int q1,int p1){
    if(q1%p1==0) return p1;
    return gcd(p1,q1%p1);
}

//jが素数なら1、違うなら0を返す
int sosu(int j){
    if(j<2)return 0;
    if(j==2)return 1;
    if(j%2==0)return 0;
    for(int i=3; i<=j/2; i++){
        if(j%i==0)return 0;
    }
    return 1;
}

int main(){
    std::vector<int> n;
    n.resize(N);
    //入力
    for(int i=0; i<N; i++){
        std::cin >> n[i];
        if(n[i]==0)break;
    }
    for(int i=0; i<N; i++){
        if(n[i]==0)break;
        for(int j=n[i]; j>5; j--){
            if(sosu(j)&&sosu(j-2))
                if(gcd(j,j-2)==1){
                    std::cout << j-2 << " " << j <<std::endl;
                    break;
                }
            }
        }
    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 k,n,p,q;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(k=2;k<=n-2;k++){
      if(isprime(k)&&isprime(k+2)){
        p=k;
        q=k+2;
      }
    }
    printf("%d %d\n",p,q);
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main() {

	vector<int> prime;
	vector<bool> used(10001, false);
	used[0] = used[1] = true;
	for (int i = 2; i * i <= 10000; i++) {
		if (!used[i]) prime.push_back(i);
		used[i] = true;
		for (int j = i * 2; j <= 10000; j += i) {
			used[j] = true;
		}
	}
	REP(i, 10000 + 1) if (!used[i]) {
		prime.push_back(i);
		used[i] = true;
	}
	
	vector<int> ans;
	FOR(i, 1, prime.size()) {
		if (prime[i] == prime[i - 1] + 2) ans.push_back(prime[i]);
	}
	sort(ans.begin(), ans.end());
	
	int n;
	while (cin >> n, n) {
		int b = *(lower_bound(ans.begin(), ans.end(), n) - 1);
		int a = b - 2;
		cout << a << " " << b << endl;
	}
	return 0;
}

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

int main(){
	bool prime[10001];
	int n, p1, q1;
	for(int i = 0; i < 10001; i++){
		prime[i] = true;
	}
	prime[0] = prime[1] = false;
	for(int i = 2; i < sqrt(10001); i++){
		if(prime[i]){
			
			for(int j = 2; j * i < 10001; j++){
				prime[j*i] = false;
			}
		}
	}
	
	while(scanf("%d", &n) != EOF){
		if(n == 0) break;
		for(int i = n; i > 0; i--){
			if(prime[i] && prime[i-2]){
				p1 = i-2;
				q1 = i;
				break;
			}
		}
		
		printf("%d %d\n", p1, q1);
	}
	
	return 0;
}