Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define pri priority_queue
#define syo <int,V<int>
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define all(a)  (a).begin(),(a).end()
#define Pi P<int,int>
#define elif else if
//#define min min<int>
//#define max max<int>
int low(V<int> a,int b){
  decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b);
  int d=c-a.bgn;
  return d;
}
int upp(V<int> a,int b){
  decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b);
  int d=c-a.bgn;
  return d;
}
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    } */
int gcm(int a,int b){
  if(a%b==0)
    return b;
  return gcm(b,a%b);
}
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }

struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}*/
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
bool fe(int a,int b){
  a%=10;
  b%=10;
  if(a==0)
    a=10;
  if(b==0)
    b=10;
  if(a>b)
    return true;
  else
    return false;
}
int INF=1000000007;
struct edge{int s,t,d; };
V<int> mojisyu(string a){
  V<int> b(26,0);
  fo(i,a.sz){
    b[a[i]-'a']++;
  }
  return b;
}
int wa2(int a){
  if(a%2==1)
    return a/2;
  return a/2-1;
}
/*signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  V<V<edge>> d(a);
  fo(i,b){
    edge e;
    cin>>e.s>>e.t>>e.d;
    d[e.s].pb(e);
  }
  V<int> e(a,INF);
  e[c]=0;
  priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f;
  f.push({0,c});
  int h=INF;
  while(!f.empty()){
    P<int,int> g;
    g=f.top();
    f.pop();
    int v = g.second, i = g.first;
    for(edge l : d[v]){
      if(e[l.t] > i + l.d){
        e[l.t] = i + l.d;
        f.push({i+l.d , l.t});
      }
    }
  }
  fo(i,a){
    if(e[i]==INF)
      cout<<"INF"<<endl;
    else
      cout<<e[i]<<endl;
  }
}
?*/
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  V<int> e(a),f(b),g(c);
  V<int> e1(a-1),f1(b-1),g1(c-1);
  fo(i,a)
  cin>>e[i];
  fo(i,b)
  cin>>f[i];
  fo(i,c)
  cin>>g[i];
  Sort(e);
  Sort(f);
  Sort(g);
  rev(e);
  rev(f);
  rev(g);
  fo(i,a-1)
  e1[i]=e[i]-e[i+1];
  fo(i,b-1)
  f1[i]=f[i]-f[i+1];
  fo(i,c-1)
  g1[i]=g[i]-g[i+1];
  fo(i,a-2)
  e1[i+1]=e1[i]+e1[i+1];
  fo(i,b-2)
  f1[i+1]=f1[i]+f1[i+1];
  fo(i,c-2)
  g1[i+1]=g1[i]+g1[i+1];
  int h=e[0]+f[0]+g[0]
  int i1=0,j1=0,k1=0;
  cout<<h<<endl;
  fo(i,d-1){
    if(e[i1]<=f[j1]&&e[i1]<=g[k1]){
      cout<<h-e[i1]<<endl;
      i1++;
    }
    elif(f[j1]<=e[i1]&&f[j1]<=g[k1]){
      cout<<h-f[j1]<<endl;
      j1++;
    }
    else{
      cout<<h-g[k1]<<endl;
      k1++;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:13: error: expected ',' or ';' before 'long'
    3 | #define int long long
      |             ^~~~
a.cc:285:3: note: in expansion of macro 'int'
  285 |   int i1=0,j1=0,k1=0;
      |   ^~~
a.cc:288:10: error: 'i1' was not declared in this scope; did you mean 'i'?
  288 |     if(e[i1]<=f[j1]&&e[i1]<=g[k1]){
      |          ^~
      |          i
a.cc:288:17: error: invalid conversion from 'double (*)(double) noexcept' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-fpermissive]
  288 |     if(e[i1]<=f[j1]&&e[i1]<=g[k1]){
      |                 ^~
      |                 |
      |                 double (*)(double) noexcept
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:288:31: error: 'k1' was not declared in this scope; did you mean 'g1'?
  288 |     if(e[i1]<=f[j1]&&e[i1]<=g[k1]){
      |                               ^~
      |                               g1
a.cc:292:12: error: invalid conversion from 'double (*)(double) noexcept' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-fpermissive]
  292 |     elif(f[j1]<=e[i1]&&f[j1]<=g[k1]){
      |            ^~
      |            |
      |            double (*)(double) noexcept
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:292:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-fpermissive]
  292 |     elif(f[j1]<=e[i1]&&f[j1]<=g[k1]){
      |                          ^~
      |                          |
      |                          double (*)(double) noexcept
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:293:17: error: invalid conversion from 'double (*)(double) noexcept' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-fpermissive]
  293 |       cout<<h-f[j1]<<endl;
      |                 ^~
      |                 |
      |                 double (*)(double) noexcept
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:294:7: warning: ISO C++ forbids incrementing a pointer of type 'double (*)(double) noexcept' [-Wpointer-arith]
  294 |       j1++;
      |       ^~
a.cc:294:9: error: lvalue required as increment operand
  294 |       j1++;
      |         ^~