#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair P; constexpr int INF = 1e9; vector divisor(long long n){ vector res; for(long long i = 1; i*i <= n; i++){ if(n%i==0){ res.push_back(i); if(n/i != i)res.push_back(n/i); } } return res; } int main(){ int x; cin >> x; set

st; int mi = INF; for (int a = 1; a + a <= x; a++) { int b = x - a; auto d1 = divisor(a); auto d2 = divisor(b); int f1 = a - d1.size(), f2 = b - d2.size(); int v = abs(f1 - f2); if (v < mi) mi = v; } vector

res1, res2; for (int a = 1; a + a <= x; a++) { int b = x - a; auto d1 = divisor(a); auto d2 = divisor(b); int f1 = a - d1.size(), f2 = b - d2.size(); int v = abs(f1 - f2); if (v == mi) { res1.emplace_back(make_pair(a, b)); res2.emplace_back(make_pair(b, a)); } } reverse(res2.begin(), res2.end()); for (auto e : res1) { printf("%d %d\n", e.first, e.second); } for (auto e : res2) { printf("%d %d\n", e.first, e.second); } return 0; }