Language: C++

#include <bits/stdc++.h>
using namespace std;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)
 
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
 
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
 
const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;
 
// -------------------------------------------------------
 
ll T;
 
vector<ll> ansvec;
 
int main() {
  cin >> T;
  rep(i, 0, T) {
    ll N;
    cin >> N;
    map<ll, vector<Pll>> red, blue;
    priority_queue<ll, vector<ll>, greater<ll>> red_que, blue_que;
    ll ans = 0;
    rep(j, 0, N) {
      ll k, l, r;
      cin >> k >> l >> r;
      ans += min(l, r);
      if (l >= r) {
        red[k].push_back(Pll(l, r));
      } else {
        blue[N - k].push_back(Pll(r, l));
      }
    }
 
    repe(i, 1, N) {
      for (auto e : red[i]) {
        red_que.push(e.first - e.second);
      }
      while (red_que.size() > i) {
        red_que.pop();
      }
    }
    while (!red_que.empty()) {
      auto add = red_que.top();
      red_que.pop();
      ans += add;
    }
 
    repe(i, 1, N) {
      for (auto e : blue[i]) {
        blue_que.push(e.first - e.second);
      }
      while (blue_que.size() > i) {
        blue_que.pop();
      }
    }
    while (!blue_que.empty()) {
      auto add = blue_que.top();
      blue_que.pop();
      ans += add;
    }
 
    ansvec.push_back(ans);
  }
 
  for (auto e : ansvec) {
    cout << e << "\n";
  }
}

Compiler output:
a.cc:4:18: error: 'll' was not declared in this scope
    4 | using Pll = pair<ll, ll>;
      |                  ^~
a.cc:4:22: error: 'll' was not declared in this scope
    4 | using Pll = pair<ll, ll>;
      |                      ^~
a.cc:4:24: error: template argument 1 is invalid
    4 | using Pll = pair<ll, ll>;
      |                        ^
a.cc:4:24: error: template argument 2 is invalid
a.cc:34:1: error: 'll' does not name a type
   34 | ll T;
      | ^~
a.cc:36:8: error: 'll' was not declared in this scope
   36 | vector<ll> ansvec;
      |        ^~
a.cc:36:10: error: template argument 1 is invalid
   36 | vector<ll> ansvec;
      |          ^
a.cc:36:10: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:39:10: error: 'T' was not declared in this scope
   39 |   cin >> T;
      |          ^
a.cc:41:5: error: 'll' was not declared in this scope
   41 |     ll N;
      |     ^~
a.cc:42:12: error: 'N' was not declared in this scope
   42 |     cin >> N;
      |            ^
a.cc:43:20: error: 'Pll' was not declared in this scope
   43 |     map<ll, vector<Pll>> red, blue;
      |                    ^~~
a.cc:43:20: error: template argument 1 is invalid
a.cc:43:20: error: template argument 2 is invalid
a.cc:43:23: error: template argument 2 is invalid
   43 |     map<ll, vector<Pll>> red, blue;
      |                       ^~
a.cc:43:23: error: template argument 3 is invalid
a.cc:43:23: error: template argument 4 is invalid
a.cc:44:33: error: template argument 2 is invalid
   44 |     priority_queue<ll, vector<ll>, greater<ll>> red_que, blue_que;
      |                                 ^
a.cc:44:46: error: template argument 2 is invalid
   44 |     priority_queue<ll, vector<ll>, greater<ll>> red_que, blue_que;
      |                                              ^~
a.cc:44:46: error: template argument 3 is invalid
a.cc:45:7: error: expected ';' before 'ans'
   45 |     ll ans = 0;
      |       ^~~~
      |       ;
a.cc:47:9: error: expected ';' before 'k'
   47 |       ll k, l, r;
      |         ^~
      |         ;
a.cc:48:14: error: 'k' was not declared in this scope
   48 |       cin >> k >> l >> r;
      |              ^
a.cc:48:19: error: 'l' was not declared in this scope
   48 |       cin >> k >> l >> r;
      |                   ^
a.cc:48:24: error: 'r' was not declared in this scope
   48 |       cin >> k >> l >> r;
      |                        ^
a.cc:49:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   49 |       ans += min(l, r);
      |       ^~~
      |       abs
a.cc:58:24: error: invalid types 'int[int]' for array subscript
   58 |       for (auto e : red[i]) {
      |                        ^
a.cc:59:17: error: request for member 'push' in 'red_que', which is of non-class type 'int'
   59 |         red_que.push(e.first - e.second);
      |                 ^~~~
a.cc:61:22: error: request for member 'size' in 'red_que', which is of non-class type 'int'
   61 |       while (red_que.size() > i) {
      |                      ^~~~
a.cc:62:17: error: request for member 'pop' in 'red_que', which is of non-class type 'int'
   62 |         red_que.pop();
      |                 ^~~
a.cc:65:21: error: request for member 'empty' in 'red_que', which is of non-class type 'int'
   65 |     while (!red_que.empty()) {
      |                     ^~~~~
a.cc:66:26: error: request for member 'top' in 'red_que', which is of non-class type 'int'
   66 |       auto add = red_que.top();
      |                          ^~~
a.cc:67:15: error: request for member 'pop' in 'red_que', which is of non-class type 'int'
   67 |       red_que.pop();
      |               ^~~
a.cc:68:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   68 |       ans += add;
      |       ^~~
      |       abs
a.cc:72:25: error: invalid types 'int[int]' for array subscript
   72 |       for (auto e : blue[i]) {
      |                         ^
a.cc:73:18: error: request for member 'push' in 'blue_que', which is of non-class type 'int'
   73 |         blue_que.push(e.first - e.second);
      |                  ^~~~
a.cc:75:23: error: request for member 'size' in 'blue_que', which is of non-class type 'int'
   75 |       while (blue_que.size() > i) {
      |                       ^~~~
a.cc:76:18: error: request for member 'pop' in 'blue_que', which is of non-class type 'int'
   76 |         blue_que.pop();
      |                  ^~~
a.cc:79:22: error: request for member 'empty' in 'blue_que', which is of non-class type 'int'
   79 |     while (!blue_que.empty()) {
      |                      ^~~~~
a.cc:80:27: error: request for member 'top' in 'blue_que', which is of non-class type 'int'
   80 |       auto add = blue_que.top();
      |                           ^~~
a.cc:81:16: error: request for member 'pop' in 'blue_que', which is of non-class type 'int'
   81 |       blue_que.pop();
      |                ^~~
a.cc:82:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   82 |       ans += add;
      |       ^~~
      |       abs
a.cc:85:12: error: request for member 'push_back' in 'ansvec', which is of non-class type 'int'
   85 |     ansvec.push_back(ans);
      |            ^~~~~~~~~
a.cc:85:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   85 |     ansvec.push_back(ans);
      |                      ^~~
      |                      abs
a.cc:88:17: error: 'begin' was not declared in this scope
   88 |   for (auto e : ansvec) {
      |                 ^~~~~~
a.cc:88:17: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:88:17: error: 'end' was not declared in this scope
   88 |   for (auto e : ansvec) {
      |                 ^~~~~~
a.cc:88:17: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~