Language: C++

// ABC123_D
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

struct Cake {
    // 任意の構造体
    ll a;
    ll b;
    ll c;
};
Cake start = {0, 0, 0};
queue<Cake> q;
q.push(start);  // 初期状態をキューに入れる

ll X, Y, Z, K;
vector<ll> one, two, three;
bool d[1010][1010][1010] = {{{false}}};

vector<ll> vec;
ll num = 0;

int bfs() {
    while (!q.empty()) {
        // キューの先頭の要素を取り出す dequeue(pop)
        Cake now = q.front(); q.pop();
        vec.push_back(now.a + now.b + now.c);
        

        // 停止条件
        if (num == min(3000, X+Y+Z)) return 0;  // 探索対象

        // BFS
        if (!(d[now.a+1][now.b][now.c])) {
            d[now.a+1][now.b][now.c] = true;
            Cake next = {now.a+1, now.b, now.c};
            q.push(next);
        }
        if (!(d[now.a][now.b+1][now.c])) {
            d[now.a][now.b+1][now.c] = true;
            Cake next = {now.a, now.b+1, now.c};
            q.push(next);
        }
        if (!(d[now.a][now.b][now.c+1])) {
            d[now.a][now.b][now.c+1] = true;
            Cake next = {now.a+1, now.b, now.c};
            q.push(next);
        }
    }
}

int main() {
    // input(sunippets: inpv, inpn, inps)
    cin >> X >> Y >> Z >> K;
    one.resize(X); two.resize(Y); three.resize(Z);
    REP(i, X) cin >> one[i];
    REP(i, Y) cin >> two[i];
    REP(i, Z) cin >> three[i];
    sort(one.begin(), one.end(), greater<>());  // int big -> small
    sort(two.begin(), two.end(), greater<>());  // int big -> small
    sort(three.begin(), three.end(), greater<>());  // int big -> small
    
    bfs();
    
    // calculation
    // 最後大きい順に出力
    sort(vec.begin(), vec.end(), greater<>());  // int big -> small
    REP(i, K) {
        cout << vec[i] << "\n";
    }
    
    return 0;
}

Compiler output:
a.cc:44:1: error: 'q' does not name a type
   44 | q.push(start);  // 初期状態をキューに入れる
      | ^
a.cc: In function 'int bfs()':
a.cc:61:23: error: no matching function for call to 'min(int, ll)'
   61 |         if (num == min(3000, X+Y+Z)) return 0;  // 探索対象
      |                    ~~~^~~~~~~~~~~~~
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:2:
/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:   template argument deduction/substitution failed:
a.cc:61:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   61 |         if (num == min(3000, X+Y+Z)) return 0;  // 探索対象
      |                    ~~~^~~~~~~~~~~~~
/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, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:13:
/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, 2 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:   template argument deduction/substitution failed:
a.cc:61:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   61 |         if (num == min(3000, X+Y+Z)) return 0;  // 探索対象
      |                    ~~~^~~~~~~~~~~~~
a.cc:80:1: warning: control reaches end of non-void function [-Wreturn-type]
   80 | }
      | ^