Language: C++

#include <iostream>
#include <vector> #include <map>
#include <cstdio>
#include <cmath>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

struct P{
  long long x;
  long long y;
};

int main(void){
  int N;
  cin >> N;
  vector<P> p(N);
  map<long long, int> xm;
  map<long long, int> ym;
  for(int n = 0; n < N; ++n){
    cin >> p[n].x >> p[n].y;
    ++xm[p[n].x];
    ++ym[p[n].y];
  }
  long long q = 0;
  int max = 0;
  for(int n = 0; n < N; ++n){
    for(int m = n; m < N - 1; ++m){
      int count = 0;
      long long diff = p[m].x - p[m + 1].x;
      for(int l = 0; l < N; ++l){
        if(xm[p[m].x - diff] != 0){
          ++count;
        }
      }
      if(max < count){
        max = count;
        q = diff;
      }
      count = 0;
      for(int l = 0; l < N; ++l){
        if(xm[p[m].x + diff] != 0){
          ++count;
        }
      }
      if(max < count){
        max = count;
        q = diff;
      }
    }
  }
  long long r = 0;
  max = 0;
  for(int n = 0; n < N; ++n){
    for(int m = n; m < N - 1; ++m){
      int count = 0;
      long long diff = p[m].y - p[m + 1].y;
      for(int l = 0; l < N; ++l){
        if(ym[p[m].y - diff] != 0){
          ++count;
        }
      }
      if(max < count){
        max = count;
        r = diff;
      }
      count = 0;
      for(int l = 0; l < N; ++l){
        if(ym[p[m].y + diff] != 0){
          ++count;
        }
      }
      if(max < count){
        max = count;
        r = diff;
      }
    }
  }
  
  int count1 = 0, count2 = 0;
  for(int n = 0; n < N; ++n){
    if(xm[p[n].x - q] != 0 && ym[p[n].y - r] != 0){
      ++count1;
    }
  }
  for(int n = 0; n < N; ++n){
    if(xm[p[n].x + q] != 0 && ym[p[n].y + r] != 0){
      ++count2;
    }
  }
  if(count1 > count2)
    cout << N - count1 << endl;
  else
    cout << N - count2 << endl;

  return 0;
}


Compiler output:
a.cc:2:19: warning: extra tokens at end of #include directive
    2 | #include <vector> #include <map>
      |                   ^
a.cc: In function 'int main()':
a.cc:19:3: error: 'map' was not declared in this scope
   19 |   map<long long, int> xm;
      |   ^~~
a.cc:8:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    7 | #include <algorithm>
  +++ |+#include <map>
    8 | using namespace std;
a.cc:19:7: error: expected primary-expression before 'long'
   19 |   map<long long, int> xm;
      |       ^~~~
a.cc:20:7: error: expected primary-expression before 'long'
   20 |   map<long long, int> ym;
      |       ^~~~
a.cc:23:7: error: 'xm' was not declared in this scope; did you mean 'tm'?
   23 |     ++xm[p[n].x];
      |       ^~
      |       tm
a.cc:24:7: error: 'ym' was not declared in this scope; did you mean 'yn'?
   24 |     ++ym[p[n].y];
      |       ^~
      |       yn
a.cc:33:12: error: 'xm' was not declared in this scope; did you mean 'm'?
   33 |         if(xm[p[m].x - diff] != 0){
      |            ^~
      |            m
a.cc:43:12: error: 'xm' was not declared in this scope; did you mean 'm'?
   43 |         if(xm[p[m].x + diff] != 0){
      |            ^~
      |            m
a.cc:60:12: error: 'ym' was not declared in this scope; did you mean 'm'?
   60 |         if(ym[p[m].y - diff] != 0){
      |            ^~
      |            m
a.cc:70:12: error: 'ym' was not declared in this scope; did you mean 'm'?
   70 |         if(ym[p[m].y + diff] != 0){
      |            ^~
      |            m
a.cc:83:8: error: 'xm' was not declared in this scope; did you mean 'tm'?
   83 |     if(xm[p[n].x - q] != 0 && ym[p[n].y - r] != 0){
      |        ^~
      |        tm
a.cc:83:31: error: 'ym' was not declared in this scope; did you mean 'yn'?
   83 |     if(xm[p[n].x - q] != 0 && ym[p[n].y - r] != 0){
      |                               ^~
      |                               yn
a.cc:88:8: error: 'xm' was not declared in this scope; did you mean 'tm'?
   88 |     if(xm[p[n].x + q] != 0 && ym[p[n].y + r] != 0){
      |        ^~
      |        tm
a.cc:88:31: error: 'ym' was not declared in this scope; did you mean 'yn'?
   88 |     if(xm[p[n].x + q] != 0 && ym[p[n].y + r] != 0){
      |                               ^~
      |                               yn