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 main(void)
{
	int a,i,j,c,d,x,flg1;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
			for(i=a;i>1;i--){
				flg1=0;
				for(j=2;j*j<=i;j++){
					if(i%j==0){
						flg1=1;
						break;
					}
				}
				if(flg1==0){
					x=i-2;
					for(j=2;j*j<=x;j++){
						if(x%j==0){
							flg1=1;
							break;
						}					
					}
				}
				if(flg1==0){
					c=i;
					d=x;
					break;
				}	
			}
		printf("%d %d\n",d,c);
		c=0;
		d=0;
	}
	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

std::vector<int> prime;
void MakePrime(int n) {
	prime.emplace_back(2);
	for (int i = 3; i < n; i += 2) {
		bool a = false;
		for (int j = 3; j <= std::sqrt(i); j += 2) {
			if (i%j == 0) {
				a = true;
			}
		}
		if (a == false) {
			prime.emplace_back(i);
		}
	}
}
int main() {
	MakePrime(10000);
	bool p[10001] = { false };
	for (int i = 0; i < prime.size(); i++) {
		p[prime[i]] = true;
	}
	int n;
	while (cin >> n&&n != 0) {
		for (int i = n; i >= 0; i--) {
			if (p[i] && p[i - 2]) {
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}
}

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

int dummy_prime(int n,int i){return i>1 ? n%i ? dummy_prime(n,i-1) : 0 : 1;}
int isprime(int n){return n>1 ? dummy_prime(n,(int)sqrt(n)) : 0;} 

int main(){
	int n;
	while(cin >> n && n){
		while(n>4){
			if(isprime(n) && isprime(n-2)){
				cout << n-2 << " " << n << endl;
				break;
			}
			n--;
		}
	}
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,flg,i,j,p1,q1,fllg,ii;
	while(1){
		cin>>n;
		if(n==0)break;
		for(i=n-1;i>1;i--){
			flg=1;
			if(i!=2&&i%2!=0){
				fllg=1;
				for(j=2;j<i;j++){
					if(i%j==0){
						fllg=0;
						break;
					}
				}
				if(fllg==1){
					ii=i-2;
					for(j=2;j<ii;j++){
						if(ii%j==0){
							fllg=0;
							break;
						}
					}
				}
			}
			if(fllg==1){
				p1=ii;
				q1=i;
				break;
			}
		}
		cout<<p1<<' '<<q1<<endl;
	}
	return 0;
}

C++: // #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

bool primeCheck(int candidate){
	for (int i = 3; i <= sqrt(candidate); i += 2){
		if (candidate%i == 0)
			return false;
	}
	return true;
}

void kakunou(VPII &primeList){
	for (int i = 3; i < 10000; i += 2){
		if (primeCheck(i))
			if (primeCheck(i + 2))
				primeList.push_back(MP(i, i + 2));
	}
}

int main(){
	fastIO;
	VPII primeList;
	int n = 0;

	kakunou(primeList);

	while (cin >> n, n){
		for (int i = n; i >= 5; i--){
			if (count(primeList.begin(), primeList.end(), MP(i - 2, i)) == 1){
				cout << (i - 2) << " " << i << endl;
				break;
			}
		}
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
std::vector<int> twin_primes(int upper) {
	std::vector<bool> suspects(upper + 1, true);
	suspects[0] = suspects[1] = false;
	std::vector<int> res;
	for (auto i = 2; i <= upper; ++i) {
		if (suspects[i]) {
			if (suspects[i - 2])
				res.push_back(i);
			for (auto j = 2 * i; j <= upper; j += i)
				suspects[j] = false;
		}
	}
	return res;
}
int main() {
	int n;
	std::cin >> n;
	auto primes = twin_primes(10000);
	while (n != 0) {
		auto prime = *(std::upper_bound(primes.begin(), primes.end(), n) - 1);
		std::cout << prime - 2 << ' ' << prime << std::endl;
		std::cin >> n;
	}
}

C++: #include<stdio.h>
#include<math.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,	a,	b,	max,	data[10000];
	while(1){
	  a	=	0;
	  b	=	0;
	  max	=	0;
	  scanf("%d",	&n);
	  if(n	==	0) break;
	  for(i	=	n;	i	>=	1;	i--){
		  if(isprime(i)	==	1){
			  a	=	b;
			  b	=	i;
		  }
		  if(a	-	b	==	2)break;
		}
		printf("%d %d\n",	b,	a);
	}
	return	0;
}

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

const int MAX = 10000;
int plist[MAX + 1] = {};

void primeNumber(){
	
	//0 -> prime, 1 -> composite
	
	plist[0] = 1;
	plist[1] = 1;
	
	for(int i = 2; i <= MAX; ++i){
		if(plist[i] == 0){
			int c = i * 2;
			while(c <= MAX){
				plist[c] = 1;
				c += i;
			}
		}
	}
}

int main(){
	int n;
	
	primeNumber();
	
	while(cin >> n, n){
		int k;
		if(n % 2 == 0){
			k = n - 1;
		}else{
			k = n;
		}
		
		while(k >= 3){
			if(plist[k] == 0 && plist[k - 2] == 0){
				cout << k - 2 << " " << k << endl;
				break;
			}
			k -= 2;
		}
	}
	
	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[100];
	scanf("%d",	&n);
	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;
	}
	
		
		
	printf("%d %d\n",	data[max - 1],	data[max]);
	return	0;
}

C++: #include<iostream>
#include<fstream>
#include<vector>
#define N 10000

int gcd(int q1,int p1){
    if(q1%p1==0) return p1;
    return gcd(p1,q1%p1);
}

int sosu(int j){
    if(j<2)return 0;
    if(j==2)return 1;
    if(j%2==0)return 0;
    for(int i=3; i<=j/2; i++){
        if(j%i==0)return 0;
    }
    return 1;
}

int main(){
    std::vector<int> n;
    n.resize(N);
    for(int i=0; i<N; i++){
        std::cin >> n[i];
        if(n[i]==0)break;
    }
    for(int i=0; i<N; i++){
        if(n[i]==0)break;
        for(int j=n[i]; j>5; j--){
            if(sosu(j)&&sosu(j-2))
                if(gcd(j,j-2)==1){
                    std::cout << j-2 << " " << j <<std::endl;
                    break;
                }
            }
        }
    return 0;
}

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

bool isPrime(int n){
	if(n%2 == 0){
		return false;
	}
	for(int i=3; i*i<=n; i+=2){
		if(n%i == 0){
			return false;
		}
	}
	return true;
}

main(){
	while(true){
		int n;
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		// 偶数だったらnを1へらす
		if(n%2 == 0){
			n--;
		}
		
		for(int i=n; i>=4; i-=2){
			if( isPrime(i) && isPrime(i-2) ){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
}