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

#include <bits/stdc++.h>
using namespace std;
int l[9];
int n,a,b,c;
int ans;
int dfs(int number,int A,int B,int C){
    if(number==n){
        int answer=abs(A-a)+abs(B-b)+abs(C-c)-30;
        if(A>0 && B>0 && C>0)ans=min(ans,answer);
        return ans;
    }
    else{
        if(number==0)ans=1e9;
        int ans1=dfs(number+1,A+l[number],B,C)+10;
        int ans2=dfs(number+1,A,B+l[number],C)+10;
        int ans3=dfs(number+1,A,B,C+l[number])+10;
        int ans4=dfs(number+1,A,B,C);
        return min(ans1,ans2,ans3,ans4);
    }
}

int main(){
    cin >> n >> a >> b >> c;
    for(int i=0;i<n;i++)cin >> l[i];
    cout << dfs(0,0,0,0) << endl;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int, int)':
a.cc:18:19: error: no matching function for call to 'min(int&, int&, int&, int&)'
   18 |         return min(ans1,ans2,ans3,ans4);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 4 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 4 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 4 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 4 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
int l[9];
int n,a,b,c;
int ans;
void dfs(int number,int A,int B,int C){
    if(number==n){
        int answer=abs(A-a)+abs(B-b)+abs(C-c);
        if(A>0 && B>0 && C>0)ans=min(ans,answer);
        return;
    }
    else{
        if(number==0)ans=1e9;
        dfs(number+1,A+l[number+1],B,C);
        dfs(number+1,,A,B+l[number+1],C);
        dfs(number+1,A,B,C+l[number+1]);
        dfs(number+1,A,B,C);
        return;
    }
}

int main(){
    cin >> n >> a >> b >> c;
    for(int i=0;i<n;i++)cin >> l[i];
    dfs(0,0,0,0);
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int, int)':
a.cc:15:22: error: expected primary-expression before ',' token
   15 |         dfs(number+1,,A,B+l[number+1],C);
      |                      ^
Language: C++

// Synthetic Kadomatsu
#include <bits/stc++.h>
using namespace std;
#define ll long long

ll a,b,c,n;
int *arr;
ll Synthetic(ll x,ll y,ll z,ll i){
	if(i == n){
		if(x<0||y<0||z<0) return 1e11;
		else return abs(a-x)+abs(b-y)+abs(c-z)-30;
	}

	ll op1 = Synthetic(x,y,z,i+1);
	ll op2 = Synthetic(x+arr[i],y,z,i+1)+10;
	ll op3 = Synthetic(x,y+arr[i],z,i+1)+10;
	ll op4 = Synthetic(x,y,z+arr[i],i+1)+10;
	return min(op1,min(op2,min(op3,op4)));
}

