Language: C++

int main(void) {
	int x, y, z;
	long long k;
	cin >> x >> y >> z >> k;
	vector<long long> a(x);
	vector<long long> b(y);
	vector<long long> c(z);
	for (int i = 0; i < x; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < y; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < z; ++i) {
		cin >> c[i];
	}

	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());

	unordered_map<long long, long long> dict;
	dict.insert(make_pair(0, a[0] + b[0] + c[0]));
	cout << a[0] + b[0] + c[0] << "\n";

	for (int i = 0; i < k-1; ++i) {
		long long key;
		long long maxv = 0;
		long long maxk = 0;
		long long v;
		for (int i_x = 0; i_x < x; ++i_x) {
			for (int i_y = 0; i_y < y; ++i_y) {
				for (int i_z = 0; i_z < z; ++i_z) {
					key = i_x + 1000 * i_y + 1000000 * i_z;
					if (dict.find(key) != dict.end()) {
						continue;
					}
					v = a[i_x] + b[i_y] + c[i_z];
					if (v > maxv) {
						maxv = v;
						maxk = key;
					}
				}
			}
		}
		dict.insert(make_pair(maxk, maxv));
		cout << maxv << "\n";
	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> x >> y >> z >> k;
      |         ^~~
a.cc:5:9: error: 'vector' was not declared in this scope
    5 |         vector<long long> a(x);
      |         ^~~~~~
a.cc:5:16: error: expected primary-expression before 'long'
    5 |         vector<long long> a(x);
      |                ^~~~
a.cc:6:16: error: expected primary-expression before 'long'
    6 |         vector<long long> b(y);
      |                ^~~~
a.cc:7:16: error: expected primary-expression before 'long'
    7 |         vector<long long> c(z);
      |                ^~~~
a.cc:9:24: error: 'a' was not declared in this scope
    9 |                 cin >> a[i];
      |                        ^
a.cc:12:24: error: 'b' was not declared in this scope
   12 |                 cin >> b[i];
      |                        ^
a.cc:15:24: error: 'c' was not declared in this scope
   15 |                 cin >> c[i];
      |                        ^
a.cc:18:14: error: 'a' was not declared in this scope
   18 |         sort(a.rbegin(), a.rend());
      |              ^
a.cc:18:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |         sort(a.rbegin(), a.rend());
      |         ^~~~
      |         short
a.cc:19:14: error: 'b' was not declared in this scope
   19 |         sort(b.rbegin(), b.rend());
      |              ^
a.cc:20:14: error: 'c' was not declared in this scope
   20 |         sort(c.rbegin(), c.rend());
      |              ^
a.cc:22:9: error: 'unordered_map' was not declared in this scope
   22 |         unordered_map<long long, long long> dict;
      |         ^~~~~~~~~~~~~
a.cc:22:23: error: expected primary-expression before 'long'
   22 |         unordered_map<long long, long long> dict;
      |                       ^~~~
a.cc:23:9: error: 'dict' was not declared in this scope
   23 |         dict.insert(make_pair(0, a[0] + b[0] + c[0]));
      |         ^~~~
a.cc:23:21: error: 'make_pair' was not declared in this scope
   23 |         dict.insert(make_pair(0, a[0] + b[0] + c[0]));
      |                     ^~~~~~~~~
a.cc:24:9: error: 'cout' was not declared in this scope
   24 |         cout << a[0] + b[0] + c[0] << "\n";
      |         ^~~~