#include #include using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=20000000; 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; } ll left=j+1,right=n+10; while (right-left>1) { ll mid=(right+left)/2; if (i*j+j*mid+i*mid>n) { right=mid; }else{ left=mid; } } if (i*j+i*left+j*left==n) { a.push_back(i),b.push_back(j),c.push_back(left); } } } 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; } }