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

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MOD 1000000007

double dp[305][305][305];
double prob[305][305][305];

int main(){
    int n; cin >> n;
    rep(j,305) rep(i,305) rep(k,305) dp[i][j][k] = 0.0;
    rep(j,305) rep(i,305) rep(k,305) prob[i][j][k] = 0.0;
    int s[]= {0,0,0}; rep(i,n){
        int t; cin >> t;
        s[t-1]++;
    }
    prob[s[2]][s[1]][s[0]] = 1.0;
    double ans = 0.0;
    rep(i,n){
        rep(j, i+1){
            dp[i+1][j] += (1 - p[i]) * dp[i][j];
           // if(j+1 > n / 2) ans += p[i] * dp[i][j];
            dp[i+1][j+1] +=  p[i] * dp[i][j];
        }
    }
    rep(i,n+1) if(i > n / 2) ans += dp[n][i];
    printf("%.16lf\n", ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:32: error: 'p' was not declared in this scope
   27 |             dp[i+1][j] += (1 - p[i]) * dp[i][j];
      |                                ^
a.cc:32:34: error: invalid operands of types 'double' and 'double*' to binary 'operator+'
   32 |     rep(i,n+1) if(i > n / 2) ans += dp[n][i];
      |                              ~~~~^~~~~~~~~~~
a.cc:32:34: note:   in evaluation of 'operator+=(double, double*)'
Language: Java

import java.util.*;
import java.text.*;

public class MyClass {
    public static void main(String args[]) {
      Scanner in = new Scanner(System.in);
      int n = in.nextInt();
      int[] a = new int[n];
      int[] c = new int[4];
      double[][][] DP = new double[1+n][1+n][1+n];
      for(int i = 0; i< DP.length; i++)
        for(int j = 0; j< DP[i].length; j++)
            for(int k = 0; k< DP[i][j].length; k++)
                DP[i][j][k] = -1;
      for(int i = 0; i< n; i++)c[in.nextInt()]++;
      System.out.println(new DecimalFormat("0.000000000").format(calc(DP, n, c[1], c[2], c[3])));
    }
    static double calc(double[][][] DP, int n, int c1, int c2, int c3){
        if(Math.min(c1, Math.min(c2, c3)) < 0)return 0;
        if(c1+c2+c3 == 0)return 0.0;
        if(DP[c1][c2][c3] > -0.5)return DP[c1][c2][c3];
        int c0 = n-c1-c2-c3;
        double p0 = c0*1.0/n, p1 = c1*1.0/n, p2 = c2*1.0/n, p3 = c3*1.0/n;
        DP[c1][c2][c3] = (1+p1*calc(DP, n, c1-1, c2, c3)+p2*calc(DP, n, c1+1, c2-1, c3)+p3*calc(DP, n, c1, c2+1, c3-1))*1.0/(1-p0);
        return DP[c1][c2][c3];
    }
}

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

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

public class sushitopcoder {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		n=scan.nextInt();
		int[] f=new int[4];
		for(int i=0;i<n;i++) {
			f[scan.nextInt()]++;
		}
		dp=new double[301][301][301];
		for(double[][] d:dp) for(double[] dd:d) Arrays.fill(dd,-1);
		System.out.println(go(f[1],f[2],f[3]));
	}
	static double[][][] dp;
	static int n;
	
	public static double go(int f1, int f2, int f3) {
		int rem=f1+f2+f3;
		if(rem==0) return 0;
		
		if(dp[f1][f2][f3]!=-1) return dp[f1][f2][f3];
		
		double res=0;
		res+=n*1.0/(f1+f2+f3);
		
		if(f1>0) res+=f1*1.0/rem*go(f1-1,f2,f3);
		if(f2>0) res+=f2*1.0/rem*go(f1+1,f2-1,f3);
		if(f3>0) res+=f3*1.0/rem*go(f1,f2+1,f3-1);
		
		return dp[f1][f2][f3]=res;
	}
}

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

#include<stdio.h>
#define int long long
long double dpp[305][305][305];

long double dp(int n,int a, int b, int c)
{
	if(dpp[a][b][c]!=-1)
		return dpp[a][b][c];
	else
	{
		dpp[a][b][c] = (1.0*n)/(1.00*(a+b+c));
		if(a!=0)
			dpp[a][b][c] +=  ((1.0*a)/(1.0*(a+b+c))*(1.0*dp(n,a-1,b,c)));
		if(b!=0)
			dpp[a][b][c] += ((1.0*b)/(1.0*(a+b+c))*(1.0*dp(n,a+1,b-1,c)));
		if(c!=0)
			dpp[a][b][c] += ((1.0*c)/(1.0*(a+b+c))*1.0*dp(n,a,b+1,c-1));
		return dpp[a][b][c];
	}
}	 

int main(void)
{
	int n;
	scanf("%lld",&n);
	int a=0,b=0,c=0;
	int A[n];
	for(int i = 0;i<n;i++)
	{
		scanf("%lld",A+i);
		if(A[i] == 1) a++;
		if(A[i] == 2) b++;
		if(A[i] == 3) c++;
	}
	long double ans;
	for(int i = 0;i<305;i++)
		for(int j = 0;j<305;j++)
			for(int k = 0;k<305;k++)
				dpp[i][j][k] = -1.0;
	dpp[0][0][0] = 0.0;
	dpp[1][0][0] = 1.0*n;
	ans = dp(n,a,b,c);
	printf("%.14llf\n",ans);
	return 0;
}


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

#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int arr[4],n;
double dp[305][305][305];
double dfs(int a,int b,int c)
{
    if(a==0&&b==0&&c==0) return 0;
    if(dp[a][b][c]>0) return dp[a][b][c];
    double ans = 1.0*n/(a+b+c);
    if(a) ans+=(1.0*a/(a+b+c))*dfs(a-1,b,c);
    if(b) ans+=(1.0*b/(a+b+c))*dfs(a+1,b-1,c);
    if(c) ans+=(1.0*c/(a+b+c))*dfs(a,b+1,c-1);
    return dp[a][b][c] = ans;
}
int main()
{
    int d;c
    cin>>d;
    for(int i = 1;i<=n;++i)
    {
        cin>>d;
        arr[d]++;
    }
    printf("%.10f\n",dfs(arr[1],arr[2],arr[3]));
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:29:11: error: 'c' was not declared in this scope
   29 |     int d;c
      |           ^
Language: C++

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

// 入力
int N;

//添え字ややこしいときはメモ化再帰でいいかも
// DP テーブル
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;//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() {
    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:91:5: error: 'memset' was not declared in this scope
   91 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
a.cc:19:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   18 | #include <iomanip>
  +++ |+#include <cstring>
   19 | using namespace std;
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.15f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll n;
double dp[310][310][310]; // dp[i][j][k] : 寿司が残り1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の状態からすべての寿司をなくすのに必要な操作回数の期待値

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

int main() {
    
    cin >> n;

    ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a == 1) {
            cnt1++;
        }
        else if(a == 2) {
            cnt2++;
        } 
        else if(a == 3) {
            cnt3++;
        } 
    }

    memset(dp, -1, sizeof(dp));

    exout(f(cnt1, cnt2, cnt3));
    re0;
}

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

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

