Language: C++

#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define repprev(i,a,b) for(ll i=b-1;i>=a;i--)
#define reprev(i,n) repprev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> int former(const vector<T> &v, T x){
   return upper_bound(v.begin(),v.end(),x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(),v.end(),x) - v.begin();
}
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }

    ll root(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    ll size(ll x) {
        return -par[root(x)];
    }
};

template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<int, T> > > & G){
   const T INF = numeric_limits<T>::max();
   using P = pair<T, int>;
   int n=G.size();
   vector<T> d(n,INF);
   vector<int> b(n,-1);
   priority_queue<P,vector<P>,greater<P> > q;
   d[s]=0;
   q.emplace(d[s],s);
   while(!q.empty()){
     P p=q.top();q.pop();
     int v=p.second;
     if(d[v]<p.first) continue;
     for(auto& e:G[v]){
       int u=e.first;
       T c=e.second;
       if(d[u]>d[v]+c){
         d[u]=d[v]+c;
         b[u]=v;
         q.emplace(d[u],u);
       }
     }
   }
   return d;
}

const int dx[4] = {1, 0, -1, 0}; // const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[4] = {0, 1, 0, -1}; // const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

class Nums{
 public:
  int a,b,c;
  Nums(int _a, int _b, int _c){
    a = _a;
    b = _b;
    c = _c;
  }
};
int main(){
    int x,y,z;
  	int k;
  	cin >> x >> y >> z;
  	cin >> k;
  	vector<ll> A(x),B(y),C(z);
  	rep(i,x) cin >> A[i];
  	rep(i,x) cin >> B[i];
  	rep(i,x) cin >> C[i];
  	
  	sort(all(A));
  	reverse(all(A));
  	sort(all(B));
  	reverse(all(B));
  	sort(all(C));
  	reverse(all(C));
  
  	priority_queue<pair<ll,Nums>> pq;
  	pq.push(make_pair(A[0] + B[0] + C[0], Nums(0,0,0)));
  	set<ll> s;
  	s.insert(0);
  
  	vector<ll> ans;
  	while(ans.size() < k) {
      auto v = pq.top(); pq.pop();
      ans.pb(v.first);
      if(v.second.a ! x-1) {
        int a = v.second.a + 1;
        int b = v.second.b;
        int c = v.second.c;
        int hash = (a << 20) + (b << 10) + c;
        if(s.find(hash) == s.end()) {
          s.insert(hash);
          pq.push(make_pair(A[0] + B[0] + C[0], Nums(a,b,c)))
        }
        
        pq.push(make_pair(A[a] + B[b] + C[c]), Nums(a,b,c)));
      }
      
      auto v = pq.top(); pq.pop();
      ans.pb(v.first);
      if(v.second.a ! y-1) {
        int a = v.second.a;
        int b = v.second.b + 1;
        int c = v.second.c;
        int hash = (a << 20) + (b << 10) + c;
        if(s.find(hash) == s.end()) {
          s.insert(hash);
          pq.push(make_pair(A[0] + B[0] + C[0], Nums(a,b,c)))
        }
        
        pq.push(make_pair(A[a] + B[b] + C[c]), Nums(a,b,c)));
      }
      auto v = pq.top(); pq.pop();
      ans.pb(v.first);
      if(v.second.a ! z-1) {
        int a = v.second.a;
        int b = v.second.b;
        int c = v.second.c + 1;
        int hash = (a << 20) + (b << 10) + c;
        if(s.find(hash) == s.end()) {
          s.insert(hash);
          pq.push(make_pair(A[0] + B[0] + C[0], Nums(a,b,c)))
        }
        
        pq.push(make_pair(A[a] + B[b] + C[c]), Nums(a,b,c)));
      }
      
    }
  

  	
      
  	rep(i,k){
      cout << ans[i] << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:156:20: error: expected ')' before '!' token
  156 |       if(v.second.a ! x-1) {
      |         ~          ^~
      |                    )
a.cc:163:62: error: expected ';' before '}' token
  163 |           pq.push(make_pair(A[0] + B[0] + C[0], Nums(a,b,c)))
      |                                                              ^
      |                                                              ;
  164 |         }
      |         ~                                                     
