stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define ll unsigned long long



struct ac{

    int x, y;

}a[55], d[55];



int cmp1(ac b, ac c)

{

    return b.x < c.x;

}



int cmp2(ac b, ac c)

{

    return b.y<c.y;

}



int sl(int x1,int y1,int x2,int y2,int i)

{

    int xl = min(x1, x2), xr = max(x1, x2);

    int yl = min(y1, y2), yr = max(y1, y2);

    if(a[i].x >= xl && a[i].x <= xr && a[i].y >= yl && a[i].y <= yr)

    {

        return 1;

    }

    return 0;

}



int main()

{

    ll maxx = 1ll*10e9*10e9*4+2;

    int n, k1;

    cin >> n >> k1;

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

    {

        cin >> a[i].x >> a[i].y;

        d[i].x = a[i].x, d[i].y = a[i].y;

    }

    sort(a+1, a+1+n,cmp1);

    sort(d+1, d+n+1,cmp2);

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

    {

        for(int j = i+1; j <= n; j++)

        {

            for(int k = 1; k <= n; k++)

            {

                for(int l = k+1; l <= n; l++)

                {

                    int flag = 0;

                    for(int u = 1; u <= n; u++)

                    {

                        if(sl(a[i].x,d[k].y,a[j].x,d[l].y,u))

                        {

                            flag++;

                        }

                    }

                    if(flag >= k1)

                    {

                        maxx = min(maxx, (ll)abs(1ll*a[i].x-1ll*a[j].x)*abs(1ll*d[k].y-1ll*d[l].y));

                    }

                }

            }

        }



    }

   cout << maxx << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cctype>

#include <algorithm>

#define int long long

using namespace std;



struct Node {

    int x, y;

} a[233];



int n, num, ans = 0x7fffffffffffffff;



int read() {

    int ret, f = 1;

    char ch;

    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);

    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');

    return ret * f;

}



void print(int x) {

    if(x < 0) putchar('-'), x = -x;

    if(x > 9) print(x / 10);

    putchar(x % 10 + '0');

}



bool cmp(Node a, Node b) {

    return a.x < b.x;

}