int main() {
  int n;
  cin >> n;
  vector<int> s(3);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s.at(a - 1)++;
  }
  static double dp[n + 1][n + 1][n + 1] = { };
  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;
        if (i) dp[i][j][k] += i * dp[i - 1][j][k] / (i + j + k);
        if (j) dp[i][j][k] += j * dp[i + 1][j - 1][k] / (i + j + k);
        if (k) dp[i][j][k] += k * dp[i][j + 1][k - 1] / (i + j + k);
        dp[i][j][k] += 1.0 * n / (i + j + k);
      }
    }
  }
  cout << setprecision(17) << dp[s.at(0)][s.at(1)][s.at(2)] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: storage size of 'dp' isn't constant
   13 |   static double dp[n + 1][n + 1][n + 1] = { };
      |                 ^~
Language: C++

#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define se second
#define fi first
#define ss size()
#define pb push_back
#define mp make_pair
#define ins insert
#define ll long long
#define y1 y12313312312
#define endl '\n'
#define gcd __gcd
//#define int ll

using namespace std;
//using namespace __gnu_pbds;

//template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e2 + 40, T = 4 * N, inf = 1e9 + 7;

int n, m, r, l, e, w, o, z, test, id, x, y;
int a[N], col[4];
double f, d[N][N][N];

void freop()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

void boos()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

main()
{
    //freop();
    boos();
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        col[a[i]]++;
    }
    for (int k = 0; k <= col[3]; k++)
    {
        for (int j = 0; j <= col[2]; j++)
        {
            for (int i = 0; i <= col[1]; i++)
            {

                if (i) d[i][j][k] += d[i - 1][j][k] * (double)i / (double)(i + j + k);
                if (j) d[i][j][k] += d[i + 1][j - 1][k] * (double)j / (double)(i + j + k);
                if (k) d[i][j][k] += d[i][j + 1][k - 1] * (double)k / (double)(i + j + k)0;
                if (i || j || k) d[i][j][k] += (double)n / (double)(i + j + k);
            }
        }
    }
    printf("%.9f", d[col[1]][col[2]][col[3]]);
}




