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 <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(10000, prime);

    vector<int> ret(10001);
    for(int i=5; i<=10000; ++i){
        if(prime[i] && prime[i-2])
            ret[i] = i;
        else
            ret[i] = ret[i-1];
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        cout << (ret[n]-2) << ' ' << ret[n] << endl;
    }
}

C++: #include <stdio.h>
#include <time.h>
int isprime(int n){
	for(int i = 2; i < n; i++){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}
int main() {
	int i,p,q,n;
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		for(i=n;i>=0;i--){
			if(isprime(i) == 1 && isprime(i-2) == 1){
				p = i;
				q = i-2;
				break;
			}
		}
		printf("%d %d\n",q,p);
	}
	return 0;
}


	// clock_t start, now;
	// now = clock();
	// printf("%f\n",(double)(now - start) / CLOCKS_PER_SEC);

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[10000];
	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++: int i,j,k;char s[9];p(int n){if(n<2)return 0;else if(n==2)return 1;if(n%2==0)return 0;for(i=3;i*i<=n;i+=2)if(n%i==0)return 0;return 1;}main(){while(scanf("%d",&j)){if(!j)break;while(k++<j){if(p(k-1)&&p(k-3)){sprintf(s,"%d %d",k-3,k-1);}}puts(s);}}

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

bool p[1000100];

void erato(){
    fill(p, p+1000100, true);
    p[0] = p[1] = false;

    for(int i=0; i < 1000100; i++){
        if(!p[i]) continue;
        for(int j=i+i; j < 1000100; j += i){
            p[j] = false;
        }
    }
}

int main(){
    erato();
    int n;
    while(cin >> n, n){
        for(int i=n; ; i--)if(p[i] && p[i-2]){cout << i-2 << " " << i << endl;break;}
    }
}

C++: int main(void){
	int i,j;
	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;
			}
		}
	}
	for(i=2;i<=1000;i++){
		if(isprime[i-2]==1 && isprime[i]==1){
			printf("(%d,%d)",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, p1, q1, result, resultt;
  for( ;; ) {
    scanf( "%d", &n );
    if( n == 0 )break;
    for( i = n; i >= 0; i-- ) {
      result = isprime( i );
      resultt = isprime( i - 2 );
      if( result == 1 && resultt == 1 ) {
        q1 = i;
        p1 = q1 - 2;
        break;
      }
    }
    printf( "%d %d\n", p1, q1 );
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int N = 10005;
signed main() {
	vector<bool>p(N, true);
	p[0] = p[1] = false;
	rep(i, 2, sqrt(N)) {
		if (p[i]) {
			for (int j = i + i; j < N; j += i) {
				p[j] = false;
			}
		}
	}
	int n;
	while (cin >> n, n) {
		int a, b;
		for (int i = n; i >= 0; i--) {
			if (p[i] && p[i - 2]) {
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

const int SIZE = 10001;

int main()
{
	bool prime[ SIZE ];
	memset( prime, 0, sizeof(prime) );

	prime[ 0 ] = prime[ 1 ] = true;
	for( int i = 2; i < SIZE; ++i ){
		if( prime[ i ] ) continue;
		for( int j = i + i; j < SIZE; j += i ){
			prime[ j ] = true;
		}
	}

	int n;
	while( cin >> n && n ){
		for( int i = ( n % 2 == 0 ? n - 1 : n ); n > 1; i -= 2 ){
			if( !prime[ i ] && !prime[ i - 2 ] ){
				cout << i - 2<< " " << i << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while(true) {
    cin >> n;
    if(n == 0) break;
    for(int i = n; i >= 0; i--) {
      if(IsPrime(i) && IsPrime(i - 2)) {
        cout << i - 2 << " " << i << endl;
        break;
      }
    }
  }
  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 p1[10000];
	int q1[10000];
	int n, i, cnt = 0;

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