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

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

int main() {
  int n;
  cin >> n;
  int b[n];
  vector<int> c;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    c.push_back(b[i]);
    reverse(begin(c), end(c));
  }
  for (int i = 0; i < n - 1; i++) {
    cout << c.at(i) << " ";
  }
  cout << c.at(n - 1) << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int b[n];
  deque<int> c;

  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      if (i % 2 == 0) {
        c.push_back(b[i]);
      } else
        c.push_front(b[i]);
    }
  }
  if (n % 2 == 1) {
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      if (i % 2 == 0) {
        c.push_front(b[i]);
      } else
        c.push_back(b[i]);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    cout << c.at(i) << " ";
  }
  cout << c.at(n - 1) << endl;
  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
typedef long long ll;
#define dump(x) cerr << #x << "=" << x << endl

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);

  vector<ll> b;
  for (int i = 0; i < a.size(); i++) {
    b.push_back(a.at(i));
    reverse(b.begin(), b.end());
  }

  rep(i, b.size()) cout << b.at(i) << " ";
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
typedef long long ll;
#define dump(x) cerr << #x << "=" << x << endl

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);

  vector<ll> b(n, 0);
  if (n == 1) {
    cout << a.at(0) << endl;
    return 0;
  }

  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      int tmp = n / 2;
      int tmp2 = (i + 1) / 2;
      if (i % 2 == 0) {
        b.at(tmp + tmp2) = a.at(i);
      } else {
        b.at(tmp - tmp2) = a.at(i);
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      int tmp = n / 2;
      int tmp2 = (i + 1) / 2;
      if (i % 2) {
        b.at(tmp + tmp2) = a.at(i);
      } else {
        b.at(tmp - tmp2) = a.at(i);
      }
    }
  }

  rep(i, b.size()) cout << b.at(i) << " ";
  cout << endl;
}
Problem p03673 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
  return (x + y - 1) / y;
}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
  long long int m = number1;
  long long int n = number2;

  if (number2 > number1) {
    m = number2;
    n = number1;
  }
  long long int s = -1;
  while (s != 0) {
    s = m % n;
    m = n;
    n = s;
  }
  return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
  long long int m = number1;
  long long int n = number2;
  return m / lcm(m, n) * n;
}
int main() {
  int n;
  cin >> n;
  vector<int> s;
  vector<int> b;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s.push_back(a);
  }
  for (int i = 0; i < n; i++) {
    b.push_back(s[i]);
    reverse(b.begin(), b.end());
  }
  for (int i = 0; i < n; i++) {
    cout << b[i] << " ";
  }
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
  return (x + y - 1) / y;
}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
  long long int m = number1;
  long long int n = number2;

  if (number2 > number1) {
    m = number2;
    n = number1;
  }
  long long int s = -1;
  while (s != 0) {
    s = m % n;
    m = n;
    n = s;
  }
  return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
  long long int m = number1;
  long long int n = number2;
  return m / lcm(m, n) * n;
}
int main() {
  int n;
  cin >> n;
  vector<int> s;
  vector<int> b;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s.push_back(a);
  }
  if (s.size() % 2 == 0) {
    for (int i = s.size() - 1; i >= 0; i = i - 2) {
      cout << s[i] << " ";
    }
    for (int i = 0; i < s.size(); i = i + 2) {
      cout << s[i] << " ";
    }

  } else {
    for (int i = s.size() - 1; i >= 0; i = i - 2) {
      cout << s[i] << " ";
    }
    for (int i = 1; i < s.size(); i = i + 2) {
      cout << s[i] << " ";
    }
  }
}
Problem p03673 (C++)

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

int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);

  vector<int> B;
  for (int i = 0; i < N; i++) {
    B.push_back(A.at(i));
    reverse(B.begin(), B.end());
  }

  for (int i = 0; i < N; i++)
    cout << B.at(i) << ' ';
  cout << endl;
}

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

int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);

  vector<int> B;
  for (int i = 0; i < N; i++) {
    if (N % 2 == 0 && i % 2 == 0)
      B.push_back(A.at(i));
    else if (N % 2 == 0 && i % 2 == 1)
      B.insert(B.begin(), A.at(i));
    if (N % 2 == 1 && i % 2 == 0)
      B.insert(B.begin(), A.at(i));
    else if (N % 2 == 1 && i % 2 == 1)
      B.push_back(A.at(i));
  }

  for (int i = 0; i < N; i++)
    cout << B.at(i) << ' ';
  cout << endl;
}
Problem p03673 (C++)

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

#define Komachi is retarded
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define bcnt __builtin_popcount
#define clz __builtin_clz
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define LB lower_bound
#define UB upper_bound
#define IN insert
#define lp (p << 1)
#define rp (p << 1 | 1)
#define lson l, mid, lp
#define rson mid + 1, r, rp
#define LL long long
#define uLL unsigned long long
#define DB double
#define INF 1000000000
#define EPS 1e-6
#define debug(a, p) cerr << a << p;
#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; i++)
#define DREP(i, a, b) for (int i = (a), i##_end_ = (b); i > i##_end_; i--)

