Language: C++

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const ll INF=1e18;
const ll MOD=998244353;
const ll MAX=200001;
ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(ll i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}


ll COM(ll n,ll k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll powMOD(ll n,ll r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

ll add(ll &x,ll y){
    x+=y;
    x%=MOD;
}
ll divup(ll x,ll y){
    if(x%y==0)return x/y;
    else return x/y+1;
}

signed main(){
    ll n;cin>>n;
    ll sum=0;
    ll a[n];
    REP(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    //dp[k][s]=前からk個みたとき赤がsになる場合の数
    int dp[n+1][sum+1];
    int ex[n+1][sum+1];
    REP(i,n+1) REP(j,sum+1) dp[i][j]=ex[i][j]=0;
    dp[0][0]=ex[0][0]=1;
    REP(i,n){
        REP(j,sum+1){
            add(dp[i+1][j],dp[i][j]*2);
            add(ex[i+1][j],ex[i][j]);
            if(j-a[i]>=0){
                add(dp[i+1][j],dp[i][j-a[i]]);
                add(ex[i+1][j],ex[i][j-a[i]]);
            }
        }
    }
    ll ans=powMOD(3,n);
    for(ll i=divup(sum,2);i<=sum;i++){
        ans-=dp[n][i]*3;
        ans%=MOD;
    }
    if(sum%2==0)ans+=ex[n][sum/2]*3%MOD;
    ans%=MOD;
    if(ans<0)ans+=MOD;
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'long long int add(long long int&, long long int)':
a.cc:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
   61 | }
      | ^
a.cc: In function 'int main()':
a.cc:82:26: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'int'
   82 |             add(dp[i+1][j],dp[i][j]*2);
      |                 ~~~~~~~~~^
a.cc:58:12: note:   initializing argument 1 of 'long long int add(long long int&, long long int)'
   58 | ll add(ll &x,ll y){
      |            ^
a.cc:83:26: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'int'
   83 |             add(ex[i+1][j],ex[i][j]);
      |                 ~~~~~~~~~^
a.cc:58:12: note:   initializing argument 1 of 'long long int add(long long int&, long long int)'
   58 | ll add(ll &x,ll y){
      |            ^
a.cc:85:30: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'int'
   85 |                 add(dp[i+1][j],dp[i][j-a[i]]);
      |                     ~~~~~~~~~^
a.cc:58:12: note:   initializing argument 1 of 'long long int add(long long int&, long long int)'
   58 | ll add(ll &x,ll y){
      |            ^
a.cc:86:30: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'int'
   86 |                 add(ex[i+1][j],ex[i][j-a[i]]);
      |                     ~~~~~~~~~^
a.cc:58:12: note:   initializing argument 1 of 'long long int add(long long int&, long long int)'
   58 | ll add(ll &x,ll y){
      |            ^
a.cc: In function 'long long int powMOD(long long int, long long int)':
a.cc:56:1: warning: control reaches end of non-void function [-Wreturn-type]
   56 | }
      | ^