Language: C++

#include <iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<string>
using namespace std;

const double PI  =3.141592653589793238463;
#define pb push_back
#define pf push_front
#define sz(v)  ((int)(v).size());
#define all(v) ((v).begin()),((v).end())
typedef unsigned long long ull;
typedef long long ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ull> vul;

typedef pair<int,int> pi;
//2 7 3 4 9

void printVec(vul v1)
{
    for(int i=0; i<v1.size(); i++)
        cout<<v1[i]<<" ";
    cout<<endl;
}
ll rec(ll r,ll c){

if(r<=1 || c<=1){
    return 1;
}


return rec(r-1,c)+rec(r,c-1);
}

bool bin_search(ull  target, vul V){

ll low=0;
ll high=V.size()-1;
while(low<=high){
    ll mid=(low+high)/2;
    if(target==V[mid]){
        return true;
    }
    if(target <V[mid]){
        high=mid-1;
    }else{
    low=mid+1;
    }
}
return false;
}
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
ll n,m,k;cin>>n>>m>>k;
vul A(n+1,0);
vul B(m+1,0);

for(ll i=1;i<=n;i++){
cin>>A[i];
A[i]=A[i]+A[i-1];
}
for(ll i=1;i<=m;i++){
cin>>B[i];
B[i]=B[i]+B[i-1];
}
/*
    vector<ull>::iterator lower,upper;
     upper = upper_bound(A.begin(),A.end(),150);
     lower = lower_bound(A.begin(),A.end(),150);

cout<<upper-A.begin()<<endl;
cout<<lower-A.begin();
5 5 100
20 20 20 20 20
8 8 4 70 20
*/

ll books=0,A_books=0,B_books=0;
ull sum=0;

 vector<ull>::iterator lower,upper;
for(ull i=1;i<=n;i++){
if(A[i]<=k){
sum=max(sum,i);
}
ll t=k-A[i];
if(t <= 0){
    continue;
}
 lower = lower_bound(B.begin(),B.end(),k-A[i]);
B_books=lower-B.begin();
if(B[B_books] >k-A[i]){
    B_books--;
}
//B_books--;
sum=max(sum,B_books+i);

}
    vector<ull>::iterator lower,upper;
     lower = lower_bound(A.begin(),A.end(),k);
A_books=lower-A.begin();
if(A[A_books] >k){
    A_books--;
}

lower = lower_bound(B.begin(),B.end(),k);
B_books=lower-B.begin();
if(B[B_books] >k){
B_books--;
}

ll mx=max(A_books,B_books);

cout<<max(sum,mx)<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:113:27: error: redeclaration of 'std::vector<long long unsigned int>::iterator lower'
  113 |     vector<ull>::iterator lower,upper;
      |                           ^~~~~
a.cc:95:24: note: 'std::vector<long long unsigned int>::iterator lower' previously declared here
   95 |  vector<ull>::iterator lower,upper;
      |                        ^~~~~
a.cc:113:33: error: redeclaration of 'std::vector<long long unsigned int>::iterator upper'
  113 |     vector<ull>::iterator lower,upper;
      |                                 ^~~~~
a.cc:95:30: note: 'std::vector<long long unsigned int>::iterator upper' previously declared here
   95 |  vector<ull>::iterator lower,upper;
      |                              ^~~~~
a.cc:128:10: error: no matching function for call to 'max(ull&, ll&)'
  128 | cout<<max(sum,mx)<<endl;
      |       ~~~^~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:128:10: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'll' {aka 'long long int'})
  128 | cout<<max(sum,mx)<<endl;
      |       ~~~^~~~~~~~
/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,
                 from a.cc:6:
/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:128:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
  128 | cout<<max(sum,mx)<<endl;
      |       ~~~^~~~~~~~