template <typename T> inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T> inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}

#define M 500007

int n, A[M], a, l = 25000, r = 24999;
int main() {
  scanf("%d", &n);
  REP(i, 0, n) {
    scanf("%d", &a);
    if (i & 1)
      A[--l] = a;
    else
      A[++r] = a;
  }
  if (n & 1)
    DREP(i, r, l - 1) printf("%d ", A[i]);
  else
    REP(i, l, r + 1) printf("%d ", A[i]);
  return 0;
}

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

#define Komachi is retarded
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define bcnt __builtin_popcount
#define clz __builtin_clz
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define LB lower_bound
#define UB upper_bound
#define IN insert
#define lp (p << 1)
#define rp (p << 1 | 1)
#define lson l, mid, lp
#define rson mid + 1, r, rp
#define LL long long
#define uLL unsigned long long
#define DB double
#define INF 1000000000
#define EPS 1e-6
#define debug(a, p) cerr << a << p;
#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; i++)
#define DREP(i, a, b) for (int i = (a), i##_end_ = (b); i > i##_end_; i--)

template <typename T> inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T> inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}

#define M 500007

int n, A[M << 1], a, l = M, r = M - 1;
int main() {
  scanf("%d", &n);
  REP(i, 0, n) {
    scanf("%d", &a);
    if (i & 1)
      A[--l] = a;
    else
      A[++r] = a;
  }
  if (n & 1)
    DREP(i, r, l - 1) printf("%d ", A[i]);
  else
    REP(i, l, r + 1) printf("%d ", A[i]);
  return 0;
}
Problem p03673 (C++)

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

const int MAXN = 1e5 + 10;
int a[MAXN];

int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int index = n - 1;
  while (index >= 0) {
    printf("%d ", a[index]);
    index -= 2;
  }
  if (index == -1)
    index = 0;
  else
    index = 1;
  while (index < n) {
    printf("%d ", a[index]);
    index += 2;
  }
  printf("\n");
  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;

const int MAXN = 2e5 + 10;
int a[MAXN];

int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int index = n - 1;
  while (index >= 0) {
    printf("%d ", a[index]);
    index -= 2;
  }
  if (index == -1)
    index = 0;
  else
    index = 1;
  while (index < n) {
    printf("%d ", a[index]);
    index += 2;
  }
  printf("\n");
  return 0;
}
Problem p03673 (C++)

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

