Language: C++

const fi='';
      fo='';
      oo=trunc(1e18);
      maxn=trunc(1e5);
var   n:longint;
      sol:int64;
      nheapmin,nheapmax:longint;
      heapmax,heapmin:array[0..2*maxn]of longint;
      a:array[0..3*maxn]of longint;
      l,r:array[0..3*maxn]of int64;
function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
procedure swap(var a,b:Longint);
var temp:longint;
begin
      temp:=a;
      a:=b;
      b:=temp;
end;
procedure upmax(i:longint);
begin
      if (i=1)or(heapmax[i div 2]>=heapmax[i]) then exit
      else begin
                  swap(heapmax[i],heapmax[i div 2]);
                  upmax(i div 2);
           end;
end;
procedure upmin(i:longint);
begin
      if (i=1)or(heapmin[i div 2]<=heapmin[i]) then exit
      else begin
                  swap(heapmin[i div 2],heapmin[i]);
                  upmin(i div 2);
           end;
end;
procedure downmax(i:longint);
var gt:longint;
begin
      gt:=i*2;
      if gt>nheapmax then exit;
      if (gt+1<=nheapmax)and(heapmax[gt]<heapmax[gt+1]) then inc(gt);
      if heapmax[i]>=heapmax[gt] then exit;
      begin
                    swap(heapmax[gt],heapmax[i]);
                    downmax(gt);
      end;
end;
procedure downmin(i:longint);
var gt:longint;
begin
      gt:=i*2;
      if gt>nheapmin then exit;
      if (gt+1<=nheapmin)and(heapmin[gt]>heapmin[gt+1]) then inc(gt);
      if heapmin[i]<=heapmin[gt] then exit;
      begin
                  swap(heapmin[gt],heapmin[i]);
                  downmin(gt);
      end;
end;
procedure pushmin(x:longint);
begin
       inc(nheapmin);
       heapmin[nheapmin]:=x;
       upmin(nheapmin);
end;
procedure pushmax(x:longint);
begin
      inc(nheapmax);
      heapmax[nheapmax]:=x;
      upmax(nheapmax);
end;
procedure popmin(x:longint);
begin
      heapmin[1]:=x;
      downmin(1);
end;
procedure popmax(x:longint);
begin
       heapmax[1]:=x;
       downmax(1);
end;
procedure inp;
var i:longint;
begin
      read(n);
      for i:=1 to 3*n do read(a[i]);
end;
procedure main;
var i,j:longint;
    res:int64;
    nmax,nmin:longint;
begin
      res:=0;
      for i:=1 to n do
      begin
          res:=res+a[i];
          pushmin(a[i]);
      end;
      l[n]:=res;
      for i:=n+1 to 2*n do
      begin
          if a[i]>heapmin[1] then
          begin
             res:=res-heapmin[1]+a[i];
             popmin(a[i]);
          end;
          l[i]:=res;
      end;
      res:=0;
      for i:=3*n downto 2*n+1 do
      begin
          res:=res+a[i];
          pushmax(a[i]);
      end;
      r[2*n+1]:=res;
      for i:=2*n downto n+1 do
      begin
          if a[i]<heapmax[1] then
          begin
             res:=res-heapmax[1]+a[i];
             popmax(a[i]);
          end;
          r[i]:=res;
      end;
      sol:=-oo;
      for i:=n to 2*n do sol:=max(sol,l[i]-r[i+1]);
      write(sol);
end;
begin
      assign(input,fi);
      reset(input);
      assign(output,fo);
      rewrite(output);
      inp;
      main;
      close(output);
end.


Compiler output:
a.cc:1:10: error: empty character constant
    1 | const fi='';
      |          ^~
a.cc:2:10: error: empty character constant
    2 |       fo='';
      |          ^~
a.cc:8:29: error: too many decimal points in number
    8 |       heapmax,heapmin:array[0..2*maxn]of longint;
      |                             ^~~~
a.cc:9:15: error: too many decimal points in number
    9 |       a:array[0..3*maxn]of longint;
      |               ^~~~
a.cc:10:17: error: too many decimal points in number
   10 |       l,r:array[0..3*maxn]of int64;
      |                 ^~~~
a.cc:1:7: error: 'fi' does not name a type
    1 | const fi='';
      |       ^~
a.cc:2:7: error: 'fo' does not name a type
    2 |       fo='';
      |       ^~
a.cc:3:7: error: 'oo' does not name a type; did you mean 'bool'?
    3 |       oo=trunc(1e18);
      |       ^~
      |       bool
a.cc:4:7: error: 'maxn' does not name a type
    4 |       maxn=trunc(1e5);
      |       ^~~~
a.cc:5:1: error: 'var' does not name a type
    5 | var   n:longint;
      | ^~~
a.cc:6:10: error: found ':' in nested-name-specifier, expected '::'
    6 |       sol:int64;
      |          ^
      |          ::
