Language: C

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  vector<int> abc(3);
  rep(i,3) cin >> abc.at(i);
  sort(abc.begin(),abc.end());
  vector<int> l(n);
  rep(i,n) cin >> l.at(i);
  setfspattern(4,n);
  int64_t mincost = 1000000000000000;
  rep(i,fspcnt){
    vector<bool> exist123(3);
    vector<int> totalabc(3);
    rep(j,n){
      if(fspattern.at(i).at(j) != 3){
        exist123.at(fspattern.at(i).at(j)) = true;
      }
    }
    //cout << exist123.at(0) << exist123.at(1) << exist123.at(2) << endl;
    if(exist123.at(0) && exist123.at(1) && exist123.at(2)){
      //cout << "W";
      rep(j,n){
        int bb = fspattern.at(i).at(j);
        if(bb != 3){
          totalabc.at(bb) += l.at(j);
        }
      }
      sort(totalabc.begin(),totalabc.end());
      int64_t cost = 0;
      rep(j,3){
        cost += abs(totalabc.at(j) - abc.at(j));
      }
      int cnt4 = 0;
      rep(j,n){
        if(fspattern.at(i).at(j) != 3){
          cnt4++;
        }
      }
      cost += (cnt4-3)*10;
      /*cout << totalabc.at(0) <<","<< totalabc.at(1) <<","<< 
      totalabc.at(2) <<","<< endl;
      cout << cost << endl;*/
      mincost = min(mincost,cost);
    }
  }
   cout << mincost << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.