criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){

  int N;
  vector<int> S;

  cin >> N;
  S.reserve(N);
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    char c;
    cin >> c;
    sum += c=='#' ? 1 : 0;//#の数を数える
    S.push_back(sum);
  }

  int minimum = N;
  for (int i = 0; i < N; ++i) {
    int a = S[i] + (N-i-1-(S[N-1]-S[i]));
    if(a<minimum) minimum = a;
  }

  if (minimum<0) minimum = N;
  int a = S[N-1];
  int b = N-S[N-1];
  minimum = min({a,b,minimum});

  cout << minimum << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   30 |   minimum = min({a,b,minimum});
      |             ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin >> N >> S;
  int wh = 0;
  bool jud = false;
  for(int i=0;i<N;i++){
    if(S[i] == '#'){
      for(int j=i;j<N;j++){
        if(S[j] =='.') wh++;
      }
      break;
    }
  }
  int bl = 0;
  reverse(S.begin(), S.end());
  for(int i=0;i<N;i++){
    if(S[i] =='.'){
      for(int j=i,j<N;j++){
        if(S[j] =='#') bl++;
      }
      break;
    }
  }
  cout << min(wh, bl) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:20: error: expected ';' before '<' token
   21 |       for(int j=i,j<N;j++){
      |                    ^
      |                    ;
a.cc:21:20: error: expected primary-expression before '<' token
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vi b;
    b.resize(N);

    int num = 0;
    vi c;
    c.resize(N + 1);
    c[0] = 0;
    vi d;
    d.resize(N + 1);
    d[0] = 0;
    REP(i, N)
    {
        if (S[i] == '.')
        {
            b[i] = false;
            c[i + 1] = c[i] + 1;
            d[i + 1] = d[i];
        }
        else
        {
            b[i] = true;
            num++;
            c[i + 1] = c[i];
            d[i + 1] = d[i] + 1;
        }
    }
    int ans = num;
    int tmp = INF;
    REP(i, N - 1)
    {
        if (b[i] and !b[i + 1])
        {
            tmp = c[N] - c[i];
            break;
        }
    }
    chmin(ans, tmp);
    int tmp = INF;
    REP(i, N - 1)
    {
        if (b[N - i - 1] and !b[N - 1])
        {
            tmp = d[N - i];
            break;
        }
    }

    chmin(ans, tmp);

    cout << ans << endl;

    // system("pause");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:9: error: redeclaration of 'll tmp'
   79 |     int tmp = INF;
      |         ^~~
a.cc:69:9: note: 'll tmp' previously declared here
   69 |     int tmp = INF;
      |         ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e5+5;
string s; 
int preB[N],sufW[N];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>s;
	// ....### 
	int len=s.length;
	for(int i=0;s[i];i++){
		if(i==0)	preB[i]=(s[i]=='#')
		else	pre[i]=pre[i-1]+ (s[i]=='#');
	} 
	for(int i=len-1;i>=0;i--)	sufW[i]=sufW[i+1]+(s[i]=='.');
	
	int res=1e9;
	for(int i=0;i<len;i++)	res=min(res,preB[i]+sufW[i+1]);
	res=min(res,sufW[0]);
	cout<<res<<'\n';
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:19: error: cannot convert 'std::__cxx11::basic_string<char>::length' from type 'std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept' {aka 'long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept'} to type 'int'
   12 |         int len=s.length;
      |                   ^~~~~~
a.cc:14:52: error: expected ';' before 'else'
   14 |                 if(i==0)        preB[i]=(s[i]=='#')
      |                                                    ^
      |                                                    ;
   15 |                 else    pre[i]=pre[i-1]+ (s[i]=='#');
      |                 ~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define MIN(a,b) ((a) < (b) ? (a) : (b))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  char *s = (char *) calloc (n + 1, sizeof (char));
  scanf ("%s", s);
  i32 w = 0;
  for (i32 i = 0; i < n; ++i) {
    if (s[i] == '.') {
      w++;
    }
  }
  i32 min = MIN(n - w, w);
  i32 b = 0;
  for (i32 i = 0; i < n; ++i) {
    if (s[i] == '.') {
      w--;
    } else {
      b++;
    }
    min = MIN(min, b + w);
  }
  printf ("%" PRIi32 "\n", min);
}

int main (void) {
  run();
  return 0;
}
220x218x

Compiler output:
main.c:38:1: error: invalid suffix "x218x" on integer constant
   38 | 220x218x
      | ^~~~~~~~
main.c:38:1: error: expected identifier or '(' before numeric constant
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

using namespace std;

int main() {
int N;
string S;
cin >> N;
cin >> S;
int count=0;
for (int i = 0; i < N-1; ++i){
if(S[i]=="#" && S[i+1]==".") count++;
}
cout << count << endl;
return 0;








}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:8: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   43 | if(S[i]=="#" && S[i+1]==".") count++;
a.cc:43:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   43 | if(S[i]=="#" && S[i+1]==".") count++;
Language: C++


import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int[] sum1 = new int[n + 1], sum2 = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum1[i] = sum1[i - 1] + (s.charAt(n - i) == '#' ? 0 : 1);
            sum2[i] = sum2[i - 1] + (s.charAt(i - 1) == '.' ? 0 : 1);
        }

        debug(sum1, sum2);

        int ans = 2 * n;
        for (int i = 0; i <= n; i++) {
            ans = Math.min(ans, sum1[i] + sum2[n - i]);
        }
        System.out.println(ans);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Arrays;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
