Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Interval {
    int start, score;
};

class SegmentTree {
  public:
    SegmentTree(int size):
        m_size(size),
        m_add(size * 2, 0),
        m_max(size * 2, 0) {}

    void add(int from, int to, int64_t value) {
        for (int l = from + m_size, r = to + m_size; l < r; l /= 2, r /= 2) {
            if (l & 1) {
                m_max[l] += value;
                m_add[l++] += value;
            }
            if (r & 1) {
                m_add[--r] += value;
                m_max[r] += value;
            }
        }
        build(from + m_size);
        build(to + m_size - 1);
    }

    int64_t query() const {
        return m_max[1];
    }

  private:
    void build(int position) {
        while (position > 1) {
            position /= 2;
            m_max[position] = max(m_max[position * 2], m_max[position * 2 + 1]) + m_add[position];
        }
    }

    int m_size;
    vector<int64_t> m_add, m_max;
};

int main() {
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;

    vector< vector<Interval> > intervals(N);
    for (int i = 0; i < M; ++i) {
        int L, R, W; cin >> L >> R >> W;
        --L; --R;
        intervals[R].emplace_back(Interval{L, W});
    }

    vector<int64_t> dp(N, 0);
    SegmentTree S(N);
    for (int i = 0; i < N; ++i) {
        dp[i] = S.query();

        S.add(i, i + 1, dp[i]);
        for (auto &interval : intervals[i])
            S.add(interval.start, i + 1, interval.score);
    }

    cout << max(S.query(), 0LL) << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:16: error: no matching function for call to 'max(int64_t, long long int)'
   71 |     cout << max(S.query(), 0LL) << "\n";
      |             ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:71:16: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   71 |     cout << max(S.query(), 0LL) << "\n";
      |             ~~~^~~~~~~~~~~~~~~~
/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,
                 from a.cc:3:
/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:71:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   71 |     cout << max(S.query(), 0LL) << "\n";
      |             ~~~^~~~~~~~~~~~~~~~