Compiler output:
a.cc:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:63:90: error: expected ';' before numeric constant
   63 |                 if (k) d[i][j][k] += d[i][j + 1][k - 1] * (double)k / (double)(i + j + k)0;
      |                                                                                          ^
      |                                                                                          ;
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int N;

static double dp[310][310][310];

double cal_E(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 tmp = 0;

    if (i > 0)
    {
        tmp += cal_E(i - 1, j, k) * i;
    }

    if (j > 0)
    {
        tmp += cal_E(i + 1, j - 1, k) * j;
    }

    if (k > 0)
    {
        tmp += cal_E(i, j + 1, k - 1) * k;
    }

    tmp += N;

    tmp *= 1.0 / (i + j + k);

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

int main()
{
    int a;
    int one, two, three;
    int i, j, k;

    cin >> N;

    one = two = three = 0;

    rep(i, 1, N)
    {
        cin >> a;

        if (a == 1)
        {
            one++;
        }
        else if (a == 2)
        {
            two++;
        }
        else
        {
            three++;
        }
    }

    memset(dp, -1, sizeof(dp));

    printf("%.10f\n", cal_E(one, two, three));
}

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

#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
int n,a[4];
double dp[303][303][303];
bool vis[303][303][303];
double dfs(int i,int j,int k){
	if (vis[i][j][k]) return dp[i][j][k];
	vis[i][j][k]=1;
	double pos0=(double)(n-i-j-k)/(double)(n),pos1=(double)(i)/(double)(n),pos2=(double)(j)/(double)(n),pos3=(double)(k)/(double)(n);
	if (i!=0) dp[i][j][k]+=pos1*dfs(i-1,j,k);
	if (j!=0) dp[i][j][k]+=pos2*dfs(i+1,j-1,k);
	if (k!=0) dp[i][j][k]+=pos3*dfs;
	dp[i][j][k]=(dp[i][j][k]+1.0)/(1.0-pos0);
	return dp[i][j][k];
}
int main(){ 
	read(n);
	for (int i=1;i<=n;i++){
		int x;read(x);a[x]++;
	}
	dp[0][0][0]=0.0;vis[0][0][0]=1;
	dfs(a[1],a[2],a[3]);
	printf("%.12lf",dp[a[1]][a[2]][a[3]]);
}

Compiler output:
a.cc: In function 'double dfs(int, int, int)':
a.cc:17:36: error: invalid operands of types 'double' and 'double(int, int, int)' to binary 'operator*'
   17 |         if (k!=0) dp[i][j][k]+=pos3*dfs;
      |                                ~~~~^~~~
      |                                |    |
      |                                |    double(int, int, int)
      |                                double
Language: Java



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

public class Main {

	private static Scanner in;

    private static int n;
    private static int[] a;
    private static Integer[][][] dp;

    public static void main(String[] args) {
        in = new Scanner(System.in);
        n = in.nextInt();
        a = new int[n];

        for(int i=0; i<n; i++) a[i] = in.nextInt();

        dp = new Integer[n+1][n+1][n+1];

        int one=0;
        int two=0;
        int three=0;

        for(int i=0; i<n; i++) {
            switch(a[i]) {
	            case 1: one++; break;
	            case 2: two++; break;
	            case 3: three++; break;
                default:
                    break;
            }
        }

        System.out.println(solve(one, two, three));

    }

    private static double solve(int one, int two, int three) {
        if (one<0 || two<0 || three<0) return 0;

        if (one+two+three==0) return 0;

        if (dp[one][two][three]!=null) return dp[one][two][three];

        double A = one*1.0/n*solve(one-1, two, three);
        double B = two*1.0/n*solve(one+1, two-1, three);
        double C = three*1.0/n*solve(one, two+1, three-1);

        return dp[one][two][three] = n*(1+A+B+C)/(one+two+three);

    }

}


Compiler output:
Main.java:52: error: incompatible types: double cannot be converted to Integer
        return dp[one][two][three] = n*(1+A+B+C)/(one+two+three);
                                                ^
1 error
Language: C++

#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

long double dp[310][310][310];
Int N;

long double solve(Int i, Int j, Int k) {
	if (i==0&&j==0&&k==0) {//終端条件
		return dp[i][j][k] = 0.0;
	}
	if (dp[i][j][k]>=0) {//既に探索済みならreturn
		return dp[i][j][k];
	}

	long double res = 0.0;
	if (i > 0) {
		res += solve(i - 1, j, k) * i;
	}
	if (j>0) {
		res += solve(i + 1, j - 1, k) * j;
	}
	if (k>0) {
		res += solve(i, j + 1, k - 1) * k;
	}
	res += N;
	res *= 1.0 / (i + j + k);

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N;

	Int a;
	Int cnt1 = 0;
	Int cnt2 = 0;
	Int cnt3 = 0;
	for (Int i = 0; i < N; i++) {
		cin >> a;
		if (a==1) {
			cnt1++;
		}
		else if (a==2) {
			cnt2++;
		}
		else {
			cnt3++;
		}
	}

	//for (Int i = 0; i < 310; i++) {
	//	for (Int j = 0; j < 310; j++) {
	//		for (Int k = 0; k < 310; k++) {
	//			dp[i][j][k] = -1.0;
	//		}
	//	}
	//}

	memset(dp, -1, sizeof(dp));

	long double ans = solve(cnt1, cnt2, cnt3);
	cout << fixed << setprecision(10) << ans << "\n";
}


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

#include <iostream>

using namespace std;

const int maxn = 3e3 + 10;

long double dp[maxn][maxn][maxn];
long double n;
int a[4];
long double ii , jj ,kk , zz;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >>x;
        a[x]++;
    }
    for (int k = 0; k <= 302; k++) {
        for (int j = 0; j <= 302; j++) {
            for (int i = 0; i <= 302; i++) {
                if (i == 0 && j == 0&& k ==0)
                    continue;
                ii = 0;
                jj = 0;
                kk = 0;
                if (k != 0)
                    kk = (k / (long double)(i + j + k)) * (dp[i][j + 1][k - 1]);
                if (j != 0)
                    jj = (j / (long double)(i + j + k)) * (dp[i+1][j-1][k]);
                if (i != 0)
                    ii = (i / (long double)(i + j + k)) * (dp[i-1][j][k]);
                dp[i][j][k] += ii + jj + kk + 1 + ((n-(i + j + k)) / (long double)(i+j+k));
            }
        }
    }
    cout << dp[a[1]][a[2]][a[3]] << endl;
    return 0;
}

