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 <math.h>

#define N 10001

using namespace std;

int main(void){
	bool isprime[N];
	for(int i=0;i<N;i++) isprime[i]=true;
	int upto = (int)sqrt(N);
	for(int i=2;i<=upto;i++){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<=N;j++) isprime[i*j] = false;
		}
	}
	int n;
	while(cin >> n){
		if(n==0)break;
		int p1,q1,w=3;
		for(int i=n;i>=3;--i){
			if(isprime[i]&&isprime[i-2]){
				q1=i;
				p1=i-2;
				break;
			}
		}
		cout<<p1<<" "<<q1<<"\n";
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

const int MAX_P = 10020;
bool prime[MAX_P];

void init()
{
    for (int i = 0; i < MAX_P; i++)
        prime[i] = true;
    prime[0] = prime[1] = false;

    for (int i = 2; i * i < MAX_P; i++)
        if (prime[i]) 
            for (int j = 2 * i; j < MAX_P; j += i)
                prime[j] = false;
}


int main()
{
    init();

    int n;
    while (cin >> n) {
        while (n - 2 >= 0) {
            if (prime[n] && prime[n - 2]) {
                cout << n - 2 << " " << n << endl;
                break;
            }
            n--;
        }
    }

    return 0;
}

C++: #include <stdio.h>
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,a,b,p1,q1,n;
	scanf("%d", &n);
	while( n != 0){
		for(i=2;i<=n;i++){
			a = isprime(i-2);
			b = isprime(i);
			if(a==1 && b==1){
				p1 = i-2;
				q1 = i;
			}
		}
		printf("%d %d\n",p1,q1);
		scanf("%d", &n);
	}
	return 0;
 }

C++: #include <stdio.h>

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

int main(void)
{
	int i,n;
	int p[10001];
	for (i = 0; i < 10001; i++){
		p[i] = isprime(i);
	}
	scanf("%d", &n);
	for (i = n; i >1; i--){
		if (p[i] * p[i - 2] == 1)
			break;
	}
	if (n>=5)
		printf("%d %d\n", i - 2, i);
	return 0;
}

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

int main() {
    const int MAX = 10001;
    bool isPrime[MAX];
    fill_n(isPrime, MAX, true);
    for (int i = 4; i < MAX; i += 2) {
        isPrime[i] = false;
    }
    for (int i = 3; i * i <= MAX; i += 2) {
        if (isPrime[i]) {
            for (int j = i * 2; j < MAX; j += i) {
                isPrime[j] = false;
            }
        }
    }
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        if (n % 2 == 0) {
            n--;
        }
        for (int i = n; i >= 5; i -= 2) {
            if (isPrime[i] && isPrime[i - 2]) {
                cout << i - 2 << " " << i << endl;
                break;
            }
        }
    }
}

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

C++: #include <stdio.h>
int main(){
	int i,j,a,b,n,p1,q1;
	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;
			}
		}
	}

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

C++: #include <iostream>

using namespace std;

#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){
        for(int i=n; ; i--)if(p[i] && p[i-2]){cout << i-2 << " " << i << endl;break;}
    }
}

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;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

bool isPrime(int n) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return true;
}
int main() {

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

		for (int i = n - 2; i >= 0; i--) {
			if (isPrime(i) && isPrime(i + 2)) {
				cout << i << " " << i + 2 << endl;
				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 k,suu,an1,an2;
	int su[10000]={0};
    for(k=0;k<10000;k++){
    	if(isprime(k)==1)  su[k]=1;
    }
    while(1){
        scanf("%d",&suu);
        if(suu != 0){
            for(k=2;k<=suu;k++){
            	if(su[k-2]==1 && su[k]==1){
        	    	an1=k-2;
        	    	an2=k;
            	}
            }
            printf("%d %d\n",an1,an2);
        }
        else{
    	    break;
        }
    }
}

C++: #include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	bool p[10010] = {};
	p[0] = p[1] = 1;
	rep2(i,2,101) {
		if(!p[i]) {
			for(int j=2*i;j<=10000;j+=i) {
				p[j] = 1;
			}
		}
	}
	int n;
	while(cin >> n, n) {
		while(p[n] || p[n-2]) --n;
		cout << n-2 << " " << n << endl;
	}
	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;
		}
	}
}