Language: C++

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

ll power(ll int x,ll int n)
{if(n==0)return 1;
else if(n%2 == 0)return power(x*x,n/2);
else return x*power(x*x,(n-1)/2);}

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}

/*void solve()
{
  ll i,j,k,l,m,n,a=0,b=0,c=0,cnt=0,x=0;
  //cin>>n>>m>>l;
  n=200000;
  m=200000;
  l=1000000000;
  vi v1(n),v2(m);
  r(i,0,n)
  {
  	  k=rand()%100;
	  v1[i]=k;
	  cout<<k<<" ";
  }
  cout<<"\n";
  r(i,0,m)
  {
      k=rand()%100;
	  v2[i]=k;
	  cout<<k<<" ";
  }
  cout<<"\n";
  sort(all(v1));
  sort(all(v2));
  for(i=0;(sz(v1)!=0 && sz(v2)!=0);)
  {
  	if(v1[i]>v2[i])
  	{
  		a+=v2[i];
  		if(a<=l)
  		cnt++;
  		else
  		break;
  		v2.erase(v2.begin());
	}
	else
	{
		a+=v1[i];
		if(a<=l)
		cnt++;
		else
		break;
		v1.erase(v1.begin());
	}
  }
  if(a<l)
  {
  	if(sz(v1)!=0)
  	{
  		for(i=0;i<sz(v1);i++)
  		{
  			a+=v1[i];
  			if(a<=l)
  			cnt++;
  			else
  			break;
		  }
	  }
	  else
	  if(sz(v2)!=0)
	  {
	  	for(i=0;i<sz(v2);i++)
	  	{
	  		a+=v2[i];
	  		if(a<=l)
	  		cnt++;
	  		else
	  		break;
		  }
	  }
  }
  cout<<cnt;
    
}
*/


void solve()
{
	ll i,j,k,l,m,n,a=0,b=0,c=0,cnt=0,x=0,y=0;
	cin>>n>>m>>k;
	vector<ll int> p1,p2;
	r(i,0,n)
	{
		cin>>l;
		p1.pb(l);
	}
	r(i,0,m)
	{
		cin>>l;
		p2.pb(l);
	}
	for(i=0;(sz(p1)!=0 && sz(p2)!=0);)
	{
		if(p1[i]>p2[i])
		{
			a+=p2[i];
			p2.erase(p2.begin());
			if(a<=k)
			cnt++;
			else
			break;
		}
		else
		if(p1[i]<p2[i])
		{
			a+=p1[i];
			p1.erase(p1.begin());
			if(a<=k)
			cnt++;
			else
			break;	
		}
		else
		if(p1[i]==p2[i])
		{
			j=1;
			while(p1[j]!=p2[j])
			j++;
			if(p1[j]<p2[j])
			{
				a+=p1[i];
			p1.erase(p1.begin());
			if(a<=k)
			cnt++;
			else
			break;	
			}
			else
			{
				a+=p2[i];
			p2.erase(p2.begin());
			if(a<=k)
			cnt++;
			else
			break;	
			}	
		}
	}
	if(a<k)
	{
		for(i=0;i<sz(v1);i++)
		{
			a+=p1[i];
			p1.erase(p1.begin());
			if(a<=k)
			cnt++;
			else
			break;
		}
		for(i=0;i<sz(v2);i++)
		{
			a+=p2[i];
			p2.erase(p2.begin());
			if(a<=k)
			cnt++;
			else
			break;
		}	
	}
	cout<<cnt;
}

int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    
}
//pr12


Compiler output:
a.cc: In function 'void solve()':
a.cc:183:30: error: 'v1' was not declared in this scope; did you mean '__pstl::execution::v1'?
  183 |                 for(i=0;i<sz(v1);i++)
      |                              ^~
a.cc:10:29: note: in definition of macro 'sz'
   10 | #define sz(x)       (ll int)x.size()
      |                             ^
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/execution_defs.h:19:18: note: '__pstl::execution::v1' declared here
   19 | inline namespace v1
      |                  ^~
a.cc:192:30: error: 'v2' was not declared in this scope; did you mean 'p2'?
  192 |                 for(i=0;i<sz(v2);i++)
      |                              ^~
a.cc:10:29: note: in definition of macro 'sz'
   10 | #define sz(x)       (ll int)x.size()
      |                             ^