Compiler output:
/tmp/cckUbCdQ.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0x51): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0x78): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0xc0): relocation truncated to fit: R_X86_64_PC32 against symbol `ii' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0xc8): relocation truncated to fit: R_X86_64_PC32 against symbol `jj' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0xd0): relocation truncated to fit: R_X86_64_PC32 against symbol `kk' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0x132): relocation truncated to fit: R_X86_64_PC32 against symbol `kk' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0x194): relocation truncated to fit: R_X86_64_PC32 against symbol `jj' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0x1f3): relocation truncated to fit: R_X86_64_PC32 against symbol `ii' defined in .bss section in /tmp/cckUbCdQ.o
a.cc:(.text+0x22f): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <algorithm>
#include <unordered_map>
#include <functional>

using namespace std;

typedef array<int, 4> Status;

template<>
struct hash<Status> {
  size_t operator()(const Status& value) const {
    return hash<int>()(value[0]) ^ hash<int>()(value[1]) ^
           hash<int>()(value[2]) ^ hash<int>()(value[3]);
  }
};

unordered_map<Status, double> cache;

double f(const Status& st) {
  if (st[1] == 0 && st[2] == 0 && st[3] == 0) {
    return 0;
  }
  auto it = cache.find(st);
  if (it != cache.end()) {
    return it->second;
  }

  const int have_sushi = st[1] + st[2] + st[3];
  double value = (have_sushi + st[0]) / (double)have_sushi;
  if (st[1] > 0) {
    Status new_st = st;
    new_st[0]++;
    new_st[1]--;
    value += ((double)st[1] / have_sushi) * f(new_st);
  }
  if (st[2] > 0) {
    Status new_st = st;
    new_st[1]++;
    new_st[2]--;
    value += ((double)st[2] / have_sushi) * f(new_st);
  }
  if (st[3] > 0) {
    Status new_st = st;
    new_st[2]++;
    new_st[3]--;
    value += ((double)st[3] / have_sushi) * f(new_st);
  }
  cache[st] = value;
  return value;
}

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

  Status input = {0, 0, 0, 0};

  for (int i = 0; i < n; i++) {
    int value;
    cin >> value;
    if (value > 3) {
      cerr << "ERROR: Invalid value, must be <= 3. " << value << endl;
      return 0;
    }
    input[value]++;
  }

  cout << f(input) << endl;

  return 0;
}


