stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.393389443442446x):
#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;

}
// Slower C++ solution:
#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");

    }

  }

}

// Faster C++ solution for the same problem (measured speedup: 5.131231722652573x):
#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");

    }

  }

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.114822563762855x):


#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.122225244508003x):


#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.168522883105258x):


#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.072181758744097x):


#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.08724784196417x):


#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;

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 9.718449676139024x):
#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(3*n);

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

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

  

  ll ans = 0;

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

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

  }

  cout << ans << endl;

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 9.897798696592565x):
#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);

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 10.289467220164713x):
//#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);

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 9.897873314523439x):
#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);

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 10.289467220164713x):
//#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);

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.136172387036437x):
#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);

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.199621606221954x):
#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);

}
// Slower C++ solution:
#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);

}

// Faster C++ solution for the same problem (measured speedup: 5.179216032798463x):
#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);

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 2.17049054491389x):
//#include<cstdio>

//#include<cassert>

//#include<iostream>

//#include<cstring>

//#include<algorithm>

#include<bits/stdc++.h>

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>

#define MAX ((int)1e9 + 5)

#define MAXL ((ll)3e18 + 7)

#define MAX_X ((ll)1e5 + 2)

#define pi (2.0*acos(0))

#define M ((int)1e6 + 7)

#define MOD ((int)1e9 + 7)

#define NN ((int)3e6 + 7)

#define N ((int)3e5 + 5)

#define eps (0)

#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)

#define logn 29

#define endl "\n"

#define mp make_pair

#define BUCK 105

#define RIG ((idx<<1)|1)

#define LEF (idx<<1)

//#define int ll





using namespace std;

using namespace __gnu_pbds;



typedef long long ll;

typedef unsigned long long ull;

typedef unsigned int uint;



/*fast io

ios_base::sync_with_stdio(false);

cin.tie(NULL);

*/









typedef tree < int,  null_type,  less < int >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;

/// o_set s;

/// s.order_of_key(k) : Number of items strictly smaller than k .

/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).



int arr[N];





int main()

{

    fastio;

    int n ;

    cin>>n;

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

        cin>>arr[i];

    }

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

    ll ans = 0;

    for(int i = 3*n - 1 ; i>n ; i -= 2) ans += arr[i];

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 2.194693845086109x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 2.161583439470041x):
#include<bits/stdc++.h>

using namespace std;

typedef long long LL;



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    int n;

    cin >> n;



    int z = n * 3;

    vector< LL >v(z);

    for (int i = 0; i < z; i++) cin >> v[i];



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



    LL ans = 0;

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

        ans += v[j];

    }



    cout << ans << "\n";





    return 0;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 2.1497453157747426x):
#include <bits/stdc++.h>



using namespace std;



typedef long long ll;

typedef pair<int, int> pii;



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

#define fap(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



const int inf = 0x3f3f3f3f;

const ll INF = 2e18;



int main() {

	FastIO;



	int n;

	cin >> n;



	int nn = n * 3;

	vector<int> a(nn);

	for(int &x : a) cin >> x;



	sort(all(a));

	ll res = 0;

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

		res += a[i];

	}

	cout << res << "\n";

	

	return 0;

}