alexjercan/bugnet huggingface dataset:
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++)
int64_t MOD = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int64_t> A(N, 0);
  for (int i = 1; i < N; i++) {
    for (int j = i + 1; j <= N; j++) {
      auto k = min(
          j - i, min(abs(i - X) + abs(j - Y) + 1, abs(i - Y) + abs(j - X) + 1));
      A.at(k)++;
    }
  }
  rep(i, N - 1) { cout << A.at(i + 1) << endl; }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD = 1000000007;
const long long INF = 1LL << 60;

void warshall_floyd(int n, vector<vector<int64_t>> &d) {
  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]);
      }
    }
  }
}

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<vector<int64_t>> S(N, vector<int64_t>(N, 1000000));
  rep(i, N) {
    S[i][i] = 0;
    if (i < N - 1) {
      S[i][i + 1] = 1;
      S[i + 1][i] = 1;
    }
  }
  S[X - 1][Y - 1] = 1;
  S[Y - 1][X - 1] = 1;
  warshall_floyd(N, S);
  vector<int64_t> A(N, 0);
  rep(i, N) {
    rep(j, N) { A.at(S.at(i).at(j))++; }
  }
  rep(i, N - 1) { cout << A.at(i + 1) / 2 << endl; }
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e3 + 1;

int n, x, y, ans[MAXN];

int main() {
  cin >> n >> x >> y;
  if (x > y)
    swap(x, y);
  for (int i = 1, j, dis; i < n; ++i)
    for (j = i + 1; j <= n; ++j) {
      if (i <= x) {
        if (j <= x)
          ++ans[j - i];
        else if (j <= y)
          ++ans[min(j - i, x - i + y - j + 1)];
        else
          ++ans[min(x - i + j - y + 1, j - i)];
      } else if (i <= y) {
        if (j <= y)
          ++ans[min(j - i, i - x + y - j + 1)];
        else
          ++ans[min(j - i, i - x + 1 + j - y)];
      } else
        ++ans[j - i];
    }
  for (int i = 1; i < n; ++i)
    cout << ans[i] << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e3 + 1;

int n, x, y, ans[MAXN];

int main() {
  cin >> n >> x >> y;
  for (int i = 1, j, dis; i < n; ++i)
    for (j = i + 1; j <= n; ++j) {
      if (i <= x && j >= y)
        ++ans[x - i + j - y + 1];
      else
        ++ans[j - i];
    }
  for (int i = 1; i < n; ++i)
    cout << ans[i] << endl;
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>

using namespace std;

const int MAXN = 2e3 + 10;

int n, x, y;
int sol[MAXN];

int main(void) {
  scanf("%d%d%d", &n, &x, &y);
  --x;
  --y;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int d = min(abs(i - j), min(1 + abs(i - x) + abs(j - y),
                                  1 + abs(i - y) + abs(j - x)));
      sol[d]++;
    }
  }
  for (int i = 1; i < n; ++i)
    printf("%d\\n", sol[i]);
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>

using namespace std;

const int MAXN = 1e3 + 10;

int n, x, y;
int sol[MAXN];

int main(void) {
  scanf("%d%d%d", &n, &x, &y);
  --x;
  --y;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int d = min(abs(i - j), min(1 + abs(i - x) + abs(j - y),
                                  1 + abs(i - y) + abs(j - x)));
      sol[d]++;
    }
  }
  for (int i = 1; i < n; ++i)
    printf("%d\\n", sol[i]);
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x, a) memset(x, a, sizeof(x))
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod = 1000000007, N = 2e3 + 5, M = 1e5 + 5, INF = 0x3f3f3f3f;
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// head
int main(void) {
  int n, x, y;
  cin >> n >> x >> y;
  VI ans(n);
  rep(i, 1, n) {
    rep(j, i + 1, n + 1) { ++ans[min(j - i, abs(x - i) + 1 + abs(y - j))]; }
  }
  rep(i, 1, n) cout << ans[i] << '\\n';
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x, a) memset(x, a, sizeof(x))
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod = 1000000007, N = 2e3 + 5, M = 1e5 + 5, INF = 0x3f3f3f3f;
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// head
int dp[N][N];
int main(void) {
  int n, x, y;
  cin >> n >> x >> y;
  VI ans(n);
  MEM(dp, 0x3f);
  rep(i, 1, n) dp[i][i + 1] = dp[i + 1][i] = 1;
  dp[x][y] = 1;
  rep(k, 1, n + 1) rep(i, 1, n + 1) rep(j, 1, n + 1) dp[i][j] =
      min(dp[i][k] + dp[k][j], dp[i][j]);
  rep(i, 1, n + 1) {
    rep(j, i + 1, n + 1) { ++ans[dp[i][j]]; }
  }
  rep(i, 1, n) cout << ans[i] << '\\n';
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string.h>
#include <string>
#include <vector>
#define INF 100000000

const int MOD = 1e9 + 7;
typedef long long ll;
using namespace std;
const ll M = 998244353;

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


Error: TLE

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string.h>
#include <string>
#include <vector>
#define INF 100000000

const int MOD = 1e9 + 7;
typedef long long ll;
using namespace std;
const ll M = 998244353;

int main(void) {
  int n, x, y;
  cin >> n >> x >> y;
  int d[n][n];
  int count[n + 1];
  fill(count, count + n + 1, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        d[i][j] = 0;
      else if (abs(i - j) == 1)
        d[i][j] = 1;
      else
        d[i][j] = INF;
    }
  }

  d[x - 1][y - 1] = 1;
  d[y - 1][x - 1] = 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]);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      count[d[i][j]]++;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int, int>