typedef long long int ll;
typedef pair<ll, ll> pll;

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

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main() {
  int N;
  cin >> N;
  REP(i, N) { cin >> A[i]; }
  if (N % 2 == 1) {
    for (int i = N - 1; i >= 0; i -= 2) {
      cout << A[i] << " ";
    }
    for (int i = 1; i < N; i += 2) {
      cout << A[i] << " ";
    }
  } else {
    for (int i = N - 1; i >= 0; i -= 2) {
      cout << A[i] << " ";
    }
    for (int i = 0; i < N; i += 2) {
      cout << A[i] << " ";
    }
  }
  cout << endl;

  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

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

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[200005];

int main() {
  int N;
  cin >> N;
  REP(i, N) { cin >> A[i]; }
  if (N % 2 == 1) {
    for (int i = N - 1; i >= 0; i -= 2) {
      cout << A[i] << " ";
    }
    for (int i = 1; i < N; i += 2) {
      cout << A[i] << " ";
    }
  } else {
    for (int i = N - 1; i >= 0; i -= 2) {
      cout << A[i] << " ";
    }
    for (int i = 0; i < N; i += 2) {
      cout << A[i] << " ";
    }
  }
  cout << endl;

  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define ll long long
#define sz 205

using namespace std;

int main() {
  ll n, crr[sz], arr[sz], brr[sz];

  scanf("%lld", &n);

  for (ll i = 1; i <= n; i++) {
    scanf("%lld", &crr[i]);
  }

  ll m = n, j = 0, k = 0;

  for (ll i = 1; i <= n; i++) {
    if (i % 2 != 0) {
      arr[j++] = crr[m];
    }

    else {
      brr[k++] = crr[m];
    }

    m--;
  }

  for (ll i = 0; i < j; i++) {
    printf("%lld ", arr[i]);
  }

  for (ll i = k - 1; i >= 0; i--) {
    printf("%lld ", brr[i]);
  }

  printf("\n");

  return (0);
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define ll long long
#define sz 200005

using namespace std;

int main() {
  ll n, crr[sz], arr[sz], brr[sz];

  scanf("%lld", &n);

  for (ll i = 1; i <= n; i++) {
    scanf("%lld", &crr[i]);
  }

  ll m = n, j = 0, k = 0;

  for (ll i = 1; i <= n; i++) {
    if (i % 2 != 0) {
      arr[j++] = crr[m];
    }

    else {
      brr[k++] = crr[m];
    }

    m--;
  }

  for (ll i = 0; i < j; i++) {
    printf("%lld ", arr[i]);
  }

  for (ll i = k - 1; i >= 0; i--) {
    printf("%lld ", brr[i]);
  }

  printf("\n");

  return (0);
}
Problem p03673 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#define MAXNUM 200000

int lower = 0;
int upper = 0;
int stack[MAXNUM] = {0};
char reverse = 'T';

void push(int);

int main(void) {
  int n;
  int i, j;
  int a[MAXNUM] = {0};

  scanf("%d", &n);
  scanf("%d", &a[0]);

  if (n != 1) {
    for (i = 1; i < n; i++) {
      scanf(" %d", &a[i]);
    }

    for (i = 0; i < n; i++) {
      push(a[i]);
    }

    if (reverse == 'T') {
      for (i = (MAXNUM / 2) + upper; i > (MAXNUM / 2) - lower; i--) {
        printf("%d ", stack[i]);
      }
      printf("%d", stack[i]);
    } else {
      for (i = (MAXNUM / 2) - lower; i < (MAXNUM / 2) + upper; i++) {
        printf("%d ", stack[i]);
      }
      printf("%d", stack[i]);
    }
  } else {
    for (i = 0; i < n - 1; i++) {
      printf("%d ", a[i]);
    }
    printf("%d", a[n - 1]);
  }

  return 0;
}

void push(int num) {
  if (reverse == 'T') {
    if (lower == 0 && upper == 0) {
      stack[MAXNUM / 2] = num;
    } else {
      lower++;
      stack[(MAXNUM / 2) - lower] = num;
    }
    reverse = 'F';
  } else {
    upper++;
    stack[(MAXNUM / 2) + upper] = num;
    reverse = 'T';
  }
}

Fixed submission:
#include <stdio.h>
#define MAXNUM 200002

int lower = 0;
int upper = 0;
int stack[MAXNUM] = {0};
char reverse = 'T';

void push(int);

int main(void) {
  int n;
  int i, j;
  int a[MAXNUM] = {0};

  scanf("%d", &n);
  scanf("%d", &a[0]);

  if (n != 1) {
    for (i = 1; i < n; i++) {
      scanf(" %d", &a[i]);
    }

    for (i = 0; i < n; i++) {
      push(a[i]);
    }

    if (reverse == 'T') {
      for (i = (MAXNUM / 2) + upper; i > (MAXNUM / 2) - lower; i--) {
        printf("%d ", stack[i]);
      }
      printf("%d", stack[i]);
    } else {
      for (i = (MAXNUM / 2) - lower; i < (MAXNUM / 2) + upper; i++) {
        printf("%d ", stack[i]);
      }
      printf("%d", stack[i]);
    }
  } else {
    for (i = 0; i < n - 1; i++) {
      printf("%d ", a[i]);
    }
    printf("%d", a[n - 1]);
  }

  return 0;
}

void push(int num) {
  if (reverse == 'T') {
    if (lower == 0 && upper == 0) {
      stack[MAXNUM / 2] = num;
    } else {
      lower++;
      stack[(MAXNUM / 2) - lower] = num;
    }
    reverse = 'F';
  } else {
    upper++;
    stack[(MAXNUM / 2) + upper] = num;
    reverse = 'T';
  }
}
Problem p03673 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, x, n) for (int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll, ll>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void) {
  ll n;
  cin >> n;
  vector<ll> a(n), b;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    b.push_back(a[i]);
    reverse(all(b));
  }
  rep(i, n) {
    cout << b[i];
    if (i != n - 1)
      cout << ' ';
    else
      cout << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, x, n) for (int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll, ll>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void) {
  ll n;
  cin >> n;
  vector<ll> a(n), b;
  rep(i, n) cin >> a[i];
  if (n % 2) {
    ll tmp = n - 1;
    while (tmp >= 0) {
      b.push_back(a[tmp]);
      tmp -= 2;
    }
    ll tmp2 = 1;
    while (tmp2 <= n - 2) {
      b.push_back(a[tmp2]);
      tmp2 += 2;
    }
  } else {
    ll tmp = n - 1;
    while (tmp >= 1) {
      b.push_back(a[tmp]);
      tmp -= 2;
    }
    ll tmp2 = 0;
    while (tmp2 <= n - 2) {
      b.push_back(a[tmp2]);
      tmp2 += 2;
    }
  }
  rep(i, n) {
    cout << b[i];
    if (i != n - 1)
      cout << ' ';
    else
      cout << endl;
  }
  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define INF 1000000007
using P = pair<int, int>;
using ll = long long;
int main() {
  int n;
  cin >> n;
  int a[114514];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  if (n % 2 == 1) {
    for (int i = n / 2 * 2; i >= 0; i -= 2)
      cout << a[i] << " ";
    for (int i = 1; i < n; i += 2)
      cout << a[i] << " ";
    cout << endl;
  } else {
    for (int i = n - 1; i >= 0; i -= 2)
      cout << a[i] << " ";
    for (int i = 0; i < n; i += 2)
      cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define INF 1000000007
using P = pair<int, int>;
using ll = long long;
int main() {
  int n;
  cin >> n;
  int a[214514];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  if (n % 2 == 1) {
    for (int i = n / 2 * 2; i >= 0; i -= 2)
      cout << a[i] << " ";
    for (int i = 1; i < n; i += 2)
      cout << a[i] << " ";
    cout << endl;
  } else {
    for (int i = n - 1; i >= 0; i -= 2)
      cout << a[i] << " ";
    for (int i = 0; i < n; i += 2)
      cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}
Problem p03673 (C++)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
  fastio() {
    ios::sync_with_stdio(false);
    cout << setprecision(10) << fixed;
    cin.tie(0);
  }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n;
int a[N];
int b[N];

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int l = 0, r = n - 1;
  int k = 1;
  for (int i = n - 1; i >= 0; --i) {
    if (k) {
      b[l++] = a[i];
    } else {
      b[r--] = a[i];
    }
    k = 1 - k;
  }
  for (int i = 0; i < n; ++i) {
    cout << b[i] << ' ';
  }
  cout << endl;
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
  fastio() {
    ios::sync_with_stdio(false);
    cout << setprecision(10) << fixed;
    cin.tie(0);
  }
};

fastio _fast_io;

const int N = 2e5 + 5;
int n;
int a[N];
int b[N];

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int l = 0, r = n - 1;
  int k = 1;
  for (int i = n - 1; i >= 0; --i) {
    if (k) {
      b[l++] = a[i];
    } else {
      b[r--] = a[i];
    }
    k = 1 - k;
  }
  for (int i = 0; i < n; ++i) {
    cout << b[i] << ' ';
  }
  cout << endl;
  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

  int N;
  cin >> N;
  int A[100000];
  rep(i, N) cin >> A[i];

  if (N % 2) {
    rep(i, N / 2) { cosp(A[N - 1 - 2 * i]); }
    cosp(A[0]);
    rep(i, N / 2) { cosp(A[1 + 2 * i]); }
  } else {
    rep(i, N / 2) { cosp(A[N - 1 - 2 * i]); }
    rep(i, N / 2) { cosp(A[2 * i]); }
  }
  cout << endl;

  Would you please return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

  int N;
  cin >> N;
  int A[200000];
  rep(i, N) cin >> A[i];

  if (N % 2) {
    rep(i, N / 2) { cosp(A[N - 1 - 2 * i]); }
    cosp(A[0]);
    rep(i, N / 2) { cosp(A[1 + 2 * i]); }
  } else {
    rep(i, N / 2) { cosp(A[N - 1 - 2 * i]); }
    rep(i, N / 2) { cosp(A[2 * i]); }
  }
  cout << endl;

  Would you please return 0;
}
Problem p03673 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> a(n), b(0);
  rep(i, n) { cin >> a.at(i); }
  rep(i, n) {
    b.push_back(a.at(i));
    reverse(b.begin(), b.end());
  }
  rep(i, n) { cout << b.at(i) << " "; }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> a(n), b(0);
  rep(i, n) { cin >> a.at(i); }
  if (n % 2 == 0) {
    for (int i = n - 1; i > 0; i -= 2) {
      b.push_back(a.at(i));
    }
    for (int i = 0; i < n - 1; i += 2) {
      b.push_back(a.at(i));
    }
  } else {
    for (int i = n - 1; i >= 0; i -= 2) {
      b.push_back(a.at(i));
    }
    for (int i = 1; i < n - 1; i += 2) {
      b.push_back(a.at(i));
    }
  }
  rep(i, n) { cout << b.at(i) << " "; }
}
Problem p03673 (C++)

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

int main() {
  int a[110000], b[110000];
  memset(b, 0, sizeof(b));
  int n, pp;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i % 2 == 0 && n % 2 == 0) {
      b[(n - i + 1) / 2 + 1] = a[i];
    } else if (i % 2 == 0 && n % 2 != 0) {
      b[(n + i + 1) / 2] = a[i];
    } else if (i % 2 == 1 && n % 2 == 1) {
      b[(n - i + 2) / 2] = a[i];
    } else {
      b[(n + i + 2) / 2] = a[i];
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    printf("%d ", b[i]);
  }
  printf("%d\n", b[n]);
  //  10 1 2 3 4 5 6 7 8 9 10
  return 0;
}


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

int main() {
  int a[210000], b[210000];
  int n, pp;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i % 2 == 0 && n % 2 == 0) {
      b[(n - i + 1) / 2 + 1] = a[i];
    } else if (i % 2 == 0 && n % 2 != 0) {
      b[(n + i + 1) / 2] = a[i];
    } else if (i % 2 == 1 && n % 2 == 1) {
      b[(n - i + 2) / 2] = a[i];
    } else {
      b[(n + i + 2) / 2] = a[i];
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    printf("%d ", b[i]);
  }
  printf("%d\n", b[n]);
  //  10 1 2 3 4 5 6 7 8 9 10
  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<ll> b;
  for (ll i = 0; i < n; i++) {
    b.push_back(a[i]);
    reverse(b.begin(), b.end());
  }
  for (ll i = 0; i < n; i++) {
    cout << b[i] << " ";
  }
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  deque<ll> b;
  if (n % 2 == 0) {
    for (ll i = 0; i < n; i++) {
      if (i % 2 == 0) {
        b.push_back(a[i]);
      } else {
        b.push_front(a[i]);
      }
    }
  } else {
    for (ll i = 0; i < n; i++) {
      if (i % 2 == 1) {
        b.push_back(a[i]);
      } else {
        b.push_front(a[i]);
      }
    }
  }
  for (ll i = 0; i < n; i++) {
    cout << b[i] << " ";
  }
  cout << endl;
}
Problem p03673 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  int n, a[n + 1], res[n + 1];
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  int t = n;
  if (n % 2)
    t = n - 1;
  for (int i = 1; i <= t / 2; i++) {
    res[i] = a[t - 2 * (i - 1)];
    res[t / 2 + i] = a[2 * i - 1];
  }
  if (n % 2 == 0) {
    for (int i = 1; i <= n; i++)
      cout << res[i] << " ";
  } else {
    cout << a[n] << " ";
    for (int i = n - 1; i >= 1; i--)
      cout << res[i] << " ";
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll int n, a[1000000], res[1000000];
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  int t = n;
  if (n % 2)
    t = n - 1;
  for (int i = 1; i <= t / 2; i++) {
    res[i] = a[t - 2 * (i - 1)];
    res[t / 2 + i] = a[2 * i - 1];
  }
  if (n % 2 == 0) {
    for (int i = 1; i <= n; i++)
      cout << res[i] << " ";
  } else {
    cout << a[n] << " ";
    for (int i = n - 1; i >= 1; i--)
      cout << res[i] << " ";
  }
}
Problem p03673 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;

int gint() {
  char c;
  int f = 1;
  while (c = getchar(), c < 48 || c > 57)
    if (c == '-')
      f = -1;
  int x = 0;
  for (; c > 47 && c < 58; c = getchar()) {
    x = x * 10 + c - 48;
  }
  return x * f;
}

#define max_N 100005

int n, a[max_N], b[max_N];

int main() {
  n = gint();
  for (int i = 1, j = 0, k = n + 1; i <= n; ++i) {
    a[i] = gint();
    if (i & 1)
      b[++j] = n - i + 1;
    else
      b[--k] = n - i + 1;
  }
  for (int i = 1; i <= n; ++i)
    printf("%d%c", a[b[i]], i == n ? '\n' : ' ');
  return 0;
}


Fixed submission:
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;

int gint() {
  char c;
  int f = 1;
  while (c = getchar(), c < 48 || c > 57)
    if (c == '-')
      f = -1;
  int x = 0;
  for (; c > 47 && c < 58; c = getchar()) {
    x = x * 10 + c - 48;
  }
  return x * f;
}

#define max_N 200005

int n, a[max_N], b[max_N];

int main() {
  n = gint();
  for (int i = 1, j = 0, k = n + 1; i <= n; ++i) {
    a[i] = gint();
    if (i & 1)
      b[++j] = n - i + 1;
    else
      b[--k] = n - i + 1;
  }
  for (int i = 1; i <= n; ++i)
    printf("%d%c", a[b[i]], i == n ? '\n' : ' ');
  return 0;
}
Problem p03673 (C++)

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

int main() {
  int n;
  cin >> n;

  list<int> li;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    li.push_back(x);
    reverse(li.begin(), li.end());
  }

  vector<int> v;
  for (int x : li) {
    v.push_back(x);
  }

  cout << v[0];
  for (int i = 1; i < n; i++) {
    cout << " " << v[i];
  }
  cout << endl;

  return 0;
}

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

