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

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
// #define debug
// #define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 100010;

int n, a[MAXN];
llint sol;

int main(void) {
  scanf("%d", &n);
  n *= 3;
  REP(i, n) scanf("%d", &a[i]);
  sort(a, a + n);

  int lo = 0, hi = n - 1;
  while (lo <= hi) {
    sol += a[hi - 1];
    ++lo;
    hi -= 2;
  }

  cout << sol << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
// #define debug
// #define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 300010;

int n, a[MAXN];
llint sol;

int main(void) {
  scanf("%d", &n);
  n *= 3;
  REP(i, n) scanf("%d", &a[i]);
  sort(a, a + n);

  int lo = 0, hi = n - 1;
  while (lo <= hi) {
    sol += a[hi - 1];
    ++lo;
    hi -= 2;
  }

  cout << sol << endl;

  return 0;
}
Problem p03767 (C++)

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

using namespace std;
#define rep(i, a, b) for (int i = int(a), nn = int(b); i <= nn; ++i)

typedef long long ll;

int n, a[100100];

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  rep(i, 1, n * 3) cin >> a[i];
  sort(a + 1, a + 1 + n * 3);
  ll as = 0;
  for (int i = n * 3 - 1, t = 1; t <= n; ++t, i -= 2)
    as += a[i];
  return cout << as << endl, 0;
}


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

using namespace std;
#define rep(i, a, b) for (int i = int(a), nn = int(b); i <= nn; ++i)

typedef long long ll;

int n, a[300100];

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  rep(i, 1, n * 3) cin >> a[i];
  sort(a + 1, a + 1 + n * 3);
  ll as = 0;
  for (int i = n * 3 - 1, t = 1; t <= n; ++t, i -= 2)
    as += a[i];
  return cout << as << endl, 0;
}
Problem p03767 (C++)

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(), greater<int>())
#define SORT(v, n) sort(v, v + n)
#define DSORT(v, n) sort(v, v + n, greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int, int>
#define Pll pair<ll, ll>

template <class T> void chmin(T &a, const T &b) { a = min(a, b); }
template <class T> void chmax(T &a, const T &b) { a = max(a, b); }

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head &&h, Tail &&...t) {
  if (sizeof...(t) == 0)
    cout << h;
  else
    cout << h << ' ';
  print(move(t)...);
}

const double EPS = 1e-9;
const int INF = 2e+9;
const ll INFL = 9e+18;
const long MOD = 1e+9 + 7;
#define PI 3.14159265258979

int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};

int main(void) {
  int N, A[100000], i;
  ll sum = 0;

  cin >> N;
  REP(i, 3 * N) cin >> A[i];
  SORT(A, 3 * N);

  for (i = N; i <= 3 * N; i += 2)
    sum += A[i];
  print(sum);

  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(), greater<int>())
#define SORT(v, n) sort(v, v + n)
#define DSORT(v, n) sort(v, v + n, greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int, int>
#define Pll pair<ll, ll>

template <class T> void chmin(T &a, const T &b) { a = min(a, b); }
template <class T> void chmax(T &a, const T &b) { a = max(a, b); }

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head &&h, Tail &&...t) {
  if (sizeof...(t) == 0)
    cout << h;
  else
    cout << h << ' ';
  print(move(t)...);
}

const double EPS = 1e-9;
const int INF = 2e+9;
const ll INFL = 9e+18;
const long MOD = 1e+9 + 7;
#define PI 3.14159265258979

int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};

