#pragma GCC target("avx2") #pragma GCC optimize("Ofast,unroll-loops") #include #include #define rep(i, n) for (int i = 0; i < n; i++) #define ALL(a) a.begin(), a.end() #define ll long long using namespace std; using namespace atcoder; constexpr int INF = 1e5; int ans1[INF], ans2[INF], ans3[INF]; void solve() { int n; scanf("%d", &n); int nn = n / 3; int cnt = 0; 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 { ans1[cnt] = per[0]; ans2[cnt] = per[1]; ans3[cnt] = per[2]; cnt++; } while (next_permutation(ALL(per))); yyy += (yy++ << 1) | 1; } xx += (x++ << 1) | 1; } printf("%d\n", cnt); rep(i, cnt) printf("%d %d %d\n", ans1[i], ans2[i], ans3[i]); return; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(13); solve(); return 0; }