Problem p03952 (C++)

Buggy submission (status: Runtime Error):
// Feet don't fail me now
// Take me to the finish line
// Oh, my heart, it breaks every step that I take
// But I'm hoping at the gates, they'll tell me
// that IOI gold is mine
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer                                                              \
  {                                                                            \
    cout << "NO";                                                              \
    exit(0);                                                                   \
  }
#define vectors vector<vector<llong>>
#define FOR(i, start, finish, k) for (llong i = start; i <= finish; i += k)

const long long MXN = 2e5 + 10;
const long long MNN = 1e4 + 520;
const long long MOD = 10007;
const long long INF = 1e18;
const long long OO = 1e9;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, x;
bool used[MXN];
deque<int> ans;

int main() {
  ios;
  cin >> n >> x;
  if (x == 1 || x == n * 2 - 1)
    return cout << "No", 0;
  if (x == n) {
    cout << "Yes" << nl;
    for (int i = 1; i <= 2 * n - 1; i++) {
      cout << i << ' ';
    }
    return 0;
  } else if (x < n) {
    ans.push_back(x);
    ans.push_front(x - 1);
    ans.push_front(n);
    used[n] = used[x] = used[x - 1] = 1;
    for (int i = 1; i <= n; i++) {
      if (used[i] == 0) {
        ans.push_front(i);
      }
    }
    for (int i = n + 1; i <= 2 * n - 1; i++) {
      ans.push_back(i);
    }
    cout << "Yes" << nl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << ' ';
    }
  } else {
    cout << 1 / 0 + 1 << nl;
  }
}


Fixed submission:
// Feet don't fail me now
// Take me to the finish line
// Oh, my heart, it breaks every step that I take
// But I'm hoping at the gates, they'll tell me
// that IOI gold is mine
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer                                                              \
  {                                                                            \
    cout << "NO";                                                              \
    exit(0);                                                                   \
  }
#define vectors vector<vector<llong>>
#define FOR(i, start, finish, k) for (llong i = start; i <= finish; i += k)

const long long MXN = 2e5 + 10;
const long long MNN = 1e4 + 520;
const long long MOD = 10007;
const long long INF = 1e18;
const long long OO = 1e9;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, x;
bool used[MXN];
deque<int> ans;

int main() {
  ios;
  cin >> n >> x;
  if (x == 1 || x == n * 2 - 1)
    return cout << "No", 0;
  if (x == n) {
    cout << "Yes" << nl;
    for (int i = 1; i <= 2 * n - 1; i++) {
      cout << i << ' ';
    }
    return 0;
  } else if (x < n) {
    ans.push_back(x);
    ans.push_front(x - 1);
    ans.push_front(n);
    used[n] = used[x] = used[x - 1] = 1;
    for (int i = 1; i <= n; i++) {
      if (used[i] == 0) {
        ans.push_front(i);
      }
    }
    for (int i = n + 1; i <= 2 * n - 1; i++) {
      ans.push_back(i);
    }
    cout << "Yes" << nl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << ' ';
    }
  } else {
    for (int i = 1; i < n; i++)
      ans.push_back(i);
    ans.push_back(x);
    ans.push_back(x + 1);
    ans.push_back(n);
    used[x] = used[x + 1] = used[n] = 1;
    for (int i = n; i <= 2 * n - 1; i++) {
      if (used[i] == 0) {
        ans.push_back(i);
      }
    }
    cout << "Yes" << nl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << ' ';
    }
  }
}