int main(void) {
  int N, A[300000], i;
  ll sum = 0;

  cin >> N;
  REP(i, 3 * N) cin >> A[i];
  SORT(A, 3 * N);

  for (i = N; i <= 3 * N; i += 2)
    sum += A[i];
  print(sum);

  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define pdd pair<double, double>
#define pii pair<ll, ll>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD2 1000000009
#define INF ((ll)1e+18)
#define x1 fldgjdflgjhrthrl
#define x2 fldgjdflgrtyrtyjl
#define y1 fldggfhfghjdflgjl
#define y2 ffgfldgjdflgjl
#define SQ 317
#define MAG 33554431
#define RED 0
#define BLUE 1
#define ALP 26
typedef long long ll;
typedef long double ld;
using namespace std;
ll i, j, k, l, m, r, x, y, K, tot, sz, cur, sum, n, c, maxlvl, q, z, N, ans;
ll a[100500], b[100500];
int main() {
  // freopen("input.txt","r",stdin);
  // freopen("input.txt","w",stdout);
  cin >> n;
  for (i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a, a + 3 * n);
  reverse(a, a + 3 * n);
  for (i = 1; i < 2 * n; i += 2)
    ans += a[i];
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define pdd pair<double, double>
#define pii pair<ll, ll>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD2 1000000009
#define INF ((ll)1e+18)
#define x1 fldgjdflgjhrthrl
#define x2 fldgjdflgrtyrtyjl
#define y1 fldggfhfghjdflgjl
#define y2 ffgfldgjdflgjl
#define SQ 317
#define MAG 33554431
#define RED 0
#define BLUE 1
#define ALP 26
typedef long long ll;
typedef long double ld;
using namespace std;
ll i, j, k, l, m, r, x, y, K, tot, sz, cur, sum, n, c, maxlvl, q, z, N, ans;
ll a[400500], b[100500];
int main() {
  // freopen("input.txt","r",stdin);
  // freopen("input.txt","w",stdout);
  cin >> n;
  for (i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a, a + 3 * n);
  reverse(a, a + 3 * n);
  for (i = 1; i < 2 * n; i += 2)
    ans += a[i];
  cout << ans << endl;
  return 0;
}
Problem p03767 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (int i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  long long int ans = 0;
  for (int i = 0; i < n; i++)
    ans = ans + a[n - (2 * i) - 2];
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (int i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  long long int ans = 0;
  for (int i = 0; i < n; i++)
    ans = ans + a[(3 * n) - (2 * i) - 2];
  cout << ans << endl;
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
// <A.cpp> - Sat Apr  1 19:59:54 2017
// This file is created by XuYike's black technology automatically.
// Copyright (C) 2015 ChangJun High School, Inc.
// I don't know what this program is.

#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long lol;
template <typename T> inline void gg(T &res) {
  res = 0;
  T fh = 1;
  char ch = getchar();
  while ((ch > '9' || ch < '0') && ch != '-')
    ch = getchar();
  if (ch == '-')
    fh = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    res = res * 10 + ch - '0', ch = getchar();
  res *= fh;
}
inline int gi() {
  int x;
  gg(x);
  return x;
}
inline lol gl() {
  lol x;
  gg(x);
  return x;
}
const int MAXN = 100010;
const int INF = 1e9;
int a[MAXN];
int main() {
  int n = gi();
  for (int i = 1; i <= 3 * n; i++)
    a[i] = gi();
  sort(a + 1, a + 3 * n + 1);
  lol ans = 0;
  for (int i = 1; i <= n; i++)
    ans += a[3 * n - i * 2 + 1];
  printf("%lld", ans);
  return 0;
}

Fixed submission:
// <A.cpp> - Sat Apr  1 19:59:54 2017
// This file is created by XuYike's black technology automatically.
// Copyright (C) 2015 ChangJun High School, Inc.
// I don't know what this program is.

#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long lol;
template <typename T> inline void gg(T &res) {
  res = 0;
  T fh = 1;
  char ch = getchar();
  while ((ch > '9' || ch < '0') && ch != '-')
    ch = getchar();
  if (ch == '-')
    fh = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    res = res * 10 + ch - '0', ch = getchar();
  res *= fh;
}
inline int gi() {
  int x;
  gg(x);
  return x;
}
inline lol gl() {
  lol x;
  gg(x);
  return x;
}
const int MAXN = 300010;
const int INF = 1e9;
int a[MAXN];
int main() {
  int n = gi();
  for (int i = 1; i <= 3 * n; i++)
    a[i] = gi();
  sort(a + 1, a + 3 * n + 1);
  lol ans = 0;
  for (int i = 1; i <= n; i++)
    ans += a[3 * n - i * 2 + 1];
  printf("%lld", ans);
  return 0;
}
Problem p03767 (C++)

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b) {
  if (a < b)
    euclid(b, a);
  if (b == 0)
    return a;
  int r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main() {
  int n;
  int a[100000];
  cin >> n;
  for (int i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a, a + 3 * n, greater<int>());
  /*
  for (int i = 0; i < 3 * n; i++)
      cout << a[i] << " ";
  cout << endl;
*/
  int sum = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    sum += a[i + 1];
  }
  cout << sum << endl;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b) {
  if (a < b)
    euclid(b, a);
  if (b == 0)
    return a;
  int r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main() {
  int n;
  int a[3 * 100000];
  cin >> n;
  for (int i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a, a + 3 * n, greater<int>());
  /*
  for (int i = 0; i < 3 * n; i++)
      cout << a[i] << " ";
  cout << endl;
*/
  int sum = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    sum += a[i + 1];
  }
  cout << sum << endl;
}
Problem p03767 (C++)

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

using namespace std;

int main() {

  int N;
  cin >> N;
  long long a[31000];
  int k = 3 * N;
  for (int i = 0; i < k; i++) {
    cin >> a[i];
  }
  sort(a, a + k, greater<int>());
  long long max2 = 0;
  int l = 2 * N;
  for (int i = 1; i < l; i += 2) {
    max2 += (long long)a[i];
  }
  cout << max2 << endl;
  return 0;
}


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

using namespace std;

int main() {

  int N;
  cin >> N;
  long long a[310000];
  int k = 3 * N;
  for (int i = 0; i < k; i++) {
    cin >> a[i];
  }
  sort(a, a + k, greater<int>());
  long long max2 = 0;
  int l = 2 * N;
  for (int i = 1; i < l; i += 2) {
    max2 += (long long)a[i];
  }
  cout << max2 << endl;
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for (ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

const ll MOD = 1000000007;
ll N;
ll a[100000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  rep(i, 0, 3 * N) { cin >> a[i]; }
  sort(a, a + 3 * N);
  reverse(a, a + 3 * N);
  ll ans = 0;
  rep(i, 0, N) { ans += a[2 * i + 1]; }
  cout << ans << "\n";
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for (ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

const ll MOD = 1000000007;
ll N;
ll a[300000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  rep(i, 0, 3 * N) { cin >> a[i]; }
  sort(a, a + 3 * N);
  reverse(a, a + 3 * N);
  ll ans = 0;
  rep(i, 0, N) { ans += a[2 * i + 1]; }
  cout << ans << "\n";
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> P;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
typedef __gnu_pbds::priority_queue<int, greater<int>, pairing_heap_tag> pq;
int n, a[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3 * n; i++)
    scanf("%d", &a[i]);
  sort(a, a + 3 * n);
  ll ans = 0;
  for (int i = 3 * n - 2; i >= n; i -= 2)
    ans += a[i];
  printf("%lld\n", ans);
  return 0;
}


Fixed submission:
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MAXN 300005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> P;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
typedef __gnu_pbds::priority_queue<int, greater<int>, pairing_heap_tag> pq;
int n, a[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3 * n; i++)
    scanf("%d", &a[i]);
  sort(a, a + 3 * n);
  ll ans = 0;
  for (int i = 3 * n - 2; i >= n; i -= 2)
    ans += a[i];
  printf("%lld\n", ans);
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N;
  cin >> N;
  vector<long> data(N);
  for (int i = 0; i < N * 3; i++)
    cin >> data.at(i);
  sort(data.begin(), data.end());
  long ans = 0;
  for (int i = N; i < N * 3; i += 2) {
    ans += data.at(i);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N;
  cin >> N;
  vector<long> data(N * 3);
  for (int i = 0; i < N * 3; i++)
    cin >> data.at(i);
  sort(data.begin(), data.end());
  long ans = 0;
  for (int i = N; i < N * 3; i += 2) {
    ans += data.at(i);
  }
  cout << ans << endl;
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

int main() {
  while (~scanf("%d", &n)) {
    n = n * 3;
    for (int i = 1; i <= n; i++)
      scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    int cnt = 0;
    long long ans = 0;
    for (int i = n; i >= 1; i -= 2) {
      ans = ans + a[i - 1];
      cnt++;
      if (cnt == n / 3)
        break;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

const int MaxN = 4e5;
int n;
int a[MaxN + 5];

int main() {
  while (~scanf("%d", &n)) {
    n = n * 3;
    for (int i = 1; i <= n; i++)
      scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    int cnt = 0;
    long long ans = 0;
    for (int i = n; i >= 1; i -= 2) {
      ans = ans + a[i - 1];
      cnt++;
      if (cnt == n / 3)
        break;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
Problem p03767 (C++)

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

int A[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 3 * n; i++) {
    scanf("%d", &A[i]);
  }
  sort(A, A + 3 * n);
  long long ans = 0;
  int flag = 1;
  for (int i = n; i < 3 * n; i++) {
    if (flag) {
      ans += A[i];
      flag = 0;
    } else {
      flag = 1;
    }
  }
  printf("%lld", ans);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
using namespace std;

int A[300010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 3 * n; i++) {
    scanf("%d", &A[i]);
  }
  sort(A, A + 3 * n);
  long long ans = 0;
  int flag = 1;
  for (int i = n; i < 3 * n; i++) {
    if (flag) {
      ans += A[i];
      flag = 0;
    } else {
      flag = 1;
    }
  }
  printf("%lld", ans);
  return 0;
}
Problem p03767 (C++)

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

#define INF (1e9)
#define INF_LL (1e17)
#define YJ 1145141919810
#define mod 1000000007

using LL = long long;
using ULL = unsigned long long;

using namespace std;

#define MAX_N 100005
int N;
LL A[MAX_N];

int main() {
  cin >> N;
  N *= 3;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  sort(A, A + N);

  LL ans = 0;
  for (int i = 0; i < N / 3; i++) {
    ans += A[N - 1 - 1 - (2 * i)];
  }

  cout << ans << endl;

  return 0;
}


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

#define INF (1e9)
#define INF_LL (1e17)
#define YJ 1145141919810
#define mod 1000000007

using LL = long long;
using ULL = unsigned long long;

using namespace std;

#define MAX_N 300005
int N;
LL A[MAX_N];

int main() {
  cin >> N;
  N *= 3;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  sort(A, A + N);

  LL ans = 0;
  for (int i = 0; i < N / 3; i++) {
    ans += A[N - 1 - 1 - (2 * i)];
  }

  cout << ans << endl;

  return 0;
}
Problem p03767 (C++)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  int N;
  cin >> N;
  vector<uint64_t> a(N);
  rep(i, 3 * N) cin >> a[i];

  uint64_t res = 0;
  sort(all(a), greater<int>());
  rep(i, N) res += a[2 * (i + 1) - 1];

  cout << res << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  int N;
  cin >> N;
  vi a(3 * N);
  rep(i, 3 * N) cin >> a[i];

  uint64_t res = 0;
  sort(all(a), greater<int>());
  rep(i, N) res += a[2 * (i + 1) - 1];

  cout << res << endl;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <functional>

typedef long long i64;

const int N = 100000 + 10;

int n, a[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3 * n; ++i)
    scanf("%d", &a[i]);
  std::sort(a + 1, a + 3 * n + 1, std::greater<int>());
  i64 ans = 0;
  for (int i = 2, j = n; j--; i += 2)
    ans += a[i];
  printf("%lld\n", ans);
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <functional>

typedef long long i64;

const int N = 300000 + 10;

int n, a[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3 * n; ++i)
    scanf("%d", &a[i]);
  std::sort(a + 1, a + 3 * n + 1, std::greater<int>());
  i64 ans = 0;
  for (int i = 2, j = n; j--; i += 2)
    ans += a[i];
  printf("%lld\n", ans);
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define int long long
using namespace std;

int b[100000];
signed main() {
  int a;
  cin >> a;
  a *= 3;
  for (int c = 0; c < a; c++) {
    scanf("%lld", &b[c]);
  }
  sort(b, b + a, greater<int>());
  int ans = 0;
  for (int i = 1; i < a / 3 * 2; i += 2) {
    ans += b[i];
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define int long long
using namespace std;

int b[300000];
signed main() {
  int a;
  cin >> a;
  a *= 3;
  for (int c = 0; c < a; c++) {
    scanf("%lld", &b[c]);
  }
  sort(b, b + a, greater<int>());
  int ans = 0;
  for (int i = 1; i < a / 3 * 2; i += 2) {
    ans += b[i];
  }
  cout << ans << endl;
}
Problem p03767 (C++)

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F() {
  char ch;
  int x, a;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  if (ch == '-')
    ch = getchar(), a = -1;
  else
    a = 1;
  x = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0';
  return a * x;
}

const int N = 200010;

int n, a[N];

int main() {
  gi(n);
  for (int i = 1; i <= 3 * n; ++i)
    gi(a[i]);
  sort(a + 1, a + 3 * n + 1);
  int cnt = 0;
  long long ans = 0;
  for (int i = 3 * n - 1; i; i -= 2) {
    ans += a[i];
    ++cnt;
    if (cnt == n)
      break;
  }
  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F() {
  char ch;
  int x, a;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  if (ch == '-')
    ch = getchar(), a = -1;
  else
    a = 1;
  x = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0';
  return a * x;
}

const int N = 300010;

int n, a[N];

int main() {
  gi(n);
  for (int i = 1; i <= 3 * n; ++i)
    gi(a[i]);
  sort(a + 1, a + 3 * n + 1);
  int cnt = 0;
  long long ans = 0;
  for (int i = 3 * n - 1; i; i -= 2) {
    ans += a[i];
    ++cnt;
    if (cnt == n)
      break;
  }
  printf("%lld\n", ans);
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
  int n, a[100000];
  long long s = 0;
  cin >> n;
  for (int i = 0; i < n * 3; i++) {
    cin >> a[i];
  }
  sort(a, a + n * 3, greater<int>());
  for (int i = 1; i < 2 * n; i += 2) {
    s += a[i];
  }
  cout << s << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
  int n, a[300000];
  long long s = 0;
  cin >> n;
  for (int i = 0; i < n * 3; i++) {
    cin >> a[i];
  }
  sort(a, a + n * 3, greater<int>());
  for (int i = 1; i < 2 * n; i += 2) {
    s += a[i];
  }
  cout << s << endl;
}
Problem p03767 (C++)

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

int main() {
  long int N;
  long int a[11000];
  cin >> N;
  long int res = 0;
  for (int i = 0; i < N * 3; ++i)
    cin >> a[i];
  sort(a, a + (N * 3), greater<int>());
  for (int i = 0; i < N * 2; ++i) {
    if ((i + 1) % 2 == 0) {
      res += a[i];
    }
  }
  cout << res << endl;
}

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

int main() {
  int N;
  int a[1100000];
  cin >> N;
  long int res = 0;
  for (int i = 0; i < N * 3; ++i)
    cin >> a[i];
  sort(a, a + (N * 3), greater<int>());
  for (int i = 0; i < N * 2; ++i) {
    if ((i + 1) % 2 == 0) {
      res += a[i];
    }
  }
  cout << res << endl;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-13
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.9lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios                                                                    \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0)
#define endl '\n'
using namespace std;
ll a[100004];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 3 * n; i++) {
    cin >> a[i];
    a[i] = -a[i];
  }
  sort(a + 1, a + 3 * n + 1);
  ll ans = 0;
  for (int i = 2; i <= 2 * n; i = i + 2)
    ans -= a[i];
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-13
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.9lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios                                                                    \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0)
#define endl '\n'
using namespace std;
ll a[300004];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 3 * n; i++) {
    cin >> a[i];
    a[i] = -a[i];
  }
  sort(a + 1, a + 3 * n + 1);
  ll ans = 0;
  for (int i = 2; i <= 2 * n; i = i + 2)
    ans -= a[i];
  cout << ans << endl;
}
Problem p03767 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  int n2 = n * 3;
  vector<ll> a(n2);
  for (int i = 0; i < n2; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  while (!a.empty()) {
    ans += a[a.size() - 2];
    a.pop_back();
    a.pop_back();
    a.erase(a.begin());
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  int n2 = n * 3;
  vector<ll> a(n2);
  for (int i = 0; i < n2; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  int ind = n2 - 2;
  for (int i = 0; i < n; i++) {
    ans += a[ind];
    ind -= 2;
  }
  cout << ans << endl;
  return 0;
}
Problem p03767 (C++)

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

int n;
ll a[100010];

int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < 3 * n; i++)
      scanf("%lld", &a[i]);
    sort(a, a + 3 * n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[3 * n - 2 - 2 * i];
    }
    printf("%lld\n", sum);
  }
  return 0;
}


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

int n;
ll a[300010];

int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < 3 * n; i++)
      scanf("%lld", &a[i]);
    sort(a, a + 3 * n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[3 * n - 2 - 2 * i];
    }
    printf("%lld\n", sum);
  }
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }

int main() {
  ll n;
  cin >> n;
  vll a(3 * n);
  for (ll i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(all(a));
  ll ans = 0;
  for (ll i = 0; i < n; i++)
    ans += a[n - 1 - (i * 2 + 1)];
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }

int main() {
  ll n;
  cin >> n;
  vll a(3 * n);
  for (ll i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(all(a));
  ll ans = 0;
  for (ll i = 0; i < n; i++)
    ans += a[3 * n - 1 - (i * 2 + 1)];
  cout << ans << endl;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long INT;
double PI = 3.14159265;

const long long INF = 1LL << 60;

int main() {
  int a[100001] = {}, n;
  INT sum = 0;

  cin >> n;

  rep(i, n * 3) cin >> a[i];

  sort(a, a + n * 3, greater<int>());

  rep(i, n) sum += a[i * 2 + 1];

  cout << sum << endl;

  return 0;
}

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

const long long INF = 1LL << 60;

int main() {
  int a[300010] = {}, n;
  INT sum = 0;

  cin >> n;

  rep(i, n * 3) cin >> a[i];

  sort(a, a + n * 3, greater<int>());

  rep(i, n) sum += a[i * 2 + 1];

  cout << sum << endl;

  return 0;
}
Problem p03767 (C++)

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

const int N = 1000 * 100 + 10, inf = 1e9;

long long a[N];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a, a + 3 * n);
  int k = n;
  long long ans = 0, cnt = 3 * n - 2;
  while (k) {
    ans += a[cnt];
    cnt -= 2;
    k--;
  }
  cout << ans << endl;
}

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

const int N = 3000 * 100 + 10, inf = 1e9;

long long a[N];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a, a + 3 * n);
  int k = n;
  long long ans = 0, cnt = 3 * n - 2;
  while (k) {
    ans += a[cnt];
    cnt -= 2;
    k--;
  }
  cout << ans << endl;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll n;
  vector<ll> a(111111);
  cin >> n;
  for (int i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    ans += a[cnt];
    cnt += 2;
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll n;
  vector<ll> a(311111);
  cin >> n;
  for (int i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    ans += a[cnt];
    cnt += 2;
  }
  cout << ans << endl;
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> vec(3 * n);
  for (ll i = 0; i < 3 * n; ++i) {
    cin >> vec[i];
  }
  //  sort(vec, vec+3*n);
  sort(vec.begin(), vec.end(), greater<int>());
  ll ans = 0;
  for (ll i = 1; i < 2 * n; i += 2) {
    ans += vec[i];
  }
  //  debug(ans);
  cout << ans << '\n';
}


Fixed submission:
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> vec(3 * n);
  for (ll i = 0; i < 3 * n; ++i) {
    cin >> vec[i];
  }
  //  sort(vec, vec+3*n);
  sort(vec.begin(), vec.end(), greater<int>());
  ll ans = 0;
  for (ll i = 1; i < 2 * n; i += 2) {
    ans += vec[i];
  }
  //  debug(ans);
  cout << ans << '\n';
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main(void) {
  int n, i, a[100005];
  ll ans = 0;

  cin >> n;
  for (i = 0; i < n * 3; i++)
    cin >> a[i];

  sort(a, a + n * 3, greater<int>());

  i = 1;
  while (i < n * 2) {
    ans += a[i];
    i += 2;
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main(void) {
  int n, i, a[300005];
  ll ans = 0;

  cin >> n;
  for (i = 0; i < n * 3; i++)
    cin >> a[i];

  sort(a, a + n * 3, greater<int>());

  i = 1;
  while (i < n * 2) {
    ans += a[i];
    i += 2;
  }

  cout << ans << endl;

  return 0;
}
Problem p03767 (C++)

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

using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");

#define hello cout << "hello" << endl
#define dbg(var) cout << #var << " --> " << var << endl
#define mset(a, b) memset(a, b, sizeof(a))
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define boost ios_base::sync_with_stdio(false)

const int MOD = 1e9 + 7;
const double EPS = 1e-6;

const int N = 1e5 + 10;
int a[N];
int main() {
  boost;
  int n;
  cin >> n;
  n *= 3;
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  sort(a, a + n);
  int m = n / 3;
  ll sum = 0;
  while (m--) {
    sum += a[n - 2];
    n -= 2;
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");

#define hello cout << "hello" << endl
#define dbg(var) cout << #var << " --> " << var << endl
#define mset(a, b) memset(a, b, sizeof(a))
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define boost ios_base::sync_with_stdio(false)

const int MOD = 1e9 + 7;
const double EPS = 1e-6;

const int N = 3e5 + 10;
int a[N];
int main() {
  boost;
  int n;
  cin >> n;
  n *= 3;
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  sort(a, a + n);
  int m = n / 3;
  ll sum = 0;
  while (m--) {
    sum += a[n - 2];
    n -= 2;
  }
  cout << sum << endl;
  return 0;
}
Problem p03767 (C++)

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

#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define REP2(i, n) for (int i = 0; i < (int)(n); i++)
#define REP3(i, m, n) for (int i = m; i < (int)(n); i++)
#define REP4(i, m, n, s)                                                       \
  for (int i = m; (s > 0 and i < (int)(n)) or (s < 0 and i > (int)(n)); i += s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i, c)                                                            \
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define PIS(x) printf("%d ", x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

void RI() {}
template <typename... T> void RI(int &head, T &...tail) {
  scanf("%d", &head);
  RI(tail...);
}
void RLL() {}
template <typename... T> void RLL(LL &head, T &...tail) {
  scanf("%lld", &head);
  RLL(tail...);
}
void print() { putchar('\n'); }
template <typename T, typename... U> void print(T head, U... tail) {
  cout << head << " ";
  print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005
int a[MAX_N];

int main() {
  int n;
  RI(n);
  REP(i, 3 * n) { RI(a[i]); }
  sort(a, a + 3 * n, greater<int>());
  LL ans = 0;
  REP(i, 1, 2 * n, 2) { ans += a[i]; }
  printf("%lld\n", ans);
  return 0;
}


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

#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define REP2(i, n) for (int i = 0; i < (int)(n); i++)
#define REP3(i, m, n) for (int i = m; i < (int)(n); i++)
#define REP4(i, m, n, s)                                                       \
  for (int i = m; (s > 0 and i < (int)(n)) or (s < 0 and i > (int)(n)); i += s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i, c)                                                            \
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define PIS(x) printf("%d ", x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

void RI() {}
template <typename... T> void RI(int &head, T &...tail) {
  scanf("%d", &head);
  RI(tail...);
}
void RLL() {}
template <typename... T> void RLL(LL &head, T &...tail) {
  scanf("%lld", &head);
  RLL(tail...);
}
void print() { putchar('\n'); }
template <typename T, typename... U> void print(T head, U... tail) {
  cout << head << " ";
  print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005
int a[3 * MAX_N];

int main() {
  int n;
  RI(n);
  REP(i, 3 * n) { RI(a[i]); }
  sort(a, a + 3 * n, greater<int>());
  LL ans = 0;
  REP(i, 1, 2 * n, 2) { ans += a[i]; }
  printf("%lld\n", ans);
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define DEBUG(x) cout << #x << " = " << x << endl
#define pb push_back
using namespace std;
typedef long long ll;

const int MAXN = 100005;
ll a[MAXN];
ll ans;
int main() {
  // freopen("input.txt", "r", stdin);
  int n;
  cin >> n;
  for (int i = 0; i < 3 * n; i++) {
    cin >> a[i];
  }
  sort(a, a + 3 * n);
  for (int i = 0; i < n; i++) {
    ans += a[3 * n - 2 - 2 * i];
  }

  cout << ans;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define DEBUG(x) cout << #x << " = " << x << endl
#define pb push_back
using namespace std;
typedef long long ll;

const int MAXN = 500005;
ll a[MAXN];
ll ans;
int main() {
  // freopen("input.txt", "r", stdin);
  int n;
  cin >> n;
  for (int i = 0; i < 3 * n; i++) {
    cin >> a[i];
  }
  sort(a, a + 3 * n);
  for (int i = 0; i < n; i++) {
    ans += a[3 * n - 2 - 2 * i];
  }

  cout << ans;

  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < 3 * N; i++)
    cin >> A.at(i);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int64_t ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A.at(2 * i + 1);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int64_t> A(3 * N);
  for (int i = 0; i < 3 * N; i++)
    cin >> A.at(i);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int64_t ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A.at(2 * i + 1);
  }
  cout << ans << endl;
  return 0;
}
Problem p03767 (C++)

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

int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  vector<long long> a(3 * n);
  for (long long i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    ans += a[n - 2 - 2 * i];
  }
  cout << ans << endl;
}


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

int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  vector<long long> a(3 * n);
  for (long long i = 0; i < 3 * n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    ans += a[3 * n - 2 - 2 * i];
  }
  cout << ans << endl;
}
Problem p03767 (C++)

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

using namespace std;

int main() {
  int n, *a;
  cin >> n;
  a = new int[3 * n];
  int i;
  for (i = 0; i < 3 * n; i++)
    cin >> a[i];

  long long ans = 0;

  sort(a, a + n * 3);

  for (i = 0; i < n * 3; i += 2)
    ans += a[n + 1 + i];

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main() {
  int n, *a;
  cin >> n;
  a = new int[3 * n];
  int i;
  for (i = 0; i < 3 * n; i++)
    cin >> a[i];

  long long ans = 0;

  sort(a, a + n * 3);

  for (i = 0; i / 2 < n; i += 2)
    ans += a[n + i];

  cout << ans << endl;

  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <algorithm> // sort
#include <iostream>
#include <map> // pair
using namespace std;
long long N;
long long a[100001];
long long R = 0;
long long T = 0;
int main() {
  cin >> N;
  for (int i = 0; i < N * 3; i++)
    cin >> a[i];

  sort(a, a + N * 3, greater<long long>());

  int S = 0;
  for (int i = 1; S < N; i += 2) {
    R += a[i];
    S += 1;
  }

  cout << R << endl;

  return 0;
}


Fixed submission:
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <algorithm> // sort
#include <iostream>
#include <map> // pair
using namespace std;
long long N;
long long a[300001];
long long R = 0;
long long T = 0;
int main() {
  cin >> N;
  for (int i = 0; i < N * 3; i++)
    cin >> a[i];

  sort(a, a + N * 3, greater<long long>());

  int S = 0;
  for (int i = 1; S < N; i += 2) {
    R += a[i];
    S += 1;
  }

  cout << R << endl;

  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, a[100010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3 * n; i++)
    scanf("%d", &a[i]);
  sort(a + 1, a + 3 * n + 1);
  ll ans = 0;
  int now = 3 * n - 1;
  while (n--) {
    ans += (ll)a[now];
    now -= 2;
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, a[300010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3 * n; i++)
    scanf("%d", &a[i]);
  sort(a + 1, a + 3 * n + 1);
  ll ans = 0;
  int now = 3 * n - 1;
  while (n--) {
    ans += (ll)a[now];
    now -= 2;
  }
  cout << ans;
  return 0;
}
Problem p03767 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define ll long long
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-')
    ch = getchar();
  if (ch == '-')
    t = true, ch = getchar();
  while (ch <= '9' && ch >= '0')
    x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
int n, a[100100];
ll ans;
int main() {
  n = read();
  for (int i = 1; i <= n * 3; ++i)
    a[i] = read();
  sort(&a[1], &a[n + n + n + 1]);
  for (int i = n + n + n - 1, j = 1; j <= n; ++j, i -= 2)
    ans += a[i];
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define ll long long
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-')
    ch = getchar();
  if (ch == '-')
    t = true, ch = getchar();
  while (ch <= '9' && ch >= '0')
    x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
int n, a[300100];
ll ans;
int main() {
  n = read();
  for (int i = 1; i <= n * 3; ++i)
    a[i] = read();
  sort(&a[1], &a[n + n + n + 1]);
  for (int i = n + n + n - 1, j = 1; j <= n; ++j, i -= 2)
    ans += a[i];
  cout << ans << endl;
  return 0;
}