#include #include using namespace std; using namespace atcoder; #define rep(i, n) for (int i = 0; i < n; i++) #define ALL(a) a.begin(), a.end() #define ll long long #define pii pair #define pil pair void chmax(ll &x, ll y) { if (x < y) x = y; } ll mp(ll a, ll b, ll m) { if (b == 0) return 1; if (b & 1) return mp(a * a % m, b / 2, m); return a * mp(a, b - 1, m) % m; } void solve() { int n; cin >> n; int nn = n / 3; vector> ans; int x = 0, xx = 0; while (xx <= nn) { const int k = n + xx; int yy = x << 1, yyy = yy * yy; while (yyy <= k) { if (yy == 0 || k % yy > 0) { yyy += (yy++ << 1) | 1; continue; } vector per = {x, yy - x, k / yy - x}; do { ans.push_back({per[0], per[1], per[2]}); } while (next_permutation(ALL(per))); yyy += (yy++ << 1) | 1; } xx += (x++ << 1) | 1; } sort(ALL(ans)); cout << ans.size() << '\n'; for (auto &[x, y, z] : ans) cout << x << ' ' << y << ' ' << z << '\n'; return; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(13); solve(); return 0; }