Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
typedef long l;

int main(){
	int x,y,z,k;
	cin>>l>>x>>z>>k;
  	vector<l> a(x,0);
  	for(int i=0;i<x;i++)
      cin>>a[i];
  	vector<l> b(y,0);
  	for(int i=0;i<y;i++)
      cin>>b[i];
  	vector<l> c(z,0);
  	for(int i=0;i<z;i++)
      cin>>c[i];
  	set<l> res;
  	for(int i=0;i<x;i++){
      for(int j=0;j<y;j++){
        for(int g=0;g<z;g++){
          res.insert(a[i]+b[j]+c[g]);
          if(res.size()>k+1) res.erase(res.begin());
        }
      }
    }
  	for(auto it=res.end()-1;it!=res.begin();it--)
      cout<<*it;
  	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:15: error: expected primary-expression before '>>' token
   17 |         cin>>l>>x>>z>>k;
      |               ^~
a.cc:36:30: error: no match for 'operator-' (operand types are 'std::set<long int>::iterator' {aka 'std::_Rb_tree<long int, long int, std::_Identity<long int>, std::less<long int>, std::allocator<long int> >::const_iterator'} and 'int')
   36 |         for(auto it=res.end()-1;it!=res.begin();it--)
      |                     ~~~~~~~~~^~
      |                            |  |
      |                            |  int
      |                            std::set<long int>::iterator {aka std::_Rb_tree<long int, long int, std::_Identity<long int>, std::less<long int>, std::allocator<long int> >::const_iterator}
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:36:31: note:   'std::set<long int>::iterator' {aka 'std::_Rb_tree<long int, long int, std::_Identity<long int>, std::less<long int>, std::allocator<long int> >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
   36 |         for(auto it=res.end()-1;it!=res.begin();it--)
      |                               ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:36:31: note:   'std::set<long int>::iterator' {aka 'std::_Rb_tree<long int, long int, std::_Identity<long int>, std::less<long int>, std::allocator<long int> >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
   36 |         for(auto it=res.end()-1;it!=res.begin();it--)
      |                               ^