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 = 3;
        int q1 = 5;
        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 <iostream>
using namespace std;
bool is[10010];

int main(){
  for(int i = 0; i < 10010; i++) is[i] = true;
  is[0]=is[1]=false;
  for(int i = 2; i < 10010; i++){
    if(is[i]){
      for(int j = 2; j*i < 10010; j++){
	is[j*i]=false;
      }
    }
  }
  int n,i;
  while(1){
    cin >> n;
    if(n == 0)break;
    for(i = n; i > 2; i--){
      if(is[i] && is[i-2]) break;
    } 
    cout << i-2 << " " << i << endl;
  }
  return 0;
}

C++: #include<stdio.h>
	int data[100000];
	int main(){
		int n,k,S,q,T,y,cnt=0,zero=0;
		scanf("%d",&n);
		for(k=zero;k<n;k++){
			scanf("%d",&S);
			data[k]=S;
		}
		scanf("%d",&q);
		for(k=zero;k<q;k++){
		     scanf("%d",&T);
		     for(y=zero;y<n;y++){
		     	if(data[y]==T){
		     		cnt++;
		     		break;
		     	}
		     }
		 }
		 printf("%d\n",cnt);
		 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 k,v,a=0,b=0;
    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);
    }
}

C++: #include<stdio.h>
int main(void)
{
    int n,i,flg,j,x,a,flg2;
	
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		while(1)	{
			flg=1;
			for(i=2;i<n;i++){
				if(n%i==0){
					flg=0;
					break;
				}
			}
			
			if(flg==1){
				i=n-2;
				flg2=1;
				for(j=2;j<i;j++){
					if(i%j==0){
						flg2=0;
						break;
					}
				}
			}	
			if(flg==1 && flg2==1){
				break;
			}
			n--;
		}
		
		printf("%d %d\n",i,n);
	}
	return 0;
}

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

#define MAX_N 12000

int prime[MAX_N];
bool is_prime[MAX_N + 1];


void prime_generate(){
	int p = 0;
	for(int i = 0; i <= MAX_N; i++) is_prime[i] = true;

	is_prime[0] = is_prime[1] = false;

	for(int i = 2; i <= MAX_N; i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2 * i; j <= MAX_N; j += i) is_prime[j] = false;
		}
	}
}

void solve(int n){
	int p1 = -1, p2 = -1;

	for(int i = 0; prime[i+1] <= n; i++){
		if(prime[i+1] - prime[i] == 2){
			if(p1 <= prime[i]){
				p1 = prime[i];
			}
			if(p2 <= prime[i+1]){
				p2 = prime[i+1];
			}
		}
	}
	cout << p1 << " " << p2 << endl;
}

int main(){
	prime_generate();

	int n;
	while(cin >> n){
		solve(n);
	}
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n,max,mx;
	int flg[10001];
	while(1) {
		scanf("%d",&n);
		if(n==0) break;
		for(i=2;i<=n;i++) flg[i]=1;
		for(i=2;i*i<=n;i++) {
			if(flg[i]==1) {
				for(j=2;j*i<n;j++) flg[i*j]=0;
			}
		}
		max=-1;
		mx=-1;
		for(i=2;i<n;i++) {
			if(flg[i]==1 && flg[i]==flg[i+2] && i+2<=n) {
				if(max<i) max=i;
				if(mx<i+2) mx=i+2;
			}
		}
		printf("%d %d\n",max,mx);
	}
	return 0;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int ans[10001] = {};
  int z = 1000000;
  dep(i, 10000, 5) {
    int f = 0;
    dep(j, i - 1, 2) {
      if(i % j == 0) {
        f = 1;
        break;
      }
    }
    if(!f) {
      if(z - i == 2) ans[z] = 1;
      z = i;
    }
  }
  int n;
  while(cin >> n) {
    if(!n) return 0;
    dep(i, n, 0) {
      if(ans[i]) {
        cout << i - 2 << " " << i << endl;
        break;
      }
    }
  }
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool isprime (int n){

	if (n == 0 || n == 1){
		return false;
	}else if (n == 2){
		return true;
	}else if (n % 2 == 0){
		return false;
	} // end if
	
	for (int i = 3; i <= sqrt(n); i+= 2){
		if (n % i == 0){
			return false;
		} // end if
	} // end for
		
	return true;
}
int main()
{
//	cut here before submit 
//	freopen ("testcase.twinprime", "r", stdin );
	string str = "";

	while (getline (cin, str ) ){
		int n;
		stringstream ssn(str);
		ssn >> n;
		if (n == 0 ){
			break;
		} // end if
		int i;

		for (i = n; i >= 5; --i){
			if (isprime(i-2) && isprime(i) ){
				cout << (i-2) << ' ' << i << endl;
				break;
			} // end if
		} // end for
	} // end loop
		
	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>
const int MAX_V = 10000;
int prime[MAX_V+1];
int main(){
  int i,k,n,j,i1,i2,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 == 1){
        i1 = 1;
      }else{
        i1 = 0;
      }
      if(isprime2 == 1){
        i2 = 1;
      }else{
        i2 = 0;
      }
      if(i1 == 1 && i2 == 1){ 
        p1 = j;
        q1 = j + 2;
      }
    }
    printf("%d %d\n",p1,q1);
  }
  return 0;
}