Language: C++

#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e3 + 5;
ll x, y, z, k, a[N], b[N], c[N];
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> x >> y >> z >> k;
    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<ll>ans;
    if(x * y * z <= 1e6){
        for(int i = 0; i < x; i++)
            for(int j = 0; j < y; j++)
                for(int ii = 0; ii < z; ii++)
                    ans.push_back(a[i] + b[j] + c[ii]);
        sort(ans.rbegin(), ans.rend());
        for(int i = 0; i < k; i++)
            cout << ans[i] << '\n';
        return 0;
    }
    sort(a, a + x);
    sort(b, b + y);
    sort(c, c + z);
    for(int i = 0; i < x; i++)
        for(int j = 0; j < y; j++)
            ans.push_back(a[i] + b[j]);
    sort(ans.rbegin(), ans.rend());
    vector<ll>ans2;
    for(int i = 0; i < z; i++){
        for(int j = 0; j < z; j++)
            ans2.push_back(ans[i] + c[j]);
    }
    for(int i = z; i < ans.size(); i++){
        for(int j = 0; j < min(z, 100); j++)
            ans2.push_back(ans[i] + c[j]);
    }
    sort(ans2.rbegin(), ans2.rend());
    for(int i = 0; i < k; i++)
        cout << ans2[i] << '\n';
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:31: error: no matching function for call to 'min(long long int&, int)'
   42 |         for(int j = 0; j < min(z, 100); j++)
      |                            ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:42:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   42 |         for(int j = 0; j < min(z, 100); j++)
      |                            ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:42:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   42 |         for(int j = 0; j < min(z, 100); j++)
      |                            ~~~^~~~~~~~