Language: C++

    int main(){
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int n,m,k;
        cin>>n>>m>>k;
        

        vector<ll> A(n);
        vector<ll> B(n);
        for(ll i=0;i<n;i++){
            cin>>A[i];
        }
     


        for(ll j=0;j<m;j++){
            cin>>B[j];
        }

        vector<ll> a(n+1);
        vector<ll> b(m+1);
        for(ll i=0;i<n;i++){
            a[i+1]=a[i]+A[i];
        }


        for(ll i=0;i<m;i++){
            b[i+1]=b[i]+B[i];
        }
        ll ans=0; 
        for(ll i=0;i<=n;i++){

            ll left=k-a[i];
           
            if(left < 0)
                continue;
           
            ll j=lower_bound(b.begin() ,b.end(), left) - b.begin();
           
            if(  j>m || b[j] > left ){
               j--;
            } 

            ans=max(ans,(i+j));

        }  

        cout<<ans<<endl;

    }

Compiler output:
a.cc: In function 'int main()':
a.cc:3:37: error: 'stdin' was not declared in this scope
    3 |             freopen("input.txt","r",stdin);
      |                                     ^~~~~
a.cc:1:1: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 |     int main(){
a.cc:3:13: error: 'freopen' was not declared in this scope
    3 |             freopen("input.txt","r",stdin);
      |             ^~~~~~~
a.cc:4:38: error: 'stdout' was not declared in this scope
    4 |             freopen("output.txt","w",stdout);
      |                                      ^~~~~~
a.cc:4:38: note: 'stdout' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:6:9: error: 'ios' has not been declared
    6 |         ios::sync_with_stdio(false);
      |         ^~~
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin.tie(0);
      |         ^~~
a.cc:8:9: error: 'cout' was not declared in this scope
    8 |         cout.tie(0);
      |         ^~~~
a.cc:13:9: error: 'vector' was not declared in this scope
   13 |         vector<ll> A(n);
      |         ^~~~~~
a.cc:13:16: error: 'll' was not declared in this scope
   13 |         vector<ll> A(n);
      |                ^~
a.cc:13:20: error: 'A' was not declared in this scope
   13 |         vector<ll> A(n);
      |                    ^
a.cc:14:20: error: 'B' was not declared in this scope
   14 |         vector<ll> B(n);
      |                    ^
a.cc:15:15: error: expected ';' before 'i'
   15 |         for(ll i=0;i<n;i++){
      |               ^~
      |               ;
a.cc:15:20: error: 'i' was not declared in this scope
   15 |         for(ll i=0;i<n;i++){
      |                    ^
a.cc:21:15: error: expected ';' before 'j'
   21 |         for(ll j=0;j<m;j++){
      |               ^~
      |               ;
a.cc:21:20: error: 'j' was not declared in this scope
   21 |         for(ll j=0;j<m;j++){
      |                    ^
a.cc:25:20: error: 'a' was not declared in this scope
   25 |         vector<ll> a(n+1);
      |                    ^
a.cc:26:20: error: 'b' was not declared in this scope
   26 |         vector<ll> b(m+1);
      |                    ^
a.cc:27:15: error: expected ';' before 'i'
   27 |         for(ll i=0;i<n;i++){
      |               ^~
      |               ;
a.cc:27:20: error: 'i' was not declared in this scope
   27 |         for(ll i=0;i<n;i++){
      |                    ^
a.cc:32:15: error: expected ';' before 'i'
   32 |         for(ll i=0;i<m;i++){
      |               ^~
      |               ;
a.cc:32:20: error: 'i' was not declared in this scope
   32 |         for(ll i=0;i<m;i++){
      |                    ^
a.cc:35:11: error: expected ';' before 'ans'
   35 |         ll ans=0;
      |           ^~~~
      |           ;
a.cc:36:15: error: expected ';' before 'i'
   36 |         for(ll i=0;i<=n;i++){
      |               ^~
      |               ;
a.cc:36:20: error: 'i' was not declared in this scope
   36 |         for(ll i=0;i<=n;i++){
      |                    ^
a.cc:38:15: error: expected ';' before 'left'
   38 |             ll left=k-a[i];
      |               ^~~~~
      |               ;
a.cc:40:16: error: 'left' was not declared in this scope
   40 |             if(left < 0)
      |                ^~~~
a.cc:43:15: error: expected ';' before 'j'
   43 |             ll j=lower_bound(b.begin() ,b.end(), left) - b.begin();
      |               ^~
      |               ;
a.cc:45:18: error: 'j' was not declared in this scope
   45 |             if(  j>m || b[j] > left ){
      |                  ^
a.cc:45:32: error: 'left' was not declared in this scope
   45 |             if(  j>m || b[j] > left ){
      |                                ^~~~
a.cc:49:13: error: 'ans' was not declared in this scope
   49 |             ans=max(ans,(i+j));
      |             ^~~
a.cc:49:28: error: 'j' was not declared in this scope
   49 |             ans=max(ans,(i+j));
      |                            ^
a.cc:49:17: error: 'max' was not declared in this scope
   49 |             ans=max(ans,(i+j));
      |                 ^~~
a.cc:53:15: error: 'ans' was not declared in this scope
   53 |         cout<<ans<<endl;
      |               ^~~
a.cc:53:20: error: 'endl' was not declared in this scope
   53 |         cout<<ans<<endl;
      |                    ^~~~