#include using namespace std; int main() { int x; cin >> x; vector v(x); for (int i = 0; i < x; i++) { v.at(i) = i; } for (int i = 1; i * i < x; i++) { v.at(i * i)--; for (int j = i * i + i; j < x; j += i) { v.at(j) -= 2; } } int d = x; for (int i = 1; i < x; i++) { d = min(d, abs(v.at(i) - v.at(x - i))); } for (int i = 1; i < x; i++) { if (abs(v.at(i) - v.at(x - i)) == d) { cout << i << " " << x - i << endl; } } }