//g++ t.cpp -o t && t < p.txt //d>p.txt&&t // プログラムの耳と口 #include // 超有能配列秘書 #include // みんな大好きソートと二分探索 #include // きゅーちゃん、だいすき #include // to_string #include // 関数を変数に入れる子 #include // 値の取得・挿入・削除を高速に #include // setの妹 これまた優秀 #include // 乱択さん #include // へびになりたい #include // へびになった シャー #include // #include // using namespace atcoder; // コンパイル重い // g++ t.cpp -o t -I . #define DB cerr<<"D"<; const ll M = 998244353; ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;} ll mod_pow(ll x, ll a, ll m) { ll an = 1; while(a > 0) { if (a&1) an = an * x % m; x = x * x % m; a >>= 1;} return an;} void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template void chmax(T& x, U y) {if (x void chmin(T& x, U y) {if (x>y) x=y;} bool vaild(int x, int y, int hh, int ww){return 0<=x&&x0) res+=a%10, a/=10; return res;} const int up[]={1,-1,0,0}, lf[]={0,0,1,-1}; struct BIT { // 0-index int n; vector v; BIT(int m) : n(m) {v.resize(m);} ll sum(int i) { //cout<<"sum "<=n) return 0; ll res=0; for(; i>=0; i=(i&(i+1))-1) res+=v[i]; res%=M; return res; } ll sum(int a, int b) { return (sum(b) - sum(a-1) + M )% M ; } void add(int i, ll x) {for(;i>n; ll a[n]; for(int i=0;i>a[i]; ll b[n]; copy(a,a+n,b); sort(b,b+n); BIT b1(n),b2(n),c1(n),c2(n); for(int i=0;i