Language: C++

#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <queue>

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue pq;

#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RFOR(i,a,b) for (long i=(b)-1;i>=(a);i--)
#define REP(i,n) for (long i=0;i<(n);i++)
#define RREP(i,n) for (long i=(n)-1;i>=0;i--)

#define MAX 2147483648

#define ALL(a) (a).begin(),a.end()
#define MAXE(a) *max_element(ALL(a))
#define MINE(a) *min_element(ALL(a))

int main(){
	long long N;
	cin >> N;
	long long a[300001];

	REP(i,3*N) cin >> a[i];
	pq <long long ,vl,greater<long long> > left;
	pq <long long ,vl,greater<long long> > right;

	long long kl[300001];//左のkまでの最大値を記録
	long long kr[300001];	
	
	long long tl = 0;
	long long tr = 0;


	/* k */
	// k = N ... 2N
	//  left ... i = 0~k-1までの最大値
	// right ... i = k~3N-1 までの最小値



	//初期解
	REP(i,N) {
		left.push(a[i]);
		tl+=a[i];
	}
	kl[N] = tl;
	FOR(i,N,2*N){
		left.push(a[i]);
		tl+=a[i];
		tl-=left.top();
		left.pop();//leftから最小のものをpopする
		kl[i+1] = tl;
	}

	FOR(i,2*N,3*N) {
		right.push(-a[i]);
		tr-=a[i];
	}
	kr[2*N] = tr;
	for(ll i = 2*N-1;i>=N;i--){
		right.push(-a[i]);
		tr-=a[i];
		tr-=right.top();
		right.pop();
		kr[i] = tr;
	}

	
	long long out = kl[N]+kr[N];
	FOR(i,N+1,2*N){
		out = max(out,kl[i]+kr[i]);
	}


	cout << out << endl;
}

Compiler output:
a.cc:18:9: error: typedef declared 'auto'
   18 | typedef priority_queue pq;
      |         ^~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:37:9: error: invalid template-id
   37 |         pq <long long ,vl,greater<long long> > left;
      |         ^~
a.cc:37:24: error: 'vl' was not declared in this scope; did you mean 'vll'?
   37 |         pq <long long ,vl,greater<long long> > left;
      |                        ^~
      |                        vll
a.cc:38:9: error: invalid template-id
   38 |         pq <long long ,vl,greater<long long> > right;
      |         ^~
a.cc:56:22: error: request for member 'push' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)'
   56 |                 left.push(a[i]);
      |                      ^~~~
a.cc:61:22: error: request for member 'push' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)'
   61 |                 left.push(a[i]);
      |                      ^~~~
a.cc:63:26: error: request for member 'top' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)'
   63 |                 tl-=left.top();
      |                          ^~~
a.cc:64:22: error: request for member 'pop' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)'
   64 |                 left.pop();//leftから最小のものをpopする
      |                      ^~~
a.cc:69:23: error: request for member 'push' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)'
   69 |                 right.push(-a[i]);
      |                       ^~~~
a.cc:74:23: error: request for member 'push' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)'
   74 |                 right.push(-a[i]);
      |                       ^~~~
a.cc:76:27: error: request for member 'top' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)'
   76 |                 tr-=right.top();
      |                           ^~~
a.cc:77:23: error: request for member 'pop' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)'
   77 |                 right.pop();
      |                       ^~~