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])
	}
}

Python: dplist = [(5, 3), (7, 5), (13, 11), (19, 17), (31, 29), (43, 41), (61, 59), (73, 71), (103, 101), (109, 107), (139, 137), (151, 149), (181, 179), (193, 191), (199, 197), (229, 227), (241, 239), (271, 269), (283, 281), (313, 311), (349, 347), (421, 419), (433, 431), (463, 461), (523, 521), (571, 569), (601, 599), (619, 617), (643, 641), (661, 659), (811, 809), (823, 821), (829, 827), (859, 857), (883, 881), (1021, 1019), (1033, 1031), (1051, 1049), (1063, 1061), (1093, 1091), (1153, 1151), (1231, 1229), (1279, 1277), (1291, 1289), (1303, 1301), (1321, 1319), (1429, 1427), (1453, 1451), (1483, 1481), (1489, 1487), (1609, 1607), (1621, 1619), (1669, 1667), (1699, 1697), (1723, 1721), (1789, 1787), (1873, 1871), (1879, 1877), (1933, 1931), (1951, 1949), (1999, 1997), (2029, 2027), (2083, 2081), (2089, 2087), (2113, 2111), (2131, 2129), (2143, 2141), (2239, 2237), (2269, 2267), (2311, 2309), (2341, 2339), (2383, 2381), (2551, 2549), (2593, 2591), (2659, 2657), (2689, 2687), (2713, 2711), (2731, 2729), (2791, 2789), (2803, 2801), (2971, 2969), (3001, 2999), (3121, 3119), (3169, 3167), (3253, 3251), (3259, 3257), (3301, 3299), (3331, 3329), (3361, 3359), (3373, 3371), (3391, 3389), (3463, 3461), (3469, 3467), (3529, 3527), (3541, 3539), (3559, 3557), (3583, 3581), (3673, 3671), (3769, 3767), (3823, 3821), (3853, 3851), (3919, 3917), (3931, 3929), (4003, 4001), (4021, 4019), (4051, 4049), (4093, 4091), (4129, 4127), (4159, 4157), (4219, 4217), (4231, 4229), (4243, 4241), (4261, 4259), (4273, 4271), (4339, 4337), (4423, 4421), (4483, 4481), (4519, 4517), (4549, 4547), (4639, 4637), (4651, 4649), (4723, 4721), (4789, 4787), (4801, 4799), (4933, 4931), (4969, 4967), (5011, 5009), (5023, 5021), (5101, 5099), (5233, 5231), (5281, 5279), (5419, 5417), (5443, 5441), (5479, 5477), (5503, 5501), (5521, 5519), (5641, 5639), (5653, 5651), (5659, 5657), (5743, 5741), (5851, 5849), (5869, 5867), (5881, 5879), (6091, 6089), (6133, 6131), (6199, 6197), (6271, 6269), (6301, 6299), (6361, 6359), (6451, 6449), (6553, 6551), (6571, 6569), (6661, 6659), (6691, 6689), (6703, 6701), (6763, 6761), (6781, 6779), (6793, 6791), (6829, 6827), (6871, 6869), (6949, 6947), (6961, 6959), (7129, 7127), (7213, 7211), (7309, 7307), (7333, 7331), (7351, 7349), (7459, 7457), (7489, 7487), (7549, 7547), (7561, 7559), (7591, 7589), (7759, 7757), (7879, 7877), (7951, 7949), (8011, 8009), (8089, 8087), (8221, 8219), (8233, 8231), (8293, 8291), (8389, 8387), (8431, 8429), (8539, 8537), (8599, 8597), (8629, 8627), (8821, 8819), (8839, 8837), (8863, 8861), (8971, 8969), (9001, 8999), (9013, 9011), (9043, 9041), (9241, 9239), (9283, 9281), (9343, 9341), (9421, 9419), (9433, 9431), (9439, 9437), (9463, 9461), (9631, 9629), (9679, 9677), (9721, 9719), (9769, 9767), (9859, 9857), (9931, 9929)]

while(True):
    N = int(input())
    if N == 0:
        break
    for i in range(len(dplist)-1, -1, -1):
        if dplist[i][0] <= N:
            print(dplist[i][1], dplist[i][0])
            break

