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>
using namespace std;

#define MAX_N 12000

int prime[MAX_N];
bool is_prime[MAX_N + 1];


void prime_generate(){
	int p = 0;
	for(int i = 0; i <= MAX_N; i++) is_prime[i] = true;

	is_prime[0] = is_prime[1] = false;

	for(int i = 2; i <= MAX_N; i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2 * i; j <= MAX_N; j += i) is_prime[j] = false;
		}
	}
}

void solve(int n){
	int p1 = -1, p2 = -1;

	for(int i = 0; prime[i+1] <= n; i++){
		if(prime[i+1] - prime[i] == 2){
			if(p1 <= prime[i]){
				p1 = prime[i];
			}
			if(p2 <= prime[i+1]){
				p2 = prime[i+1];
			}
		}
	}
	cout << p1 << " " << p2 << endl;
}

int main(){
	prime_generate();

	int n;
	while(cin >> n){
		solve(n);
	}
}

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

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

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

vector<int> sosuu(int n){
	vector<int>s;
	bool f[10001];
	f[0]=false;f[1]=false;
	
	for(int i=2; i<n; i++)
	{
		
		if(f[i])
		{
			s.push_back(i);
			for( int j = i*2 ; j<n; j+=i ) {f[j]=false;}
		}
	}
	return s;
}

int main(){
	int n;
	while(cin>>n && n)
	{
		vector<int>so;
		so = sosuu(n);
		for( vector<int>::iterator it=so.end()-1; it != so.begin(); --it)
		{
			if( *(it) - *(it-1) == 2) 
			{
				cout<<*(it-1)<<" "<<*(it)<<endl;
				break;
			}
		}
	}
	return 0;
}

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

vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}

int main() {
  int a; cin >> a;
  vector<int> p = sieve_of_eratosthenes(a + 1);
  for (int i = a; i > 2; --i) {
    if (p[i - 2] && p[i]) {
      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 <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

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

int main(void)
{
	int n;
	while (scanf("%d", &n), n){
		
		for (int i = n; 5 <= i; i--){
			// cout << i << endl;
			if (isPrime(i) && isPrime(i-2)){
				cout << i-2 << " " << i << endl;
				break;
			}
		}
		
	}
	
	return 0;
}

C++: #include <stdio.h>

int isprime(int n) {
	int i;
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) return 0;
    }
    return 1; 
}

int main(){
	int k,suu,an1,an2;
    while(1){
        scanf("%d",&suu);
        if(suu == 0)  break;
        for(k=2;k<=suu;k++){
            if(isprime(k-2)==1 && isprime(k)==1){
                an1=k-2;
                an2=k;
            }
        }
        printf("%d %d\n",an1,an2);
    }
}

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

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

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
bool sosu(int q);
int mem[10005]={0};
main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;
    int q;
    for(q=n-((n+1)%2);q-2>1;q-=2){
      if(sosu(q)&&sosu(q-2)){
	cout<<q-2<<" "<<q<<endl;
	break;
      }
    }
  }
}
bool sosu(int q){
  if(mem[q]==1){
    return 1;
  }
  else if(mem[q]==-1){
    return 0;
  }
  else{
    for(int i=2;i<=sqrt(q);i++){
      if(mem[i]==0||mem[i]==1){
	for(int j=i;j<=q;j+=i){
	  mem[j]=0;
	  if(j==q){
	    return 0;
	  }
	}
      }
    }
    if(mem[q]==0){
      mem[q]=1;
      return 1;
    }
  }
}

C++: #include<iostream>
using namespace std;
bool flag[10000001];
int main(){
    for(int i=0;i <= 1000000;i++){
		if(i<=1)flag[i]=false;
		else flag[i]=true;
	}
	for(int i=2;i <= 1001 ;i++){
		if(flag[i]==true){
			for(int j=i*2 ; j<=1000000 ; j=j+i){
				flag[j] = false;
			}
		}
	}
	int n;
	while(cin>>n,n){
        for(int i=n;i!=1;i--){
            if(flag[i]&flag[i-2]){
                cout<<i-2<<" "<<i<<endl;
                break;
            }
        }
	}

    return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstring>
using namespace std;
bool is_p[1000000];

void erast(int n, vector<int> &p){
  is_p[0] = is_p[1] = 1;
  p.push_back(1);
  for (int i = 2; i <= n; i++) {
    if(is_p[i] == 1)continue;
    is_p[i] = 1;
    p.push_back(i);
    for (int j = 2*i; j <= n; j += i) {
      is_p[j] = 1;
    }
  }
}
  
int main(int argc, char *argv[]){
  int n;
  while(cin >> n, n){
    memset(is_p, 0, sizeof(is_p));
    vector<int> p;
    erast(n, p);
    for (int i = p.size() - 1; i > 0; i--) {
      if(p[i] - p[i - 1] == 2){
        std::cout << p[i - 1] << " " << p[i] << std::endl;
        break;
      }
    }
  }
  return 0;
}

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