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++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <sstream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

const int MAX_N=50100;
int p[(MAX_N+1)/2];
bool isp[MAX_N+1];

int gen_ps(){
    memset(isp,1,sizeof(isp));
    isp[0]=isp[1]=false;
    int idx=0;
    loop(i,2,MAX_N+1){
        if(!isp[i]) continue;
        p[idx++]=i;
        for(int j=i+i; j<=MAX_N; j+=i){
            isp[j]=false;
        }
    }
    return idx;
}

int main(){
    int n;
    int len = gen_ps();
    while(cin>>n && n){
        int *lb = lower_bound(p,p+len,n)-1;
        while(lb[0] != lb[-1]+2)lb--;
        cout << lb[-1] << " " << lb[0] << endl;
    }
}

C++: #include<iostream>
using namespace std;
bool isp[10000];
main()
{
    isp[0]=isp[1]=1;
    for(int i=2;i<=100;i++)
    {
        if(isp[i])continue;
        for(int j=i*i;j<=10000;j+=i)isp[j]=1;
    }
    int n;
    while(cin>>n,n)
    {
        while(isp[n]||isp[n-2])n--;
        cout<<n-2<<" "<<n<<endl;
    }
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main()
{
	int maxsize(0);
	vector<int> input;

	while (1)
	{
		int tmp;

		cin >> tmp;

		(maxsize < tmp) ? (maxsize = tmp) : (0);
	}

	vector<int> prime, ans;

	for (int i(1); i <= maxsize; ++i)
	{
		for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
		{
			if (i % *i2 == 0)
			{
				prime.push_back(i);
				if (i2 != prime.begin())
				{
					if (*(--i2) == i)
					{
						ans.push_back(i);
					}
				}
				break;
			}
		}
	}

	for (vector<int>::iterator i(input.begin()), n(input.end()); i != n; ++i)
	{
		int out(*i);

		for (vector<int>::reverse_iterator i2(ans.rbegin()), n2(ans.rend()); i2 != n2; ++i2)
		{
			if (*i2 <= out)
			{
				cout << (*i2 - 2) << ' ' << (*i2) << endl;
				break;
			}
		}
	}

	return 0;
}

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

string prime(int n){
  int i,j;
  string p = "001";
  while(p.size()<=n)p+="10";

  i = 3;
  while(i*i<n){
    for(j=3*i;j<n;j+=2*i)p[j] = '0';
    do{
      i+=2;
    }while(p[i]-'1');
  }
  return p;
}

int main(){
  int n;
  string p;
  while(1){
    cin >> n;
    if(!n)break;

    p = prime(n);
    cout << p.size() <<endl; 
    while(n){
      if(p[n]=='1' && p[n-2]=='1'){
	cout << n-2 << " " << n << endl;
	break;
      }
      n--;
    }
  }
}

C++: #include <iostream>
#include <vector>
using namespace std;
vector<int>prime;
int main(){
    int ask;
    prime.push_back(1);
    prime.push_back(2);
    for(int i=3;i<10001;i++){
        int t=1;
        for(int j=2;j*j<=i;j++){
            if(i%j==0){
                t=0;
                break;
            }
        }
        
        if(t)
            prime.push_back(i);
    }
    while(true){
        cin>>ask;
        if(ask==0)
            break;
        for(int i=ask;i>1;i--){
            if(find(prime.begin(),prime.end(),i)!=prime.end()&&find(prime.begin(),prime.end(),i-2)!=prime.end()){
                cout<<i-2<<" "<<i<<endl;
                break;
            }
        }
    }
    return 0;
}

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>
#include <vector>
using namespace std;
int main()
{
	int maxsize(0);
	vector<int> input;

	while (1)
	{
		int tmp;

		cin >> tmp;

		(maxsize < tmp) ? (maxsize = tmp) : (0);
	}

	vector<int> prime, ans;

	for (int i(1); i <= maxsize; ++i)
	{
		for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
		{
			if (i % *i2 == 0)
			{
				prime.push_back(i);
				if (i2 != prime.begin())
				{
					if (*(--i2) == i)
					{
						ans.push_back(i);
					}
				}
				break;
			}
		}
	}

	for (vector<int>::iterator i(input.begin()), n(input.end()); i != n; ++i)
	{
		int out(*i);

		for (vector<int>::iterator i2(ans.rbegin()), n2(ans.rend()); i2 != n2; ++i2)
		{
			if (*i2 <= out)
			{
				cout << (*i2 - 2) << ' ' << (*i2) << endl;
			}
		}
	}

	return 0;
}

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

int main(){
	bool prime[10001];
	int i,j,n;
	for(i = 4;i<=10000;i+=2){
		prime[i] = false;
	}
	prime[2] = true;
	for(i = 3;i<=10000;i+=2){
		if(prime[i]){
			for(j = 3;j<=10000/i;j+=2){
				prime[i*j] = false;
			}
		}
	}
	while(cin >> n && (n != 0)){
		for(i = n;i>=5;i--){
			if(prime[i] && prime[i-2]){
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <stdio.h>
const int MAX_V = 10000;//10000?????§????´???°??¨?????????

int main(){
int prime [MAX_V+1];
	int i, k, v, n;
	for(i = 2; i <= MAX_V; i++){
		prime[i] = 1;
	}
	for(i = 2; i*i <= MAX_V; i++){//??¨?????????????????????????????¨????????????
		if(prime[i] == 1){
			for(k = 2*i; k <= MAX_V; k += i){
				prime[k] = 0;//?´???°????????°????´???°??§??????
			}
		}
	}
	while(1){
		scanf("%d", &n);
		if(n == 0) break;
		for(i = n; n >= 5; i--){
			if(prime[i] == 1 && prime[i-2] == 1){
				printf("%d %d\n", i-2, i);
				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 v;
  while(scanf("%d", &v) != EOF) {
    if(v == 0){
      break;
    }
    while(1){
      if(isprime(v) == 1 && isprime(v - 2) == 1){
        printf("%d %d\n", v - 2, v);
        break;
      }else{
        v--;
      }
    }
  }
  return 0;
}

C++: #include<stdio.h>
const int MAX_V = 1000000;
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, k, i = 0, count = 0, q1[100];
  while(scanf("%d", &v) != EOF) {
    if(v == 0){
      break;
    }
    while(1){
      if(hurui(v) == 1 && hurui(v - 2) == 1){
        q1[i] = v;
        break;
      }else{
        v--;
        count ++;
      }
    }
    i++;
  }
  for(k = 0; k < i; k++){
    printf("%d %d\n", q1[k] - 2, q1[k]);
  }
  return 0;
}