#include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } template ostream& operator << (ostream& os, const vector& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); vector> ans; int n; cin >> n; auto f = [&](ll x, ll y){ ll ng = -1, ok = n; while(ng + 1 < ok){ ll mid = (ok + ng) / 2; ll v = x * y + y * mid + mid * x; (n <= v ? ok : ng) = mid; } return ok; }; vector a = {0, 1, n}; do{ ans.emplace_back(a[0], a[1], a[2]); }while(next_permutation(a.begin(), a.end())); for(int x = 1; x <= n; x++){ for(int y = x; x * y <= n; y++){ int z = f(x, y); ll v = x * y + y * x + x * x; if(v == n){ a = {x, y, z}; sort(a.begin(), a.end()); do{ ans.emplace_back(a[0], a[1], a[2]); }while(next_permutation(a.begin(), a.end())); } } } cout << ans.size() << '\n'; sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); for(auto &&tup : ans){ int A, B, C; tie(A, B, C) = tup; cout << A << " " << B << " " << C << '\n'; } }