Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template <class T> void print1d(T x, ll n = -1) {
  if (n == -1)
    n = x.size();
  rep(i, 0, n) { cout << x[i] << ' '; }
  cout << '\\n';
}
template <class T> void print2d(T x, ll r = -1, ll c = -1) {
  if (r == -1)
    r = x.size();
  if (c == -1)
    c = x[0].size();
  rep(i, 0, r) print1d(x[i], c);
}
template <class T, class U> bool haskey(T mp, U key) {
  return mp.find(key) != mp.end();
}
template <class T, class U> bool isin(T el, U container) {
  return find(all(container), el) != container.end();
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool even(T n) { return !(n & 1); }
template <class T> bool odd(T n) { return n & 1; }
template <class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template <class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a, ll n) {
  ll p = 1;
  while (n) {
    if (n & 1)
      p *= a;
    a *= a;
    n >>= 1;
  }
  return p;
}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
  ll N, X, Y;
  cin >> N >> X >> Y;
  vll ans(N + 1);
  rep(i, 1, N + 1) {
    rep(j, i, N + 1) {
      if (i <= X and Y <= j) {
        ans[X - i + j - Y + 1]++;
      } else if (X <= i and i <= Y and Y <= j) {
        ll tmp = min(j - i, i - X + j - Y + 1);
        ans[tmp]++;
      } else if (i <= X and X <= j and j <= Y) {
        ll tmp = min(j - i, Y - j + X - i + 1);
        ans[tmp]++;
      } else if (X <= i and i <= Y and X <= j and j <= Y) {
        ll tmp = min(j - i, i - X + Y - j + 1);
        ans[tmp]++;
      } else {
        ans[j - i]++;
      }
    }
  }
  rep(i, 1, N) { cout << ans[i] << endl; }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define irange(end) for (long long int i = 0; i < end; ++i)
#define jrange(end) for (long long int j = 0; j < end; ++j)
#define krange(end) for (long long int k = 0; k < end; ++k)
#define rep(i, first, last) for (long long int i = first; i <= last; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout << #x << " = " << (x) << " (L" << LINE << ")" << endl;
#define vdeb(x)                                                                \\
  {                                                                            \\
    cout << #x << " = { ";                                                     \\
    rep(i, x.size()) cout << x[i] << ' ';                                      \\
    cout << '}' << " (L" << LINE << ")" << endl;                               \\
  }
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long int>;
using vs = vector<string>;

int main() {
  int n, x, y;
  int tmp;
  cin >> n >> x >> y;
  vi d{n + 1, 0};
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      int min = j - i;
      tmp = abs(i - x) + abs(j - y) + 1;
      if (tmp < min)
        min = tmp;
      tmp = abs(j - x) + abs(i - y) + 1;
      if (tmp < min)
        min = tmp;
      ++d[min];
    }
  }
  for (int i = 1; i < n; ++i) {
    cout << d[i] << endl;
  }
}