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 k,v,a=0,b=0;
    while(1) {
        scanf("%d", &v);
        if(v == 0) break;
        for(k = v; k > 0; k--) {
            if(isprime(k) == 1 && isprime(k-2) == 1){
                a = k - 2;
                b = k;
                break;
            }
        }
        printf("%d %d\n",a,b);
    }
    return 0;
}

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[100];
	scanf("%d",	&n);
	for(i	=	2;	i	<=	n;	i++){
		if(Prime(i)	==	1){
			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++: #include <iostream>
#include <algorithm>
using namespace std;

bool data[10010];

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

	int n;
	while(cin >> n && n != 0){
		fill(data, data + n, true);

		for(int i = 2; i <= n; ++i){
			for(int j = 2; i * j <= n; ++j){
				data[i * j] = false;
			}
		}

		for(int i = n; i >= 2; --i){
			if(data[i] && data[i - 2]){
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include <stdio.h>

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<iostream>

using namespace std;

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

int main(){
	int n;
	while(cin>>n,n!=0){
		while(true){
			if(prime(n)&&prime(n-2)){
				cout<<n-2<<" "<<n<<endl;
				break;
			}
			n--;
		}
	}
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n;

bool judge(int num)
{
	int cnt = 0;

	for (int i = 2; i < num;i++)
	{
		if (num%i==0)
		{
			cnt = 1;

			return false;
		}
	}

	return true;


}

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

	}


	return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int s[10001]={1,1,0,0,1};
int main(){
	r(i,2,10001)for(int j=i*2;j<10001;j+=i)s[j]++;
	int a;
	while(cin>>a,a){
		while(a--){
			if(!s[a]&&!s[a-2]){
				cout<<a-2<<' '<<a<<endl;
				break;
			}
		}
	}
}

C++: #include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

bool isprime(int n){
	if(n<2)return false;
	for(int i=2;i*i<=n;i++) if( n % i == 0)return false;
	return true;
}
int main(){
	int n;
	while(cin >> n , n){
		while(n){
			if(isprime(n) & isprime(n-2)){
				cout << n-2 << " " << n << endl;
				break;
				}
			n--;
		}
	}
}

C++: #include<iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;

int so[10010];
int set[10010];

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

	int num[10000];
	for(int i=0;i<n;i++){
	num[i]=1;
	}
	
	
	for(int i=2;i<n;i++){
		if(num[i]==1){
			for(int j=0;i*(j+2)<n;j++){
			num[i*(j+2)]=0;
			}
		}
	}
	for(int i=2;i<n;i++){
		if(num[i]){
		so[i]=i;
		}
	}
	
	sort(so, so+n,greater<int>() );

	for(int i=0;i<n;i++){
		if(so[i]-so[i+1]==2){
		cout<<so[i+1]<<" "<<so[i]<<endl;
			break;
		}
	}
	
}


}

C++: #include <stdio.h>

const int max = 10000; //素数表最大数
int prime[max + 1]; //素数表配列
int idx, idx2, tmp;

void list(); //素数表作成
void judge(int n); //双子素数判定

int main(){
    
    int n;
    
    list();
    
    while (scanf("%d", &n)){
        if (n == 0) break;
        judge(n);
        printf("%d %d\n", idx2, idx);
    }
    
    return 0;
}

void list(){
    int i, k;
    for (i = 2; i <= max; i++){
        prime[i] = 1;
    }
    for (i = 2; i * i <= max; i++){
        if (prime[i]){
            for (k = 2 * i; k <= max; k += i){
                prime[k] = 0;
            }
        }
    }
}

void judge(int n){
    int i;
    for (i = n; 0 < n; i--){
        tmp = i - 2;
        if(prime[i]){
            if(prime[tmp]){
                idx = i;
                idx2 = tmp;
                break;
            }
        }
    }
}

C++: #include <iostream>
#include <vector>
#include <string.h>

using namespace std;
bool IsPrime[10500];
vector<int> Prime;

void calc()
{
	memset(IsPrime, 1, sizeof(IsPrime));
	for(int i = 2; i < 10500; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 10500; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		while(Prime[count] < n)
		{
			count++;
		}
		if(Prime[count] != n)
		{
			count--;
		}
		for(int i = count; i >= 0; --i)
		{
			if(Prime[i] - Prime[i - 1] == 2)
			{
				cout << Prime[i - 1] << " " << Prime[i] << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

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, n) {
        while (n >= 2) {
            if (prime[n] && prime[n - 2]) {
                printf("%d %d\n", n - 2, n);
                break;
            }
            n--;
        }
    }

    return 0;
}

C++: #include<iostream>
#include<fstream>
#include<vector>
#define N 10000

//jが素数なら1、違うなら0を返す
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)){
                std::cout << j-2 << " " << j <<std::endl;
                break;
            }
        }
    }
    return 0;
}