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

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

double sol(int i, int j, int k, vector<vector<vector<double>>>& dp){
    if(dp[i][j][k] or i+j+k == 0) return dp[i][j][k];

    int N = dp.size()-1;
    dp[i][j][k] += N/(i+j+k);
    if(i > 0) dp[i][j][k] += sol(i-1, j, k, dp) * i/(i+j+k);
    if(j > 0) dp[i][j][k] += sol(i+1, j-1, k, dp) * j/(i+j+k);
    if(k > 0) dp[i][j][k] += sol(i, j+1, k-1, dp) * k/(i+j+k);

    return dp[i][j][k];
}


int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    vector<vector<vector<double>>> dp(N+1, vector<vector<double>>(N+1, vector<double>(N+1, 0)));

    cout << fixed << setprecision(10) << sol(count(a.begin(), a.end(), 1),
                                             count(a.begin(), a.end(), 2),
                                             count(a.begin(), a.end(), 3), dp) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:46: error: 'count' was not declared in this scope
   31 |     cout << fixed << setprecision(10) << sol(count(a.begin(), a.end(), 1),
      |                                              ^~~~~
Language: C++

#include <iostream>
#include <iomanip>

using namespace std;

int n;
double dp[310][310][310];

double rec(int i,int j,int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if((i == 0) && (j == 0) && (k == 0)) return 0.0;
    double res = 0.0;
    if(i > 0) res += rec(i-1,j,k) * i;
    if(j > 0) res += rec(i+1,j-1,k) * j;
    if(k > 0) res += rec(i,j+1,k-1) * k;
    res += n;
    res *= 1.0/(i+j+k);

    return dp[i][j][k] = res;
    }

int main(){
    int one = 0,two = 0,three = 0;
    cin >> n;
    int a;
    for (int i = 0; i < n; i++){
        cin >> a;
        if(a == 1) one++;
        else if (a == 2) two++;
        else three++;
    }
    memset(dp,-1,sizeof(dp));
    cout << fixed << setprecision(10) << rec(one,two,three) << endl; 
    return 0;
}

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

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

double dp[301][301][301];



double solve(int cnt1,int cnt2,int cnt3,int N){
    if(cnt1<0||cnt2<0||cnt3<0){
        return 0;
    }
    if(cnt1==0 and cnt2==0 and cnt3==0){
        return 0;
    }
    if(dp[cnt1][cnt2][cnt3]>-0.9){
        return dp[cnt1][cnt2][cnt3];
    }
    
    double expected_v=N+cnt1*solve(cnt1-1,cnt2,cnt3,N)+cnt2*solve(cnt1+1,cnt2-1,cnt3,N)+cnt3*solve(cnt1,cnt2+1,cnt3-1,N); //this is a simplified recurrence for more insight please remember to take a note of the recurrence somewhere.

    dp[cnt1][cnt2][cnt3]=expected_v/(cnt1+cnt2+cnt3);
    return  dp[cnt1][cnt2][cnt3];
}






int main(){
    int N, cnt1=0,cnt2=0,cnt3=0,x;
    cin>>N;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++){
        cin>>x;
        if(x==1){
            cnt1++;
        }
        if(x==2){
            cnt2++;
        }
        if(x==3){
            cnt3++;
        }
    }
    //cout<<cnt1<<" "<<cnt2;
    cout<<fixed<<setprecision(10)<<solve(cnt1,cnt2,cnt3,N);
}
#include<bits/stdc++.h>
using namespace std;

double dp[301][301][301];



double solve(int cnt1,int cnt2,int cnt3,int N){
    if(cnt1<0||cnt2<0||cnt3<0){
        return 0;
    }
    if(cnt1==0 and cnt2==0 and cnt3==0){
        return 0;
    }
    if(dp[cnt1][cnt2][cnt3]>-0.9){
        return dp[cnt1][cnt2][cnt3];
    }
    
    double expected_v=N+cnt1*solve(cnt1-1,cnt2,cnt3,N)+cnt2*solve(cnt1+1,cnt2-1,cnt3,N)+cnt3*solve(cnt1,cnt2+1,cnt3-1,N); //this is a simplified recurrence for more insight please remember to take a note of the recurrence somewhere.

    dp[cnt1][cnt2][cnt3]=expected_v/(cnt1+cnt2+cnt3);
    return  dp[cnt1][cnt2][cnt3];
}






int main(){
    int N, cnt1=0,cnt2=0,cnt3=0,x;
    cin>>N;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++){
        cin>>x;
        if(x==1){
            cnt1++;
        }
        if(x==2){
            cnt2++;
        }
        if(x==3){
            cnt3++;
        }
    }
    //cout<<cnt1<<" "<<cnt2;
    cout<<fixed<<setprecision(10)<<solve(cnt1,cnt2,cnt3,N);
}


Compiler output:
a.cc:52:8: error: redefinition of 'double dp [301][301][301]'
   52 | double dp[301][301][301];
      |        ^~
a.cc:4:8: note: 'double dp [301][301][301]' previously declared here
    4 | double dp[301][301][301];
      |        ^~
