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 <utility>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

template<int N>
struct sieve {
	bool s[N];
	constexpr sieve() : s() {
		for (bool &i:s)
			i = true;
		for (int i = 4; i < N; i += 2)
			s[i] = false;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
	}
};

int main() {
	enum {N = 10001};
	constexpr sieve<N> s;
	vector<int> t = {5};
	for (int i = 7; i < N; i += 6)
		if (s.s[i - 2] && s.s[i])
			t.push_back(i);
	for (int n; (n = in());) {
		auto r = upper_bound(t.begin(), t.end(), n) - 1;
		outl(*r - 2, ' ', *r);
	}
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>

#define NUM 11000

struct Info{
	int small,big;
};

int main(){
	int table[NUM],limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	Info data_array[NUM];
	int pre = 2;
	data_array[2].small = 0;
	data_array[2].big = 0;

	for(int i=3; i < NUM; i++){
		if(table[i] == 1){
			if(i - pre == 2){
				data_array[i].small = pre;
				data_array[i].big = i;
			}else{
				data_array[i] = data_array[i-1];
			}
			pre = i;
		}else{
			data_array[i] = data_array[i-1];
		}
	}


	int n;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		printf("%d %d\n",data_array[n].small,data_array[n].big);
	}


	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a[10001],s,d,f,g,h,i,j;
	a[1]=0;
	for(i=2;i<=10000;i++){
		a[i]=1;
	}
	for(i=2;i<=5000;i++){
		if(a[i]!=0){
			s=2;
			while(i*s<=10000){
				a[i*s]=0;
				s++;
			}
		}
	}
	/*for(i=1;i<=10000;i++){
		if(a[i]==1){
			printf("%d\n",i);
		}
	}*/
	scanf("%d",&d);
	while(d!=0){
		for(i=d;i>=1;i--){
			if(a[i-2]==1&&a[i]==1){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	scanf("%d",&d);		
	}
	return 0;
}

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

bool is_sieve(int n)
{
    if(n % 2 == 0) return false;

    bool ret = true;
    for(int i = 3; i * i <= n; i+=2) {
        if(n % i == 0) {
            ret = false;
            break;
        }
    }
    return ret;
}

int main()
{
    int n, p;
    while(cin >> n && n) {
        p = 0;
        for(int i = 5; i <= n; i+=2) {
            if(is_sieve(i - 2) && is_sieve(i)) {
                p = i;
            }
        }
        cout << p - 2 << " " << p << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    bool prime[20000];
    fill(prime,prime+20000,true);
    prime[0]=prime[1]=false;
    for(int i=2;i*i<=20000;i++){
        if(prime[i])for(int j=i*2;j<=20000;j+=i)prime[j]=false;
    }
    int n;
    while(cin>>n,n){
        do{
            if(prime[n]&&prime[n-2]){
                cout<<n-2<<" "<<n<<endl;
                break;
            }

        }while(n--,n>=5);
    }
}

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

using namespace std;

bool prime_check(int N)
{
	if (N == 1) { return false; }

	for (int i = 2; i <= sqrt(N); i++)
	{
		if (N % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	int N[50000], I[50000], c = 0;

	while (cin >> N[c])
	{
        if(N[c] == 0){ goto END; }

		for (int i = (N[c] - 1); i > 1; i--)
		{
			if (prime_check(i) == true && prime_check(i - 2) == true)
			{
				I[c] = i; goto Exit;
			}
		}
	Exit:;

        c++;
	}

        END:;

        for(int i = 0; i < c; i++)
        {
            cout << I[i - 2] << ' ' << I[i] << endl;
        }

	return 0;
}

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

int main(){
  int n;
  int p[N], pn=0;
  bool isPrime[N];

  for( int i=0;i<N;i++ ) isPrime[i]=true;

  for( int i=2;i<N;i++ ){
    if( !isPrime[i] ) continue;
    p[pn++] = i;
    for( int j=2*i;j<N;j+=i ) isPrime[j]=false;
  }

  while( cin>>n && n ){
    // nより大きい要素を指す最小のポインタ
    int *q=upper_bound( p,p+pn,n );
    q--;
    while( *q - *(q-1) != 2 ) q--;

    cout << *(q-1) << " " << *q << endl;
  }

  return 0;
}

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

int main() {
    const int numPrimes = 10005;
    bool primes[numPrimes];
    for (int i = 2; i != numPrimes; ++i) {
        primes[i] = true;
    }

    for (int i = 2; i != int(sqrt(numPrimes)); ++i) {
        if (primes[i]) {        
            for (int j = 2; i * j < numPrimes; ++j) {
                primes[i*j] = false;
            }
        }
    }

    int n;
    while (cin >> n && n != 0) {
        for (int i = n; i - 2 >= 0; --i) {
            if (primes[i] && primes[i-2]) {
                cout << i-2 << " " << i << endl;
                break;
            }
        }

    }
    return 0;
}

C++: #include<stdio.h>
const int MAX_V = 10000;
int prime[MAX_V+1];
int hurui(int v){
  int i, k;
  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;
      }
    }
  }
  int isprime = prime[v];
  if(isprime) {
    return 1;
  }else{
    return 0;
  }
}

int main() {
  int v;
  while(scanf("%d", &v) != EOF) {
    if(v == 0)  break;
    while(1){
      if(hurui(v) == 0 || hurui(v - 2) == 0){
        v--;
      }else{
        printf("%d %d\n", v - 2, v);
        break;
      }
    }
  }
  return 0;
}