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<iostream>
#include<algorithm>
using namespace std;

int main(){
    // preparation
    bool nonprime[10001] = {};
    nonprime[0] = nonprime[1] = true;
    for(int i = 2; i < 10001; i++){
        if(!nonprime[i]){
            for(int j = i+i; j < 10001; j += i){
                nonprime[j] = true;
            }
        }
    }

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

        int large;
        for(large = n; ; large--){
            if(!nonprime[large] && !nonprime[large-2])  break;
        }

        cout << large-2 << " " << large << endl;
    }

    return 0;
}

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

using namespace std;

bool prime(int x){
 if(x==2)return true;
 if(x==3)return true;
 if(x==5)return true;
 if(x % 2 == 0)return false;
 for(int i = 3;i < x;i+=2)
  if(x % i == 0)return false;
 return true;
}

int main(){
 int n;
 while(cin >> n, n){
  for(int i = n-2;i >= 0;i--){
  if(prime(i) && prime(i + 2)){
   cout << i << " " << i+2<< endl;
  break;
  }
 }
 }
 return 0;
}

C++: #include<iostream>
#include<set>
using namespace std;
set<int>prime;
int main(){
	prime.insert(2);
	for(int i=3;i<15000;i++){
		for(int j=2;j*j<=i;j++){
			if(i%j==0)goto fail;
		}
		prime.insert(i);
		fail:;
	}
	int x;
	while(cin>>x && x){
		set<int>::iterator itr=--prime.upper_bound(x);
		while(*itr-*--itr!=2);
		cout<<*--itr<<" "<<*++itr<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int prime(int n, int k = 2)
{
    if(n < k * k) { return 1; }
    
    if(n % k == 0) { return 0; }
    
    return prime(n, k + 1);
}

int solve(int n)
{
    for(int i = n; i >= 3; i--)
    {
        if(prime(i) * prime(i - 2))
        {
            return i;
        }
    }
    
    return -1;
}

int main()
{
    int n;
    
    while(true)
    {
        cin >> n;
        
        if(n == 0) { break; }
        
        cout << solve(n) - 2 << ' ' << solve(n) << endl;
    }
    
    return 0;
}

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
	//while(scanf("%d",&n) != 0){
	while(1){
		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>
int isprime(int n){
  for(int i = 2; i * i <= n; i++){
    if(n % i == 0)return 0 ;
  }
  return 1;
}
int main(){
  int n;
  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    for(int i = n; i > 3; i--){
      if(isprime(i) == 1 && isprime(i-2) == 1){
        printf("%d %d\n",i-2,i);
        break;
      }
    }
  }
  return 0;
}

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

using namespace std;

bool prime_check(int N)
{
	if (N == 1) { return false; }

	for (int i = 2; i <= sqrt(N); i++)
	{
		if (N % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	int N[100], I[100], c = 0;

	while (cin >> N[c])
	{
                if(N[c] == -1){ goto END; }

		for (int i = (N[c] - 1); i > 1; i--)
		{
			if (prime_check(i) == true && prime_check(i - 2) == true)
			{
				I[c] = i; goto Exit;
			}
		}
	Exit:;

            c++;
	}

        END:;

        for(int i = 0; i < c; i++)
        {
            cout << I[i - 2] << ' ' << I[i] << endl;
        }

	return 0;
}

C++: #include <iostream>
using namespace std;
bool t[999999] = {false};
int main()
{
	int n, c, i, j, d;
	t[0] = true;
	for (i = 2; i * i <= 999999; i++)
	{
		if (!t[i-1])
		{
			for (j = i+i; j <= 999999; j+=i)
				t[j-1] = true;
		}
	}
	while (cin >> n, n)
	{
		for (i = n; i >= 7; i--)
		{
			if ((!t[i-1]) && (!t[i-3]))
			{
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
}

C++: #include<stdio.h>
const int MAX_X = 10000;
int prime[10000];

int main(){

	int i, k, n;

	int border[10];
	for( i = 2; i <= MAX_X; i++) {
		prime[i] = 1;
	}

	for(i = 2; i*i <= MAX_X; i++){
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_X; k += i){
				prime[k] = 0;
			}
		}
	}

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

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    bool check[10005];
    rep(i,10001){
        check[i] = true;
    }
    check[0] = check[1] = false;
    rep(i,105){
        if(check[i]){
            for(int j = i * i; j < 10001; j += i){
                check[j] = false;
            }
        }
    }

    int n;
    while(cin >> n){
        for(int i = n; i >= 2; i--){
            if(check[i] && check[i - 2]){
                cout << i- 2 << ' ' << i << endl;
                break;
            }
        }
    }
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define size_of(a) (int)(a).size()

int main() {
	vector< int > primes;
	vector< bool > isp(10010, 1);
	
	for_(i,2,10010) {
		if (isp[i]) {
			primes.push_back(i);
			for (int j = 2 * i; j < 10010; j += i) isp[j] = 0;
		}
	}
	
	int n;
	while (cin >> n, n) {
		int p = -1;
		
		for_(i,0,size_of(primes)-1) {
			if (primes[i + 1] <= n && primes[i + 1] - primes[i] == 2) {
				p = primes[i + 1];
			}
		}
		
		cout << p - 2 << " " << p << endl;
	}
}

C++: #include <stdio.h>


#define MYSCAN scanf

int main(void){
	int n, p;
	int flag;
	int i, j;

	while (1){
		MYSCAN("%d", &n);
		if (n == 0){ break; }

		p = 0;
		for (i = n; i > 1; i--){
			flag = 1;
			// iテ」ツ?古ァツエツ?ヲツ閉ーテ」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツδ?」ツつァテ」ツδε」ツつッ
			for (j = i / 2; j > 1; j--){
				if (i % j == 0){
					flag = 0;
					break;
				}
			}

			// iテ」ツ?古ァツエツ?ヲツ閉ーテ」ツ??」ツ?」テ」ツ?淌」ツつ?
			if (flag == 1){
				// テ・ツ??」ツつ暗」ツつ?テ」ツ?、テ・ツケツエテ、ツクツ凝」ツ??」ツ?」テ」ツ?淌」ツつ嘉・ツ?コテ・ツ環?
				if (i == p - 2){
					printf("%d %d\n", i, p);
					break;
				}
				// テ」ツ?敕」ツ??」ツ?佚」ツつε」ツ?ェテ」ツ?凝」ツ?」テ」ツ?淌」ツつ嘉ィツ?ェテ・ツ按?」ツ?古・ツ??」ツ?ォテ」ツ?ェテ」ツつ?
				else{
					p = i;
				}
			}

		}
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n,m[10001];
bool p(int x){
  if(m[x]>=0) return m[x];
  for(int i=2;i*i<=n;i++) {
    if(x%i==0) return m[x]=0;
  }
  return m[x]=1;
}
main() {
  memset(m,-1,sizeof(m));
  while(cin>>n&&n) {
    int mx=5;
    for(int i=2;i<=n-2;i++)if((p(i)&p(i+2)))mx=i;
    printf("%d %d\n",mx,mx+2);
  }
}