Language: C++

#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll H,W,N;
ll X[200010],Y[200010];
ll min_sp;
ll min_s;
ll ans;
map<ll, bool> mp;
int main() {
    cin>>H>>W>>N;
    ans=min_sp=min_s=inf;
    REP(i,0,N){
        cin>>X[i]>>Y[i];
        mp[X[i]-Y[i]]=min(X[i], mp[X[i]-Y[i]]);
        if(X[i] == Y[i]){
            min_sp = min(X[i], min_sp);
        }else if(X[i]==Y[i]+1){
            min_s = min(X[i]-1, min_s);
        }
    }
    REP(i,0,N){
        if(X[i] > Y[i]){
            if(!mp[X[i]-Y[i]] > X[i]){
                ans=min(ans, X[i]-1);
            }
        }
    }
    if(min_sp > min_s){
        ans = min(min_s, ans);
    }
    ans = min(ans, W);
    p(ans);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:26: error: no matching function for call to 'min(ll&, std::map<long long int, bool>::mapped_type&)'
   27 |         mp[X[i]-Y[i]]=min(X[i], mp[X[i]-Y[i]]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~
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: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:27:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::map<long long int, bool>::mapped_type' {aka 'bool'})
   27 |         mp[X[i]-Y[i]]=min(X[i], mp[X[i]-Y[i]]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~
/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:
/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:27:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   27 |         mp[X[i]-Y[i]]=min(X[i], mp[X[i]-Y[i]]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~