a.cc:56:8: error: redefinition of 'double solve(int, int, int, int)'
   56 | double solve(int cnt1,int cnt2,int cnt3,int N){
      |        ^~~~~
a.cc:8:8: note: 'double solve(int, int, int, int)' previously defined here
    8 | double solve(int cnt1,int cnt2,int cnt3,int N){
      |        ^~~~~
a.cc:78:5: error: redefinition of 'int main()'
   78 | int main(){
      |     ^~~~
a.cc:30:5: note: 'int main()' previously defined here
   30 | int main(){
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
double dp[303][303][303]={};
double dfs(int i,int j,int k,int n)
{
  // if(dp[i][j][k]!=-1)      return dp[i][j][k];
  if((i<0)||(j<0)||(k<0))    return 0;
	eles if((i==0)&&(j==0)&&(k==0)) return dp[i][j][k]=0;
  else if(dp[i][j][k]!=-1)      return dp[i][j][k];
	return dp[i][j][k]= ((double)n/(i+j+k)) + ((((double)i)/(i+j+k) * (dfs(i-1,j,k,n)))+(((double)j)/(i+j+k) * (dfs(i+1,j-1,k,n)))+(((double)k)/(i+j+k) * (dfs(i,j+1,k-1,n))));
return 0;
}
int main()
{ ios_base::sync_with_stdio(false); cin.tie(0);
	// MEM(dp,-1);
  for(int i=0;i<=300;i++)
    for(int j=0;j<300;j++)
      for(int k=0;k<300;k++)
        dp[i][j][k]=-1;
  int i,n;cin>>n;
	int a=0,b=0,c=0,z=0,count[4]={};
  for(i=0;i<n;i++)
	{   cin>>z;
    if(z==1) a++;
		if(z==2) b++;
		if(z==3) c++;
	}
  double ans=dfs(a,b,c,n);
  cout<<fixed<<setprecision(10)<<ans;
}


Compiler output:
a.cc: In function 'double dfs(int, int, int, int)':
a.cc:10:9: error: 'eles' was not declared in this scope
   10 |         eles if((i==0)&&(j==0)&&(k==0)) return dp[i][j][k]=0;
      |         ^~~~
a.cc:11:3: error: 'else' without a previous 'if'
   11 |   else if(dp[i][j][k]!=-1)      return dp[i][j][k];
      |   ^~~~
Language: C++

// https://atcoder.jp/contests/dp/tasks/dp_j
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pr pair<ll, ll>
#define infinity (ll)4e18
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

ld dp[310][310][310] = {-1};

ld solve(ll n, ll one, ll two, ll three)
{
    if (one < 0 || two < 0 || three < 0)
        return 0;
    if (dp[one][two][three] != -1)
        return dp[one][two][three];
    if (one == 0 && two == 0 && three == 0)
        dp[one][two][three] = 0;
    else
    {
        ld f = one + two + three;
        dp[one][two][three] = n / f + one * solve(n, one - 1, two, three) / f + two * solve(n, one + 1, two - 1, three) / f + three * solve(n, one, two + 1, three - 1) / f;
    }
    return dp[one][two][three];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, x;
    cin >> n;
    ll count[4] = {0};
    for (ll i = 0; i < 310; i++)
        for (ll j = 0; j < 310; j++)
            for (ll k = 0; k < 310; k++)
                dp[i][j][k] = -1;
    for (ll i = 0; i < n; i++)
    {
        cin >> x;
        count[x]++;
    }
    printf("%0.14Lf\n", solve(n, count[1], count[2], count[3]));
    return 0;
}

Compiler output:
g++: internal compiler error: File size limit exceeded signal terminated program as
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <file:///usr/share/doc/gcc-14/README.Bugs> for instructions.
Language: C++

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

double dp[301][301][301];
double solve(int x, int y, int z, int& n)
{
    if(x < 0 || y < 0 || z < 0)
        return 0;
    if(x == 0 && y == 0 && z == 0)
        return 0;
    if(dp[x][y][z] > -0.9)
        return dp[x][y][z];
    double exp = n + x*solve(x-1,y,z,n) + y*solve(x+1,y-1,z,n) + z*solve(x,y+1,z-1,n);
    return dp[x][y][z] = exp/(x+y+z);
}

int main() {
   int n, x;
   cin >> n;
   memset(dp, -1, sizeof dp);
   int o = 0, tw = 0, thr = 0;
   for(int i=1; i <= n; i++)
   {
       cin >> x;
       if(x == 1)
            o++;
       else if(x == 2)
            tw++;
       else thr++;
   }
   cout<<fixed<<setprecision(10)<<solve(o, tw, thr, n));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:55: error: expected ';' before ')' token
   31 |    cout<<fixed<<setprecision(10)<<solve(o, tw, thr, n));
      |                                                       ^
      |                                                       ;
Language: C++

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

constexpr ll INF = 1e15;

constexpr ll mod = 1e9 + 7;

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

int main() {
	int n;
	cin >> n;
	vector<int> as(n);
	vector<int> counts(4, 0);
	rep(i, n) {
		cin >> as[i];
		counts[as[i]]++;
	}

	vector<vector<vector<double>>> dp(n + 1, vector<vector<double>>(n + 1, vector<double>(n+1, -1)));
	
	//dp[i][j][k]...1枚の皿がi個、2枚の皿がj個、3枚の皿がk個のときに、必要な手数の期待値
	//dp[i][j][k] = (n-i-j-k) / n * dp[i][j][k] + i / n * dp[i-1][j][k] + j / n * dp[i+1][j-1][k] + k / n * dp[i][j+1][k-1] + 1
	//(i+j+k)/n * dp[i][j][k] = i / n * dp[i-1][j][k] + j / n * dp[i+1][j-1][k] + k / n * dp[i][j+1][k-1] + 1

	dp[0][0][0] = 0;
	const double dn = n;
	rep(k, counts[3] + 1) {
		rep(j, n + 1) {
			if (i + j> n) continue;
			rep(i, n + 1) {
				if (i == 0 && j == 0 && k == 0) continue;
				if (i + j + k > n) continue;
				double right = dn;
				if (i > 0) right += i * dp[i - 1][j][k];
				if (j > 0 && i < n) right += j * dp[i + 1][j - 1][k];
				if (k > 0 && j < n) right += k * dp[i][j + 1][k - 1];
				right *= 1.0 / (i + j + k);
				dp[i][j][k] = right;
			}
		}
	}
	cout << setprecision(10) << dp[counts[1]][counts[2]][counts[3]] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:29: error: 'i' was not declared in this scope
   53 |                         if (i + j> n) continue;
      |                             ^
Language: C++

// Author: Tyler Wang

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.precision(12);
  std::cerr.precision(12);
  std::mt19937 rng((std::uint_fast32_t)std::chrono::high_resolution_clock::now()
                       .time_since_epoch()
                       .count());
  int n;
  cin >> n;
  vector<int> cnt(4);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ++cnt[a];
  }
  vector<vector<vector<double>>> dp(
      n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1, -1)));
  dp[0][0][0] = 0;
  // dp[i][j][k] = 1 + (n - i - j - k) / n * dp[i][j][k] +
  // i / n * dp[i - 1][j][k] + j / n * dp[i][j - 1][k] + k / n * dp[i][j][k - 1]
  auto solve = y_combinator([&](auto self, int i, int j, int k) -> double {
    if (i < 0 || j < 0 || k < 0) {
      return 0;
    }
    if (dp[i][j][k] >= 0) {
      return dp[i][j][k];
    }
    double res = i * self(i - 1, j, k) + j * self(i + 1, j - 1, k) +
                 k * self(i, j + 1, k - 1);
    res = (n + res) / (i + j + k);
    return dp[i][j][k] = res;
  });
  cout << solve(cnt[1], cnt[2], cnt[3]) << '\n';
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:16: error: 'y_combinator' was not declared in this scope
   56 |   auto solve = y_combinator([&](auto self, int i, int j, int k) -> double {
      |                ^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll fpow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1LL)
			res = (res * x) % mod;
		y = y >> 1LL;
		x = (x * x) % mod;
	}
	return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second < b.second);}