a.cc:6:7: error: 'sol' does not name a type
    6 |       sol:int64;
      |       ^~~
a.cc:7:7: error: 'nheapmin' does not name a type
    7 |       nheapmin,nheapmax:longint;
      |       ^~~~~~~~
a.cc:8:7: error: 'heapmax' does not name a type
    8 |       heapmax,heapmin:array[0..2*maxn]of longint;
      |       ^~~~~~~
a.cc:9:8: error: found ':' in nested-name-specifier, expected '::'
    9 |       a:array[0..3*maxn]of longint;
      |        ^
      |        ::
a.cc:9:7: error: 'a' does not name a type
    9 |       a:array[0..3*maxn]of longint;
      |       ^
a.cc:10:7: error: 'l' does not name a type
   10 |       l,r:array[0..3*maxn]of int64;
      |       ^
a.cc:11:1: error: 'function' does not name a type; did you mean 'union'?
   11 | function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
      | ^~~~~~~~
      | union
a.cc:11:32: error: 'begin' does not name a type
   11 | function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
      |                                ^~~~~
a.cc:11:63: error: expected constructor, destructor, or type conversion before '(' token
   11 | function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
      |                                                               ^
a.cc:11:68: error: 'end' does not name a type
   11 | function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
      |                                                                    ^~~
a.cc:12:1: error: 'function' does not name a type; did you mean 'union'?
   12 | function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
      | ^~~~~~~~
      | union
a.cc:12:32: error: 'begin' does not name a type
   12 | function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
      |                                ^~~~~
a.cc:12:63: error: expected constructor, destructor, or type conversion before '(' token
   12 | function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
      |                                                               ^
a.cc:12:68: error: 'end' does not name a type
   12 | function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
      |                                                                    ^~~
a.cc:13:1: error: 'procedure' does not name a type
   13 | procedure swap(var a,b:Longint);
      | ^~~~~~~~~
a.cc:14:1: error: 'var' does not name a type
   14 | var temp:longint;
      | ^~~
a.cc:15:1: error: 'begin' does not name a type
   15 | begin
      | ^~~~~
a.cc:17:7: error: 'a' does not name a type
   17 |       a:=b;
      |       ^
a.cc:18:7: error: 'b' does not name a type
   18 |       b:=temp;
      |       ^
a.cc:19:1: error: 'end' does not name a type
   19 | end;
      | ^~~
a.cc:20:1: error: 'procedure' does not name a type
   20 | procedure upmax(i:longint);
      | ^~~~~~~~~
a.cc:21:1: error: 'begin' does not name a type
   21 | begin
      | ^~~~~
a.cc:25:24: error: expected constructor, destructor, or type conversion before '(' token
   25 |                   upmax(i div 2);
      |                        ^
a.cc:26:12: error: 'end' does not name a type
   26 |            end;
      |            ^~~
a.cc:27:1: error: 'end' does not name a type
   27 | end;
      | ^~~
a.cc:28:1: error: 'procedure' does not name a type
   28 | procedure upmin(i:longint);
      | ^~~~~~~~~
a.cc:29:1: error: 'begin' does not name a type
   29 | begin
      | ^~~~~
a.cc:33:24: error: expected constructor, destructor, or type conversion before '(' token
   33 |                   upmin(i div 2);
      |                        ^
a.cc:34:12: error: 'end' does not name a type
   34 |            end;
      |            ^~~
a.cc:35:1: error: 'end' does not name a type
   35 | end;
      | ^~~
a.cc:36:1: error: 'procedure' does not name a type
   36 | procedure downmax(i:longint);
      | ^~~~~~~~~
a.cc:37:1: error: 'var' does not name a type
   37 | var gt:longint;
      | ^~~
a.cc:38:1: error: 'begin' does not name a type
   38 | begin
      | ^~~~~
a.cc:40:7: error: expected unqualified-id before 'if'
   40 |       if gt>nheapmax then exit;
      |       ^~
a.cc:41:7: error: expected unqualified-id before 'if'
   41 |       if (gt+1<=nheapmax)and(heapmax[gt]<heapmax[gt+1]) then inc(gt);
      |       ^~
a.cc:42:7: error: expected unqualified-id before 'if'
   42 |       if heapmax[i]>=heapmax[gt] then exit;
      |       ^~
a.cc:43:7: error: 'begin' does not name a type
   43 |       begin
      |       ^~~~~
a.cc:45:28: error: expected constructor, destructor, or type conversion before '(' token
   45 |                     downmax(gt);
      |                            ^
a.cc:46:7: error: 'end' does not name a type
   46 |       end;
      |       ^~~
a.cc:47:1: error: 'end' does not name a type
   47 | end;
      | ^~~
a.cc:48:1: error: 'procedure' does not name a type
   48 | procedure downmin(i:longint);
      | ^~~~~~~~~
