prithivMLmods/Coder-Stat huggingface dataset:
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
deque<int> arr;
int is[100005];
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  if (x == 1 || x == 2 * n - 1) {
    puts("No");
    return 0;
  }
  arr.push_back(x);
  is[x] = 1;
  int tmp = 0;
  for (int i = n * 2 - 1; i > 0; i--) {
    if (is[i])
      continue;
    tmp++;
    arr.push_back(i);
    is[i] = 1;
    if (tmp == n - 1)
      break;
  }
  for (int i = 1; i < 2 * n; i++) {
    if (is[i])
      continue;
    arr.push_front(i);
  }
  puts("Yes");
  for (int i = 0; i < arr.size(); i++)
    printf("%d\n", arr[i]);
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
deque<int> arr;
int is[200005];
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  if (x == 1 || x == 2 * n - 1) {
    puts("No");
    return 0;
  }
  arr.push_back(x);
  is[x] = 1;
  int tmp = 0;
  for (int i = n * 2 - 1; i > 0; i--) {
    if (is[i])
      continue;
    tmp++;
    arr.push_back(i);
    is[i] = 1;
    if (tmp == n - 1)
      break;
  }
  for (int i = 1; i < 2 * n; i++) {
    if (is[i])
      continue;
    arr.push_front(i);
  }
  puts("Yes");
  for (int i = 0; i < arr.size(); i++)
    printf("%d\n", arr[i]);
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
template <class S, class T>
ostream &operator<<(ostream &o, const pair<S, T> &p) {
  return o << "(" << p.fs << "," << p.sc << ")";
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &vc) {
  o << "sz = " << vc.size() << endl << "[";
  for (const T &v : vc)
    o << v << ",";
  o << "]";
  return o;
}
int main() {
  int N, x;
  cin >> N >> x;
  if (x == 1 || x == N * 2 - 1) {
    puts("No");
    return 0;
  }
  int ans[100000];
  bool flip = 0;
  if (x > N)
    flip = 1, x = 2 * N - x;
  int M = 2 * N - 1;
  rep(i, M) ans[i] = i + 1;
  rotate(ans + x - 2, ans + x, ans + N);
  if (flip)
    rep(i, M) ans[i] = N * 2 - ans[i];
  puts("Yes");
  rep(i, M) cout << ans[i] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
template <class S, class T>
ostream &operator<<(ostream &o, const pair<S, T> &p) {
  return o << "(" << p.fs << "," << p.sc << ")";
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &vc) {
  o << "sz = " << vc.size() << endl << "[";
  for (const T &v : vc)
    o << v << ",";
  o << "]";
  return o;
}
int main() {
  int N, x;
  cin >> N >> x;
  if (x == 1 || x == N * 2 - 1) {
    puts("No");
    return 0;
  }
  int ans[300000];
  bool flip = 0;
  if (x > N)
    flip = 1, x = 2 * N - x;
  int M = 2 * N - 1;
  rep(i, M) ans[i] = i + 1;
  rotate(ans + x - 2, ans + x, ans + N);
  if (flip)
    rep(i, M) ans[i] = N * 2 - ans[i];
  puts("Yes");
  rep(i, M) cout << ans[i] << endl;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
typedef pair<double, int> Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
int n, x;
bool used[100005] = {};
int ans[200005];
int main() {
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    puts("No");
  } else {
    ans[n] = x;
    ans[n - 1] = 1;
    ans[n + 1] = 2 * n - 1;
    used[x] = used[1] = used[2 * n - 1] = 1;
    for (int i = 2; i < x && n > 2; i++) {
      if (!used[i]) {
        ans[n + 2] = i;
        used[i] = 1;
        break;
      }
    }
    for (int i = x + 1; i < 2 * n - 1 && n > 2; i++) {
      if (!used[i]) {
        ans[n - 2] = i;
        used[i] = 1;
        break;
      }
    }
    int nxt = 1;
    for (int i = 1; i <= 2 * n - 1; i++) {
      if (ans[i])
        continue;
      while (used[nxt])
        nxt++;
      ans[i] = nxt;
      used[nxt] = 1;
    }
    puts("Yes");
    for (int i = 1; i <= 2 * n - 1; i++)
      printf("%d\n", ans[i]);
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
typedef pair<double, int> Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
int n, x;
bool used[200005] = {};
int ans[200005];
int main() {
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    puts("No");
  } else {
    ans[n] = x;
    ans[n - 1] = 1;
    ans[n + 1] = 2 * n - 1;
    used[x] = used[1] = used[2 * n - 1] = 1;
    for (int i = 2; i < x && n > 2; i++) {
      if (!used[i]) {
        ans[n + 2] = i;
        used[i] = 1;
        break;
      }
    }
    for (int i = x + 1; i < 2 * n - 1 && n > 2; i++) {
      if (!used[i]) {
        ans[n - 2] = i;
        used[i] = 1;
        break;
      }
    }
    int nxt = 1;
    for (int i = 1; i <= 2 * n - 1; i++) {
      if (ans[i])
        continue;
      while (used[nxt])
        nxt++;
      ans[i] = nxt;
      used[nxt] = 1;
    }
    puts("Yes");
    for (int i = 1; i <= 2 * n - 1; i++)
      printf("%d\n", ans[i]);
  }
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int n, a[10];

int median(int x, int y, int z) {
  int w[3] = {x, y, z};
  sort(w, w + 3);
  return w[1];
}
int main() {
  int n, x;
  cin >> n >> x;
  if (x == 2 * n - 1 || x == 1) {
    puts("No");
    return 0;
  }
  for (int i = 0; i < 2 * n - 1; i++)
    a[i] = i + 1;
  if (x > n)
    rotate(a + n - 1, a + x - 1, a + 2 * n - 1);
  else if (x < n) {
    rotate(a, a + x, a + n);
  }
  puts("Yes");
  for (int i = 0; i < 2 * n - 1; i++)
    printf("%d\n", a[i]);
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int n, a[2000005];

int median(int x, int y, int z) {
  int w[3] = {x, y, z};
  sort(w, w + 3);
  return w[1];
}
int main() {
  int n, x;
  cin >> n >> x;
  if (x == 2 * n - 1 || x == 1) {
    puts("No");
    return 0;
  }
  for (int i = 0; i < 2 * n - 1; i++)
    a[i] = i + 1;
  if (x > n)
    rotate(a + n - 1, a + x - 1, a + 2 * n - 1);
  else if (x < n) {
    rotate(a, a + x, a + n);
  }
  puts("Yes");
  for (int i = 0; i < 2 * n - 1; i++)
    printf("%d\n", a[i]);
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long int ll;

#define FOR(i, n, m) for (ll i = (ll)(m); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, n, 0)
#define IREP(i, n) for (ll i = (ll)(n); i >= 0; --i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int A[100005];

int main() {
  int N, x;
  cin >> N >> x;
  if (x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  A[N - 2] = 1;
  A[N - 1] = x;
  A[N] = 2 * N - 1;

  int index = 0;
  FOR(i, 2 * N, 1) {
    if (index == N - 2) {
      index = N + 1;
    }
    if (i == 1 || i == x || i == 2 * N - 1) {
      continue;
    }
    A[index++] = i;
  }

  REP(i, 2 * N - 1) { cout << A[i] << endl; }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long int ll;

#define FOR(i, n, m) for (ll i = (ll)(m); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, n, 0)
#define IREP(i, n) for (ll i = (ll)(n); i >= 0; --i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int A[200005];

int main() {
  int N, x;
  cin >> N >> x;
  if (x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  A[N - 2] = 1;
  A[N - 1] = x;
  A[N] = 2 * N - 1;

  int index = 0;
  FOR(i, 2 * N, 1) {
    if (index == N - 2) {
      index = N + 1;
    }
    if (i == 1 || i == x || i == 2 * N - 1) {
      continue;
    }
    A[index++] = i;
  }

  REP(i, 2 * N - 1) { cout << A[i] << endl; }
  return 0;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
// IOI 2021
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << ends << H;
  debug_out(T...);
}
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef unsigned long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

bool M[N];
int A[N];

int main() {

  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int n, x;
  cin >> n >> x;
  if (x + 1 == 2 * n || x == 1)
    die("No");
  if (n == 2) {
    cout << "Yes" << endl;
    cout << 1 << ends << 2 << ends << 3 << endl;
    return 0;
  }
  if (x != 2) {
    A[n - 1] = 1;
    A[n] = 2 * n - 1;
    A[n + 1] = x;
    A[n + 2] = 2;
    M[2 * n - 1] = M[1] = M[2] = M[x] = true;
  } else {
    A[n - 1] = 2 * n - 1;
    A[n] = 1;
    A[n + 1] = 2;
    A[n + 2] = 3;
    M[2 * n - 1] = M[1] = M[2] = M[3] = true;
  }
  cout << "Yes" << endl;
  int p = 1;
  for (int i = 1; i <= 2 * n - 1; i++) {
    if (A[i])
      cout << A[i] << endl;
    else {
      while (M[p])
        p++;
      M[p] = true;
      cout << p << endl;
    }
  }

  return 0;
}


Fixed submission:
// IOI 2021
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << ends << H;
  debug_out(T...);
}
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef unsigned long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 2e5 + 5;

bool M[N];
int A[N];

int main() {

  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int n, x;
  cin >> n >> x;
  if (x + 1 == 2 * n || x == 1)
    die("No");
  if (n == 2) {
    cout << "Yes" << endl;
    cout << 1 << ends << 2 << ends << 3 << endl;
    return 0;
  }
  if (x != 2) {
    A[n - 1] = 1;
    A[n] = 2 * n - 1;
    A[n + 1] = x;
    A[n + 2] = 2;
    M[2 * n - 1] = M[1] = M[2] = M[x] = true;
  } else {
    A[n - 1] = 2 * n - 1;
    A[n] = 1;
    A[n + 1] = 2;
    A[n + 2] = 3;
    M[2 * n - 1] = M[1] = M[2] = M[3] = true;
  }
  cout << "Yes" << endl;
  int p = 1;
  for (int i = 1; i <= 2 * n - 1; i++) {
    if (A[i])
      cout << A[i] << endl;
    else {
      while (M[p])
        p++;
      M[p] = true;
      cout << p << endl;
    }
  }

  return 0;
}
Problem p03952 (C++)

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

#ifndef ONLINE_JUDGE
#define ONLINE_JUDGE
#endif

#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define pb push_back
#define mp make_pair
#define rep(i, n) for (i = 0; i < n; i++)
#define repr(i, j, n) for (i = j; i <= n; i++)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<int>> graph;
const ll maxn = (ll)1e5 + 9;
const ll mod = (ll)1e9 + 7;
// ll a[maxn];
// ll dp[1024][1024];
int a[maxn];
void swp(int i, int j);

int main() {
  std::ios::sync_with_stdio(0);
  ll i, j, k, t, q, m, l, r, n;
  cin >> n >> k;
  q = 2 * n - 1;
  if (k == 1 || k >= (q)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    repr(i, 1, q) { a[i] = i; }
    swp(n, k);
    swp(n - 1, 1);
    swp(n + 1, q);
    repr(i, 1, q) cout << a[i] << endl;
  }
}

void swp(int i, int j) {
  int temp = a[i];
  a[i] = a[j];
  a[j] = temp;
}

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

#ifndef ONLINE_JUDGE
#define ONLINE_JUDGE
#endif

#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define pb push_back
#define mp make_pair
#define rep(i, n) for (i = 0; i < n; i++)
#define repr(i, j, n) for (i = j; i <= n; i++)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<int>> graph;
const ll maxn = (ll)4e5 + 9;
const ll mod = (ll)1e9 + 7;
// ll a[maxn];
// ll dp[1024][1024];
int a[maxn];
void swp(int i, int j);

int main() {
  std::ios::sync_with_stdio(0);
  ll i, j, k, t, q, m, l, r, n;
  cin >> n >> k;
  q = 2 * n - 1;
  if (k == 1 || k >= (q)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    repr(i, 1, q) { a[i] = i; }
    swp(n, k);
    swp(n - 1, 1);
    swp(n + 1, q);
    repr(i, 1, q) cout << a[i] << endl;
  }
}

void swp(int i, int j) {
  int temp = a[i];
  a[i] = a[j];
  a[j] = temp;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-')
    ch = getchar();
  if (ch == '-')
    o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, x, st[N], top = 0;
int main() {
  cin >> n >> x;
  n = 2 * n - 1;
  if (x == 1 || x == n)
    puts("No");
  else {
    puts("Yes");
    for (int i = 1; i <= x - 2; i++)
      st[++top] = i;
    for (int i = x + 2; i <= n; i++)
      st[++top] = i;
    int mid = (n + 1) / 2;
    for (int i = 1; i <= mid - 2; i++)
      printf("%d\n", st[top--]);
    printf("%d\n%d\n%d\n", x - 1, x, x + 1);
    for (int i = mid + 2; i <= n; i++)
      printf("%d\n", st[top--]);
  }
  return 0;
}
// orzgzy
// 鸡贼明年进队超稳


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-')
    ch = getchar();
  if (ch == '-')
    o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, x, st[N], top = 0;
int main() {
  cin >> n >> x;
  n = 2 * n - 1;
  if (x == 1 || x == n)
    puts("No");
  else {
    puts("Yes");
    for (int i = 1; i <= x - 2; i++)
      st[++top] = i;
    for (int i = x + 2; i <= n; i++)
      st[++top] = i;
    int mid = (n + 1) / 2;
    for (int i = 1; i <= mid - 2; i++)
      printf("%d\n", st[top--]);
    printf("%d\n%d\n%d\n", x - 1, x, x + 1);
    for (int i = mid + 2; i <= n; i++)
      printf("%d\n", st[top--]);
  }
  return 0;
}
// orzgzy
// 鸡贼明年进队超稳
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL << 60)
#define int long long
#define ll long long
#define mod 1000000007

signed main() {

  int N, x;
  cin >> N >> x;
  bool hanten = false;
  if (x > N) {
    hanten = true;
    x = 2 * N - x;
  }
  if (x == 1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  int a[123456] = {0};
  a[N] = x;
  a[N - 1] = 1;
  for (int i = N + 1; i <= 2 * N - 1; i++) {
    a[i] = i;
  }
  for (int i = 1; i <= N - 2; i++) {
    if (i + 1 < x)
      a[i] = i + 1;
    else
      a[i] = i + 2;
  }

  if (hanten) {
    for (int i = 1; i <= 2 * N - 1; i++)
      a[i] = 2 * N - a[i];
  }
  for (int i = 1; i <= 2 * N - 1; i++)
    cout << a[i] << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL << 60)
#define int long long
#define ll long long
#define mod 1000000007

signed main() {

  int N, x;
  cin >> N >> x;
  bool hanten = false;
  if (x > N) {
    hanten = true;
    x = 2 * N - x;
  }
  if (x == 1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  int a[223456] = {0};
  a[N] = x;
  a[N - 1] = 1;
  for (int i = N + 1; i <= 2 * N - 1; i++) {
    a[i] = i;
  }
  for (int i = 1; i <= N - 2; i++) {
    if (i + 1 < x)
      a[i] = i + 1;
    else
      a[i] = i + 2;
  }

  if (hanten) {
    for (int i = 1; i <= 2 * N - 1; i++)
      a[i] = 2 * N - a[i];
  }
  for (int i = 1; i <= 2 * N - 1; i++)
    cout << a[i] << endl;

  return 0;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int a[1010];
int main() {
  int N, x;
  cin >> N >> x;
  if (N == 1) {
    cout << "Yes" << endl << 1 << endl;
    return 0;
  }
  if (x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
    return 0;
  }
  if (N == 2) {
    cout << "Yes" << endl << 1 << endl << 2 << endl << 3 << endl;
    return 0;
  }
  if (x == 2) {
    a[N - 2] = 2;
    a[N - 1] = 1;
    a[N - 3] = 3;
    a[N] = 4;
    int cnt = 5;
    for (int i = 0; i < N - 3; ++i)
      a[i] = cnt++;
    for (int i = N + 1; i < 2 * N - 1; ++i)
      a[i] = cnt++;
  } else {
    a[N - 2] = x;
    a[N - 1] = x + 1;
    a[N - 3] = 1;
    a[N] = 2;
    int cnt = 3;
    if (cnt == x)
      cnt = x + 2;
    for (int i = 0; i < N - 3; ++i) {
      a[i] = cnt;
      if (cnt == x - 1)
        cnt = x + 2;
      else
        ++cnt;
    }
    for (int i = N + 1; i < 2 * N - 1; ++i) {
      a[i] = cnt;
      if (cnt == x - 1)
        cnt = x + 2;
      else
        ++cnt;
    }
  }
  cout << "Yes" << endl;
  for (int i = 0; i < 2 * N - 1; ++i)
    cout << a[i] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int a[1010000];
int main() {
  int N, x;
  cin >> N >> x;
  if (N == 1) {
    cout << "Yes" << endl << 1 << endl;
    return 0;
  }
  if (x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
    return 0;
  }
  if (N == 2) {
    cout << "Yes" << endl << 1 << endl << 2 << endl << 3 << endl;
    return 0;
  }
  if (x == 2) {
    a[N - 2] = 2;
    a[N - 1] = 1;
    a[N - 3] = 3;
    a[N] = 4;
    int cnt = 5;
    for (int i = 0; i < N - 3; ++i)
      a[i] = cnt++;
    for (int i = N + 1; i < 2 * N - 1; ++i)
      a[i] = cnt++;
  } else {
    a[N - 2] = x;
    a[N - 1] = x + 1;
    a[N - 3] = 1;
    a[N] = 2;
    int cnt = 3;
    if (cnt == x)
      cnt = x + 2;
    for (int i = 0; i < N - 3; ++i) {
      a[i] = cnt;
      if (cnt == x - 1)
        cnt = x + 2;
      else
        ++cnt;
    }
    for (int i = N + 1; i < 2 * N - 1; ++i) {
      a[i] = cnt;
      if (cnt == x - 1)
        cnt = x + 2;
      else
        ++cnt;
    }
  }
  cout << "Yes" << endl;
  for (int i = 0; i < 2 * N - 1; ++i)
    cout << a[i] << endl;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int N;
int x;

int V[100005];

int main(void) {

  cin >> N >> x;

  bool ans;

  if (N == 2) {
    if (x == 2) {
      ans = true;
      V[1] = 1;
      V[2] = 2;
      V[3] = 3;
    } else {
      ans = false;
    }
  } else {

    if (x == 1 || x == 2 * N - 1) {
      ans = false;
    } else {
      ans = true;

      if (x == 2) {
        V[N] = x;
        V[N - 1] = 1;
        V[N + 1] = 2 * N - 1;
        V[N - 2] = 3;
        vector<int> tmp;
        for (int i = 4; i <= 2 * N - 2; i++) {
          tmp.push_back(i);
        }
        int I = 0;
        for (int i = 1; i <= 2 * N - 1; i++) {
          if (V[i] == 0) {
            V[i] = tmp[I];
            I++;
          }
        }

      } else {
        V[N] = x;
        V[N - 1] = 1;
        V[N + 1] = 2 * N - 1;
        V[N + 2] = 2;
        vector<int> tmp;
        for (int i = 3; i <= 2 * N - 2; i++) {
          if (i == x) {
            continue;
          }
          tmp.push_back(i);
        }
        int I = 0;
        for (int i = 1; i <= 2 * N - 1; i++) {
          if (V[i] == 0) {
            V[i] = tmp[I];
            I++;
          }
        }
      }
    }
  }

  if (ans) {
    cout << "Yes" << endl;
    for (int i = 1; i <= 2 * N - 1; i++) {
      cout << V[i] << endl;
    }
  } else {
    cout << "No" << endl;
  }
  // system("pause");
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int N;
int x;

int V[200015];

int main(void) {

  cin >> N >> x;

  bool ans;

  if (N == 2) {
    if (x == 2) {
      ans = true;
      V[1] = 1;
      V[2] = 2;
      V[3] = 3;
    } else {
      ans = false;
    }
  } else {

    if (x == 1 || x == 2 * N - 1) {
      ans = false;
    } else {
      ans = true;

      if (x == 2) {
        V[N] = x;
        V[N - 1] = 1;
        V[N + 1] = 2 * N - 1;
        V[N - 2] = 3;
        vector<int> tmp;
        for (int i = 4; i <= 2 * N - 2; i++) {
          tmp.push_back(i);
        }
        int I = 0;
        for (int i = 1; i <= 2 * N - 1; i++) {
          if (V[i] == 0) {
            V[i] = tmp[I];
            I++;
          }
        }

      } else {
        V[N] = x;
        V[N - 1] = 1;
        V[N + 1] = 2 * N - 1;
        V[N + 2] = 2;
        vector<int> tmp;
        for (int i = 3; i <= 2 * N - 2; i++) {
          if (i == x) {
            continue;
          }
          tmp.push_back(i);
        }
        int I = 0;
        for (int i = 1; i <= 2 * N - 1; i++) {
          if (V[i] == 0) {
            V[i] = tmp[I];
            I++;
          }
        }
      }
    }
  }

  if (ans) {
    cout << "Yes" << endl;
    for (int i = 1; i <= 2 * N - 1; i++) {
      cout << V[i] << endl;
    }
  } else {
    cout << "No" << endl;
  }
  // system("pause");
  return 0;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, x;
  cin >> N >> x;
  if (x == 1 || x == 2 * N - 1)
    cout << "No" << endl;
  else {
    vector<int> ans(2 * N - 1);
    for (int i = 0; i < 2 * N - 1; ++i)
      ans[i] = i + 1;
    swap(ans[x - 1], ans[N - 1]);
    swap(ans[N - 3], ans[0]);
    cout << "Yes" << endl;
    for (int i = 0; i < 2 * N - 1; ++i)
      cout << ans[i] << endl;
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, x;
  cin >> N >> x;
  if (x == 1 || x == 2 * N - 1)
    cout << "No" << endl;
  else {
    vector<int> ans(2 * N - 1);
    for (int i = 0; i < 2 * N - 1; ++i)
      ans[i] = i + 1;
    swap(ans[x - 1], ans[N - 1]);
    if (ans[N - 1] < ans[N - 2] && ans[N - 1] < ans[N])
      swap(ans[0], ans[N - 2]);
    else if (ans[N - 1] > ans[N - 2] && ans[N - 1] > ans[N])
      swap(ans[N], ans[2 * N - 2]);
    cout << "Yes" << endl;
    for (int i = 0; i < 2 * N - 1; ++i)
      cout << ans[i] << endl;
  }

  return 0;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int a[200001];
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  int m = 2 * n - 1;
  if (x == 1 || x == 2 * n - 1)
    printf("No\n");
  else {
    printf("Yes\n");
    a[n] = x;
    if (x <= n) {
      int d = n - x, i = 1;
      for (int j = m; j > m - d; j--, i++)
        a[i] = j;
      for (int j = 1; j < x; j++, i++)
        a[i] = j;
      i++;
      for (int j = m - d; j > x; j--, i++)
        a[i] = j;
    } else {
      int d = x - n, i = m;
      for (int j = 1; j <= d; j++, i--)
        a[i] = j;
      for (int j = m; j > x; j--, i--)
        a[i] = j;
      i--;
      for (int j = 1; j < x; j++, i--)
        a[i] = j;
    }
    for (int i = 1; i <= m; i++)
      printf("%d ", a[i]);
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int a[200001];
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  int m = 2 * n - 1;
  if (x == 1 || x == 2 * n - 1)
    printf("No\n");
  else {
    printf("Yes\n");
    a[n] = x;
    if (x <= n) {
      int d = n - x, i = 1;
      for (int j = m; j > m - d; j--, i++)
        a[i] = j;
      for (int j = 1; j < x; j++, i++)
        a[i] = j;
      i++;
      for (int j = m - d; j > x; j--, i++)
        a[i] = j;
    } else {
      int d = x - n, i = m;
      for (int j = 1; j <= d; j++, i--)
        a[i] = j;
      for (int j = m; j > x; j--, i--)
        a[i] = j;
      i--;
      for (int j = d + 1; j < x; j++, i--)
        a[i] = j;
    }
    for (int i = 1; i <= m; i++)
      printf("%d ", a[i]);
  }
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;

int hako[111111];
int main(void) {
  int n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1)
    cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    for (int i = 1; i <= n - 2; i++) {
      hako[i] = i + 2;
    }
    hako[n - 1] = 1;
    hako[n] = 2;
    for (int i = n + 1; i <= n * 2 - 1; i++) {
      hako[i] = i;
    }
    if (x != 2 && x <= n) {
      hako[n] = x;
      hako[x - 2] = 2;
    }
    if (x > n) {
      for (int i = 1; i <= 2 * n - 1; i++) {
        hako[i] = 2 * n - hako[i];
      }
      if (x != 2 * n - 2) {
        hako[n] = x;
        hako[2 * n - x - 2] = 2 * n - 2;
      }
    }

    for (int i = 1; i <= 2 * n - 1; i++) {
      cout << hako[i] << endl;
    }
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;

int hako[211111];
int main(void) {
  int n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1)
    cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    for (int i = 1; i <= n - 2; i++) {
      hako[i] = i + 2;
    }
    hako[n - 1] = 1;
    hako[n] = 2;
    for (int i = n + 1; i <= n * 2 - 1; i++) {
      hako[i] = i;
    }
    if (x != 2 && x <= n) {
      hako[n] = x;
      hako[x - 2] = 2;
    }
    if (x > n) {
      for (int i = 1; i <= 2 * n - 1; i++) {
        hako[i] = 2 * n - hako[i];
      }
      if (x != 2 * n - 2) {
        hako[n] = x;
        hako[2 * n - x - 2] = 2 * n - 2;
      }
    }

    for (int i = 1; i <= 2 * n - 1; i++) {
      cout << hako[i] << endl;
    }
  }
  return 0;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
  ll n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
  } else if (n == 1) {
    cout << "Yes" << endl;
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
  } else {
    cout << "Yes" << endl;
    vector<ll> ans(2 * n - 1);
    set<ll> s;
    if (x == 2) {
      ans[n - 2] = x + 2;
      s.insert(x + 2);
      ans[n - 1] = x;
      s.insert(x);
      ans[n] = x - 1;
      s.insert(x - 1);
      ans[n + 1] = x + 1;
      s.insert(x + 1);
    } else {
      ans[n - 2] = x - 2;
      s.insert(x - 2);
      ans[n - 1] = x;
      s.insert(x);
      ans[n] = x + 1;
      s.insert(x + 1);
      ans[n + 1] = x - 1;
      s.insert(x - 1);
    }
    ll st = 1;
    rep(i, 2 * n - 1) {
      if (ans[i] != 0)
        continue;
      while (s.find(st) != s.end())
        st++;
      ans[i] = st;
      st++;
    }
    for (auto an : ans) {
      cout << an << endl;
    }
  }
  return 0;
}

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

int main() {
  ll n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
  } else if (n == 2) {
    cout << "Yes" << endl;
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
  } else {
    cout << "Yes" << endl;
    vector<ll> ans(2 * n - 1);
    set<ll> s;
    if (x == 2) {
      ans[n - 2] = x + 2;
      s.insert(x + 2);
      ans[n - 1] = x;
      s.insert(x);
      ans[n] = x - 1;
      s.insert(x - 1);
      ans[n + 1] = x + 1;
      s.insert(x + 1);
    } else {
      ans[n - 2] = x - 2;
      s.insert(x - 2);
      ans[n - 1] = x;
      s.insert(x);
      ans[n] = x + 1;
      s.insert(x + 1);
      ans[n + 1] = x - 1;
      s.insert(x - 1);
    }
    ll st = 1;
    rep(i, 2 * n - 1) {
      if (ans[i] != 0)
        continue;
      while (s.find(st) != s.end())
        st++;
      ans[i] = st;
      st++;
    }
    for (auto an : ans) {
      cout << an << endl;
    }
  }
  return 0;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long N, x, M;
  cin >> N >> x;
  M = N * 2 - 1;
  if (x == 1 || x == M) {
    cout << "No" << endl;
    return 0;
  } else {
    cout << "Yes" << endl;
  }

  if (N == 2) {
    cout << 1 << endl << 2 << endl << 3 << endl;
  }

  vector<long long> ans(M, -1);
  vector<bool> used(M + 1, false);
  used[x] = true;

  if (x < N) {
    ans[N - 1] = x;
    ans[N] = x + 1;
    ans[N - 2] = 1;
    ans[N - 3] = x + 2;
    used[x + 1] = true;
    used[x + 2] = true;
    used[1] = true;
  } else {
    ans[N - 1] = x;
    ans[N] = x - 1;
    ans[N - 2] = M;
    ans[N - 3] = x - 2;
    used[x - 1] = true;
    used[x - 2] = true;
    used[M] = true;
  }

  long long now = 1;

  for (int i = 0; i < M; i++) {
    while (used[now]) {
      now++;
    }
    if (ans[i] != -1)
      continue;
    ans[i] = now;
    used[now] = true;
  }

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

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

int main() {
  long long N, x, M;
  cin >> N >> x;
  M = N * 2 - 1;
  if (x == 1 || x == M) {
    cout << "No" << endl;
    return 0;
  } else {
    cout << "Yes" << endl;
  }

  if (N == 2) {
    cout << 1 << endl << 2 << endl << 3 << endl;
    return 0;
  }

  vector<long long> ans(M, -1);
  vector<bool> used(M + 1, false);
  used[x] = true;

  if (x < N) {
    ans[N - 1] = x;
    ans[N] = x + 1;
    ans[N - 2] = 1;
    ans[N - 3] = x + 2;
    used[x + 1] = true;
    used[x + 2] = true;
    used[1] = true;
  } else {
    ans[N - 1] = x;
    ans[N] = x - 1;
    ans[N - 2] = M;
    ans[N - 3] = x - 2;
    used[x - 1] = true;
    used[x - 2] = true;
    used[M] = true;
  }

  long long now = 1;

  for (int i = 0; i < M; i++) {
    while (used[now]) {
      now++;
    }
    if (ans[i] != -1)
      continue;
    ans[i] = now;
    used[now] = true;
  }

  for (int i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }
}
Problem p03952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int n, x;

  std::cin >> n >> x;

  std::vector<int> v(2 * n - 1), ans;

  int center = n, val = 1;
  v[n - 1] = x;
  for (int i = center - 2; i >= 0; i--) {
    if (val == x)
      val++;
    v[i] = val;
    val++;
  }
  for (int i = 2 * n - 2; i >= center; i--) {
    if (val == x)
      val++;
    v[i] = val;
    val++;
  }
  ans = v;
  int hanni = 1;
  while ((2 * n - 1) - ((hanni - 1) * 2) != 1) {
    std::vector<int> arata = v;
    for (int i = hanni; i < v.size() - hanni; i++) {
      int a = v[i - 1], b = v[i], c = v[i + 1];
      if (a > b)
        std::swap(a, b);
      if (b > c)
        std::swap(b, c);
      if (a > b)
        std::swap(a, b);
      arata[i] = b;
    }
    hanni++;
    v = arata;
  }

  if (v[center - 1] == x) {
    std::cout << "Yes" << std::endl;
    for (int i = 0; i < v.size(); i++) {
      std::cout << ans[i] << std::endl;
    }
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

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

int main() {
  int n, x;

  std::cin >> n >> x;

  std::vector<int> v(2 * n - 1), ans;

  int center = n, val = 1;
  v[n - 1] = x;
  for (int i = center - 2; i >= 0; i--) {
    if (val == x)
      val++;
    v[i] = val;
    val++;
  }
  for (int i = 2 * n - 2; i >= center; i--) {
    if (val == x)
      val++;
    v[i] = val;
    val++;
  }
  ans = v;
  if (x != 1 && x != 2 * n - 1) {
    std::cout << "Yes" << std::endl;
    for (int i = 0; i < v.size(); i++) {
      std::cout << ans[i] << std::endl;
    }
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

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

  ll n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
  } else {
    vector<ll> ans(2 * n - 1, 0);
    set<ll> s;
    for (int i = 1; i <= 2 * n - 1; i++)
      s.insert(i);
    if (x != 2) {
      ans[n - 2] = x - 1;
      ans[n - 1] = x;
      ans[n] = x + 1;
      ans[n + 1] = x - 2;

      s.erase(x - 1);
      s.erase(x);
      s.erase(x + 1);
      s.erase(x - 2);
    } else {
      ans[n - 2] = 3;
      ans[n - 1] = 2;
      ans[n] = 1;
      ans[n + 1] = 4;

      s.erase(1);
      s.erase(2);
      s.erase(3);
      s.erase(4);
    }

    cout << "Yes" << endl;
    for (int i = 0; i < 2 * n - 1; i++) {
      if (ans[i] == 0) {
        ans[i] = *s.begin();
        s.erase(s.begin());
      }
      cout << ans[i] << endl;
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

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

  ll n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
  } else if (n == 2 && x == 2) {
    cout << "Yes" << endl;
    cout << 1 << endl << 2 << endl << 3 << endl;
  } else {
    vector<ll> ans(2 * n - 1, 0);
    set<ll> s;
    for (int i = 1; i <= 2 * n - 1; i++)
      s.insert(i);
    if (x != 2) {
      ans[n - 2] = x - 1;
      ans[n - 1] = x;
      ans[n] = x + 1;
      ans[n + 1] = x - 2;

      s.erase(x - 1);
      s.erase(x);
      s.erase(x + 1);
      s.erase(x - 2);
    } else {
      ans[n - 2] = 3;
      ans[n - 1] = 2;
      ans[n] = 1;
      ans[n + 1] = 4;

      s.erase(1);
      s.erase(2);
      s.erase(3);
      s.erase(4);
    }

    cout << "Yes" << endl;
    for (int i = 0; i < 2 * n - 1; i++) {
      if (ans[i] == 0) {
        ans[i] = *s.begin();
        s.erase(s.begin());
      }
      cout << ans[i] << endl;
    }
  }
}
Problem p03952 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all_map(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define ALL(a) (a).begin(), (a).end()

int main() {
  ll n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";

  vector<ll> ans(2 * n - 1);
  iota(ALL(ans), 1);
  if (x < n)
    rep(i, n - x) {
      ans.insert(ans.begin(), ans.back());
      ans.pop_back();
    }
  else
    rep(i, x - n) {
      ans.push_back(ans.front());
      ans.erase(ans.begin());
    }
  rep(i, 2 * n - 1) cout << ans[i] << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all_map(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define ALL(a) (a).begin(), (a).end()

int main() {
  ll n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";

  vector<ll> ans;
  if (x < n) {
    rep(i, n - x) cout << 2 * n - 1 - i << endl;
    rep(i, 2 * n - 1 - (n - x)) cout << i + 1 << endl;
  } else if (x > n) {
    for (ll i = x - n + 1; i <= 2 * n - 1; ++i)
      cout << i << endl;
    rep(i, x - n) cout << i + 1 << endl;
  } else
    rep(i, 2 * n - 1) cout << i + 1 << endl;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(), (v).end()
#define REP(i, p, n) for (int i = p; i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int, int> P;
using ll = long long;
using VI = vector<int>;

int main() {
  int n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1)
    cout << "No" << endl;
  else {
    vector<int> a(2 * n - 1);
    iota(a.begin(), a.end(), 1);
    swap(a[n - 1], a[x - 1]);
    if (a[n - 1] > a[n])
      swap(a[n], a[2 * n - 3]);
    else if (a[n - 1] < a[n - 2])
      swap(a[n - 2], a[0]);
    a[n - 3] = a[2 * n - 2];
    cout << "Yes" << endl;
    for (auto &i : a)
      cout << i << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(), (v).end()
#define REP(i, p, n) for (int i = p; i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int, int> P;
using ll = long long;
using VI = vector<int>;

int main() {
  int n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1)
    cout << "No" << endl;
  else {
    vector<int> a(2 * n - 1);
    iota(a.begin(), a.end(), 1);
    swap(a[n - 1], a[x - 1]);
    if (a[n - 1] < a[n - 2] && a[n - 1] < a[n])
      swap(a[0], a[n - 2]);
    else if (a[n - 1] > a[n - 2] && a[n - 1] > a[n])
      swap(a[n], a[2 * n - 2]);
    cout << "Yes" << endl;
    for (auto &i : a)
      cout << i << endl;
  }
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define fo(i, a, b) for (int i = (a); i < (b); i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, x, a[100100];
vector<int> v;

int main() {
  scanf("%d %d", &N, &x);
  if (x == 1 || x == 2 * N - 1)
    return puts("No"), 0;
  puts("Yes");
  a[N - 2] = 1;
  a[N - 1] = x;
  a[N] = 2 * N - 1;
  fo(i, 2, 2 * N - 1) if (i != x) v.PB(i);
  fo(i, 0, 2 * N - 1) if (i < N - 2 || i > N) a[i] = v.back(), v.pop_back();
  fo(i, 0, 2 * N - 1) printf("%d\n", a[i]);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fo(i, a, b) for (int i = (a); i < (b); i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, x, a[200200];
vector<int> v;

int main() {
  scanf("%d %d", &N, &x);
  if (x == 1 || x == 2 * N - 1)
    return puts("No"), 0;
  puts("Yes");
  a[N - 2] = 1;
  a[N - 1] = x;
  a[N] = 2 * N - 1;
  fo(i, 2, 2 * N - 1) if (i != x) v.PB(i);
  fo(i, 0, 2 * N - 1) if (i < N - 2 || i > N) a[i] = v.back(), v.pop_back();
  fo(i, 0, 2 * N - 1) printf("%d\n", a[i]);
  return 0;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF // or 0x3f3f3f3f ? -Wall
using namespace std;

template <class T> inline void read(T &x) {
  int f = 1;
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}

/*============ Header Template ============*/

const int N = 1000;

int n, k;
int p[N], t[N];
int a[N], b[N];

int solve() {
  for (int i = n - 1; i; i--) {
    for (int j = 1; j <= 2 * i - 1; j++) {
      t[1] = a[j];
      t[2] = a[j + 1];
      t[3] = a[j + 2];
      sort(t + 1, t + 3 + 1);
      b[j] = t[2];
    }
    for (int j = 1; j <= 2 * i - 1; j++)
      a[j] = b[j];
  }
  return a[1];
}

int main() {
  read(n), read(k);
  if (k == 1 || k == 2 * n - 1) {
    printf("No\n");
    return 0;
  }
  a[n] = k;
  int cur = 1;
  for (int i = n - 1; i; i--) {
    if (cur == k)
      cur++;
    a[i] = cur;
    cur++;
  }
  cur = 2 * n - 1;
  for (int i = n + 1; i <= 2 * n - 1; i++) {
    if (cur == k)
      cur--;
    a[i] = cur;
    cur--;
  }
  printf("Yes\n");
  for (int i = 1; i <= 2 * n - 1; i++)
    printf("%d\n", a[i]);
  // printf("ans = %d\n", solve());
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF // or 0x3f3f3f3f ? -Wall
using namespace std;

template <class T> inline void read(T &x) {
  int f = 1;
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}

/*============ Header Template ============*/

const int N = 200000 + 5;

int n, k;
int p[N], t[N];
int a[N], b[N];

int solve() {
  for (int i = n - 1; i; i--) {
    for (int j = 1; j <= 2 * i - 1; j++) {
      t[1] = a[j];
      t[2] = a[j + 1];
      t[3] = a[j + 2];
      sort(t + 1, t + 3 + 1);
      b[j] = t[2];
    }
    for (int j = 1; j <= 2 * i - 1; j++)
      a[j] = b[j];
  }
  return a[1];
}

int main() {
  read(n), read(k);
  if (k == 1 || k == 2 * n - 1) {
    printf("No\n");
    return 0;
  }
  a[n] = k;
  int cur = 1;
  for (int i = n - 1; i; i--) {
    if (cur == k)
      cur++;
    a[i] = cur;
    cur++;
  }
  cur = 2 * n - 1;
  for (int i = n + 1; i <= 2 * n - 1; i++) {
    if (cur == k)
      cur--;
    a[i] = cur;
    cur--;
  }
  printf("Yes\n");
  for (int i = 1; i <= 2 * n - 1; i++)
    printf("%d\n", a[i]);
  // printf("ans = %d\n", solve());
  return 0;
}
Problem p03952 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for (ll i = 0; i < n; i++)

int main() {
  ll n, x;
  cin >> n >> x;

  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
    return 0;
  }

  vector<ll> ans(2 * n - 1);
  if (x == 2) {
    ans[n - 1] = x;
    ans[n] = x - 1;
    ans[n - 2] = x + 1;
    ans[n + 1] = x + 2;

    ll t = 1;
    REP(i, n - 2) {
      if (t == x - 1) {
        t = x + 3;
      }
      ans[i] = t++;
    }
    for (ll i = n + 2; i < 2 * n - 1; i++) {
      if (t == x - 1) {
        t = x + 3;
      }
      ans[i] = t++;
    }
  } else {
    ans[n - 1] = x;
    ans[n] = x + 1;
    ans[n - 2] = x - 1;
    ans[n + 1] = x - 2;

    ll t = 1;
    REP(i, n - 2) {
      if (t == x - 2) {
        t = x + 2;
      }
      ans[i] = t++;
    }
    for (ll i = n + 2; i < 2 * n - 1; i++) {
      if (t == x - 2) {
        t = x + 2;
      }
      ans[i] = t++;
    }
  }

  cout << "Yes" << endl;
  REP(i, 2 * n - 1) { cout << ans[i] << '\n'; }
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for (ll i = 0; i < n; i++)

int main() {
  ll n, x;
  cin >> n >> x;

  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
    return 0;
  }

  vector<ll> ans(2 * n - 1);
  if (n == 2) {
    ans[0] = 1;
    ans[1] = 2;
    ans[2] = 3;
  } else if (x == 2) {
    ans[n - 1] = x;
    ans[n] = x - 1;
    ans[n - 2] = x + 1;
    ans[n + 1] = x + 2;

    ll t = 1;
    REP(i, n - 2) {
      if (t == x - 1) {
        t = x + 3;
      }
      ans[i] = t++;
    }
    for (ll i = n + 2; i < 2 * n - 1; i++) {
      if (t == x - 1) {
        t = x + 3;
      }
      ans[i] = t++;
    }
  } else {
    ans[n - 1] = x;
    ans[n] = x + 1;
    ans[n - 2] = x - 1;
    ans[n + 1] = x - 2;

    ll t = 1;
    REP(i, n - 2) {
      if (t == x - 2) {
        t = x + 2;
      }
      ans[i] = t++;
    }
    for (ll i = n + 2; i < 2 * n - 1; i++) {
      if (t == x - 2) {
        t = x + 2;
      }
      ans[i] = t++;
    }
  }

  cout << "Yes" << endl;
  REP(i, 2 * n - 1) { cout << ans[i] << '\n'; }
}