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"
const int MAX_V = 10000; // 1????????§????´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°,0????´???°??§?????????
int main() {
    int i, k, n;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\???????´???°??¨??????
    }
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????
            }
        }
    }
    while(scanf("%d", &n) != 0) {
        //        int isprime = prime[v];
        //        if(isprime) printf("%d is a prime number\n", v);
        //        else printf("%d is not a prime number\n", v);
        int p1;
        int q1;
        for(i = n;0 <= i;i--){
            if(prime[i] == 1 && prime[i-2] == 1){  //??????????´???°
                if (q1 <= i) {
                    q1 = i;
                    p1 = i-2;
                }
            }
        }
        printf("%d %d\n",p1,q1);
    }
    return 0;
}
//????¨??????¨????????????????????????

C++: #include<stdio.h>
int main(){
    int i,k,x,a,b,data[10000];
    for(i=2;i<=10000;i++){
        data[i]=1;
    }
    for(i=2;i*i<=10000;i++){
        if(data[i]){
            for(k=2*i;k<=10000;k+=i){
                data[k]=0;
            }
        }
    }
    while(1){
        a=0;
        b=0;
        scanf("%d",&x);
        if(x==0)break;
        for(x;x>=2;x--){
            if(data[x]==1){
                b=a;
                a=x;
            }
            if(b-a==2)break;
        }
        printf("%d %d\n",a,b);
    }
    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<bits/stdc++.h>
using namespace std;
int prime(int z)
{
    for(int i=2;i<z;i++) if(z%i==0) return 0;
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    while(1)
    {
        int n,i;
        cin >> n;
        if(n==0) break;
        if(n%2 == 0)n-=1;
        for(i=n;i>=2;i-=2)
        {
            if(prime(i) && prime(i-2))
            {
                cout << i-2 << " " << i << "\n";
                break;
            }
        }
    }

    return 0;
}

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

#define MAX_N 3000000

int prime[MAX_N], twin[MAX_N];

void isprime(int c) {
	prime[2] = 1;
	for (int i = 3; i < c; i += 2) {
		for (int j = 3; j <= sqrt(i); j += 2) {
			if (i%j == 0) { 
				goto E; 
			}
		}
		prime[i] = 1;
	E:;
	}
}

void istwin(int d) {
	for (int i = 5; i < d; i++) {
		if (prime[i - 2] + prime[i] == 2) {
			twin[i] = i;
		}
		else {
			twin[i] = twin[i - 1];
		}
	}
}

int n;

int main() {
	isprime(MAX_N);
	istwin(MAX_N);
	while (true) {
		cin >> n;
		if (n == 0) {
			break;
		}
		cout << twin[n] - 2 << twin[n] << endl;
	}
}

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

int main()
{
  const int MAX_PRIME = 10000+1;

  bool p[MAX_PRIME];
  memset(p, true, sizeof(p));
  p[0] = p[1] = false;
  for (int i = 2; i*i <= MAX_PRIME; ++i) {
    if (p[i]) {
      for (int j = i+i; j < MAX_PRIME; j += i)
	p[j] = false;
    }
  }

  vector<int> prime;
  for (int i = 0; i < MAX_PRIME; ++i) {
    if (p[i])
      prime.push_back(i);
  }

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

    for (int i = prime.size()-1; i > 0; --i) {
      if (prime[i]-2 == prime[i-1] && prime[i] <= n) {
	cout << prime[i-1] << " " << prime[i] << endl;
	break;
      }
    }
  }
  return 0;
}

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

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
bool primecheck(int n){
  FOR(i,2,n/2)
    if(n%i == 0) return false;
  return true;
}


int main(void){
  int twinprime[1000] = {0};
  int ptr=0;
  FOR(i,3,9999){
    if(primecheck(i)&&primecheck(i+2))
      twinprime[ptr++] = i;
  }
  twinprime[ptr] = 10001;
  int n;
  while(cin>>n,n){
    int i=0;
    while(true){
      if(twinprime[i]+2>n){
        cout << twinprime[i-1] << " " << twinprime[i-1] + 2<< endl;
        break;
      }
      i++;
    }
  }
}

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 n,i,max,max2;
    scanf("%d",&n);
    for(i=n;i>0;i--){
        if(isprime(i)==1){
            if(isprime(i-2)==1){
                max=i;
                break;
            }
        }
    }
    max2=max-2;
    printf("%d %d\n",max2,max);
    return 0;
}

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

int	Prime(int	x){
	int	n;
	if(x	==	2)return	1;
	if(x	<	2	||	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	=	0,	max	=	0,	data[100000];
	while(1){
	  cnt=0;
	  max=0;
	  scanf("%d",	&n);
	  if(n==0) break;
	  for(i	=	0;	i	<=	n;	i++){
		  if(Prime(i)	==	1){
			  data[cnt]	=	i;
			  cnt++;
		  }	
		}
		for(i	=	1;	i	<=	cnt;	i++){
			if(data[i]	-	data[i	-	1]	==	2)max	=	i;
		}
		if(max	!=	0)printf("%d %d\n",	data[max - 1],	data[max]);
	}
	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;
    while(1){
        scanf("%d",&suu);
        if(suu != 0){
            for(k=2;k<=suu;k++){
                if(isprime(k-2)==1 && isprime(k)==1){
                    an1=k-2;
                    an2=k;
                }
            }
            printf("%d %d\n",an1,an2);
        }
        else{
    	    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 k,v,a,b;
    while(1) {
        scanf("%d", &v);
        if(v == 0) break;
        for(k = 1; k <= v; k++) {
            if(isprime(k) == 1 && isprime(k-2) == 1){
                a = k - 2;
                b = k;
                break;
            }
        }
        printf("%d %d\n",a,b);
    }
}