#define fi first
#define se second
#define mex 1000005
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

int main() {
  fast int n, x, y;
  cin >> n >> x >> y;

  int a[mex];
  int b[mex];
  memset(b, 0, sizeof(b));
  memset(a, 0, sizeof(a));
  for (int i = n - 1; i >= 1; i--) {
    if (i >= y) {
      for (int j = n; j > i; j--)
        a[abs(j - i)] += 1;
    } else if (i < x) {
      for (int j = x; j > i; j--)
        a[abs(j - i)] += 1;
      for (int j = 0; j < n; j++)
        a[j + abs(x - i)] += b[j];
    } else if (i == x) {
      for (int j = n; j > x; j--) {
        int y1 = max(0, min(j - x, 1 + abs(j - y)));
        b[y1] += 1;
        a[y1] += 1;
      }
    } else {
      for (int j = n; j > i; j--) {
        int y1 = max(min(j - i, abs(x - i) + 1 + abs(j - y)), 0);
        a[y1] += 1;
      }
    }
  }
  for (int i = 1; i < n; i++)
    cout << a[i] << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int, int>
#define fi first
#define se second
#define mex 1000005
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
vector<int> adj[mex];

signed main() {
  fast int n, x, y;
  cin >> n >> x >> y;

  int a[n + 5];
  int b[n + 5];
  memset(b, 0, sizeof(b));
  memset(a, 0, sizeof(a));
  for (int i = n - 1; i >= 1; i--) {
    if (i > y) {
      for (int j = n; j > i; j--)
        a[abs(j - i)] += 1;
    } else if (i < x) {
      for (int j = x; j > i; j--)
        a[abs(j - i)] += 1;
      for (int j = 0; j < n; j++)
        a[j + abs(x - i)] += b[j];
    } else if (i == x) {
      for (int j = n; j > x; j--) {
        int y1 = max(0, min(j - x, 1 + abs(j - y)));
        b[y1] += 1;
        a[y1] += 1;
      }
    } else {
      for (int j = n; j > i; j--) {
        int y1 = max(min(j - i, abs(x - i) + 1 + abs(j - y)), 0);
        a[y1] += 1;
      }
    }
  }
  for (int i = 1; i < n; i++)
    cout << a[i] << endl;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll MAX = 100000;
int cnt[2005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  // if (x != 1 || y != n) {
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (i < x) {
        if (j <= x)
          cnt[j - i]++;
        else if (j > x && j <= y)
          cnt[min(j - i, x - i + 1 + y - j)]++;
        else
          cnt[x - i + 1 + j - y]++;
      } else if (i >= x && i <= y) {
        if (j <= y)
          cnt[min(j - i, i - x + 1 + y - j)]++;
        else
          cnt[min(j - i, i - x + 1 + j - y)]++;
      } else
        cnt[j - i]++;
  for (int i = 1; i <= n - 1; ++i)
    cout << cnt[i] << endl;
  //}
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll MAX = 100000;
int cnt[1005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  // if (x != 1 || y != n) {
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (i < x) {
        if (j <= x)
          cnt[j - i]++;
        else if (j > x && j <= y)
          cnt[min(j - i, x - i + 1 + y - j)]++;
        else
          cnt[x - i + 1 + j - y]++;
      } else if (i >= x && i <= y) {
        if (j <= y)
          cnt[min(j - i, i - x + 1 + y - j)]++;
        else
          cnt[min(j - i, i - x + 1 + j - y)]++;
      } else
        cnt[j - i]++;
  for (int i = 1; i <= n - 1; ++i)
    cout << cnt[i] << endl;
  //}
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1 << 30;
const ll MOD = 1000000007;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--, Y--;
  vll ans(N + 1, 0);
  rep(i, N) for (int j = i + 1; j < N; j++) {
    int d1 = j - i;
    int d2 = INF;
    if (i <= X && Y <= j)
      d2 = X - i + j - Y + 1;
    else if (X < i && Y <= j)
      d2 = i - X + j - Y + 1;
    else if (i <= X && j < Y)
      d2 = X - i + Y - j + 1;
    else if (X < i && j < Y)
      d2 = i - X + Y - j + 1;
    ans[min(d1, d2)]++;
  }
  for (int i = 1; i < N; i++)
    cout << ans[i] << endl;
}


Error: TLE

Fixed submission:

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

ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// =================グラフテンプレート==================

// costの部分の型は指定できます
template <typename T> struct edge {
  int from, to;
  T cost;

  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

  // 行き先を代入できる
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  // intにキャスト(?)するとかなんとか
  operator int() const { return to; }
};

template <typename T> using Edges = vector<edge<T>>;

template <typename T> using WeightedGraph = vector<Edges<T>>;

template <typename T> using Matrix = vector<vector<T>>;

using UnWeightedGraph = vector<vector<int>>;

// ===============ワーシャルフロイド法==============
// warshall_floyd(隣接行列,INF(intでもllでも))
// i-jと,i-k-jルートを比較して短い方を採用していく
// 隣接行列が穴埋めされます
template <typename T> void warshall_floyd(Matrix<T> &g, T INF) {
  for (int k = 0; k < g.size(); k++) {
    for (int i = 0; i < g.size(); i++) {
      for (int j = 0; j < g.size(); j++) {
        if (g[i][k] == INF || g[k][j] == INF)
          continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

// ====================================================================

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

  for (int i = 0; i < n; i++) {
    if (g[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }
  vll a(n + 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (g[i][j] >= INFL) {
        continue;
      } else
        a[g[i][j]]++;
    }
  }
  for (int i = 1; i < n; i++)
    cout << a[i] / 2 << endl;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#pragma warning(disable : 4996)

typedef long long ll;
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LINF 9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
#define INF2 1140000000
// const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

void solve() {
  int n, x, y;
  scanf("%d%d%d", &n, &x, &y);

  vector<int> a(n);
  int m = n - (y - x - 1);
  int i;
  for (i = 1; i <= m - 1; i++) {
    a[i] += (m - i) * 2;
  }
  a[1] -= 2;

  int mm = y - x + 1;
  for (i = 1; i <= mm - 1; i++) {
    int d = MIN(i, mm - i);
    a[d] += mm;
  }
  int j;
  for (i = 1; i <= mm - 2; i++) {
    int i2 = MIN(i, mm - i);
    for (j = 1; j <= n - y; j++) {
      a[i2 + j] += 2;
    }
    for (j = 1; j <= x - 1; j++) {
      a[i2 + j] += 2;
    }
  }

  for (i = 1; i < n; i++) {
    printf("%d\\n", a[i] / 2);
  }

  return;
}

int main(int argc, char *argv[]) {
#if 1
  solve();
#else
  int T;
  scanf("%d", &T);
  while (T--) {
    solve();
  }
#endif
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#pragma warning(disable : 4996)

typedef long long ll;
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LINF 9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
#define INF2 1140000000
// const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

ll d[2000][2000];

void solve() {
  int n, x, y;
  scanf("%d%d%d", &n, &x, &y);
  x--;
  y--;

  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = INF2;
    }
  }
  for (i = 0; i < n - 1; i++) {
    d[i][i + 1] = d[i + 1][i] = 1;
  }
  d[x][y] = d[y][x] = 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]);

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

  for (i = 1; i < n; i++) {
    printf("%d\\n", ans[i]);
  }
  return;
}

int main(int argc, char *argv[]) {
#if 1
  solve();
#else
  int T;
  scanf("%d", &T);
  while (T--) {
    solve();
  }
#endif
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#include <iomanip>
#include <math.h>
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;
}

vector<pair<int64_t, int64_t>> prime_factorize(int64_t x) {
  vector<pair<int64_t, int64_t>> p;
  for (int64_t i = 2; i * i <= x; i++) {
    int cnt = 0;
    if (x % i == 0) {
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      p.push_back(make_pair(i, cnt));
    }
  }
  if (x != 1) {
    p.push_back(make_pair(x, 1));
  }
  return p;
}

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

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#include <iomanip>
#include <math.h>
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;
}

vector<pair<int64_t, int64_t>> prime_factorize(int64_t x) {
  vector<pair<int64_t, int64_t>> p;
  for (int64_t i = 2; i * i <= x; i++) {
    int cnt = 0;
    if (x % i == 0) {
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      p.push_back(make_pair(i, cnt));
    }
  }
  if (x != 1) {
    p.push_back(make_pair(x, 1));
  }
  return p;
}
int G[3000][3000];
void warshall_floyd(int n) {
  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]);
      }
    }
  }
}

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  for (int i = 0; i < 3000; i++) {
    for (int j = 0; j < 3000; j++) {
      G[i][j] = 999999;
    }
  }
  // vector<vector<int>>G(N,vector<int>(N));
  for (int i = 0; i < N; i++) {
    G[i][i + 1] = 1;
    G[i + 1][i] = 1;
  }
  G[Y - 1][X - 1] = 1;
  G[X - 1][Y - 1] = 1;

  warshall_floyd(N);
  map<int, int> k;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      k[G[i][j]]++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << k[i] << endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

