# X<2*10**6と小さいので全探索して間に合うのでは X = int(input()) count = [0]*(X+1) # 約数の個数を数えるだけに改造 def divisors_count(n): lower_divisors , upper_divisors = 0, 0 i = 1 while i*i <= n: if n % i == 0: lower_divisors += 1 if i != n // i: upper_divisors += 1 i += 1 return lower_divisors + upper_divisors for x in range(1, X+1): calc = divisors_count(x) count[x] = calc #print(count) ans_list = [] mn = 10**10 for i in range(1, X): j = X-i if i > j: break calc = abs(i-count[i]-j+count[j]) #print('i', i, 'j', j, 'calc', calc) if calc < mn: mn = calc if i != j: ans_list = [(i, j), (j, i)] else: ans_list = [(i, j)] elif calc == mn: if i != j: ans_list.append((i, j)) ans_list.append((j, i)) else: ans_list.append((i, j)) ans_list.sort() #print(mn) #print(ans_list) for i, j in ans_list: print(i, j)