#include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } ll f(ll x){ ll ans = 0; ll add = 0; while(x){ ll y = x/4; add += x-y*4; x /= 4; ans += x; } return ans+add/3; } void test(){ for(int i = 0; i < 1000; i++) cout << i << ":" << f(i) << ' ' << i/3 << endl; } using T = tuple; void output(vector ans){ cout << ans.size() << endl; for(auto [op, i, j, k]: ans){ if(op == "plus") cout << op << ' ' << i << ' ' << j << ' ' << k << endl; else cout << op << ' ' << i << ' ' << j << endl; } } ll test(int x, vector ans){ vector a(101); a[1] = x; a[2] = 1; for(auto [op, i, j, k]: ans){ if(op == "plus") { a[i] = a[j]+a[k]; }else{ a[i] = a[j]/2; } // print_vector(a); } return a[3]; } vector solve(){ vector ans; ans.push_back({"plus", 1, 2, 1}); // a[1] <- x*(2^32) for(int i = 0; i <= 31; i++){ ans.push_back({"plus", 1, 1, 1}); } // a[4] <- a[1]/4 ans.push_back({"div", 4, 1, -1}); ans.push_back({"div", 4, 4, -1}); for(int i = 1; i < 20; i++){ int idx = i+4; // a[idx] <- a[iidx-1]/4 ans.push_back({"div", idx, idx-1, -1}); ans.push_back({"div", idx, idx, -1}); } // a[3] += a[1]/4 + a[1]/16 + ... for(int i = 0; i < 20; i++){ int idx = i+4; ans.push_back({"plus", 3, 3, idx}); } // a[3]; ans.push_back({"plus", 3, 100, 100}); for(int i = 0; i <= 19; i++){ int idx = i+4; ans.push_back({"plus", 3, 3, idx}); } for(int i = 0; i <= 31; i++){ ans.push_back({"div", 3, 3, -1}); } return ans; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; auto ans = solve(); output(ans); // for(int i = 1; i <= 100; i++){ // ll x = i*1000; // ll y = test(x, ans); // cout << x << ":" << x/3 << ' ' << y << endl; // } }