Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> ii;
 
const int N = 1e5 + 5;
 
multiset <int> l1,l2,r1,r2;
multiset <int> :: iterator it,it2;
 
int x,y,z,n,a[N],b[N],c[N],id[N];
ll suml,sumr,sumc,ans,nice;
 
void add_l(int x){
  if (l1.size() < ::x) {
    suml += a[x];
    l1.insert(-a[x]);
  }
  else {
    it = l1.rbegin();
    if (-*it < a[x]) {
      suml += a[x];
      suml -= -*it;
      l2.insert(*it);
      l1.erase(iit);
      l1.insert(-a[x]);
    }
    else
      l2.insert(-a[x]);
  }
}
 
void add_r(int x) {
  if (r1.size() < y) {
    sumr += b[x];
    r1.insert(-b[x]);
  }
  else {
    it = r1.rbegin();
    if (-*it < b[x]) {
      sumr += b[x];
      sumr -= -*it;
      r2.insert(*it);
      r1.erase(it);
      r1.insert(-b[x]);
    }
    else
      r2.insert(-b[x]);
  }
}
 
void remove_r(int x) {
  if (r2.empty()) {
    if (r1.empty())
      break;
    it = r1.find(-b[x]);
    if (it != r1.end()) {
      sumr -= -*it;
      r1.erase(it);
    }
  }
  else {
    it = r2.find(-b[x]);
    if (it != r2.end()) {
      r2.erase(it);
      return;
    }
    it = r1.find(-b[x]);
    if (it != r1.end()) {
      sumr -= -*it;
      r1.erase(it);
      if (r2.empty() == false) {
        it2 = r2.begin();
        sumr += -*it2;
        r1.insert(*it2);
        r2.erase(it2);
      }
    }
  }
}
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> x >> y >> z;
  n = x + y + z;
  for (int i = 1 ; i <= n ; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] -= c[i];
    b[i] -= c[i];
    nice += c[i];
    id[i] = i;
  }
  sort(id + 1,id + n + 1,[&](int x,int y) {
    if (a[x] - b[x] == a[y] - b[y])
      return a[x] >= a[y];
    return a[x] - b[x] > a[y] - b[y];
  });
  for (int i = 1 ; i <= x ; i++)
    add_l(id[i]);
  for (int i = x + 1 ; i <= n ; i++)
    add_r(id[i]);
  ans = suml + sumr;
  for (int i = x + 1 ; i <= n ; i++) {
    if (n - i < y)
      break;
    add_l(id[i]);
    remove_r(id[i]);
    ans = max(ans,suml + sumr);
  }
  cout << ans + nice << "\n";
}

Compiler output:
a.cc:14:23: error: 'll nice' redeclared as different kind of entity
   14 | ll suml,sumr,sumc,ans,nice;
      |                       ^~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:619:12: note: previous declaration 'int nice(int)'
  619 | extern int nice (int __inc) __THROW __wur;
      |            ^~~~
a.cc: In function 'void add_l(int)':
a.cc:22:20: error: no match for 'operator=' (operand types are 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'})
   22 |     it = l1.rbegin();
      |                    ^
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(const std::_Rb_tree_const_iterator<int>&)'
  324 |     struct _Rb_tree_const_iterator
      |            ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:324:12: note:   no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'const std::_Rb_tree_const_iterator<int>&'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(std::_Rb_tree_const_iterator<int>&&)'
/usr/include/c++/14/bits/stl_tree.h:324:12: note:   no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'std::_Rb_tree_const_iterator<int>&&'
a.cc:27:16: error: 'iit' was not declared in this scope; did you mean 'it'?
   27 |       l1.erase(iit);
      |                ^~~
      |                it
a.cc: In function 'void add_r(int)':
a.cc:41:20: error: no match for 'operator=' (operand types are 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'})
   41 |     it = r1.rbegin();
      |                    ^
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(const std::_Rb_tree_const_iterator<int>&)'
  324 |     struct _Rb_tree_const_iterator
      |            ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:324:12: note:   no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'const std::_Rb_tree_const_iterator<int>&'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(std::_Rb_tree_const_iterator<int>&&)'
/usr/include/c++/14/bits/stl_tree.h:324:12: note:   no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'std::_Rb_tree_const_iterator<int>&&'
a.cc: In function 'void remove_r(int)':
a.cc:57:7: error: break statement not within loop or switch
   57 |       break;
      |       ^~~~~
a.cc: In function 'int main()':
a.cc:93:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   93 |     nice += c[i];
      |     ~~~~~^~~~~~~
a.cc:93:10: error: assignment of read-only location 'nice'
a.cc:113:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  113 |   cout << ans + nice << "\n";
      |           ~~~~^~~~~~