Language: C++

#include <iostream>
#using namespace std;

int main(void){
    int a;
    cin>>a;
    char b;
    int counter=0,flag=0;
    int counter_b=0
    for(int i=0;i<a;i++){
        cin>>b
        if(flag==1 && b=="."){
            counter += 1;
            continue;
        }
        if(flag==1 && b=="#"){
            counter_b += 1;
            continue;
        }
        if(flag==0 && b=="#"){
            flag = 1;
        }
    }
    if(counter_b<counter){
        counter = counter_b;
    }
    cout << counter << '\n';
}


Compiler output:
a.cc:2:2: error: invalid preprocessing directive #using
    2 | #using namespace std;
      |  ^~~~~
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |     cin>>a;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:10:5: error: expected ',' or ';' before 'for'
   10 |     for(int i=0;i<a;i++){
      |     ^~~
a.cc:10:17: error: 'i' was not declared in this scope
   10 |     for(int i=0;i<a;i++){
      |                 ^
a.cc:27:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |     cout << counter << '\n';
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

N = input()
S = raw_input()
flag1 = 0
a = 0
count = [0,0]
count2 = []
count3 = []
for c in S:
	if(c == "#"):
		count[0] += 1
		if(flag1 == 1):
			flag1 = 0
			count2.append(count[0])
			count3.append(count[1])
	else:
		count[1] += 1
		flag1 = 0
countf = []
for i in range(len(count2)):
	countf.append(count2[i] + count[1] - count3[i])
countf.append(N - count[0])
countf.append(N - count[1])
print(min(countf))

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = input()
      | ^
Language: C

#include <bits/stdc++.h>

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<typename T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<typename T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<typename T> T anti(const T &a, const T &b){ return a == -1 || b == -1 ? -1 : ant(a, b); }
template<typename T> T onti(const T &a, const T &b){ return a == -1 ? b : b == -1 ? a : ont(a, b); }
template<typename T> T rng(const T &a, const T &b){ return a > b ? a - b : b - a; }
template<typename T> T &th(T &a, const T &b, T (*f)(const T &l, const T &r)){ return a = f(a, b); }
#define ANTH(a, b) th(a, b, ant)
#define ONTH(a, b) th(a, b, ont)

template<typename T> T make_v(T val){ return val; }
template<typename... Ts> auto make_v(size_t n, Ts... ts){ return std::vector<decltype(make_v(ts...))>(n, make_v(ts...)); }

int main(){
	int n;
	char S[212345];
	scanf("%d%s", &n, &S);

	int count = 0;
	for(int i = 0; i < n; ++i) count += S[i] == '.';

	int ans = count;
	for(int i = 0; i < n; ++i){
		if(S[i] == '#') ++count;
		else --count;
		ONTH(ans, count);
	}

	printf("%d\n", ans);
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define x first
#define y second
#define tm (tl + tr) / 2
#define Point pair<int, int>
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int inf = 1e15;
const int mod = (1e9) + 7;

mt19937 random(16783849);
int randlr(int l, int r) {
    return random() % (r - l + 1) + l;
}

signed main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);

    int n;
    string s;
    cin >> n >> s;

    vector<int> pref(n + 1);
    vector<int> suff(n + 1);

    for (int i = 0; i < n; i ++) {
        pref[i + 1] = pref[i] + (s[i] == '#');
    }

    for (int i = n - 1; i > -1; i--) {
        suff[i] = suff[i + 1] + (s[i] == '#');
    }

    int answ = inf;
    for (int i = 0; i <= n; i ++) {
        answ = min(answ, pref[i] + (n - i - suff[i]));
    }

    cout << answ;

    return 0;
}


Compiler output:
a.cc:15:15: error: 'std::mt19937 random' redeclared as different kind of entity
   15 | mt19937 random(16783849);
      |               ^
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:521:17: note: previous declaration 'long int random()'
  521 | extern long int random (void) __THROW;
      |                 ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

long long n;
string s;

int solve();

int main() {
  cin >> n >> s;

  cout << solve() << endl;
  return 0;
}

int solve() {
  int cnt = 0;
  for(int i = 0; i < n; ++i)
    if(s[i] == '.') ++cnt;
  if(cnt == n) return 0;
  return min(cnt, n - cnt);
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:21:13: error: no matching function for call to 'min(int&, long long int)'
   21 |   return min(cnt, n - cnt);
      |          ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:21:13: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   21 |   return min(cnt, n - cnt);
      |          ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:21:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |   return min(cnt, n - cnt);
      |          ~~~^~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const long long int MOD=998244353;

int main()
{
    int N;
    if (scanf("%d", &N)){}
    vector<int> A(N+1);
    for(int i = 1; i < N+1; i++) if (scanf("%d", &A[i])) {}
    A[0] = 0;

    int sum=0;
    for(int i = 0; i < N+1; i++) sum += A[i];

    long long dp[N + 1][sum + 1];
    memset(&dp, 0, sizeof(dp[0][0])*(N+1)*(sum+1));

    dp[0][0] = 1;
    for(int i = 1; i < N+1; i++)
    {
        for(int j = 0; j < sum + 1; j++)
        {
            if (j - A[i] >= 0) {
                dp[i][j] += dp[i-1][j - A[i]];
                dp[i][j] %= MOD;
            }
            dp[i][j] += dp[i-1][j]*2;
            dp[i][j] %= MOD;
        }
    }
    long long half = 0;
    if (sum%2 == 0){
        long long dp2[N+1][sum+1];
        memset(&dp2, 0, sizeof(dp2[0][0])*(N+1)*(sum+1));
        dp2[0][0] = 1;
        for(int i = 1; i <= N; i++)
        {
            for(int j = 0; j <= sum; j++)
            {
                dp2[i][j] += dp2[i-1][j];
                dp2[i][j] %= MOD;
                if (j - A[i] >= 0){
                    dp2[i][j] += dp2[i-1][j - A[i]];
                    dp[i][j] %= MOD;
                }
                // printf("%lld\n", dp2[i][j]);
            }
        }
        half = dp2[N][sum/2];
        // printf("aa%d %d %d\n", half, N, sum/2);
    }

    long long ans=1;
    for (int i = 0; i < N; i++)
    {
        ans = ans * 3 % MOD;
    }
    for(int j = 0; j <= sum; j++)
    {
        if (j*2 >= sum ) {
            ans -= 3LL * dp[N][j];
        }
    }
    // printf("\n**************\n");

    // printf("**************\n"); 
    // printf("%lld\n", ans);
    // printf("%lld\n", ans);
    ans += 3LL*half;
    // printf("%lld\n", ans);
    ans %= MOD;

    if (ans < 0) ans = (MOD + ans) % MOD;

    printf("%lld\n", ans);
    return 0 
}



Compiler output:
a.cc: In function 'int main()':
a.cc:81:13: error: expected ';' before '}' token
   81 |     return 0
      |             ^
      |             ;
   82 | }
      | ~
Language: Java

import java.math.*; 
import java.util.*; 

public class AtCoder_tenka1_2019_d {

	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in) ;
		int n = in.nextInt()   ;
		int[] a  = new int[n]  ; 
		long mod = 998244353   ;
		long S = 0;
				
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt() ;
			S += (long) a[i] ;
			
		}
		
			
		long[] s2     = new long[301] ;
		long[] s3     = new long[301] ;
        s2[2] = 1 ;
		s3[3] = 1 ;
        
		for(int i=3;i<=300;i++){
			s2[i] = (1 + 2 * s2[i-1]) % mod ; 	
		}
			
		for(int i=4;i<=300;i++){
			s3[i] = (s2[i-1] + 3 * s3[i-1]) % mod ;
		}
				    

		long[] d1  = new long[90001] ;
		long[] d2  = new long[90001] ;
		
		for(int x :a) {
			for(int i=90000;i>=0;i--) {
		        if(d2[i] > 0) {
		            d2[i+x] = (d2[i+x] + 2 * d2[i]) % mod ;
		        }    		
			}
			
			for(int i=90000;i>=0;i--) {
		        if(d1[i] > 0) {
		            d1[i+x]  = (d1[i+x] + d1[i]) % mod    ;
		            d2[i+x]  = (d2[i+x] + d1[i]) % mod    ;
			    }
			}
			
		    d1[x] = (d1[x] + 1) % mod ;       
		    
		}
		    
		   
		
		long count = 0 ;

		for(int i=1; i <= (int) S / 2;i++){
			count = (count+d2[i]) % mod ;
		}
		
		System.out.println(6*(s3[n]-count+mod) % mod) ;
    }
}


