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){
  int i;
  for(i = 2; i * i <= n; i++){
    if(n % i == 0){
      return 0;
    }
  }
  return 1;
}

int main(){
  int k, n, ans, dif;
  while(1){
    scanf("%d", &n);
    if(n == 0){
      break;
    }
    for(k = n; k >= 2; k--){
      ans = isprime(k);
      if(ans == 1){
        dif = isprime(k - 2);
        if(dif == 1){
          printf("%d %d\n", k - 2, k);
          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 num;
    while(1){
        scanf("%d", &num);
        if(num==0)break;
        for(int i=num; i>2; i--){
            if(isprime(i)==1)
                if(isprime(i-2)==1){
                    printf("%d %d\n", i-2, i);
                    break;
                }
        }
    }
    return 0;
}

C++: #include <stdio.h>
const int MAX_V = 1000000; // 100???????????????????f???????¢\????°???¬?????
int prime[MAX_V+1];
int main() {
	int k,i,max,min,n; // 1????????f???????C0????????f????????????????????¢
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1; // 2???????£????f????????????°??????¨
	}
	for(i = 2; i*i <= MAX_V; i++) {
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0; // ???f??????2???{???????£????{?????????f????????????????????¢
			}
		}
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = n;i > 0;i--){
			if(prime[i] && prime[i-2]){
				max = i;
				min = max -2;
				//printf("%d %d\n",i-2,i);
				break;
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cmath>
#include <ostream>
#include <vector>
using namespace std;
    int n,m,k,i,t=1;
    int prm(int k)
    {
       for(i=2;i<=sqrt(k);i++){
       if(k%i==0)
       return 0;
       }
       return 1;
    }
    int main(){
    cin >> m;
    if (m==5){
    cout << 3 <<" " << 5 << std::endl;}
    else
    {
    for (m>5;m<=10000;m--)
    {
    if ((m%10==1||m%10==3||m%10==7||m%10==9)&&(m%6==1)&&prm(m)&&prm(m-2))
    break;
    }
    
    cout << m-2 <<" " << m << std::endl;
    }
}

C++: #include <iostream>

using namespace std;

bool isPrime[10001];

void setPrime( bool *p, int size )
{
	memset(p, true, size);
	p[0] = p[1] = false;

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

int main( void )
{
	setPrime(isPrime, 10001);
	int n;
	while(cin >> n, n) {
		bool hit = true;
		for(int i=n-2; i > 0 && hit; --i) {
			if(isPrime[i]) {
				if(isPrime[i+2]) {
					cout << i << ' ' << i+2 << endl;
					hit = false;
				}
			}
		}
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
	int i,j;
	int isprime[10000];
	for(i=0;i<=10000;i++){
 		isprime[i]=1;
	}
	isprime[0]=isprime[1]=0;
	for(i=2;i<=10000;i++){
 		if(isprime[i]==1){
 			for(j=2*i;j<=1000;j+=i){
				isprime[j]=0;
			}
		}
	}
	int n,p1,q1;
	while (scanf("%d", &n) != EOF){
		for(i=2;i<=n;i++){
			if(isprime[i-2]==1 && isprime[i]==1){
				p1 = i-2;
				q1 = i;
			}
		}
		printf("%d %d\n",p1,q1);
	}
	return 0;
 }

C++: #include <bits/stdc++.h>

using namespace std;

const int MAXN = 10100;
bool sieve[MAXN] = {true, true};

int main(){
  for (int i = 2; i * i < MAXN; i++){
    if (sieve[i]) continue;
    for (int j = i * i; j < MAXN; j += i) sieve[j] = true;
  }
  int N;
  while (cin >> N, N){
    while (sieve[N] or sieve[N - 2]) N--;
    cout << N - 2 << " " << N << endl;
  }
  return 0;
}

C++: #include <iostream>
#define MAX 10000

using namespace std;

bool prime[MAX];

void isPrime(void){

  for( int i = 0 ; i < MAX ; i++ ) prime[i] = true;
  prime[0] = prime[1] = false;

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

}

int main(void){

  isPrime();

  int n;
  while( cin >> n , n ){

    for( int i = n ; i >= 0 ; i-- ){

      if( prime[i] && prime[i - 2] ){
	cout << i - 2 << " " << i << endl;
	break;
      }
    }

  }
  return 0;
}

C++: #include <stdio.h>
const int MAX_V = 10000; // 100???????????????????f???????¢\????°???¬?????
int prime[MAX_V+1];
int main() {
	int k,i,max,min,n; // 1????????f???????C0????????f????????????????????¢
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1; // 2???????£????f????????????°??????¨
	}
	for(i = 2; i*i <= MAX_V; i++) {
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0; // ???f??????2???{???????£????{?????????f????????????????????¢
			}
		}
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = n;i > 0;i--){
			if(prime[i] && prime[i-2]){
				max = i;
				min = max -2;
				//printf("%d %d\n",i-2,i);
				break;
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[10005];
    memset(prime,0,sizeof(prime));
    for(int i=2;i<sqrt(10005);i++){
        if(!prime[i])for(int j=i*2;j<10005;j+=i)prime[j]=1;
    }
    int num[210],co=0;
    for(int i=3;i<10001;i++){
        if(!prime[i]&&!prime[i+2]){
            num[co]=i;
            co++;
        }
    }
    int n;
    while(cin>>n,n){
        for(int i=0;i<co;i++){
            if(num[i]>=n&&num[i-1]+2<=n){
                cout<<num[i-1]<<" "<<num[i-1]+2<<endl;
                break;
            }
            else if(num[i]>n){
                cout<<num[i-2]<<" "<<num[i-2]+2<<endl;
                break;
            }
        }
        if(num[co-1]<n)cout<<num[co-1]<<" "<<num[co-1]+2<<endl;
    }
}

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

string prime(int n){
  int i,j;
  string p = "001";
  while(p.size()<n)p+="10";

  i = 3;
  while(i*i<n){
    for(j=3*i;j<n;j+=2*i)p[j] = '0';
    do{
      i+=2;
    }while(p[i]-'1');
  }
  return p;
}

int main(){
  int n;
  string p;
  while(1){
    cin >> n;
    if(!n)break;

    p = prime(n);

    while(n){
      if(p[n]=='1' && p[n-2]=='1'){
	cout << n-2 << " " << n << endl;
	break;
      }
      n--;
    }
  }
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>

using namespace std;

int s[10001];

void sieve() {
    for(int i = 0; i < 10001; i++) s[i] = 1;
    s[0] = s[1] = 0;

    for(int i = 2; i <= sqrt(10001); i++) {
        if(s[i]) {
            for(int j = i * i; j < 10001; j += i) {
                s[j] = 0;
            }
        }
    }
}

int main() {
    sieve();
    int n;
    while(~scanf("%d", &n)) {
        if(n == 0) break;
        for(int i = n; i >= 2; i--) {
            if(s[i] && s[i - 2]) {
                printf("%d %d\n", i - 2, i);
                goto end;
            }
        }
        end:;
    }
}