Language: C++

#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(X); sll(Y); sll(Z); sll(K);
	VLL As, Bs, Cs;
	rep(i, 0, X)	As.push_back(scanLong());
	rep(i, 0, Y)	Bs.push_back(scanLong());
	rep(i, 0, Z)	Cs.push_back(scanLong());
	sort(As.begin(), As.end(), greater<LL,LL>());
	sort(Bs.begin(), Bs.end(), greater<LL,LL>());
	sort(Cs.begin(), Cs.end(), greater<LL,LL>());
	VLL ans;
	rep(i, 0, X) {
		rep(j, 0, Y) {
			rep(k, 0, Z) {
				if((i+1)*(j+1)*(k+1) <= K)	ans.push_back(As[i] + Bs[j] + Cs[k]);
				else	break;
			}
		}
	}
	sort(ans.begin(), ans.end(), greater<LL,LL>());
	rep(i, 0, K)	pll(ans[i]); nl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:49: error: wrong number of template arguments (2, should be at least 0)
   65 |         sort(As.begin(), As.end(), greater<LL,LL>());
      |                                                 ^
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_function.h:353:12: note: provided for 'template<class _Tp> struct std::greater'
  353 |     struct greater;
      |            ^~~~~~~
a.cc:66:49: error: wrong number of template arguments (2, should be at least 0)
   66 |         sort(Bs.begin(), Bs.end(), greater<LL,LL>());
      |                                                 ^
/usr/include/c++/14/bits/stl_function.h:353:12: note: provided for 'template<class _Tp> struct std::greater'
  353 |     struct greater;
      |            ^~~~~~~
a.cc:67:49: error: wrong number of template arguments (2, should be at least 0)
   67 |         sort(Cs.begin(), Cs.end(), greater<LL,LL>());
      |                                                 ^
/usr/include/c++/14/bits/stl_function.h:353:12: note: provided for 'template<class _Tp> struct std::greater'
  353 |     struct greater;
      |            ^~~~~~~
a.cc:77:51: error: wrong number of template arguments (2, should be at least 0)
   77 |         sort(ans.begin(), ans.end(), greater<LL,LL>());
      |                                                   ^
/usr/include/c++/14/bits/stl_function.h:353:12: note: provided for 'template<class _Tp> struct std::greater'
  353 |     struct greater;
      |            ^~~~~~~