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 "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) != EOF) {
        //        int isprime = prime[v];
        //        if(isprime) printf("%d is a prime number\n", v);
        //        else printf("%d is not a prime number\n", v);
        int p1 = 3;
        int q1 = 5;
        for(i = n;0 <= i;i--){
            if(prime[i] == 1 && prime[i-2] == 1){  //??????????´???°
                if (q1 <= i) {
                    q1 = i;
                    p1 = i-2;
                }
            }
        }
        printf("%d %d\n",p1,q1);
        return 0;
    }
}
//????¨??????¨????????????????????????

C++: #include <iostream>
#include <vector>
#include <algorithm>
std::vector<int> twin_primes(int upper) {
	std::vector<bool> suspects(upper + 1, true);
	suspects[0] = suspects[1] = false;
	std::vector<int> res;
	for (auto i = 2; i <= upper; ++i) {
		if (suspects[i]) {
			if (suspects[i - 2])
				res.push_back(i);
			for (auto j = 2 * i; j <= upper; j += i)
				suspects[j] = false;
		}
	}
	return res;
}
int main() {
	int n;
	std::cin >> n;
	auto primes = twin_primes(10000);
	while (n != 0) {
		auto prime = *(std::upper_bound(primes.begin(), primes.end(), n) - 1);
		std::cout << prime - 2 << ' ' << prime << std::endl;
		std::cin >> n;
	}
}

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

int main(){

	const int x=10001;
	int p[x];
	int i,k,j,n;

	for(i=2; i<x; i++){
		p[i]=1;
	}
	p[0]=p[1]=0;
	for(i=2; i*i<=x; i++){
		if(p[i]){
			for(j=i*2; j<x; j+=i){
				p[j]=0;
			}
		}
	}

	while(1){

		cin >> n;
		if(!n){
			break;
		}

		for(k=n; k>0; k--){
			if(p[k] && p[k-2]){
				cout << k-2 << " " << k << endl;
				break;
			}
		}
	}

}

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

int dummy_prime(int n,int i){return i>1 ? n%i ? dummy_prime(n,i-1) : 0 : 1;}
int isprime(int n){return n>1 ? dummy_prime(n,(int)sqrt(n)) : 0;} 

int main(){
	int n;
	while(cin >> n && n){
		while(n>4){
			if(isprime(n) && isprime(n-2)){
				cout << n-2 << " " << n << endl;
				break;
			}
			n--;
		}
	}
}

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

using namespace std;

vector<int> primes;
void gen(int N){
    N = N + 1;
    bool find[N];
    for(int i=0;i<N;i++){
        find[i] = false;
    }
    for(int i=2;i*i<=N;i++){
        if(find[i]) continue;
        for(int j=i+1;j<N;j++){
            if(find[j])continue;
            if(j%i==0)find[j]=true;
        }
    }
    for(int i=2;i<N;i++){
        if(!find[i])primes.push_back(i);
    }
}

void solve(int n){
    int p,q;
    for(int i=1;;i++){
        if(primes[i] > n) break;
        if(primes[i] - primes[i-1] == 2){
            p = primes[i];q=primes[i-1];
        }
    }
    cout << q << " " << p << endl;
}

int main(){
    gen(10000);
    while(true){
        int n;
        cin >> n;
        if(n==0)break;
        solve(n);
    }
    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;
	}
	while(1) {
		sousi[0] = 0;
		sousi[1] = 0;	 
		scanf("%d",&n);
		for (i = 0; i < n; i++) {
			prime[i][1] = 0;
		}
		if(n == 0) {
			break;
		}
		for(i = 0; i <= n; i++) {
			prime[i][1] = isprime(prime[i][0]);
		}
		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 <stdio.h>
#include <math.h>
#include <string>
const int MAX_V = 1000;
int prime[MAX_V+1];

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

C++: #include "stdio.h"
//#include "time.h"
//?????§??????????´???°?????????????????????
// 5<= n <= 10000
//p1=?°????????´???°p2=??§???????´???°

int isprime(int n) {
    int i;
    for(i = 2; i < n; i++) {   //??????????§????????????¨??§??¶??°??§??????????´???°??¨??????
        if(n % i == 0)return 0;    //????????????????????§?´???°??§?????????
    }
    return 1;
}
int main(){
    int i,n,p1,q1;
   //     clock_t start, now;//??£?¨?
    while(1){
        scanf("%d",&n);
     //   start = clock(); // ????§???????
        if(n == 0)break;
        for(i = n;3 <= i;i--){
            if (isprime(i) == 1 && isprime(i - 2) == 1) break;
        }
        p1 = i-2;
        q1 = i;
       // now = clock(); // ????????????
       // printf("%f\n", (double)(now - start) / CLOCKS_PER_SEC);//??¬???
        printf("%d %d\n",p1,q1);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(){
	bool prime[10001];
	int n;
	rep(i,10001)prime[i]=true;;
	prime[0]=prime[1]=false;
	for(int i=2;i<=10000;i++)if(prime[i])for(int j=2*i;j<=10000;j+=i)prime[j]=false;
	while(cin>>n){
		for(int i=n;i>=2;i--){
			if(prime[i]&&prime[i-2]){
				cout<<i-2<<" "<<i<<endl;
				break;
			}
		}
	}
}

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

int table[10010] = {} ;

void f(){
	table[0] = 1 ;
	table[1] = 1 ;
	for( int i=2 ; i<=10000 ; i++ ){
		if( !table[i] ){
			for( int j=2 ; i*j<=10000 ; j++ ) table[i*j] = 1 ;
		}
	}
}

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

C++: #include<stdio.h>
int main(void)
{
    int a,i,flg1,p,q,l,b,a2,b2,n[10000],m[10000],k=0;
	scanf("%d",&a);
	while(a!=0){
	    flg1=1;
		p=0;
		q=0;
		a2=0;
		b2=0;
	    for(i=2;i<=a;i++){
		    for(l=2;l<i-2;l++){
			    b=i%l;
				if(b==0) {
				    flg1=0;
					break;
				}
			}
			if(flg1==1) {
				if(p==0){
				    q=i;
				}
				else if(p!=0){
				    q=i;
				}
				if(q-2==p){
				    a2=p;
					b2=q;
				}
				else{
				    p=q;
				}
			}
			flg1=1;
			if(a==5||a==6) a2=3,b2=5;
		}
		n[k]=a2,m[k]=b2;
		k++;
		scanf("%d",&a);
	}
	for(i=0;i<k;i++) printf("%d %d\n",n[i],m[i]);
	return 0;
}