Language: C++

#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)	
#define REP(i,n) FOR(i,0,n)
	
int main(){
	int N;
	cin>>N;
	vector<pair<int,int>>A(N),B(N);
	REP(i,N){
		int a;
		cin>>a;
		A.at(i)=make_pair(a,i);
	}
	REP(i,N){
		int a;
		cin>>a;
		B.at(i)=make_pair(a,i);
	}
	
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	
	vector<pair<int,int> >ary(N);
	bool flag = false;
	REP(i,N){
		if(A.at(i).first>B.at(i).first){
			cout<<"No"<<endl;
			exit(0);
		}
		else
		{
			ary.at(i)=make_pair(A.at(i)second,B.at(i).second);
			if(!flag&&i!=0&&A.at(i)<=B.at(i-1))
			{
				flag=true;
			}
		}
	}
	
	sort(ary.begin(),ary.end());
	vector<bool> check(N,false);
	check.at(0)=true;
	int idx=ary.at(0).second;
	int cnt=1;
	
	while(check(N,false){
		check.at(idx)=true;
		idx=ary.at(idx).second;
		cnt++;
	}
	if(cnt!=N||flag==true){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:52: error: expected ')' before 'second'
   34 |                         ary.at(i)=make_pair(A.at(i)second,B.at(i).second);
      |                                            ~       ^~~~~~
      |                                                    )
a.cc:34:73: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'std::pair<std::pair<int, int>, int>')
   34 |                         ary.at(i)=make_pair(A.at(i)second,B.at(i).second);
      |                                                                         ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:946:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U2 = _U1; _T1 = int; _T2 = int]'
  946 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:946:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h: In substitution of 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<int&, const _U1&>, std::is_assignable<int&, const _U2&> >::value, std::pair<int, int>&>::type std::pair<int, int>::operator=(const std::pair<_T1, _T2>&) [with _U1 = std::pair<int, int>; _U2 = int]':
a.cc:34:52:   required from here
   34 |                         ary.at(i)=make_pair(A.at(i)second,B.at(i).second);
      |                                                                         ^
/usr/include/c++/14/bits/stl_pair.h:946:9: error: no type named 'type' in 'struct std::enable_if<false, std::pair<int, int>&>'
  946 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:957:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U2 = _U1; _T1 = int; _T2 = int]'
  957 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:957:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h: In substitution of 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<int&, _U1&&>, std::is_assignable<int&, _U2&&> >::value, std::pair<int, int>&>::type std::pair<int, int>::operator=(std::pair<_T1, _T2>&&) [with _U1 = std::pair<int, int>; _U2 = int]':
a.cc:34:52:   required from here
   34 |                         ary.at(i)=make_pair(A.at(i)second,B.at(i).second);
      |                                                                         ^
/usr/include/c++/14/bits/stl_pair.h:957:9: error: no type named 'type' in 'struct std::enable_if<false, std::pair<int, int>&>'
  957 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:921:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&>) [with _T1 = int; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&> = const std::pair<int, int>&]'
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:923:65: note:   no known conversion for argument 1 from 'std::pair<std::pair<int, int>, int>' to 'std::__conditional_t<true, const std::pair<int, int>&, const std::__nonesuch&>' {aka 'const std::pair<int, int>&'}
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  922 |                                        is_copy_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  923 |                                 const pair&, const __nonesuch&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:931:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&>) [with _T1 = int; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&> = std::pair<int, int>&&]'
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:933:55: note:   no known conversion for argument 1 from 'std::pair<std::pair<int, int>, int>' to 'std::__conditional_t<true, std::pair<int, int>&&, std::__nonesuch&&>' {aka 'std::pair<int, int>&&'}
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  932 |                                        is_move_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  933 |                                 pair&&, __nonesuch&&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:48:20: error: no match for call to '(std::vector<bool>) (int&, bool)'
   48 |         while(check(N,false){
      |               ~~~~~^~~~~~~~~
a.cc:48:29: error: expected ')' before '{' token
   48 |         while(check(N,false){
      |              ~              ^
      |                             )