Python: # AOJ 0150 Twin Prime
# Python3 2018.6.17 bal4u

MAX = 10000
SQRT = 100     # sqrt(MAX)

prime = [True for i in range(MAX)]
def sieve():
	for i in range(4, MAX, 2):
		prime[i] = False
	for i in range(3, SQRT, 2):
		if prime[i] is True:
			for j in range(i*i, MAX, i):
				prime[j] = False
sieve()
while True:
	n = int(input())
	if n == 0: break
	if (n & 1) == 0: n -= 1
	while not prime[n] or not prime[n - 2]: n -= 2
	print(n-2, n)

Python: r = 10001
sqrt = int(r**0.5)
p = [1]*r
twin = [0]*r
p[0] = 0
p[1::2] = [0 for x in range(1,r,2)]
for i in range(2,r,2):
	if p[i]:
		p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
		if p[i-2]:
			twin[i] = 1

Python: def prime(N):
    first=[True for i in range(N+1)]
    first[0],first[1]=False,False
    for i in range(2,int((N+1)**0.5)):
        if not first[i]:continue
        for j in range(i*2,N+1,i):first[j]=False
    return [i for i in range(N+1) if first[i]]

prime_number=prime(10000)
while 1:
    n=int(input())
    if n==0:break
    box=0
    for i,j in enumerate(prime_number):
        if j>n:break
        if prime_number[i]-prime_number[i-1]==2:
            box=max(box,prime_number[i])
    print(box-2,box)

Python: from itertools import takewhile
pnum, tmp = [], [i for i in range(2, 10000)]
while tmp[0] < 101:
    v = tmp.pop(0)
    pnum.append(v)
    tmp = list(filter(lambda x: x%v!=0, tmp))
for t in tmp: pnum.append(t)
del pnum[0:2]
while True:
    n = int(input())
    if n==0: break
    prime = list(takewhile(lambda x: x<n, pnum))
    for i in range(len(prime))[:0:-1]:
        if prime[i]-prime[i-1]==2:
            print(prime[i-1], prime[i])
            break

Python: # -*- coding: utf-8 -*-
"""
"""
import sys
from sys import stdin
from bisect import bisect_left
input = stdin.readline


def create_prime_list(limit):
    """ ??¨??????????????????????????§limit?????§????´???°?????????????±???????
    https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
    """
    x = limit**0.5
    primes = []
    nums = [x for x in range(2, limit+1)]
    while nums[0]<=x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = [x for x in nums if x%current_prime != 0]
    primes.extend(nums)
    return primes


def main(args):
    # ??????????´???°?????????
    primes = create_prime_list(10000)
    twin_primes = []
    prev = primes[0]
    for p in primes[1:]:
        if p == prev + 2:
            twin_primes.append([prev, p])
        prev = p

    keys = [x[1] for x in twin_primes]
    while True:
        n = int(input())
        if n == 0:
            break
        r = bisect_left(keys, n)
        print(*twin_primes[r-1])


if __name__ == '__main__':
    main(sys.argv[1:])

Python: import math


def prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    else:
        return True


while 1:
    n = int(input())
    if n == 0:
        break

    if n % 2 == 0:
        n -= 1

    for i in range(n, 3, -2):
        if prime(i) and prime(i-2):
            print(i-2, i)
            break

Python: primes = [0, 0] + [1]*9999
for i in range(2, 100):
    for j in range(i*i, 10001, i):
        primes[j] = 0

while True:
    n = int(input())
    if n == 0:
        break
    for i in range(2, n+1)[::-1]:
        if primes[i-2] and primes[i]:
            print(i-2, i)
            break

Python: def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

MAX = 10001
primes = list()
for i in range(MAX):
    primes.append(True)
primes[0] = False
primes[1] = False

tprimes = [False for i in range(MAX)]

for i in range(2, MAX):
    j = i + i
    while j < MAX:
        primes[j] = False
        j = j + i

for i in range(2, MAX):
    if primes[i] and primes[i-2]:
        tprimes[i] = True

while True:
    n = int(input())
    if n == 0:
        break

    for i in range(n, -1, -1):
        if tprimes[i]:
            print(i-2, i)
            break