Language: C++

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N1 100001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
struct data
{
    //Use required attributes
    int mn;

    //Default Values
    data() : mn(0) {};
};


    int N;
    vector<data> st;
    vector<bool> cLazy;
    vector<int> lazy;

    void init(int n)
    {
        N = n;
        st.resize(4 * N + 5);
    }

    //Write reqd merge functions
    void merge(data &cur, data &l, data &r)
    {
        cur.mn = max(l.mn, r.mn);
    }

    //Handle lazy propagation appriopriately
    void build(int node, int L, int R)
    {
        if(L==R)
        {
            st[node].mn = 1e9;
            return;
        }
        int M=(L + R)/2;
        build(node*2, L, M);
        build(node*2 + 1, M + 1, R);
        merge(st[node], st[node*2], st[node*2+1]);
    }

    data Query(int node, int L, int R, int i, int j)
    {
        if(j<L || i>R)
            return data();
        if(i<=L && R<=j)
            return st[node];
        int M = (L + R)/2;
        data left=Query(node*2, L, M, i, j);
        data right=Query(node*2 + 1, M + 1, R, i, j);
        data cur;
        merge(cur, left, right);
        return cur;
    }
    void pUpdate(int node, int L, int R, int pos, int val)
    {

        if(L == R)
        {
            st[node].mn=val;
            return;
        }
        int M = (L + R)/2;
        if(pos <= M)
            pUpdate(node*2, L, M, pos, val);
        else
            pUpdate(node*2 + 1, M + 1, R, pos, val);
        merge(st[node], st[node*2], st[node*2 + 1]);
    }








main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{
  cin>>n;
  int h[n],a[n];
  for(i=0;i<n;i++)
    cin>>h[i];
for(i=0;i<n;i++)
    cin>>a[i];
int ans=0;
init(200001);
for(i=0;i<n;i++)
{
    data t1=Query(1,1,n,1,h[i]-1);
    ans=max(ans,t1.mn+a[i]);
    pUpdate(1,1,n,h[i],t1.mn+a[i]);
}
cout<<ans;

}

}


Compiler output:
a.cc:39:16: error: template argument 1 is invalid
   39 |     vector<data> st;
      |                ^
a.cc:39:16: error: template argument 2 is invalid
a.cc: In function 'void init(long long int)':
a.cc:46:12: error: request for member 'resize' in 'st', which is of non-class type 'int'
   46 |         st.resize(4 * N + 5);
      |            ^~~~~~
a.cc: At global scope:
a.cc:50:10: error: variable or field 'merge' declared void
   50 |     void merge(data &cur, data &l, data &r)
      |          ^~~~~
a.cc:50:16: error: reference to 'data' is ambiguous
   50 |     void merge(data &cur, data &l, data &r)
      |                ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:28:8: note:                 'struct data'
   28 | struct data
      |        ^~~~
a.cc:50:22: error: 'cur' was not declared in this scope
   50 |     void merge(data &cur, data &l, data &r)
      |                      ^~~
a.cc:50:27: error: reference to 'data' is ambiguous
   50 |     void merge(data &cur, data &l, data &r)
      |                           ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:28:8: note:                 'struct data'
   28 | struct data
      |        ^~~~
a.cc:50:33: error: 'l' was not declared in this scope
   50 |     void merge(data &cur, data &l, data &r)
      |                                 ^
a.cc:50:36: error: reference to 'data' is ambiguous
   50 |     void merge(data &cur, data &l, data &r)
      |                                    ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:28:8: note:                 'struct data'
   28 | struct data
      |        ^~~~
a.cc:50:42: error: 'r' was not declared in this scope
   50 |     void merge(data &cur, data &l, data &r)
      |                                          ^
a.cc: In function 'void build(long long int, long long int, long long int)':
a.cc:60:15: error: invalid types 'int[long long int]' for array subscript
   60 |             st[node].mn = 1e9;
      |               ^
a.cc:66:17: error: invalid types 'int[long long int]' for array subscript
   66 |         merge(st[node], st[node*2], st[node*2+1]);
      |                 ^
a.cc:66:27: error: invalid types 'int[long long int]' for array subscript
   66 |         merge(st[node], st[node*2], st[node*2+1]);
      |                           ^
a.cc:66:39: error: invalid types 'int[long long int]' for array subscript
   66 |         merge(st[node], st[node*2], st[node*2+1]);
      |                                       ^
a.cc: At global scope:
a.cc:69:5: error: reference to 'data' is ambiguous
   69 |     data Query(int node, int L, int R, int i, int j)
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:28:8: note:                 'struct data'
   28 | struct data
      |        ^~~~
a.cc: In function 'void pUpdate(long long int, long long int, long long int, long long int, long long int)':
a.cc:87:15: error: invalid types 'int[long long int]' for array subscript
   87 |             st[node].mn=val;
      |               ^
a.cc:95:17: error: invalid types 'int[long long int]' for array subscript
   95 |         merge(st[node], st[node*2], st[node*2 + 1]);
      |                 ^
a.cc:95:27: error: invalid types 'int[long long int]' for array subscript
   95 |         merge(st[node], st[node*2], st[node*2 + 1]);
      |                           ^
a.cc:95:39: error: invalid types 'int[long long int]' for array subscript
   95 |         merge(st[node], st[node*2], st[node*2 + 1]);
      |                                       ^
a.cc: At global scope:
a.cc:105:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  105 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:126:5: error: reference to 'data' is ambiguous
  126 |     data t1=Query(1,1,n,1,h[i]-1);
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:28:8: note:                 'struct data'
   28 | struct data
      |        ^~~~
a.cc:127:17: error: 't1' was not declared in this scope; did you mean 'y1'?
  127 |     ans=max(ans,t1.mn+a[i]);
      |                 ^~
      |                 y1