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 <cstdio>
using namespace std;
int main()
{
    int n;
    bool prime[10001];
    for (int i=0; i<=10000; i++) prime[i]=true;
    prime[0]=false;
    prime[1]=false;
    for (int i=2; i<=10000; i++) {
        if (!prime[i]) continue;
        for (int j=i+i;j<=10000; j+=i) prime[j]=false;
    }
    while (scanf("%d",&n)&&n!=0) {
        int p1=0, p2=0;
        for (int i=2; i+2<=n; i++) {
            if (!prime[i]) continue;
            if (prime[i]&&prime[i+2]) {
                p1=i;
                p2=i+2;
            }
        }
        printf("%d %d\n",p1,p2);
    }
}

C++: #include <stdio.h>
#include <string.h>
int main() {
	int in[100]={0};
	int out[100]={0};
	int count = 0;
	int i = 0,z = 0,c;
	while(scanf("%d",&in[i])!=EOF){
		if(in[i]!=0){
			i++;
			//printf("in[%d]=%d\n",i,in[i]);
		}else{
			//printf("%d",in[i-1]);
			out[z] = in[i-1];
			//printf("out[%d]=%d\n",z,out[z]);
			z++;
			i--;
		}
	}
	for(i=0;i<z;i++){
		printf("%d\n",out[i]);
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);++i)
#define reps(i,j,k) for(int i=j;i<k;++i)
typedef long long ll;
typedef unsigned long long ull;
bool us[100100]={false};
int p[100100]={0};
int main(){
	/*Eratosthenes*/
	p[2] = 2;
	for(int i = 0; i < 100101 ; i+=2)us[i] = true;
	for(int i = 3; i < 100101; i+=2){
		if(us[i] == true)continue;
		else if(us[i] == false){
			p[i] = i;
			for(int j = i+i; j < 100101; j += i)us[j] = true;
		}
	}

	int n;

	while(scanf("%d",&n),n){
		for(int i = n; i >= 0; i--){
			if(!us[i] && !us[i-2]){
				printf("%d %d\n",p[i-2],p[i]);
				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>
#include<string>
using namespace std;
int main(){
	const int MAX = 10000;
	int katarogu[MAX] = { 0 };
	const int NOsosu = 1;
	int num[MAX] = { 0 };
	num[1] = NOsosu;
	for (int i = 3; i < MAX; i = i + 2){
		for (int j = 3; j*j <= i; j = j + 2){
			if (i%j == 0){ num[i] = NOsosu; break; }
		}
		if (num[i] != NOsosu && num[i - 2] != NOsosu){ katarogu[i] = 1; }
	}
	int a;
	while (cin >> a,a!=0){
		for (; a > 6; a--){
			if (katarogu[a] != 0){
				cout << a-2<<" "<<a << endl;
				break; 
			}
		}


	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int prime[10001];

void CreatePrime(int n)
{
	rep(i,n)
	{
		prime[i] = 1;
	}

	prime[0] = prime[1] = 0;

	REP(i,2,sqrt(n))
	{
		if(prime[i])
		{
			for(int j=0;i*(j+2) < n;j++)
			{
				prime[i*(j+2)] = 0;
			}
		}
	}
}

int main()
{
	int n;
	vector<int> v;
	vector<pair<int,int> > ans;

	CreatePrime(10001);
	while(cin >> n && n)
	{
		rep(i,n+1)
		{
			if(prime[i]) v.push_back(i);
		}
		
		rep(i,v.size()-1)
		{
			REP(j,i+1,v.size())
			{
				if(v[j] - v[i] == 2)
				{
					ans.push_back(make_pair(v[i],v[j]));				
				}

				else if(v[j] - v[i] > 2)
				{
					break;
				}
			}
		}

		cout << ans[ans.size()-1].first << " " << ans[ans.size()-1].second << endl;
	}
	return 0;
}

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAX = 10010;

bool p[MAX];

int main()
{
    p[0] = p[1] = 1;
    rep(i,MAX)if(!p[i])for(int j= i*2;j<MAX;j+=i)p[j] = 1;

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

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

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int main() {
	vi v(100100, 1);
	v[0] = 0;
	v[1] = 1;
	for (int i = 2; i < 100100; i++) {
		if (v[i] == 1) {
			for (int j = 2; j <= 100100 / i; j++) {
				v[i*j] = 0;
			}
		}
	}
	int n;
	while (cin >> n&&n > 0) {
		int ans = 5;
		for (int i = n; i > 1; i--) {
			if (v[i] && v[i - 2]) {
				ans = i;
				break;
			}
		}
		cout << ans - 2 << " " << ans << endl;
	}
}