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>
#include <math.h>
#include <string>
const int MAX_V = 100;
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 <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int prime[10000];
bool is_p[100000];

int n;

int main(){
	for (int i = 0; i <= 10000; i++) is_p[i] = 1;
	is_p[0] = is_p[1] = 0;
	/*int p = 0;*/
	for (int i = 2; i <= 10000; i++){
		if (is_p[i]){
			//prime[p++] = i;
			for (int j = i * 2; j <= 10000; j += i)is_p[j] = 0;
		}
	}
	while (cin >> n&&n){
		int p = -1, q = -1;
		for (int i = n; i > 0; i--){
			if (is_p[i] == 1){
				if (p == -1){
					p = i;
					continue;
				}
				if (q == -1){
					q = i;
					if (p - q == 2){
						cout << q << " " << p << endl;
						break;
					}
					else{
						p = q;
						q = -1;
					}
				}
			}
		}
	}
}

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

C++: #include<stdio.h>
const int MAX_V = 10000;
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;
      }
    }
  }

  while(scanf("%d", &v) != EOF) {
    if(v == 0){
      break;
    }
    while(1){
      if(prime[v] == 0 || prime[v - 2] == 0){
        v--;
      }else{
        printf("%d %d\n", v - 2, v);
        break;
      }
    }
  }
  return 0;
}

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


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

const int Max = 10001;
bool isPrime[Max];
pair<int, int> twinPrimes[Max];
int main()
{
	fill(isPrime, isPrime+Max, true);
	int prev = -100;
	pair<int, int> twin;
	for (int i = 2; i < Max; ++i)
	{
		if (isPrime[i])
		{
			for (int j = 2*i; j < Max; j += i)
				isPrime[j] = false;
			if (i - prev == 2)
				twin = make_pair(prev, i);
			prev = i;
		}
		twinPrimes[i] = twin;
	}

	int n;
	while (scanf("%d", &n), n)
		printf("%d %d\n", twinPrimes[n].first, twinPrimes[n].second);

	return 0;
}

C++: #include <iostream>
using namespace std;
#define MAX (10001)

bool prime[MAX];

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

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

C++: #include<stdio.h>
#include<math.h>

int	Prime(int	x){
	int	n;
	if(x	==	2)return	1;
	if(x	%	2	==	0)return	0;
	for(n	=	3;	n	<=	sqrt((double)x);	n	+=	2){
		if(x	%	n	==	0)return	0;
		return	1;
	}
}

int	main(){
	int	n,	i,	cnt	=	1,	max	=	0,	data[100];
	scanf("%d",	&n);
	for(i	=	2;	i	<=	n;	i++){
		if(Prime(i)){
			data[cnt]	=	i;
			if(data[cnt]	-	data[cnt	-	1]	==	2)max	=	cnt;
			cnt++;
		}	
	}
	printf("%d %d\n",	data[max - 1],	data[max]);
	return	0;
}

C++: #include "bits/stdc++.h"

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool isPrime(int n){
    if(n==1)return false;
    if(n==2)return true;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}


int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        
        for(int i=n;i>=5;i--){
            if(isPrime(i) && isPrime(i-2)){
                cout<<i-2<<" "<<i<<endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include<iostream>
#include<fstream>
#include<vector>
#define N 10000

int gcd(int q1,int p1){
    if(q1%p1==0) return p1;
    return gcd(p1,q1%p1);
}

int sosu(int j){
    if(j<2)return 0;
    if(j==2)return 1;
    if(j%2==0)return 0;
    for(int i=3; i<=j/2; i++){
        if(j%i==0)return 0;
    }
    return 1;
}

int main(){
    std::vector<int> n;
    n.resize(N);
    for(int i=0; i<N; i++){
        std::cin >> n[i];
        if(n[i]==0)break;
    }
    for(int i=0; i<N; i++){
        if(n[i]==0)break;
        for(int j=n[i]; j>5; j--){
            if(sosu(j)&&sosu(j-2))
                if(gcd(j,j-2)==1){
                    std::cout << j-2 << " " << j <<std::endl;
                    break;
                }
            }
        }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long n,i,j,p[10001];
while(cin>>n){
if(n==0)break;
p[1]=0;
for(i=2;i<=n;i++)p[i]=1;
for(j=4;j<n;j+=2)p[j]=0;
for(i=3;i<=n;i+=2){
if(p[i]==1){
for(j=i*i;j<=n;j+=i)p[j]=0;
}
}
for(i=n;i>=4;i--)if(p[i]==1&&p[i-2]==1)break;
cout<<i-2<<" "<<i<<endl;
}
return 0;
}