alexjercan/bugnet huggingface dataset:
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long int ll;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> g(n, vector<int>(n, 10000000));
  for (int i = 0; i < n - 1; i++) {
    g[i][i + 1] = 1;
    g[i + 1][i] = 1;
  }
  x--;
  y--;
  g[x][y] = 1;
  g[y][x] = 1;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      g[i][j] = min(g[i][j], j - i);
      g[j][i] = min(g[j][i], j - i);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      g[i][j] = min(g[i][j], (abs(i - x) + abs(j - y) + 1));
      g[j][i] = min(g[i][j], (abs(i - x) + abs(j - y) + 1));
    }
  }
  vector<int> ans(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (g[i][j] >= 10000000) {
        continue;
      }
      ans[g[i][j]]++;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

typedef long long int ll;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> g(n, vector<int>(n, 10000000));
  for (int i = 0; i < n - 1; i++) {
    g[i][i + 1] = 1;
    g[i + 1][i] = 1;
  }
  x--;
  y--;
  g[x][y] = 1;
  g[y][x] = 1;

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }

  for (int k = 1; k < n; k++) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (g[i][j] == k) {
          ans += 1;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end)                                                     \\
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \\
       i != (end) - ((begin) > (end));                                         \\
       i += 1 - 2 * ((begin) >                                                 \\
                     (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) -->
                             // {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> res(n + 1, 0);
  rep(i, 1, n + 1) rep(j, i + 1, n + 1) {
    int z = min(abs(j - i), abs(x - i) + 1 + abs(j - y));
    res[z]++;
  }
  rep(i, 1, n) cout << res[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end)                                                     \\
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \\
       i != (end) - ((begin) > (end));                                         \\
       i += 1 - 2 * ((begin) >                                                 \\
                     (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) -->
                             // {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

// function for finding minimum no. of edge
// using BFS
int minEdgeBFS(vector<int> edges[], int u, int v, int n) {
  // visited[n] for keeping track of visited
  // node in BFS
  vector<bool> visited(n, 0);

  // Initialize distances as 0
  vector<int> distance(n, 0);

  // queue to do BFS.
  queue<int> Q;
  distance[u] = 0;

  Q.push(u);
  visited[u] = true;
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();

    for (int i = 0; i < edges[x].size(); i++) {
      if (visited[edges[x][i]])
        continue;

      // update distance for i
      distance[edges[x][i]] = distance[x] + 1;
      Q.push(edges[x][i]);
      visited[edges[x][i]] = 1;
    }
  }
  return distance[v];
}

void addEdge(vector<int> edges[], int u, int v) {
  edges[u].push_back(v);
  edges[v].push_back(u);
}

int main() {

  int n, x, y;
  cin >> n >> x >> y;
  vector<int> adj[n];
  rep(i, 0, n - 1) addEdge(adj, i, i + 1);
  addEdge(adj, x - 1, y - 1);
  vector<pair<int, int>> v;
  vector<int> res(n + 1, 0);
  rep(i, 0, n) rep(j, i + 1, n) v.push_back({i, j});
  for (auto it : v)
    res[minEdgeBFS(adj, it.first, it.second, n)]++;
  rep(i, 1, n) cout << res[i] << endl;
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y;
  int ans[2000];
  for (int i = 0; i < 2000; i++) {
    ans[i] = 0;
  }
  cin >> n >> x >> y;
  x--;
  y--;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i; j < n; j++) {
      if (j <= x || i >= y) {
        ans[j - i]++;
      } else {
        ans[min(j - i, abs(x - i) + 1 + abs(j - y))]++;
      }
    }
  }
  for (int i = 1; i < n; i++) {
    cout << ans[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y;
  int ans = 0;
  cin >> n >> x >> y;
  x--;
  y--;
  for (int k = 1; k <= n - 1; k++) {
    ans = 0;
    for (int i = 0; i < n - k; i++) {
      for (int j = i + k; j < n; j++) {
        if (j <= x || i >= y) {
          if (j - k == i) {
            ans++;
          }
        } else {
          if (min(j - i, abs(x - i) + 1 + abs(j - y)) == k) {
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int N, X, Y;

  cin >> N >> X >> Y;

  int ans[N];

  for (int i = 0; i < N; i++) {
    ans[i] = 0;
  }

  for (int i = 1; i <= N - 1; i++) {

    for (int j = i + 1; j <= N; j++) {
      int a = min(
          j - i, min(abs(X - i) + 1 + abs(j - Y), abs(Y - i) + 1 + abs(j - X)));
      ans[a]++;
    }
  }

  for (int i = 1; i < N; i++) {
    cout << ans[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int N, X, Y;

  cin >> N >> X >> Y;

  for (int k = 1; k < N; k++) {
    int ans = 0;
    for (int i = 1; i <= N - 1; i++) {
      for (int j = i + 1; j <= N; j++) {
        int a = min(j - i, min(abs(X - i) + 1 + abs(j - Y),
                               abs(Y - i) + 1 + abs(j - X)));
        if (a == k) {
          // cout << i << " " << j << endl;
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define repo(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {

  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;

  vector<int> ans(N);

  // N回BFSやる
  for (int sv = 0; sv < N; sv++) {
    vector<int> dist(N, -1);
    queue<int> que;
    auto push = [&](int v, int d) {
      if (dist[v] != -1)
        return;
      dist[v] = d;
      que.push(v);
    };
    // 一番初めに見るノードを頂点として初期化する
    push(sv, 0);

    while (!que.empty()) {
      int v = que.front();
      que.pop();
      int d = dist[v];
      if (v - 1 >= 0)
        push(v - 1, d + 1);
      if (v + 1 < N)
        push(v + 1, d + 1);
      if (v == X)
        push(Y, d + 1);
      if (v == Y)
        push(X, d + 1);
      //             if(v-1 >= 0 ){
      //                 if(dist[v-1] == -1){
      //
      //                dist[v-1] = dist[v] + 1;
      //                que.push(v-1);
      //                 }
      //             }else if(v+1 < N){
      //                 if(dist[v+1]==-1){
      //
      //                 dist[v+1] = dist[v] + 1;
      //                 que.push(v+1);
      //                 }
      //             }
      //
      //             if(v == X){
      //                 if(dist[Y]==-1){
      //                 dist[Y] = dist[v] + 1;
      //                que.push(Y);
      //                 }
      //             }
      //
      //             if(v == Y){
      //                 if(dist[X] == -1){
      //                 dist[X] = dist[v] + 1;
      //                que.push(X);
      //                 }
      //             }
    }

    for (int j = 0; j < N; j++) {
      ans[dist[j]]++;
    }
  }

  for (int i = 0; i < N; i++) {
    ans[i] /= 2;
  }

  for (int i = 1; i <= N - 1; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <vector>

#define repo(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> L(N, vector<int>(N));
  int X, Y;

  cin >> X >> Y;
  X--;
  Y--;
  repo(i, N) { L[i][i + 1] = 1; }
  L[X][Y] = 1;

  //     repo(i,N){
  //         repo(j,N){
  //             cout << L[i][j] << " ";
  //         }
  //         cout << endl;
  //     }
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      //             if(L[i][j] != 0) continue;
      for (int k = 0; k < N; k++) {
        if (i == k || j == k)
          continue;
        if (L[i][j] == 0 && L[i][k] * L[k][j] != 0) {
          L[i][j] = L[i][k] + L[k][j];
        } else if (L[i][k] * L[k][j] != 0) {

          L[i][j] = min(L[i][k] + L[k][j], L[i][j]);
        }
      }
    }
  }
  repo(i, N) {
    repo(j, N) { cout << L[i][j] << " "; }
    cout << endl;
  }
  vector<int> ANS(N);
  for (int i = 0; i < N - 1; i++) {
    int count = 0;
    for (int j = i + 1; j < N; j++) {

      //             if(L[i][j] == i+1)
      //                 count++;
      ANS[L[i][j]]++;
    }
  }

  for (int i = 1; i < N; i++) {
    cout << ANS[i] << endl;
  }

  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>

using namespace std;

const int N = 2e3 + 5;

int e[N][N], ans[N];

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      e[j][i] = e[i][j] = j - i;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      e[i][j] = e[j][i] = min(e[i][x] + e[y][j] + 1, e[i][j]);
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      ans[e[i][j]]++;
  for (int i = 1; i < n; ++i)
    cout << ans[i] << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace std;

const int N = 1e3 + 5;

int e[N][N], ans[N];

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      e[j][i] = e[i][j] = j - i;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      e[i][j] = e[j][i] = min(e[i][x] + e[y][j] + 1, e[i][j]);
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      ans[e[i][j]]++;
  for (int i = 1; i < n; ++i)
    cout << ans[i] << endl;

  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = (0); (i) < (int)(n); ++(i))
using ll = long long;
using namespace std;

// E log V
const int MAXV = 2001;
const int INF = 1e8;
struct edge {
  int to, cost;
  edge(int t = 0, int c = 0) : to(t), cost(c) {}
};
int V;
vector<edge> G[MAXV];
int d[MAXV];

// 経路復元
// int prev[MAXV];
int mp[MAXV];

void dijkstra(int s) {
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      que;
  fill(d, d + V, INF);
  d[s] = 0;
  que.push(make_pair(0, s));

  while (!que.empty()) {
    pair<int, int> p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first)
      continue;
    for (int i = 0; i < G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(make_pair(d[e.to], e.to));
        // prev[e.to] = v;
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, X, Y;
  cin >> N >> X >> Y;
  V = N;

  rep(i, N - 1) {
    G[i].emplace_back(i + 1, 1);
    G[i + 1].emplace_back(i, 1);
  }
  X--;
  Y--;
  G[X].emplace_back(Y, 1);
  G[Y].emplace_back(X, 1);

  rep(i, N) {
    dijkstra(i);
    rep(j, N) mp[d[j]]++;
  }

  for (int i = 1; i < N; ++i) {
    cout << mp[i] / 2 << endl;
  }
}


Error: TLE

Fixed submission:

#pragma GCC optimize("Ofast")

// #include <bits/stdc++.h>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define rep(i, n) for (int(i) = (0); (i) < (int)(n); ++(i))
using ll = long long;
using namespace std;

const int MAXV = 2001;
const int INF = 1e8;
int d[MAXV * MAXV + 1]; // d[u][v]は辺e=(u,v)のコスト, （存在しない場合はINF,
                        // ただしd[i][i]=0とする）
int V;
int mp[MAXV];

inline void warshall_floyd() {
  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
      for (int j = 0; j < V; ++j)
        d[i * V + j] = min(d[i * V + j], d[i * V + k] + d[k * V + j]);
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, X, Y;
  cin >> N >> X >> Y;
  V = N;
  fill(d, d + N * N, INF);

  rep(i, N) {
    d[i * V + i] = 0;
    d[i * V + (i + 1)] = d[(i + 1) * V + i] = 1;
  }

  X--;
  Y--;
  d[X * V + Y] = d[Y * V + X] = 1;

  warshall_floyd();

  rep(i, N) for (int j = i + 1; j < N; ++j) { mp[d[i * V + j]]++; }

  for (int i = 1; i < N; ++i) {
    cout << mp[i] << endl;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define pii pair<int, int>
#define ll long long
#define cl(x, y) memset(x, y, sizeof(x))
#define ct cerr << "Time elapsed:" << 1.0 * clock() / CLOCKS_PER_SEC << "s.\\n";
const int N = 2e3 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
using namespace std;
int a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x, y, i, j;
  cin >> n >> x >> y;
  for (i = 1; i < n; i++)
    a[i] = n - i;
  int p = y - (y - x) / 2;
  for (i = 1; i < p; i++)
    for (j = p + 1; j <= n; j++) {
      if (abs(j - i) > abs(x - i) + 1 + abs(j - y)) {
        a[abs(j - i)]--;
        a[abs(x - i) + 1 + abs(j - y)]++;
      }
    }
  for (i = 1; i < n; i++)
    cout << a[i] << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define pii pair<int, int>
#define ll long long
#define cl(x, y) memset(x, y, sizeof(x))
#define ct cerr << "Time elapsed:" << 1.0 * clock() / CLOCKS_PER_SEC << "s.\\n";
const int N = 1e3 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
using namespace std;
int a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x, y, i, j;
  cin >> n >> x >> y;
  for (i = 1; i < n; i++)
    a[i] = n - i;
  int p = y - (y - x) / 2;
  for (i = 1; i < p; i++)
    for (j = p + 1; j <= n; j++) {
      if (abs(j - i) > abs(x - i) + 1 + abs(j - y)) {
        a[abs(j - i)]--;
        a[abs(x - i) + 1 + abs(j - y)]++;
      }
    }
  for (i = 1; i < n; i++)
    cout << a[i] << endl;
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"

int main(int, char **) {
  int N, X, Y;
  std::cin >> N >> X >> Y;
  int count[N - 1];
  for (int i = 0; i < N - 1; i++) {
    count[i] = 0;
  }

  for (int i = 0; i < N - 1; i++) {
    int distance[N];
    for (int k = 0; k < N; k++) {
      distance[k] = std::abs(k - i);
    }

    int min_distance[N];
    for (int k = 0; k < N; k++) {
      int dist = distance[X - 1] + 1 + std::abs((Y - 1) - k);
      min_distance[k] = std::min(distance[k], dist);
    }
    for (int j = i + 1; j < N; j++) {
      int dist;
      if (min_distance[i] == min_distance[j])
        dist = 1;
      else
        dist = std::abs(min_distance[i] - min_distance[j]);
      count[dist - 1] += 1;
    }
  }

  for (int i = 0; i < N - 1; i++) {
    std::cout << count[i] << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"

int main(int, char **) {
  int N, X, Y;
  std::cin >> N >> X >> Y;
  int count[N - 1];
  for (int i = 0; i < N - 1; i++) {
    count[i] = 0;
  }

  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      int distance[N];
      for (int k = 0; k < N; k++) {
        distance[k] = std::abs(k - i);
      }

      int min_distance[N];
      for (int k = 0; k < N; k++) {
        int dist = distance[X - 1] + 1 + std::abs((Y - 1) - k);
        min_distance[k] = std::min(distance[k], dist);
      }

      int dist;
      if (min_distance[i] == min_distance[j])
        dist = 1;
      else
        dist = std::abs(min_distance[i] - min_distance[j]);
      count[dist - 1] += 1;
    }
  }

  for (int i = 0; i < N - 1; i++) {
    std::cout << count[i] << std::endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x;
  --y;
  vector<vector<int>> mat(n, vector<int>(n, n + 1));

  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      mat[i][j] = j - i;
      mat[j][i] = j - i;
    }
  }
  mat[x][y] = 1;
  mat[y][x] = 1;
  vector<int> ex = {x, y};
  for (int e : ex) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j) {
          continue;
        }
        if (mat[i][j] > mat[i][e] + mat[e][j]) {
          mat[i][j] = mat[i][e] + mat[e][j];
        }
      }
    }
  }

  vector<int> ans(n - 1);
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int t = mat[i][j];
      ans[t - 1] += 1;
    }
  }

  for (int a : ans) {
    cout << a << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x;
  --y;
  vector<vector<int>> mat(n, vector<int>(n, n + 1));
  for (int i = 0; i < n - 1; ++i) {
    mat[i][i + 1] = 1;
    mat[i + 1][i] = 1;
    if (i == x) {
      mat[x][y] = 1;
      mat[y][x] = 1;
    }
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j) {
          continue;
        }

        if (mat[i][j] > mat[i][k] + mat[k][j]) {
          mat[i][j] = mat[i][k] + mat[k][j];
        }
      }
    }
  }

  vector<int> ans(n - 1);
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int t = mat[i][j];
      ans[t - 1] += 1;
    }
  }

  for (int a : ans) {
    cout << a << endl;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  map<int, int> mp;
  for (int i = 1; i < N + 1; i++) {
    for (int j = i + 1; j < N + 1; j++) {
      mp[min(j - i, abs(X - i) + 1 + abs(Y - j))]++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  for (int k = 1; k <= N - 1; k++) {
    int cnt = 0;
    for (int i = 1; i < N + 1; i++) {
      for (int j = i + 1; j < N + 1; j++) {
        // cout<<i<<" "<<j<<" "<<min(j-i,abs(X-i)+1+abs(Y-j))<<endl;
        if (k == min(j - i, abs(X - i) + 1 + abs(Y - j))) {
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for (ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for (ll i = (ll)(n - 1); i >= 0; i--)
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;
}

int main() {
  cout << fixed << setprecision(18);

  ll n, x, y;
  ll d[2005][2005];
  memset(d, 0, sizeof(d));
  ll count[2005];
  memset(count, 0, sizeof(count));

  cin >> n >> x >> y;

  rep(i, n) d[i][i + 1] = d[i + 1][i] = 1;
  d[x - 1][y - 1] = 1;

  rep(i, n) {
    for (ll j = i + 2; j < n; j++) {
      if (j != y - 1)
        d[i][j] = d[i][j - 1] + 1;
      else if (i != x - 1) {
        if (i < x - 1)
          d[i][j] = d[i][x - 1] + 1;
        else
          d[i][j] = d[i][j - 1] + 1;
      }

      d[j][i] = d[i][j];
    }
  }

  rep(i, n) {
    for (ll j = i + 1; j < n; j++) {
      d[i][j] = min(d[i][j], min(d[i][x - 1] + 1 + d[j][y - 1],
                                 d[i][y - 1] + 1 + d[j][y - 1]));
    }
  }

  rep(i, n) {
    for (ll j = i + 1; j < n; j++) {
      count[d[i][j]]++;
    }
  }

  rep1(i, n) cout << count[i] << endl;

  return 0;
}

Error: -11

Fixed submission:

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for (ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for (ll i = (ll)(n - 1); i >= 0; i--)
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;
}

int main() {
  cout << fixed << setprecision(18);

  ll n, x, y;
  ll d[2000][2000];
  memset(d, 0, sizeof(d));
  ll count[2000];
  memset(count, 0, sizeof(count));

  cin >> n >> x >> y;

  rep(i, n) d[i][i + 1] = d[i + 1][i] = 1;
  d[x - 1][y - 1] = 1;

  rep(i, n) {
    for (ll j = i + 2; j < n; j++) {
      if (j != y - 1)
        d[i][j] = d[i][j - 1] + 1;
      else if (i != x - 1) {
        if (i < x - 1)
          d[i][j] = d[i][x - 1] + 1;
        else
          d[i][j] = d[i][j - 1] + 1;
      }

      d[j][i] = d[i][j];
    }
  }

  rep(i, n) {
    for (ll j = i + 1; j < n; j++) {
      d[i][j] = min(d[i][j], min(d[i][x - 1] + 1 + d[j][y - 1],
                                 d[i][y - 1] + 1 + d[j][y - 1]));
    }
  }

  rep(i, n) {
    for (ll j = i + 1; j < n; j++) {
      count[d[i][j]]++;
    }
  }

  rep1(i, n) cout << count[i] << endl;

  return 0;
}