Language: C++

#include <bits/stdc++.h>
#ifndef ATCODER_INTERNAL_BITOP_HPP
#define ATCODER_INTERNAL_BITOP_HPP 1
#ifdef _MSC_VER
#include <intrin.h>
#endif
#include<atcoder/all>
using namespace atcoder;
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll big=998244353;

template <ll mod> struct Fp{
    ll x;
    constexpr Fp(ll x=0) noexcept : x ((x%mod+mod)%mod){}
    /*-------ここから演算子-------*/
    constexpr Fp operator-() const noexcept{
        return *this*(-1);
    }
    constexpr Fp operator+()const noexcept{
        return *this;
    }
    constexpr Fp& operator+=(const Fp &a) noexcept{
        if((x+=a.x)>=mod)x-=mod;
        return *this;
    }
    constexpr Fp& operator-=(const Fp &a) noexcept{
        if((x+=mod-a.x)>=mod)x-=mod;
        return *this;
    }
    constexpr Fp& operator*=(const Fp &a) noexcept{
        (x*=a.x)%=mod;
        return *this;
    }
    constexpr Fp& operator/=(const Fp &a) noexcept{
        return (*this)*=a.inv();
    }
    constexpr Fp operator+(const Fp &a)const noexcept{
        Fp res(*this);
        return res+=a;
    }
    constexpr Fp operator-(const Fp &a)const noexcept{
        Fp res(*this);
        return res-=a;
    }
    constexpr Fp operator*(const Fp &a)const noexcept{
        Fp res(*this);
        return res*=a;
    }
    constexpr Fp operator/(const Fp &a)const noexcept{
        Fp res(*this);
        return res/=a;
    }

    constexpr bool operator==(const Fp &a)const noexcept{
        if((*this).x==a.x)return true;
        else return false;
    }
    constexpr bool operator!=(const Fp &a)const noexcept{
        return !((*this)==a);
    }
    constexpr bool operator<(const Fp &a)const noexcept{
        if((*this).x<a.x)return true;
        else return false;
    }
    constexpr bool operator>(const Fp &a)const noexcept{
        if((*this).x>a.x)return true;
        else return false;
    }
    constexpr bool operator<=(const Fp &a)const noexcept{
        return !((*this)>a);
    }
    constexpr bool operator>=(const Fp &a)const noexcept{
        return !((*this)<a);
    }
    /*-------ここまで演算子-------*/

    constexpr Fp pow(const ll &t)const noexcept{
        if(t==0)return (Fp)1;
        if(t%2==0){
            Fp k=pow(t/2);
            return k*k;
        }else{
            if(t>0)return (*this)*pow(t-1);
            else return pow(t+1)/(*this);
        }
    }
    constexpr Fp inv()const noexcept{
        return (Fp)forinv((*this).x,mod).first;
    }


    friend ostream& operator<<(ostream &os,const Fp &m)noexcept{
        os << m.x;
        return os;
   }
    friend istream& operator>>(istream &is,Fp &m)noexcept{
        is >> m.x;
        m.x%=mod;
        if(m.x<0)m.x+=mod;
        return is;
    }

private:
    //Euclidの互除法
    constexpr pair<ll,ll> forinv(ll a,ll b)const noexcept{
        if(b==0)return pair<ll,ll>(1,0);

        pair<ll,ll> ans = forinv(b,a%b);
        pair<ll,ll> t=pair<ll,ll>(ans.second,ans.first-a/b*ans.second);
        return t;
    }
};

using mint=Fp<big>;


struct S{mint a;int size;};
S op(S a,S b){return {a.a+b.a,a.size+b.size};}
S e(){return S{0,0};}
struct F{mint a;mint b;};
S mapping(F f,S a){return {f.a*a.a+f.b*a.size,a.size};}
F co(F f,F g){
    F k;
    k.a=f.a * g.a;
    k.b=f.a*g.b + f.b;
    return k;
}
F id(){return F{1,0};}

int main(){
    int n,q;cin >> n >> q;
    vector<mint> out;
    vector<S> a(n,{0,1});rep(i,n)cin >> a[i].a;
    lazy_segtree<S , op , e , F , mapping , co , id> seg(a);
    rep(i,q){
        int com;cin >> com;
        if(com==0){
            int l,r,b,c;cin >> l >> r >> b >> c;
            seg.apply(l,r,F{b,c});
        }
        else{
            int l,r;cin >> l >> r;
            out.emplace_back(seg.prod(l,r).a);
        }
    }
    rep(i,out.size())cout << out[i] << " \n"[i+1==out.size()];
}
/*
作用fはf(x*y)=f(x)*f(y)になるようにしたい
区間にax+bするだけだと、左辺:ax+ay+b 右辺:ax+ay+2b
*/

Compiler output:
a.cc:7:9: fatal error: atcoder/all: No such file or directory
    7 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.