signed main() {

    n = read(), num = read();

    for(int i = 1; i <= n; ++i) a[i].x = read(), a[i].y = read();

    std::sort(a + 1, a + n + 1, cmp);

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

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

            int tmx = std::max(a[i].y, a[j].y),

                tmn = std::min(a[i].y, a[j].y);

            for(int k = 1; k <= n; ++k) {

                if(a[k].y > tmx || a[k].y < tmn) continue;

                int cnt = 0;

                for(int l = k; l <= n; ++l) {

                    if(a[l].y > tmx || a[l].y < tmn) continue;

                    if(++cnt >= num) ans = min(ans, (tmx - tmn) * (a[l].x - a[k].x));

                }

            }

        }

    print(ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;



bool visit[26],g[26][26];



bool dfs(int v){

  visit[v] = true;

  bool f = false;

  for(int i=0;i<26;i++)

    if(g[v][i]){

      f = true;

      if(!visit[i])dfs(i);

    }

  return f;

}

 

int graph_num(void){

  int res = 0;

  for(int i=0;i<26;i++)

    if(!visit[i] && dfs(i))res++;

  return res;

}

  

int main(){

  int i,n,pre[26],suf[26],h,t;

  string s;



  while(cin>>n && n){

    for(i=0;i<26;i++){

      visit[i] = false;

      pre[i] = suf[i] = 0;

      for(int j=0;j<26;j++)g[i][j] = false;

    }

    

    for(i=0;i<n;i++){

      cin >> s;

      h = s[0]-'a', t = s[(int)s.size()-1]-'a';

      

      pre[h]++;

      suf[t]++;

      g[h][t] = g[t][h] = true;

    }

  

    if(graph_num() != 1)printf("NG\n");

    else{

      for(i=0;i<26;i++)if(pre[i] != suf[i])break;

      

      if(i==26)printf("OK\n");

      else printf("NG\n");

    }

  }

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

using namespace std;



bool visit[26],g[26][26];



bool dfs(int v){

  visit[v] = true;

  bool f = false;

  for(int i=0;i<26;i++)

    if(g[v][i]){

      f = true;

      if(!visit[i])dfs(i);

    }

  return f;

}

 

int graph_num(void){

  int res = 0;

  for(int i=0;i<26;i++)

    if(!visit[i] && dfs(i))res++;

  return res;

}

  

int main(){

  int i,n,pre[26],suf[26],h,t;



  while(scanf("%d",&n) && n){

    for(i=0;i<26;i++){

      visit[i] = false;

      pre[i] = suf[i] = 0;

      for(int j=0;j<26;j++)g[i][j] = false;

    }

    

    for(i=0;i<n;i++){

      char s[40];

      scanf("%s",s);

      int len = strlen(s);

      h = s[0]-'a';

      t = s[len-1]-'a';

      

      pre[h]++;

      suf[t]++;

      g[h][t] = g[t][h] = true;

    }

  

    if(graph_num() != 1)printf("NG\n");

    else{

      for(i=0;i<26;i++)if(pre[i] != suf[i])break;

      

      if(i==26)printf("OK\n");

      else printf("NG\n");

    }

  }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <memory.h>



#define fr first

#define sc second

#define mk make_pair



using namespace std;



int n, ar[1000001];



int main()

{

    cin >> n;

    for(int i =0 ; i < n * 3; i++)

        cin >> ar[i];

    sort(ar, ar + n * 3);

    long long sum = 0;

    int k = n;

    int t = n * 3;

    while(k--)

    {

        t = t - 2;

        sum += ar[t];

    }

    cout << sum;

    return 0;

}


// Optimized solution to the same problem (faster):


#include <cstdio>

#include <algorithm>

using namespace std;

int N;

long long a[300005];

int main(){

    scanf("%d", &N);

    for(int i = 0; i < 3 * N; i++)

        scanf("%lld", &a[i]);

    sort(a, a+3*N);

    reverse(a,a+3*N);

    long long  ans = 0;

    int i = 1;

    while(N--)

    {

        ans += a[i];

        i+=2;

    }

    printf("%lld\n", ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define pb push_back

#define mk make_pair

#define sc second

#define fr first



using namespace std;



typedef long long ll;



const long long N = (long long) 1e6 + 5;

const long long mod = (long long) 1e9 + 7;



long long n,a[N],sum,sum1;



int main () {

        cin >> n;



        for(long long i = 1; i <= 3 * n; i ++)

                cin >> a[i];



        sort(a + 1,a + n + n + n + 1);



        for(long long i = n + 1; i <= 2 * n; i ++)

                sum += a[i];



        for(long long i = n * 3 - 1; i >= n + 1; i -= 2)

                sum1 += a[i];



        cout << max(sum,sum1) << endl;

        return 0;

}


// Optimized solution to the same problem (faster):


#include <cstdio>

#include <algorithm>

using namespace std;

int N;

long long a[300005];

int main(){

    scanf("%d", &N);

    for(int i = 0; i < 3 * N; i++)

        scanf("%lld", &a[i]);

    sort(a, a+3*N);

    reverse(a,a+3*N);

    long long  ans = 0;

    int i = 1;

    while(N--)

    {

        ans += a[i];

        i+=2;

    }

    printf("%lld\n", ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    long long n, i, x, k = 1;

    long long ans = 0;

    vector <long long> v;



    cin >> n;



    for(i = 0; i < n * 3; ++i)

    {

        cin >> x;

        v.push_back(x);

    }

    sort(v.rbegin(), v.rend());

    while(n > 0)

    {

        n--;

        ans += v[k];

        k += 2;

    }

    cout << ans;



return 0;

}


// Optimized solution to the same problem (faster):


#include <cstdio>

#include <algorithm>

using namespace std;

int N;

long long a[300005];

int main(){

    scanf("%d", &N);

    for(int i = 0; i < 3 * N; i++)

        scanf("%lld", &a[i]);

    sort(a, a+3*N);

    reverse(a,a+3*N);

    long long  ans = 0;

    int i = 1;

    while(N--)

    {

        ans += a[i];

        i+=2;

    }

    printf("%lld\n", ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define fr first

#define sc second

#define mk make_pair

#define pb push_back

#define ll long long

#define ld long double

#define OK puts("OK");

#define sz(s) (int)s.size()

#define all(s) s.begin(), s.end()



using namespace std;



const int N = 1e5 + 10;

const ll inf = 1e15 + 7;



int n;

int a[3*N];

ll ans;



main()

{

    scanf("%d", &n);

    n *= 3;

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

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

    sort(a + 1, a + n + 1);

    for(int i = n - 1 ; i >= n / 3 + 1 ; i -= 2)

        ans += a[i];

    cout << ans << endl;

}


// Optimized solution to the same problem (faster):


#include <cstdio>

#include <algorithm>

using namespace std;

int N;

long long a[300005];

int main(){

    scanf("%d", &N);

    for(int i = 0; i < 3 * N; i++)

        scanf("%lld", &a[i]);

    sort(a, a+3*N);

    reverse(a,a+3*N);

    long long  ans = 0;

    int i = 1;

    while(N--)

    {

        ans += a[i];

        i+=2;

    }

    printf("%lld\n", ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <algorithm>

using namespace std;



typedef long long ll;



int main()

{

//	freopen("input.txt", "r", stdin);

//	freopen("output.txt", "w", stdout);

    int n;

    cin >> n;



    int a[n*3];

    for(int i = 0;i < n*3;i ++)

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



    ll s = 0, c = 0;

    sort(a, a + 3*n);

    for(int i = 3*n - 2;i >= 0;i -= 2){

         s += a[i];

         c ++;

         if(c == n)

             break;

    }

    cout << s << endl;

	return 0;

}


// Optimized solution to the same problem (faster):


#include <cstdio>

#include <algorithm>

using namespace std;

int N;

long long a[300005];

int main(){

    scanf("%d", &N);

    for(int i = 0; i < 3 * N; i++)

        scanf("%lld", &a[i]);

    sort(a, a+3*N);

    reverse(a,a+3*N);

    long long  ans = 0;

    int i = 1;

    while(N--)

    {

        ans += a[i];

        i+=2;

    }

    printf("%lld\n", ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); i++)

#define all(v) v.begin(), v.end()

#define allr(v) v.rbegin(), v.rend()





int main() {

  ll n;

  cin >> n;

  vector<ll> a(1100000);

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

  sort(&a[0], &a[0]+n*3);

  

  ll ans = 0;

  for (int i = 0; i < n; i++) {

    ans += a[n + 2*i];

  }

  cout << ans << endl;

}




// Optimized solution to the same problem (faster):
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

/*using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); i++)

#define all(v) v.begin(), v.end()

#define allr(v) v.rbegin(), v.rend()*/





int main() {

  long long int n, ans = 0;

 

  scanf("%lld", &n);

 

  vector<long long int> a(3 * n);

 

  for (int i = 0; i < 3 * n; i++)

  {

    scanf("%lld", &a[i]);

}

    sort(a.begin(), a.end(), greater<int>());

 

  for (int i = 0; i < n; i++)

  {

    ans += a[2 * i + 1];

  }

 

  printf("%lld", ans);

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

using namespace std;





int n, a[300000];



int main(void) {

  cin >> n;

  for (int i = 0; i < 3*n; ++i) {

    cin >> a[i];

  }

  sort(a, a + 3*n);

  long long ans = 0;

  for (int i = 0, j = 3*n-2; i < n; ++i, j -= 2) {

    ans += a[j];

  }

  cout << ans;

  return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long li;



const int maxn = 1e5;

int n, a[3 * maxn];



int main(void) {

  scanf("%d", &n);

  for (int i = 0; i < 3 * n; ++i) scanf("%d", a + i);

  sort(a, a + 3 * n);

  li ans = 0;

  for (int i = 0, j = 3 * n - 2; i < n; ++i, j -= 2) {

    ans += a[j];

  }

  printf("%lld\n", ans);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

long long n,ans=0,a[500010];

int main()

{

    scanf("%lld",&n);

    for(int i=1;i<=3*n;i++) scanf("%lld",&a[i]);

    sort(a+1,a+1+3*n);

    long long mid=n;

    for(int i=3*n-1;i>mid;i-=2)

        ans+=a[i];

    cout<<ans<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include "algorithm"

#include "cstdio"

using namespace std;

int s[300005],i,j,n;long long ss;

int A(){

    int a=0,k=1;char c=getchar();

    while(c<'0'||c>'9'){

        if(c=='-') k=-1;c=getchar();

    }

    while(c>='0'&&c<='9'){

        a=a*10+c-'0';c=getchar();

    }

    return a*k;

}

bool cmp(int a,int b){

	return a>b;

}

int main(){

	n=A();

	for(i=1;i<=n*3;i++)s[i]=A();

	sort(s+1,s+1+3*n,cmp);

	for(i=1,j=3*n;i<=j;i+=2,j--){

		ss+=s[i+1];

	}

	printf("%lld\n",ss);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

const int maxn=300000+10;

long long n,a[maxn],ans=0;

int main()

{

    scanf("%lld",&n);

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

        scanf("%lld",&a[i]);

    }

    sort(a+1,a+1+3*n);

    for(int i=(3*n)-1;i>=n+1;i-=2){

        ans+=a[i];

    }

    printf("%lld\n",ans);

}

// Optimized solution to the same problem (faster):
#include "algorithm"

#include "cstdio"

using namespace std;

int s[300005],i,j,n;long long ss;

int A(){

    int a=0,k=1;char c=getchar();

    while(c<'0'||c>'9'){

        if(c=='-') k=-1;c=getchar();

    }

    while(c>='0'&&c<='9'){

        a=a*10+c-'0';c=getchar();

    }

    return a*k;

}

bool cmp(int a,int b){

	return a>b;

}

int main(){

	n=A();

	for(i=1;i<=n*3;i++)s[i]=A();

	sort(s+1,s+1+3*n,cmp);

	for(i=1,j=3*n;i<=j;i+=2,j--){

		ss+=s[i+1];

	}

	printf("%lld\n",ss);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

    for(i=0;i<3*n;i++)

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#define sci1(a) scanf("%d",&a)

#define sci2(a,b) scanf("%d %d",&a,&b)

#define sci3(a,b,c) scanf("%d %d %d",&a,&b,&c)

#define scs(s) scanf("%s",s)

#ifndef GET_MACRO



#define GET_MACRO(__1,__2,__3,NAME,...) NAME



#endif // GET_MACRO



#define sci(...) GET_MACRO(__VA_ARGS__,sci3,sci2,sci1)(__VA_ARGS__)

#define ll long long

#define pii pair<int,int>

#define mp(a,b) make_pair(a,b)

#define LSB(i) ((i)&(-i))

#define read freopen("input.txt","r",stdin)

#define write freopen("output.txt","w",stdout)

#define infl 0x7ffffffffffffff

#define infi  0x7fffffff

#define fill_(a,b) fill(a.begin(),a.end(),b)

#define pb push_back

#define xx first

#define yy second

int main(){

    int n;

    sci(n);

    vector<int> data(3*n);

    int i;

    ll ans=0;

    for(i=0;i<3*n;i++){

        sci(data[i]);

    }

    sort(data.begin(),data.end());

    for(i=n;i<3*n;i+=2){

        ans+=data[i];

    }

    cout<<ans<<endl;

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<iomanip>

#include<math.h>

#include<vector>

#include<algorithm>

#include<set>

#include<map>

#include<queue>

#include<stack>

#include<string>

#define INF 1000000000ll

#define MOD 1000000007ll

#define EPS 1e-8

#define REP(i,m) for(long long i=0; i<m; ++i)

#define FOR(i,n,m) for(long long i=n; i<m; ++i)

#define DUMP(n,a) for(long long i=0; i<n; ++i) { cout<<a[i]; if(i!=n-1) cout<<" "; else cout<<endl; }

#define ALL(v) v.begin(),v.end()

#define pb push_back

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef long double ld;

typedef vector<int> vi;

typedef vector<vector<int> > vii;

typedef vector<long long> vl;

typedef vector<vector<long long> > vll;

typedef vector<P> vp;

typedef vector<vector<P> > vpp;

int main() {

	ios::sync_with_stdio(false);

	int n;

	cin>>n;

	vector<ll> a(3*n);

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

	sort(ALL(a));

	ll res=0;

	REP(i,n) {

		res+=a[3*n-2-2*i];

	}

	cout<<res<<endl;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>



using namespace std;



int N;

int A[300005];



int main(){

	scanf("%d", &N);

	for(int i=0;i<3*N;i++){

		scanf("%d", &A[i]);

	}

	sort(A, A+3*N);

	long long tot = 0;

	for(int i=N;i<3*N;i+=2){

		tot += (long long)A[i];

	}

	printf("%lld\n", tot);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

#define INF 1<<30

#define LINF 1LL<<60



int main(void) {

    cin.tie(0); ios::sync_with_stdio(false);

    ll N; cin >> N;

    vector<ll> a(3*N);

    for(auto &in:a)cin >> in;

    sort(a.begin(),a.end());

    ll res = 0;

    for(int i = 0; i < N; i++){

        res += a[3*N - 2*(i+1)];

    }

    cout << res << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>



using namespace std;



int N;

int A[300005];



int main(){

	scanf("%d", &N);

	for(int i=0;i<3*N;i++){

		scanf("%d", &A[i]);

	}

	sort(A, A+3*N);

	long long tot = 0;

	for(int i=N;i<3*N;i+=2){

		tot += (long long)A[i];

	}

	printf("%lld\n", tot);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<complex>

using namespace std;



#define FOR(i,a,b) for (int i = (a); i < (b); i++)

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



#define SZ(a) (int)a.size()

#define ALL(a) a.begin(), a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 3 * 1000 * 100 + 47;



int A[MAX];



int main()

{

	//freopen("in.txt", "r", stdin);

	//freopen("out.txt", "w", stdout);

	//ios::sync_with_stdio(false); cin.tie(0);

	int n;

	cin >> n;

	FOR(i, 0, 3 * n) cin >> A[i];

	sort(A, A + 3 * n);

	reverse(A, A + 3 * n);

	LL s = 0;

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

	{

		s += A[i];

	}



	cout << s << endl;	

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>



using namespace std;



int N;

int A[300005];



int main(){

	scanf("%d", &N);

	for(int i=0;i<3*N;i++){

		scanf("%d", &A[i]);

	}

	sort(A, A+3*N);

	long long tot = 0;

	for(int i=N;i<3*N;i+=2){

		tot += (long long)A[i];

	}

	printf("%lld\n", tot);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<string>

#include<vector>

#include<math.h>

#include<map>

#include<functional>

#include<queue>

#include<stack>

using namespace std;

int main(){

    int n;

    cin>>n;

    int a[364364]={};

    long long int ans=0;

    for(int i=0;i<3*n;i++){

        cin>>a[i];

    }

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

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

        ans+=a[i];

    }

    cout<<ans<<endl;

}   






// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define all(vec) vec.begin(),vec.end()

typedef long long int ll;

typedef pair<int,int> P;

const ll MOD=1000000007;

const ll INF=1000000010;

const ll LINF=4000000000000000010LL;

const int MAX=310;

const double EPS=1e-9;

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

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

int main(){

	int n;cin>>n;

	ll a[300010];

	for(int i=0;i<3*n;i++){

		cin>>a[i];

	}

	sort(a,a+3*n);

	ll ans=0;

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

		ans+=a[i];

	}

	cout<<ans<<endl;

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string>

#include<algorithm>	

#include<cmath>

using namespace std;

int main() {

	long long n, sum = 0; cin >> n;

	int a[300000] = { 0 };

	for (int i = 0; i < n * 3; i++) {

		cin >> a[i];

	}

	sort(a, a + n * 3);

	for (int h = n; h < n * 3; h++) {

		sum += a[h];

		h++;

	}

	cout << sum << endl;

	cin >> n;

}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<string>

#include<algorithm>    

#include<cmath>

#include<map>

#include<vector>

#include<math.h>

#include<stdio.h>

#include<stack>

#include<queue>

#include<tuple>

#include<cassert>

#include<set>

#define int long long

#define mod(int)(1000000007)

using namespace std;

int test[313456];

signed main() {

	int n, m = 0, a, ans = 0; cin >> n;

	for (int h = 0; h < n * 3; h++) {

		cin >> test[h];

	}

	sort(test, test + (n * 3));

	m = (n * 3 - 2) % 2;

	for (int h = n * 3 - 2; h >= n; h--) {

		if (h % 2 == m) {

			ans += test[h];

		}

	}

	cout << ans << endl;

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;



int n;



struct Task

{

    int TimeLong = -1;

    int Limit = -1;

    Task(int timeLong, int limit)

    {

        TimeLong = timeLong;

        Limit = limit;

    }

};

vector<Task> vec;



int main(int argc, char *argv[])

{

    cin >> n;

    for (int i = 0; i < n; ++i)

    {

        int timeLong, limit;

        cin >> timeLong >> limit;

        vec.emplace_back(Task(timeLong, limit));

    }

    sort(vec.begin(), vec.end(), [](Task x, Task y)->bool{

        return x.Limit < y.Limit;

    });

    int sum = 0;

    for (Task item : vec)

    {

        sum += item.TimeLong;

    }

    for (int i = n - 1; i >= 0; --i)

    {

        if (sum > vec[i].Limit)

        {

            cout << "No" << endl;

            return 0;

        }

        sum -= vec[i].TimeLong;

    }

    cout << "Yes" << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

	if(x.b==y.b) return x.a<y.a;

	else return x.b<y.b;

}

int main(){

	int n;

	while(~scanf("%d",&n)){

		for(int i=0;i<n;i++){

			scanf("%d%d",&ss[i].a,&ss[i].b);

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

		for(int i=0;i<n;i++){

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

// Fastest known solution for this problem: