#include #if __has_include() #endif using namespace std; #define eb emplace_back #define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__) #define fo(i,...) for(auto[i,i##stop,i##step]=for_range(0,__VA_ARGS__);ivoid pp(const auto&...a){[[maybe_unused]]const char*c="";((o<(a...);} #define entry defpp void main();void main2();}int main(){my::io();my::main();}namespace my{ namespace my{ void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<constexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};} void lin(auto&...a){(cin>>...>>a);} void vin(auto&...a){fo(i,(a.size()&...))(cin>>...>>a[i]);} template>auto&sort(auto&a,F f={}){ranges::sort(a,f);return a;} auto&unique(auto&a){sort(a).erase(ranges::unique(a).begin(),a.end());return a;} templateusing pack_back_t=tuple_element_t>; } namespace my{ templateconcept vectorial=is_base_of_v::value_type>,remove_cvref_t>; templatestruct vec; templatestruct hvec_helper{using type=vec::type>;}; templatestruct hvec_helper<0,T>{using type=T;}; templateusing hvec=hvec_helper::type; templatestruct vec:vector{ using vector::vector; ll size()const{return vector::size();} auto&emplace_back(auto&&...a){vector::emplace_back(std::forward(a)...);return*this;} auto flatten()const{if constexpr(!vectorial)return*this;else{ }} auto unique()const{auto res=flatten();return my::unique(res);} }; templaterequires(sizeof...(A)>=2)vec(const A&...a)->vec>>; } #include namespace my{entry void main(){ LL(N); vecc(N); veca(N); vin(c,a); if(c.unique().size()==1){ if(c[0]=='+'){ pp(N); fo(i,N)pp(format("add a a A[{}]",i+1)); return; } } // p/qで持つ vecres; res.eb(format("add q q 1")); fo(i,N){ if(c[i]=='+'){ // p/q+x=(p+q*x)/q res.eb(format("mul t q A[{}]",i+1)); res.eb(format("add p p t")); } else if(c[i]=='*'){ res.eb(format("mul p p A[{}]",i+1)); } else if(c[i]=='/'){ res.eb(format("mul q q A[{}]",i+1)); } } res.eb(format("div a p q")); pp(res.size()); fe(res,e)pp(e); }}