bool fd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.first > b.first);}
bool sd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second > b.second);}
ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};
bool valid(ll x, ll y, ll n, ll m) {
	if (x < 0 || y < 0) {
		return false;
	}
	else if (x >= n || y >= m) {
		return false;
	}
	else
		return true;
}
#define MAXN 1000001
ll spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (ll i = 3; i * i < MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (ll j = i * i; j < MAXN; j += i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}

vector<int> getFactorization(int x)
{
	vector<int> ret;
	while (x != 1)
	{
		ret.push_back(spf[x]);
		x = x / spf[x];
	}
	return ret;
}
double dp[301][301][301];
double solve(int x, int y, int z, int n) {
    if(x<0 || y<0 || z<0)
        return 0;
	if (x == 0 && y == 0 and z == 0)
		return 0;
	if (dp[x][y][z] >= 0.9)
		return dp[x][y][z];
	double ans = n + x * solve(x - 1, y, z, n) + y * solve(x + 1, y - 1, z, n) + z * solve(x, y + 1, z - 1, n);
	return dp[x][y][x] = ans / (x + y + z);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	memset(dp, -1, sizeof(dp));
	int n;
	cin >> n;
	int one = 0, two = 0, three = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x == 1)
			one++;
		if (x == 2)
			two++;
		if (x == 3)
			three++;
	}
	cout << solve(one, two, three, n);
	return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:127:18: error: expected '}' at end of input
  127 |         return 0;
      |                  ^
a.cc:107:12: note: to match this '{'
  107 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