int main() {
  int n;
  cin >> n;

  list<int> li;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (i % 2 == 0) {
      li.push_back(x);
    } else {
      li.push_front(x);
    }
  }

  if (n & 1) {
    reverse(li.begin(), li.end());
  }

  vector<int> v;
  for (int x : li) {
    v.push_back(x);
  }

  cout << v[0];
  for (int i = 1; i < n; i++) {
    cout << " " << v[i];
  }
  cout << endl;

  return 0;
}
Problem p03673 (C++)

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

#define int long long
#define MAX 21000

int n;
int a[MAX];
deque<int> d;

signed main() {

  cin >> n;

  for (int i = 0, f = !(n % 2); i < n; i++) {
    cin >> a[i];
    if (f == 0) {
      d.push_front(a[i]);
      f = 1;
    } else {
      d.push_back(a[i]);
      f = 0;
    }
  }

  for (int i = 0; i < n; i++) {
    if (i)
      cout << " ";
    cout << d[i];
  }
  cout << endl;

  return 0;
}


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

#define int long long
#define MAX 210000

int n;
int a[MAX];
deque<int> d;

signed main() {

  cin >> n;

  for (int i = 0, f = !(n % 2); i < n; i++) {
    cin >> a[i];
    if (f == 0) {
      d.push_front(a[i]);
      f = 1;
    } else {
      d.push_back(a[i]);
      f = 0;
    }
  }

  for (int i = 0; i < n; i++) {
    if (i)
      cout << " ";
    cout << d[i];
  }
  cout << endl;

  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  int n;
  cin >> n;
  vector<ll> b;
  ll temp;
  cin >> temp;
  b.push_back(temp);
  rep(i, n - 1) {
    cin >> temp;
    b.push_back(temp);
    reverse(b.begin(), b.end());
  }

  rep(i, n) {
    if (i != 0)
      printf(" ");
    printf("%lld", b[i]);
  }

  printf("\n");

  return 0;
}

