Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll n,m,k;
  cin>>n>>m>>k;
  ll a[n],b[m];
  fo(i,n)
  cin>>a[i];
  fo(i,m)
  cin>>b[i];
  ll x[n],y[m];
  x[0]=a[0];y[0]=b[0];
  for(ll i=1;i<n;i++)
    x[i]=x[i-1]+a[i];
  for(ll i=1;i<m;i++)
    y[i]=y[i-1]+b[i];
  ll ans=upper_bound(y,y+m,k)-y;
  for(ll i=0;i<n;i++)
  {
    if(x[i]<=k)
    {
      ll p=upper_bound(y,y+m,k-x[i])-y;
      ans=max(ans,i+1+p);
    }
  }
  ans=max(ans,upper_bound(x,x+n,k)-x);
  for(ll i=0;i<m;i++)
  {
    if(y[i]<=k)
    {
      ll p=upper_bound(x,x+n,k-y[i])-x;
      ans=max(ans,i+1+p);
    }
  }
  cout<<ans;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:10: error: no matching function for call to 'max(long long int&, long int)'
   50 |   ans=max(ans,upper_bound(x,x+n,k)-x);
      |       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:50:10: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   50 |   ans=max(ans,upper_bound(x,x+n,k)-x);
      |       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:50:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   50 |   ans=max(ans,upper_bound(x,x+n,k)-x);
      |       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~