Compiler output:
a.cc:21:8: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
   21 | struct hash<Status> {
      |        ^~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

double dp[310][310][310];
int n;
 
double find(int a, int b, int c) {
	if (a < 0 || b < 0 || c < 0) return 0;
	if (a == 0 && b == 0 && c == 0) return 0;
	if (dp[a][b][c] == 0) {
		dp[a][b][c] = n + a*find(a - 1, b, c) + b*find(a + 1, b - 1, c) + c*find(a, b + 1, c - 1);
		dp[a][b][c] /= a + b + c;
	}
	return dp[a][b][c];
}
 
int main() {
  	cin >> n;
  	int cnt[5] = {};
  	cout << setprecision(10) << fixed;
	rep{
    	int a;
    	cin >> a;
    	cnt[a]++;
  	}
 
  cout << find(cnt[1], cnt[2], cnt[3]) << '\n';
 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'rep' was not declared in this scope
   23 |         rep{
      |         ^~~
Language: C++



#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int N = 305;

string s;
int n;
int a[N];
double dp[N][N][N]; // dp[i][j] 捜査回数iの時の
int memo[4];


void cal(int i, int j, int k) {
  if(dp[i][j][k] >= 0) return;
  if(i) cal(i-1, j, k);
  if(j) cal(i + 1, j - 1, k);
  if(k) cal(i, j+1, k-1);

  dp[i][j][k] = (i ? dp[i - 1][j][k] * i : 0) + (j ? dp[i + 1][j - 1][k] * j : 0) + (k ? dp[i][j + 1][k - 1] * k : 0) + n;
  dp[i][j][k] *= 1.0 / (i + j + k);
}

int main () {
  cin >> n;
  memset(dp, -1, sizeof dp);
  rep(i,n) {
    cin >> a[i+1];
    memo[a[i+1]]++;
  }
  dp[0][0][0] = 0.0;
  cal(memo[1],memo[2],memo[3]);
  pd(dp[memo[1]][memo[2]][memo[3]]);br();
}


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

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

double dp[305][305][305];

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

    int N;
    cin >> N;

    int 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++;
    }

    int MX = max({x,y*2,z*3});
        
    dp[0][0][0] = 0.0;
    for (int k = 0; k <= MX; k++) {
        for (int j = 0; j <= MX; j++) {
            for (int i = 0; i <= MX; i++) {
                int T = i + j + k;
                if (T == 0) continue;
                dp[i][j][k] = (1.0*N / T);
                
                double r1 = 0.0;
                if (i > 0) r1 = (1.0*i / T) * dp[i-1][j][k];

                double r2 = 0.0;
                if (j > 0) r2 = (1.0*j / T) * dp[i+1][j-1][k];

                double r3 = 0.0;
                if (k > 0) r3 = (1.0*k / T) * dp[i][j+1][k-1];

                dp[i][j][k] += (r1 + r2 + r3);
            }
        }
    }

    cout << setprecision(9) << fixed << dp[x][y][z] << "\n";
}



Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   24 |     int MX = max({x,y*2,z*3});
      |              ~~~^~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
Language: C++

/*
Author Shivam
*/
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007 
#define int			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii> 
#define ve          vector
#define endl		"\n"
#define double 		long double
#define couts		cout<<setprecision(12)<<fixed					
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;					
// can

double dp[3*300+1][3*300+1][3*301+1];
int n;
double call(int i, int j, int k)
{	
	
	double &res=dp[i][j][k];
	//cout<<i<<" "<<j<<" "<<k<<" "<<n<<" "<<res<<endl;
	if(res!=-1) return res;
	double x1=0, x2=0, x3=0, sum=i+j+k;
	if(sum==0) return 0;
	if(i) x1=call(i-1,j,k);
	if(j) x2=call(i+1,j-1,k);
	if(k) x3=call(i,j+1,k-1);
	res=n*((x1+1)*i/n+(x2+1)*j/n+(x3+1)*k/n+(n-sum)/n)/sum;
	
	return res;

}
void solve()
{
	cin>>n;
	int a[n];
	int mp[4]={0,0,0,0};
	rep(i,0,n)
	{ 
		cin>>a[i];
		mp[a[i]]++;
	}
	int sum=mp[1]+mp[2]+mp[3];
	rep(i,0,sum+1)
	{
		rep(j,0,sum+1)
			rep(k,0,sum+1) dp[i][j][k]=-1;
	}
	cout<<call(mp[1], mp[2], mp[3]);
}
signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t;
		t=1;
		while(t--)
		{
			solve();
		}
}	

Compiler output:
/tmp/ccqniWB9.o: in function `call(long long, long long, long long)':
a.cc:(.text+0x132): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccqniWB9.o
a.cc:(.text+0x14c): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccqniWB9.o
a.cc:(.text+0x168): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccqniWB9.o
a.cc:(.text+0x186): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccqniWB9.o
a.cc:(.text+0x198): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccqniWB9.o
a.cc:(.text+0x1ab): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccqniWB9.o
/tmp/ccqniWB9.o: in function `solve()':
a.cc:(.text+0x1e1): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccqniWB9.o
a.cc:(.text+0x1fa): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccqniWB9.o
a.cc:(.text+0x2b2): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccqniWB9.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.Scanner;

import java.io.*;
import java.util.*;

