#include #include using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=20000000000000; ll mod=998244353; int main(){ ll n; cin >> n; vectora,b,c; for (ll i = 0; i*i*3=0; j++) { if (i*j*2+j*j>=n) { break; } for (ll k = j+1; k >=0; k++) { ll x=i*j+j*k+i*k; if (x>n) { break; }else if (x==n) { a.push_back(i),b.push_back(j),c.push_back(k); break; } } } } vectoraa,bb,cc; for (ll i = 1; i*i*3 < n; i++) { for (ll j = i+1; j >=0; j++) { if (i*i+i*j*2==n) { aa.push_back(i),bb.push_back(i),cc.push_back(j); break; }else if (i*i+i*j*2>n) { break; } } } vectoraaa,bbb,ccc; for (ll i = 0; i*i*3 < n; i++) { for (ll j = i+1; j >=0; j++) { if (j*j+i*j*2==n) { aaa.push_back(i),bbb.push_back(j),ccc.push_back(j); break; }else if (j*j+i*j*2>n) { break; } } } ll ans=-1; for (ll i = 0; i >=0; i++) { if (i*i*3==n) { ans=i; break; }else if (i*i*3>n) { break; } } ll siz=0; siz+=a.size(); siz*=6; ll zz=aa.size(); zz*=3; siz+=zz; zz=aaa.size(); zz*=3; siz+=zz; if (ans!=-1) { siz++; } cout << siz << endl; for (ll i = 0; i < a.size(); i++) { cout << a[i] << ' ' << b[i] << ' ' << c[i] << endl; cout << a[i] << ' ' << c[i] << ' ' << b[i] << endl; cout << b[i] << ' ' << a[i] << ' ' << c[i] << endl; cout << b[i] << ' ' << c[i] << ' ' << a[i] << endl; cout << c[i] << ' ' << a[i] << ' ' << b[i] << endl; cout << c[i] << ' ' << b[i] << ' ' << a[i] << endl; } for (ll i = 0; i < aa.size(); i++) { cout << aa[i] << ' ' << bb[i] << ' ' << cc[i] << endl; cout << aa[i] << ' ' << cc[i] << ' ' << bb[i] << endl; cout << cc[i] << ' ' << bb[i] << ' ' << aa[i] << endl; } for (ll i = 0; i < aaa.size(); i++) { cout << aaa[i] << ' ' << bbb[i] << ' ' << ccc[i] << endl; cout << bbb[i] << ' ' << aaa[i] << ' ' << bbb[i] << endl; cout << ccc[i] << ' ' << bbb[i] << ' ' << aaa[i] << endl; } if (ans!=-1) { cout << ans << ' ' << ans << ' ' << ans << endl; } }