vector<bool> visited;
vector<int> dist;
vector<int> sum(2005, 0);

Graph G;

void bfs(int s) {
  queue<int> que;
  que.push(s);
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    rep(i, G[x].size()) {
      if (visited[G[x][i]])
        continue;
      visited[G[x][i]] = true;
      dist[G[x][i]] = dist[x] + 1;
      que.push(G[x][i]);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ///////////////////////////////////////
  int n, x, y;
  cin >> n >> x >> y;
  G.resize(n);
  --x;
  --y;
  G[x].push_back(y);
  G[y].push_back(x);
  rep(i, n - 1) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  rep(i, n) {
    visited.resize(n);
    dist.resize(n);
    rep(j, n) {
      visited[j] = false;
      dist[j] = 0;
    }
    visited[i] = true;
    bfs(i);
    rep(j, n) { sum[dist[j]]++; }
  }
  repi(i, 1, n) { cout << sum[i] / 2 << endl; }
  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

struct edge {
  ll to, cost;
};
typedef pair<ll, ll> P;
struct graph {
  ll V;
  vector<vector<edge>> G;
  vector<ll> d;

  graph(ll n) { init(n); }

  void init(ll n) {
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i, V) { d[i] = INF; }
  }

  void add_edge(ll s, ll t, ll cost) {
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s) {
    rep(i, V) { d[i] = INF; }
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    while (!que.empty()) {
      P p = que.top();
      que.pop();
      ll v = p.second;
      if (d[v] < p.first)
        continue;
      for (auto e : G[v]) {
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(P(d[e.to], e.to));
        }
      }
    }
  }
};

int n, x, y;
vector<int> ans;

void calc(int s) {
  graph g(n);
  rep(i, n - 1) g.add_edge(i, i + 1, 1);
  g.add_edge(x, y, 1);
  g.dijkstra(s);
  rep(k, n) { ans[g.d[k] - 1]++; }
}

int main() {
  cin >> n >> x >> y;
  x--;
  y--;
  ans.resize(n, 0);
  rep(i, n - 1) { calc(i); }
  rep(i, n - 1) cout << ans[i] << endl;
  return 0;
}