#define _USE_MATH_DEFINES #include #ifdef LOC #include "debuglib.h" #else #define deb(...) #define DBP(...) #endif using namespace std; using ll = long long; using Vi = vector; using Pii = pair; #define pb push_back #define mp make_pair #define x first #define y second #define rep(i, b, e) for (int i = (b); i < (e); i++) #define each(a, x) for (auto& a : (x)) #define all(x) (x).begin(), (x).end() #define sz(x) int((x).size()) int uplg(int n) { return 32-__builtin_clz(n); } int uplg(ll n) { return 64-__builtin_clzll(n); } int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(18); vector cnt(50); cnt[0] = 1; int days = 0; while (*max_element(all(cnt)) < ll(1e18)+50) { auto prv = cnt; rep(i, 0, sz(cnt)) { if (i > 0) cnt[i] += prv[i-1]; if (i+1 < sz(cnt)) cnt[i] += prv[i+1]; } days++; } ll n; cin >> n; vector cut, harv; rep(i, 0, 3500) { rep(j, 0, 50) { cut.pb({i*2, j}); } } Vi used(sz(cnt)); while (n > 0) { int best = -1; rep(i, 0, sz(cnt)) if (cnt[i] <= n && (best == -1 || cnt[best] < cnt[i])) best = i; assert(best != -1); n -= cnt[best]; harv.pb({ used[best]*2, best }); used[best]++; } assert(sz(cut) <= ll(2e5)); assert(sz(harv) <= ll(1e4)); cout << sz(cut) << '\n'; each(e, cut) cout << e.x << ' ' << e.y << ' ' << (e.y == 0 ? 1 : 0) << '\n'; cout << sz(harv) << ' ' << days << '\n'; each(e, harv) cout << e.x << ' ' << e.y << '\n'; return 0; }