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

#include <bits/stdc++.h>

#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int MD = (int)1e9 + 7;
typedef vector<ll> VL;
void dbg() { cerr << "\\n"; }
template <class T, class... T2> void dbg(const T &fst, const T2 &...rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
template <class T, class T2> void amax(T &a, T2 b) {
  if (a < b)
    a = b;
}
const int INF = 1 << 28;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, x, y;
  cin >> n >> x >> y;

  vector<VI> a(n, VI(n));
  rep(i, n) rep2(j, i + 1, n) { a[i][j] = a[j][i] = abs(j - i); }
  rep(i, n) rep2(j, i + 1, n) {
    a[i][j] = min(a[i][j], a[i][x - 1] + a[y - 1][j] + 1);
    a[j][i] = a[i][j];
  }
  VI ds(n + 2);
  rep(i, n) rep2(j, i + 1, n) ds[a[i][j]]++;

  rep2(i, 1, n) cout << ds[i] << "\\n";

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int MD = (int)1e9 + 7;
typedef vector<ll> VL;
void dbg() { cerr << "\\n"; }
template <class T, class... T2> void dbg(const T &fst, const T2 &...rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
template <class T, class T2> void amax(T &a, T2 b) {
  if (a < b)
    a = b;
}
const int INF = 1 << 28;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, x, y;
  cin >> n >> x >> y;
  vector<VI> a(n, VI(n, INF));
  rep(i, n) a[i][i] = 0;
  rep(i, n - 1) a[i][i + 1] = a[i + 1][i] = 1;
  a[x - 1][y - 1] = a[y - 1][x - 1] = 1;
  rep(k, n) rep(i, n) {
    int j = 0;
    for (j = 0; j + 3 < n; j += 4) {
      a[i][j + 0] = min(a[i][j + 0], a[i][k] + a[k][j + 0]);
      a[i][j + 1] = min(a[i][j + 1], a[i][k] + a[k][j + 1]);
      a[i][j + 2] = min(a[i][j + 2], a[i][k] + a[k][j + 2]);
      a[i][j + 3] = min(a[i][j + 3], a[i][k] + a[k][j + 3]);
    }
    for (; j < n; j++) {
      a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
    }
  }
  VI ds(n + 2);
  rep(i, n) rep2(j, i + 1, n) ds[a[i][j]]++;

  // for(auto x :ds) cerr<<x<<" "; dbg();
  rep2(i, 1, n) cout << ds[i] << "\\n";
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

int min3(int i, int j, int X, int Y) {
  int m;
  m = min(abs(j - i), abs(i - Y) + 1 + abs(X - j));
  m = min(m, abs(i - X) + 1 + abs(Y - j));
  return (m);
}

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--, Y--;

  map<int, int> m;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      int d;
      d = min3(i, j, X, Y);
      m[d]++;
      // cout<<"("<<i<<","<<j<<")="<<d<<endl;
    }
  }
  for (int i = 1; i < N; i++)
    cout << m[i] << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

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

  Graph G(N);
  for (int i = 0; i < N - 1; i++) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[X - 1].push_back(Y - 1);
  G[Y - 1].push_back(X - 1);

  int d[N][N];
  // d[i][j]=i-jへの最短経路

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j)
        d[i][j] = 0;
      else if (count(G[i].begin(), G[i].end(), j) == 0)
        d[i][j] = 100;
      else if (count(G[i].begin(), G[i].end(), j) != 0)
        d[i][j] = 1;
    }
  }

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

  map<int, int> m;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      m[d[i][j]]++;
    }
  }

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

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int Inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> dis(n + 1, vector<int>(n + 1));
  vector<int> freq(n);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      dis[i][j] = min(
          {j - i, 1 + abs(x - i) + abs(y - j), 1 + abs(x - j) + abs(y - i)});
      freq[dis[i][j]]++;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << freq[i] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int Inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> dis(n, vector<int>(n));
  vector<int> freq(n);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      dis[i][j] = min(
          {j - i, 1 + abs(x - i) + abs(y - j), 1 + abs(x - j) + abs(y - i)});
      freq[dis[i][j]]++;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << freq[i] << endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

int m[2010][2010];
int N, X, Y;
int c[2010];

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

ll m[2010][2010];
ll N, X, Y;
ll c[2010];

