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>

bool f[10003];

bool f2[10003];


int main(){

for(int i=0;i<10002;i++)
for(int j=2;j*j<=i;j++)
{if(i%j!=0)f[i]=true;
else{ f[i]=false;break;}
}


for(int i=0;i<10002;i++) 
if(f[i]==true&&f[i+2]==true)f2[i]=true;

int n;
while(1){
scanf("%d",&n);if(n==0)break;
int p=0,q=0;
for(int i=n-2;i>=5;i--)
if(f2[i]==true){q=i+2;p=i;break;}

printf("%d %d\n",p,q);
}
return 0;
}

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?????\???????????°????´???°??§?????????
            }
        }
    }
    //    scanf("%d",&n);
    //    while (1) {
    //    if (n == 0)break;
    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 = 0,q1 = 0;
        for(i = n;0 <= i;i--){
            if(prime[i] == 1 && prime[i-2] == 1){  //??????????´???°
                q1 = i;
                p1 = i-2;
                break;
            }
        }
        printf("%d %d\n",p1,q1);//for?????????????????????
    }
    return 0;
}
//????¨??????¨????????????????????????

C++: #import<algo.h>
int i,j,n,P[9999];
int main()
{
	for(i=2;i*i<9999;i++)for(j=i;j<9999;P[j+=i]=1);
	for(;std::cin>>n,n;printf("%d %d\n",i-2,i))
		for(i=n;P[i]||P[i-2];i--);
}

C++: #include <iostream>

using namespace std;

#include<iostream>
#include<algorithm>
using namespace std;

bool p[1000100];

void erato(){
    fill(p, p+1000100, true);
    p[0] = p[1] = false;

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

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

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define int long long

using namespace std;

class Solver {
};
signed main() {
	vector<bool> isPrime(10005, true);
	vector<int> primes;
	for (int i = 2; i < isPrime.size(); i++) {
		if (!isPrime[i])continue;

		primes.emplace_back(i);

		for (int j = 2; i * j < isPrime.size(); j++) {
			isPrime[i * j] = false;
		}
	}

	vector<int> vals;
	for (int i = 1; i < primes.size(); i++) {
		if (primes[i] - primes[i - 1] == 2)vals.emplace_back(primes[i]);
	}

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

		int max = 0;
		for (int i = 0; i < vals.size(); i++) {
			if (vals[i] > n)break;
			max = vals[i];
		}
		cout << max - 2 << ' ' << max << endl;
	}
}

C++: #include <stdio.h>
#define MAX 10000

int main(void){
    int list[MAX]={0}, q;
    
    // determine primes
    for (int i=2; i<MAX; i++){
        if (list[i]==-1) continue;
        list[i]=1;
        for (int j=2*i; j<MAX; j+=i){
            list[j] = -1;
        }
    }
    
    while (scanf("%d",&q),q){
        for (int i=q; i>=5; i--){
            if (list[i]==1 && list[i-2]==1){
                printf("%d %d\n",i-2, i);
                break;
            }
        }
    }
    
    return 0;
}

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 n,i;
	int sousi[2];
	int prime[10100][2];
	for (i = 0; i < 10100; i++) {
		prime[i][0] = i;
		prime[i][1] = isprime(i);
	}
	while(1) {
		sousi[0] = 0;
		sousi[1] = 0;	 
		scanf("%d",&n);
		if(n == 0) {
			break;
		}
		for(i = n; i > 2; i--) {
			if(prime[i][1] == 1 && prime[i - 2][1] == 1) {
				sousi[0] = prime[i - 2][0];
				sousi[1] = prime[i][0];
				break;
			}
		}
		printf("%d %d\n",sousi[0],sousi[1]);
	}
	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 n ,i , fir ,sec;
  while(scanf("%d" ,&n)){
    if(n==0)break;
    fir = 0 ,sec = 0;
    for(i=n ;i>3 ;i--){
      if(number[i] && number[i-2]){
        fir = i-2;
        sec = i;
        break;
      }
    }
    printf("%d %d\n" ,fir ,sec);
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 10e-6;



int main(){
	int n;
	int* primeTable = new int[100001];
	fill((int*)primeTable,(int*)primeTable+100001,1);

	primeTable[0] = 0;
	primeTable[1] = 0;

	for(int i=2;i*i<=100000;i++){
		if(primeTable[i] != 1) continue;
		for(int j=i+i;j<=100000;j+=i){
			primeTable[j] = 0;
		}
	}

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

C++: #include<stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1];
int hurui(int v){
  int i, k;
  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;
      }
    }
  }
  int isprime = prime[v];
  if(isprime) {
    return 1;
  }else{
    return 0;
  }
}

int main() {
  int v, i = 0, count = 0, q1[100];
  while(scanf("%d", &v) != EOF) {
    if(v == 0)  break;
    while(1){
      if(hurui(v) == 0 || hurui(v - 2) == 0){
        v--;
        count ++;
      }else{
        printf("%d %d\n", v - 2, v);
        break;
      }
    }
    i++;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;
bool isPrime[10002];

void PrimeCalc()
{
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 10001; ++i)
	{
		if(isPrime[i])
		{
			for(int j = 2 * i; j < 10001; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n, n)
	{
		for(int i = n; i >= 7; --i)
		{
			if(isPrime[i] && isPrime[i - 2])
			{
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	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;
    for(k=2;k<=suu;k++){
        if(isprime(k-2)==1 && isprime(k)==1){
            an1=k-2;
            an2=k;
        }
    }
    while(1){
        scanf("%d",&suu);
        if(suu != 0){
            printf("%d %d\n",an1,an2);
        }
        else{
    	    break;
        }
    }
}