Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <chrono> 
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (ll i=(a); i<(b);++i)
#define frr(i,a,b) for(int i=(a-1);i>=(b);--i)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define sz(a) (ll)a.size()
#define endl "\n"
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
const ll M=1e17+7;
const int MaxM=501;



int main()
{ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);

    int tt=1;
    //cin>>tt;
    while(tt--){

ll n,m,k;
cin>>n>>m>>k;
ll a[n],b[m];
fr(i,0,n)cin>>a[i];
fr(i,0,m)cin>>b[i];

ll pa[n+1]={};
fr(i,1,n+1)pa[i]=pa[i-1]+a[i-1];
ll pb[m+1]={};
fr(i,1,m+1)pb[i]=pb[i-1]+b[i-1];

ll ans=0;
fr(i,0,n+1)
{
    if(pa[i]>k)break;
    ll num=k-pa[i]; 
    auto lb=lower_bound(pb,pb+m+1,num+1)-pb;
  lb--;

    lb=max(0,lb);
    ans=max(ans,i+lb); 
}
cout<<ans;
   
  }}



Compiler output:
a.cc: In function 'int main()':
a.cc:62:11: error: no matching function for call to 'max(int, long int&)'
   62 |     lb=max(0,lb);
      |        ~~~^~~~~~
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:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:62:11: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   62 |     lb=max(0,lb);
      |        ~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:62:11: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   62 |     lb=max(0,lb);
      |        ~~~^~~~~~