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

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

int main(){
	int n,i,min,max;
	int number[10000+2] = {0};
	for(i = 2;i < 10000;i++){
		number[i] = isprime(i);
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = n;i > 0;i--){
			//printf("%d  ",i);
			if(number[i] && number[i-2]){
				min = i-2;
				max = i;
				//printf("%d %d\n",i,i-2);
				break;
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

C++: #include <stdio.h>

int main(){
	int i,n,k,data[10000];
	for(i=2;i<10000;i++){
		data[i]=1;
	}
	for(i=2;i*i<10000;i++){
		if(data[i]==1){
			for(k=i*i;k<=10000;k+=i){
				data[k]=0;
			}
		}
	}
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=n;n>=3;i--){
			if(data[i]==1&&data[i-2]==1){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	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 i, k, v,an1,an2,suu;
    int MAX_V = 10000;
    int prime[MAX_V+1];
    for(i = 0; 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",&suu);
        if(suu != 0){
            for(k=2;k<=suu;k++){
            	if(prime[k-2]==1 && prime[k]==1){
        	    	an1=k-2;
        	    	an2=k;
            	}
            }
            printf("%d %d\n",an1,an2);
        }
        else{
    	    break;
        }
    }
    return 0; 
}

C++: #include <bits/stdc++.h>

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

const int MAX_N = 10000;

int main()
{
    bool sieve[MAX_N + 1];
    rep(i, MAX_N + 1) sieve[i] = true;
    for (int i = 2; i * i <= MAX_N; i++){
        for (int j = i * i; j <= MAX_N; j += i){
            sieve[j] = false;
        }
    }

    int n;
    while (n = in()){
        while (!(sieve[n] && sieve[n - 2])) n--;
        printf("%d %d\n", n - 2, n);
    }
    return (0);
}