public class Solution {
    static int N;
    static double[][][] dp;
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        N = Integer.parseInt(s.nextLine());

        int[] count = new int[3];
        StringTokenizer st = new StringTokenizer(s.nextLine());
        for (int i =0 ; i < N; ++i) {
            int dish = Integer.parseInt(st.nextToken()) - 1;
            count[dish]++;
        }

        dp = new double[301][301][301];

        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;
                }
            }
        }

        dp[0][0][0] = 0;

        System.out.println(getExpectedValue(count[2], count[1], count[0]));
    }

    static double getExpectedValue(int a, int b, int c) {
        if (dp[a][b][c] != -1) {
            return dp[a][b][c];
        }

        double expected = 0;
        if (a != 0)
            expected += a * getExpectedValue(a-1, b+1, c);
        if (b != 0)
            expected += b * getExpectedValue(a, b-1, c+1);
        if (c != 0)
            expected += c * getExpectedValue(a, b, c-1);

        double score = N/((double)(a + b + c)) + expected/(double)(a + b + c);
        dp[a][b][c] = score;
        return score;

    }
}


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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
int n;
//sushiのある皿がそれぞれi,j,k枚だった時の期待値
double sushi[310][310][310];
double dp(int i,int j,int k){
    if(sushi[i][j][k]){
        //一回訪れているとき，もう期待値が変わることはない
        if(sushi[i][j][k])>=0) return sushi[i][j][k];
        //もうsushiが無い
        if(i==0 and j==0 and k==0) return 0.0;
        double res=0;
        if(i>0) res+=dp(i-1,j,k);
        if(j>0) res+=dp(i+1,j-1,k);
        if(k>0) res+=dp(i,j+1,k-1);
        //期待値の計算(余分な皿に行くことこあるためnを足す)
        res=(res+n)/(i+j+k);
        return sushi[i][j][k]=res;
    }
}
signed main(){
    cin>>n;
    int one=0,two=0,three=0;
    rep(i,n){
        int x;
        cin>>x;
        if(x==1) one++;
        else if(x==2) two++;
        else three++;
    }
    memset(dp,-1,sizeof(dp));
    printf("%.16f\n",dp(one,two,three));
    return 0;
}

Compiler output:
a.cc: In function 'double dp(int, int, int)':
a.cc:20:27: error: expected primary-expression before '>=' token
   20 |         if(sushi[i][j][k])>=0) return sushi[i][j][k];
      |                           ^~
a.cc: In function 'int main()':
a.cc:42:25: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
   42 |     memset(dp,-1,sizeof(dp));
      |                        ~^~~
