Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define all(v) v.begin(), v.end()

struct node {
  int x, y, z;
  ll v;
  node(int a, int b, int c, ll d) : x(a), y(b), z(c), v(d) {}
  bool operator<(const node b) const {
    return v < b.v;
  }
  bool operator>(const node b) const {
    return b < (*this);
  }
};

vector<ll> a, b, c;

node calc(int x, int y, int z)
{
  if (x < a.size() && y < b.size() && z < c.size()) {
    node n(x, y, z, a[x] + b[y] + c[z]);
    return n;
  }
  node n(x, y, z, 0);
  return n;
}

int main()
{
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  a.resize(x);
  b.resize(y);
  c.resize(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  sort(all(a), greater<ll>());
  sort(all(b), greater<ll>());
  sort(all(c), greater<ll>());
  priority_queue<node> q;
  q.push(calc(0, 0, 0));
  set<pair<ll, pair<ll, ll>>> s;
  s.insert(make_pair(0, make_pair(0, 0)));
  while (1) {
    if (k == 0) break;
    auto a = q.top();
    q.pop();
    cout << a.v << endl;
    node t = calc(a.x+1, a.y, a.z);
    auto p = make_pair(a.x+1, make_pair(a.y, a.z));
    if (s.count(p) == 0) {
      q.push(t);
      s.insert(t);
    }
    t = calc(a.x, a.y+1, a.z);
    p = make_pair(a.x, make_pair(a.y+1, a.z));
    if (s.count(p) == 0) {
      q.push(t);
      s.insert(t);
    }
    t = calc(a.x, a.y, a.z+1);
    p = make_pair(a.x, make_pair(a.y, a.z+1));
    if (s.count(p) == 0) {
      q.push(t);
      s.insert(t);
    }    
    k--;
  }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:60:15: error: no matching function for call to 'std::set<std::pair<long long int, std::pair<long long int, long long int> > >::insert(node&)'
   60 |       s.insert(t);
      |       ~~~~~~~~^~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:568:9: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = std::pair<long long int, std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >]'
  568 |         insert(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:511:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::pair<long long int, std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::pair<long long int, std::pair<long long int, long long int> >, std::pair<long long int, std::pair<long long int, long long int> >, std::_Identity<std::pair<long long int, std::pair<long long int, long long int> > >, std::less<std::pair<long long int, std::pair<long long int, long long int> > >, std::allocator<std::pair<long long int, std::pair<long long int, long long int> > > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >, std::pair<long long int, std::pair<long long int, long long int> > >::rebind<std::pair<long long int, std::pair<long long int, long long int> > >; typename _Alloc::value_type = std::pair<long long int, std::pair<long long int, long long int> >; value_type = std::pair<long long int, std::pair<long long int, long long int> >]'
  511 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:511:32: note:   no known conversion for argument 1 from 'node' to 'const std::set<std::pair<long long int, std::pair<long long int, long long int> > >::value_type&' {aka 'const std::pair<long long int, std::pair<long long int, long long int> >&'}
  511 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:520:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = std::pair<long long int, std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::pair<long long int, std::pair<long long int, long long int> >, std::pair<long long int, std::pair<long long int, long long int> >, std::_Identity<std::pair<long long int, std::pair<long long int, long long int> > >, std::less<std::pair<long long int, std::pair<long long int, long long int> > >, std::allocator<std::pair<long long int, std::pair<long long int, long long int> > > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >, std::pair<long long int, std::pair<long long int, long long int> > >::rebind<std::pair<long long int, std::pair<long long int, long long int> > >; typename _Alloc::value_type = std::pair<long long int, std::pair<long long int, long long int> >; value_type = std::pair<long long int, std::pair<long long int, long long int> >]'
  520 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:520:27: note:   no known conversion for argument 1 from 'node' to 'std::set<std::pair<long long int, std::pair<long long int, long long int> > >::value_type&&' {aka 'std::pair<long long int, std::pair<long long int, long long int> >&&'}
  520 |       insert(value_type&& __x)
      |              ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:548:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, const value_type&) [with _Key = std::pair<long long int, std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >; iterator = std::_Rb_tree<std::pair<long long int, std::pair<long long int, long long int> >, std::pair<long long int, std::pair<long long int, long long int> >, std::_Identity<std::pair<long long int, std::pair<long long int, long long int> > >, std::less<std::pair<long long int, std::pair<long long int, long long int> > >, std::allocator<std::pair<long long int, std::pair<long long int, long long int> > > >::const_iterator; const_iterator = std::_Rb_tree<std::pair<long long int, std::pair<long long int, long long int> >, std::pair<long long int, std::pair<long long int, long long int> >, std::_Identity<std::pair<long long int, std::pair<long long int, long long int> > >, std::less<std::pair<long long int, std::pair<long long int, long long int> > >, std::allocator<std::pair<long long int, std::pair<long long int, long long int> > > >::const_iterator; value_type = std::pair<long long int, std::pair<long long int, long long int> >]'
  548 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:548:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:553:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, value_type&&) [with _Key = std::pair<long long int, std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >; iterator = std::_Rb_tree<std::pair<long long int, std::pair<long long int, long long int> >, std::pair<long long int, std::pair<long long int, long long int> >, std::_Identity<std::pair<long long int, std::pair<long long int, long long int> > >, std::less<std::pair<long long int, std::pair<long long int, long long int> > >, std::allocator<std::pair<long long int, std::pair<long long int, long long int> > > >::const_iterator; const_iterator = std::_Rb_tree<std::pair<long long int, std::pair<long long int, long long int> >, std::pair<long long int, std::pair<long long int, long long int> >, std::_Identity<std::pair<long long int, std::pair<long long int, long long int> > >, std::less<std::pair<long long int, std::pair<long long int, long long int> > >, std::allocator<std::pair<long long int, std::pair<long long int, long long int> > > >::const_iterator; value_type = std::pair<long long int, std::pair<long long int, long long int> >]'
  553 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:553:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:580:7: note: candidate: 'void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<long long int, std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >]'
  580 |       insert(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:580:43: note:   no known conversion for argument 1 from 'node' to 'std::initializer_list<std::pair<long long int, std::pair<long long int, long long int> > >'
  580 |       insert(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:600:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::insert_return_type std::set<_Key, _Compare, _Alloc>::insert(node_type&&) [with _Key = std::pair<long long int, std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<long long int, std::pair<long long int, long long int> > >; insert_return_type = std::_Rb_tree<std::pair<long long int, std::pair<long long int, long long int> >, std::pair<long long int, std::pair<long long int, long long int> >, std::_Identity<std::pair<long long int, std::pair<long long int, long long int> > >, std::less<std::pair<long long int, std::pair<long long int, long long int> > >, std::allocator<std::pair<long long int, std::pair<long long int, long long int> > > >::insert_return_type; node_type = std::_Rb_tree<std::pair<long long int, std::pair<long