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 <algorithm>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)

bool is[10010];

int main(){
  int n;

  rep(i,10010){
    is[i] = true;
  }
  is[1] = is[0] = false;
  for(int i = 2; i < 10010; i++){
    for(int j = 2; i*j < 10010; j++){
      if(is[i] == true){
	is[i*j] = false;
      }
    }
  }

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



  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,i;
	while(1){
	scanf("%d",&n);
	if(n==0) break;
		for(i=n;i>0;i--){
			if(i==5||i==7){
				printf("%d %d\n",i-2,i);
				break;
			}
			else if(i%2!=0&&i%3!=0&&i%5!=0&&i%7!=0){
				if((i-2)%2!=0&&(i-2)%3!=0&&(i-2)%5!=0&&(i-2)%7!=0){
					printf("%d %d\n",i-2,i);
					break;
				}
			}
		}
	}
	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <vector>

constexpr bool divisible(const std::size_t n, const std::size_t m)
{
    return (0 == n % m);
}

std::vector<std::size_t> prime_table = {2};

bool prime(const std::size_t n)
{
    const std::size_t found_last_prime = prime_table.back();
    if(found_last_prime < n)
    {
        std::list<std::size_t> undefined_table;

        for(std::size_t i = found_last_prime + 1; i < n; ++i)
        {
            undefined_table.push_back(i);
        }

        const std::size_t sn = std::sqrt(n);
        for(std::size_t p = 0; !undefined_table.empty() && p < prime_table.size(); ++p)
        {
            for(auto u = undefined_table.begin(); u != undefined_table.end();)
            {
                if(divisible(*u, prime_table.at(p)))
                {
                    u = undefined_table.erase(u);
                }
                else
                {
                    ++u;
                }
            }
            if(!undefined_table.empty() && found_last_prime <= prime_table.at(p))
            {
                prime_table.push_back(undefined_table.front());
                undefined_table.pop_front();
                if(sn < prime_table.front())
                {
                    break;
                }
            }
        }
        prime_table.insert(prime_table.end(), undefined_table.begin(), undefined_table.end());
    }
    return std::binary_search(prime_table.begin(), prime_table.end(), n);
}

std::pair<std::size_t, std::size_t> find_twin_prime(const std::size_t limit, const bool next_skip = false)
{
    return prime(limit) ?
        prime(limit - 2) ?
        std::make_pair(limit - 2, limit) :
        find_twin_prime(limit - (next_skip ? 3 : 1), true) :
        find_twin_prime(limit - (next_skip ? 2 : 1), false);
}

int main()
{
    std::size_t n;

    while(std::cin >> n, n != 0)
    {
        const auto&& t = find_twin_prime(n);
        std::cout << t.first << " " << t.second << std::endl;
    }
}

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,g,j,suu,an1,an2;
	int su[10000]={1};
    for(k=0;k<10000;k++){
    	if(isprime(k)==1){
    		j=0;
    		for(g=2;j<=10000;g++){
    			j=g*k;
    			su[j]=0;
    		}
    	}  
    }
    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;
        }
    }
    return 0; 
}

C++: #include<stdio.h>
int main()
{
	int i,j,n;
	const int N=10001;
	bool p[N];
	for(i=2;i<N;++i)p[i]=true;
	for(i=2;i<=N/2;++i)if(p[i])for(j=2*i;j<N;j+=i)p[j]=false;
	while(scanf("%d",&n),n){for(i=n;;--i)if(p[i]&&p[i-2])break;printf("%d %d\n",i-2,i);}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

const int MAXN = 10001;
bool isPrime[MAXN];

int main() {
  fill(isPrime, isPrime+MAXN, true);
  isPrime[0] = isPrime[1] = false;
  for(int i = 2; i < MAXN; ++i) {
    if(isPrime[i])
      for(int j = i*2; j < MAXN; j += i) isPrime[j] = false;
  }

  int n;
  while(cin >> n && n) {
    int p, q;
    for(int x = 3; x+2 <= n; ++x) {
      if(isPrime[x] && isPrime[x+2]) {
        p = x;
        q = x+2;
      }
    }
    cout << p << " " << q << endl;
  }
  return 0;
}

C++: #include <stdio.h>
const int MAX_V = 10000;
int prime[MAX_V+1];
int main(){
  int i,k,n,j,i1,i2,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<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  bool prime[100000];
  prime[0]=prime[1]=0;
  loop(i,2,100000){
    prime[i]=true;
  }
  for(int i=2;i<=100000;i++){
    for(int j=2;i*j<=100000;j++){
      prime[i*j]=false;
    }
  }
  int n,m,ans1,ans2;
  while(cin>>n,n){
    for(int i=2;i<=n;i++){
      if(prime[i]){
	m=i;
	i++;
	while(!prime[i])i++;
	if(i>n)break;
	if((i-m)==2){
	  ans1=m;
	  ans2=i;
	}
	i--;
      }
    }
    cout<<ans1<<" "<<ans2<<endl;
  }
  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 = 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",&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; 
}