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 <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

bool prime[10100];
int a[10100];
int main(){
	rep(i,10100){
		prime[i]=true;
	}
	prime[0]=prime[1]=false;
	for(int i=2;i*i<10100;i++){
		if(prime[i]){
			for(int j=i*i;j<10100;j+=i){
				prime[j]=false;
			}
		}
	}
	int M=5;
	reep(i,5,10100){
		if(prime[i]&&prime[i-2]){
			M=i;
		}
		a[i]=M;
	}
	int n;
	while(cin>>n,n){
		cout<<a[n]-2<<" "<<a[n]<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 10000;

int main(void){
    bool isP[N + 1];
    MEMSET(isP, true);
    rep(i, 2) isP[i] = false;
    COUNT(i, N) if(isP[i]) for(int j = i; i * j <= N; j ++) isP[i * j] = false;

    vi res(N + 1);
    COUNT(i, N - 2) if(isP[i] & isP[i + 2]) fill(res.begin() + i + 2, res.end(), i + 2);
    
    for(int n; cin >> n, n; cout << res[n] - 2 << ' ' << res[n] << endl);
 
    return 0;
}

C++: #include<stdio.h>
const int size=10000;
int main(){
  int i,k,n;
  int data[size];
  for(i=2;i<size;i++){
    data[i]=1;
  }
  for(i=2;i<size;i++){
    if(data[i]){
      for(k=2*i;k<=size;k+=i){
        data[k]=0;
      }
    }
  }
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=n;i>=0;i--){
      if(data[i]==1 && data[i-2]==1){
        break;
      }
    }
    printf("%d %d\n",i-2,i);
  }
  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=suu;k>0;k--){
            if(isprime(k-2)==1 && isprime(k)==1){
                an1=k-2;
                an2=k;
                break;
            }
        }
        printf("%d %d\n",an1,an2);
    }
}

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);
    }
}

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

int main()
{
	int n;

	while (cin >> n, n){
		vector<bool> num(n + 1, true);
		
		for (int i = 2; i <= n; i++){
			if (num[i]){
				for (int j = i; j * i <= n; j++){
					num[j * i] = false;
				}
			}
		}
		bool check = false;
		for (int i = n; i >= 5; i--){
			if (num[i]){
				for (int j = i - 1; j >= 5; j--){
					if (num[j]){
						if (i - j == 2){
							cout << j << " " << i << endl;
							check = true;
						}
					}
				}
			}
			if (check){
				break;
			}
		}
		num.clear();
	}
	
	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 n, i, p1, q1, result, resultt;
  for( ;; ) {
    scanf( "%d", &n );
    if( n == 0 )break;
    for( i = 2; i <= n; i++ ) {
      result = isprime( i );
      resultt = isprime( i - 2 );
      if( result == 1 && resultt == 1 ) {
        q1 = i;
        p1 = q1 - 2;
      }
    }
    printf( "%d %d\n", p1, q1 );
  }
  return 0;
}

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

const int MAX_N = 10010;

bool isPrime[MAX_N];
vector<int> prime;
void eratosthenes(int n){
    for(int i=0; i<=n; i++) isPrime[i] = true;
    isPrime[0] = false, isPrime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(isPrime[i]){
            for(int j=2; i*j<=n; j++){
                isPrime[i*j] = false;
            }
        }
    }

    for(int i=0; i<MAX_N; i++){
        if(isPrime[i]){
            prime.emplace_back(i);
        }
    }
}

int main(){
    eratosthenes(10005);

    vector<int> twinLarge;
    for(int i=0; i<prime.size()-1; i++){
        if(prime[i] + 2 == prime[i+1]){
            twinLarge.emplace_back(prime[i+1]);
        }
    }

    int cnt = 0;
    int m = twinLarge.size();
    vector<int> ans(10010, -1);
    for(int i=5; i<=10000; i++){
        if(twinLarge[min(cnt+1, m-1)] == i){
            cnt++;
        }

        ans[i] = twinLarge[min(cnt, m-1)];
    }

    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        cout << ans[n] - 2 << " " << ans[n] << endl;
    }
}

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

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