Language: C++

/// meowa 

#pragma GCC optimize("O3")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;

void stndrtn() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

void ma1n() {
    stack<int> s, t;
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    for (int& x : a) {
        cin >> x;
    }
    vector<int> b(m);
    for (int& x : b) {
        cin >> x;
    }
    vector<ll> p(m+1);
    p[0] = 0;
    for (int i = 0; i < m; ++i) {
        p[i+1] = p[i] + b[i];    
    }
    ll sum = 0;
    int ans = upper_bound(p.begin(), p.end(), k)-p.begin()-1;
    for (int i = 0; i < n; ++i) {
        sum += a[i];
        if (sum > k) {
            break;
        }
        ans = max(ans, i+1 + upper_bound(p.begin(), p.end(), k-sum)-p.begin()-1);
    }
    cout << ans;
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

Compiler output:
a.cc: In function 'void ma1n()':
a.cc:52:18: error: no matching function for call to 'max(int&, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)'
   52 |         ans = max(ans, i+1 + upper_bound(p.begin(), p.end(), k-sum)-p.begin()-1);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:5:
/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:52:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type' {aka 'long int'})
   52 |         ans = max(ans, i+1 + upper_bound(p.begin(), p.end(), k-sum)-p.begin()-1);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:52:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |         ans = max(ans, i+1 + upper_bound(p.begin(), p.end(), k-sum)-p.begin()-1);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~