Problem p03576 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)
#define each(a, b) for (auto(a) : (b))
#define all(v) (v).begin(), (v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout << #x << " = " << (x) << endl
#define spair(p) cout << #p << ": " << p.fi << " " << p.se << endl
#define svec(v)                                                                \
  cout << #v << ":";                                                           \
  rep(kbrni, v.size()) cout << " " << v[kbrni];                                \
  cout << endl
#define sset(s)                                                                \
  cout << #s << ":";                                                           \
  each(kbrni, s) cout << " " << kbrni;                                         \
  cout << endl
#define smap(m)                                                                \
  cout << #m << ":";                                                           \
  each(kbrni, m) cout << " {" << kbrni.first << ":" << kbrni.second << "}";    \
  cout << endl

using namespace std;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, K;
  cin >> n >> K;
  vector<ll> x(n), y(n);
  vector<ll> u(n), v(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
    u[i] = x[i], v[i] = y[i];
  }
  rep(i, n) { x.pb(x[i] + 1), y.pb(y[i] + 1); }
  zip(x), zip(y);
  ll ans = (1LL << 62);
  rep(i, len(x) - 1) {
    srep(j, i + 1, len(x)) {
      rep(k, len(y) - 1) {
        srep(l, k + 1, len(y)) {
          int res = 0;
          rep(m, n) {
            if (x[i] <= u[m] && u[m] <= x[j] && y[k] <= v[m] && v[m] <= y[l]) {
              res++;
            }
          }
          if (res >= K) {
            ans = min(ans, (x[j] - x[i]) * (y[l] - y[k]));
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)
#define each(a, b) for (auto(a) : (b))
#define all(v) (v).begin(), (v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout << #x << " = " << (x) << endl
#define spair(p) cout << #p << ": " << p.fi << " " << p.se << endl
#define svec(v)                                                                \
  cout << #v << ":";                                                           \
  rep(kbrni, v.size()) cout << " " << v[kbrni];                                \
  cout << endl
#define sset(s)                                                                \
  cout << #s << ":";                                                           \
  each(kbrni, s) cout << " " << kbrni;                                         \
  cout << endl
#define smap(m)                                                                \
  cout << #m << ":";                                                           \
  each(kbrni, m) cout << " {" << kbrni.first << ":" << kbrni.second << "}";    \
  cout << endl

using namespace std;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, K;
  cin >> n >> K;
  vector<ll> x(n), y(n);
  vector<ll> u(n), v(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
    u[i] = x[i], v[i] = y[i];
  }
  rep(i, n) { x.pb(x[i] + 1), y.pb(y[i] + 1); }
  zip(x), zip(y);
  ll ans = (1LL << 62);
  rep(i, len(x) - 1) {
    srep(j, i + 1, len(x)) {
      rep(k, len(y) - 1) {
        srep(l, k + 1, len(y)) {
          int res = 0;
          rep(m, n) {
            if (x[i] <= u[m] && u[m] <= x[j] && y[k] <= v[m] && v[m] <= y[l]) {
              res++;
            }
          }
          if (res >= K) {
            ans = min(ans, (x[j] - x[i]) * (y[l] - y[k]));
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}