Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
 
int main() 
{
    int x, y, z;
    int k;
    cin >> x >> y >> z;
    cin >> k;
 
    vector<long long> a(x), b(y), 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];
 
    vector<long long> ab;
    for (int i = 0; i < x; ++i) {
        for (int j = 0; j < y; ++j) {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());
 
    vector<long long> abc;
    for (int i = 0; i < min(k, (int)ab.size()); ++i) {
        for (int j = 0; j < z; ++j) {
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(abc.begin(), abc.end());
    reverse(abc.begin(), abc.end());
 
    for (int i = 0; i < k; ++i) {
        cout << abc[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'vector' was not declared in this scope
   13 |     vector<long long> a(x), b(y), c(z);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <algorithm>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:13:12: error: expected primary-expression before 'long'
   13 |     vector<long long> a(x), b(y), c(z);
      |            ^~~~
a.cc:14:40: error: 'a' was not declared in this scope
   14 |     for (int i = 0; i < x; ++i) cin >> a[i];
      |                                        ^
a.cc:15:40: error: 'b' was not declared in this scope
   15 |     for (int i = 0; i < y; ++i) cin >> b[i];
      |                                        ^
a.cc:16:40: error: 'c' was not declared in this scope
   16 |     for (int i = 0; i < z; ++i) cin >> c[i];
      |                                        ^
a.cc:18:12: error: expected primary-expression before 'long'
   18 |     vector<long long> ab;
      |            ^~~~
a.cc:21:13: error: 'ab' was not declared in this scope; did you mean 'abs'?
   21 |             ab.push_back(a[i] + b[j]);
      |             ^~
      |             abs
a.cc:21:26: error: 'a' was not declared in this scope
   21 |             ab.push_back(a[i] + b[j]);
      |                          ^
a.cc:21:33: error: 'b' was not declared in this scope
   21 |             ab.push_back(a[i] + b[j]);
      |                                 ^
a.cc:24:10: error: 'ab' was not declared in this scope; did you mean 'abs'?
   24 |     sort(ab.begin(), ab.end());
      |          ^~
      |          abs
a.cc:27:12: error: expected primary-expression before 'long'
   27 |     vector<long long> abc;
      |            ^~~~
a.cc:30:13: error: 'abc' was not declared in this scope; did you mean 'abs'?
   30 |             abc.push_back(ab[i] + c[j]);
      |             ^~~
      |             abs
a.cc:30:35: error: 'c' was not declared in this scope
   30 |             abc.push_back(ab[i] + c[j]);
      |                                   ^
a.cc:33:10: error: 'abc' was not declared in this scope; did you mean 'abs'?
   33 |     sort(abc.begin(), abc.end());
      |          ^~~
      |          abs