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

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int MAX_N = 8;
int N, A, B, C;
vector<int> l(MAX_N);

int dfs(int depth, int a, int b, int c) {
    if(depth == N) {
        if(a == 0 || b == 0 || c == 0) {
            return 99999999;
        }
        return abs(a-A) + abs(b-B) + abs(c-C) - 30; 
    }
    else {
        int notUse = dfs(depth+1, a, b, c);
        int useForA = dfs(depth+1, a+l[depth], b, c);
        int useForB = dfs(depth+1, a, b+l[depth], c);
        int useForC = dfs(depth+1, a, b, c+l[depth]);
        return min({notUse, useForA, useForB, useForC});
    }
}

int main() {
    cin >> N >> A >> B >> C;
    rep(i, n) {
        cin >> l[i];
    }

    cout << dfs(0, 0, 0, 0);

    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:12: error: 'n' was not declared in this scope
   33 |     rep(i, n) {
      |            ^
a.cc:7:39: note: in definition of macro 'rep'
    7 | #define rep(i, n) for(int i = 0; i < (n); i++)
      |                                       ^
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int MAX_N = 8;
int N, A, B, C;
vector<int> l(MAX_N);

int dfs(int depth, int a, int b, int c) {
    if(depth == N) {
        if(a == 0 || b == 0 || c == 0) {
            return 99999999;
        }
        return abs(a-A) + abs(b-B) + abs(c-C) - 30; 
    }
    else {
        int notUse = dfs(depth+1, a, b, c);
        int useForA = dfs(depth+1, a+l[depth], b, c);
        int useForB = dfs(depth+1, a, b+l[depth], c);
        int useForC = dfs(depth+1, a, b, c+l[depth]);
        return min({notUse, useForA, useForB, useForC});
    }
}

int main() {
    cin >> N >> A >> B >> C;
    reo(i, n) {
        cin >> l[i];
    }

    cout << dfs(0, 0, 0, 0);

    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: 'i' was not declared in this scope
   33 |     reo(i, n) {
      |         ^
a.cc:33:12: error: 'n' was not declared in this scope
   33 |     reo(i, n) {
      |            ^
a.cc:33:5: error: 'reo' was not declared in this scope; did you mean 'rep'?
   33 |     reo(i, n) {
      |     ^~~
      |     rep
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>	//cout << fixed << setprecision(桁数);

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define All(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
const int INF = INT_MAX;
//#define int long long
template<class T> void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> void chmin(T& a, T 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);
	rep(i, N)	cin >> L.at(i);

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

	return 0;
}


Compiler output:
a.cc:12:17: error: 'INT_MAX' was not declared in this scope
   12 | const int INF = INT_MAX;
      |                 ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <iomanip>      //cout << fixed << setprecision(桁数);
  +++ |+#include <climits>
    7 |
Language: C++

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

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

int dfs(int n, int a, int b, int c){
  if(n == N){
    if(std::min( {a, b, c} ) > 0){
      return std::fabs(a - A) + std::fabs(b - B) + std::fabs(c - C) - 30;
    }else{
      return 100000;
    }
  }

  int mp1 = dfs(n + 1, a, b, c);
  int mp2 = dfs(n + 1, a + l[n], b, c) + 10;
  int mp3 = dfs(n + 1, a, b + l[n] ,c) + 10;
  int mp4 = dfs(n + 1, a, b, c + l[n]) + 10;
  return min( {mp1, mp2, mp3, mp4} );
}

int main(){
  std::cin >> N >> A >> B >> C;
  std::copy_n(std::istream_iterator<int>(std::cin), N, std::back_inserter(l));
  std::cout << dfs(0, 0, 0, 0) << std::endl;
  return 0;
}


Compiler output:
a.cc: In function 'int dfs(int, int, int, int)':
a.cc:23:10: error: 'min' was not declared in this scope; did you mean 'std::min'?
   23 |   return min( {mp1, mp2, mp3, mp4} );
      |          ^~~
      |          std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

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

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

int dfs(int n, int a, int b, int c){
  if(n == N){
    if(min( {a, b, c} ) >0){
      return std::fabs(a - A) + std::fabs(b - B) + std::fabs(c - C) - 30;
    }else{
      return 100000;
    }
  }
  int mp1 = dfs(n + 1, a, b, c);
  int mp2 = dfs(n + 1, a + l[n], b, c) + 10;
  int mp3 = dfs(n + 1, a, b + l[n] ,c) + 10;
  int mp4 = dfs(n + 1, a, b, c + l[n]) + 10;
  return min( {mp1, mp2, mp3, mp4} );
}

int main(){
  std::cin >> N >> A >> B >> C;
  std::copy_n(std::istream_iterator<int>(std::cin), N , std::back_inserter(l));
  std::cout << dfs(0, 0, 0, 0) << std::endl;
  return 0;
}


Compiler output:
a.cc: In function 'int dfs(int, int, int, int)':
a.cc:11:8: error: 'min' was not declared in this scope; did you mean 'std::min'?
   11 |     if(min( {a, b, c} ) >0){
      |        ^~~
      |        std::min
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:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:21:10: error: 'min' was not declared in this scope; did you mean 'std::min'?
   21 |   return min( {mp1, mp2, mp3, mp4} );
      |          ^~~
      |          std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:26:8: error: 'copy_n' is not a member of 'std'; did you mean 'copy'?
   26 |   std::copy_n(std::istream_iterator<int>(std::cin), N , std::back_inserter(l));
      |        ^~~~~~
      |        copy
Language: C++

import java.util.Scanner;

public class Main {
	private static int[] L;
	private static int N, A, B, C;
	private static int INF = 10000000;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		L = new int[N];
		for (int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}

		System.out.println(dfs(0, 0, 0, 0));
	}

	private static int dfs(int i, int a, int b, int c) {
		//停止条件
		if (i == N) {
			if(a == 0 || b == 0 || c == 0) return INF;	//いずれも一本は必ず使わなければならない
			return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30;	//合体してできたa, b, cをA, B, Cにするコスト
		}

		//分岐
		//竹を使わないとき
		int res = dfs(i + 1, a, b, c);
		//A, B, Cを使うとき
		res = Math.min(res, dfs(i + 1, a + L[i], b, c) + 10);
		res = Math.min(res, dfs(i + 1, a, b + L[i], c) + 10);
		res = Math.min(res, dfs(i + 1, a, b, c + L[i]) + 10);

		return res;
	}
}

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

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

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

int dfs(int a, int b, int c, int i){
 if(i == N){//末端まで探索した時の処理
   if(a == 0 || b == 0 || c == 0) return 1000000;
   return abs(a - A) + abs(b - B) + abs(c - C) - 30;
 }
 //再帰
 int choose_A = dfs(a + l[i], b, c, i + 1) + 10;
 int choose_B = dfs(a, b + l[i], c, i + 1) + 10;
 int choose_C = dfs(a, b, c + l[i], i + 1) + 10;
 int choose_none = dfs(a, b, c, i + 1);
 return min({choose_A, choose_B, choose_C, choose_none});
}

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


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

#include <iostream>
#include <algorithm>
#define INF 100000000

using namespace std;

int N, A, B, C;
int l[8];


int dfs(int n, int a, int b, int c) {
    if (n == 0) {
        if (a == 0 || b == 0 || c == 0) {
            return INF;
        } else {
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        }
    }

    int l = l[n - 1];
    int ret0 = dfs(n - 1, a, b, c);
    int ret1 = dfs(n - 1, a + l, b, c) + 10;
    int ret2 = dfs(n - 1, a, b + l, c) + 10;
    int ret3 = dfs(n - 1, a, b, c + l) + 10; 

    return min({ret0, ret1, ret2, ret3});
}

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

    cout << dfs(N, 0, 0, 0) << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int dfs(int, int, int, int)':
a.cc:20:14: error: invalid types 'int[int]' for array subscript
   20 |     int l = l[n - 1];
      |              ^
Language: C++


N,A,B,C = input().split()

N= int(N)
A= int(A)
B= int(B)
C= int(C)

stick =[]
leng = []
left_nums = ""
all_zero = ""


for i in range(N):

    x = int(input())
    stick.append(x)
    left_nums += "1"
    all_zero += "0"


for i in range(2 ** N):

    uses_int = format(i,'b')
    uses = uses_int.zfill(N)

    lensum = 0
    
    for j in range(N):

        if (uses[j] == "1"):
            lensum += stick[j]

    leng.append( [lensum , uses] )

#print (leng)


order = ((A,B,C),(A,C,B),(B,A,C),(B,C,A),(C,A,B),(C,B,A))


mini_last = 3000

for i in range(6): #ABC全ての順番において最小を調べる

    point = 0
    lefts = left_nums # 1がN個並んでいる文字列
    

    for j in range(3): #A,B,Cそれぞれの場合において最小を考察&出力

            
            goal = order[i][j] #近づける値

            mini_point = 1000
            mini_num = ""

            for k in leng:

                if (  abs( k[0] - goal ) + ( k[1].count('1') - 1 ) * 10 < mini_point and abs( k[0] - goal ) + ( k[1].count('1') - 1 ) * 10 >= 0  and k[1] != all_zero ):

                    flag = True
                    for m in range(N):

                        if (lefts[m] == "0" and k[1][m] == "1"):
                            flag = False
                            #print ("lefts:",lefts," nowk1:",k[1])

                    if (flag):
                        mini_point = abs( k[0] - goal ) + ( k[1].count('1') - 1 ) * 10
                        mini_num = k[1]


            for m in range(N):

                if (mini_num[m] == "1"):
                    lef_lis = list(lefts)
                    lef_lis[m] = "0"
                    lefts = "".join(lef_lis)

            point += mini_point

            #print ("mp:",mini_point ," mn:",mini_num)

    if (point < mini_last):
        mini_last = point


print (mini_last)

            

Compiler output:
a.cc:37:2: error: invalid preprocessing directive #print
   37 | #print (leng)
      |  ^~~~~
a.cc:45:20: error: stray '#' in program
   45 | for i in range(6): #ABC全ての順番において最小を調べる
      |                    ^
a.cc:48:23: error: stray '#' in program
   48 |     lefts = left_nums # 1がN個並んでいる文字列
      |                       ^
a.cc:51:24: error: stray '#' in program
   51 |     for j in range(3): #A,B,Cそれぞれの場合において最小を考察&出力
      |                        ^
a.cc:54:32: error: stray '#' in program
   54 |             goal = order[i][j] #近づける値
      |                                ^
a.cc:68:30: error: invalid preprocessing directive #print
   68 |                             #print ("lefts:",lefts," nowk1:",k[1])
      |                              ^~~~~
a.cc:84:14: error: invalid preprocessing directive #print
   84 |             #print ("mp:",mini_point ," mn:",mini_num)
      |              ^~~~~
a.cc:2:1: error: 'N' does not name a type
    2 | N,A,B,C = input().split()
      | ^
Language: C++

#include<iostream>
#include<vector>
#include<climits>

using namespace std;

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

int dfs(int depth, int LA, int LB, int LC){
  if( depth == N ){ 
    if(LA && LB && LC){return abs(LA - A) + abs(LB - B) + abs(LC - C) - 30;}
     else{ return INT_MAX;}}
  
   int ret1 = dfs( depth+1, LA + l[depth],LB,LC) + 10 ;
   int ret2 = dfs( depth+1, LA, LB + l[depth], LC) + 10;
   int ret3 = dfs( depth+1, LA, LB, LC + l[depth]) + 10;
   int ret4 = dfs( depth+1, LA,LB,LC);
  
   return min(min(ret1,ret2),min(ret3,ret4));}
  


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

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

using namespace std;

//INF
const long long INF = 1LL << 60;

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

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

//再帰
//i は竹の添字
int rec(int i, int a, int b, int c)
{
    //竹をi=0-Nまで見終わったとき
    int(i==N)
    {
        if(!a || !b || !c) return INF;//a,b,cどれか1つでも0のときは竹をつかっていないのでNG
        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)　は三項演算子
    //a==0のときのみFalseなので0,それ以外は10になる
    //これは最初の一本目だけは合体ではないのでコストが0であることを意味する
    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:24:14: error: expected ';' before '{' token
   24 |     int(i==N)
      |              ^
      |              ;
   25 |     {
      |     ~
Language: C++

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

using namespace std;

//INF
const long long INF = 1LL << 60;

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

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

//再帰
//i は竹の添字
int rec(int i, int a, int b, int c)
{
    //竹をi=0-Nまで見終わったとき
    int(i==N)
    {
        if(!a || !b || !c) return INF;//a,b,cどれか1つでも0のときは竹をつかっていないのでNG
        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)　は三項演算子
    //a==0のときのみFalseなので0,それ以外は10になる
    //これは最初の一本目だけは合体ではないのでコストが0であることを意味する
    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);
    rep(i,N)cin>>L[i];

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

Compiler output:
a.cc: In function 'int rec(int, int, int, int)':
a.cc:24:14: error: expected ';' before '{' token
   24 |     int(i==N)
      |              ^
      |              ;
   25 |     {
      |     ~         
a.cc: In function 'int main()':
a.cc:49:9: error: 'i' was not declared in this scope
   49 |     rep(i,N)cin>>L[i];
      |         ^
a.cc:49:5: error: 'rep' was not declared in this scope; did you mean 'rec'?
   49 |     rep(i,N)cin>>L[i];
      |     ^~~
      |     rec
Language: C++

#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<limits.h>

using namespace std;

int main()
{
	int ans = INT_MAX;
	int n, a, b, c;
	vector<int> kadomatu;
	vector<int> takechoice;
	int wk;

	int wa, wb, wc;
	int mpa, mpb, mpc;


	cin >> n >> a >> b >> c;

	for (int i = 0; i < n; i++) {
		cin >> wk;
		kadomatu.push_back(wk);
		takechoice.push_back(0);
	}

	int loop = pow(4, n);
	int wkans;
	for (int i = 0; i < loop; i++) {
		wkans = 0;
		wk = i;
		for (int j = 0; j < n; j++) {
			takechoice[j] = wk % 4;
			wk /= 4;
		}

		wa = 0;
		wb = 0;
		wc = 0;

		for (int j = 0; j < n; j++) {
			if (takechoice[j] == 0) {
				wa += kadomatu[j];
				if (wa != kadomatu[j])wkans += 10;

			}
			else if (takechoice[j] == 1) {
				wb += kadomatu[j];
				if (wb != kadomatu[j])wkans += 10;

			}
			else if(takechoice[j] == 2){
				wc += kadomatu[j];
				if (wc != kadomatu[j])wkans += 10;

			}
		}

		if (wa * wb * wc == 0)continue;

		wkans += abs(a - wa);
		wkans += abs(b - wb);
		wkans += abs(c - wc);

		if (wkans < ans)ans = wkans;






	}



	cout << ans << endl;




	return 0;



}



Compiler output:
a.cc: In function 'int main()':
a.cc:30:20: error: 'pow' was not declared in this scope
   30 |         int loop = pow(4, n);
      |                    ^~~
Language: C++

#include<bits\stdc++.h>
#include<math.h>
using namespace std ;
int N,A,B,C,arr[100];
int ret_cost(int n,int a,int b,int c)
{
    if(n==N)
    {
        return  (abs(A-a)+abs(B-b)+abs(C-c)) ;
    }
    int ret = (a>0 ? 10:0) + ret_cost(n+1,a+arr[n],b,c);
    ret = min ( ret ,(b>0 ? 10:0) + ret_cost(n+1,a,b+arr[n],c));
    ret = min (ret ,(c>0 ? 10:0) + ret_cost(n+1,a,b,c+arr[n]));
    ret = min(ret,ret_cost(n+1,a,b,c));
}
int main()
{
    cin >> N >> A >> B >> C ;
    for(int i=0;i<N;i++)
    {
        int x ; cin >> x ; arr[i]=x ;
    }
     cout << ret_cost(0,0,0,0) << endl;;
}


Compiler output:
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
    1 | #include<bits\stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

// C. Synthetic Kadomatsu - C++.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>



using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

template <class T>
void chmin(T& ans, const T& b)
{
	if (ans > b) {
		ans = b;
	}
}

constexpr int BIG = std::numeric_limits<int>::max();

int dfs(const int N, const vec& L, int nowIdx, const int A, const int B, const int C, int a, int b, int c, int nowcost)
{
	if (N == nowIdx) {
		if (min(a, b, c) == 0) return BIG;
		else return abs(A - a) + abs(B - b) + abs(C - c) + nowcost - 30;
	}

	int ans = BIG;
	chmin(ans, dfs(N, L, nowIdx + 1, A, B, C, a, b, c, nowcost));
	chmin(ans, dfs(N, L, nowIdx + 1, A, B, C, a+L[nowIdx], b, c, nowcost+10));
	chmin(ans, dfs(N, L, nowIdx + 1, A, B, C, a, b+L[nowIdx], c, nowcost+10));
	chmin(ans, dfs(N, L, nowIdx + 1, A, B, C, a, b, c+L[nowIdx], nowcost+10));
	return ans;
}

int main()
{
	lolo N, A, B, C;
	cin >> N >> A >> B >> C;
	vec L(N);
	FOR(i, N) cin >> L[i];
	cout << dfs(N, L, 0, A, B, C, 0, 0, 0, 0) << endl;
}


Compiler output:
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:4:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:44:10:   required from here
   44 |                 if (min(a, b, c) == 0) return BIG;
      |                     ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int> P;
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; }
vector<string> v;
queue<P> Q;
int N,A,B,C;
 vector<int> L(N);
int solve(int i,int a,int b,int c){
    if(i==N){
        if(!a||!b||!c) return INF;//いずれも一本は必ず使う。
        return abs(a-A)+(b-B)+(c-C);//短縮・延長を行ったコスト
    }
    //採用しない場合
    int res=solve(i+1,a,b,c);
    chmin(res,solve(i+1,a+L.at(i),b,c))+(a?10:0);//初回だけaはＦを返す
　  chmin(res,solve(i+1,a,b+L.at(i),c))+(b?10:0);
　  chmin(res,solve(i+1,a,b,c+L.at(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.at(i);
   } 
   cout<<solve(0,0,0,0)<<endl;
} 


Compiler output:
a.cc:19:1: error: extended character 　 is not valid in an identifier
   19 | 　  chmin(res,solve(i+1,a,b+L.at(i),c))+(b?10:0);
      | ^
a.cc:20:1: error: extended character 　 is not valid in an identifier
   20 | 　  chmin(res,solve(i+1,a,b,c+L.at(i)))+(c?10:0);
      | ^
a.cc: In function 'int solve(int, int, int, int)':
a.cc:13:31: error: 'INF' was not declared in this scope
   13 |         if(!a||!b||!c) return INF;//いずれも一本は必ず使う。
      |                               ^~~
a.cc:19:1: error: '\U00003000' was not declared in this scope
   19 | 　  chmin(res,solve(i+1,a,b+L.at(i),c))+(b?10:0);
      | ^~
a.cc:20:3: error: expected ';' before 'chmin'
   20 | 　  chmin(res,solve(i+1,a,b,c+L.at(i)))+(c?10:0);
      |   ^ ~~~~~
      |   ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int N,A,B,C;
vector<int> L;

void chmin(int &x,int y){
    if(x > y){
        x = y;
    }
}

int DFS(int i,int a,int b,int c){

    if(i == N){ //終了条件
        if(!a || !b || !c){
            return 100000;
        }
        else {
            return abs(a - A) + abs(b - B) + abs(c - C);
        }
    }
    int res = rec(i+1,a,b,c);
    chmin(res,DFS(i+1,a + L[i],b,c) + (a ? 10 : 0));
    chmin(res,DFS(i+1,a,b + L[i],c) + (b ? 10 : 0));
    chmin(res,DFS(i+1,a,b,c + L[i]) + (c ? 10 : 0));

    return res;

}


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

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

Compiler output:
a.cc: In function 'int DFS(int, int, int, int)':
a.cc:22:15: error: 'rec' was not declared in this scope; did you mean 'res'?
   22 |     int res = rec(i+1,a,b,c);
      |               ^~~
      |               res
Language: C++

#include <bits/stdc++.h>
using namespace std;
int N,A,B,C;
vector<int> L;

void chmin(int &x,int y){
    if(x > y){
        x = y;
    }
}

int DFS(int i,int a,int b,int c){

    if(n == N){ //終了条件
        if(!a || !b || !c){
            return 100000;
        }
        else {
            return abs(a - A) + abs(b - B) + abs(c - C);
        }
    }
    int res = 0;
    chmin(res,DFS(i+1,a + L[i],b,c) + (a ? 10 : 0));
    chmin(res,DFS(i+1,a,b + L[i],c) + (b ? 10 : 0));
    chmin(res,DFS(i+1,a,b,c + L[i]) + (c ? 10 : 0));

    return res;

}


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

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

Compiler output:
a.cc: In function 'int DFS(int, int, int, int)':
a.cc:14:8: error: 'n' was not declared in this scope
   14 |     if(n == N){ //終了条件
      |        ^
Language: C

#include<stdio.h>
#include<math.h>

int i,j,k=0;
int N,A,B,C;
scanf("%d %d %d %d",&N,&A,&B,&C);

for(i=0;i<N;i++){
  scanf("%d",&A[i]);
}

int min(int a,int b){
  if(a > b)
    return b;
  else
    return a;
}

int dfs(int a,int b, int c, int d){
  if(d == N)
    return (abs(a-A)+abs(b-B)+abs(c-C) -30);
  int ret0 = dfs(a+A[d],b,c,d+1)+10;
  int ret1 = dfs(a,b+A[d],c,d+1)+10;
  int ret2 = dfs(a,b,c+A[d],d+1)+10;
  int ret3 = dfs(a,b,c,d+1);
  return min((min(a,b),min(c,d));
             }

int main(){
  printf("%d\n",dfs(0,0,0,0));
  return 0;
}
  

Compiler output:
main.c:6:7: error: expected declaration specifiers or '...' before string constant
    6 | scanf("%d %d %d %d",&N,&A,&B,&C);
      |       ^~~~~~~~~~~~~
main.c:6:21: error: expected declaration specifiers or '...' before '&' token
    6 | scanf("%d %d %d %d",&N,&A,&B,&C);
      |                     ^
main.c:6:24: error: expected declaration specifiers or '...' before '&' token
    6 | scanf("%d %d %d %d",&N,&A,&B,&C);
      |                        ^
main.c:6:27: error: expected declaration specifiers or '...' before '&' token
    6 | scanf("%d %d %d %d",&N,&A,&B,&C);
      |                           ^
main.c:6:30: error: expected declaration specifiers or '...' before '&' token
    6 | scanf("%d %d %d %d",&N,&A,&B,&C);
      |                              ^
main.c:8:1: error: expected identifier or '(' before 'for'
    8 | for(i=0;i<N;i++){
      | ^~~
main.c:8:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    8 | for(i=0;i<N;i++){
      |          ^
main.c:8:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    8 | for(i=0;i<N;i++){
      |              ^~
main.c: In function 'dfs':
main.c:21:13: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   21 |     return (abs(a-A)+abs(b-B)+abs(c-C) -30);
      |             ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:22:21: error: subscripted value is neither array nor pointer nor vector
   22 |   int ret0 = dfs(a+A[d],b,c,d+1)+10;
      |                     ^
main.c:23:23: error: subscripted value is neither array nor pointer nor vector
   23 |   int ret1 = dfs(a,b+A[d],c,d+1)+10;
      |                       ^
main.c:24:25: error: subscripted value is neither array nor pointer nor vector
   24 |   int ret2 = dfs(a,b,c+A[d],d+1)+10;
      |                         ^
main.c:26:33: error: expected ')' before ';' token
   26 |   return min((min(a,b),min(c,d));
      |             ~                   ^
      |                                 )
main.c:26:10: error: too few arguments to function 'min'
   26 |   return min((min(a,b),min(c,d));
      |          ^~~
main.c:12:5: note: declared here
   12 | int min(int a,int b){
      |     ^~~
main.c:26:34: error: expected ';' before '}' token
   26 |   return min((min(a,b),min(c,d));
      |                                  ^
      |                                  ;
   27 |              }
      |              ~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cstdio>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9;
using namespace std;
const ll INF = 1 << 30;
int main() {
	int a, b, q;
	scanf_s("%d %d %d", &a, &b, &q);
	vector<ll>s(a), t(b), x(q);
	repp(i, 0, a)scanf_s("%jd", &s[i]);
	repp(i, 0,b)scanf_s("%jd", &t[i]);
	repp(i, 0, q)scanf_s("%jd",&x[i]);
	vector<ll>minv(q);
	repp(i, 0,q) {
		auto pos_sr = s.begin(), pos_tr = t.begin(), pos_sl = s.begin(), pos_tl = t.begin();//iteratorを書くと煩雑になるのでautoを使っている
		s.insert(s.begin(), -INF); t.insert(t.begin(), -INF);
		s.push_back(INF); t.push_back(INF);
		pos_sr=lower_bound(s.begin(), s.end(), x[i]);
		pos_tr = lower_bound(t.begin(), t.end(), x[i]);
		pos_sl = pos_sr - 1;
		pos_tl = pos_tr - 1;
		ll d1 = abs(*pos_sr - x[i]), d2 = abs(*pos_sl - x[i]);
		ll d3 = abs(*pos_tr - x[i]), d4 = abs(*pos_tl - x[i]);
		minv[i] = min({ d1 + abs(*pos_tr - *pos_sr),d1 + abs(*pos_tl - *pos_sr),d2 + abs(*pos_tr - *pos_sl),d2 + abs(*pos_tl - *pos_sl),d3 + abs(*pos_sl - *pos_tr),d3 + abs(*pos_sr - *pos_tr),d4 + abs(*pos_sl - *pos_tl),d4 + abs(*pos_sr - *pos_tl) });
	}
	repp(i, 0, q)printf("%jd\n", minv[i]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   17 |         scanf_s("%d %d %d", &a, &b, &q);
      |         ^~~~~~~
      |         scanf
Language: C++

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int min(int* array, int n) {
	int i;
	int min = array[0];
	for (i = 1; i < n; i++) if (min > array[i]) min = array[i];
	return min;
}

int main() {
	int n, a, b, c, l[8], i;
	scanf("%d%d%d%d", &n, &a, &b, &c);
	for (i = 0; i < n; i++) scanf("%d", &l[i]);
	
	//cur 次に追加する要素のインデックス
	int dfs(int cur, int x, int y, int z){
		int ret[4];
		if (cur == n) {
			return (x * y * z == 0) ? 100000000 : abs(x - a) + abs(y - b) + abs(z - c) - 30;
		}
		ret[0] = dfs(cur + 1, x, y, z);
		ret[1] = dfs(cur + 1, x + l[cur], y, z) + 10;
		ret[2] = dfs(cur + 1, x, y + l[cur], z) + 10;
		ret[3] = dfs(cur + 1, x, y, z + l[cur]) + 10;
		return min(ret, 4);
	}

	printf("%d", dfs(0, 0, 0, 0));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:46: error: a function-definition is not allowed here before '{' token
   18 |         int dfs(int cur, int x, int y, int z){
      |                                              ^
a.cc:30:22: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   30 |         printf("%d", dfs(0, 0, 0, 0));
      |                      ^~~
      |                      ffs
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int main(void){
    int A,B,C,N;
    cin>>N>>A>>B>>C;
    vector<int> l(N);
    for (auto& i:l){
        cin>>i;
    }
    vector<int> dp;
    vector<int> t(6);
    int tmp1=0,tmp2=0,tmp3=0;
    int sti1=0,sti2=0,sti3=0;
    for (int a = 0; a <= N; a++){
        for (int b = a+1; b <= N; b++){
            for (int c = b+1; c <= N; c++){
                for (int d = c+1; d <= N; d++){
                    tmp1=tmp2=tmp3=0;
                    sti1=sti2=sti3=-1;
                    for(int i=a;i<b;i++){
                        tmp1+=l[i];
                        sti1++;
                    }
                    for(int i=b;i<c;i++){
                        tmp2+=l[i];
                        sti2++;
                    }
                    for(int i=c;i<d;i++){
                        tmp3+=l[i];
                        sti3++;
                    }
                    //cout<<tmp1<<" "<<tmp2<<" "<<tmp3<<endl;
                    t[0]=abs(A-tmp1)+abs(B-tmp2)+abs(C-tmp3);
                    t[1]=abs(A-tmp1)+abs(B-tmp3)+abs(C-tmp2);
                    t[2]=abs(A-tmp2)+abs(B-tmp1)+abs(C-tmp3);
                    t[3]=abs(A-tmp2)+abs(B-tmp3)+abs(C-tmp1);
                    t[4]=abs(A-tmp3)+abs(B-tmp1)+abs(C-tmp2);
                    t[5]=abs(A-tmp3)+abs(B-tmp2)+abs(C-tmp1);
                    sort(t.begin(),t.end());
                    dp.push_back((sti1+sti2+sti3)*10+t[0]);
                    //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<(sti1+sti2+sti3)*10+t[0]<<endl;
                }
            }
        }
    }
    
    sort(dp.begin(),dp.end());

    cout<<dp[0]<<endl;


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:21: error: 'sort' was not declared in this scope; did you mean 'short'?
   42 |                     sort(t.begin(),t.end());
      |                     ^~~~
      |                     short
a.cc:50:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   50 |     sort(dp.begin(),dp.end());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <vector>
#include <queue>
struct E {
    int mp;
    int bamboos;
};
struct S {
    std::vector<E>::iterator a, b, c;
};
struct C {
    bool operator()(const S &x, const S &y) const {
        return x.a->mp + x.b->mp + x.c->mp > y.a->mp + y.b->mp + y.c->mp;
    }
};
int calc_mp(int target, int bamboos, std::vector<int> &lengths) {
    if (bamboos == 0) {
        return INT_MAX / 3;
    }
    int mp = -10;
    int n = lengths.size();
    for (int i = 0; i < n; i++) {
        if (bamboos & (1 << i)) {
            mp += 10;
            target -= lengths[i];
        }
    }
    mp += std::abs(target);
    return mp;
}
int main() {
    int n, a, b, c;
    std::cin >> n >> a >> b >> c;
    std::vector<int> l(n);
    for (auto &li: l) std::cin >> li;
    int m = 1 << n;
    std::vector<E> ae(m), be(m), ce(m);
    for (int i = 0; i < m; i++) {
        ae[i].bamboos = i;
        be[i].bamboos = i;
        ce[i].bamboos = i;
        ae[i].mp = calc_mp(a, i, l);
        be[i].mp = calc_mp(b, i, l);
        ce[i].mp = calc_mp(c, i, l);
    }
    std::sort(ae.begin(), ae.end(), [](const E &x, const E &y){ return x.mp < y.mp; });
    std::sort(be.begin(), be.end(), [](const E &x, const E &y){ return x.mp < y.mp; });
    std::sort(ce.begin(), ce.end(), [](const E &x, const E &y){ return x.mp < y.mp; });
    std::priority_queue<S, std::vector<S>, C> q;
    q.push({ ae.begin(), be.begin(), ce.begin() });
    for (;;) {
        S s = q.top();
        q.pop();
        if ((s.a->bamboos & s.b->bamboos) == 0 &&
            (s.a->bamboos & s.c->bamboos) == 0 &&
            (s.b->bamboos & s.c->bamboos) == 0) {
            std::cout << (s.a->mp + s.b->mp + s.c->mp);
            break;
        }
        q.push({ s.a + 1, s.b, s.c });
        q.push({ s.a, s.b + 1, s.c });
        q.push({ s.a, s.b, s.c + 1 });
    }
}

Compiler output:
a.cc: In function 'int calc_mp(int, int, std::vector<int>&)':
a.cc:18:16: error: 'INT_MAX' was not declared in this scope
   18 |         return INT_MAX / 3;
      |                ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <queue>
  +++ |+#include <climits>
    4 | struct E {
a.cc: In function 'int main()':
a.cc:46:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   46 |     std::sort(ae.begin(), ae.end(), [](const E &x, const E &y){ return x.mp < y.mp; });
      |          ^~~~
      |          qsort
a.cc:47:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   47 |     std::sort(be.begin(), be.end(), [](const E &x, const E &y){ return x.mp < y.mp; });
      |          ^~~~
      |          qsort
a.cc:48:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   48 |     std::sort(ce.begin(), ce.end(), [](const E &x, const E &y){ return x.mp < y.mp; });
      |          ^~~~
      |          qsort
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int N, A, B, C,maxans;

maxans = 100000;
vector<int> l(100) = {-1};

int dfs(int depth, vector<int> l){
  int a, b, c, ans, counter = 0;
  if(depth == N-1){
    for(int i = 0; i < N; i++){
      if(c[i] == '1') {
         a += c[i];
         counter++;
      }
      if(c[i] == '2') {
         b += c[i];
         counter++;
      }
      if(c[i] == '3') {
         c += c[i];
         counter++;
      }
    }
    ans = counter * 10 + abs(A - a) + abs(B - b) + abs(C - c);
    minans = min(ans,maxans);
    return minans;
  } 
  for(int i = 0; i < 4; i++){
    c[depth + 1] = i;
    ans = dfs(depth + 1, l);
    return ans;
  }
}

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

Compiler output:
a.cc:8:1: error: 'maxans' does not name a type
    8 | maxans = 100000;
      | ^~~~~~
a.cc:9:20: error: expected ',' or ';' before '=' token
    9 | vector<int> l(100) = {-1};
      |                    ^
a.cc: In function 'int dfs(int, std::vector<int>)':
a.cc:15:11: error: invalid types 'int[int]' for array subscript
   15 |       if(c[i] == '1') {
      |           ^
a.cc:16:16: error: invalid types 'int[int]' for array subscript
   16 |          a += c[i];
      |                ^
a.cc:19:11: error: invalid types 'int[int]' for array subscript
   19 |       if(c[i] == '2') {
      |           ^
a.cc:20:16: error: invalid types 'int[int]' for array subscript
   20 |          b += c[i];
      |                ^
a.cc:23:11: error: invalid types 'int[int]' for array subscript
   23 |       if(c[i] == '3') {
      |           ^
a.cc:24:16: error: invalid types 'int[int]' for array subscript
   24 |          c += c[i];
      |                ^
a.cc:29:5: error: 'minans' was not declared in this scope; did you mean 'maxans'?
   29 |     minans = min(ans,maxans);
      |     ^~~~~~
      |     maxans
a.cc:33:6: error: invalid types 'int[int]' for array subscript
   33 |     c[depth + 1] = i;
      |      ^
a.cc: In function 'int main()':
a.cc:42:20: error: expected ',' or ';' before '=' token
   42 |   vector<int> c(N) = {0};
      |                    ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

int N,A,B,C;

int kadomatsu(int a,int b,int c,int i,vector<int> &vec){
  if(i==N){
    return;
  }
  else{
    kadomatsu(a+vec.at(i),b,c,i+1,vec);
    kadomatsu(a,b+vec.at(i),c,i+1,vec);
    kadomatsu(a,b,c+vec.at(i),i+1,vec);
    kadomatsu(a,b,c,i+1,vec);
  }
}

int main(){
  
  cin>>N>>A>>B>>C;
  vector<int> vec(N);
  
  for(int i=0;i<N;i++)
    cin>>vec.at(i);
  
  kadomatsu(0,0,0,0,vec);
}

Compiler output:
a.cc: In function 'int kadomatsu(int, int, int, int, std::vector<int>&)':
a.cc:9:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
    9 |     return;
      |     ^~~~~~
a.cc:15:14: warning: control reaches end of non-void function [-Wreturn-type]
   15 |     kadomatsu(a,b,c,i+1,vec);
      |     ~~~~~~~~~^~~~~~~~~~~~~~~
Language: C++

#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
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:24:34: error: 'INF' was not declared in this scope
   24 |         if(!a|| !b  ||!c) return INF;
      |                                  ^~~
Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>

using namespace std;

int n;
int t[3];
int inf = 5000;

int re(int cnt, int a, int b, int c, int l[n]){
    if(cnt == n){
        if(a != 0 && b != 0 && c != 0){
            return abs(t[0] - a) + abs(t[1] - b) + abs(t[2] - c) - 30;
        }else{
            return inf;
        }
    }
    int A = re(cnt + 1, a, b, c, l);
    int B = re(cnt + 1, a + l[cnt] , b, c, l) + 10;
    int C = re(cnt + 1, a, b + l[cnt], c, l) + 10;
    int D = re(cnt + 1, a, b, c + l[cnt], l) + 10;
    return min({A, B, C, D});
}

int main(){
    cin >> n >> t[0] >> t[1] >> t[2];
    int lm[n];
    for(int i = 0; i < n; i++){
        cin >> lm[i];
    }
    cout << re(0, 0, 0, 0, lm);
}


Compiler output:
a.cc:18:44: error: size of array 'l' is not an integral constant-expression
   18 | int re(int cnt, int a, int b, int c, int l[n]){
      |                                            ^
Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>

using namespace std;

int n;
int t[3];
int inf = 5000;

int re(int cnt, int a, int b, int c, int l[n]){
    if(cnt == n){
        if(a != 0 && b != 0 && c != 0){
            return abs(t[0] - a) + abs(t[1] - b) + abs(t[2] - c) - 30;
        }else{
            return inf;
        }
    }
    int A = re(cnt + 1, a, b, c, l);
    int B = re(cnt + 1, a + l[cnt] , b, c, l) + 10;
    int C = re(cnt + 1, a, b + l[cnt], c, l) + 10;
    int D = re(cnt + 1, a, b, c + l[cnt], l) + 10;
    return min({A, B, C, D});
}

int main(){
    cin >> n >> t[0] >> t[1] >> t[2];
    int l[n];
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    cout << re(0, 0, 0, 0, l);
}

Compiler output:
a.cc:18:44: error: size of array 'l' is not an integral constant-expression
   18 | int re(int cnt, int a, int b, int c, int l[n]){
      |                                            ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

int main(void){
    int N;
    int A,B,C;

    cin>>N>>A>>B>>C;

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

    int size=1;
    for(int i=0;i<N;i++){
        size*=4;
    }

    int ans=INT_MAX;

    for(int i=0;i<size;i++){
        int A_temp=0;
        int B_temp=0;
        int C_temp=0;
        int MPsum=0;

        for(int k=0;k<N;k++){

            int ABCjudge=i;
            for(int l=0;l<k;l++){
                ABCjudge/=4;
            }
            ABCjudge%=4;

            if(ABCjudge==1){
                if(A_temp>0){MPsum+=10;}
                A_temp+=l[k];
            }else if(ABCjudge==2){
                if(B_temp>0){MPsum+=10;}
                B_temp+=l[k];
            }else if(ABCjudge==3){
                if(C_temp>0){MPsum+=10;}
                C_temp+=l[k];
            }
        }

        MPsum+=abs(A-A_temp);
        MPsum+=abs(B-B_temp);
        MPsum+=abs(C-C_temp);
        if(MPsum<ans && A_temp!=0 && B_temp!=0 && C_temp!=0){ans=MPsum;}
    }

    cout<<ans<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: 'INT_MAX' was not declared in this scope
   27 |     int ans=INT_MAX;
      |             ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <numeric>
  +++ |+#include <climits>
    7 | #include <string>
Language: C++

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

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

const int INF = 1LL << 20;

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 rec = rec(i+1, a, b, c);

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

    return rec;
}

int main(){
    cin >> N >> A >> B >> C;
    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:32:18: error: 'rec' cannot be used as a function
   32 |     int rec = rec(i+1, a, b, c);
      |               ~~~^~~~~~~~~~~~~~
a.cc:34:19: error: 'rec' cannot be used as a function
   34 |     chmin(rec, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:35:19: error: 'rec' cannot be used as a function
   35 |     chmin(rec, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:36:19: error: 'rec' cannot be used as a function
   36 |     chmin(rec, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
Language: C++

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

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

const int INF = 1LL << 20;

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

int dfs(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 dfs = dfs(i+1, a, b, c);

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

    return dfs;
}

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:32:18: error: 'dfs' cannot be used as a function
   32 |     int dfs = dfs(i+1, a, b, c);
      |               ~~~^~~~~~~~~~~~~~
a.cc:34:19: error: 'dfs' cannot be used as a function
   34 |     chmin(dfs, dfs(i+1, a + L[i], b, c) + (a ? 10 : 0));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:35:19: error: 'dfs' cannot be used as a function
   35 |     chmin(dfs, dfs(i+1, a, b + L[i], c) + (b ? 10 : 0));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:36:19: error: 'dfs' cannot be used as a function
   36 |     chmin(dfs, dfs(i+1, a, b, c + L[i]) + (c ? 10 : 0));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~