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.h"
//#include "time.h"
//?????§??????????´???°?????????????????????
// 5<= n <= 10000
//p1=?°????????´???°p2=??§???????´???°

void isprime(int n) {
    scanf("%d",&n);
    for(int 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;0 <= i;i--){
            if (isprime(i) == 1 && isprime(i-2)) 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<algorithm>
#include<numeric>
#include<iterator>
#include<vector>

using namespace std;
typedef unsigned int val;

struct pred{
	bool operator()(int m, int n) { return m - n == 2; }
};

int main() {
	int n;
	while(cin>>n && n)
	{
		vector<int>so(10000);
		so.clear();
		bool flag[10010];
		flag[0]=flag[1]=false;
		for(int i=2; i<n; i++)
		{
			if( flag[i] )
			{
				so.push_back(i);
				for(int j=i*2; j<n; j+=i) flag[j]=false;
			}
		}
		vector<int>::reverse_iterator ite = adjacent_find(so.rbegin(), so.rend(), pred());
		cout<< *(ite+1) << " "<< *ite << endl;

	}
	return 0;
}

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

bool isP(int x){
  if(x==0||x==1)return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0)return false;
  }
  return true;
}

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

C++: #include <stdio.h>

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

C++: #include <stdio.h>
#include <math.h>
#include <string>
const int MAX_V = 10000;
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;
	isprime();
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		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>
	   const int MAX_V = 1000000;
	   int prime[MAX_V+1];
	   int main(){
	   	int i,k,v,m=2;
	   	for(i=m;i<=MAX_V;i++){
	   		prime[i]=1;
	   	}
	   	for(i=m;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(i=v;i>=m;i--){
	   			if(prime[i]==1 && prime[i-2]==1){
	   				printf("%d %d\n",i-2,i);
	   				break;
	   			}
	  	   	}
	  	}
	   	return 0;
	  }

C++: #include<stdio.h>
const int MAX_V=10000;
int prime[MAX_V+1];
int main(){
  int i,k,n,p,q,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(1){
    scanf("%d",&n);
    if(n==0)break;
    for(v=2;v<=n-2;v++){
      int isprime=prime[v]*prime[v+2];
      if(isprime)p=v,q=v+2;
    }
    printf("%d %d\n",p,q);
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n;
int memo[10001];
bool isPrime(int x) {
  if(memo[x]>=0) return memo[x];
  for(int i=2; i*i<=n; i++) {
    if(x % i == 0) return memo[x] = 0;
  }
  return memo[x] = 1;
}

int main() {
  fill(memo, memo+10000, -1);
  while(cin >> n && n) {
    int mx = 5;
    for(int i=2; i<=n-2 ; i++) {
      if((isPrime(i)&isPrime(i+2)) == 1) {
	mx = i;
      }
    }
    cout << mx << ' ' << mx+2 << endl;
  }
  
  return 0;
}

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

#define PMAX 10000

int main() {
  bool p[PMAX+1];
  int n, t;
  vector<int> twin;
  vector<int>::iterator it;
  for (int i=0; i<=PMAX; i++) p[i] = true;
  for (int i=2; i*i<=PMAX; i++) {
    for (int j=2*i; j<=PMAX; j+=i) {
      p[j] = false;
    }
  }
  for (int i=2; i<=PMAX; i++) {
    if (p[i] && p[i+2]) {
      twin.push_back(i+2);
    }
  }

  while (1) {
    cin >> n;
    if (!n) break;
    it = upper_bound(twin.begin(), twin.end(), n);
    --it;
    cout << (*it)-2 << " " << *it << endl;
  }

  return 0;
}

C++: #include "stdio.h"
const int MAX_V = 10000; // 1????????§????´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°,0????´???°??§?????????
int main() {
    int i, k, n,p1,q1;
    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 (1) {
    scanf("%d",&n);
    if (n == 0)break;
//    while(scanf("%d", &n) != 0) {
        //        int isprime = prime[v];
        //        if(isprime) printf("%d is a prime number\n", v);
        //        else printf("%d is not a prime number\n", v);
        
        for(i = n;0 <= i;i--){
            p1 = 0;
            q1 = 0;
            if(prime[i] == 1 && prime[i-2] == 1){  //??????????´???°
                    q1 = i;
                    p1 = i-2;

            }
        }
        printf("%d %d\n",p1,q1);
        p1 = q1 = 0;
    }
    return 0;
}
//????¨??????¨????????????????????????

C++: #include <stdio.h>
int main(){
	int i,j,a,b,n,p1,q1;
	int isprime[1000];
	for(i=0;i<=1000;i++){
 		isprime[i]=1;
	}
	isprime[0]=isprime[1]=0;
	for(i=2;i<=1000;i++){
 		if(isprime[i]==1){
 			for(j=2*i;j<=1000;j+=i){
				isprime[j]=0;
			}
		}
	}



	scanf("%d", &n);
	while (n != 0){
		for(i=2;i<=n;i++){
			a = isprime[i-2];
			b = isprime[i];
			if(a==1 && b==1){
				p1 = i-2;
				q1 = i;
			}
		}
		printf("%d %d\n",p1,q1);
		scanf("%d", &n);
	}
	return 0;
 }