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>

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[1000000+2] = {0};
	for(i = 2;i < 1000000;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<iostream>
#include<vector>
#include<utility>
using namespace std;
typedef pair<int, int>p;
bool ip[10005];
vector<int>prime;
vector<p> twin;

void eratos() {
	for (int i = 0;i < 10005;i++)ip[i] = true;

	ip[0] = ip[1] = false;

	for (int i = 2;i*i < 10005;i++) {
		if (ip[i] == true) {
			for (int j = i * i;j < 10005;j += i)ip[j] = false;
		}
	}

	for (int i = 0;i < 10005;i++) {
		if (ip[i]) {
			prime.push_back(i);
		}
	}
	return;
}

int main() {
	int n;
	eratos();

	for (int i = 0;i < prime.size()-1;i++) {
		if (prime[i + 1] - prime[i] == 2) {
			twin.push_back(make_pair(prime[i], prime[i+1]));
		}
	}
	int x = twin.size();

	while (cin >> n, n) {
		for (int i = 1;i<x;i++) {
			if (twin[i].second > n) {
				cout << twin[i - 1].first << ' ' << twin[i - 1].second << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
bool prime[10001];

bool make(){
  memset(prime,true,sizeof(prime));
  prime[0]=prime[1]=false;
  for(int i=0;i<10001;i++)
    {
      if(prime[i])
	for(int j=i+i;j<10001;j+=i)
	  prime[j]=false;
    }
}

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

C++: #include <iostream>
#include <math.h>
using namespace std;

int fl[10001] = {0};

void isfl(int);
void twlf(int);

int main(void) {
  int tag;

  while(1){
    cin >> tag;
    if(tag == 0) break;
    isfl(tag);
    twlf(tag);
  }
  return 0;
}

void isfl(int tag){
  int i,lim,idx = 2;
  fl[0] = 1;
  fl[1] = 1;

  lim = sqrt(tag);

  while(idx <= lim){
    if(fl[idx] == 0) for(i = idx*2;i<=tag;i+=idx) fl[i] = 1;
    idx++;
  }
  return;
}

void twlf(int tag){
  int k=0,data[10000];
  for(int i=1;i<=tag;i++) if(fl[i] == 0){
    data[k] = i;
    k++;
  }
  for(int i=k-1;i>=0;i--){
    if(data[i] - data[i-1] == 2){
      cout << data[i-1] << " " << data[i] << endl;
      break;
    }
  }
  return;
}

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+1];
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = 2;i < n;i++){
			number[i] = isprime(i);
			if(number[i] && number[i-2]){
				min = i-2;
				max = i;
				//printf("%d %d\n",i-2,i);
			}
		}
		printf("%d %d\n",min,max);
	}
	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+1];
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = 2;i < n;i++){
			number[i] = isprime(i);
			if(number[i] && number[i-2]){
				min = i-2;
				max = i;
				//printf("%d %d\n",i-2,i);
			}
		}
		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 <iostream>
using namespace std;

int isprime(int n);
int isSmallTwinPrime(int n);
int GetMaxTwinPrimeNumber(int argRange);

int main()
{
	int const size = 10000;
	int data[size];	
	
	int i=0;
	while(1) //for(int i=0; data[i]!=0; i++)
	{
		cin >> data[i];
		if(data[i]<=0) break;
		i++;
	}
	
	int outputNum;
	
	for(int i=0; data[i]!=0; i++)
	{
		outputNum = GetMaxTwinPrimeNumber(data[i]);
		if(outputNum!=0)
		{
			cout << outputNum-2 << " " << outputNum << endl;
		}
	}
	
	return 0;
}

int isprime(int n) 
{
	for(int i = 2; i * i <= n; i++) 
	{
		if(n % i == 0) 
		{
			return 0;
		}
	}
	return 1;
}

int isSmallTwinPrime(int n)
{
	for(int i = 2; i * i <= n; i++) 
	{
		if((n-2) % i == 0) 
		{
			return 0;
		}
	}
	return 1;
}

int GetMaxTwinPrimeNumber(int argRange)
{
	int maxTwinPrimeNum = 0;
	
	for(int i=0; ; i++)
	{
		int Num = argRange - i;
		
		if(isprime(Num)==1 && isSmallTwinPrime(Num)==1)
		{
			maxTwinPrimeNum = Num;
			return maxTwinPrimeNum;
		}
		
		if(Num==0)
		{
			return 0;
		}
	}
}

C++: #include<stdio.h>
int main(void)
{
    int a,i,flg1,p,q,l,b,a2,b2;
	scanf("%d",&a);
	while(a!=0){
	    flg1=1;
		p=0;
		q=0;
		a2=0;
		b2=0;
	    for(i=2;i<=a;i++){
		    for(l=2;l<i-2;l++){
			    b=i%l;
				if(b==0) {
				    flg1=0;
					break;
				}
			}
			if(flg1==1) {
				if(p==0){
				    q=i;
				}
				else if(p!=0){
				    q=i;
				}
				if(q-2==p){
				    a2=p;
					b2=q;
				}
				else{
				    p=q;
				}
			}
			flg1=1;
			if(a==5||a==6) a2=3,b2=5;
		}
		printf("%d %d\n",a2,b2);
		scanf("%d",&a);
	}
	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) {
		int b = *(lower_bound(ans.begin(), ans.end(), n) - 1);
		int a = b - 2;
		cout << a << " " << b << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
    int tbl[10001];
    fill(tbl, tbl+10001, 1);
    for (int i=2; i<10001; ++i) {
        for (int j=i*2; j<10001; j+=i) {
            tbl[j] = 0;
        }
    }

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

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	const int MAX = 10000;
	int katarogu[MAX] = { 0 };
	const int YESsosu = 1;
	const int NOsosu = 0;
	int num[MAX] = { NOsosu };
	num[2] = YESsosu;
	num[3] = YESsosu;
	for (int i = 3; i < MAX; i = i + 2){
		for (int j = 3; j <= i; j = j + 2){
			if (i == j){ num[i] = YESsosu; }
			if (i%j == 0){ break; }
		}
		if (num[i] == YESsosu && num[i - 2] == YESsosu){ 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;
}