Fixed submission:
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) { cin >> a[i]; }

  int l = 0;
  int r = n - 1;
  bool useL = true;
  for (int i = n - 1; i >= 0; --i) {
    if (useL) {
      b[l] = a[i];
      l++;
      useL = false;
    } else {
      b[r] = a[i];
      r--;
      useL = true;
    }
  }

  rep(i, n) {
    if (i != 0)
      printf(" ");
    printf("%lld", b[i]);
  }

  printf("\n");

  return 0;
}
Problem p03673 (C++)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>>
    vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

  ll N;
  cin >> N;

  vector<ll> a(N);
  REP(i, N) { cin >> a.at(i); }

  vector<ll> b;

  REP(i, N) {
    b.push_back(a.at(i));
    reverse(b.begin(), b.end());
  }

  REP(i, N) { cout << b.at(i) << " "; }
  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>>
    vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

  ll N;
  cin >> N;

  vector<ll> a(N);
  REP(i, N) { cin >> a.at(i); }

  deque<ll> b;
  if (N % 2 == 0) {
    REP(i, N) {
      if (i % 2 == 0) {
        b.push_back(a.at(i));
      } else {
        b.push_front(a.at(i));
      }
    }
  } else {
    REP(i, N) {
      if (i % 2 == 0) {
        b.push_front(a.at(i));
      } else {
        b.push_back(a.at(i));
      }
    }
  }

  REP(i, N) { cout << b.at(i) << " "; }
  return 0;
}
Problem p03673 (C++)

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

