Language: C++

#include<bits/stdc++.h>

int main(){
    constexpr long long mod=998244353;
    int N,S;std::cin>>N>>S;
    using ll = long long;
    std::vector<std::vector<ll[3]>> dp(N+1,std::vector<ll[3]>(S+1));
    std::vector<int> A(N);
    for(int i=0;i<N;++i) std::cin>>A[i];
    dp[0][0][0]=1;
    for(int i=0;i<N;++i) for(int s=0;s<=S;++s){
        dp[i+1][s][0]=dp[i][s][0];
        dp[i+1][s][1]=dp[i][s][1];
        dp[i+1][s][2]=dp[i][s][2];
        if(s>=A[i]){
            dp[i+1][s][1]+=(i+1)*dp[i][s-A[i]][0]+dp[i][s-A[i]][1];
            dp[i+1][s][2]+=(N-i)*(dp[i][s-A[i]][1]+dp[i][s-A[i]][0]);
        }
        for(int j=0;j<3;++j) dp[i][s][j]%=mod;
    }
    std::cout<<dp[N][S][2]<<std::endl;
}

Compiler output:
In file included from /usr/include/c++/14/vector:65,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_uninitialized.h: In instantiation of 'constexpr bool std::__check_constructible() [with _ValueType = long long int [3]; _Tp = const long long int (&)[3]]':
/usr/include/c++/14/bits/stl_uninitialized.h:182:4:   required from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const long long int (*)[3], vector<long long int [3]> >; _ForwardIterator = long long int (*)[3]]'
  182 |         = _GLIBCXX_USE_ASSIGN_FOR_INIT(_ValueType2, _From);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:373:37:   required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const long long int (*)[3], vector<long long int [3]> >; _ForwardIterator = long long int (*)[3]; _Tp = long long int [3]]'
  373 |       return std::uninitialized_copy(__first, __last, __result);
      |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:606:31:   required from 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int [3]; _Alloc = std::allocator<long long int [3]>]'
  606 |           std::__uninitialized_copy_a(__x.begin(), __x.end(),
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
  607 |                                       this->_M_impl._M_start,
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~
  608 |                                       _M_get_Tp_allocator());
      |                                       ~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_construct.h:119:7:   required from 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = vector<long long int [3]>; _Args = {const vector<long long int [3], allocator<long long int [3]> >&}]'
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:267:21:   required from '_ForwardIterator std::__do_uninit_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = vector<long long int [3]>*; _Size = long unsigned int; _Tp = vector<long long int [3]>]'
  267 |             std::_Construct(std::__addressof(*__cur), __x);
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:284:34:   required from 'static _ForwardIterator std::__uninitialized_fill_n<_TrivialValueType>::__uninit_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = std::vector<long long int [3]>*; _Size = long unsigned int; _Tp = std::vector<long long int [3]>; bool _TrivialValueType = false]'
  284 |         { return std::__do_uninit_fill_n(__first, __n, __x); }
      |                  ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:327:17:   required from '_ForwardIterator std::uninitialized_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = vector<long long int [3]>*; _Size = long unsigned int; _Tp = vector<long long int [3]>]'
  326 |       return __uninitialized_fill_n<__can_fill>::
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  327 |         __uninit_fill_n(__first, __n, __x);
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:472:39:   required from '_ForwardIterator std::__uninitialized_fill_n_a(_ForwardIterator, _Size, const _Tp&, allocator<_Tp2>&) [with _ForwardIterator = vector<long long int [3]>*; _Size = long unsigned int; _Tp = vector<long long int [3]>; _Tp2 = vector<long long int [3]>]'
  472 |       return std::uninitialized_fill_n(__first, __n, __x);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1709:33:   required from 'void std::vector<_Tp, _Alloc>::_M_fill_initialize(size_type, const value_type&) [with _Tp = std::vector<long long int [3]>; _Alloc = std::allocator<std::vector<long long int [3]> >; size_type = long unsigned int; value_type = std::vector<long long int [3]>]'
 1709 |           std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1710 |                                         _M_get_Tp_allocator());
      |                                         ~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:572:9:   required from 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<long long int [3]>; _Alloc = std::allocator<std::vector<long long int [3]> >; size_type = long unsigned int; value_type = std::vector<long long int [3]>; allocator_type = std::allocator<std::vector<long long int [3]> >]'
  572 |       { _M_fill_initialize(__n, __value); }
      |         ^~~~~~~~~~~~~~~~~~
a.cc:7:67:   required from here
    7 |     std::vector<std::vector<ll[3]>> dp(N+1,std::vector<ll[3]>(S+1));
      |                                                                   ^
/usr/include/c++/14/bits/stl_uninitialized.h:90:56: error: static assertion failed: result type must be constructible from input type
   90 |       static_assert(is_constructible<_ValueType, _Tp>::value,
      |                                                        ^~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:90:56: note: 'std::integral_constant<bool, false>::value' evaluates to false