Problem p00503 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

ll n, K;
vector<ll> unzipx, unzipy, unzipz;
int x, y, z;
vector<ll> bx, by, bz, ex, ey, ez;
int sum[55][55][55];

int press(vector<ll> &v1, vector<ll> &v2, vector<ll> &unzip) {
  auto t1 = v1, t2 = v2;
  t1.insert(t1.end(), t2.begin(), t2.end());
  sort(t1.begin(), t1.end());
  t1.erase(unique(t1.begin(), t1.end()), t1.end());
  for (int i = 0; i < v1.size(); i++) {
    ll tmp = lower_bound(t1.begin(), t1.end(), v1[i]) - t1.begin();
    unzip[tmp] = v1[i];
    v1[i] = tmp;
  }

  for (int i = 0; i < v2.size(); i++) {
    ll tmp = lower_bound(t1.begin(), t1.end(), v2[i]) - t1.begin();
    unzip[tmp] = v2[i];
    v2[i] = tmp;
  }

  return t1.size();
}

int main() {
  unzipx.resize(55 * 3), unzipy.resize(55 * 3), unzipz.resize(55 * 3);
  cin >> n >> K;
  for (int i = 0; i < n; i++) {
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    bx.push_back(a), by.push_back(b), bz.push_back(c);
    ex.push_back(d), ey.push_back(e), ez.push_back(f);
  }
  x = press(bx, ex, unzipx), y = press(by, ey, unzipy),
  z = press(bz, ez, unzipz);
  // ?´?????????????
  ll ans = 0;
  for (int i = 0; i < bx.size(); i++) {
    for (int j = bx[i]; j < ex[i]; j++) {
      for (int k = by[i]; k < ey[i]; k++) {
        for (int l = bz[i]; l < ez[i]; l++) {
          sum[j][k][l]++;
        }
      }
    }
  }
  for (int i = 0; i < x - 1; i++) {
    for (int j = 0; j < y - 1; j++) {
      for (int k = 0; k < z - 1; k++) {
        if (sum[i][j][k] >= K) {
          ans += ((unzipx[i + 1] - unzipx[i]) * (unzipy[j + 1] - unzipy[j]) *
                  (unzipz[k + 1] - unzipz[k]));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

ll n, K;
vector<ll> unzipx, unzipy, unzipz;
int x, y, z;
vector<ll> bx, by, bz, ex, ey, ez;
int sum[105][105][105];

int press(vector<ll> &v1, vector<ll> &v2, vector<ll> &unzip) {
  auto t1 = v1, t2 = v2;
  t1.insert(t1.end(), t2.begin(), t2.end());
  sort(t1.begin(), t1.end());
  t1.erase(unique(t1.begin(), t1.end()), t1.end());
  for (int i = 0; i < v1.size(); i++) {
    ll tmp = lower_bound(t1.begin(), t1.end(), v1[i]) - t1.begin();
    unzip[tmp] = v1[i];
    v1[i] = tmp;
  }

  for (int i = 0; i < v2.size(); i++) {
    ll tmp = lower_bound(t1.begin(), t1.end(), v2[i]) - t1.begin();
    unzip[tmp] = v2[i];
    v2[i] = tmp;
  }

  return t1.size();
}

int main() {
  unzipx.resize(55 * 3), unzipy.resize(55 * 3), unzipz.resize(55 * 3);
  cin >> n >> K;
  for (int i = 0; i < n; i++) {
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    bx.push_back(a), by.push_back(b), bz.push_back(c);
    ex.push_back(d), ey.push_back(e), ez.push_back(f);
  }
  x = press(bx, ex, unzipx), y = press(by, ey, unzipy),
  z = press(bz, ez, unzipz);
  // ?´?????????????
  ll ans = 0;
  for (int i = 0; i < bx.size(); i++) {
    for (int j = bx[i]; j < ex[i]; j++) {
      for (int k = by[i]; k < ey[i]; k++) {
        for (int l = bz[i]; l < ez[i]; l++) {
          sum[j][k][l]++;
        }
      }
    }
  }
  for (int i = 0; i < x - 1; i++) {
    for (int j = 0; j < y - 1; j++) {
      for (int k = 0; k < z - 1; k++) {
        if (sum[i][j][k] >= K) {
          ans += ((unzipx[i + 1] - unzipx[i]) * (unzipy[j + 1] - unzipy[j]) *
                  (unzipz[k + 1] - unzipz[k]));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}