Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

typedef pair<ll, ll> P;

bool pairCompare1(const P& firstElof, const P& secondElof)
{
    return firstElof.first > secondElof.first;
}
bool pairCompare2(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
bool pairCompare3(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}
bool pairCompare4(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main() {
    int n; cin >> n;
    vector<P> p;
    ll tx,ty;
    rep(i, n) {
        cin >> tx >> ty;
        p.push_back(make_pair(tx, ty));
    }

    ll ans = 100000;

    vector<P> p1;
    sort(p.begin(),p.end(),pairCompare1);
    for(int i=1; i < n; i++) {
        p1.push_back(make_pair(p[i].first-p[i-1].first, p[i].second-p[i-1].second));
    }
    sort(p1.begin(), p1.end());
    p1.erase(unique(p1.begin(), p1.end()), p1.end());
    int tmp = p1.size();
    ans = min(ans, tmp);



//    vector<P> p2;
//    sort(p.begin(),p.end(),pairCompare2);
//    for(int i=1; i < n; i++) {
//        p2.push_back(make_pair(p[i].first-p[i-1].first, p[i].second-p[i-1].second));
//    }
//    sort(p2.begin(), p2.end());
//    p2.erase(unique(p2.begin(), p2.end()), p2.end());
//    tmp = p2.size();
//    cout << tmp << endl;
//    rep(i, tmp) {
//        cout << p2[i].first << " " << p2[i].second  << endl;
//    }
//    cout << "hoge" << endl;
//    ans = min(ans, tmp);

    vector<P> p3;
    sort(p.begin(),p.end(),pairCompare3);
    for(int i=1; i < n; i++) {
        p3.push_back(make_pair(p[i].first-p[i-1].first, p[i].second-p[i-1].second));
    }
    sort(p3.begin(), p3.end());
    p3.erase(unique(p3.begin(), p3.end()), p3.end());
    tmp = p3.size();
    ans = min(ans, tmp);

//    vector<P> p4;
//    sort(p.begin(),p.end(),pairCompare4);
//    for(int i=1; i < n; i++) {
//        p4.push_back(make_pair(p[i].first-p[i-1].first, p[i].second-p[i-1].second));
//    }
//    sort(p4.begin(), p4.end());
//    p4.erase(unique(p4.begin(), p4.end()), p4.end());
//    tmp = p4.size();
//    cout << tmp << endl;
//    ans = min(ans, tmp);

    cout << ans << endl;

}

/**
4
1 1
3 7
3 3
5 9
 **/

Compiler output:
a.cc: In function 'int main()':
a.cc:48:14: error: no matching function for call to 'min(ll&, int&)'
   48 |     ans = min(ans, tmp);
      |           ~~~^~~~~~~~~~
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:48:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   48 |     ans = min(ans, tmp);
      |           ~~~^~~~~~~~~~
/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:4:
/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:48:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |     ans = min(ans, tmp);
      |           ~~~^~~~~~~~~~
a.cc:75:14: error: no matching function for call to 'min(ll&, int&)'
   75 |     ans = min(ans, tmp);
      |           ~~~^~~~~~~~~~
/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:75:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   75 |     ans = min(ans, tmp);
      |           ~~~^~~~~~~~~~
/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
/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:75:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   75 |     ans = min(ans, tmp);
      |           ~~~^~~~~~~~~~