Compiler output:
Main.java:4: error: class AtCoder_tenka1_2019_d is public, should be declared in a file named AtCoder_tenka1_2019_d.java
public class AtCoder_tenka1_2019_d {
       ^
1 error
Language: C++

#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

const ll mod = 998244353;
const int h = 90010;
const int m = 310;

int n;
ll a[mn];
ll sum;

ll dp[m][h];
//iまでで赤がx
ll dp2[m][h];
//赤か青にしか入れない

ll power_ll_p(ll a, ll b, ll p)	//F_pでのべき
{
  if (b > p)
  {
    b %= (p - 1);//位数p-1
  }
  if (b == 0)
  {
    return 1;
  }
  if (b % 2 == 0)
  {
    ll t = power_ll_p(a, b / 2, p);
    return t * t % p;
  }
  else
  {
    return a * power_ll_p(a, b - 1, p) % p;
  }
}

int main()
{
  cin >> n;
  sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
  }

  for (int x = 0; x < sum + 1; x++)
  {
    for (int i = 0; i < m; i++)
    {
      dp[i][x] = 0;
      dp2[i][x] = 0;
    }
  }
  dp[0][0] = 1;
  dp2[0][0] = 1;

  for (int i = 1; i <= n; i++)
  {
    for (int x = 0; x < sum + 1; x++)
    {
      dp[i][x] = 2 * dp[i - 1][x];
      dp[i][x] %= mod;
      dp2[i][x] = dp2[i - 1][x];
      dp2[i][x] %= mod;
      if (x >= a[i - 1])
      {
        dp[i][x] += dp[i - 1][x - a[i - 1]];
        dp[i][x] %= mod;
        dp2[i][x] += dp2[i - 1][x - a[i - 1]];
        dp2[i][x] %= mod;
      }
    }
  }

  ll ans = 0;
  ll ans2 = 0;
  for (int x = (sum + 1) / 2; x < sum + 1; x++)
  {
    ans += dp[n][x];
    ans %= mod;
  }
  if (sum % 2 == 0)
  {
    ans2 = dp2[n][sum / 2];
    ans2 %= mod;
  }
  cout << (power_ll_p(3, n, mod) - 3 * ans + 3 * ans2  + 10 * mod) % mod << "\n";
}

