Language: C++

#include<bits/stdc++.h>
#include <complex>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace  std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 998244353 ;

void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{   ll z = 1;
    while(y > 0)
    {if(y % 2 == 1) z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{   if(n<0 || k<0) return 0;
    if(k>n) return 0;
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
///--//

// Change lazy updates as per requirement
struct data
{
    //Use required attributes
    int val;

    //Default Values
    data() : val(0) {};
    int get_val(){
        return val;
    }
};

struct SegTree
{
    int N;
    vector<data> st;
    vector<bool> cLazy;
    vector<int> lazy;
    vector<int> m_pow;
    vector<int> cof;
    void init(int n)
    {
        N = n;
        st.resize(4 * N + 5);
        cLazy.assign(4 * N + 5, false);
        lazy.assign(4 * N + 5, 0);
        cof.assign(4*N+5,0);
        m_pow.assign(N+5,0);
        m_pow[n]=1;
        for(int i=n-1; i>=1; i--){
            m_pow[i]=mul(m_pow[i+1],10);
        }
    }

    //Write reqd merge functions
    void merge(data &cur, data &l, data &r)
    {
        cur.val=add(l.val,r.val);
    }

    //Handle lazy propagation appriopriately
    void propagate(int node, int L, int R)
    {
        if(L != R)
        {
            cLazy[node*2] = 1;
            cLazy[node*2 + 1] = 1;
            lazy[node*2] = lazy[node];
            lazy[node*2 + 1] = lazy[node];
        }
        st[node].val = mul(cof[node],lazy[node]);
        cLazy[node] = 0;
    }

    void build(int node, int L, int R)
    {
        if(L==R)
        {
            cof[node]=m_pow[L];
            st[node].val = m_pow[L];
            return;
        }
        int M=(L + R)/2;
        build(node*2, L, M);
        build(node*2 + 1, M + 1, R);
        cof[node]=add(cof[node*2],cof[node*2+1]);
        merge(st[node], st[node*2], st[node*2+1]);
    }

    data Query(int node, int L, int R, int i, int j)
    {
        if(cLazy[node])
            propagate(node, L, R);
        if(j<L || i>R)
            return data();
        if(i<=L && R<=j)
            return st[node];
        int M = (L + R)/2;
        data left=Query(node*2, L, M, i, j);
        data right=Query(node*2 + 1, M + 1, R, i, j);
        data cur;
        merge(cur, left, right);
        return cur;
    }


    void Update(int node, int L, int R, int i, int j, int val)
    {
        if(cLazy[node])
            propagate(node, L, R);
        if(j<L || i>R)
            return;
        if(i<=L && R<=j)
        {
            cLazy[node] = 1;
            lazy[node] = val;
            propagate(node, L, R);
            return;
        }
        int M = (L + R)/2;
        Update(node*2, L, M, i, j, val);
        Update(node*2 + 1, M + 1, R, i, j, val);
        merge(st[node], st[node*2], st[node*2 + 1]);
    }


    data query(int l, int r)
    {
        return Query(1, 1, N, l, r);
    }



    void update(int l, int r, int val)
    {
        Update(1, 1, N, l, r, val);
    }
};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen ("output.txt","w",stdout);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * use greater<ll> for ll's
    */

    int n,q; cin>>n>>q;
    SegTree st;
    st.init(n);
    st.build(1,1,n+1);
    while(q--){
        int l,r,d; cin>>l>>r>>d;
        st.update(l,r,d);
        int ans=st.query(1,n).get_val();
        cout<<ans<<endl;
    }
    return 0;


}

Compiler output:
a.cc:78:16: error: template argument 1 is invalid
   78 |     vector<data> st;
      |                ^
a.cc:78:16: error: template argument 2 is invalid
a.cc:98:16: error: reference to 'data' is ambiguous
   98 |     void merge(data &cur, data &l, data &r)
      |                ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:63:8: note:                 'struct data'
   63 | struct data
      |        ^~~~
a.cc:98:16: error: 'data' has not been declared
   98 |     void merge(data &cur, data &l, data &r)
      |                ^~~~
a.cc:98:27: error: reference to 'data' is ambiguous
   98 |     void merge(data &cur, data &l, data &r)
      |                           ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:63:8: note:                 'struct data'
   63 | struct data
      |        ^~~~
a.cc:98:27: error: 'data' has not been declared
   98 |     void merge(data &cur, data &l, data &r)
      |                           ^~~~
a.cc:98:36: error: reference to 'data' is ambiguous
   98 |     void merge(data &cur, data &l, data &r)
      |                                    ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:63:8: note:                 'struct data'
   63 | struct data
      |        ^~~~
a.cc:98:36: error: 'data' has not been declared
   98 |     void merge(data &cur, data &l, data &r)
      |                                    ^~~~
a.cc:132:5: error: reference to 'data' is ambiguous
  132 |     data Query(int node, int L, int R, int i, int j)
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:63:8: note:                 'struct data'
   63 | struct data
      |        ^~~~
a.cc:169:5: error: reference to 'data' is ambiguous
  169 |     data query(int l, int r)
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:63:8: note:                 'struct data'
   63 | struct data
      |        ^~~~
a.cc: In member function 'void SegTree::init(int)':
a.cc:86:12: error: request for member 'resize' in '((SegTree*)this)->SegTree::st', which is of non-class type 'int'
   86 |         st.resize(4 * N + 5);
      |            ^~~~~~
a.cc: In member function 'void SegTree::merge(int&, int&, int&)':
a.cc:100:13: error: request for member 'val' in 'cur', which is of non-class type 'int'
  100 |         cur.val=add(l.val,r.val);
      |             ^~~
a.cc:100:23: error: request for member 'val' in 'l', which is of non-class type 'int'
  100 |         cur.val=add(l.val,r.val);
      |                       ^~~
a.cc:100:29: error: request for member 'val' in 'r', which is of non-class type 'int'
  100 |         cur.val=add(l.val,r.val);
      |                             ^~~
a.cc: In member function 'void SegTree::propagate(int, int, int)':
a.cc:113:11: error: invalid types 'int[int]' for array subscript
  113 |         st[node].val = mul(cof[node],lazy[node]);
      |           ^
a.cc: In member function 'void SegTree::build(int, int, int)':
a.cc:122:15: error: invalid types 'int[int]' for array subscript
  122 |             st[node].val = m_pow[L];
      |               ^
a.cc:129:17: error: invalid types 'int[int]' for array subscript
  129 |         merge(st[node], st[node*2], st[node*2+1]);
      |                 ^
a.cc:129:27: error: invalid types 'int[int]' for array subscript
  129 |         merge(st[node], st[node*2], st[node*2+1]);
      |                           ^
a.cc:129:39: error: invalid types 'int[int]' for array subscript
  129 |         merge(st[node], st[node*2], st[node*2+1]);
      |                                       ^
a.cc: In member function 'void SegTree::Update(int, int, int, int, int, int)':
a.cc:165:17: error: invalid types 'int[int]' for array subscript
  165 |         merge(st[node], st[node*2], st[node*2 + 1]);
      |                 ^
a.cc:165:27: error: invalid types 'int[int]' for array subscript
  165 |         merge(st[node], st[node*2], st[node*2 + 1]);
      |                           ^
a.cc:165:39: error: invalid types 'int[int]' for array subscript
  165 |         merge(st[node], st[node*2], st[node*2 + 1]);
      |                                       ^
a.cc: In function 'int32_t main()':
a.cc:199:20: error: 'struct SegTree' has no member named 'query'
  199 |         int ans=st.query(1,n).get_val();
      |                    ^~~~~