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 <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int N = 100000;
	
	bool a[100000];
	
	for(int i = 0; i < N; i++){
		a[i] = true;
	}
	
	a[0] = false;
	a[1] = false;
	
	for(int i = 2; i < N; i++){
		if(a[i]){
			for(int j = i * 2; j < N; j += i){
				a[j] = false;
			}
		}
	}
	
	int n;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}else if(n < 5 || n > 10000){
			printf("NA\n");
			continue;
		}else{
			for(int i = n; i > 2; i--){
				if(a[i] && a[i - 2]){
					printf("%d %d\n", i - 2, i);
					break;
				}
			}
		}
	}
	
	return 0;
}

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

int main() {
    vector<bool> v(11111, true);
    v[0] = v[1] = false;
    for (int i = 2; i <= 10000 / 2; i++) {
        for (int j = 2; j * i <= 10000; j++) {
            v[i * j] = false;
        }
    }

    vector<pair<int,int> > d;
    for (int i = 0; i <= 10000 ; i++) {
        if (v[i] && v[i+2]) d.push_back(pair<int,int>(i, i+2));
    }

    int n;
    while (cin >> n, n) {
        auto iter = upper_bound(d.begin(), d.end(), pair<int,int>(n - 2,n - 2)) - d.begin();
        while (d[iter].second > n) iter--;
        cout << d[iter].first << ' ' << d[iter].second << endl;
    }

    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,prime[10000];
	for(i=3;i<10000;i++){
		prime[i]=isprime(i);
	}
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=n;i>=3;i--){
			if(prime[i]==1&&prime[i-2]==1){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <cstring>
#include <climits>

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

using namespace std;

bool primearray[10000];

void erathos()
{
	int i;
	memset(primearray, 0, sizeof(primearray));

	REP( i, 2, 10000)
	{
		if( primearray[i] == 0 )
		{
			for( int j = i*2; j < 10000; j+=i)
			{
				primearray[j] = 1;
			}
		}
	}

	return;
}

int main()
{
	int in;

	erathos();

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

	return 0;

}

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);
}

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; 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 <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 (int i = 0; i < N; i++)
			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;
		}
	}
};

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;
	scanf("%d", &n);
	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;
 }

C++: #include <iostream>
#include <string.h>

using namespace std;
bool isPrime[10002];

void PrimeCalc()
{
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 10001; ++i)
	{
		if(isPrime[i])
		{
			for(int j = 2 * i; j < 10001; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n, n)
	{
		for(int i = n; i >= 7; --i)
		{
			if(isPrime[i] && isPrime[i - 2])
			{
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

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