Compiler output:
a.cc:21:6: error: 'mn' was not declared in this scope; did you mean 'yn'?
   21 | ll a[mn];
      |      ^~
      |      yn
a.cc: In function 'int main()':
a.cc:56:12: error: 'a' was not declared in this scope
   56 |     cin >> a[i];
      |            ^
a.cc:79:16: error: 'a' was not declared in this scope
   79 |       if (x >= a[i - 1])
      |                ^
Language: C++

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

static const int dy[4] = {0,1,0,-1};
static const int dx[4] = {1,0,-1,0};

using namespace std;

#define int long long 

const int MOD = 998244353;

int main(){
    int n;
    int a[400]={};
    
    cin >> n;

    for(int i = 0; i < n; i++) cin >> a[i];

    int sum = 0;
    for(int i = 0; i < n; i++) sum += a[i];

    vector<int> dp(sum+1, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        vector<int> nx(sum+1, 0);
        for(int j = 0; j <= sum; j++){
            nx[j] += dp[j]*2%MOD;
            if(j + a[i] <= sum) nx[j + a[i]] += dp[j];
        }
        for(int j = 0; j <= sum; j++){
            dp[j] = nx[j] % MOD;
        }
    }
    
    vector<int> dp2(sum+1, 0);
    dp2[0] = 1;
    for(int i = 0; i < n; i++){
        vector<int> nx(sum+1, 0);
        for(int j = 0; j <= sum; j++){
            nx[j] += dp2[j];
            if(j + a[i] <= sum) nx[j + a[i]] += dp2[j];
        }
        for(int j = 0; j <= sum; j++){
            dp2[j] = nx[j] % MOD;
        }
    }

    int ans = 0;
    if(sum % 2 == 0){
        ans -= dp2[sum/2]*3%MOD;
        ans += MOD;
    }

    for(int j = (sum+1)/2; j <= sum; j++){
        ans += dp[j]*3;
        ans %= MOD;
    }
    ans = MOD - ans;

    int po3 = 1;
    for(int i = 0; i < n; i++) po3 = po3*3%MOD;
    ans += po3;
    ans %= MOD;

    cout << ans << endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

static const int dy[4] = {0,1,0,-1};
static const int dx[4] = {1,0,-1,0};

using namespace std;

#define int long long 

const int MOD = 998244353;

int main(){
    int n;
    int a[400]={};
    
    cin >> n;
    
    for(int i = 0; i < n; i++) cin >> a[i];

    int sum = 0;
    for(int i = 0; i < n; i++) sum += a[i];

    vector<int> dp(sum+1, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        vector<int> nx(sum+1, 0);
        for(int j = 0; j <= sum; j++){
            nx[j] += dp[j]*2%MOD;
            if(j + a[i] <= sum) nx[j + a[i]] += dp[j];
        }
        for(int j = 0; j <= sum; j++){
            dp[j] = nx[j] % MOD;
        }
    }
    
    vector<int> dp2(sum+1, 0);
    dp2[0] = 1;
    for(int i = 0; i < n; i++){
        vector<int> nx(sum+1, 0);
        for(int j = 0; j <= sum; j++){
            nx[j] += dp2[j];
            if(j + a[i] <= sum) nx[j + a[i]] += dp2[j];
        }
        for(int j = 0; j <= sum; j++){
            dp2[j] = nx[j] % MOD;
        }
    }

    int ans = 0;
    if(sum % 2 == 0){
        ans -= dp2[sum/2]*3%MOD;
        ans += MOD;
    }

    for(int j = (sum+1)/2; j <= sum; j++){
        ans += dp[j]*3;
        ans %= MOD;
    }
    ans = MOD - ans;

    int po3 = 1;
    for(int i = 0; i < n; i++) po3 = po3*3%MOD;
    ans += po3;
    ans %= MOD;

    cout << ans << endl;
    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

static const int dy[4] = {0,1,0,-1};
static const int dx[4] = {1,0,-1,0};

using namespace std;
using int = long long;

const int MOD = 998244353;

int main(){
    int n;

    cin >> n;

    for(int i = 0; i < n; i++) cin >> a[i];

    int sum = 0;
    for(int i = 0; i < n; i++) sum += a[i];

    vector<int> dp(sum+1, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        vector<int> nx(sum+1, 0);
        for(int j = 0; j <= sum; j++){
            nx[j] += dp[j]*2%MOD;
            if(j + a[i] <= sum) nx[j + a[i]] += dp[j];
        }
        for(int j = 0; j <= sum; j++){
            dp[j] = nx[j] % MOD;
        }
    }
    
    vector<int> dp2(sum+1, 0);
    dp2[0] = 1;
    for(int i = 0; i < n; i++){
        vector<int> nx(sum+1, 0);
        for(int j = 0; j <= sum; j++){
            nx[j] += dp2[j];
            if(j + a[i] <= sum) nx[j + a[i]] += dp2[j];
        }
        for(int j = 0; j <= sum; j++){
            dp2[j] = nx[j] % MOD;
        }
    }

    int ans = 0;
    if(sum % 2 == 0){
        ans -= dp2[sum/2]*3%MOD;
        ans += MOD;
    }

    for(int j = (sum+1)/2; j <= sum; j++){
        ans += dp[j]*3;
        ans %= MOD;
    }
    ans = MOD - ans;

    int po3 = 1;
    for(int i = 0; i < n; i++) po3 = po3*3%MOD;
    ans += po3;
    ans %= MOD;

    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:23:7: error: expected nested-name-specifier before 'int'
   23 | using int = long long;
      |       ^~~
a.cc: In function 'int main()':
a.cc:32:39: error: 'a' was not declared in this scope
   32 |     for(int i = 0; i < n; i++) cin >> a[i];
      |                                       ^
a.cc:35:39: error: 'a' was not declared in this scope
   35 |     for(int i = 0; i < n; i++) sum += a[i];
      |                                       ^
a.cc:43:20: error: 'a' was not declared in this scope
   43 |             if(j + a[i] <= sum) nx[j + a[i]] += dp[j];
      |                    ^
a.cc:56:20: error: 'a' was not declared in this scope
   56 |             if(j + a[i] <= sum) nx[j + a[i]] += dp2[j];
      |                    ^
Language: C++

  1 #include<bits/stdc++.h>                                                     
  2 #define REP(i,n) for(int i=0;i<(n);i++)
  3 using namespace std;
  4 #define int long long
  5 
  6 const int mod=998244353;
  7 
  8 signed main()
  9 {
 10    int N; cin>>N;
 11    vector<int> a(N);
 12    for(int i=0;i<N;i++) cin>>a[i];
 13 
 14    int S=0;
 15    for(int i=0;i<N;i++) S+=a[i];
 16    vector<vector<int> > dp(N+1,vector<int>(S+1));
 17    vector<vector<int> > dp2(N+1,vector<int>(S+1));
 18 
 19    dp[0][0]=dp2[0][0]=1;
 20    for(int i=0;i<N;i++){
 21       for(int j=0;j+a[i]<=S;j++){
 22          (dp[i+1][j+a[i]]+=dp[i][j])%=mod;
 23          (dp[i+1][j]+=dp[i][j])%=mod;
 24 
 25          (dp2[i+1][j+a[i]]+=dp2[i][j])%=mod;
 26          (dp2[i+1][j]+=dp2[i][j]*2)%=mod;
 27       }
 28    }
 29 
 30    int ans=1;
 31    for(int i=0;i<N;i++) ans=ans*3%mod;
 32 
 33    if(S%2==1){
 34       for(int i=(S+1)/2;i<=S;i++){
 35          (ans+=(mod-dp2[N][i])*3)%=mod;
 36       }
 37    }
 38    else{
 39       for(int i=S/2;i<=S;i++){
 40          (ans+=(mod-dp2[N][i])*3)%=mod;
 41       }
 42       (ans+=dp[N][S/2]*3)%=mod;
 43    }
 44    cout<<ans<<endl;
 45 }


Compiler output:
a.cc:1:5: error: stray '#' in program
    1 |   1 #include<bits/stdc++.h>
      |     ^
a.cc:2:5: error: stray '#' in program
    2 |   2 #define REP(i,n) for(int i=0;i<(n);i++)
      |     ^
a.cc:4:5: error: stray '#' in program
    4 |   4 #define int long long
      |     ^
a.cc:1:3: error: expected unqualified-id before numeric constant
    1 |   1 #include<bits/stdc++.h>
      |   ^
a.cc:2:34: error: 'i' does not name a type
    2 |   2 #define REP(i,n) for(int i=0;i<(n);i++)
      |                                  ^
a.cc:2:40: error: 'i' does not name a type
    2 |   2 #define REP(i,n) for(int i=0;i<(n);i++)
      |                                        ^
a.cc:4:3: error: expected unqualified-id before numeric constant
    4 |   4 #define int long long
      |   ^
a.cc:7:3: error: expected unqualified-id before numeric constant
    7 |   7
      |   ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//余事象で答えを求める

int n;
const ll mod=998244353;
ll l[330];
ll dp1[330][100001];
ll dp2[330][100001];

int main(){
    cin>>n;
    ll l[330];
    ll s=0;
    ll ans=1;
    const ll mod=998244353;
    for (int i=0;i<n;i++){
        cin>>l[i];
        s+=l[i];
        ans*=3;
        ans%=mod;
    }
    dp1 [0][0]=1;
    dp2 [0][0]=1;
    for (int i=0;i<n;i++){
        for (int j=0;j<=s;j++){
            dp1[i][j]%=mod;
            dp2[i][j]%=mod;
            if (dp1[i][j]!=0){
                dp1[i+1][j]+=2*dp1[i][j];
                dp1[i+1][j+l[i]]+=dp1[i][j];
                //dp1[i+1][j+l[i]]%=mod;
            }
            if (dp2[i][j]!=0){
                dp2[i+1][j]+=dp2[i][j];
                //dp2[i+1][j]%=mod;
                dp2[i+1][j+l[i]]+=dp2[i][j];
                //dp2[i+1][j+l[i]]%=mod;
            }
        }
    }
    for (int i=(s+1)/2;i<=s;i++){
        ans-=(3*dp1[n][i])%mod;
    }
    if (s%2==0){
        ans+=3*dp2[n][s/2];
    }
    if (ans<0){
        ans+=mod;
    }
    ans%=mod
    cout<<ans%mod<<endl;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:13: error: expected ';' before 'cout'
   62 |     ans%=mod
      |             ^
      |             ;
   63 |     cout<<ans%mod<<endl;
      |     ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

const long long MOD = 998244353;

void solve(long long N, std::vector<long long> a){
    int dp[301][90301] = {};
    int dp2[301][90301] = {};
    int sum_a = std::accumulate(a.begin(), a.end(), 0);

    dp[0][0] = 1;
    dp2[0][0] = 1;

    for(int i = 0; i < N; i++)
    {
        for(long j = 0; j <= sum_a; j++)
        {
            dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 2) % MOD;
            dp[i+1][j+a[i]] = (dp[i+1][j+a[i]] + dp[i][j]) % MOD;

            dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j]) % MOD;
            dp2[i+1][j+a[i]] = (dp2[i+1][j+a[i]] + dp2[i][j]) % MOD;
        }
        
    }
    
    int border = (sum_a + 1) / 2;
    long sum_r = 0;
    for(int j = border; j <= sum_a; j++)
    {
        sum_r = (sum_r + dp[N][j]) % MOD;
    }
    
    long result;
    result = 1;
    for(int i = 0; i < N; i++)
    {
        result = (result * 3) % MOD;
    }

    if (border * 2 == sum_a) {
        result = (result - 3 * sum_r + 3 * dp2[N][border] * (border * 2 == sum_a)) % MOD;
    }

    if (result < 0) {
        result += MOD
    }
    

    cout << result << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Compiler output:
a.cc: In function 'void solve(long long int, std::vector<long long int>)':
a.cc:46:22: error: expected ';' before '}' token
   46 |         result += MOD
      |                      ^
      |                      ;
   47 |     }
      |     ~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//余事象で答えを求める

int n;
const ll mod=998244353;
ll l[330];
ll dp1[330][100001];
ll dp2[330][100001];

int main(){
    cin>>n;
    ll l[330];
    ll s=0;
    ll ans=1;
    const ll mod=998244353;
    for (int i=0;i<n;i++){
        cin>>l[i];
        s+=l[i];
        ans*=3;
        ans%=mod
    }
    dp1 [0][0]=1;
    dp2 [0][0]=1;
    for (int i=0;i<n;i++){
        for (int j=0;j<=s;j++){
            dp1[i][j]%=mod;
            dp2[i][j]%=mod;
            if (dp1[i][j]!=0){
                dp1[i+1][j]+=2*dp1[i][j];
                dp1[i+1][j+l[i]]+=dp1[i][j];
                //dp1[i+1][j+l[i]]%=mod;
            }
            if (dp2[i][j]!=0){
                dp2[i+1][j]+=dp2[i][j];
                //dp2[i+1][j]%=mod;
                dp2[i+1][j+l[i]]+=dp2[i][j];
                //dp2[i+1][j+l[i]]%=mod;
            }
        }
    }
    for (int i=(s+1)/2;i<=s;i++){
        ans-=(3*dp1[n][i])%mod;
    }
    if (s%2==0){
        ans+=3*dp2[n][s/2];
    }
    cout<<ans%mod<<endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: expected ';' before '}' token
   32 |         ans%=mod
      |                 ^
      |                 ;
   33 |     }
      |     ~
Language: C++

#include <vector>
#include <cmath>

using namespace std;

const int MOD = 998244353;

int main() {
  int n;
  cin >> n;

  long sum = 0;
  vector<int> a(n);

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }

  vector<vector<long>> dp(n+1, vector<long>(sum+1, 0));
  vector<vector<long>> dp2(n+1, vector<long>(sum+1, 0));

  dp[0][0] = 1;
  dp2[0][0] = 1;
  for (int i = 0; i < n; i++) {
    long ai = a[i];
    for (long j = 0; j + a[i] <= sum; j++) {
      // 新しいやつを赤にする場合
      dp[i+1][j+ai] += dp[i][j];
      dp[i+1][j+ai] %= MOD;
      // 新しいやつを緑または青にする場合
      dp[i+1][j] += 2 * dp[i][j];
      dp[i+1][j] %= MOD;

      dp2[i+1][j+ai] += dp2[i][j];
      dp2[i+1][j+ai] %= MOD;
      // 新しいやつを緑にする場合
      dp2[i+1][j] += dp2[i][j];
      dp2[i+1][j] %= MOD;
    }
  }

  long dp_sum = 0;
  for (long i = sum / 2 + 1; i <= sum; i++) {
    dp_sum += dp[n][i];
    dp_sum %= MOD;
  }
  
  long dp2_sum = 0;
  if (sum % 2 == 0) {
    dp_sum += dp[n][sum / 2];
    dp_sum %= MOD;
    dp2_sum += dp2[n][sum / 2];
    dp2_sum %= MOD;
  }

  int power_result = 1;
  for (int i = 0; i < n; i++) {
    power_result *= 3;
    power_result %= MOD;
  }

  int result;
  result = power_result - 3 * dp_sum + 3 * dp2_sum;
  result %= MOD;

  if (result < 0) {
    result += MOD;
  }

  cout << result << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'cin' was not declared in this scope
   10 |   cin >> n;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <cmath>
  +++ |+#include <iostream>
    3 | 
a.cc:71:3: error: 'cout' was not declared in this scope
   71 |   cout << result << endl;
      |   ^~~~
a.cc:71:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:71:21: error: 'endl' was not declared in this scope
   71 |   cout << result << endl;
      |                     ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <cmath>
  +++ |+#include <ostream>
    3 |
Language: C++

#include<iostream>MOD
#include<math.h>
using namespace std;

long int MOD = 998244353;
long long int dp[300][90001], sum = 0, ans = 0;
long long powmod(long long a, long long b) {
	a %= MOD;
	long long res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}
int main() {
	int N, A[300], i, j;


	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	for (i = 0; i < 90001; i++)dp[0][i] = (long long)0;
	dp[0][0] = (long long)2;
	dp[0][A[0]] = (long long)1;
	for (i = 1; i < N; i++) {
		for (j = 0; j < 90001; j++) {
			dp[i][j] = dp[i - 1][j] * 2;
			if (A[i] <= j)dp[i][j] += dp[i - 1][j - A[i]];
			dp[i][j] %= MOD;
		}
	}
	for (i = (sum + 1) / 2; i < 90001; i++) {
		ans += dp[N - 1][i];
		ans %= MOD;
	}
	for (i = 0; i < 90001; i++)dp[0][i] = 0;
	dp[0][0] = 1;
	dp[0][A[0]] = 1;
	for (i = 1; i < N; i++) {
		for (j = 0; j < 90001; j++) {
			dp[i][j] = dp[i - 1][j];
			if (A[i] <= j)dp[i][j] += dp[i - 1][j - A[i]];
			dp[i][j] %= MOD;
		}
	}
	if (sum % 2 == 0)ans -= dp[N - 1][sum / 2];
	printf("%lld", (((long long)powmod(3.0, N - 1) - ans + MOD) * 3) % MOD);
}


Compiler output:
a.cc:1:9: fatal error: iostream>MO: No such file or directory
    1 | #include<iostream>MOD
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
#include <unordered_set>
#include <numeric>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

const int p = 998244353;

int dp1[300][90000+1];
int dp2[300][90000+1];

int f1(vector<int>& a, int n) {
    memset(dp1,0,sizeof(dp1));
    dp1[0][0]=2;
    dp1[0][a[0]]=1;
    repeat(i,1,n) {
	rep(s,90000+1) {
	    dp1[i][s]=dp1[i-1][s]*2;
	    dp1[i][s]%=p;
	    if(s-a[i]>=0) {
		dp1[i][s]+=dp1[i-1][s-a[i]];
		dp1[i][s]%=p;
	    }
	}
    }
    int S=accumulate(a.begin(),a.end(),0);
    int ret=0;
    for(int s=(S+1)/2; s<=S; s++) {
	ret+=dp1[n-1][s];
	ret%=p;
    }
    return ret;
}

int f2(vector<int>& a, int n) {
    memset(dp2,0,sizeof(dp2));
    dp2[0][0]=1;
    dp2[0][a[0]]=1;
    repeat(i,1,n) {
	rep(s,90000+1) {
	    dp2[i][s]=dp2[i-1][s];
	    dp2[i][s]%=p;
	    if(s-a[i]>=0) {
		dp2[i][s]+=dp2[i-1][s-a[i]];
		dp2[i][s]%=p;
	    }
	}
    }
    int S=accumulate(a.begin(),a.end(),0);
    if(S%2==1)
	return 0;
    return dp2[n-1][S/2];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int ret=1;
  rep(i,n) {
      ret*=3;
      ret%=p;
  }
  ret-=3*f1(a,n);
  ret%=p;
  ret+=p;
  ret%=p;
  ret+=3*f2(a,n);
  ret%=p;
  cout << ret << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int f1(std::vector<int>&, int)':
a.cc:27:5: error: 'memset' was not declared in this scope
   27 |     memset(dp1,0,sizeof(dp1));
      |     ^~~~~~
a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   14 | #include <numeric>
  +++ |+#include <cstring>
   15 | using namespace std;
a.cc: In function 'int f2(std::vector<int>&, int)':
a.cc:50:5: error: 'memset' was not declared in this scope
   50 |     memset(dp2,0,sizeof(dp2));
      |     ^~~~~~
a.cc:50:5: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

// a/b の切り上げを求める
int ceil( int a, int b )
{
    if ( ( a / b ) * b == a ) return a / b;

    return a / b + 1;
}

long pow_mod( long a, long n, long mod )
{
    if ( n == 0 ) return 1;

    if ( n & 1 )
    {
        long t = pow_mod( a, n - 1, mod );
        return ( a * t ) % mod;
    }
    else
    {
        long t = pow_mod( a, n >> 1, mod );
        return ( t * t ) % mod;
    }
}

#define MAX_N 300
#define MAX_A 300
#define MOD 998244353

// R が S/2 以上の場合を数える dp
long dp1[MAX_N + 1][MAX_N * MAX_A + 1];
// R=G=S/2 となる場合を数える dp
long dp2[MAX_N + 1][MAX_N * MAX_A + 1];

long A[MAX_N];

int main( int argc, char **argv )
{
    int N;
    cin >> N;

    long S = 0;
    for ( int n = 0; n < N; n++ )
    {
        cin >> A[n];
        S += A[n];
    }

    memset( dp1, 0, sizeof( dp1 ) );
    memset( dp2, 0, sizeof( dp2 ) );

    dp1[0][0] = dp2[0][0] = 1;

    long limit = ceil( S, 2 );

    for ( int n = 0; n < N; n++ )
    {
        long a = A[n];
        for ( int r = 0; r <= limit; r++ )
        {
            // R を使わない場合
            // R >= S/2 を求める時は、R で使わないものは B/G の二通り
            // あるので x2
            dp1[n + 1][r] = ( dp1[n + 1][r] + 2 * dp1[n][r] ) % MOD;
            // R=G=S/2 を求める時は、R で使わないものは全部 G にするので
            // x1
            dp2[n + 1][r] = ( dp2[n + 1][r] + 1 * dp2[n][r] ) % MOD;

            if ( limit < r + a )
            {
                // S/2 を超えるものをカウントするのは R >= S/2 を求める時だけ。
                // R=G=S/2 の場合は S/2 を超えるものは必要ない
                dp1[n + 1][limit] = ( dp1[n + 1][limit] + dp1[n][r] ) % MOD;
            }
            else
            {
                // 今回の a を利用して S/2 以下になるものをカウントする
                dp1[n + 1][r + a] = ( dp1[n + 1][r + a] + dp1[n][r] ) % MOD;
                dp2[n + 1][r + a] = ( dp2[n + 1][r + a] + dp2[n][r] ) % MOD;
            }
        }
    }

    // 全ての塗り方は 3^N 通り。そこから R/G/B のどれかが S/2
    // 以上になる場合を引く。 dp1 は R が S/2 以上になる場合だが、G, B
    // も同じ通りあるので、x3 している。
    long ans = ( pow_mod( 3, N, MOD ) - 3 * dp1[N][limit] ) % MOD;

    if ( ans < 0 ) ans = ( ans + MOD ) % MOD;

    // S が 2 の倍数の時だけ (R,G,B) = (S/2,S/2,0) (S/2,0,S/2) (0,S/2,S/2)
    // となる可能性があり、これは上の 3*dp1[N][limit] でそれぞれ一回ずつ重複して
    // 覗かれている。つまり、(R,G,B) = (S/2,S/2,0) となる場合 (dp2[N][limit]x3)
    // だけ無駄に取り除かれているのでそれを補正する。
    if ( S % 2 == 0 ) ans = ( ans + 3 * dp2[N][limit] ) % MOD;

    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:54:5: error: 'memset' was not declared in this scope
   54 |     memset( dp1, 0, sizeof( dp1 ) );
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <iostream>
  +++ |+#include <cstring>
    3 | #include <string>
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const ll M = 998244353;
const string END = "\n";

ll dp[301][90001];
ll dp2[301][90001];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	ll a[301] = {};
	int sum = 0
	ll ans = 1;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
		ans = (ans * 3) % M;
	}
	int s = (sum+1) / 2;
	dp[0][0] = 1;
	dp2[0][0] = 1;
	rep(i, n){
		rep(j, 90001){
			(dp[i+1][j] += 2 * dp[i][j]) %= M;
			(dp2[i+1][j] += dp2[i][j]) %= M;
			if(j >= a[i]) {
				(dp[i+1][j] += dp[i][j-a[i]]) %= M;
				(dp2[i+1][j] += dp2[i][j-a[i]]) %= M;
			}
		}
	}
	if(sum % 2 == 0){
		(ans += 3 * dp2[n][sum/2]) %= M;
	}
	frep(i, s, sum+1){
		(ans -= 3 * dp[n][i] - M) %= M;
	}
	cout << (ans + M) % M << END;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: expected ',' or ';' before 'll'
   30 |         ll ans = 1;
      |         ^~
a.cc:34:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |                 ans = (ans * 3) % M;
      |                 ^~~
      |                 abs
a.cc:50:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |                 (ans += 3 * dp2[n][sum/2]) %= M;
      |                  ^~~
      |                  abs
a.cc:53:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |                 (ans -= 3 * dp[n][i] - M) %= M;
      |                  ^~~
      |                  abs
a.cc:55:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   55 |         cout << (ans + M) % M << END;
      |                  ^~~
      |                  abs
Language: C++

#include<iostream>
#include<stdint>
using namespace std; // 575

const int MAX = 301;
const int MAX2 = 90001;
const int MOD = 998244353;

int64_t pow(int64_t a, int b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	if (b == 2) return a * a % MOD;
	return pow(pow(a, b >> 1), 2) * pow(a, b & 1) % MOD;
}
int main() {
	int N, a[MAX2];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> a[i];
	static int64_t sum = 0, dp[MAX2], dp2[MAX2], ans = 0;
	// dp[i]は3色に塗り分けるとき、紅色がiとなるようなものの個数
	// dp2[i]は2色に塗り分けるとき、紅色がiとなるようなものの個数
	for (int i = 0;i < N;++ i) sum += a[i];
	for (int i = 0;i < MAX2;++ i) dp[i] = dp2[i] = 0;
	dp[0] = dp2[0] = 1;
	for (int i = 0;i < N;++ i) {
		for (int j = sum;j >= a[i];-- j) {
			dp[j] = (dp[j - a[i]] + dp[j] * 2) % MOD;
			dp2[j] = (dp2[j - a[i]] + dp2[j]) % MOD;
		}
		for (int j = 0;j < a[i];++ j) dp[j] = (dp[j] * 2) % MOD;
	}
	
	
	for (int i = sum + 1 >> 1;i <= sum;++ i) (ans += dp[i] * 3) %= MOD;
	
	if (sum % 2 == 0) (ans -= dp2[sum / 2] * 3) %= MOD;
	cout << (pow(3, N) - ans + MOD) % MOD;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

R≧G,Bとしても一般性を失わない

……解説見た、R≧S/2だけ除外すりゃ終わり！なのか……悲しいね
ちなみに今使っているエディタだと[300][90000]のメモリはとれないので、ちょっとメモリ圧縮してるよ
*/

Compiler output:
a.cc:2:9: fatal error: stdint: No such file or directory
    2 | #include<stdint>
      |         ^~~~~~~~
compilation terminated.