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>
using namespace std;

int main(){
	int prime[10001];
	int i,j,n;
	for(i = 3;i<=10000;i+=2){
		prime[i] = 1;
	}
	prime[2] = 1;
	for(i = 3;i<=100;i+=2){
		if(prime[i] == 1){
			for(j = 3;j<=10000/i;j+=2){
				prime[i*j] = 0;
			}
		}
	}
	while(cin >> n && (n != 0)){
		for(i = n;i>=5;i--){
			if(prime[i] == 1 && prime[i-2] == 1){
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include<algorithm>
#include<functional>
#include<cstdio>
#include<iostream>
using namespace std;
int flg[1000000];
int main(void)
{
	int i,j,k,n,f;
	for(i=2;i<=1000000;i++) flg[i]=1;
	for(i=2;i*i<=1000000;i++){
		if(flg[i]==1){
			for(j=2;j*i<1000000;j++) flg[i*j]=0;
		}
	}
	cin>>n;
	while(n) {
		for(i=n;i>=4;i--) {
			if(flg[i]==1&&flg[i-2]==1) {
				cout<<i-2<<" "<<i<<endl;
				break;
			}
		}
		cin>>n;
	}
}

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[10000];
	scanf("%d",	&n);
	for(i	=	0;	i	<=	n;	i++){
		if(Prime(i)	==	1){
			data[cnt]	=	i;
//			if(data[cnt]	-	data[cnt	-	1]	==	2)max	=	cnt;
			cnt++;
		}	
	}
	for(i	=	1;	i	<=	cnt;	i++){
		if(data[i]	-	data[i	-	1]	==	2)max	=	i;
	}
	
		
	if(max	!=	0)printf("%d %d\n",	data[max - 1],	data[max]);
	return	0;
}

C++: #include <cstdio>
#include <cmath>
#define buf 10000
using namespace std;
int k=0;
int B[buf];
void Answer(int n);
int PrimeNumber(int n);

int main(void){
  int i,n;
  char str[buf];

  for(i=2;i<buf;i++)
    PrimeNumber(i);
  for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
    sscanf(str,"%d",&n);
    if(n==0) break;
    Answer(n);
  }
  return 0;
}

void Answer(int n){
  int i,j;
  for(i=0;i<k;i++){
    if(B[i]>n)
        break;
  }
  for(j=i-1;j>=0;j--){
    if(B[j]-B[j-1]==2){
      printf("%d %d\n",B[j-1],B[j]);
      break;
    }
  }
}

int PrimeNumber(int n){
  int i,c;
  if(n==2){
    B[k]=n;
    k++; return 0;
  }
  if(n<2 || n%2==0)
    return 0;
  c=sqrt(n);
  for(i=3;i<=c;i+=2){
    if(n%i==0)
      return 0;
  }
  B[k]=n;
  k++; return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[10001];
    memset(prime,0,sizeof(prime));
    for(int i=2;i<sqrt(10001);i++){
        if(!prime[i])for(int j=i*2;j<10005;j+=i)prime[j]=1;
    }
    int n;
    while(cin>>n,n){
        for(int i=n;i>2;i--){
            if(!prime[i]&&!prime[i-2]){
                cout<<i-2<<" "<<i<<endl;
                break;
            }
        }
    }
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int lis[10001];
int main(){
    for(int i=2;i<=10000;i++){
        int flg=1;
        for(int j=2;j<=10000;j++){
            if(i%j==0&&i!=j)flg=0;
        }
        lis[i]=flg;
    }
    while(1){
        int a;
        cin>>a;
        if(a==0)break;
        for(int i=a;;a--){
            if(lis[a]&&lis[a-2]){
                cout<<a-2<<' '<<a<<endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
//26

int dp[20000];
signed main(){
	fill(dp, dp+20000, 1);
	dp[0] = dp[1] = 0;
	repi(i,2,10002){
		if(dp[i] == 1)for(int j = 2;i*j <= 10001;j++){
			dp[i*j] = 0;
		}
	}
	
	while(1){
		int n;
		scanf("%lld", &n);
		if(n == 0)break;
		P p = P(3, 5);
		repi(i,5,n+1){
			if(dp[i] == 1 and dp[i-2] == 1)p = P(i-2, i);
		}
		printf("%lld %lld\n", p.fi, p.se);
	}
	//rep(i,15)printf("%lld %lld\n", i, dp[i]);
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[10005];
    memset(prime,0,sizeof(prime));
    for(int i=2;i<sqrt(10005);i++){
        if(!prime[i])for(int j=i*2;j<10005;j+=i)prime[j]=1;
    }
    int num[210],co=0;
    for(int i=3;i<10001;i++){
        if(!prime[i]&&!prime[i+2]){
            num[co]=i;
            co++;
        }
    }
    int n;
    while(cin>>n,n){
        if(num[co-1]<n)cout<<num[co-1]<<" "<<num[co-1]+2<<endl;
        else{
            for(int i=0;i<co;i++){
                if(num[i]>=n&&num[i-1]+2<=n){
                    cout<<num[i-1]<<" "<<num[i-1]+2<<endl;
                    break;
                }
                else if(num[i]>=n){
                    cout<<num[i-2]<<" "<<num[i-2]+2<<endl;
                    break;
                }
            }
        }
    }
}

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

int main()
{
    int n, a, b;
    bool p[10000] = {false};

    for( int i = 2; i < 10000; i++ )
    {
        bool judge = true;
        for( int j = 2; j <= sqrt(i); j++ )
            if( i % j == 0 )
                judge = false;
        if( judge == true )
            p[i] = true;
    }

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

        for( int i = 2; i <= n - 2; i++ )
        {
            if( p[i] == true && p[i+2] == true )
            {
                a = i;
                b = i + 2;
            }
        }
        cout << a << " " << b << endl;
    }
    return 0;
}

C++: /*it will crash due to not much memory
available in the cache1() in my lappy
but got accepted
in UVA ;)*/

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define clear(a) memset(a,0,sizeof(a))
#define N 10000
char a[10002];
void seive(void){
	int k = sqrt(N);
	clear(a);
	a[0]=1;
	a[1]=1;
	int i;
	for(i=2;i<=k;i++){
		if(a[i]==0){
			int j;
			for(j=i+i;j<=N;j+=i){
				a[j]=1;
			}
		}
	}
}

int main(){
    int n,i,j,k;
    seive();
    while(scanf("%d",&n) && n){
        for(i=n;i>=2;i--){
            if(!a[i] && !a[i-2]){
                printf("%d %d\n",i-2,i);
                break;
            }
        }
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
#define MAX (1<<10001)

bool prime[MAX];

int main(){
	int n;
	for(int i=2; i<MAX; i++) prime[i] = true;
	for(int i=2; i<MAX; i++){
		if( prime[i] ){
			for(int j=i+i; j<MAX; j+=i){
				prime[j] = false;
			}
		}
	}
	while( cin >> n, n ){
		for(int i=n; 0<i; i--){
			if( prime[i] && prime[i-2] ){
				cout << i << endl;
				return 0;
			}
		}
	}
}

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

int isprime(int n);

int main()
{
	int i,n,ans;

	while(cin >> n){
		if(!n) break;
		for(i=n; i-2>2; i--){
			if(isprime(i) && isprime(i-2)){
				ans=i;
				break;
			}
		}

		cout << ans-2 << " " << ans << "\n";
	}

	return 0;
}

int isprime(int n)
{
	for(int i=2; i*i<=n; i++)
		if(n%i==0) return 0;
	return 1;
}