#include using namespace std; template std::vector get_min_prime_fact_table(INT n){ std::vector lp(n + 1), P; for (INT i = 2; i <= n; i++){ if (lp[i] == 0){ lp[i] = i; P.push_back(i); } for (INT j = 0; j <= P.size() and P[j] <= lp[i] and i * P[j] <= n; j++) lp[i * P[j]] = P[j]; } return lp; } template std::vector prime_factorize(INT n, std::vector &lp){ vector res(1); int last = 2; while (n != 1){ if (last != lp[n]){ res.push_back(0); last = lp[n]; } n /= lp[n]; res[res.size() - 1]++; } return res; } int main(){ int x; cin >> x; auto lp = get_min_prime_fact_table(x); vector A(x + 1); int mi = 1e9; for (int a = 1; a < x; a++){ auto b = x - a; auto pa = prime_factorize(a, lp); auto pb = prime_factorize(b, lp); int ca = 1, cb = 1; for (const auto &v : pa) ca *= (v + 1); for (const auto &v : pb) cb *= (v + 1); auto s = abs(a - ca - (b - cb)); A[a] = s; mi = min(mi, s); } for (int i = 1; i < x; i++){ if (A[i] == mi){ cout << i << " " << x - i << endl; } } }