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 <math.h>
using namespace std;
bool check(int x,int y){
        for(int i=2 ; i<=sqrt(x) ; i++ ){
                if(x%i==0)
                        return false;
                if(y%i==0)
                        return false;
        }
        return true;
}
int main(){
        int n;
        while(true){
                cin >> n;
                if(n==0)break;
                if(n<=6)
                        cout<<5<<" "<<3<<endl;
                int de=(n/6);
                for(int x=6*de ; x>0 ; x=de*6 ){
                        if(check(x+1,x-1) && x<n ){
                                cout << x-1 <<" " << x+1 << endl;
                                break;
                        }
                        de--;
                }
        }
        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 k,n;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(k=n-2;k>=2;k--){
      if(isprime(k)&&isprime(k+2)){
        printf("%d %d\n",k,k+2);
      }
    }
  }
  return 0;
}

C++: #include <iostream>
int i,j,n,P[10001];int main(){for(i=2;i*i<10001;i++)for(j=i*2;j<10001;j+=i)P[j]=1;for(;std::cin>>n,n;printf("%d %d\n",i-2,i))for(i=n&1?n:n-1;i>4&&(P[i]||P[i-2]);i-=2);return 0;}

C++: #include<stdio.h>
const int MAX_X = 10000;
int prime[10000];

int main(){

	int i, k, n;

	int border[10];
	for( i = 2; i <= MAX_X; i++) {
		prime[i] = 1;
	}

	for(i = 2; i*i <= MAX_X; i++){
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_X; k += i){
				prime[k] = 0;
			}
		}
	}

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

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vector<bool>IsPrime(MAX+1,true);
    vector<int>Prime(MAX+1,0); //Primearray
    int Primecounter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(IsPrime[i]){
            for(int j = 2;i*j<MAX;j++)
                IsPrime[i*j] = false;//?´???°??????Primearray???????´??????????????????°?????¨???false???
            Prime[Primecounter] = i;
            Primecounter++;
        }
    }
    int n;
    while(cin>>n,n){
        int maxi=0;
        for(int i=n; i>=2; i--){
            if(IsPrime[i]&&IsPrime[i-2]){
                cmax(maxi,i);
                break;
            }
        }
        cout<<maxi-2<<" "<<maxi<<endl;
    }
}

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<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n,max,mx;
	int flg[10001];
	while(1) {
		scanf("%d",&n);
		if(n==0) break;
		for(i=2;i<=n;i++) flg[i]=1;
		for(i=2;i*i<=n;i++) {
			if(flg[i]==1) for(j=2;j*i<n;j++) flg[i*j]=0;
		}
		max=-1;
		for(i=2;i<n;i++) {
			if(flg[i]==1 && flg[i]==flg[i+2] && i+2<=n) {
				if(max<i) max=i;
			}
		}
		printf("%d %d\n",max,max+2);
	}
	return 0;
}

C++: #include<stdio.h>

int main() {
  int MAX_V = 1000000;
  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) {
  int s = 0;
  for(int i = 5;i <= v;i++){
    int isprime = prime[i];
    if(isprime){
      s++;
    }
  }
  int side[s],d = 0;
  for(int i = 5;i <= v;i++){
    int isprime = prime[i];
      if(isprime) {
        side[d] = i;
        d++;
      }
    }
  int m = d-1;
  int dai = 0,syo = 0;
  for(int n = m;n >= 0;n--){
    if(side[n] - side[n-1] == 2){
      if(syo < side[n-1]){
        syo = side[n-1];
        dai = side[n];
      }
    }
  }
  printf("%d %d\n",syo,dai);
}
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[10005];
    memset(prime,0,sizeof(prime));
    for(int i=2;i<sqrt(10005);i++){
        if(!prime[i])for(int j=i*2;j<10005;j+=i)prime[j]=1;
    }
    int num[210],co=0;
    for(int i=3;i<10001;i++){
        if(!prime[i]&&!prime[i+2]){
            num[co]=i;
            co++;
        }
    }
    int n;
    while(cin>>n,n){
        if(num[co-1]<n)cout<<num[co-1]<<" "<<num[co-1]+2<<endl;
        else{
            for(int i=0;i<co;i++){
                if(num[i]>=n&&num[i-1]+2<=n){
                    cout<<num[i-1]<<" "<<num[i-1]+2<<endl;
                    break;
                }
                else if(num[i]>n){
                    cout<<num[i-2]<<" "<<num[i-2]+2<<endl;
                    break;
                }
            }
        }
    }
}

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 k,n,p,q;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(k=2;k<=n-2;k++){
      if(isprime(k)*isprime(k+2)){
        p=k;
        q=k+2;
      }
    }
    printf("%d %d\n",p,q);
  }
  return 0;
}