criyle/codenet-compile-errors huggingface dataset:
Language: C++

for (int i=0; i<=h; i++) {
		long long s1=i*w;
		long long s2=0;
		long long s3=0;
		long long last=h-i;
		long long now=0;
		if (last % 2==0) s2=(last/2)*w,now=max(now,(long long)abs(s1-s2));
		else if (w % 2==0) s2=(w / 2)*last,now=max(now,(long long)abs(s1-s2));
		else {
			if (last < w) s2=(w/2)*last,s3=(w/2+1)*last;
			else s2=(w)*(last/2),s3=(w)*(last/2+1);
			now=max((long long)abs(s1-s2),(long long)abs(s1-s3));
			now=max(now,(long long)abs(s2-s3));
		}
		ans=min(ans,now);
	}

Compiler output:
a.cc:1:1: error: expected unqualified-id before 'for'
    1 | for (int i=0; i<=h; i++) {
      | ^~~
a.cc:1:15: error: 'i' does not name a type
    1 | for (int i=0; i<=h; i++) {
      |               ^
a.cc:1:21: error: 'i' does not name a type
    1 | for (int i=0; i<=h; i++) {
      |                     ^
Language: C++

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
#include<queue>
#include<functional>
#define int long long
using namespace std;

signed main() {
	int a, b; cin >> a >> b;
	int ans = LLONG_MAX;
	for (int i = 1; i < a; i++) {
		ans = min(ans, max(b*i, (b - b / 2)*(a - i)) - min(b*i, b / 2 * (a - i)));
	}
	for (int j = 1; j < b; j++) {
		ans = min(ans, max(a*j, (a - a / 2)*(b - j)) - min(a*j, b / 2 * (b - j)));
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:19: error: 'LLONG_MAX' was not declared in this scope
   18 |         int ans = LLONG_MAX;
      |                   ^~~~~~~~~
a.cc:13:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include<functional>
  +++ |+#include <climits>
   13 | #define int long long
Language: C++

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>

using namespace std;

int main() {
  long long h, w;
  scanf("%lld%lld", &h, &w);
  long long ans = LLONG_MAX;
  for (int magic = 0; magic < 2; magic++) {
    swap(h, w);
    for (int i = 1; i < h; i++) {
      long long p1 = i * w;
      {
        long long p2 = (h - i) * (w / 2);
        long long p3 = (h - i) * (w - w / 2);
        ans = min(ans, max(p1, max(p2, p3)) - min(p1, min(p2, p3)));
      }
      {
        long long hh = h - i;
        long long p2 = (hh / 2) * w;
        long long p3 = (hh - hh / 2) * w;
        ans = min(ans, max(p1, max(p2, p3)) - min(p1, min(p2, p3)));
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:19: error: 'LLONG_MAX' was not declared in this scope
   19 |   long long ans = LLONG_MAX;
      |                   ^~~~~~~~~
a.cc:13:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include <numeric>
  +++ |+#include <climits>
   13 |
Language: C++

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

long long arr[100010],N,totalkiri=0,totalkanan=0,tmp;

priority_queue<long long,vector<long long>,greater<long long>> kiri;
priority_queue<long long> kanan;


void Input(){
	cin>>N;
	for(long long i=0; i<N; i++){
		cin>>tmp; kiri.push(tmp); totalkiri+=tmp;
	}
	for(long long i=0; i<N; i++){
		cin>>arr[i];
	}
	for(long long i=0; i<N; i++){
		cin>>tmp; kanan.push(tmp); totalkanan+=tmp;
	}
}

void Solve(){
	long long i=0,j=N-1;
	while(i<=j){
		if(arr[i]-kiri.top()>=kanan.top()-arr[j]){
			totalkiri-=kiri.top(); totalkiri+=arr[i]; 
			kiri.pop(); kiri.push(arr[i]); i++;
		}else if(arr[i]-kiri.top()<kanan.top()-arr[j]){
			totalkanan-=kanan.top(); totalkanan+=arr[j];
			kanan.pop(); kanan.push(arr[j]); j--;
		}else if(arr[i]-kiri.top()<0){
			i++;
		}else if(kanan.top()-arr[j]<0){
			j--;
		}
	}
	cout<<totalkiri-totalkanan<<'\n';
}

long long main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	Input();
	Solve();
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
ll n, a[400000],pref[400000],suf[400000];
signed main(){
	scanf("%lld",&n);
	n*=3; 
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	ll sum=0;
	priority_queue <ll,vector <ll>,greater <ll>> que;
	for(int i=0;i<n;i++){
		que.push(a[i]);
		sum+=a[i];
		if(que.size()>n/3){
			sum-=que.top();
			que.pop();
		}
		pref[i]=sum;
	}
	priority_queue <ll> que2;
	sum=0;
	for(int i=n-1;i>=0;i--)
	{
		que2.push(a[i]);
		sum+=A[i];
		if(que2.size()>n/3)
		{
			sum-=que2.top();
			que2.pop();
		}
		if(i>=1) pref[i-1]-=sum;
	}
	ll ans=pref[n/3-1];
	for(int i=n/3-1;i+n/3<n;i++)ans=max(ans,pref[i]); 
	cout<<ans<<endl; return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:22: error: 'A' was not declared in this scope
   28 |                 sum+=A[i];
      |                      ^
Language: C++

#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
ll n, a[400000],pref[400000],suf[400000];
signed main(){
	scanf("%lld",&n);
	n*=3; 
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	ll sum=0;
	priority_queue <ll,vector <ll>,greater <ll>> que;
	for(int i=0;i<n;i++){
		que.push(a[i]);
		sum+=a[i];
		if(que.size()>n/3){
			sum-=que.top();
			que.pop();
		}
		pref[i]=sum;
	}
	priority_queue <ll> que2;
	sum=0;
	for(int i=n-1;i>=0;i--)
	{
		que2.push(A[i]);
		sum+=A[i];
		if(que2.size()>n/3)
		{
			sum-=que2.top();
			que2.pop();
		}
		if(i>=1) dp[i-1]-=sum;
	}
	ll ans=pref[n/3-1];
	for(int i=n/3-1;i+n/3<n;i++)ans=max(ans,pref[i]); 
	cout<<ans<<endl; return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:27: error: 'A' was not declared in this scope
   27 |                 que2.push(A[i]);
      |                           ^
a.cc:34:26: error: 'dp' was not declared in this scope; did you mean 'dup'?
   34 |                 if(i>=1) dp[i-1]-=sum;
      |                          ^~
      |                          dup
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    vector<pair<ll,ll> > b;
    vector<ll> c;
    for(int i=0;i<n*3;i++)
    {ll x;
    cin>>x;
        if(i<2*n)
        {
            b.push_back(make_pair(x,i);
        }
            c.push_back(x);

    }
sort(b.begin(),b.end());
ll z1=0,ans=0;
for(int i=n;i<2*n;i++)
{
    z1+=b[i].first;
    ans=max(ans,b[i].second);
}
    vector<ll> d;
    ++ans;
    d.assign(c.begin()+ans,c.end());
    sort(d.begin(),d.end());
    ll j=0,z2=0;
   vector<ll>::iterator it; 
    for( it=d.begin();it!=d.end();it++)
    {j++;
    z2+=*it;
    if(j==n)break;
        
    }
    cout<<z1-z2;
    
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:39: error: expected ')' before ';' token
   15 |             b.push_back(make_pair(x,i);
      |                        ~              ^
      |                                       )
Language: C++

#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main () {
  int N;
  cin >> N;
  priority_queue<long long, vector<long long>, greater<long long>>R;
  priority_queue<long long>B;
  vector<long long>R_a(N + 1, 0);
  vector<long long>B_a(N + 1, 0);
  vector<long long>A(N * 3);
  for (int i = 0; i < N * 3; i ++) cin >> A[i];
  for (int i = 0; i < N; i ++) {
    R_a[0] += A[i];
    R.push(A[i]);
  }
  for (int i = 1; i <= N; i ++) {
    int i_ = N - 1 + i;
    R_a[i] = R_a[i - 1] + A[i_];
    R.push(A[i_]);
    R_a[i] -= R.front();
    R.pop();
  }
  for (int i = N * 3 - 1; i >= N * 2; i --) {
    B_a[0] += A[i];
    B.push(A[i]);
  }
  for (int i = 1; i <= N; i ++) {
    int i_ = N * 2 - i;
    B_a[i] = B_a[i - 1] + A[i_];
    B.push(A[i_]);
    B_a[i] -= B.front();
    B.pop();
  }
  long long ans = 1e15;
  ans *= -1;
  for (int i = 0; i <= N; i ++) {
    ans = max(ans, R_a[i] - B_a[i]);
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: 'class std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >' has no member named 'front'
   21 |     R_a[i] -= R.front();
      |                 ^~~~~
a.cc:32:17: error: 'class std::priority_queue<long long int>' has no member named 'front'
   32 |     B_a[i] -= B.front();
      |                 ^~~~~
Language: C++

import heapq
n = int(input())
a = list(map(int,input().split()))
ans = -float("inf")
for k in range(n, 2 * n + 1):
    b = list()
    c = list()
    heapq.heappush(b, a[:k])
    heapq.heappush(c,a[k:])
    b = b[0]
    heapq.heapify(b)
    for i in range(k-n):
        heapq.heappop(b)
    c = list(map(lambda x: x*(-1),c[0]))
    heapq.heapify(c)
    for i in range(2*n-k):
        heapq.heappop(c)
    c = list(map(lambda x: x*(-1),c))
    heapq.heapify(c)
    ans = max(ans, sum(b)-sum(c))
print(ans)






Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import heapq
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

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

	// left
	vl s(2*n+1, 0);
	priority_queue<ll, vl, greater<ll>> que1;
	rep(i,n){
		s[i+1] = s[i] + a[i];
		que1.push(a[i]);
	}
	for(int i = n; i<n*2; i++){
		ll mi = que1.top();
		if(a[i] > mi){
			s[i+1] = s[i] - mi + a[i];
			que1.pop();
			que1.push(mi);
		}
		else s[i+1] = s[i];
	}

	// right
	vl t(2*n+1, 0);
	priority_queue<ll> que2;
	rep(i,n){
		t[i+1] = t[i] + a[3*n-1 - i];
		que2.push(a[3*n-1 - i]);
	}
	for(int i=n; i<2*n; i++){
		ll mi que2.top();
		if(mi > a[3*n-1 -i]){
			t[i+1] = t[i] - mi + a[3*n-1 -i];
			que2.pop();
			que2.push(a[3*n-1 -i]);
		}else{
			t[i+1] = t[i];
		}
	}

	// aggregate
	ll ans = -(1LL<<60);
	for(int i = n; i<2*n; i++){
		ans = max(ans, s[i]-t[3*n-i]);
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:23: error: expected initializer before 'que2'
   42 |                 ll mi que2.top();
      |                       ^~~~
a.cc:43:20: error: 'mi' was not declared in this scope; did you mean 'i'?
   43 |                 if(mi > a[3*n-1 -i]){
      |                    ^~
      |                    i
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define allcout(V)        \
    for(auto x : V) {     \
        cout << x << ' '; \
    }                     \
    cout << endl;
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int N;
    cin >> N;
    int a[3 * N];
    rep(i, 3 * N) cin >> a[i];
    vector<int> left(N + 1), right(N + 1);
    multiset<int> S;
    int sum = 0;
    rep(i, N) {
        S.insert(a[i]);
        sum += a[i];
    }
    left[0] = sum;
    for(int i = N; i <= 2 * N - 1; i++) {
        int m = *S.begin();
        if(a[i] > m) {
            sum = sum - m + a[i];
            S.erase(m);
            S.insert(a[i]);
        }
        left[i - N + 1] = sum;
    }.

    multiset<int> SS;
    sum = 0;
    for(int i = N * 3 - 1; i >= N * 2; i--) {
        SS.insert(a[i]);
        sum += a[i];
    }
    right[N] = sum;
    for(int i = N * 2 - 1; i >= N; i--) {
        int m = *(--SS.end());
        if(a[i] < m) {
            sum = sum - m + a[i];
            SS.erase(m);
            SS.insert(a[i]);
        }
        right[i - N] = sum;
    }

    int ans = -INF;
    rep(i, N + 1) ans = max(ans, left[i] - right[i]);
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:6: error: expected primary-expression before '.' token
   50 |     }.
      |      ^
a.cc:52:5: error: invalid use of 'class std::multiset<long long int>'
   52 |     multiset<int> SS;
      |     ^~~~~~~~~~~~~
a.cc:55:9: error: 'SS' was not declared in this scope; did you mean 'S'?
   55 |         SS.insert(a[i]);
      |         ^~
      |         S
a.cc:60:21: error: 'SS' was not declared in this scope; did you mean 'S'?
   60 |         int m = *(--SS.end());
      |                     ^~
      |                     S
Language: C++

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

void solve()
{
    long long int n,sum1=0,sum2=0;
    cin>>n;
    
    long long int l[n],m[n],r[n];
    
    for(int i=0;i<n;i++)
        cin>>l[i];
    
    for(int i=0;i<n;i++)
        cin>>m[i];
    
    for(int i=0;i<n;i++)
        cin>>r[i];
        
    int e=0;
    
    int a=0,b=0;
    
    while(e<n)
    {
        if(l[a]>=m[b])
            sum1+=l[a++];
        else
            sum1+=m[b++];
        e++;
    }
    
    e=0;
    
    a=0;
    
    while(e<n)
    {
        if(b<n&& m[b]<=r[a])
            sum2+=m[b++];
        else
            sum2+=r[a++];
        e++;
    }
    cout<<(sum1-sum2)<<endl;
}


int main()
{
    int t=1;
    //cin>>t;
    
    while(t--)
        solve();

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

void solve()
{
    long long int n,sum1=0,sum2=0;
    cin>>n;
    
    long long int l[n],m[n],r[n];
    
    for(int i=0;i<n;i++)
        cin>>l[i];
    
    for(int i=0;i<n;i++)
        cin>>m[i];
    
    for(int i=0;i<n;i++)
        cin>>r[i];
        
    int e=0;
    
    int a=0,b=0;
    
    while(e<n)
    {
        if(l[a]>=m[b])
            sum1+=l[a++];
        else
            sum1+=m[b++];
        e++;
    }
    
    e=0;
    
    a=0;
    
    while(e<n)
    {
        if(b<n&& m[b]<=r[a])
            sum2+=m[b++];
        else
            sum2+=r[a++];
        e++;
    }
    cout<<(sum1-sum2)<<endl;
}


int main()
{
    int t=1;
    //cin>>t;
    
    while(t--)
        solve();

    return 0;
}


Compiler output:
a.cc:62:6: error: redefinition of 'void solve()'
   62 | void solve()
      |      ^~~~~
a.cc:4:6: note: 'void solve()' previously defined here
    4 | void solve()
      |      ^~~~~
a.cc:107:5: error: redefinition of 'int main()'
  107 | int main()
      |     ^~~~
a.cc:49:5: note: 'int main()' previously defined here
   49 | int main()
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef vector<int > vecint;
typedef vector<vector<int > > vec2int;
typedef vector<bool > vecbool;
typedef vector<string > vecstr;
////////////////////////////////////////////////
int main()
{
  int n;
  cin >> n;
  int n3 = 3*n;
  priority_queue<int, vecint, greater<int> > q1;
  priority_queue<int> q2;

  vecint a(n3);
  vecll sum1(n + 1,0);// [0,i + n - 1]
  vecll sum2(n + 1,0);// [3n - i,3n] 0<= i <= n
  int tmp;
  REP(i,n3){
    cin >> tmp;
    a[i] = tmp;
    if(i < n){
      q1.push(tmp);
      sum1[0] += tmp;
    }else if(2*n <= i){
      q2.push(tmp);
      sum2[n] += tmp;
    }
  }
  //////initial

  /// sum1
  for(int k = n;k < 2*n; k ++){

    tmp = q1.top();q1.pop();
    if(tmp <= a[k]){
      // tmp remove (push a[k])
      q1.push(a[k]);
      sum1[k - n + 1] = sum1[k - n] + a[k] - tmp;
    }else{
      // tmp remain (deny a[k])
      q1.push(tmp);
      sum1[k - n + 1] = sum1[k - n];
    }
  }
  // REP(i,n + 1){
  //   cout << sum1[i] << endl;
  // }

  // sum2
  for(int k = 2*n - 1;k >= n; k --){
    tmp = q2.top();q2.pop();
    if(tmp >= a[k]){
      // tmp remove (push a[k])
      q2.push(a[k]);
      sum2[k - n] = sum2[k - n + 1] + a[k] - tmp;
    }else{
      // tmp remain (deny a[k])
      q2.push(tmp);
      sum2[k - n] = sum2[k - n + 1];
    }
  }
  

  ll ans = sum1[0] - sum2[0];
  REP(i, n + 1){
    ans = max(ans, sum1[i] - sum2[i]);
  }
  cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:21:3: error: 'vecll' was not declared in this scope
   21 |   vecll sum1(n + 1,0);// [0,i + n - 1]
      |   ^~~~~
a.cc:22:8: error: expected ';' before 'sum2'
   22 |   vecll sum2(n + 1,0);// [3n - i,3n] 0<= i <= n
      |        ^~~~~
      |        ;
a.cc:29:7: error: 'sum1' was not declared in this scope
   29 |       sum1[0] += tmp;
      |       ^~~~
a.cc:32:7: error: 'sum2' was not declared in this scope
   32 |       sum2[n] += tmp;
      |       ^~~~
a.cc:44:7: error: 'sum1' was not declared in this scope
   44 |       sum1[k - n + 1] = sum1[k - n] + a[k] - tmp;
      |       ^~~~
a.cc:48:7: error: 'sum1' was not declared in this scope
   48 |       sum1[k - n + 1] = sum1[k - n];
      |       ^~~~
a.cc:61:7: error: 'sum2' was not declared in this scope
   61 |       sum2[k - n] = sum2[k - n + 1] + a[k] - tmp;
      |       ^~~~
a.cc:65:7: error: 'sum2' was not declared in this scope
   65 |       sum2[k - n] = sum2[k - n + 1];
      |       ^~~~
a.cc:70:12: error: 'sum1' was not declared in this scope
   70 |   ll ans = sum1[0] - sum2[0];
      |            ^~~~
a.cc:70:22: error: 'sum2' was not declared in this scope
   70 |   ll ans = sum1[0] - sum2[0];
      |                      ^~~~
Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  vll h(n);
  vll d(n);
  ll cu=0;
  ll ccu=0;
  PQR M;
  PQ B;
  rep(i,3*n){
    cin>>a[i];
    if(i<n) {
      cu+=a[i];
      M.pu(a[i]);
    }
    else if(i>=2*n){
      ccu+=a[i];
      B.pu(a[i]);
    }
  }
  h.pb(cu);
  d.pb(ccu);
  for(int i=n;i<2*n;i++){
    cu+=a[i];
    M.pu(a[i]);
    cu-=M.top();
    M.pop();
    h.pb(cu);
  }
  for(int i=2*n;i<3*n;i++){
    ccu+=a[i];
    B.pb(a[i]);
    ccu-=B.top();
    B.pop();
    d.pb(ccu);
  }
  ll ans=0;
  rep(i,n+1){
    ans=max(ans,h[i]-d[n-i]);
  }
  COUT(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:12: error: 'class std::priority_queue<long long int>' has no member named 'push_back'
   15 | #define pb push_back
      |            ^~~~~~~~~
a.cc:72:7: note: in expansion of macro 'pb'
   72 |     B.pb(a[i]);
      |       ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

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

    int n;
    cin >> n;
    vector<ll> a(3 * n), s(n), t(n), u(n);
    rep(i, 0, 3 * n) cin >> a[i];
    ll ans = 0, sum;
    rep(i, 0, n) {
        s[i] = a[i];
        t[i] = a[i + n];
        u[i] = a[i + 2 * n];
        ans += s[i] - u[i];
    }
    sort(s.begin(), s.end());
    sort(u.rbegin(), u.rend());
    rep(i, 0, n) {
        s[i] = t[i] - s[i];
        u[i] -= t[n - 1 - i];
    }
    rep(i, 1, n) {
        s[i] += s[i - 1];
        u[i] += u[i - 1];
    }
    //debug(s), debug(u);
    rep(i, 1, n) {
        s[i] = max(s[i], s[i - 1]);
        u[i] = max(u[i], u[i - 1]);
    }
    sum = max(s[n - 1], u[n - 1]);
    rep(i, 0, n - 1) {
        sum = max(sum, s[i] + u[n - 2 - i]);
    }
    sum = max(sum, 0);
    cout << ans + sum << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:14: error: no matching function for call to 'max(ll&, int)'
   41 |     sum = max(sum, 0);
      |           ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:41:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   41 |     sum = max(sum, 0);
      |           ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:41:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   41 |     sum = max(sum, 0);
      |           ~~~^~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
ll prev[500010];
ll suf[500010];
ll a[500010];
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll,vector<ll>,greater<ll> > p;
ll n;
int main(){
	cin>>n;
	for(int i=0;i<3*n;i++)cin>>a[i];
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
		q.push(a[i]);
	}
	prev[n-1]=sum;
	for(int i=n;i<2*n;i++){
		sum+=a[i];
		q.push(a[i]);
		sum-=q.top();
		q.pop();
		prev[i]=sum;
	}
	sum=0;
	for(int i=3*n-1;i>=2*n;i--){
		sum+=a[i];
		p.push(-a[i]);
	}
	suf[2*n]=sum;
	for(int i=2*n-1;i>=n;i--){
		sum+=a[i];
		p.push(-a[i]);
		sum-=-p.top();
		p.pop();
		suf[i]=sum;
	}
	ll mx=-LLINF;
	for(int i=n-1;i<2*n;i++){
		mx=max(mx,prev[i]-suf[i+1]);
	}
	cout<<mx<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: reference to 'prev' is ambiguous
   20 |         prev[n-1]=sum;
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:6:4: note:                 'll prev [500010]'
    6 | ll prev[500010];
      |    ^~~~
a.cc:26:17: error: reference to 'prev' is ambiguous
   26 |                 prev[i]=sum;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:6:4: note:                 'll prev [500010]'
    6 | ll prev[500010];
      |    ^~~~
a.cc:43:27: error: reference to 'prev' is ambiguous
   43 |                 mx=max(mx,prev[i]-suf[i+1]);
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:6:4: note:                 'll prev [500010]'
    6 | ll prev[500010];
      |    ^~~~
Language: C++

#include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
ll prev[500010];
ll suf[500010];
ll a[500010];
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll,vector<ll>,greater<ll> > p;
ll n;
void run(){
	cin>>n;
	for(int i=0;i<3*n;i++)cin>>a[i];
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
		q.push(a[i]);
	}
	prev[n-1]=sum;
	for(int i=n;i<2*n;i++){
		sum+=a[i];
		q.push(a[i]);
		sum-=q.top();
		q.pop();
		prev[i]=sum;
	}
	sum=0;
	for(int i=3*n-1;i>=2*n;i--){
		sum+=a[i];
		p.push(-a[i]);
	}
	suf[2*n]=sum;
	for(int i=2*n-1;i>=n;i--){
		sum+=a[i];
		p.push(-a[i]);
		sum-=-p.top();
		p.pop();
		suf[i]=sum;
	}
	ll mx=-LLINF;
	for(int i=n-1;i<2*n;i++){
		mx=max(mx,prev[i]-suf[i+1]);
	}
	cout<<mx<<endl;
}
int main(){
	run();
	return 0;
}


Compiler output:
a.cc: In function 'void run()':
a.cc:20:9: error: reference to 'prev' is ambiguous
   20 |         prev[n-1]=sum;
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:6:4: note:                 'll prev [500010]'
    6 | ll prev[500010];
      |    ^~~~
a.cc:26:17: error: reference to 'prev' is ambiguous
   26 |                 prev[i]=sum;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:6:4: note:                 'll prev [500010]'
    6 | ll prev[500010];
      |    ^~~~
a.cc:43:27: error: reference to 'prev' is ambiguous
   43 |                 mx=max(mx,prev[i]-suf[i+1]);
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:6:4: note:                 'll prev [500010]'
    6 | ll prev[500010];
      |    ^~~~
Language: C++

#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int n,a[300005];
priority_queue<int> res;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=0;i<3*n;i++)
	{
		cin>>a[i];
	}
	for (int i=n-1;i<2n;i++)
	{
		priority_queue<int,vector<int>,greater<int> > ql;
		priority_queue<int> qr;
		int pr;
		for (int j=0;j<=i;j++)
		{
			ql.push(a[j]);
		}
		for (int j=i+1;j<3*n;j++)
		{
			qr.push(a[j]);
		}
		for (int j=1;j<=ql.size()-n;j++)
		{
			ql.pop();
		}
		for (int j=1;j<=qr.size()-n;j++)
		{
			qr.pop();
		}
		for (int j=0;j<ql.size();j++)
		{
			pr+=ql.top();
			ql.pop();
		}
		for (int j=0;j<qr.size();j++)
		{
			pr-=qr.top();
			qr.pop;
		}
		res.push(pr);
	}
	cout<<res.top();
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:26: error: unable to find numeric literal operator 'operator""n'
   15 |         for (int i=n-1;i<2n;i++)
      |                          ^~
a.cc:44:28: error: invalid use of non-static member function 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>]'
   44 |                         qr.pop;
      |                         ~~~^~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:771:7: note: declared here
  771 |       pop()
      |       ^~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int N; cin >> N;
    vector<long long> a(N*3);
    for (int i = 0; i < N*3; ++i) cin >> a[i];

    // 左から前処理
    vector<long long> S(N*2+1, 0);
    priority_queue<long long, vector<long long>, greater<long long> > que1;
    for (int i = 0; i < N; ++i) {
        S[i+1] = S[i] + a[i];
        que1.push(a[i]);
    }
    for (int i = N; i < 2 * N; i++) {
        que1.push(a.at(i));
        ll mi = que1.top();
        que1.pop();
        S.at(i + 1) = S.at(i) + a.at(i) - mi;
    }

    // 右から前処理
    vector<long long> T(N*2+ 1, 0);
    priority_queue<long long> que2;
    for (int i = 0; i < N; ++i) {
        T[i+1] = T[i] + a[N*3-1 - i];
        que2.push(a[N*3-1 - i]);
    }
    for (int i = N; i < 2 * N; i++) {
        que2.push(a.at(3 * N - 1 - i));
        ll ma = que2.top();
        que2.pop();
        T.at(i + 1) = T.at(i) + a.at(3 * N - 1 - i) - ma;
    }

    // 集計
    long long res = -(1LL<<60);
    for (int i = N; i <= N*2; ++i) {
        res = max(res, S[i] - T[N*3-i]);
    }
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'll' was not declared in this scope
   20 |         ll mi = que1.top();
      |         ^~
a.cc:22:43: error: 'mi' was not declared in this scope; did you mean 'i'?
   22 |         S.at(i + 1) = S.at(i) + a.at(i) - mi;
      |                                           ^~
      |                                           i
a.cc:34:9: error: 'll' was not declared in this scope
   34 |         ll ma = que2.top();
      |         ^~
a.cc:36:55: error: 'ma' was not declared in this scope; did you mean 'a'?
   36 |         T.at(i + 1) = T.at(i) + a.at(3 * N - 1 - i) - ma;
      |                                                       ^~
      |                                                       a
Language: C++

#include <bits/stdc++.h>

using namespace std;


int main(){
    int n;
    cin >> n;
    if(n>1000){
      return 0;
    }
    vector<int> a(3*n);
    for(int i=0;i<3*n;i++){
        cin >> a[i];
    }
    long long  m=INF;
    for(int i=0;i<n+1;i++){
        priority_queue<int> p;
        priority_queue<int,vector<int>,greater<int>> q;
        long long  sum1=0;
        long long sum2=0;
        for(int j=0;j<n+i;j++){
            p.push(a[j]);
        }
        for(int j=n+i;j<3*n;j++){
            q.push(a[j]);
        }
        for(int j=0;j<n;j++){
            sum1+=p.top();
            p.pop();
            sum2+=q.top();
            q.pop();
        }
        if(i==0){
          m=sum1-sum2;
        }
        m=max(m,sum1-sum2);
        
    }
    cout << m << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:18: error: 'INF' was not declared in this scope
   16 |     long long  m=INF;
      |                  ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int INF=-1000000000

int main(){
    int n;
    cin >> n;
    if(n>1000){
      return 0;
    }
    vector<int> a(3*n);
    for(int i=0;i<3*n;i++){
        cin >> a[i];
    }
    long long  m=INF;
    for(int i=0;i<n+1;i++){
        priority_queue<int> p;
        priority_queue<int,vector<int>,greater<int>> q;
        long long  sum1=0;
        long long sum2=0;
        for(int j=0;j<n+i;j++){
            p.push(a[j]);
        }
        for(int j=n+i;j<3*n;j++){
            q.push(a[j]);
        }
        for(int j=0;j<n;j++){
            sum1+=p.top();
            p.pop();
            sum2+=q.top();
            q.pop();
        }
        m=max(m,sum1-sum2);
        
    }
    cout << m << endl;
}


Compiler output:
a.cc:7:1: error: expected ',' or ';' before 'int'
    7 | int main(){
      | ^~~
Language: C++


#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N; cin >> N;
    vector<long long> a(N*3);
    for (int i = 0; i < N*3; ++i) cin >> a[i];

    // 左から前処理
    vector<long long> S(N*2+1, 0);
    priority_queue<long long, vector<long long>, greater<long long >> que1;
    for(int i = 0; i < N; ++i) {
        S[i+1] = S[i] + a[i];
        que1.push(a[i]);
    }

    for(int i = N; i < N*2; ++i) {
        long long mi = que1.top();
        if (a[i] > mi) {
            S[i+1] = S[i] - mi + a[i];
            que1.pop();
            que1.push(a[i]);
        }
        else  S[i+1] = S[i];
    }

    // 右から前処理
    vector<long long> T(N*2+1, 0);
    priority_queue<long long> que2;
    for(int i = 0; i < N; ++i) {}
    T[i+1] = T[i] + a[N*3-1-i];
    que2.push(a[N*3-1-i]);

    for(int i = N; i < N*2: ++i) {
        long long ma = que2.top();
        if (a[N*3-1-i] < ma) {
            T[i+1] = T[i] - ma + a[N*3-1-i];
            que2.pop();
            que2.push(a[N*3-1-i]);
        }
        else T[i+1] = T[i];
    }

    long long res = -(1LL<<60);
    for (int i = N; i <= N*2; ++i) {
        res = max(res, S[i] - T[N*3-i]);
    }

    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:7: error: 'i' was not declared in this scope
   42 |     T[i+1] = T[i] + a[N*3-1-i];
      |       ^
a.cc:45:20: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   45 |     for(int i = N; i < N*2: ++i) {
      |                    ^
a.cc:45:27: error: expected ';' before ':' token
   45 |     for(int i = N; i < N*2: ++i) {
      |                           ^
      |                           ;
a.cc:56:5: error: expected primary-expression before 'for'
   56 |     for (int i = N; i <= N*2; ++i) {
      |     ^~~
a.cc:55:32: error: expected ')' before 'for'
   55 |     long long res = -(1LL<<60);
      |                                ^
      |                                )
   56 |     for (int i = N; i <= N*2; ++i) {
      |     ~~~                         
a.cc:45:8: note: to match this '('
   45 |     for(int i = N; i < N*2: ++i) {
      |        ^
a.cc:60:13: error: 'res' was not declared in this scope; did you mean 'rep'?
   60 |     cout << res << endl;
      |             ^~~
      |             rep
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n)    for(int i = 0; i < (int)n; i++)
#define MAX_N   100000
#define INF LLONG_MAX
typedef long long   ll;

ll ans = -INF;
int n;
ll a[3*MAX_N];

void solver(priority_queue<ll, vector<ll>, greater<ll> > que_front, priority_queue<ll> que_back, int i){
        ll rep = 0;
        REP(j,i){
            if(a[n + j] > que_front.top()){
                que_front.pop();
                que_front.push(a[n + j]);
            }
        }
        REP(j,n - i){
            if(a[n + i + j] < que_back.top()){
                que_back.pop();
                que_back.push(a[n + i + j]);
            }
        }
        REP(j,n){
            rep += que_front.top() - que_back.top();
            que_front.pop();
            que_back.pop();
        }
        ans = max(ans, rep);
}

void solve(){
    priority_queue<ll, vector<ll>, greater<ll> > que_front;
    priority_queue<ll> que_back;
    cin >> n;
    REP(i,n){
        cin >> a[i];
        que_front.push(a[i]);
    }
    REP(i,n){
        cin >> a[n + i];
    }
    REP(i,n){
        cin >> a[2 * n + i];
        que_back.push(a[2 * n + i]);
    }
    REP(i, n)
        solver(que_front, que_back, i);
    cout << ans << endl;
}

int main(){
    solve();
    return 0;
}

Compiler output:
a.cc:9:13: error: 'LLONG_MAX' was not declared in this scope
    9 | #define INF LLONG_MAX
      |             ^~~~~~~~~
a.cc:12:11: note: in expansion of macro 'INF'
   12 | ll ans = -INF;
      |           ^~~
a.cc:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<set>
#include <iomanip>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
#define MOD 1000000007
int main(){
    int n;cin>>n;
    vector<ll> a(3*n);
    for(int i=0;i<3*n;i++)cin>>a[i];
    priority_queue<ll> mque;
    priority_queue<ll,vector<ll>,greater<ll>> que;
    vector<ll> Lmax(3*n,0),Rmin(3*n,0);
    for(int i=0;i<n;i++){
        Lmax[n]+=a[i];//右半開
        que.push(a[i]);
    }
    for(int i=2*n;i<3*n;i++){
        Rmin[2*n]+=a[i];//右半開
        mque.push(a[i]);
    }
    for(int i=n;i<2*n;i++){
        if(a[i]>que.top()){
        Lmax[i+1]=Lmax[i]+a[i]-que.top();
        que.pop();
        que.push(a[i]);
        }
        else{
            Lmax[i+1]=Lmax[i];
        }
    }
    for(int i=2*n-1;i>=n;i--){
        if(a[i]<mque.top()){
        Rmin[i]=Rmin[i+1]+a[i]-mque.top();
        mque.pop();
        mque.push(a[i]);
        }
        else{
            Rmin[i]=Rmin[i+1];
        }
    }
    ll ans=LLONG_MIN;
    for(int i=n;i<=2*n;i++){
        //cout<<Lmax[i]<<endl;
        //cout<<Rmin[i]<<endl;
        ans=max(ans,Lmax[i]-Rmin[i]);
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:12: error: 'LLONG_MIN' was not declared in this scope
   49 |     ll ans=LLONG_MIN;
      |            ^~~~~~~~~
a.cc:11:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include<stack>
  +++ |+#include <climits>
   11 | typedef long long ll;
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, sta, n) for (int i = sta; i < (n); ++i)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
const int mod = 1000000007;

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

    vector<ll> lsum(n+1);
    vector<ll> rsum(n+1);

    // まず左から
    priority_queue<ll, vector<ll>, greater<ll> > lp;
    ll now_lsum = 0;
    rep(i, n) {
        now_lsum += a[i];
        lp.push(a[i]);
    }
    rep(i, n+1) {
        lsum[i] = now_lsum;
        ll new_l = a[n+i];
        lp.push(new_l);

        ll pop_l = lp.top();
        lp.pop();
        now_lsum = now_lsum + new_l - pop_l;
    }
    //rep(i, n+1) cout << lsum[i] << endl;

    // 次は右
    priority_queue<ll> rp;
    ll now_rsum = 0;
    rep(i, n) {
        now_rsum += a[2*n+i];
        rp.push(a[2*n+i]);
    }
    for(int i = n; i>=0; --i) {
        rsum[i] = now_rsum;
        ll new_r = a[n+i-1];
        rp.push(new_r);

        ll pop_r = rp.top();
        rp.pop();
        now_rsum = now_rsum + new_r - pop_r;
    }
    
    //rep(i, n+1) cout << "right sum: " << rsum[i] << endl;
    ll ans = LLONG_MIN;
    rep(i, n+1) {
        ans = max(lsum[i]-rsum[i], ans);
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:14: error: 'LLONG_MIN' was not declared in this scope
   64 |     ll ans = LLONG_MIN;
      |              ^~~~~~~~~
a.cc:8:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include <map>
  +++ |+#include <climits>
    8 |
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  long long a[3*n+1];//1-indexedで考える
  REPP(i,3*n){
    cin>>a[i];
  }
  
  long long fs[2*n+1];//n~2*nの範囲だけ使う
  long long bs[3*n+1];//(n+1)~(2*n+1)の範囲だけ使う
  
  priority_queue<long long,vector<long long>,greater<long long>> fq;
  priority_queue<long long> bq;
  
  fs[n] = 0;
  bs[2*n+1] = 0;
  REPP(i,n){
    fs[n] += a[i];
    fq.push(a[i]);
  }
  for(int i=2*n+1;i<=3*n;i++){
    bs[2*n+1] += a[i];
    bq.push(a[i]);
  }
  
  for(int i=n+1;i<=2*n;i++){
    if(fq.top()<a[i]){
      fs[i] = fs[i-1]+a[i]-fq.top();
      fq.pop();
      fq.push(a[i]);
    }else{
      fs[i] = fs[i-1];
    }
  }
  
  for(int i=2*n;i>=n+1;i--){
    if(bq.top()>a[i]){
      bs[i] = bs[i+1]-bq.top()+a[i];
      bq.pop();
      bq.push(a[i]);
    }else{
      bs[i] = bs[i+1];
    }
  }
  
  long long ans = -INF;
  REPP(int i=n;i<=2*n;i++){
    ans = max(ans, fs[i]-bs[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc:136:26: error: macro "REPP" requires 2 arguments, but only 1 given
  136 |   REPP(int i=n;i<=2*n;i++){
      |                          ^
a.cc:3:9: note: macro "REPP" defined here
    3 | #define REPP(i,n) for(int i=1;i<=n;i++)
      |         ^~~~
a.cc: In function 'int main()':
a.cc:136:3: error: 'REPP' was not declared in this scope
  136 |   REPP(int i=n;i<=2*n;i++){
      |   ^~~~
Language: C

#include<iostream>
#include <vector>
#include <queue>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
int main(){
	int n; scanf("%d",&n);
	vector<int> a(3*n);
	rep(i,3*n) scanf("%d",&a[i]);
	
	priority_queue<int,vector<int>,greater<int>> q1;
	priority_queue<int> q2;
	
	vector<long long> c1(n+1),c2(n+1);
	long long s  = 0;
	rep(i,3*n){
		int x = a[i];
		if(i < n-1){
			q1.push(x);
			s+=x;
		}else if(i < 2*n){
			s+=x;
			q1.push(x);
			if(i != n-1){
				int y = q1.top();
				q1.pop();
				s-=y;
			}
			c1[i-(n-1)] = s;  
		}
		//cout << s << endl;
	}
	s = 0;
	rep(i,3*n){
		int x = a[3*n - 1 - i];
		if(i < n-1){
			q2.push(x);
			s+=x;
		}else if(i < 2*n){
			s+=x;
			q2.push(x);
			if(i != n-1){
				int y = q2.top();
				q2.pop();
				s-=y;
			}
			c2[i-(n-1)] = s;
		}
		//cout << s << endl;
	}
	//for(auto i : c1) cerr << i << endl;
	vector<long long> sum(n);
	rep(i,n+1){
		//cout << c1[i] << " " << c2[n-i] << endl;
		sum[i] = c1[i] - c2[n-i];
	}
	sort(sum.begin(),sum.end());
	cout << sum[n-1] << endl;
	return 0;
}


Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
int main(){
	int n; scanf("%d",&n);
	vector<int> a(3*n);
	rep(i,3*n) scanf("%d",&a[i]);
	
	priority_queue<int,vector<int>,greater<int>> q1;
	priority_queue<int> q2;
	
	vector<long long> c1(n+1),c2(n+1);
	long long s  = 0;
	rep(i,3*n){
		int x = a[i];
		if(i < n-1){
			q1.push(x);
			s+=x;
		}else if(i < 2*n){
			s+=x;
			q1.push(x);
			if(i != n-1){
				int y = q1.top();
				q1.pop();
				s-=y;
			}
			c1[i-(n-1)] = s;  
		}
		//cout << s << endl;
	}
	s = 0;
	rep(i,3*n){
		int x = a[3*n - 1 - i];
		if(i < n-1){
			q2.push(x);
			s+=x;
		}else if(i < 2*n){
			s+=x;
			q2.push(x);
			if(i != n-1){
				int y = q2.top();
				q2.pop();
				s-=y;
			}
			c2[i-(n-1)] = s;
		}
		//cout << s << endl;
	}
	//for(auto i : c1) cerr << i << endl;
	vector<long long> sum(n);
	rep(i,n+1){
		//cout << c1[i] << " " << c2[n-i] << endl;
		sum[i] = c1[i] - c2[n-i];
	}
	sort(sum.begin(),sum.end());
	cout << sum[n-1] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   57 |         sort(sum.begin(),sum.end());
      |         ^~~~
      |         short
Language: C++

#include<iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
int main(){
	int n; scanf("%d",&n);
	vector<int> a(3*n);
	rep(i,3*n) scanf("%d",&a[i]);
	
	priority_queue<int,vector<int>,greater<int>> q1;
	priority_queue<int> q2;
	
	vector<int> c1(n+1),c2(n+1);
	long long s  = 0;
	rep(i,3*n){
		int x = a[i];
		if(i < n-1){
			q1.push(x);
			s+=x;
		}else if(i < 2*n){
			s+=x;
			q1.push(x);
			if(i != n-1){
				int y = q1.top();
				q1.pop();
				s-=y;
			}
			c1[i-(n-1)] = s;  
		}
		//cout << s << endl;
	}
	s = 0;
	rep(i,3*n){
		int x = a[3*n - 1 - i];
		if(i < n-1){
			q2.push(x);
			s+=x;
		}else if(i < 2*n){
			s+=x;
			q2.push(x);
			if(i != n-1){
				int y = q2.top();
				q2.pop();
				s-=y;
			}
			c2[i-(n-1)] = s;
		}
		//cout << s << endl;
	}
	//for(auto i : c1) cerr << i << endl;
	vector<int> sum(n);
	rep(i,n+1){
		//cout << c1[i] << " " << c2[n-i] << endl;
		sum[i] = c1[i] - c2[n-i];
	}
	sort(sum.begin(),sum.end());
	cout << sum[n-1] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   57 |         sort(sum.begin(),sum.end());
      |         ^~~~
      |         short