Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,h,k,w;
ll T;

vector<ll> A;

ll look = 0;

bool mono(){


bool inc = 1;
bool dec = 1;

for(ll c1 = 0; c1 < A.size()-1; c1++){

    if(A[c1] >= A[c1+1])inc = 0;
    if(A[c1] <= A[c1+1])dec = 0;

}

return (dec || inc);
}

ll med(ll x, ll y, ll z){

if(x >= min(z,y) && x <= max(z,y))return x;
if(y >= min(z,x) && y <= max(z,x))return y;
if(z >= min(x,y) && z <= max(x,y))return z;
return x;
}

vector<ll> C;
void solve(){


if(mono()){
    cout << A[look-1] << "\n";
    return;
}

C.clear();
for(ll c1 = 1; c1 < A.size()-1; c1++){
    C.push_back(med(A[c1-1] , A[c1] , A[c1+1]));

}



ll l = 0;
look--;
for(ll c1 = 0; c1 < min(look,C.size()-1); c1++){
    if(C[c1] == C[c1+1])l = c1;
}
ll r = C.size()-1;
for(ll c1 = look; c1 < C.size()-1; c1++){

    if(C[c1] == C[c1+1]){r = c1+1;break;}
}

A.clear();
for(ll c1 = l; c1 <= r; c1++){
    A.push_back(C[c1]);
}
look -= l;

solve();

}

int main()
{
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,d,e,c;
    ll x,y,z;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    cin >> n;
    look = n;

    for(c1 = 0; c1 < 2*n-1; c1++){
        cin >> a;
        A.push_back(a);
    }
    solve();

	return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:78:24: error: no matching function for call to 'min(ll&, std::vector<long long int>::size_type)'
   78 | for(ll c1 = 0; c1 < min(look,C.size()-1); c1++){
      |                     ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:78:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'})
   78 | for(ll c1 = 0; c1 < min(look,C.size()-1); c1++){
      |                     ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:78:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   78 | for(ll c1 = 0; c1 < min(look,C.size()-1); c1++){
      |                     ~~~^~~~~~~~~~~~~~~~~