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 main() {
	int i, k, n;
	int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????????
	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?????\???????????°????´???°??§?????????
			}
		}
	}
	//?´???°??¨fin
	for(;;){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=n;i>=3;i--){//???????????¨????´???°????????????
			if(prime[i] == 1 && prime[i-2] == 1){
				break;
			}
		}
	// 	ans[a]=i; a++;
	// 	ans[a]=i-2; a++;
	// }
	// for(i=0;i<=a;i=i+2){
	// 	printf("%d %d\n",ans[i],ans[i+1]);
	// }
		printf("%d %d\n",i,i-2);
	}
	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?????\???????????°????´???°??§?????????
            }
        }
    }
   while (1) {
        scanf("%d",&n);
        if (n == 0)break;
//        while(scanf("%d", &n) != 0) {
        int p1 = 0,q1 = 0;
        for(i = n;3 <= 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++: #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 v,k;
		while(1){
			scanf("%d",&v);
			if(v==0)break;
			for(k=v;k>=0;k--){
				if(isprime(k)==1 && isprime(k-2)==1){
					printf("%d %d\n",k-2,k);
					break;
				}
			}
		}
		return 0;
	}

C++: #include <cstring>
#include <functional>
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

const int vx[4] = {0, 1, 0, -1}, vy[4] = {1, 0, -1, 0};

int solve(int H, int W, std::string s[]) {
	int ret = 0;
  int sx, sy;
	bool is_searched[21][21];

	std::memset(is_searched, false, sizeof is_searched);

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (s[i][j] == '@') {
        sx = i, sy = j;
        break;
      }
    }
  }

  std::function<int(int, int)> dfs = [&](int x, int y) {
    int res = 0;
    is_searched[x][y] = true;

    for (int i = 0; i < 4; ++i) {
      int nx = x + vx[i], ny = y + vy[i];

      if (0 <= nx && nx < H && 0 <= ny && ny < W &&
          !is_searched[nx][ny] && s[nx][ny] == '.') {

        res += dfs(nx, ny) + 1;
      }
    }

    return res;
  };

  ret = dfs(sx, sy) + 1; // +1 は'@' の分

	return ret;
}

int main() {
	int W, H;
	std::string s[21];

	while(cin >> W >> H, W | H) {
		for(int i = 0; i < H; ++i) {
			cin >> s[i];
		}

		int ans = solve(H, W, s);

		cout << ans << endl;
	}

	return 0;
}

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

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

constexpr bool help_prime(const std::size_t n, const std::size_t m)
{
	return (m * m <= n) ?
        !divisible(n, m) && help_prime(n, m + 1) :
        true;
}

constexpr bool prime(const std::size_t n)
{
	return (n <= 1) ?
        false :
        help_prime(n, 2);
}

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::vector<std::size_t> ns;
    std::size_t n;
    
    while(std::cin >> n, n != 0)
    {
        ns.push_back(n);
    }

    for(const auto a : ns)
    {
        const auto&& t = find_twin_prime(a);
        std::cout << t.first << " " << t.second << std::endl;
    }
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <complex>
using namespace std;

typedef long long ll;

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

bool isPrime(int x){
  if(x == 0 || x == 1) return false;

  for(int i = 2; i * i <= x; i++){
    if(x % i == 0){
      return false;
    }
  }
  return true;
}

int main(){
  int n;

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

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) && 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>

const int MAX_V = 10000;


int main() {
	int i, k, v;
	int sousi[2];
	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) {
		int isprime = prime[v];
		sousi[0] = 0;
		sousi[1] = 0;
		scanf("%d", &v);
		if (v == 0) {
			break;
		}
		for (i = v; i > 2; i--) {
			if (prime[i] == 1 && prime[i - 2] == 1) {
				sousi[0] = i - 2;
				sousi[1] = i;
				break;
			}
		}
		printf("%d %d\n", sousi[0], sousi[1]);
	}	
	return 0;
}

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

const int MAX_V = 1000000;
int prime[MAX_V+1];

int main()
{
	int i, k, v;
	int input;

	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;
			}
		}
	}

	for (i = 0; ; ++i)
	{
		cin >> input;
		if (input == 0) break;

		for (v = input; v != 0; --v)
		{
			if (prime[v] && prime[v - 2])
			{
				cout << v - 2 << " " << v << endl;
				break;
			}
		}
	}

	return 0;
}