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 <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;

vi eratos(int n)
{
	vector<bool> isprime(n, true);
	isprime[0] = isprime[1] = false;
	reep(i, 2, n){
		if(isprime[i]){
			for(int j=i*2; j<n; j+=i)
				isprime[j] = false;
		}
	}
	
	vi prime;
	rep(i, n){
		if(isprime[i])
			prime.push_back(i);
	}
	
	return prime;
}

int main()
{
	vi prime = eratos(10001);
	int n;
	while(scanf("%d", &n), n){
		int id = distance(prime.begin(), upper_bound(prime.begin(), prime.end(), n)) - 1;
		for(;;){
			if(prime[id]-prime[id-1] == 2)
				break;
			--id;
		}
		
		printf("%d %d\n", prime[id-1], prime[id]);
	}

	return 0;
}

C++: #include "stdio.h"
const int MAX_V = 10000; // 1????????§????´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°,0????´???°??§?????????
int main() {
    int i, k, n;
    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1; // 2??\???????´???°??¨??????
    }
    for(i = 2; i * i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????
            }
        }
    }
        while(scanf("%d", &n) != 0) {
        int p1 = 0,q1 = 0;
        for(i = n;3 <= i;i--){
            if(prime[i] == 1 && prime[i-2] == 1){  //??????????´???°
                q1 = i;
                p1 = i-2;
                break;
            }
        }
        printf("%d %d\n",p1,q1);//for?????????????????????
    }
    return 0;
}
//????¨??????¨????????????????????????

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

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

int main()
{
	int n;
	while (std::cin >> n) {
		for (int p=n; p>=2; p--) {
			if (isPrime(p) && isPrime(p-2)) { std::cout << p-2 << " " << p << std::endl; break; }
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define al(s) s.begin(),s.end()

typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef pair<int, ppi> pipp;

vector<int> pri;
void era(int n)
{
	vector<int> fl(n+1,0);
	for (int i = 2; i <= n; i++)
	{
		if (fl[i] == 0)
		{
			for (int l = i; l <= n; l += i)
			{
				fl[l] = 1;
			}
			pri.push_back(i);
		}
	}

}

int main()
{
	era(10000);
	int n;
	vector<int> ans;
	for (int i = 0; i < pri.size(); i++)
	{
		if (binary_search(al(pri), pri[i] + 2))
		{
			ans.push_back(pri[i] + 2);
		}
	}

	while (cin >> n&&n)
	{
		if (binary_search(al(ans), n))
		{
			cout << *(lower_bound(al(ans), n))-2 <<" "<< *(lower_bound(al(ans), n)) << endl;
		}
		else
		{
			cout << *(lower_bound(al(ans), n)-1) -2<<" "<< *(lower_bound(al(ans), n) - 1)<< endl;
		}
	}
}

C++: #include <iostream>
using namespace std;
#define MAX (10001)

bool prime[MAX];

int main(){
	int n;
	for(int i=2; i<MAX; i++) prime[i] = true;
	for(int i=2; i<MAX; i++){
		if( prime[i] ){
			for(int j=i+i; j<MAX; j+=i){
				prime[j] = false;
			}
		}
	}
	while( cin >> n, n ){
		for(int i=n; 0<i; i--){
			if( prime[i] && prime[i-2] ){
				cout << i << endl;
				return 0;
			}
		}
	}
}

C++: #include <iostream>
#include <cmath>
#define MAX 1000000
#define N 10100
using namespace std;

void eratos(int, bool*);

int main(){
  bool prime[MAX+1];
  int size;
  eratos(N,prime);
  int count=0;
  int data[1250];
  for(int i=0, j=0;i<N;i++){
    if(prime[i]){
      data[j]=i;
      j++;
    }
  }

  while(1){
    int n;
    cin >> n;
    if(n==0) break;
    int ans1, ans2;
    for(int i=1;i<1250;i++){
      if(data[i]>n) break;
      if((data[i]-data[i-1])==2){
	ans1=data[i-1];
	ans2=data[i];
      }
    }
    cout << ans1 << ' ' << ans2 << endl;
  }
  return 0;
}

void eratos(int n, bool prime[]){
  for(int i=0;i<=n;i++) prime[i]=false;
  for(int i=3;i<=n;i+=2) prime[i]=true;
  prime[2]=true;
  int limit=(int)sqrt((double)n)+1;
  for(int i=3;i<=limit;i+=2){
    if(!prime[i]) continue;
    for(int j=i+i;j<=n;j+=i)
      prime[j]=false;
  }
}

C++: #include<iostream>
#include<vector>
#include<utility>
using namespace std;
typedef pair<int, int>p;
bool ip[20005];
vector<int>prime;
vector<p> twin;

void eratos() {
	for (int i = 0;i < 20005;i++)ip[i] = true;

	ip[0] = ip[1] = false;

	for (int i = 2;i*i < 20005;i++) {
		if (ip[i] == true) {
			for (int j = i * i;j < 20005;j += i)ip[j] = false;
		}
	}

	for (int i = 0;i < 20005;i++) {
		if (ip[i]) {
			prime.push_back(i);
		}
	}
	return;
}

int main() {
	int n;
	eratos();

	for (int i = 0;i < prime.size()-1;i++) {
		if (prime[i + 1] - prime[i] == 2) {
			twin.push_back(make_pair(prime[i], prime[i+1]));
		}
	}
	int x = twin.size();

	while (cin >> n, n) {
		for (int i = 1;i<x;i++) {
			if (twin[i].second > n) {
				cout << twin[i - 1].first << ' ' << twin[i - 1].second << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
    int masatoy, kouay, i, k, max1=5, max2=7;
    scanf("%d", &masatoy);
    while (masatoy != 0) {
        for (i = 1; i <= masatoy; i++) {
            if (i + 2 > masatoy)break;
            if (i!= 1 || i != 2 || i != 3) {
                if (i%2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0) {
                    if ((i + 2) % 2 != 0 && (i + 2) % 3 != 0 && (i + 2) % 5 != 0 && (i + 2 )% 7 != 0) {
                        if (max1 < i) {
                            max1 = i;
                            max2 = i + 2;
                        }
                    }
                }

            }
        }
        printf("%d %d\n", max1,max2);
            scanf("%d", &masatoy);
            max1 = 5;
            max2 = 7;
    }
    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n;

bool judge(int num)
{
	int cnt = 0;

	for (int i = 2; i < num;i++)
	{
		if (num%i==0)
		{
			cnt = 1;

			return false;
		}
	}

	return true;


}

int main(void)
{
	while (cin >> n, n)
	{
		for (int i = n; i > 2;i--)
		{
			if (judge(i)&&judge(i-2))
			{
				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/2; i++){
        if(j%i==0)return 0;
    }
    return 1;
}

int main(){
    std::vector<int> n;
    n.resize(N);