a.cc:42:12: error: invalid conversion from 'double (*)(int, int, int)' to 'void*' [-fpermissive]
   42 |     memset(dp,-1,sizeof(dp));
      |            ^~
      |            |
      |            double (*)(int, int, int)
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
a.cc: In function 'double dp(int, int, int)':
a.cc:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define setbits __builtin_popcount 
#define big 1e9+7
using namespace std;
ll n,k,m,flag,mod = 1000005,cnt;
ll a[1005];
double dp[205][205][205];
string s;
int main()
{
	IOS
	ll x = 0,y = 0,z = 0;
	cin>>n;
	for(int i = 0; i < n; ++i)
	{
		cin>>a[i];
		if(a[i] > 0)
		{
			if(a[i] > 1)
			{
				if(a[i] > 2)
					z++;
				else y++;
			}
			else x++;
		}
	}
	for(double i = 0.0; i <= z; ++i)
	{
		for(double j = 0.0; j+i <= z+y; ++j)
		{
			for(double k = 0.0; k+j+i <= x+y+z; ++k)
			{
				if(i+j+k > 0)
					dp[i][j][k] = (double)n/(i+j+k);
				if(i)
					dp[i][j][k] += dp[i-1][j+1][k]*i/(i+j+k);
				if(j)
					dp[i][j][k] += dp[i][j-1][k+1]*j/(i+j+k);
				if(k)
					dp[i][j][k] += dp[i][j][k-1]*k/(i+j+k);
			}
		}
	}
	cout<<setprecision(10)<<dp[z][y][x]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:43: error: invalid types 'double [205][205][205][double]' for array subscript
   37 |                                         dp[i][j][k] = (double)n/(i+j+k);
      |                                           ^
a.cc:39:43: error: invalid types 'double [205][205][205][double]' for array subscript
   39 |                                         dp[i][j][k] += dp[i-1][j+1][k]*i/(i+j+k);
      |                                           ^
a.cc:39:58: error: invalid types 'double [205][205][205][double]' for array subscript
   39 |                                         dp[i][j][k] += dp[i-1][j+1][k]*i/(i+j+k);
      |                                                          ^
a.cc:41:43: error: invalid types 'double [205][205][205][double]' for array subscript
   41 |                                         dp[i][j][k] += dp[i][j-1][k+1]*j/(i+j+k);
      |                                           ^
a.cc:41:58: error: invalid types 'double [205][205][205][double]' for array subscript
   41 |                                         dp[i][j][k] += dp[i][j-1][k+1]*j/(i+j+k);
      |                                                          ^
a.cc:43:43: error: invalid types 'double [205][205][205][double]' for array subscript
   43 |                                         dp[i][j][k] += dp[i][j][k-1]*k/(i+j+k);
      |                                           ^
a.cc:43:58: error: invalid types 'double [205][205][205][double]' for array subscript
   43 |                                         dp[i][j][k] += dp[i][j][k-1]*k/(i+j+k);
      |                                                          ^
Language: Java

//Created by Aminul on 8/14/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class J {
    static double N;
    static int n;
    static double dp[][][];

    public static void main(String[] args) throws Exception {
        new Thread(null ,new Runnable(){
            public void run(){
                try{solveIt();} catch(Exception e){e.printStackTrace(); System.exit(1);}
            }
        },"Main",1<<28).start();
    }

    public static void solveIt() throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = in.nextInt();
        int a[] = new int[4];
        for (int i = 0; i < n; i++) {
            a[in.nextInt()]++;
        }
        dp = new double[n + 1][n + 1][n + 1];
        N = n;
        for (double x[][] : dp) for (double y[] : x) Arrays.fill(y, -1);
        pw.println(solve(a[1], a[2], a[3]));

        pw.close();
    }

    static double solve(int ones, int twos, int threes) {
        if (ones == 0 && twos == 0 && threes == 0) return 0;
        if (dp[ones][twos][threes] != -1) return dp[ones][twos][threes];
        int zeros = n - ones - twos - threes;
        double e = 1;
        if (ones > 0) e += (ones / N) * solve(ones - 1, twos, threes);
        if (twos > 0) e += (twos / N) * solve(ones + 1, twos - 1, threes);
        if (threes > 0) e += (threes / N) * solve(ones, twos + 1, threes - 1);
        if (zeros > 0) e /= (1 - (zeros / N));
        return dp[ones][twos][threes] = e;
    }

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

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

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define nax 305
int p[nax][nax][nax], ev[nax][nax][nax];


