Language: C++

#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>

#define int ll
//#define double long double
//#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.14159265358979

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 7e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/

template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}

template <class T>
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}

inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

signed main()
{
    Start();
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    cin >> a >> b;
    auto ta = a, tb = b;
    sort(all(a));
    sort(all(b));
    for (int i = 0; i < n; ++i)
    {
        if (a[i] > b[i])
            return cout << "No", 0;
    }
    vector <int> ab, ba;
    for (int i = 0; i < n - 1; ++i)
        if (b[i] < a[i + 1])
            ab.pb(i);
    for (int i = 0; i < n - 1; ++i)
        if (a[i] > b[i + 1])
            ba.pb(i);
    for (int i = 0; i < n; ++i)
    {
        if (ta[i] <= tb[i])
        {
            int posa = lower_bound(all(a)) - a.begin(), posb = lower_bound(all(b)) - b.begin();
            if (posa == posb)
                return cout << "Yes", 0;
            if (posa < posb)
            {
                if (lower_bound(all(ab), posa) >= posb)
                    return cout << "Yes", 0;
            }
            else
            {
                if (lower_bound(all(ba), posb) >= posa)
                    return cout << "Yes", 0;
            }
        }
    }
    cout << "No";
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:102:35: error: no matching function for call to 'lower_bound(std::vector<long long int>::iterator, std::vector<long long int>::iterator)'
  102 |             int posa = lower_bound(all(a)) - a.begin(), posb = lower_bound(all(b)) - b.begin();
      |                        ~~~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1530 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1963:5: note:   candidate expects 4 arguments, 2 provided
a.cc:103:25: error: 'posb' was not declared in this scope; did you mean 'posa'?
  103 |             if (posa == posb)
      |                         ^~~~
      |                         posa
a.cc:105:24: error: 'posb' was not declared in this scope; did you mean 'posa'?
  105 |             if (posa < posb)
      |                        ^~~~
      |                        posa