int main() {
  cin >> N >> X >> Y;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j)
        m[i][j] = 0;
      else if (i == j + 1 || i == j - 1)
        m[i][j] = 1;
      else
        m[i][j] = 1e9;
    }
  }
  m[X - 1][Y - 1] = m[Y - 1][X - 1] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        m[j][k] = min(m[j][k], m[j][i] + m[i][k]);
      }
    }
  }
  for (int i = 0; i < N; i++)
    c[i] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      c[m[i][j]]++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << c[i] << endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm> // sort
#include <bits/stdc++.h>
#include <map>
#include <stdio.h>
#include <vector>
using namespace std;

using ll = long long int;
using ppi = pair<ll, ll>;
using pql = priority_queue<ll, vector<ll>, greater<ll>>;
using pq = priority_queue<ll>;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  int a[n];
  for (int i = 0; i < n; i++) {
    a[i] = min(max(x - 1 - i, i + 1 - x) + 1, max(y - 1 - i, i + 1 - y));
  }
  int b[n - 1];
  for (int i = 0; i < n - 1; i++) {
    b[i] = 0;
  }
  for (int j = 0; j < n; j++) {
    for (int k = j + 1; k < n; k++) {
      b[min(k - j, a[j] + a[k]) - 1]++;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    cout << b[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm> // sort
#include <bits/stdc++.h>
#include <map>
#include <stdio.h>
#include <vector>
using namespace std;

using ll = long long int;
using ppi = pair<ll, ll>;
using pql = priority_queue<ll, vector<ll>, greater<ll>>;
using pq = priority_queue<ll>;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  int a[n];
  for (int i = 0; i < n; i++) {
    a[i] = min(max(x - 1 - i, i + 1 - x) + 1, max(y - 1 - i, i + 1 - y));
  }
  int c = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (i + 1 == min(k - j, a[j] + a[k])) {
          c++;
        }
      }
    }
    cout << c << endl;
    c = 0;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <math.h>
#include <stdio.h>
int main() {
  int K, X, Y, i, j, z;
  scanf("%d %d %d", &K, &X, &Y);
  int A[K];
  int saX, saY, Arute;
  for (i = 0; i < K; i++) {
    A[i] = 0;
  }
  for (i = 1; i < K; i++) {
    saX = i - X;
    if (i - X < 0) {
      saX = X - i;
    }
    for (j = i + 1; j <= K; j++) {
      saY = j - Y;
      if (j - Y < 0) {
        saY = Y - j;
      }
      Arute = saX + saY + 1;
      if (Arute < j - i) {
        A[Arute] = A[Arute] + 1;
      } else {
        A[j - i] = A[j - i] + 1;
      }
    }
  }
  for (z = 1; z < K; z++) {
    printf("%d\\n", A[z]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <math.h>
#include <stdio.h>
int main() {
  int K, X, Y, i, j, z;
  scanf("%d %d %d", &K, &X, &Y);
  int A[K][K];
  int anser[K];
  int saX, saY, Arute;
  for (i = 1; i < K; i++) {
    saX = i - X;
    if (i - X < 0) {
      saX = X - i;
    }
    for (j = i + 1; j <= K; j++) {
      saY = j - Y;
      if (j - Y < 0) {
        saY = Y - j;
      }
      Arute = saX + saY + 1;
      if (Arute < j - i) {
        A[i][j] = Arute;
      } else {
        A[i][j] = j - i;
      }
    }
  }

  for (z = 1; z < K; z++) {
    anser[z] = 0;
    for (i = 1; i < K; i++) {
      for (j = i + 1; j <= K; j++) {
        if (A[i][j] == z) {
          anser[z] = anser[z] + 1;
        }
      }
    }
    printf("%d\\n", anser[z]);
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
constexpr int mo = 1e9 + 7;
constexpr int inf = 1 << 30;
constexpr ll infl = 1ll << 60;
constexpr ll mo2 = 998244353;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n, x, y;
  cin >> n >> x >> y;
  vector<int> E[2005];
  for (int i = 0; i < n - 1; ++i) {
    E[i].push_back(i + 1);
    E[i + 1].push_back(i);
  }
  x--;
  y--;
  E[x].push_back(y);
  E[y].push_back(x);
  vector<int> ret(2005);
  for (int i = 0; i < n; ++i) {
    vector<int> dist(2005, inf);
    queue<int> q;
    q.push(i);
    dist[i] = 0;
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      if (cur > i)
        ret[dist[cur]]++;
      for (auto v : E[cur])
        if (dist[v] == inf) {
          dist[v] = dist[cur] + 1;
          q.push(v);
        }
    }
  }
  for (int i = 1; i < n; ++i)
    cout << ret[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
constexpr int mo = 1e9 + 7;
constexpr int inf = 1 << 30;
constexpr ll infl = 1ll << 60;
constexpr ll mo2 = 998244353;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> dp(2000, vector<int>(2000, inf));
  for (int i = 0; i < n - 1; ++i) {
    dp[i][i + 1] = 1;
    dp[i + 1][i] = 1;
    dp[i][i] = 0;
  }
  x--;
  y--;
  dp[x][y] = 1;
  dp[y][x] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < n; ++k)
        if (dp[k][i] < inf and dp[i][j] < inf and
            dp[k][j] > dp[k][i] + dp[i][j])
          dp[k][j] = dp[k][i] + dp[i][j];
  map<int, int> m;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      m[dp[i][j]]++;
    }
  for (int i = 0; i < n - 1; ++i) {
    cout << m[i + 1] << endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));

signed main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  vector<vector<int>> dp(N, vector<int>(N, INF));
  rep(i, N) rep(j, N) dp[i][j] = abs(j - i);
  dp[X][Y] = 1;
  dp[Y][X] = 1;
  for (int i = 0; i < N; i++) {   // 始点
    for (int j = 0; j < N; j++) { // 終点
      dp[i][j] =
          min({dp[i][j], dp[i][X] + dp[Y][j] + 1, dp[i][Y] + dp[X][j] + 1});
    }
  }
  map<int, int> m;
  rep(i, N) rep(j, N) m[dp[i][j]]++;
  for (int i = 1; i <= N - 1; i++)
    cout << m[i] / 2 << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));

signed main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  vector<vector<int>> dp(N, vector<int>(N, INF));
  rep(i, N) dp[i][i] = 0;
  rep(i, N - 1) dp[i][i + 1] = 1;
  rep(i, N - 1) dp[i + 1][i] = 1;
  dp[X][Y] = 1;
  dp[Y][X] = 1;
  for (int k = 0; k < N; k++) {     // 経由する頂点
    for (int i = 0; i < N; i++) {   // 始点
      for (int j = 0; j < N; j++) { // 終点
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  map<int, int> m;
  rep(i, N) rep(j, N) m[dp[i][j]]++;
  for (int i = 1; i <= N - 1; i++)
    cout << m[i] / 2 << endl;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

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

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

  ll i, j, k, l, m, n, w, x, y, z, p, q, tmp, sum = 0;
  ll a[100000];
  string str;
  cin >> n >> x >> y;
  ;
  x--;
  y--;
  rep(i, n - 1) {
    REP(j, i + 1, n) {
      a[min(j - i, abs(j - y) + 1 + abs(x - i))]++;
      // cout<<i<<" "<<j<<" "<<min(j-i,abs(j-y)+1+abs(x-i))<<endl;
    }
  }
  rep(i, n) {
    if (i == 0)
      continue;
    cout << a[i] << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

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

  ll i, j, k, l, m, n, w, x, y, z, p, q, tmp, sum = 0;
  ll a[1000];
  string str;
  cin >> n >> x >> y;
  ;
  x--;
  y--;
  rep(i, n - 1) {
    REP(j, i + 1, n) {
      a[min(j - i, abs(j - y) + 1 + abs(x - i))]++;
      // cout<<i<<" "<<j<<" "<<min(j-i,abs(j-y)+1+abs(x-i))<<endl;
    }
  }
  rep(i, n) {
    if (i == 0)
      continue;
    cout << a[i] << endl;
  }

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

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void YN(bool flg) {
  if (flg)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void Yn(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void yn(bool flg) {
  if (flg)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int INF = 1001001001;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x, --y;
  vvi g(n);
  rep(i, n - 1) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);

  vvi dist(n, vi(n, -1));
  rep(i, n) {
    queue<P> q;
    q.push({i, 0});
    while (!q.empty()) {
      auto x = q.front();
      q.pop();
      int p = x.first, d = x.second;
      if (dist[i][p] != -1)
        continue;
      dist[i][p] = d;
      for (int np : g[p]) {
        q.push({np, d + 1});
      }
    }
  }

  vi ans(n - 1);
  rep(i, n) {
    for (int j = i + 1; j < n; j++) {
      int c = dist[i][j];
      ans[c - 1]++;
    }
  }

  for (int x : ans)
    cout << x << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void YN(bool flg) {
  if (flg)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void Yn(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void yn(bool flg) {
  if (flg)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int INF = 1001001001;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vvi dp(n, vi(n, INF));
  --x, --y;
  dp[x][y] = 1;
  dp[y][x] = 1;
  rep(i, n - 1) {
    dp[i][i + 1] = 1;
    dp[i + 1][i] = 1;
  }

  rep(k, n) rep(i, n) rep(j, n) {
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  }

  vi ans(n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int num = dp[i][j];
      if (num >= n - 1)
        continue;
      ans[num]++;
    }
  }

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

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

#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define nmax 2005
int n, m, edge[nmax][nmax];
int vis[nmax] = {0};
int main() {
  ios::sync_with_stdio(false);
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      edge[i][j] = min(j - i, abs(j - y) + abs(i - x) + 1);
      vis[edge[i][j]]++;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << vis[i] << "\\n";
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define nmax 2005
int n, m, edge[nmax][nmax];
int main() {
  ios::sync_with_stdio(false);
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      edge[i][j] = abs(j - i);
    }
  }
  edge[x][y] = edge[y][x] = 1;
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (edge[k][j] < inf && edge[i][k] < inf &&
            edge[i][j] > edge[i][k] + edge[k][j]) {
          edge[i][j] = edge[i][k] + edge[k][j];
        }
      }
    }
  }
  int vis[2005] = {0};
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      vis[edge[i][j]]++;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << vis[i] / 2 << "\\n";
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define mp make_pair
#define pr pair<ll, ll>
#define MAX 1000000
using namespace std;
typedef long long int ll;
#define mod 998244353
void sync() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void floud(vector<vector<ll>> &G, ll n) {
  for (ll k = 0; k < n; k++) {
    for (ll i = 0; i < n; i++) {
      for (ll j = 0; j < n; j++) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
}
int main() {
  sync();
  ll n, x, y;
  cin >> n >> x >> y;
  x--, y--;
  vector<vector<ll>> G(n, vector<ll>(n, INT_MAX));
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++)
      G[i][j] = G[j][i] = min(abs(j - i), min(abs(x - i) + abs(j - y) + 1,
                                              abs(y - i) + abs(j - x) + 1));
  }
  map<ll, ll> ans;
  for (ll i = 0; i <= n - 1; i++) {
    for (ll j = i + 1; j < n; j++) {
      if (G[i][j] != INT_MAX)
        ans[G[i][j]]++;
    }
  }
  for (ll i = 1; i <= n - 1; i++)
    cout << ans[i] << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define mp make_pair
#define pr pair<ll, ll>
#define MAX 1000000
using namespace std;
typedef long long int ll;
#define mod 998244353
void sync() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void floud(vector<vector<ll>> &G, ll n) {
  for (ll k = 0; k < n; k++) {
    for (ll i = 0; i < n; i++) {
      for (ll j = 0; j < n; j++) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
}
int main() {
  sync();
  //	ll t;
  //	cin>>t;
  ll n, x, y;
  cin >> n >> x >> y;
  //	cout<<"fasdf";
  vector<vector<ll>> G(n, vector<ll>(n, INT_MAX));
  for (int i = 0; i < n - 1; i++)
    G[i][i + 1] = G[i + 1][i] = 1;
  x--;
  y--;
  G[x][y] = G[y][x] = 1;
  for (ll i = 0; i < n; i++)
    G[i][i] = 0;

  floud(G, n);

  map<ll, ll> ans;
  for (ll i = 0; i <= n - 1; i++) {
    for (ll j = i + 1; j < n; j++) {
      if (G[i][j] != INT_MAX)
        ans[G[i][j]]++;
    }
  }
  for (ll i = 1; i <= n - 1; i++)
    cout << ans[i] << endl;
}