Language: Java

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int n;
int l[10];
int a, b, c;
int aans = 1e9;

void cnt(vector<int> v){
    int A=0, B=0, C=0;
    int aa=0,bb=0,cc=0;
    for(int i=0; i<v.size(); i++){
        if(v[i]==0) continue;
        if(v[i]==1) {
            A+=l[i];
            aa++;
        }
        if(v[i]==2){
            B+=l[i];
            bb++;
        } 
        if(v[i]==3) {
            C+=l[i];
            cc++;
        }
    }
    if(A==0 || B==0 || C == 0) return;
    int ans = abs(A-a) + abs(B-b) + abs(C-c) + (aa+bb+cc-3)*10;
    aans = min(ans, aans);
}

void dfs(int depth, vector<int> v){
    if(depth == n) {
        cnt(v);
        return;
    }
    for(int i=0; i<4; i++){
        v[depth] = i;
        dfs(depth+1, v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>a>>b>>c;
    rep(i, n){
        cin >> l[i];
    }
    vector<int> tmp(n+10, 0);
    dfs(0,tmp);
    // dfsして状態全列挙
    cout<<aans<<endl;

}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:3: error: class, interface, enum, or record expected
typedef long long ll;
^
Main.java:4: error: class, interface, enum, or record expected
typedef pair<int, int> P;
^
Main.java:5: error: illegal character: '#'
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
^
Main.java:5: error: class, interface, enum, or record expected
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
        ^
Main.java:5: error: class, interface, enum, or record expected
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
                                  ^
Main.java:5: error: class, interface, enum, or record expected
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
                                                ^
Main.java:6: error: '{' expected
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
                 ^
Main.java:6: error: illegal start of type
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
                                                 ^
Main.java:6: error: <identifier> expected
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
                                                      ^
Main.java:6: error: <identifier> expected
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
                                                          ^
Main.java:6: error: illegal start of type
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
                                                                               ^
Main.java:7: error: class, interface, enum, or record expected
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
^
Main.java:7: error: '{' expected
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
                 ^
Main.java:7: error: illegal start of type
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
                                                 ^
Main.java:7: error: > or ',' expected
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
                                                          ^
Main.java:7: error: illegal start of type
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
                                                                               ^
Main.java:9: error: unnamed classes are a preview feature and are disabled by default.
int n;
^
  (use --enable-preview to enable unnamed classes)
Main.java:10: error: class, interface, enum, or record expected
int l[10];
^
Main.java:11: error: class, interface, enum, or record expected
int a, b, c;
^
Main.java:50: error: not a statement
    ios::sync_with_stdio(false);
    ^
Main.java:51: error: not a statement
    cin>>n>>a>>b>>c;
                ^
Main.java:53: error: not a statement
        cin >> l[i];
            ^
Main.java:55: error: not a statement
    vector<int> tmp(n+10, 0);
                     ^
Main.java:58: error: not a statement
    cout<<aans<<endl;
              ^
Main.java:50: error: ';' expected
    ios::sync_with_stdio(false);
                        ^
Main.java:52: error: ';' expected
    rep(i, n){
             ^
Main.java:55: error: ';' expected
    vector<int> tmp(n+10, 0);
                   ^
Main.java:55: error: ';' expected
    vector<int> tmp(n+10, 0);
                        ^
30 errors