Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdlib>

using namespace std;
typedef long long ll;

int n;
int aa[10001];
int bb[10001];

const int MAX_N=10001;
const int MAX_Q=10001;
const int DAT_SIZE=(1<<18)-1;
int N,Q;
int A[MAX_N];
char T[MAX_Q];
int L[MAX_Q],R[MAX_Q],X[MAX_Q];

// segmentation tree
ll data[DAT_SIZE];
ll datb[DAT_SIZE];

// [a,b)ÉxðÁZ
// kÍß_ÌÔÅAæÔ[l,r)ÉÎ
void add(int a,int b,int x,int k,int l,int r){
    if(a<=l&&r<=b)
        data[k]+=x;
    else if(l<b&&a<r){
        datb[k]+=(min(b,r)-max(a,l))*x;
        add(a,b,x,k*2+1,l,(l+r)/2);
        add(a,b,x,k*2+2,(l+r)/2,r);
    }
}
// [a,b)ÌaðvZ
// kÍß_ÌÔÅAæÔ[l,r)ÉÎ
ll sum(int a,int b,int k,int l,int r){
    if(b<=l||r<=a)
        return 0;
    else if(a<=l&&r<=b)
        return data[k]*(r-l)+datb[k];
    ll res=(min(b,r)-max(a,l))*data[k];
    res+=sum(a,b,k*2+1,l,(l+r)/2);
    res+=sum(a,b,k*2+2,(l+r)/2,r);
    return res;
}

int main(){

    while(cin>>n&&n!=0){
        // [NA
        memset(data,0,sizeof(data));
        memset(datb,0,sizeof(datb));
        for(int i = 0; i < n; i++)cin>>aa[i];
        for(int i = 0; i < n; i++)cin>>bb[i];
        sort(aa,aa+n);
        sort(bb,bb+n);
        int havingZeroCow=-1;
        // »Ý0ðÂàÁÆàEÌñ
        for(int i = 0; i < n; i++){
            if(aa[i]==0)
                havingZeroCow=i;
            else
                break;
        }
        // seg treeÉúlðÁZ
        for(int i = 0; i < n; i++)
            add(i,i+1,aa[i],0,0,n);
        bool f=false;
        // àÁÆàå«¢ðÂs©çÔÉ
        for(int i = n-1; i >= 0; i--){
            // E©çÔÉßÄ¢ÁÄAÅÉóÉÈéñ
            int firstEmpty=n-bb[i]-1;
            // àµ»Ìñª0ÈçÎA»ÌñæèEÌñ©ç1ðø¢ÄÌðs¤
            // 0Å³¯êÎÀ»sÂ\
            if(firstEmpty==-1||sum(firstEmpty,firstEmpty+1,0,0,n)==0)
                add(firstEmpty+1,n,-1,0,0,n);
            else{
                f=true;
                break;
            }
        }
        if(f)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'void add(int, int, int, int, int, int)':
a.cc:30:9: error: reference to 'data' is ambiguous
   30 |         data[k]+=x;
      |         ^~~~
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:23:4: note:                 'll data [262143]'
   23 | ll data[DAT_SIZE];
      |    ^~~~
a.cc: In function 'll sum(int, int, int, int, int)':
a.cc:43:16: error: reference to 'data' is ambiguous
   43 |         return data[k]*(r-l)+datb[k];
      |                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:23:4: note:                 'll data [262143]'
   23 | ll data[DAT_SIZE];
      |    ^~~~
a.cc:44:32: error: reference to 'data' is ambiguous
   44 |     ll res=(min(b,r)-max(a,l))*data[k];
      |                                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:23:4: note:                 'll data [262143]'
   23 | ll data[DAT_SIZE];
      |    ^~~~
a.cc: In function 'int main()':
a.cc:54:16: error: reference to 'data' is ambiguous
   54 |         memset(data,0,sizeof(data));
      |                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:23:4: note:                 'll data [262143]'
   23 | ll data[DAT_SIZE];
      |    ^~~~
a.cc:54:30: error: reference to 'data' is ambiguous
   54 |         memset(data,0,sizeof(data));
      |                              ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:23:4: note:                 'll data [262143]'
   23 | ll data[DAT_SIZE];
      |    ^~~~
a.cc:80:13: error: 'else' without a previous 'if'
   80 |             else{
      |             ^~~~