Language: C++

// seabreeeze //

#include<bits/stdc++.h>
 
using namespace std;
 
#define lli long long
lli MOD=1e9+7;
 
#define MAXN 2000006 

// Template function //
lli powermod(lli x, lli y)  
{  
    lli res = 1;  
    x = x % MOD;
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % MOD;  
        y = y>>1;   
        x = (x*x) % MOD;  
    }  
    return res;  
}
lli modinv(lli x)
{
    return powermod(x,MOD-2);
}
// Template functions end //

// Custom funtions //
lli tree[MAXN];

void buildTree(vector<lli> a, int n)
{
    for(int i=0;i<n;i++)
        tree[n+i] = a[i];
    for(int i=n-1;i>0;i--)
    {
        tree[i] = min(tree[i<<1] , tree[i<<1|1]);
    }
}

void updateTree(int n, int p, lli value)
{
    tree[p+n] = value;
    p+=n;
    for(int i=p; i>1;i >>= 1)
        tree[i>>1] = min(tree[i], tree[i^1]);
}

lli queryTree(int n, int l, int r)
{
    lli res = INT_MAX;
    for(l+=n,r+=n;l<r;l>>=1, r>>=1)
    {
        if(l&1)
            res = min(res, tree[l++]);
        if(r&1)
            res = min(res,tree[--r]);
    }
    return res;
}

// Custom functions end //

int main()
{
    lli q=1;
    // cin>>q;
    time_t start, end;
    time(&start);
    for(lli tc=1;tc<=q;tc++)
    {
        // Start solution //
        lli n,m,k;
        cin>>n>>m>>k;
        lli a[n],b[m];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        for(int j=0;j<m;j++)
        {
            cin>>b[j];
        }
        int ans = 0;
        for(int i=1;i<m;i++)
        {
            b[i]+=b[i-1];
        }
        for(int i=1;i<n;i++)
        {
            a[i]+=a[i-1];
        }
        ans = lower_bound(a,a+n,k)-a;
        for(int i=0;i<m;i++)
        {
            if(b[i]<=k)
            ans = max(i+1+upper_bound(a,a+n,k-b[i])-a,ans);
        }
        cout<<ans<<endl;
        end:;
        // End Solution //
    }
    
    time(&end);
    // cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
    return 0;
}

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