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 <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator+(Point p){return Point(x + p.x, y + p.y);}
    Point operator-(Point p){return Point(x - p.x, y - p.y);}
    Point operator*(double a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}


int sosu[10005];
int ans[10005];

void make(){
    memset(sosu, -1, sizeof(sosu));
    sosu[0] = 0;
    sosu[1] = 0;
    for (int i = 2; i < 10005; i++){
        if (!~sosu[i]){
            sosu[i] = 1;
            for (int j = 2; j*i < 10005; j++){
                sosu[j*i] = 0;
            }
        }
    }
}

vector<int> Q;

int main(void){
    make();
    for (int i = 4; i < 10005; i++){
        if (sosu[i] & sosu[i-2]) ans[i] = i;
        else ans[i] = ans[i-1];
    }
    while(1){
        int N;
        cin >> N;
        if (!N) break;
        Q.push_back(N);
    }
    for (auto itr = Q.begin(); itr != Q.end(); itr++){
        cout << ans[*itr]-2 << " " << ans[*itr] << endl;
    }
    


    return 0;
}

C++: #include <iostream>

using namespace std;

int prime(int n, int k = 2)
{
    if(n < k * k) { return 1; }
    
    if(n % k == 0) { return 0; }
    
    return prime(n, k + 1);
}

int solve(int n)
{
    for(int i = n; i >= 3; i--)
    {
        if(prime(i) * prime(i - 2))
        {
            return i;
        }
    }
    
    return -1;
}

int main()
{
    int n;
    
    while(true)
    {
        cin >> n;
        
        if(n == 0) { break; }
        
        cout << solve(n) << endl;
    }
    
    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,p1,q1,i1 = 0,i2 = 0,max = 0,k;
  while(1){
    scanf("%d",&n);
    if(n == 0){
      break;
    }
    for(k = 0;k + 2 < n;k++){
      i1 = isprime(k);
      i2 = isprime(k + 2);
      if(i1 == 1 && i2 == 1){
        max = k;
      }
    }
    p1 = max;
    q1 = max + 2;
    printf("%d %d\n",p1,q1);
  }
  return 0;
}

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

using namespace std;

int main(){
  int i, j, n, isFound, large, small;
  vector<int> data;

  data.push_back(2);
  data.push_back(3);
  for(i=5; i<=N; i+=2){
    for(j=1, isFound=0; data[j]<=sqrt(i); ++j){
      if(i%data[j] == 0){
	isFound = 1;
	break;
      }
    }
    if(isFound == 0) data.push_back(i);
  }

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<data.size(); ++i){
      if(n < data[i]) break;
    }
    for(j=i-1; j>0; --j){
      if(data[j] == data[j-1]+2) break;
    }

    cout << data[j-1] << " " << data[j] << endl;
  }

  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main() {

	vector<int> prime;
	vector<bool> used(10001, false);
	used[0] = used[1] = true;
	for (int i = 2; i * i <= 10000; i++) {
		if (!used[i]) prime.push_back(i);
		used[i] = true;
		for (int j = i * 2; j <= 10000; j += i) {
			used[j] = true;
		}
	}
	REP(i, 10000 + 1) if (!used[i]) {
		prime.push_back(i);
		used[i] = true;
	}
	
	vector<int> ans;
	FOR(i, 1, prime.size()) {
		if (prime[i] == prime[i - 1] + 2) ans.push_back(prime[i]);
	}
	sort(ans.begin(), ans.end());
	
	int n;
	while (cin >> n, n) {
		int b = *(upper_bound(ans.begin(), ans.end(), n) - 1);
		int a = b - 2;
		cout << a << " " << b << endl;
	}
	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;
	while(1){
		scanf("%d", &n);
		if( n == 0) break;
		int max = 0;
		for( i = n; i >=2; i--){
			if( isprime(i)){
				if(isprime( i - 2)){
					max = i;
					break;
				}
			}
		}
		printf("%d %d\n", max - 2, max);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
bool t[10000] = {false};
int main()
{
	int n, c, i, j, d;
	t[0] = true;
	for (i = 2; i * i <= 10000; i++)
	{
		if (!t[i-1])
		{
			for (j = i+i; j <= 10000; j+=i)
				t[j-1] = true;
		}
	}
	while (cin >> n, n)
	{
		for (i = n; i >= 5; i--)
		{
			if ((!t[i-1]) && (!t[i-3]))
			{
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
}

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

int prime[MAX]={0};
void is_prime(){
    prime[0] = prime[1] = 1;
    
    for(int i = 2 ; i*i < MAX ; i++)
        if(!prime[i])
            for(int j = i*2 ; j < MAX ; j += i)
                prime[j] = 1;
}

int main(){
    int n;
    
    is_prime();
    
    while(cin >> n,n){
        int a,b;
        
        for(int i = 0 ; i <= n ; i++){
            if(i >= 2 && !prime[i] && !prime[i-2]){
                a = i-2;
                b = i;
            }
        }
        
        cout << a << ' ' << b << endl;
    }
    
    return 0;
}