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>
using namespace std;
bool so[10000]={};

int main(){
  so[0] = 1;
  so[1] = 1;
  for(int i=2;i*i<=10000;i++)
    if(so[i] == 0)
      for(int j=2;j*i<=10000;j++)
	so[i*j] =1;
  int n;
  while(cin>>n && n){
    for(int i=n;i>=5;i--)
      if(so[i]==0 && so[i-2]==0){
	cout << i-2 <<" "<< i<<endl;
	break;
      }
  }

  return 0;
}

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

bool p[10001];

void seive(int s){
	for(int i=0;i<=s;i++)p[i]=true;
	p[0]=p[1]=false;
	for(int i=2;i<=s;i++){
		if(p[i]==true){
			for(int j=i*2;j<=s;j+=i)p[j]=false;
		}
	}
}

int main(void){
	seive(10000);
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		while(1){
			if(p[n]==true && p[n-2]==true){
				printf("%d %d\n",n-2,n);
				break;
			}
			n--;
		}
	}
    return 0;
}

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

C++: #include <stdio.h>
#include <time.h>
int isprime(int n){
	for(int i = 2; i < n; i++){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}
int main() {
	int i,p,q,n;
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		for(i=n;i>=2;i--){
			if(isprime(i) == 1 && isprime(i-2) == 1){
				p = i;
				q = i-2;
				break;
			}
		}
		printf("%d %d\n",q,p);
	}
	return 0;
}


	// clock_t start, now;
	// now = clock();
	// printf("%f\n",(double)(now - start) / CLOCKS_PER_SEC);

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

bool p[101000];

void prime() {
  fill(p, p+101000, true);
  p[0] = false;
  p[1] = false;
  for(int i = 2; i < 101000; i++) {
    if(p[i]) {
      for(int j = 2; i*j < 101000; j++) {
	p[i*j] = false;
      }
    }
  }
}

int main() {
  int n;
  prime();
  while(cin >> n, n) {
    int ans;
    for(int i = 0; i <= n; i++) {
      if(p[i] && p[i-2]) ans = i;
    }
    cout << ans-2 << ' ' << ans << endl;
  }
}

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

int main( void )
{
	vector <bool> is_prime(10001, false);
	for ( int i = 3; i < 10001; i += 2 )
		is_prime[i] = true;
	for ( int i = 3; i < 10001; i += 2 )
	{
		if ( is_prime[i] )
		{
			for ( int j = i + i; j < 10001; j += i )
			{
				is_prime[j] = false;
			}
		}
	}

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

	return 0;
}

C++: #include <iostream>

using namespace std;

const int N = 10000;

class Solver {
    private:
        bool is_prime_[N + 1];
    public:
        Solver() {
            for (int i = 0; i <= N; ++i) {
                is_prime_[i] = true;
            }
            for (int i = 2; i <= N; ++i) {
                if (!is_prime_[i]) {
                    continue;
                }
                for (int j = 2; j * i <= N; ++j) {
                    is_prime_[j * i] = false;
                }
            }
        }
        int solve(int n) {
            for (int i = n; true; --i) {
                if (is_prime_[i] && is_prime_[i - 2]) {
                    return i;
                }
            }
        }
};

int main() {
    Solver s;
    int n, x;
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        x = s.solve(n);
        cout << x - 2 << ' ' << x << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
bool prim[10001];

int main(void){
  int n;
  for(int i=0; i < 10001; i++){
    prim[i] = true;
  }
  for(int i=2; i < sqrt(10001); i++){
    if(prim[i]){
      for(int j=0; i*(j+2) < 10001; j++){
        prim[i * (j+2)] = false;
      }
    }
  }

  while(cin >> n, n){
    int cnt = 0;
    vector<int> ans;
    for(int i=n; i > 0; i--){
      if(prim[i]){
        ans.push_back(i);
        cnt++;
      }
      if(cnt == 2){
        if(ans[0] - ans[1] == 2){
          cout << ans[1] << " " << ans[0] << endl;
          break;
        }else{
          ans.erase(ans.begin());
          cnt = 0;
        }
      }
    }
  }
  return 0;
}

C++: #include <stdio.h>
#include <time.h>
int isprime(int n){
	for(int i = 2; i * i <= n; i++){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}
int main() {
	int i,p,q,n;
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		for(i=n;i>=2;i--){
			if(isprime(i) && isprime(i-2) ){
				break;
			}
		}
		printf("%d %d\n",i-2,i);
	}
	return 0;
}


	// clock_t start, now;
	// now = clock();
	// printf("%f\n",(double)(now - start) / CLOCKS_PER_SEC);

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

int main()
{
	int n, i, i2;
	int prime[10000];
	for(int i=2; i<= n; i++){
		prime[i]=1;
		for(i2 = 2; i2<=sqrt(i); i2++)
		{
			if(i % i2 == 0)
			{
				prime[i] = 0;
				break;
			}
		}
	}
	while(1)
	{
		scanf ("%d",&n);
		if(n==0)
		{
			return 0;
		}
		for(i=n; 1; i--)
		{
			if(prime[i] && prime[i-2])
			{
				printf("%d %d",i ,i2);
				break;
			}
		}
	}
}

C++: #include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム 
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std; // std 名前空間を使用する
const int MAX=10000;
bool prime[MAX+1];
void make_prime(){
    for(int i=0;i<=MAX;i++){
        prime[i]=true;
    }
    prime[0]=false;
    prime[1]=false;
    for(int p=2;p<=MAX;p++){
        if(prime[p]){
            for(int n=p+p;n<=MAX;n+=p){
                prime[n]=false;
            }
        }
    }
}
int main(void){
    make_prime();
    while(1){
        int n;
        scanf("%d",&n);
        if(n==0)break;
        for(int i=n;i>=2;i--){
            if(prime[i]&&prime[i-2]){
                printf("%d %d\n",i-2,i);
                break;
            }
        }
    }
}

C++: #include "stdio.h"
//#include "time.h"
//?????§??????????´???°?????????????????????
// 5<= n <= 10000
//p1=?°????????´???°p2=??§???????´???°

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,n,p1,q1;
   //     clock_t start, now;//??£?¨?
    while(1){
        scanf("%d",&n);
     //   start = clock(); // ????§???????
        if(n == 0)break;
        for(i = n;3 <= i;i--){
            if (isprime(i) == 1 && isprime(i - 2) == 1) break;
        }
        p1 = i-2;
        q1 = i;
       // now = clock(); // ????????????
       // printf("%f\n", (double)(now - start) / CLOCKS_PER_SEC);//??¬???
        printf("%d %d\n",p1,q1);
    }
    return 0;
}