int main() {

  int n;
  int a[100000];
  int ans[100000];

  cin >> n;
  for (int i = 1; i <= n; i++) {

    cin >> a[i];
  }

  if (n % 2 == 0) {

    for (int i = 1; i <= n; i += 2) {

      cout << a[n + 1 - i] << " ";
    }
    for (int i = 1; i <= n; i += 2) {

      cout << a[i] << " ";
    }

  } else {

    for (int i = 1; i <= n; i += 2) {

      cout << a[n + 1 - i] << " ";
    }
    for (int i = 2; i <= n; i += 2) {

      cout << a[i] << " ";
    }
  }

  cout << endl;

  return 0;
}

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

int main() {

  int n;
  int a[200000];
  int ans[200000];

  cin >> n;
  for (int i = 1; i <= n; i++) {

    cin >> a[i];
  }

  if (n % 2 == 0) {

    for (int i = 1; i <= n; i += 2) {

      cout << a[n + 1 - i] << " ";
    }
    for (int i = 1; i <= n; i += 2) {

      cout << a[i] << " ";
    }

  } else {

    for (int i = 1; i <= n; i += 2) {

      cout << a[n + 1 - i] << " ";
    }
    for (int i = 2; i <= n; i += 2) {

      cout << a[i] << " ";
    }
  }

  cout << endl;

  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std;
int main(void) {
  int i, n, p1, p2, a[100000], b[100000];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  p1 = (n - 1) / 2;
  p2 = p1;
  b[p1] = a[0];
  p1++;
  p2--;
  for (i = 1; i < n; i++) {
    if (i % 2 == 1) {
      b[p1] = a[i];
      p1++;
    } else {
      b[p2] = a[i];
      p2--;
    }
  }
  if (n % 2 == 1) {
    printf("%d", b[0]);
    for (i = 1; i < n; i++) {
      printf(" %d", b[i]);
    }
    printf("\n");
  } else {
    printf("%d", b[n - 1]);
    for (i = n - 2; i >= 0; i--) {
      printf(" %d", b[i]);
    }
    printf("\n");
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std;
int main(void) {
  int i, n, p1, p2, a[200000], b[200000];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  p1 = (n - 1) / 2;
  p2 = p1;
  b[p1] = a[0];
  p1++;
  p2--;
  for (i = 1; i < n; i++) {
    if (i % 2 == 1) {
      b[p1] = a[i];
      p1++;
    } else {
      b[p2] = a[i];
      p2--;
    }
  }
  if (n % 2 == 1) {
    printf("%d", b[0]);
    for (i = 1; i < n; i++) {
      printf(" %d", b[i]);
    }
    printf("\n");
  } else {
    printf("%d", b[n - 1]);
    for (i = n - 2; i >= 0; i--) {
      printf(" %d", b[i]);
    }
    printf("\n");
  }

  return 0;
}
Problem p03673 (C++)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<int> b;
  for (int i = 0; i < n; i++) {
    b.push_back(a[i]);
    reverse(b.begin(), b.end());
  }
  for (int i = 0; i < n - 1; i++) {
    cout << b[i] << " ";
  }
  cout << b[n - 1] << endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<int> b(n);
  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0)
        b[n / 2 + i / 2] = a[i];
      else
        b[n / 2 - (i + 1) / 2] = a[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0)
        b[n / 2 - i / 2] = a[i];
      else
        b[n / 2 + (i + 1) / 2] = a[i];
    }
  }
  for (int i = 0; i < n - 1; i++) {
    cout << b[i] << " ";
  }
  cout << b[n - 1] << endl;
}
Problem p03673 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []
for p in a:
    b.append(p)
    b.reverse()