int main() {
    int n; 
    scanf("%d", &n);
    vector<int> cnt(4);
    int x;
    for(int i=0; i<n;i++){
        scanf("%d", &x);
        cnt[x]++;
    }
    
    double p_wast, ex_wast, p_go;
    p[1][2][3] = 1;
    for(int c = n; c>=0; c--){
        for(int b = n; b>=0; b--){
            for(int a=0; a>=0; a--){
                
                if((a == 0 && b == 0 && c ==0) || a+b+c > n){
                    continue;
                }
                
                
                p_wast = (double)(n-(a+b+c))/n;
                ex_wast = p_wast / (1 - p_wast) + 1;
                
                ev[a][b][c] += ex_wast * p[a][b][c];
                
                if(a != 0){
                        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;
                }
                
                if(b != 0){
                        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;
                }
                
                if(c != 0){
                        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("%.10%lf", ev[0][0][0] )
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:36: error: expected ';' before 'return'
   58 |     printf("%.10%lf", ev[0][0][0] )
      |                                    ^
      |                                    ;
   59 | 
   60 |         return 0;
      |         ~~~~~~
Language: C++

dp = [[[0.0 for i in range(303)]for j in range(303)] for k in range(303)]
a1 = [0 for i in range(4)]
n = int(input())
for i in input().split():
	a1[int(i)] += 1
dp[a1[1]][a1[2]][a1[3]] = 1
ans = 0.0
for c in range(n,-1,-1):
	for b in range(n,-1,-1):
		for a in range(n,-1,-1):
			tot = (a+b+c)
			if(tot == 0):
				continue
			mis = (n-(tot))/n
			waste = mis/(1-mis)
			ans += dp[a][b][c] * waste
			if(a>=1):
				dp[a-1][b][c] += a/(tot) * dp[a][b][c]
			if(b>=1):
				dp[a+1][b-1][c] += b/(tot) * dp[a][b][c]
			if(c>=1):
				dp[a][b+1][c-1] += c/(tot) * dp[a][b][c] 
print(ans+a1[1]+2*a1[2]+3*a1[3])

Compiler output:
a.cc:1:1: error: 'dp' does not name a type
    1 | dp = [[[0.0 for i in range(303)]for j in range(303)] for k in range(303)]
      | ^~
Language: C++

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

double dp[305][305][305];
bool vis[305][305][305];

double f(int one, int two, int three, int n)
{
  if (one < 0 or two < 0 or three < 0)
    return 0;
  if (one == 1 and two == 0 and three == 0)
    return n;
  if (one == 0 and two == 0 and three == 0)
    return 0;
  auto& ret = dp[one][two][three];
  if (vis[one][two][three])
    return ret;
  vis[one][two][three] = true;
  ret = 1;
  double p = ((double)n - one - two - three)/n;
  return ret = ((1 + f(one - 1, two, three, n) * (double)(one)/n + f (one + 1, two - 1 , three, n) * (double)two / n + f (one, two + 1, three - 1, n) * (double)three/n))/(1-p);
}

// 2/3 * f(1,0,0,3)

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(4);
  for (int i = 0 ; i < n; ++i) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  memset(dp, -1, sizeof dp);
 // cout << cnt[1] << ' ' << cnt[2] <<' '<< cnt[3] <<'\n';
  cout << setprecision(15) << f(cnt[1], cnt[2], cnt[3], n) << '\n';

  return 0;
}


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

double dp[301][301][301];
long long n;
double recurse(long long one, long long two, long long three)
{

    if(dp[one][two][three]!=0)
    {
        return dp[one][two][three];
    }

    if(one==1&&two==0&&three==0)
    {
        return n;
    }

    double answer=n*1.0/(one+two+three);

    if(three>0)
    {
        answer+=three*1.0/(one+two+three)*recurse(one,two+1,three-1);
    }
    if(two>0)
    {
        answer+=two*1.0/(one+two+three)*recurse(one+1,two-1,three);
    }
    if(one>0)
    {
        answer+=one*1.0/(one+two+three)*recurse(one-1,two,three);
    }

    dp[one][two][three]=answer;

    //cout<<one<<" "<<two<<" "<<three<<" "<<answer<<endl;
    return answer;
}
int main()
{
    cin>>n;
    long long sushi[n];
    long long types[4];
    for(int i=0;i<n;i++)
    {
        cin>>sushi[i];
        types[sushi[i]]++;
    }
    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]=0;
            }
        }
    }
    recurse(types[1],types[2],types[3]);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:5: error: 'cin' was not declared in this scope
   38 |     cin>>n;
      |     ^~~
Language: C++

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

double dp[300][300][300];
long long n;
double recurse(long long one, long long two, long long three)
{
    if(dp[one][two][three]!=0)
    {
        return dp[one][two][three];
    }
    if(one==1&&two==0&&three==0)
    {
        return n;
    }
    double answer=n*1.0/(one+two+three);
    if(three>0)
    {
        answer+=three*1.0/(one+two+three)*recurse(one,two+1,three-1);
    }
    if(two>0)
    {
        answer+=two*1.0/(one+two+three)*recurse(one+1,two-1,three);
    }
    if(one>0)
    {
        answer+=one*1.0/(one+two+three)*recurse(one-1,two,three);
    }
    dp[one][two][three]=answer;
    //cout<<one<<" "<<two<<" "<<three<<" "<<answer<<endl;
    return answer;
}
int main()
{
    cin>>n;
    long long sushi[n];
    long long types[4];
    for(int i=0;i<n;i++)
    {
        cin>>sushi[i];
        types[sushi[i]]++;
    }
    dp[0][0][0]=0;
    recurse(types[1],types[2],types[3])
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:40: error: expected ';' before '}' token
   45 |     recurse(types[1],types[2],types[3])
      |                                        ^
      |                                        ;
   46 | }
      | ~
Language: C++

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

double dp[300][300][300];
long long n;
double recurse(long long one, long long two, long long three)
{
    if(dp[one][two][three]!=0)
    {
        return dp[one][two][three];
    }
    if(one==1&&two==0&&three==0)
    {
        return n;
    }
    double answer=n*1.0/(one+two+three);
    if(three>0)
    {
        answer+=three*1.0/(one+two+three)*recurse(one,two+1,three-1);
    }
    if(two>0)
    {
        answer+=two*1.0/(one+two+three)*recurse(one+1,two-1,three);
    }
    if(one>0)
    {
        answer+=one*1.0/(one+two+three)*recurse(one-1,two,three);
    }
    dp[one][two][three]=answer;
    //cout<<one<<" "<<two<<" "<<three<<" "<<answer<<endl;
    return answer;
}
int main()
{
    cin>>n;
    long long sushi[n];
    long long types[4];
    for(int i=0;i<n;i++)
    {
        cin>>sushi[i];
        types[sushi[i]]++;
    }
    dp[0][0][0]=0;
    recurse(type[1],type[2],type[3])
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:13: error: 'type' was not declared in this scope; did you mean 'types'?
   45 |     recurse(type[1],type[2],type[3])
      |             ^~~~
      |             types