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

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

bool is[10010];

int main(){
  int n;

  rep(i,10010){
    is[i] = true;
  }
  is[1] = is[0] = false;
  for(int i = 2; i < 10010; i++){
    for(int j = 2; i*j < 10010; j++){
      if(is[i] == true){
	is[i*j] = false;
      }
    }
  }

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



  return 0;
}

C++: #include<stdio.h>

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

C++: #include<iostream>

using namespace std;

const int MAX=10000;
bool prime[MAX];
void make_prime(){
	for(int i = 0 ; i < MAX ; i ++){
		prime[i] = true;
	}
	
	prime[0] = false;
	prime[1] = false;
	
	for(int i = 2 ; i <= MAX ; i ++){
		if(prime[i]){
			for(int j = i+i ; j <= MAX ; j += i){
				prime[j] = false;
			}
		}
	}
}

int main(void){
	make_prime();
	int n;
	while(cin>>n,n){
		for(int i = n ; 2 <= i ; i --){
			if(prime[i] && prime[i-2]){
				cout<<i-2<<" "<<i<<endl;
				break;
			}
		}
	}
}

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


#define MAX_N 10000
int prime[MAX_N];
bool is_prime[MAX_N+1];
int sieve(int n){
	int p=0;
	memset(is_prime,true,sizeof(is_prime));
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
		}
	}
	return p;
}

int main(){
	sieve(MAX_N);
	vector<int> p;
	for(int i=2;i<=MAX_N-2;i++)
		if(is_prime[i]&&is_prime[i+2])p.push_back(i+2);
	int n;
	while(cin>>n&&n){
		int a=upper_bound(p.begin(),p.end(),n)-p.begin();
		cout<<p[a-1]-2<<' '<<p[a-1]<<endl;
	}
	return 0;
}

C++: #include <stdio.h>

#define MYSCAN scanf

int main(void){
	int n, p;
	int flag;
	int i, j;
	int tmp;

	while (1){
		MYSCAN("%d", &n);
		if (n == 0){ break; }

		p = 0;
		if (n % 2 == 0){ n--; }
		for (i = n; i > 2; i -= 2){
			flag = 1;
			tmp = i / 2;
			// iテ」ツ?古ァツエツ?ヲツ閉ーテ」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツδ?」ツつァテ」ツδε」ツつッ
			for (j = 3; j < tmp; j += 2){
				if (i % j == 0){
					flag = 0;
					break;
				}
			}

			// iテ」ツ?古ァツエツ?ヲツ閉ーテ」ツ??」ツ?」テ」ツ?淌」ツつ?
			if (flag == 1){
				// テ・ツ??」ツつ暗」ツつ?テ」ツ?、テ・ツケツエテ、ツクツ凝」ツ??」ツ?」テ」ツ?淌」ツつ嘉・ツ?コテ・ツ環?
				if (i == p - 2){
					printf("%d %d\n", i, p);
					break;
				}
				// テ」ツ?敕」ツ??」ツ?佚」ツつε」ツ?ェテ」ツ?凝」ツ?」テ」ツ?淌」ツつ嘉ィツ?ェテ・ツ按?」ツ?古・ツ??」ツ?ォテ」ツ?ェテ」ツつ?
				p = i;
			}
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int prime[10000000];
bool isprime[10000001];

int sieve(int n){
	int p=0;
	for(int i=0;i<=n;i++)isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(int i=0;i<=n;i++){
		if(isprime[i]){
			prime[p++]=i;
			for(int j=i*2;j<=n;j+=i)isprime[j]=false;
		}
	}
	return p;
}

int main(){
	sieve(1e+4);
	int n;
	while(cin>>n){
		if(!n)return 0;
		do{
			if(isprime[n]&&isprime[n-2]){
				cout<<n-2<<" "<<n<<endl;
				break;
			}
		}while(n--);
	}
}

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

const int MAX_N = 10000;
bool is_prime[MAX_N + 1];

bool 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;
    is_prime[1] = true;
    is_prime[2] = true;

    for(int i = 3; i <= MAX_N; i++)
        is_prime[i] = sieve(i);

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

C++: #include <stdio.h>
const int MAX_V = 1000000; // 100????????§??´???°??¨?????????
int number[MAX_V+1];
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,min,max;
	for(i = 0;i < MAX_V;i++){
		number[i] = isprime(i);
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = n;i > 0;i--){
			//printf("%d  ",i);
			if(number[i] && number[i-2]){
				min = i-2;
				max = i;
				//printf("%d %d\n",i,i-2);
				break;
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

C++: #include <stdio.h>

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

int main() {
	int n,i;
	int sousi[2];
	int prime[10100][2];
	for (i = 0; i < 10100; i++) {
		prime[i][0] = i;
		prime[i][1] = isprime(i);
	}
	while(1) {
		sousi[0] = 0;
		sousi[1] = 0;	 
		scanf("%d",&n);
		if(n == 0) {
			break;
		}
		for(i = n; i > 2; i--) {
			if(prime[i][1] == 1 && prime[i - 2][1] == 1) {
				sousi[0] = prime[i - 2][0];
				sousi[1] = prime[i][0];
				break;
			}
		}
		printf("%d %d\n",sousi[0],sousi[1]);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,m,most1,most2,d[11000]={0};
  while(1){
    cin >> n;
    if(n==0){
      break;
    }

    most1=0;most2=0;
    for(int i=0;i<10100;i++){
      d[i]=0;
    }

    for(int i=2;i*i<=n;i++){
      if(d[i]==0){
	for(int j=i+i;j<=n;j+=i){
	  d[j]=1;
	}
      }
    }
    
    for(int i=n;i>=0;i--){
      if(d[i]==0 && d[i-2]==0){
	most1=i-2;
	most2=i;
	break;
      }
    }

    cout << most1 << " " << most2 << endl;
  }
}

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