Problem p02797 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed << std::setprecision(2) << (x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...)                                                         \
  {                                                                            \
    string _s = #args;                                                         \
    replace(_s.begin(), _s.end(), ',', ' ');                                   \
    stringstream _ss(_s);                                                      \
    istream_iterator<string> _it(_ss);                                         \
    err(_it, args);                                                            \
  }
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)                                                       \
  __builtin_clzll((long long)0) - __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int
#define int long long
#define all(x) (x).begin(), (x).end()
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define sz(x) (int)((x).size())
#define fr first
#define sc second
#define pii pair<int, int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define ppc __builtin_popcount
#define ppcll __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

void faster() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
void solve() {
  int n, k, s;
  cin >> n >> k >> s;
  vi v(n);
  int arr[2] = {s / 2, s - (s / 2)};
  rep(i, 0, k + 1) v[i] = arr[i % 2];
  rep(i, k + 1, n) v[i] = arr[i % 2] + 2 + (arr[i % 2] + 2 == s);
  for (auto e : v)
    cout << e << " ";
  cout << "\n";
}
signed main() {
  faster();
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
}

Fixed submission:
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed << std::setprecision(2) << (x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...)                                                         \
  {                                                                            \
    string _s = #args;                                                         \
    replace(_s.begin(), _s.end(), ',', ' ');                                   \
    stringstream _ss(_s);                                                      \
    istream_iterator<string> _it(_ss);                                         \
    err(_it, args);                                                            \
  }
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)                                                       \
  __builtin_clzll((long long)0) - __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int
#define int long long
#define all(x) (x).begin(), (x).end()
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define sz(x) (int)((x).size())
#define fr first
#define sc second
#define pii pair<int, int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define ppc __builtin_popcount
#define ppcll __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

void faster() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
void solve() {
  int n, k, s;
  cin >> n >> k >> s;
  vi v(n);
  int arr[2] = {max(1ll, s / 2), s - (s / 2)};
  if (k == n)
    fill(all(v), s);
  else {
    rep(i, 0, s == 1 ? k : k + 1) v[i] = arr[i % 2];
    rep(i, s == 1 ? k : k + 1, n) v[i] = arr[i % 2] + 2 + (arr[i % 2] + 2 == s);
  }
  for (auto e : v)
    cout << e << " ";
  cout << "\n";
}
signed main() {
  faster();
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
}