a.cc:166:26: error: no matching function for call to 'make_pair(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
  166 |         pq.push(make_pair(A[a] + B[b] + C[c]), Nums(a,b,c)));
      |                 ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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_pair.h:1132:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1132:5: note:   candidate expects 2 arguments, 1 provided
a.cc:169:12: error: conflicting declaration 'auto v'
  169 |       auto v = pq.top(); pq.pop();
      |            ^
a.cc:154:12: note: previous declaration as 'std::pair<long long int, Nums> v'
  154 |       auto v = pq.top(); pq.pop();
      |            ^
a.cc:171:20: error: expected ')' before '!' token
  171 |       if(v.second.a ! y-1) {
      |         ~          ^~
      |                    )
a.cc:178:62: error: expected ';' before '}' token
  178 |           pq.push(make_pair(A[0] + B[0] + C[0], Nums(a,b,c)))
      |                                                              ^
      |                                                              ;
  179 |         }
      |         ~                                                     
a.cc:181:26: error: no matching function for call to 'make_pair(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
  181 |         pq.push(make_pair(A[a] + B[b] + C[c]), Nums(a,b,c)));
      |                 ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1132:5: note:   candidate expects 2 arguments, 1 provided
a.cc:183:12: error: conflicting declaration 'auto v'
  183 |       auto v = pq.top(); pq.pop();
      |            ^
a.cc:154:12: note: previous declaration as 'std::pair<long long int, Nums> v'
  154 |       auto v = pq.top(); pq.pop();
      |            ^
a.cc:185:20: error: expected ')' before '!' token
  185 |       if(v.second.a ! z-1) {
      |         ~          ^~
      |                    )
a.cc:192:62: error: expected ';' before '}' token
  192 |           pq.push(make_pair(A[0] + B[0] + C[0], Nums(a,b,c)))
      |                                                              ^
      |                                                              ;
  193 |         }
      |         ~                                                     
a.cc:195:26: error: no matching function for call to 'make_pair(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
  195 |         pq.push(make_pair(A[a] + B[b] + C[c]), Nums(a,b,c)));
      |                 ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1132:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h: In instantiation of 'constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&) [with _T1 = long long int; _T2 = Nums]':
/usr/include/c++/14/bits/stl_function.h:405:20:   required from 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = std::pair<long long int, Nums>]'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/predefined_ops.h:196:23:   required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, Nums>*, std::vector<std::pair<long long int, Nums>, std::allocator<std::pair<long long int, Nums> > > >; _Value = std::pair<long long int, Nums>; _Compare = std::less<std::pair<long long int, Nums> >]'
  196 |         { return bool(_M_comp(*__it, __val)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:140:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, Nums>*, vector<pair<long long int, Nums>, allocator<pair<long long int, Nums> > > >; _Distance = long int; _Tp = pair<long long int, Nums>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<pair<long long int, Nums> > >]'
  140 |       while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23:   required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long long int, Nums>*, vector<pair<long long int, Nums>, allocator<pair<long long int, Nums> > > >; _Compare = less<pair<long long int, Nums> >]'
  216 |       std::__push_heap(__first, _DistanceType((__last - __first) - 1),
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217 |                        _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:747:16:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<long long int, Nums>; _Sequence = std::vector<std::pair<long long int, Nums>, std::allocator<std::pair<long long int, Nums> > >; _Compare = std::less<std::pair<long long int, Nums> >; value_type = std::pair<long long int, Nums>]'
  747 |         std::push_heap(c.begin(), c.end(), comp);
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:148:11:   required from here
  148 |         pq.push(make_pair(A[0] + B[0] + C[0], Nums(0,0,0)));
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1047:57: error: no match for 'operator<' (operand types are 'const Nums' and 'const Nums')
 1047 |              || (!(__y.first < __x.first) && __x.second < __y.second); }
      |                                              ~~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1047:57: note:   'const Nums' is not derived from 'const std::pair<_T1, _T2>'
 1047 |              || (!(__y.first < __x.first) && __x.second < __y.second); }
      |                                              ~~~~~~~~~~~^~~~~~~~~~~~