a.cc:49:1: error: 'var' does not name a type
   49 | var gt:longint;
      | ^~~
a.cc:50:1: error: 'begin' does not name a type
   50 | begin
      | ^~~~~
a.cc:52:7: error: expected unqualified-id before 'if'
   52 |       if gt>nheapmin then exit;
      |       ^~
a.cc:53:7: error: expected unqualified-id before 'if'
   53 |       if (gt+1<=nheapmin)and(heapmin[gt]>heapmin[gt+1]) then inc(gt);
      |       ^~
a.cc:54:7: error: expected unqualified-id before 'if'
   54 |       if heapmin[i]<=heapmin[gt] then exit;
      |       ^~
a.cc:55:7: error: 'begin' does not name a type
   55 |       begin
      |       ^~~~~
a.cc:57:26: error: expected constructor, destructor, or type conversion before '(' token
   57 |                   downmin(gt);
      |                          ^
a.cc:58:7: error: 'end' does not name a type
   58 |       end;
      |       ^~~
a.cc:59:1: error: 'end' does not name a type
   59 | end;
      | ^~~
a.cc:60:1: error: 'procedure' does not name a type
   60 | procedure pushmin(x:longint);
      | ^~~~~~~~~
a.cc:61:1: error: 'begin' does not name a type
   61 | begin
      | ^~~~~
a.cc:63:8: error: 'heapmin' does not name a type
   63 |        heapmin[nheapmin]:=x;
      |        ^~~~~~~
a.cc:64:13: error: expected constructor, destructor, or type conversion before '(' token
   64 |        upmin(nheapmin);
      |             ^
a.cc:65:1: error: 'end' does not name a type
   65 | end;
      | ^~~
a.cc:66:1: error: 'procedure' does not name a type
   66 | procedure pushmax(x:longint);
      | ^~~~~~~~~
a.cc:67:1: error: 'begin' does not name a type
   67 | begin
      | ^~~~~
a.cc:69:7: error: 'heapmax' does not name a type
   69 |       heapmax[nheapmax]:=x;
      |       ^~~~~~~
a.cc:70:12: error: expected constructor, destructor, or type conversion before '(' token
   70 |       upmax(nheapmax);
      |            ^
a.cc:71:1: error: 'end' does not name a type
   71 | end;
      | ^~~
a.cc:72:1: error: 'procedure' does not name a type
   72 | procedure popmin(x:longint);
      | ^~~~~~~~~
a.cc:73:1: error: 'begin' does not name a type
   73 | begin
      | ^~~~~
a.cc:75:14: error: expected constructor, destructor, or type conversion before '(' token
   75 |       downmin(1);
      |              ^
a.cc:76:1: error: 'end' does not name a type
   76 | end;
      | ^~~
a.cc:77:1: error: 'procedure' does not name a type
   77 | procedure popmax(x:longint);
      | ^~~~~~~~~
a.cc:78:1: error: 'begin' does not name a type
   78 | begin
      | ^~~~~
a.cc:80:15: error: expected constructor, destructor, or type conversion before '(' token
   80 |        downmax(1);
      |               ^
a.cc:81:1: error: 'end' does not name a type
   81 | end;
      | ^~~
a.cc:82:1: error: 'procedure' does not name a type
   82 | procedure inp;
      | ^~~~~~~~~
a.cc:83:1: error: 'var' does not name a type
   83 | var i:longint;
      | ^~~
a.cc:84:1: error: 'begin' does not name a type
   84 | begin
      | ^~~~~
a.cc:86:7: error: expected unqualified-id before 'for'
   86 |       for i:=1 to 3*n do read(a[i]);
      |       ^~~
a.cc:87:1: error: 'end' does not name a type
   87 | end;
      | ^~~
a.cc:88:1: error: 'procedure' does not name a type
   88 | procedure main;
      | ^~~~~~~~~
a.cc:89:1: error: 'var' does not name a type
   89 | var i,j:longint;
      | ^~~
a.cc:90:8: error: found ':' in nested-name-specifier, expected '::'
   90 |     res:int64;
      |        ^
      |        ::
a.cc:90:5: error: 'res' does not name a type
   90 |     res:int64;
      |     ^~~
a.cc:91:5: error: 'nmax' does not name a type
   91 |     nmax,nmin:longint;
      |     ^~~~
a.cc:92:1: error: 'begin' does not name a type
   92 | begin
      | ^~~~~
a.cc:94:7: error: expected unqualified-id before 'for'
   94 |       for i:=1 to n do
      |       ^~~
a.cc:97:18: error: expected constructor, destructor, or type conversion before '(' token
   97 |           pushmin(a[i]);
      |                  ^
a.cc:98:7: error: 'end' does not name a type
   98 |       end;
      |       ^~~
a.cc:99:7: error: 'l' does not name a type
   99 |       l[n]:=res