Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

typedef pair<int,int> P;

int main() {
  int N; cin >> N;
  vector<P> A, B;
  rep(i,N) { int tmp; cin >> tmp; A.push_back(make_pair(tmp,i)) };
  rep(i,N) { int tmp; cin >> tmp; B.push_back(make_pair(tmp,i)) };

  bool ok = false; rep(i,N) if (A[i]==B[i]) ok = true;
  sort(A.begin, A.end, [](const P& x, const P& y) {return x.first<y.first;});
  sort(B.begin, B.end, [](const P& x, const P& y) {return x.first<y.first;});
  rep(i,N) if (A[i]>B[i]) { cout << "No" << endl; return 0; }
  if (ok) { cout << "Yes" << endl; return 0; }

  int pos = ( A[0].second - B[0].second + N ) % N;
  int okok = true;
  rep(i,N) {
    if (( A[i].second - B[i].second + N ) % N!=pos) okok = false;
  }
  string result = (okok) ? "No" : "Yes";
  cout << result << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:64: error: expected ';' before '}' token
   16 |   rep(i,N) { int tmp; cin >> tmp; A.push_back(make_pair(tmp,i)) };
      |                                                                ^~
      |                                                                ;
a.cc:17:64: error: expected ';' before '}' token
   17 |   rep(i,N) { int tmp; cin >> tmp; B.push_back(make_pair(tmp,i)) };
      |                                                                ^~
      |                                                                ;
a.cc:20:7: error: no matching function for call to 'sort(<unresolved overloaded function type>, <unresolved overloaded function type>, main()::<lambda(const P&, const P&)>)'
   20 |   sort(A.begin, A.end, [](const P& x, const P& y) {return x.first<y.first;});
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   template argument deduction/substitution failed:
a.cc:20:7: note:   couldn't deduce template parameter '_RAIter'
   20 |   sort(A.begin, A.end, [](const P& x, const P& y) {return x.first<y.first;});
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   template argument deduction/substitution failed:
a.cc:20:7: note:   couldn't deduce template parameter '_ExecutionPolicy'
   20 |   sort(A.begin, A.end, [](const P& x, const P& y) {return x.first<y.first;});
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:21:7: error: no matching function for call to 'sort(<unresolved overloaded function type>, <unresolved overloaded function type>, main()::<lambda(const P&, const P&)>)'
   21 |   sort(B.begin, B.end, [](const P& x, const P& y) {return x.first<y.first;});
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   template argument deduction/substitution failed:
a.cc:21:7: note:   couldn't deduce template parameter '_RAIter'
   21 |   sort(B.begin, B.end, [](const P& x, const P& y) {return x.first<y.first;});
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   template argument deduction/substitution failed:
a.cc:21:7: note:   couldn't deduce template parameter '_ExecutionPolicy'
   21 |   sort(B.begin, B.end, [](const P& x, const P& y) {return x.first<y.first;});
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~