for p in b:
    print(str(p) + " ", end="")
print()


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
if n % 2:
    for i in range(n // 2 + 1):
        print(str(a[n - 1 - 2 * i]) + " ", end="")
    for i in range(n // 2):
        print(str(a[1 + 2 * i]) + " ", end="")
    print()
else:
    for i in range(n // 2):
        print(str(a[n - 1 - 2 * i]) + " ", end="")
    for i in range(n // 2):
        print(str(a[2 * i]) + " ", end="")
    print()
Problem p03673 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
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; }
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do
    putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {
  putchar('0'), putchar('b'), printb(v), putchar('\n');
}
#define ALL(W) (W).begin(), (W).end()

signed main() {
  int N;
  cin >> N;
  vector<int> a;
  rep(i, N) {
    int t;
    cin >> t;
    if (i % 2 == 0)
      a.push_back(t);
    else
      a.insert(a.begin(), t);
  }
  if (N % 2 == 0) {
    rep(i, N - 1) cout << a[i] << " ";
    cout << a[N - 1] << endl;
  } else {
    for (int i = N - 1; i > 0; i--)
      cout << a[i] << " ";
    cout << a[0] << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
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; }
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do
    putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {
  putchar('0'), putchar('b'), printb(v), putchar('\n');
}
#define ALL(W) (W).begin(), (W).end()

signed main() {
  int N;
  cin >> N;
  int a[N] = {};
  rep(i, N) cin >> a[i];
  for (int i = N - 1; i >= 0; i -= 2)
    cout << a[i] << " ";
  int g;
  if (N % 2 == 1)
    g = 1;
  else
    g = 0;
  for (int i = g; i < N; i += 2) {
    if (i == N - 2 || i == N - 1) {
      cout << a[i] << endl;
      break;
    }
    cout << a[i] << " ";
  }
  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int a[512345];
int b[212345];
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  int left = 212345, right = left + 1;
  for (int i = 0; i < N; i++) {
    if (i % 2 == (N - 1) % 2) {
      a[left--] = b[i];
    } else {
      a[right++] = b[i];
    }
  }

  for (int i = left + 1; i < right; i++) {
    if (i != left + 1) {
      cout << " ";
    }
    cout << a[i];
  }
  cout << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int a[512345];
int b[212345];
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  int left = 212345, right = left + 1;
  for (int i = 0; i < N; i++) {
    if (i % 2 == (N - 1) % 2) {
      a[left--] = b[i];
    } else {
      a[right++] = b[i];
    }
  }

  for (int i = left + 1; i < right; i++) {
    if (i != left + 1) {
      cout << " ";
    }
    cout << a[i];
  }
  cout << endl;
  return 0;
}
Problem p03673 (C++)

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

#define rep(i, j, k) for (int i = (int)j; i < (int)k; ++i)
#define sz(x) ((int)(x).size())
#define ll long long
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define zero(x) memset((x), (0), sizeof(x))
#define zerox(x, y) memset((x), (y), sizeof(x))

using namespace std;
const int N = 1e5 + 7;

int a[N], b[N];
int n;

int main() {
#ifdef PIT
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
#endif // PIT

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, 1, 1 + n) cin >> a[i];

  int i, t = 1;
  for (i = n; i > 0; i -= 2)
    b[t++] = a[i];
  i = (n & 1) ? i + 3 : i + 1;
  for (; i <= n; i += 2)
    b[t++] = a[i];
  cout << b[1];
  for (int i = 2; i <= n; ++i)
    cout << " " << b[i];
  cout << endl;

#ifdef PIT
  flush(cout);
  cerr << endl << "Time: " << (clock() / double(CLOCKS_PER_SEC)) << endl;
#endif // PIT
  return 0;
}


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

#define rep(i, j, k) for (int i = (int)j; i < (int)k; ++i)
#define sz(x) ((int)(x).size())
#define ll long long
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define zero(x) memset((x), (0), sizeof(x))
#define zerox(x, y) memset((x), (y), sizeof(x))

using namespace std;
const int N = 2e5 + 7;

int a[N], b[N];
int n;

int main() {
#ifdef PIT
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
#endif // PIT

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, 1, 1 + n) cin >> a[i];

  int i, t = 1;
  for (i = n; i > 0; i -= 2)
    b[t++] = a[i];
  i = (n & 1) ? i + 3 : i + 1;
  for (; i <= n; i += 2)
    b[t++] = a[i];
  cout << b[1];
  for (int i = 2; i <= n; ++i)
    cout << " " << b[i];
  cout << endl;

#ifdef PIT
  flush(cout);
  cerr << endl << "Time: " << (clock() / double(CLOCKS_PER_SEC)) << endl;
#endif // PIT
  return 0;
}
Problem p03673 (C++)

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

int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];
  rep(i, n) reverse(a, a + i + 1);

  rep(i, n) {
    cout << a[i];
    if (i == n - 1)
      cout << endl;
    else
      cout << ' ';
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<ll> a;

  rep(i, n) {
    ll x;
    cin >> x;
    if (i % 2 == 0)
      a.push_back(x);
    else
      a.insert(a.begin(), x);
  }
  if (n % 2 == 1)
    reverse(a.begin(), a.end());

  rep(i, n) {
    cout << a[i];
    if (i == n - 1)
      cout << endl;
    else
      cout << ' ';
  }
  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <climits>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rrep(f, i, n) for (int(i) = 0; (i) < (f); (i)++)
#define FIND(v, k) find((v).begin(), (v).end(), k)
#define mset(a, x) memset(a, x, sizeof(a))

#define MAX 101
#define MAX_V 15
int a[100000];
int main() {
  int n;
  cin >> n;
  int m, c = 0;
  if (n % 2 == 0) {
    m = n / 2;
    rep(i, n) {
      if (i)
        c = i / 2;
      if (i % 2 == 0) {
        cin >> a[m + c];
      } else {
        cin >> a[m - c - 1];
      }
    }

  } else {
    m = n / 2;
    rep(i, n) {
      if (i)
        c = i / 2;
      if (i % 2 == 0) {
        cin >> a[m - c];
      } else {
        cin >> a[m + c + 1];
      }
    }
  }
  rep(i, n) {
    if (i)
      cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rrep(f, i, n) for (int(i) = 0; (i) < (f); (i)++)
#define FIND(v, k) find((v).begin(), (v).end(), k)
#define mset(a, x) memset(a, x, sizeof(a))

#define MAX 101
#define MAX_V 15
int a[1000000];
int main() {
  int n;
  cin >> n;
  int m, c = 0;
  if (n % 2 == 0) {
    m = n / 2;
    rep(i, n) {
      if (i)
        c = i / 2;
      if (i % 2 == 0) {
        cin >> a[m + c];
      } else {
        cin >> a[m - c - 1];
      }
    }

  } else {
    m = n / 2;
    rep(i, n) {
      if (i)
        c = i / 2;
      if (i % 2 == 0) {
        cin >> a[m - c];
      } else {
        cin >> a[m + c + 1];
      }
    }
  }
  rep(i, n) {
    if (i)
      cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}
Problem p03673 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x % y) : x; }

int main() {
  int n;
  cin >> n;
  vector<ll> b;
  rep(i, n) {
    int a;
    cin >> a;
    b.push_back(a);
    reverse(b.begin(), b.end());
  }
  for (auto aaa : b) {
    cout << aaa << " ";
  }
  cout << "\n";
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x % y) : x; }

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i];
  int l = 0, r = n - 1;
  for (int i = 0; i < n; ++i) {
    if (!(i % 2)) {
      b[l] = a[n - i - 1];
      l++;
    } else {
      b[r] = a[n - i - 1];
      r--;
    }
  }
  for (auto aaa : b) {
    cout << aaa << " ";
  }
  cout << "\n";
  return 0;
}
Problem p03673 (C++)

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

int a[100 * 1000 + 3];
int main() {
  deque<int> mydeque;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    if ((i & 1) != (n & 1)) { // diff parity
      mydeque.push_back(i);
    } else { // same parity
      mydeque.push_front(i);
    }
  }
  for (auto it : mydeque) {
    cout << a[it] << " ";
  }
  cout << "\n";
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

int a[200 * 1000 + 3];
int main() {
  deque<int> mydeque;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    if ((i & 1) != (n & 1)) { // diff parity
      mydeque.push_back(i);
    } else { // same parity
      mydeque.push_front(i);
    }
  }
  for (auto it : mydeque) {
    cout << a[it] << " ";
  }
  cout << "\n";
  return 0;
}