Language: C++

#include<bits/stdc++.h>

using namespace std;

const int size=2e5;
int a[size],b[size];

int max(int a,int b){
	return a > b ? a : b;
}
int main(){
	int n,m,i,k;
	int r=0,count=0;
	int top1=-1,top2=-1;
	int min1=0,min2=0;
	
	cin >> n;
	cin >> m;
	cin >> k;
	
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<m;i++)
		cin>>b[i];
	
	while(++top1 < n && min1+a[top1] <= k){
		min1+=a[top1];
	}
	while(++top2 < m && min1+min2+b[top2] <= k){
		min2+=b[top2];
	}
	//cout<<top1<<" "<<min1<<"\n";
	//cout<<top2<<" "<<min2<<"\n";
	
	if(top1 > 0)
		r+=top1;
	if(top2 > 0)
		r+=top2;
	
	while(top1 > 0 && top2 < m){
		int time=a[--top1];
		count=0;
		//cout<<"book going to remove time: "<<time<<"\n";
		//cout<<"First min: "<<min1<<"\n";
		//cout<<"Second min: "<<min2<<"\n";
		min1-=time;
		//cout<<"After reduce min1: "<<min1<<"\n";
		time=k-(min1+min2);
		//cout<<"Time available: "<<time<<"\n";
		
		while(top2 < m && b[top2]+min2 <= time){
			min2+=b[top2];
			top2++;
			//cout<<"Incrementing the top2\n";
		}
		//cout<<"top1: "<<top1<<"\n";
		//cout<<"top2: "<<top2<<"\n";
		if(top1 > 0)
			count+=top1;
		if(top2 > 0)
			count+=top2;
		r=max(r,count);
	}
	cout<<r<<"\n";
}

Compiler output:
a.cc:6:7: error: reference to 'size' is ambiguous
    6 | int a[size],b[size];
      |       ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:11: note:                 'const int size'
    5 | const int size=2e5;
      |           ^~~~
a.cc:6:15: error: reference to 'size' is ambiguous
    6 | int a[size],b[size];
      |               ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:11: note:                 'const int size'
    5 | const int size=2e5;
      |           ^~~~
a.cc: In function 'int main()':
a.cc:22:22: error: 'a' was not declared in this scope
   22 |                 cin>>a[i];
      |                      ^
a.cc:24:22: error: 'b' was not declared in this scope
   24 |                 cin>>b[i];
      |                      ^
a.cc:26:34: error: 'a' was not declared in this scope
   26 |         while(++top1 < n && min1+a[top1] <= k){
      |                                  ^
a.cc:29:39: error: 'b' was not declared in this scope
   29 |         while(++top2 < m && min1+min2+b[top2] <= k){
      |                                       ^
a.cc:41:26: error: 'a' was not declared in this scope
   41 |                 int time=a[--top1];
      |                          ^
a.cc:51:35: error: 'b' was not declared in this scope
   51 |                 while(top2 < m && b[top2]+min2 <= time){
      |                                   ^