double dp[305][305][305];
int  main(){
    long long int n; cin>>n;
        vector<long long int >a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long int  n=a.size();
    long long int  ons=count(a.begin(),a.end(),1);
    long long int  tws=count(a.begin(),a.end(),2);
    long long int  ths=count(a.begin(),a.end(),3);
    //cout<<ons<<tws<<ths;
    memset(dp,0,sizeof(dp));
    for(long long int  k=0;k<=ths;k++){
        for(long long int  j=0;j<=ths+tws;j++){
            for(long long int  i=0;i<=ons+tws+ths;i++){
                if(i+j+k==0) continue;
                else{
                    double val=n;
                    if(i>0) val+=dp[i-1][j][k]*i;
                  //  cout<<val;
                    if(j>0) val+=dp[i+1][j-1][k]*j;
                    if(k>0) val+=dp[i][j+1][k-1]*k;
                    val=(double)val/(double)(i+j+k);
                    dp[i][j][k]=val;
                }
            }
        }
    }
    // cout<<dp[0][0][0]<<endl;
    cout<<setprecision(16)<<dp[ons][tws][ths];
    // cout<<dp[ons-1][tws][ths];
    // cout<<dp[ons-2][tws][ths];
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: redeclaration of 'long long int n'
   10 |     long long int  n=a.size();
      |                    ^
a.cc:5:19: note: 'long long int n' previously declared here
    5 |     long long int n; cin>>n;
      |                   ^
Language: C++

#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

double dp[310][310][310];
int N;

double rec(int i, int j, int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if(i ==0 && j ==0 && k ==0) return 0.0;

    double res = 0.0;
    if(i > 0) res += rec(i-1, j, k) * i;
    if(j > 0) res += rec(i+1, j-1, k) * j;
    if(k > 0) res += rec(i, j+1, k-1) * k; 

    res += N;
    res /= (i+j+k);
    return dp[i][j][k] = res;
}

int main(){
    cin >> N;

    int one =0, two = 0, three = 0;
    for(int i=0; i<N; ++i){
        int a;
        cin >> a;
        if(a == 1){
            one++;
        }else if(a ==2){
            two++;
        }else{
            three++;
        }
    }

    memset(dp, -1, sizeof(dp));
    cout << fixed << setprecision (10) << rec(one, two, three) << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:5: error: 'memset' was not declared in this scope
   40 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <iomanip>
  +++ |+#include <cstring>
    4 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
double dp[301][301][301];
double Sushi(int x,int y,int z,int n){
  	if(x<0 || y<0 || z<0){
    	return 0;
    }
	if(x==0 && y==0 && z==0){
    	return 0;
    }
  	if (dp[x][y][z]!=-1){
    	return dp[x][y][z];
    }
  	double val=n+Sushi(x-1,y,z)+Sushi(x+1,y-1,z)+Sushi(x,y+1,z-1);
  	return dp[x][y][z]=val/(x+y+z);
}
int main(){
	int n;
  	cin>>n;
  	memset(dp,-1,sizeof(dp))
  	int a[n];
  	for(int i=0;i<n;i++){
    	cin>>a[i];
    }
  	int one=0,two=0,three=0;
  	for(int i=0;i<n;i++){
    	if(a[i]==1){
        	one++;
        }
      	else if(a[i]==2){
        	two++;
        }
      	else if(a[i]==3){
        	three++;
        }
    }
  	cout<<Sushi(one,two,three,n)<<endl;
  	
  	
}

Compiler output:
a.cc: In function 'double Sushi(int, int, int, int)':
a.cc:14:27: error: too few arguments to function 'double Sushi(int, int, int, int)'
   14 |         double val=n+Sushi(x-1,y,z)+Sushi(x+1,y-1,z)+Sushi(x,y+1,z-1);
      |                      ~~~~~^~~~~~~~~
a.cc:4:8: note: declared here
    4 | double Sushi(int x,int y,int z,int n){
      |        ^~~~~
a.cc:14:42: error: too few arguments to function 'double Sushi(int, int, int, int)'
   14 |         double val=n+Sushi(x-1,y,z)+Sushi(x+1,y-1,z)+Sushi(x,y+1,z-1);
      |                                     ~~~~~^~~~~~~~~~~
a.cc:4:8: note: declared here
    4 | double Sushi(int x,int y,int z,int n){
      |        ^~~~~
a.cc:14:59: error: too few arguments to function 'double Sushi(int, int, int, int)'
   14 |         double val=n+Sushi(x-1,y,z)+Sushi(x+1,y-1,z)+Sushi(x,y+1,z-1);
      |                                                      ~~~~~^~~~~~~~~~~
a.cc:4:8: note: declared here
    4 | double Sushi(int x,int y,int z,int n){
      |        ^~~~~
a.cc: In function 'int main()':
a.cc:20:33: error: expected ';' before 'int'
   20 |         memset(dp,-1,sizeof(dp))
      |                                 ^
      |                                 ;
   21 |         int a[n];
      |         ~~~                      
a.cc:23:14: error: 'a' was not declared in this scope
   23 |         cin>>a[i];
      |              ^
a.cc:27:12: error: 'a' was not declared in this scope
   27 |         if(a[i]==1){
      |            ^
Language: C++

#include <bits/stdc++.h>

#define FOR(i, a, b) for(double i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define INF 1e9

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 2e5+2;
const int M = 1e9+7;

double dp[301][301][301];
int main()
{
    _upgrade;
    int n, c1 = 0, c2 = 0, c3 = 0;
    cin>>n;
    FOR(i, 0, n)
    {
        int x;
        cin>>x;
        if(x == 1)
            c1++;
        else if(x == 2)
            c2++;
        else
            c3++;
    }
    FOR(i, 0, 301)
        FOR(j, 0, 301)
            FOR(k, 0, 301)
            {
                if(i+j+k > n || i+j+k == 0)
                    continue;
                db a, b, c;
                a = 1.0*k/(i+j+k);
                b = 1.0*j/(i+j+k);
                c = 1.0*i/(i+j+k);
                if(k)
                    dp[k][j][i] += dp[k-1][j][i]*a;
                if(j)
                    dp[k][j][i] += dp[k+1][j-1][i]*b;
                if(i)
                    dp[k][j][i] += dp[k][j+1][i-1]*c;

                dp[k][j][i] += 1.0*n/(i+j+k);
            }
    cout<<setprecision(9)<<dp[c1][c2][c3];
}



Compiler output:
a.cc: In function 'int main()':
a.cc:49:23: error: invalid types 'double [301][301][301][double]' for array subscript
   49 |                     dp[k][j][i] += dp[k-1][j][i]*a;
      |                       ^
a.cc:49:38: error: invalid types 'double [301][301][301][double]' for array subscript
   49 |                     dp[k][j][i] += dp[k-1][j][i]*a;
      |                                      ^
a.cc:51:23: error: invalid types 'double [301][301][301][double]' for array subscript
   51 |                     dp[k][j][i] += dp[k+1][j-1][i]*b;
      |                       ^
a.cc:51:38: error: invalid types 'double [301][301][301][double]' for array subscript
   51 |                     dp[k][j][i] += dp[k+1][j-1][i]*b;
      |                                      ^
a.cc:53:23: error: invalid types 'double [301][301][301][double]' for array subscript
   53 |                     dp[k][j][i] += dp[k][j+1][i-1]*c;
      |                       ^
a.cc:53:38: error: invalid types 'double [301][301][301][double]' for array subscript
   53 |                     dp[k][j][i] += dp[k][j+1][i-1]*c;
      |                                      ^
a.cc:55:19: error: invalid types 'double [301][301][301][double]' for array subscript
   55 |                 dp[k][j][i] += 1.0*n/(i+j+k);
      |                   ^
Language: C++

/*
 *    author:  Gary Shih
 *    created: 2020-05-04 13:27:07
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  int n;
  cin >> n;
  int c1 = 0, c2 = 0, c3 = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a == 1) ++c1;
    if (a == 2) ++c2;
    if (a == 3) ++c3;
  }
  vector<vector<vector<double>>> dp(
      301, vector<vector<double>>(151, vector<double>(101)));
  for (int total = 1; total <= c1 + 2 * c2 + 3 * c3; ++total) {
    for (int i = 0; i <= total; ++i)
      for (int j = 0; j <= (total - i); ++j)
        for (int k = 0; k <= (total - i - 2 * j); ++k) {
          if ((total - i - 2 * j) % 3 != 0) continue;
          debug(total, i, j, k);
          int rest = i + j + k;
          double prev = 0.0;
          if (i > 0) prev += (double)i / (double)n * dp[i - 1][j][k];
          if (j > 0) prev += (double)j / (double)n * dp[i + 1][j - 1][k];
          if (k > 0) prev += (double)k / (double)n * dp[i][j + 1][k - 1];
          dp[i][j][k] = (double)n / (double)rest * (prev + 1.0);
        }
  }
  cout << dp[c1][c2][c3] << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:11: error: 'debug' was not declared in this scope
   29 |           debug(total, i, j, k);
      |           ^~~~~
Language: Java

import java.util.*;
 
public class Main {
  static double dp[][][];
  static int n;
  public static void main(String[] args) { //Passes samples, but WA
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    dp = new double[n+1][n+1][n+1];
    int[] arr = new int[3];
    for(int i =0; i< n ;++) {
      int a = in.nextInt()-1;
      arr[a]++;
    } 
    
    System.out.println(dfs(arr[0], arr[1], arr[2]));  
  }

  static double dfs(int one, int two, int three){
     if(one ==0 && two==0 && three==0)
       return 0;
     if(dp[one][two][three]>0) return dp[one][two][three];  
     double re =n;
     if(one>0) re + = one*dfs(one-1,two, three);
     if(two > 0) re+= two*dfs(one+1, two-1, three);
     if(three>0) re+= three*dfs(one, two+1; three-1);
     re /=(one+two+three);
     return dp[one][two][three]=re; 
  }
}



Compiler output:
Main.java:11: error: illegal start of expression
    for(int i =0; i< n ;++) {
                          ^
Main.java:24: error: illegal start of expression
     if(one>0) re + = one*dfs(one-1,two, three);
                    ^
Main.java:26: error: ')' or ',' expected
     if(three>0) re+= three*dfs(one, two+1; three-1);
                                          ^
Main.java:26: error: not a statement
     if(three>0) re+= three*dfs(one, two+1; three-1);
                                                 ^
Main.java:26: error: ';' expected
     if(three>0) re+= three*dfs(one, two+1; three-1);
                                                   ^
5 errors
Language: C++

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

ll MAX = 1e9+1;
const int maxn = 300*3+1;
double dp[maxn][maxn][maxn];
int n;

double f(int i, int j, int k) {
    if (i == 0 && j == 0 && k == 0)
        return 0;
    if (dp[i][j][k] != 0)
        return dp[i][j][k];
    int l = n - i - j - k;
    double sol = 1 + (double) i/n * (i == 0 ? 0 : f(i-1,j,k))
        + (double) j/n * (j == 0 ? 0 : f(i+1, j-1, k))
        + (double) k/n * (k == 0 ? 0 : f(i, j+1, k-1));
    sol /= (1 - (double) l/n);

    dp[i][j][k] = sol;

    return sol;
}

void solve() {
    cin >> n;

    vector<int> counts(4);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        counts[x]++;
    }
    memset(dp, 0, sizeof(dp));

    // if f(i,j,k) ~ expected # of moves to finish i 1s, j 2s, and k 3s
    // f(i,j,k) = 1 + (N-i-j-k)/N f(i,j,k) + i/N f(i-1,j,k) + j/N f(i+1,j-1,k) + k/N f(i,j+1,k-1)
    //          (pick)  (pick 0 plate)       (pick 1 plate)     (pick 2 plate)   (pick 3 plate)
    // dp[i][j][k] ~ expected # of moves to finish from state (i,j,k)
    // if i'm at dp[i][j][k], then three states depend on me:
    //      - dp[i+1][j][k]
    //      - dp[i-1][j+1][k]
    //      - dp[i][j-1][k+1]

    //dp[1][0][0] = n;
    //for (int k = 0; k <= counts[3]; k++) {
    //    for (int j = 0; j <= counts[2] + counts[3]; j++) {
    //        for (int i = 0; i <= counts[1] + counts[2] + counts[3]; i++) {
    //            //cout << i << " " << j << " " << k << " ";
    //            if (j > 0)
    //                dp[i][j-1][k+1] += (double) n/(k+1) * dp[i][j][k];
    //            if (i > 0)
    //                dp[i-1][j+1][k] += (double) n/(j+1) * dp[i][j][k];
    //            dp[i+1][j][k] += (double) n/(i+1) * dp[i][j][k];
    //            //cout << dp[i][j][k] << endl;
    //        }
    //    }
    //}

    double ans = f(counts[1], counts[2], counts[3]);

    cout.precision(20);
    //cout << dp[counts[1]][counts[2]][counts[3]] << endl;
    cout << ans << endl;
}


int main() {
    solve();
	return 0;
}







Compiler output:
/tmp/ccOTF3Tv.o: in function `f(int, int, int)':
a.cc:(.text+0xb9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOTF3Tv.o
a.cc:(.text+0xd4): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOTF3Tv.o
a.cc:(.text+0x138): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOTF3Tv.o
a.cc:(.text+0x198): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOTF3Tv.o
a.cc:(.text+0x1f8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOTF3Tv.o
/tmp/ccOTF3Tv.o: in function `solve()':
a.cc:(.text+0x27d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOTF3Tv.o
a.cc:(.text+0x300): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOTF3Tv.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
double dp[301][301][301];
double solve(int x,int y,int z,int &n){
	if(x < 0 || y < 0 || z < 0)
    	return 0;
    if(x ==0 && y == 0 && z == 0)
    	return 0;
    if(dp[x][y][z] > -0.9)
    	return dp[x][y][z];
    double e = n + x*solve(x-1,y,z,n) + y*solve(x+1,y-1,z,n) + z*solve(x,y+1,z-1,n);
    return dp[x][y][z] = exp/(x+y+z);
}
int main(){
	int n,i;
    cin>>n;
    int a[n];
    int one = 0,two = 0,three = 0;
    for(i=0;i<n;++i){
    	cin>>a[i];
        if(a[i] == 1)
        	one ++;
        else if(a[i] == 2)
        	two ++;
        else
        	three++;
    }
    cout<<solve(one,two,three,n)<<"\n";
}


Compiler output:
a.cc: In function 'double solve(int, int, int, int&)':
a.cc:12:29: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator/'
   12 |     return dp[x][y][z] = exp/(x+y+z);
      |                          ~~~^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
double dp[301][301][301];
double solve(int x,int y,int x,int &n){
	if(x < 0 || y < 0 || z < 0)
    	return 0;
    if(x ==0 && y == 0 && z == 0)
    	return 0;
    if(dp[x][y][z] > -0.9)
    	return dp[x][y][z];
    double e = n + x*solve(x-1,y,z,n) + y*solve(x+1,y-1,z,n) + z*solve(x,y+1,z-1,n);
    return dp[x][y][z] = exp/(x+y+z);
}
int main(){
	int n,i;
    cin>>n;
    int a[n];
    int one = 0,two = 0,three = 0;
    for(i=0;i<n;++i){
    	cin>>a[i];
        if(a[i] == 1)
        	one ++;
        else if(a[i] == 2)
        	two ++;
        else
        	three++;
    }
    cout<<solve(one,two,three,n)<<"\n";
}

Compiler output:
a.cc:4:30: error: redefinition of 'int x'
    4 | double solve(int x,int y,int x,int &n){
      |                          ~~~~^
a.cc:4:18: note: 'int x' previously declared here
    4 | double solve(int x,int y,int x,int &n){
      |              ~~~~^
a.cc: In function 'double solve(...)':
a.cc:5:30: error: 'z' was not declared in this scope
    5 |         if(x < 0 || y < 0 || z < 0)
      |                              ^
a.cc:7:27: error: 'z' was not declared in this scope
    7 |     if(x ==0 && y == 0 && z == 0)
      |                           ^
a.cc:9:17: error: 'z' was not declared in this scope
    9 |     if(dp[x][y][z] > -0.9)
      |                 ^
a.cc:11:34: error: 'z' was not declared in this scope
   11 |     double e = n + x*solve(x-1,y,z,n) + y*solve(x+1,y-1,z,n) + z*solve(x,y+1,z-1,n);
      |                                  ^
Language: C++

#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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


double dp[305][305][305] = { -1 };

int n;

double rec(int i, int j, int k) {
	if (dp[i][j][k] >= 0)return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0)return 0;
	double res = (double)n;
	if (i > 0)res += i * rec(i - 1, j, k);
	if (j > 0)res += j * rec(i + 1, j - 1, k);
	if (k > 0)res += k * rec(i, j + 1, k - 1);
	res /= (double)(i + j + k);
	return dp[i][j][k] = res;
}


int main() {
	cin >> n;
	vector<int>dishes(3, 0);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		--a;
		dishes[a]++;
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				dp[i][j][k] = -1;
			}
		}
	}
	double ans = rec(dishes[0], dishes[1], dishes[2]);
	printf("%.10f\n", ans);
	return 0;
}

Compiler output:
/tmp/ccEYLWXk.s: Assembler messages:
/tmp/ccEYLWXk.s: Fatal error: can't fill 256 bytes in section .data of /tmp/ccyZRfSe.o: 'No space left on device'
/tmp/ccEYLWXk.s: Fatal error: /tmp/ccyZRfSe.o: No such file or directory
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 302;

int n;
double dp[MAXN][MAXN][MAXN];
bool vis[MAXN][MAXN][MAXN];

double solve(int x, int y, int z) {
  if(vis[x][y][z])
    return dp[x][y][z];
  vis[x][y][z] = 1;

  if(!x && !y && !z)
    return dp[x][y][z] = 0;

  int total = x + y + z;
  dp[x][y][z] = (double)(n - total)/total;

  if (x) dp[x][y][z] += x*((solve(x-1, y, z)+1)/total);
  if (y) dp[x][y][z] += y*((solve(x+1, y-1, z)+1)/total);
  if (z) dp[x][y][z] += z*((solve(x, y+1, z-1)+1)/total);
  return dp[x][y][z];
}

int main() {
  int n;
  cin >> n;
  int cnt[3] = {};
  for(int i=0; i<n; ++i) {
    int x;
    cin >> x;
    ++cnt[x-1];
  }
  cout.precision(10);
  cout << solve(cnt[1], cnt[2], cnt[3]); << '\n';
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:42: error: expected primary-expression before '<<' token
   38 |   cout << solve(cnt[1], cnt[2], cnt[3]); << '\n';
      |                                          ^~
Language: Java

import java.util.*;
import java.io.*;
class Main {
    static double[][][] dp;
    static double recurse(int cnt1, int cnt2, int cnt3, int n) {
        if(cnt1<0 || cnt2<0 || cnt3<0)
            return 0;
        if(cnt1==0 && cnt2==0 && cnt3==0)
            return 0;
        System.out.println(Arrays.toString(c));
        if(dp[cnt1][cnt2][cnt3]>0)
            return dp[cnt1][cnt2][cnt3];
        double expectedValue = n + cnt1*recurse(cnt1-1, cnt2, cnt3, n) +
                               cnt2*recurse(cnt1+1, cnt2-1, cnt3, n) +
                               cnt3*recurse(cnt1, cnt2+1, cnt3-1, n);
        dp[cnt1][cnt2][cnt3] = expectedValue/(cnt1+cnt2+cnt3);
        return dp[cnt1][cnt2][cnt3];
    }
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] c = new int[3];
        for(int i = 0; i<n; i++) {
            int x = sc.nextInt()-1;
            c[x]++;
        }
        dp = new double[c[0]+1][c[1]+1][c[2]+1];
        for(double[][] i: dp)
            for(double[] j: i)
                Arrays.fill(j, -1);
        System.out.println(recurse(c[0], c[1], c[2], n));
    }
}

Compiler output:
Main.java:10: error: cannot find symbol
        System.out.println(Arrays.toString(c));
                                           ^
  symbol:   variable c
  location: class Main
1 error
Language: C++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define triple pair<int, pair<int, int>>
double dp[301][301][301];
double count(int x, int y, int z, int n){
    //    printf("%d %d %d \n", x, y, z);

    if(x < 0 || y < 0 || z < 0)return 0;
    if(x == 0 && y== 0 && z == 0)return 0;
   // if(um.find(to_string(x) + to_string(y) + to_string(z)) != um.end())return um[to_string(x) + to_string(y) + to_string(z)];
    if(dp[x][y][z] != -1)return dp[x][y][z];
    double rem = ((double)(n - (x + y + z)))/n;
 //   printf("%d %d %d %f\n", x, y, z, rem);
    double ans = (rem + (((double)x)/n)*(1 + count(x-1, y, z, n)) + (((double)y)/n)*(1 + count(x+1, y-1, z, n)) + (((double)z)/n)*(1 + count(x, y+1, z-1, n))  );
    ans = ans/(1 - rem);
 //   printf("%d %d %d %f\n", x, y, z, rem);
    dp[x][y][z] = ans;
    //um[to_string(x) + to_string(y) + to_string(z)] = ans;
    return ans;
    
}

int main() {
    int n;
    cin>>n;
    int x, y, z;
    x = 0;
    y = 0;
    z = 0;
    for(int i = 0 ; i < n ; i++){
        int a;
        cin>>a;
        if(a == 1)x++;
        if(a == 2)y++;
        if(a == 3)z++;
    }
    memset(dp, -1, sizeof dp);
  //  unordered_map<string, double> um;
    printf("%.9f",count(x,y,z,n,dp));
	// your code goes here
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:24: error: no matching function for call to 'count(int&, int&, int&, int&, double [301][301][301])'
   41 |     printf("%.9f",count(x,y,z,n,dp));
      |                   ~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: candidate: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:   candidate expects 3 arguments, 5 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note:   candidate expects 4 arguments, 5 provided
a.cc:7:8: note: candidate: 'double count(int, int, int, int)'
    7 | double count(int x, int y, int z, int n){
      |        ^~~~~
a.cc:7:8: note:   candidate expects 4 arguments, 5 provided
Language: C++

#include <iostream>
using namespace std;
double dp[310][310][310];

int main(){
  int n;
  cin >> n;
  double x;
  double y[4];
  for(int i=0;i<n;i++){
    cin >> x;
    y[x] += 1;
  }
  dp[0][[0][0] = 0;
  for(int i=0;i<y[1];i++){
    for(int j=0;j<y[2];j++){
      for(int k=0;k<y[3];k++){
        dp[i][j][k]=dp[i-1][j][k]*i+dp[i+1][j-1][k]*j+dp[i][j+1][k-1]*k;
        dp[i][j][k]*=1/(n*(i+j+k));
      }
    }
  }
  cout << dp[y[1]][y[2]][y[3]] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:6: error: invalid types 'double [4][double]' for array subscript
   12 |     y[x] += 1;
      |      ^
a.cc:14:8: error: two consecutive '[' shall only introduce an attribute before '[' token
   14 |   dp[0][[0][0] = 0;
      |        ^
a.cc:23:13: error: invalid types 'double [310][310][310][double]' for array subscript
   23 |   cout << dp[y[1]][y[2]][y[3]] << endl;
      |             ^
Language: C++

using ll = long long;

const int nax = 305;
double p[nax][nax][nax], ev[nax][nax][nax];
// ev[a][b][c] - the expected number of operations so far to get to state (a,b,c)
// easier: p-bility of getting to this state at all, p[a][b][c]

int main() {
	int n;
	scanf("%d", &n);
	vector<int> cnt(4);
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		++cnt[x];
	}
	p[cnt[1]][cnt[2]][cnt[3]] = 1;
	for (int c = n; c >= 0; --c) {
		for (int b = n; b >= 0; --b) {
			for (int a = n; a >= 0; --a) {
				if (a == 0 && b == 0 && c == 0) {
					continue;
				}
				if (a + b + c > n) {
					continue;
				}
				// dp[a][b][c]

				double p_waste = (double)(n - (a + b + c)) / n;
				// p_waste + p_waste^2 + ... = S
				// 1 + S = S / p_waste
				double ev_waste = p_waste / (1 - p_waste) + 1;
				ev[a][b][c] += ev_waste * p[a][b][c];

				// remove 1 -> dp[a-1][b][c]
				// we will eventually choose one of a+b+c
				if (a != 0) {
					double p_go = (double)a / (a + b + c);
					p[a - 1][b][c] += p[a][b][c] * p_go;
					ev[a - 1][b][c] += ev[a][b][c] * p_go;
				}

				// remove 2 -> dp[a+1][b-1][c]
				if (b != 0) {
					double p_go = (double)b / (a + b + c);
					p[a + 1][b - 1][c] += p[a][b][c] * p_go;
					ev[a + 1][b - 1][c] += ev[a][b][c] * p_go;
				}

				// remove 3
				if (c != 0) {
					double p_go = (double)c / (a + b + c);
					p[a][b + 1][c - 1] += p[a][b][c] * p_go;
					ev[a][b + 1][c - 1] += ev[a][b][c] * p_go;
				}
			}
		}
	}
	printf("%.10lf\n", ev[0][0][0]); // + cnt[1] + 2 * cnt[2] + 3 * cnt[3]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'scanf' was not declared in this scope
   10 |         scanf("%d", &n);
      |         ^~~~~
a.cc:11:9: error: 'vector' was not declared in this scope
   11 |         vector<int> cnt(4);
      |         ^~~~~~
a.cc:11:16: error: expected primary-expression before 'int'
   11 |         vector<int> cnt(4);
      |                ^~~
a.cc:15:19: error: 'cnt' was not declared in this scope; did you mean 'int'?
   15 |                 ++cnt[x];
      |                   ^~~
      |                   int
a.cc:17:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
   17 |         p[cnt[1]][cnt[2]][cnt[3]] = 1;
      |           ^~~
      |           int
a.cc:59:9: error: 'printf' was not declared in this scope
   59 |         printf("%.10lf\n", ev[0][0][0]); // + cnt[1] + 2 * cnt[2] + 3 * cnt[3]);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | using ll = long long;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>sushi(3, 0);
  for (int i = 0; i < N; i ++) {
    int a;
    cin >> a;
    a --;
    sushi[a] ++;
  }
  double dp[303][303][303];
  for (int k = 0; k <= sushi[2]; k ++) {
    for (int j = 0; j <= N - k; j ++) {
      for (int i = 0; i <= N - j - k; i ++) {
        if (!i && !j && !k) {
          dp[i][j][k] = (double)0;
          continue;
        }
        dp[i][j][k] = (double) 1 / al;
        if (i > 0) {
          dp[i][j][k] += (double) dp[i - 1][j][k] * i / al;
        }
        if (j > 0) {
          dp[i][j][k] += (double) dp[i + 1][j - 1][k] * j / al;
        }
        if (k > 0) {
          dp[i][j][k] += (double) dp[i][j + 1][k - 1] * k / al;
        }
      }
    }
  }
  cout << setprecision(10) << dp[sushi[0]][sushi[1]][sushi[2]] <<
    endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:36: error: 'al' was not declared in this scope
   21 |         dp[i][j][k] = (double) 1 / al;
      |                                    ^~
Language: C++

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

    #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #define rep(i,a,b) for(int i=a; i<b; i++)
    #define ll long long
    #define pb push_back
    #define inf 1e+18L
    #define MOD 1000000007
    #define MAXN 1000007

    int n;
    vector<vector<vector<long double>>> dp(307,vector<vector<long double>>(307,vector<long double>(307,-1));
    long double solve(int a, int b, int c)
    {
        if(a<0 || b<0 || c<0) return 0;
        if(dp[a][b][c] != -1) return dp[a][b][c];
        long double A=a, B=b, C=c;
        long double currans = 0;
        currans = (A/n * solve(a-1,b,c)) + (B/n * solve(a+1,b-1,c)) + (C/n * solve(a,b+1,c-1)) + 1;
        currans *= n;
        currans /= (a+b+c);
        dp[a][b][c] = currans;
        return dp[a][b][c];
    }

    int main()
    {
        FastIO
        dp[0][0][0]=0;
        cin >> n;
        vector<int> cnt(4,0);
        int x;
        rep(i,0,n)
        {
            cin >> x;
            cnt[x]++;
        }
        cout << fixed << setprecision(10) << solve(cnt[1], cnt[2], cnt[3]);
        return 0;
    }

Compiler output:
a.cc:13:108: error: expected ')' before ';' token
   13 |     vector<vector<vector<long double>>> dp(307,vector<vector<long double>>(307,vector<long double>(307,-1));
      |                                           ~                                                                ^
      |                                                                                                            )
Language: C++

#include <cstdio>
#include <numeric>
#include <cmath>
#include <iostream>
using namespace std;

const int maxn = 300;
double dp[maxn + 1][maxn + 1][maxn + 1] = {0};
int occur[3] = {0};

void test() {
  double sum = 0;
  double n = 50, e = 30;
  for (double i = 0; i <= 1000; i++) {
    sum += (n - e) / n * pow(e / n, i) * (i + 1);
  }
  cout << sum << endl;
  cout << e / (n - e) << endl;
  cout << n / (n - e) << endl;
}

int main() {
  // test();
  // return 0;
  int n;
  cin >> n;
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    occur[x - 1]++;
  }
  for (int k = 0; k <= occur[2]; k++) {
    for (int j = 0; j <= occur[1] + occur[2]; j++) {
      for (int i = 0; i <= occur[0] + occur[1] + occur[2]; i++) {
        if (i == 0 && j == 0 && k == 0) continue;
        double s = i + j + k;
        dp[i][j][k] = 
          (k ? dp[i][j + 1][k - 1] * k / s : 0) +
          (j ? dp[i + 1][j - 1][k] * j / s : 0) + 
          (i ? dp[i - 1][j][k] * i / s : 0) + 
          + (n - s) / s + 
          
      }
    }
  }
  cout.precision(10);
  cout << dp[occur[0]][occur[1]][occur[2]]  << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:7: error: expected primary-expression before '}' token
   42 |       }
      |       ^
Language: C++

N = 305
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]
c = Counter(a)

memo = [[[-1]*N for _ in range(N)] for __ in range(N)]
memo[0][0][0] = 0

def dp(a,b,c):
    if memo[a][b][c]>-0.5:
        return memo[a][b][c]

    z = n - (a+b+c)
    nz = n-z
    aux1, aux2, aux3 = 0, 0, 0
    if a:
        aux1 = a/(a+b+c)*dp(a - 1, b, c)
    if b:
        aux2 = b/(a+b+c)*dp(a + 1, b-1, c)
    if c:
        aux3 = c/(a+b+c)*dp(a, b+1, c-1)


    ans = nz/n*(aux1+aux2+aux3+1) + z/n
    ans *= n/nz
    memo[a][b][c] = ans
    return ans



print(dp(c[1],c[2],c[3]))


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = 305
      | ^
Language: Java

import java.util.Scanner;

import static java.lang.Math.max;
import static java.lang.Math.min;


public class MainApp{

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n =scanner.nextInt();
        int[] cnt = new int[4];
        for (int i = 0; i < n; i++) {
            int tmp = scanner.nextInt();
            cnt[tmp]++;
        }
        double[][][]dp = new double[n+2][n+2][n+2];
        //dp[a][b][c]表示把a个1，b个2，c个3吃到0的期望操作次数
        dp[0][0][0] = 0;
        for(int k = 0;k<=n;k++) {
            for (int j =0;j<=n;j++) {
                for (int i=0;i<=n;i++) {
                    if(i==0&&j==0&&k==0)
                        continue;
                    double sum = (n/(double)(i+j+k));
                    if(i!=0) sum+=(i/(double)(i+j+k))*dp[i-1][j][k];
                    if(j!=0&&i+1<=n) sum+=(j/(double)(i+j+k))*dp[i+1][j-1][k];
                    if(k!=0&&j+1<=n) sum+=(k/(double)(i+j+k))*dp[i][j+1][k-1];
                    dp[i][j][k] = sum;
                }
            }
        }
        System.out.println(dp[cnt[1]][cnt[2]][cnt[3]]);
    }



}

Compiler output:
Main.java:7: error: class MainApp is public, should be declared in a file named MainApp.java
public class MainApp{
       ^
1 error