Problem p03006 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define il inline
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l + r) >> 1)
#define MAXN 1050
#define MAXM
#define mod
#define inf (1 << 30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for (register int i = x; i <= y; ++i)
#define repd(i, x, y) for (register int i = x; i >= y; --i)
#define file(s) freopen(s ".in", "r", stdin), freopen(s ".my", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) { return x > y ? x = y, 1 : 0; }
template <typename T> il bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; }
template <typename T> il void read(T &x) {
  char ch = getchar();
  int f = 1;
  x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
  read(x), read(args...);
}
int n, b[MAXN << 2], x[MAXN], y[MAXN], tot;
int f[MAXN << 2][MAXN << 2];
int main() {
  read(n);
  rep(i, 1, n) read(x[i], y[i]);
  rep(i, 1, n) rep(j, 1, n) b[++tot] = x[i] - x[j], b[++tot] = y[i] - y[j];
  sort(b + 1, b + tot + 1), tot = unique(b + 1, b + tot + 1) - b - 1;
#define get(x) (lower_bound(b + 1, b + tot + 1, x) - b)
  rep(i, 1, n) rep(j, 1, n) if (i != j) f[get(x[i] - x[j])][get(y[i] - y[j])]++;
  int ans = 0;
  rep(i, 1, tot) rep(j, 1, tot) chkmax(ans, f[i][j]);
  cout << n - ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define il inline
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l + r) >> 1)
#define MAXN 3050
#define MAXM
#define mod
#define inf (1 << 30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for (register int i = x; i <= y; ++i)
#define repd(i, x, y) for (register int i = x; i >= y; --i)
#define file(s) freopen(s ".in", "r", stdin), freopen(s ".my", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) { return x > y ? x = y, 1 : 0; }
template <typename T> il bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; }
template <typename T> il void read(T &x) {
  char ch = getchar();
  int f = 1;
  x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
  read(x), read(args...);
}
int n, b[MAXN << 2], x[MAXN], y[MAXN], tot;
int f[MAXN << 2][MAXN << 2];
int main() {
  read(n);
  rep(i, 1, n) read(x[i], y[i]);
  rep(i, 1, n) rep(j, 1, n) b[++tot] = x[i] - x[j], b[++tot] = y[i] - y[j];
  sort(b + 1, b + tot + 1), tot = unique(b + 1, b + tot + 1) - b - 1;
#define get(x) (lower_bound(b + 1, b + tot + 1, x) - b)
  rep(i, 1, n) rep(j, 1, n) if (i != j) f[get(x[i] - x[j])][get(y[i] - y[j])]++;
  int ans = 0;
  rep(i, 1, tot) rep(j, 1, tot) chkmax(ans, f[i][j]);
  cout << n - ans << endl;
  return 0;
}