int main(){
	
	cin>>n>>a>>b>>c;
	arr = new int[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	cout<<Synthetic(0,0,0,0);
	cout<<endl;
	return 0;
}

Compiler output:
a.cc:2:10: fatal error: bits/stc++.h: No such file or directory
    2 | #include <bits/stc++.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

void chmin(int &a,int b){if(a>b)a=b;}
int N,A,B,C;
vector<int>L;

int rec(int i,int a,int b,int c){
    if(i==N){
        if(!a || !b || !c)return INF;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }

    int res=rec(i+1,a,b,c);

    chmin(res,rec(i+1,a+L[i],b,c)+(a? 10:0));
    chmin(res,rec(i+1,a,b+L[i],c)+(b? 10:0));
    chmin(res,rec(i+1,a,b,c+L[i])+(c?10:0));
    return res;
}

int main(){
    cin>>N>>A>>B>>C;
    L.resize(N);
    for(int i=0;i<N;i++)cin>>L[i];

    cout<<rec(0,0,0,0)<<endl;
}

Compiler output:
a.cc: In function 'int rec(int, int, int, int)':
a.cc:12:34: error: 'INF' was not declared in this scope
   12 |         if(!a || !b || !c)return INF;
      |                                  ^~~
Language: C++

#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e14;

int n, a, b, c;

void list(int k, vector<int> &L) {
  L.resize(n);
  rep(i, n) {
    L[i] = k % 4;
    k /= 4;
  }
}

void Main() {
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int num = 1;
  rep(_, n) num *= 4;
  int ans = 1000000;
  vector<int> M;
  rep(k, num) {
    list(k, M);
    int x, y, z;
    x = y = z = 0;
    int score = 0;
    rep(i, n) {
      if (M[i] == 0) {
        if (x > 0) score += 10;
        x += l[i];
      } else if (M[i] == 1) {
        if (y > 0) score += 10;
        y += l[i];
      } else if (M[i] == 2) {
        if (z > 0) score += 10;
        z += l[i];
      }
    }
    if (x == 0 || y == 0 || z == 0) continue;
    score += abs(a - x) + abs(b - y) + abs(c - z);
    ans = min(score, ans);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Compiler output:
a.cc: In function 'void Main()':
a.cc:42:5: error: reference to 'list' is ambiguous
   42 |     list(k, M);
      |     ^~~~
In file included from /usr/include/c++/14/list:65,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:150,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:23:6: note:                 'void list(int, std::vector<int>&)'
   23 | void list(int k, vector<int> &L) {
      |      ^~~~
Language: C++

#include <iostream>
#include <queue>

#define INF 1000000000;

using namespace std;

int dfs(int N, int cur, int a, int b, int c, int A, int B, int C, int * l){
    if(cur == N) {
        if(min({a, b, c}) > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        else return INF;
    }
    else{
        int ret0 = dfs(N, cur + 1, a, b, c, A, B, C, l);
        int ret1 = dfs(N, cur + 1, a + l[cur], b, c, A, B, C, l) + 10;
        int ret2 = dfs(N, cur + 1, a, b + l[cur], c, A, B, C, l) + 10;
        int ret3 = dfs(N, cur + 1, a ,b, c + l[cur], A, B, C, l) + 10;
        return min({ret0, ret1, ret2, ret3});
    }
}

int main(){
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    int l[N];
    for(int i=0; i<N; i++) cin >> l[i];
    cout << dfs(N, 0, 0, 0, 0, A, B, C, l) << endl;;
    return 0;
}

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

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
void chmin(int &a, int b) { if (a > b) a = b; }

int N, A, B, C;
vector<int> L;

// 再帰

int rec(int i, int a, int b, int c){
    if(i==N){
        if(!a || !b || !c) return INT_MAX;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }

    int res = rec(i+1, a, b, c);

    chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
    chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));

    return res;
}

//int rec(int i, int a, int b, int c) {
//    if (i == N) {
//        if (!a || !b || !c) return INF; // A, B, C いずれも竹は 1 本は必ず使ってないとダメ
//        return abs(a - A) + abs(b - B) + abs(c - C); // 合体してできた a, b, c を A, B, C にするコスト
//    }
//
//    // 今ある竹を採用しない場合
//    int res = rec(i+1, a, b, c);
//
//    // A, B, C を使う場合。
//    // (a ? 10 : 0) とかは、最初の 1 本目は合体コストなし、2 本目からはコスト 10 かかることを意味する
//    chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
//    chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
//    chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
//
//    return res;
//}

int main() {
    // 入力
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i< N; ++i) cin >> L[i];

    // 再帰する
    cout << rec(0, 0, 0, 0) << endl;
}

Compiler output:
a.cc: In function 'int rec(int, int, int, int)':
a.cc:14:35: error: 'INT_MAX' was not declared in this scope
   14 |         if(!a || !b || !c) return INT_MAX;
      |                                   ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <cmath>
  +++ |+#include <climits>
    4 | using namespace std;
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

int answer = INT_MAX;
int N;
vector<int> abc(3);
vector<pair<int,int> > unit(4,pair<int,int>(0,0));
void dfs(int depth,vector<int> &l){
    if(depth < N){
        REP(i,4){
            unit[i].first+=l[depth];
            unit[i].second+=1;
            dfs(depth+1,l);
            unit[i].first-=l[depth];
            unit[i].second-=1;
        }
    }
    else{
        int tmp=0;
        
        REP(i,3){
            if(unit[i].second == 0)return;
            tmp += abs(unit[i].first-abc[i])+10*(unit[i].second-1);
        }
        
        answer = min(answer,tmp);
    }
}
int main(){
    cin >> N;
    vector<int>l(N);
    REP(i,3){
        cin >> abc[i];
    }
    REP(i,N)cin >> l[i];
    dfs(0,l);
    cout << answer << endl;
    return 0;
}

Compiler output:
a.cc:17:14: error: 'INT_MAX' was not declared in this scope
   17 | int answer = INT_MAX;
      |              ^~~~~~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include<queue>
  +++ |+#include <climits>
    8 | #define REP(i,a) for (int i = 0;i < (a);++i)
Language: C++

#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
void chmin(int &a,int b) {if(a>b) a=b;}
int N,A,B,C;
vector<int> l;

int rec(int i,int a,int b,int c){
  if(i==N){
    if(!a || !b || !c) return INF;
    return abs(a-A)+abs(b-B)+abs(c-C);
  }
  int res = rec(i+1,a,b,c);

  chmin(res,rec(i+1,a+l[i],b,c)+(a?10:0));
  chmin(res,rec(i+1,a,b+l[i],c)+(b?10:0));
  chmin(res,rec(i+1,a,b,c+l[i])+(c?10:0));

  return res;
}

int main(){
  cin >> N >> A >> B >> C;
  l.resize(N);
  for(int i=0;i<N;i++) cin >> l[i];
  cout << rec(0,0,0,0) << endl;
}

Compiler output:
a.cc: In function 'int rec(int, int, int, int)':
a.cc:11:31: error: 'INF' was not declared in this scope
   11 |     if(!a || !b || !c) return INF;
      |                               ^~~
Language: C++

#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
void chmin(int &a,int b) {if(a>b) a=b;}
int N,A,B,C;
vector<int> l;

int rec(int i,int a,int b,int c){
  if(i==n){
    if(!a || !b || !c) return INF;
    return abs(a-A)+abs(b-B)+abs(c-C);
  }
  int res = rec(i+1,a,b,c);

  chmin(res,rec(i+1,a+l[i],b,c)+(a?10:0));
  chmin(res,rec(i+1,a,b+l[i],c)+(b?10:0));
  chmin(res,rec(i+1,a,b,c+l[i])+(c?10:0));

  return res;
}

int main(){
  cin >> N >> A >> B >> C;
  l.resize(n);
  for(int i=0;i<n;i++) cin >> l[i];
  cout << rec(0,0,0,0) << endl;
}

Compiler output:
a.cc: In function 'int rec(int, int, int, int)':
a.cc:10:9: error: 'n' was not declared in this scope
   10 |   if(i==n){
      |         ^
a.cc:11:31: error: 'INF' was not declared in this scope
   11 |     if(!a || !b || !c) return INF;
      |                               ^~~
a.cc: In function 'int main()':
a.cc:25:12: error: 'n' was not declared in this scope
   25 |   l.resize(n);
      |            ^
Language: C++

#include <iostream>
#include <numeric>
#include <cstdlib>

int main(int argc, char *argv[]){
    constexpr int N_MAX = 8;

    int N, A, B, C;
    std::cin >> N >> A >> B >> C;
    static int L[N_MAX];
    for(int i=0; i<N; ++i){
        std::cin >> L[i];
    }

    int i,j;
    int sup = std::numeric_limits<int>::max();
    int iSup = 1<<(N<<1);
    int mp = sup, tmp;
    int NA, NB, NC;
    int LA, LB, LC;
    int state;
    for(i=0; i<iSup; ++i){
        NA = 0;
        NB = 0;
        NC = 0;
        LA = 0;
        LB = 0;
        LC = 0;
        tmp = 0;
        for(j=0; j<N; ++j){
            state = (i>>(j<<1))&3;
            switch(state){
                case 0: //choose for nothing
                    break;
                case 1: //choose for A
                    ++NA;
                    LA += L[j];
                    break;
                case 2: //choose for B
                    ++NB;
                    LB += L[j];
                    break;
                case 3: //choose for C
                    ++NC;
                    LC += L[j];
                    break;
                default:
                    break;
            }
        }
        if(NA==0 || NB==0 || NC==0){
            tmp = sup;
        }else{
            tmp += std::abs(LA - A) + (NA-1)*10;
            tmp += std::abs(LB - B) + (NB-1)*10;
            tmp += std::abs(LC - C) + (NC-1)*10;
        }
        mp = std::min(mp, tmp);
    }

    std::cout << mp << std::endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:16:20: error: 'numeric_limits' is not a member of 'std'
   16 |     int sup = std::numeric_limits<int>::max();
      |                    ^~~~~~~~~~~~~~
a.cc:16:35: error: expected primary-expression before 'int'
   16 |     int sup = std::numeric_limits<int>::max();
      |                                   ^~~
Language: C++

#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int n,a,b,c;  cin >> n >> a >> b >> c;

int calc(vi v,vi l){
  int x = 0,y = 0,z = 0;
  int cnt = 0;
  rep0(i,l.size()){
    if(v[i] == 1){
      if(x != 0 and l[i] != 0){
        cnt++;
      }
      x += l[i];
    }
    if(v[i] == 2){
      if(y != 0 and l[i] != 0){
        cnt++;
      }
      y += l[i];
    }
    if(v[i] == 3){
      if(z != 0 and l[i] != 0){
        cnt++;
      }
      z += l[i];
    }
  }
  return abs(a-x)+abs(b-y)+abs(c-z)+cnt*10;
}

int main(){
  vi l(n);
  rep0(i,n){
    cin >> l[i];
  }
  int ans = INT_MAX;
  for(int i = 0; i < (1 << 2*n); i++){
    vi v(n);
    rep0(j,n){
      v[j] = (i >> j*2) & 3;
    }
    ans = min(ans,calc(v,l));
  }
  cout << ans;
}


Compiler output:
a.cc:31:15: error: 'cin' does not name a type
   31 | int n,a,b,c;  cin >> n >> a >> b >> c;
      |               ^~~
Language: C++

#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int calc(vi v,int a,int b,int c, vi l){
  int x = 0,y = 0,z = 0;
  int cnt = 0;
  rep0(i,v.size()){
    if(v[i] == 0){
      static cnt--;
      x += l[i];
      cnt++;
    }else if(v[i] == 1){
      static cnt--;
      y += l[i];
      cnt++;
    }else if(v[i] == 2){
      static cnt--;
      z += l[i];
      cnt++;
    }
  }
  return abs(a-x)+abs(b-y)+abs(c-z)+cnt*10;
}

int main(){
  int n,a,b,c;  cin >> n >> a >> b >> c;
  vi l(n);
  int ans = 0;;
  rep0(i,n){
    cin >> l[i];
    ans += l[i];
  }
  for(int i = 0; i < (1 << 2*n); i++){
    vi v(n);
    rep0(j,n){
      v[j] = (i >> j*2) & 3;
    }
    ans = min(ans,calc(v,a,b,c,l));
  }
  cout << ans;
}


Compiler output:
a.cc: In function 'int calc(std::vector<int>, int, int, int, std::vector<int>)':
a.cc:36:14: error: 'cnt' does not name a type; did you mean 'int'?
   36 |       static cnt--;
      |              ^~~
      |              int
a.cc:40:14: error: 'cnt' does not name a type; did you mean 'int'?
   40 |       static cnt--;
      |              ^~~
      |              int
a.cc:44:14: error: 'cnt' does not name a type; did you mean 'int'?
   44 |       static cnt--;
      |              ^~~
      |              int
Language: C++

N, A, B, C = map(int, input().split())
 l = [int(input()) for i in range(N)]
 INF = 10 ** 9

 def dfs(cur, a, b, c):
 if cur == N:
 return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
 ret0 = dfs(cur + 1, a, b, c)
 ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
 ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
 ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
 return min(ret0, ret1, ret2, ret3)

 print(dfs(0, 0, 0, 0))


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N, A, B, C = map(int, input().split())
      | ^
Language: C++

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

int n;
Vi take,goal(3);

int dfs(int depth,Vi now){
    if(depth==n){
        REP(i,0,3) if(now[i]==0) return INF;
        int ret=0;
        REP(i,0,3) ret+=abs(now[i]-goal[i]);
        return ret;
    }
    
    int ret=INF;
    REP(i,0,3){
        now[i]+=take[depth];
        if(now[i]==0){
            chmin(ret,dfs(depth+1,next));
        }else{
            chmin(ret,dfs(depth+1,next)+10);
        }
        chmin(ret,dfs(depth+1,now));
    }
    return ret;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    vin(goal);
    take=Vi(n);
    vin(take);
    int ans = dfs(0,Vi(3,0));
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'long long int dfs(long long int, Vi)':
a.cc:55:26: error: cannot resolve overloaded function 'next' based on conversion to type 'Vi' {aka 'std::vector<long long int>'}
   55 |             chmin(ret,dfs(depth+1,next));
      |                       ~~~^~~~~~~~~~~~~~
a.cc:57:26: error: cannot resolve overloaded function 'next' based on conversion to type 'Vi' {aka 'std::vector<long long int>'}
   57 |             chmin(ret,dfs(depth+1,next)+10);
      |                       ~~~^~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
void chmin(int &a,int b) {if(a > b) a=b;}

int N,A,B,C;
vector<int> l;

int rec(int i,int a,int b,int c){
  if(i == N){
    if(!a || !b || !c) return 1e9;
    else return abs(a-A) + abs(b-B) + abs(c-C);
  }
  
  int res=rec(i+1,a,b,c);
  
  chmin(res,rec(i+1,a+l[i],b,c)+(a ? 10 : 0));
  chmin(res,rec(i+1,a,b+l[i],c)+(b ? 10 :0 ));
  chmin(res,rec(i+1,a,b,c+l[i])+(c ? 10 : 0));
  
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> A >> B >> C;
  l.resize(N);
  rep(i,n) cin >> l[i];
  
  cout << rec(0,0,0,0) << endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: 'n' was not declared in this scope
   30 |   rep(i,n) cin >> l[i];
      |         ^
a.cc:2:33: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<(n);++i)
      |                                 ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,ans=0,cnt=0,ret_0,ret_1,ret_2,ret_3;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;



int dfs(int n,int a,int b,int c){ //n本目まででa,b,cを作るのに必要なコスト
  if(n==0) return A+B+C;
  ret_0=dfs(n-1,a,b,c);
  ret_1=dfs(n-1,a-P.at(i),b,c)+10;
  ret_2=dfs(n-1,a,b-P.at(i),c)+10;
  ret_3=dfs(n-1,a,b,c-P.at(i))+10;
  return min(ret_0,min(ret_1,min(ret_2,ret_3)))+abs(a-A)+abs(b-B)+abs(c-C);
}


int main(){
  cin>>N>>A>>B>>C;
  P.push_back(0);
  REP(i,N){
    int h;
    cin>>h;
    P.push_back(h);
  }
  
  dfs(N,A,B,C);
}

Compiler output:
a.cc: In function 'int dfs(int, int, int, int)':
a.cc:32:24: error: 'i' was not declared in this scope
   32 |   ret_1=dfs(n-1,a-P.at(i),b,c)+10;
      |                        ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,ans=0,cnt=0,ret_0,ret_1,ret_2,ret_3,L[N+1];
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;



int dfs(int n,int a,int b,int c){ //n本目まででa,b,cを作るのに必要なコスト
  if(n==0) return A+B+C;
  ret_0=dfs(n-1,a,b,c);
  ret_1=dfs(n-1,a-L[n],b,c)+10;
  ret_2=dfs(n-1,a,b-L[n],c)+10;
  ret_3=dfs(n-1,a,b,c-L[n])+10;
  return min(ret_0,min(ret_1,min(ret_2,ret_3)))+abs(a-A)+abs(b-B)+abs(c-C);
}


int main(){
  cin>>N>>A>>B>>C;
  RREP(i,N) cin>>L[i];
  
  dfs(N,A,B,C);
}

Compiler output:
a.cc:21:56: error: size of array 'L' is not an integral constant-expression
   21 | int N,M,K,A,B,C,ans=0,cnt=0,ret_0,ret_1,ret_2,ret_3,L[N+1];
      |                                                       ~^~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,ans=0,cnt=0,ret_0,ret_1,ret_2,ret_3;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;



int dfs(int n,int a,int b,int c){ //n本目まででa,b,cを作るのに必要なコスト
  if(n==0) return A+B+C;
  ret_0=dfs(n-1,a,b,c);
  ret_1=dfs(n-1,a-L[n],b,c)+10;
  ret_2=dfs(n-1,a,b-L[n],c)+10;
  ret_3=dfs(n-1,a,b,c-L[n])+10;
  return min(ret_0,min(ret_1,min(ret_2,ret_3)))+abs(a-A)+abs(b-B)+abs(c-C);
}


int main(){
  cin>>N>>A>>B>>C;
  int L[N+1];
  RREP(i,N) cin>>L[i];
  
  dfs(N,A,B,C);
}

Compiler output:
a.cc: In function 'int dfs(int, int, int, int)':
a.cc:32:19: error: 'L' was not declared in this scope
   32 |   ret_1=dfs(n-1,a-L[n],b,c)+10;
      |                   ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;



int dfs(int n,int a,int b,int c){ //n本目まででa,b,cを作るのに必要なコスト
  if(n==0) return A+B+C;
  ret_0=dfs(n-1,a,b,c);
  ret_1=dfs(n-1,a-L[n],b,c)+10;
  ret_2=dfs(n-1,a,b-L[n],c)+10;
  ret_3=dfs(n-1,a,b,c-L[n])+10;
  return min(ret_0,min(ret_1,min(ret_2,ret_3)))+abs(a-A)+abs(b-B)+abs(c-C);
}


int main(){
  cin>>N>>A>>B>>C;
  int L[N+1];
  RREP(i,N) cin>>L[i];
  
  dfs(N,A,B,C);
}

Compiler output:
a.cc: In function 'int dfs(int, int, int, int)':
a.cc:31:3: error: 'ret_0' was not declared in this scope
   31 |   ret_0=dfs(n-1,a,b,c);
      |   ^~~~~
a.cc:32:3: error: 'ret_1' was not declared in this scope
   32 |   ret_1=dfs(n-1,a-L[n],b,c)+10;
      |   ^~~~~
a.cc:32:19: error: 'L' was not declared in this scope
   32 |   ret_1=dfs(n-1,a-L[n],b,c)+10;
      |                   ^
a.cc:33:3: error: 'ret_2' was not declared in this scope
   33 |   ret_2=dfs(n-1,a,b-L[n],c)+10;
      |   ^~~~~
a.cc:34:3: error: 'ret_3' was not declared in this scope
   34 |   ret_3=dfs(n-1,a,b,c-L[n])+10;
      |   ^~~~~
Language: C++

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

int rec(int N, int i, const std::vector<int>& L, int a, int b, int c, int A, int B, int C)
{
    if (i >= N-1) {
        if (a == 0 || b == 0 || c == 0) return 99999999;
        return std::abs(a-A) + std::abs(b-B) + std::abs(c-C) - 30;
    }

    int r0 = rec(N, i+1, L, a, b, c, A, B, C);
    int r1 = rec(N, i+1, L, a + L[i], b, c, A, B, C) + 10;
    int r2 = rec(N, i+1, L, a, b + L[i], c, A, B, C) + 10;
    int r3 = rec(N, i+1, L, a, b, c + L[i], A, B, C) + 10;

    return std::min({r0, r1, r2, r3});
}


int main()
{
    int N, A, B, C;
    std::cin >> N >> A >> B >> C;

    std::vector<int> L(N);
    for (int i = 0; i < N; i++) std::cin >> L[i];

    int ans = rec(N, 0, L, 0, 0, 0);

    std::cout << ans << std::endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:18: error: too few arguments to function 'int rec(int, int, const std::vector<int>&, int, int, int, int, int, int)'
   30 |     int ans = rec(N, 0, L, 0, 0, 0);
      |               ~~~^~~~~~~~~~~~~~~~~~
a.cc:6:5: note: declared here
    6 | int rec(int N, int i, const std::vector<int>& L, int a, int b, int c, int A, int B, int C)
      |     ^~~
Language: C++

#include <iostream>
#include <vector>
#include <cmath>

int rec(int N, int i, const std::vector<int>& L, int a, int b, int c, int A, int B, int C)
{
    if (i >= N-1) {
        if (a == 0 || b == 0 || c == 0) return 99999999;
        return std::abs(a-A) + std::abs(b-B) + std::abs(c-C) - 30;
    }

    int r0 = rec(N, i+1, L, a, b, c, A, B, C);
    int r1 = rec(N, i+1, L, a + L[i], b, c, A, B, C) + 10;
    int r2 = rec(N, i+1, L, a, b + L[i], c, A, B, C) + 10;
    int r3 = rec(N, i+1, L, a, b, c + L[i], A, B, C) + 10;

    return std::min({r0, r1, r2, r3});
}


int main()
{
    int N, A, B, C;
    std::cin >> N >> A >> B >> C;

    std::vector<int> L(N);
    for (int i = 0; i < N; i++) std::cin >> L[i];

    int ans = rec(N, 0, L, 0, 0, 0);

    std::cout << ans << std::endl;

    return 0;
}

Compiler output:
a.cc: In function 'int rec(int, int, const std::vector<int>&, int, int, int, int, int, int)':
a.cc:17:20: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   17 |     return std::min({r0, r1, r2, r3});
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
a.cc: In function 'int main()':
a.cc:29:18: error: too few arguments to function 'int rec(int, int, const std::vector<int>&, int, int, int, int, int, int)'
   29 |     int ans = rec(N, 0, L, 0, 0, 0);
      |               ~~~^~~~~~~~~~~~~~~~~~
a.cc:5:5: note: declared here
    5 | int rec(int N, int i, const std::vector<int>& L, int a, int b, int c, int A, int B, int C)
      |     ^~~
Language: C++

#include <iostream>
#include <vector>
#include <cmath>

int rec(int i, const std::vector<int>& L, int a, int b, int c, int A, int B, int C)
{
    if (i >= N-1) {
        if (a == 0 || b == 0 || c == 0) return 9999999999;
        return std::abs(a-A) + std::abs(b-B) + std::abs(c-C) - 30;
    }

    int r0 = rec(i+1, L, a, b, c, A, B, C);
    int r1 = rec(i+1, L, a + L[i], b, c, A, B, C) + 10;
    int r2 = rec(i+1, L, a, b + L[i], c, A, B, C) + 10;
    int r3 = rec(i+1, L, a, b, c + L[i], A, B, C) + 10;

    return std::min({r0, r1, r2, r3});
}


int main()
{
    int N, A, B, C;
    std::cin >> N >> A >> B >> C;

    std::vector<int> L(N);
    for (int i = 0; i < N; i++) std::cin >> L[i];

    int ans = rec(0, L, 0, 0, 0);

    std::cout << ans << std::endl;

    return 0;
}

Compiler output:
a.cc: In function 'int rec(int, const std::vector<int>&, int, int, int, int, int, int)':
a.cc:7:14: error: 'N' was not declared in this scope
    7 |     if (i >= N-1) {
      |              ^
a.cc:8:48: warning: overflow in conversion from 'long int' to 'int' changes value from '9999999999' to '1410065407' [-Woverflow]
    8 |         if (a == 0 || b == 0 || c == 0) return 9999999999;
      |                                                ^~~~~~~~~~
a.cc:17:20: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   17 |     return std::min({r0, r1, r2, r3});
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
a.cc: In function 'int main()':
a.cc:29:18: error: too few arguments to function 'int rec(int, const std::vector<int>&, int, int, int, int, int, int)'
   29 |     int ans = rec(0, L, 0, 0, 0);
      |               ~~~^~~~~~~~~~~~~~~
a.cc:5:5: note: declared here
    5 | int rec(int i, const std::vector<int>& L, int a, int b, int c, int A, int B, int C)
      |     ^~~
Language: C++

#include<iostream>
using namespace std;

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  int l[8];
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }

  int ans = 1000000000;
  for (int bit = 0; bit < (1 << 2 * N); bit++) {
    int lengthA = 0;
    int cntA = 0;
    int lengthB = 0;
    int cntB = 0;
    int lengthC = 0;
    int cntC = 0;
    for (int i = 0; i < N; i++) {
      int flag = 2 * ((bit >> (2 * i + 1)) & 1) + ((bit >> 2 * i) & 1);
      if (flag == 1) {
        lengthA += l[i];
        cntA += 1;
      }
      if (flag == 2) {
        lengthB += l[i];
        cntB += 1;
      }
      if (flag == 3) {
        lengthC += l[i];
        cntC += 1;
      }
    }

    if (lengthA != 0 && lengthB != 0 && lengthC != 0) {
      int mps = math.abs(A - lengthA) + (cntA - 1) * 10 + math.abs(B - lengthB) + (cntB - 1) * 10 + math.abs(C - lengthC) + (cntC - 1) * 10
      ans = math.min(mps, ans)
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:17: error: 'math' was not declared in this scope
   37 |       int mps = math.abs(A - lengthA) + (cntA - 1) * 10 + math.abs(B - lengthB) + (cntB - 1) * 10 + math.abs(C - lengthC) + (cntC - 1) * 10
      |                 ^~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int dfs(vector<int> l, int i, int a, int b, int c, int A, int B, int C, int current){
  int n=l.size();
  int res;
  if(i==n){
    if(a==0 || b==0 || c==0){
      res = INT_MAX;
    }else{
      res = current+abs(a-A)+abs(b-B)+abs(c-C);
    }
  }else{
    if(a!=0){
      res = dfs(l,i+1,a+l[i], b, c, A, B, C, current+10);
    }else{
      res = dfs(l, i+1, a+l[i], b, c, A, B, C, current);
    }
    if(b!=0){
      res = min(res,dfs(l, i+1, a, b+l[i], c, A, B, C, current+10));
    }else{
      res = min(res,dfs(l, i+1, a, b+l[i], c, A, B, C, current));
    }
    if(c!=0){
      res = min(res,dfs(l, i+1, a, b, c+l[i], A, B, C, current+10));
    }else{
      res = min(res,dfs(l, i+1, a, b, c+l[i], A, B, C, current));
    }
    res = min(res,dfs(l, i+1, a, b, c, A, B, C, current))
  }
  return res;
}
  
  
int main(){
  
  int n,a,b,c;
  cin>>n>>a>>b>>c;
  vector<int> l(n);
  REP(i,n){
    cin>>l[i];
  }
  
  int ans;
  ans = dfs(l,0,0,0,0,a,b,c,0);
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int dfs(std::vector<int>, int, int, int, int, int, int, int, int)':
a.cc:114:58: error: expected ';' before '}' token
  114 |     res = min(res,dfs(l, i+1, a, b, c, A, B, C, current))
      |                                                          ^
      |                                                          ;
  115 |   }
      |   ~
Language: C++

#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll dfs(ll i,ll ap,ll bp,ll cp,ll n,ll a,ll b,ll c,vector<ll> l){
    if(i==n){
        if(min({ap,bp,cp})>0) return fabs(a-ap)+fabs(b-bp)+fabs(c-cp)-30;
        else return 1e9;
    }
    ll usea=dfs(i+1,ap+l[i],bp,cp,n,a,b,c,l)+10;
    ll useb=dfs(i+1,ap,bp+l[i],cp,n,a,b,c,l)+10;
    ll usec=dfs(i+1,ap,bp,cp+l[i],n,a,b,c,l)+10;
    ll use_=dfs(i+1,ap,bp,cp,n,a,b,c,l);
    return min({usea,useb,usec,use_})
}

int main(){
    ll n,a,b,c;
    cin>>n>>a>>b>>c;
    vector<ll> l(n);
    for(ll i=0;i<n;i++) cin>>l[i];
    cout<<dfs(0,0,0,0,n,a,b,c)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'll dfs(ll, ll, ll, ll, ll, ll, ll, ll, std::vector<long long int>)':
a.cc:17:38: error: expected ';' before '}' token
   17 |     return min({usea,useb,usec,use_})
      |                                      ^
      |                                      ;
   18 | }
      | ~                                     
a.cc: In function 'int main()':
a.cc:25:14: error: too few arguments to function 'll dfs(ll, ll, ll, ll, ll, ll, ll, ll, std::vector<long long int>)'
   25 |     cout<<dfs(0,0,0,0,n,a,b,c)<<endl;
      |           ~~~^~~~~~~~~~~~~~~~~
a.cc:8:4: note: declared here
    8 | ll dfs(ll i,ll ap,ll bp,ll cp,ll n,ll a,ll b,ll c,vector<ll> l){
      |    ^~~
Language: C++

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

void chmin(int &a, int b) { if (a > b) a = b; }

int N, A, B, C;
vector<int> L;


int rec(int i, int a, int b, int c) {
    if (i == N) {
        if (!a || !b || !c) return INF;
        return abs(a - A) + abs(b - B) + abs(c - C);


    int res = rec(i+1, a, b, c);
    

    chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
    chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
    
    return res;
}




int main () {

    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i< N; ++i) cin >> L[i];

    cout << rec(0, 0, 0, 0) << endl;
}


Compiler output:
a.cc: In function 'int rec(int, int, int, int)':
a.cc:59:10: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   59 | int main () {
      |          ^~
a.cc:59:10: note: remove parentheses to default-initialize a variable
   59 | int main () {
      |          ^~
      |          --
a.cc:59:10: note: or replace parentheses with braces to value-initialize a variable
a.cc:59:13: error: a function-definition is not allowed here before '{' token
   59 | int main () {
      |             ^
a.cc:66:2: error: expected '}' at end of input
   66 | }
      |  ^
a.cc:40:37: note: to match this '{'
   40 | int rec(int i, int a, int b, int c) {
      |                                     ^
a.cc:66:2: warning: control reaches end of non-void function [-Wreturn-type]
   66 | }
      |  ^
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
void chmin(int &a, int b) { if (a > b) a = b; }

int N, A, B, C;
vector<int> L;

// 再帰
int rec(int i, int a, int b, int c) {
    if (i == N) {
        if (!a || !b || !c) return INF; // A, B, C いずれも竹は 1 本は必ず使ってないとダメ
        return abs(a - A) + abs(b - B) + abs(c - C); // 合体してできた a, b, c を A, B, C にするコスト
    }

    // 今ある竹を採用しない場合
    int res = rec(i+1, a, b, c);
    
    // A, B, C を使う場合。
    // (a ? 10 : 0) とかは、最初の 1 本目は合体コストなし、2 本目からはコスト 10 かかることを意味する
    chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
    chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
    
    return res;
}

int main() {
    // 入力
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i< N; ++i) cin >> L[i];
    
    // 再帰する
    cout << rec(0, 0, 0, 0) << endl;
}

Compiler output:
a.cc: In function 'int rec(int, int, int, int)':
a.cc:14:36: error: 'INF' was not declared in this scope
   14 |         if (!a || !b || !c) return INF; // A, B, C いずれも竹は 1 本は必ず使ってないとダメ
      |                                    ^~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

// http://drken1215.hatenablog.com/entry/2019/02/24/224100
// https://qiita.com/nomikura/items/4e66f708895fb7db76d1

void chmin(int &a, int b) {
    // b のが小さければ，aを入れ替える
     if (a > b) {
         a = b;
     } 
}


// solve
int rec(int i, int a, int b, int c, const int n, const int ca, const int cb, const int cc, int* l) {
    if(i == n) {
        if(!a || !b || !c) {
            // 1本も使ってない
            return INFINITY;
        }
        // 合体後の差分
        return abs(a-ca) + abs(b-cb) + abs(c-cc);
    }

    // 選ばないことにした場合のコスト
    int res = rec(i+1,a,b,c,n,ca,cb,cc,l);
    // Aにマージした際のコスト
    chmin(res, rec(i+1, a+l[i], b,c,n,ca,cb,cc,l)+(a?10:0));
    // Bにマージした際のコスト
    chmin(res, rec(i+1, a, b+l[i],c,n,ca,cb,cc,l)+(b?10:0));
    // Cにマージした際のコスト
    chmin(res, rec(i+1, a, b,c+l[i],n,ca,cb,cc,l)+(c?10:0));
    // 1本目はコスト増加なし

    // それぞれを選んだ場合のコストの小さい値にresを入れ替える
    // 深さ優先探索の結果，最小のresがドンドン上に伝搬する
    // 最終的には，全ノードを考慮した探索が行える

    return res;

}


int main(void) {

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    int *l = new int[n];

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

    cout << rec(0,0,0,0,n,a,b,c,l) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int rec(int, int, int, int, int, int, int, int, int*)':
a.cc:24:20: error: 'INFINITY' was not declared in this scope
   24 |             return INFINITY;
      |                    ^~~~~~~~
Language: C++

import itertools

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

state = ['A', 'B', 'C', 'D']
loop = list(itertools.product(state, repeat=N))

m = 10**8

for i in range(4**N):
    takeA = 0
    takeB = 0
    takeC = 0
    syn = -3
    for j in range(N):
        if loop[i][j] == 'A':
            takeA += l[j]
            syn += 1
        elif loop[i][j] == 'B':
            takeB += l[j]
            syn += 1
        elif loop[i][j] == 'C':
            takeC += l[j]
            syn += 1
    if takeA!=0 and takeB!=0 and takeC!=0:
        m = min(m, abs(takeA-A)+abs(takeB-B)+abs(takeC-C)+10*syn)
        
print(m)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import itertools
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'