criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
#define bit(x, i) (x & (1 << i))          //select the bit of position i of x
#define lowbit(x) ((x) & ((x) ^ ((x)-1))) //get the lowest bit of x
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a > b ? b : a)
#define abs(x) (x < 0 ? (-x) : x)   
#define IN(i, l, r) (l < i && i < r) //the next for are for checking bound
#define LINR(i, l, r) (l <= i && i <= r)
#define LIN(i, l, r) (l <= i && i < r)
#define INR(i, l, r) (l < i && i <= r)
#define clr(a, x) memset(a, x, sizeof(a)) //set elements of array to some value
#define char2Int(c) (c - '0')
#define lastEle(vec) vec[vec.size() - 1]
#define SZ(x) ((int)((x).size()))
#define REMAX(a, b) (a) = max((a), (b)) // set a to the maximum of a and b
#define REMIN(a, b) (a) = min((a), (b));
#define FOREACH(i, t) for (typeof(t.begin()) i = t.begin(); i != t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(), (c).end()                                          //handy for function like 
#define PRESENT(c, x) ((c).find(x) != (c).end())
#define CPRESENT(c, x) (find(ALL(c), x) != (c).end())
#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define ui unsigned int
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef pair<int, int> ii;
#define F(i, L, R) for (int i = L; i < R; i++) //next four are for for loops
#define FE(i, L, R) for (int i = L; i <= R; i++)
#define FF(i, L, R) for (int i = L; i > R; i--)
#define FFE(i, L, R) for (int i = L; i >= R; i--)
#define deb(x) count << #x << " " << x << endl;
template<typename... TTT>
void read(TTT&... args) {
   ((cin >> args), ...)
}
namespace EU
{
void max_self(int &a, int b)
{
a = max(a, b);
}
}

int main() {
    cout << 10;
}

Compiler output:
a.cc: In function 'void read(TTT& ...)':
a.cc:51:24: error: expected ';' before '}' token
   51 |    ((cin >> args), ...)
      |                        ^
      |                        ;
   52 | }
      | ~
Language: C++

#include  "/Users/gagandeep.nagpal/Library/stdc++.h"
using namespace std;

vector<int> h, a;

long long segtree[800002];
vector<pair<int,int> > order;

void update(int node,int l,int r , int in, long long val){
    if(l==r) {
        segtree[node]=val;
        return ;
    }
    int m = (l+r)/2;
    if(in<=m)
        update(2*node+1,l,m,in,val );
    else
        update(2*node + 2, m+1, r, in , val);
    segtree[node]  = max(segtree[2*node+1], segtree[2*node+2]);
}
 
long long query(int node, int l,int r, int ql, int qr ){
    //cout<<node<<", "<<ql<<", "<<qr<<"\n";
    if(ql>qr) return 0;
    if(qr < l || ql >r ) return 0;
    if(ql<=l && qr>=r) return segtree[node];
    if(l==r)  return segtree[node];
    int m = (l+r)/2;
    long long a1 = query(2*node + 1, l, m, ql, qr);
    long long a2 = query(2*node + 2, m+1, r, ql, qr);
    long long ans= max(a1, a2);
    //cout<<node<<", "<<ql<<", "<<qr<<": "<<ans<<"\n";
    return ans;
}
void print() {
    int i;
    for(i=0;i<=16;i++)
        cout<<segtree[i]<<" ";
    cout<<"\n";
}
int main() {
    int n;
    cin>>n;
    int i;
    for(i=1;i<=n;i++){
        int hh;
        cin>>hh;
        h.push_back(hh);
        order.push_back({-hh, i-1});
    }
    for(i=1;i<=n;i++){
        int aa;
        cin>>aa;
        a.push_back(aa);
    }
    sort(order.begin(), order.end() );
    
    long long ans = 0;
    for(auto p: order) {
        
        int in = p.second;
        int val =a[in];
       // cout<<"("<<val<<", "<<in<<")\n";
        long long max_value_in_right = query(0,1,n-1,in+1, n-1);
       // cout<<"maxValue: "<<max_value_in_right<<"\n";
        update(0,0,n-1,in, max_value_in_right +val);
       // print();
        ans  = max(ans, max_value_in_right + val);
    }
    cout<<ans<<"\n";
	return 0;
}

Compiler output:
a.cc:1:11: fatal error: /Users/gagandeep.nagpal/Library/stdc++.h: No such file or directory
    1 | #include  "/Users/gagandeep.nagpal/Library/stdc++.h"
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
using namespace std;
using ll = long long;

int N;
int h[200010],a[200010];
ll dp[200010];

ll query(int x){
    ll ret = 0;
    for(int i = x;0 <  x; x -= x & -x) r = max(r,dp[x]);
    return ret;
}

void update(int x,ll v){
    for(int i = x;x <= N; x += x & -x) dp[x] = max(dp[x],v);
}

int main(){
    cin >> N;
    for(int i=1;i<=N;++i) cin >> h[i];
    for(int i=1;i<=N;++i) cin >> a[i];
    for(int i=1;i<=N;++i){
        ll t = query(h[i]) + a[i];
        update(h[i],t);
    }
    cout << query(N) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'll query(int)':
a.cc:11:40: error: 'r' was not declared in this scope
   11 |     for(int i = x;0 <  x; x -= x & -x) r = max(r,dp[x]);
      |                                        ^
Language: C++

#inclide<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dat[800010];
ll u;
void seginit(ll n){
  for(int i=0;;i++){
    ll y=pow(2,i);
    if(y>=n){
      u=y;
      break;
    }
  }
  fill(dat,dat+2*u,0);
}
void add(ll n,ll x){
  ll i=u+n-1;
  dat[i]=x;
  while(i>0){
    i=(i-1)/2;
    dat[i]=max(dat[2*i+1],dat[2*i+2]);
  }
}
ll que(ll a,ll b,ll k,ll l,ll r){
  if(a>=r||b<=l)return 0;
  if(a<=l&&b>=r)return dat[k];
  else{
    ll m1=que(a,b,2*k+1,l,(l+r)/2);
    ll m2=que(a,b,2*k+2,(l+r)/2,r);
    return max(m1,m2);
  }
}
int main(){
  ll n;cin>>n;
  ll h[n];
  for(int i=0;i<n;i++)cin>>h[i];
  ll a[n];for(int i=0;i<n;i++)cin>>a[i];
  seginit(n+2);
  for(int i=0;i<n;i++){
    ll y=que(1,h[i],0,0,u);
    add(h[i],y+a[i]);
  }
  ll ans=que(1,n+1,0,0,u);
  cout<<ans<<endl;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inclide; did you mean #include?
    1 | #inclide<bits/stdc++.h>
      |  ^~~~~~~
      |  include
a.cc: In function 'void seginit(ll)':
a.cc:8:10: error: 'pow' was not declared in this scope
    8 |     ll y=pow(2,i);
      |          ^~~
a.cc:14:3: error: 'fill' was not declared in this scope; did you mean 'll'?
   14 |   fill(dat,dat+2*u,0);
      |   ^~~~
      |   ll
a.cc: In function 'void add(ll, ll)':
a.cc:21:12: error: 'max' was not declared in this scope
   21 |     dat[i]=max(dat[2*i+1],dat[2*i+2]);
      |            ^~~
a.cc: In function 'll que(ll, ll, ll, ll, ll)':
a.cc:30:12: error: 'max' was not declared in this scope
   30 |     return max(m1,m2);
      |            ^~~
a.cc: In function 'int main()':
a.cc:34:8: error: 'cin' was not declared in this scope
   34 |   ll n;cin>>n;
      |        ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inclide<bits/stdc++.h>
a.cc:44:3: error: 'cout' was not declared in this scope
   44 |   cout<<ans<<endl;
      |   ^~~~
a.cc:44:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:44:14: error: 'endl' was not declared in this scope
   44 |   cout<<ans<<endl;
      |              ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #inclide<bits/stdc++.h>
Language: Java

import java.util.Scanner;
import java.lang.Math;

public class apples {
	static void update(long tree[], long val, int start, int end, int idx, int pos)
	{
		if(start == end)
		{
			tree[idx] = val;
		}
		else
		{
			int mid = (start + end)/2;
			if(pos>=start && pos<=mid) update(tree, val, start, mid, 2*idx+1, pos);
			else update(tree, val, mid+1, end, 2*idx+2, pos);
			tree[idx] = Math.max(tree[2*idx+1] , tree[2*idx+2]);
		}
	}
	
	static long query(long tree[], int start, int end, int l,int r, int idx) {
		if(start>=l && end<=r) return tree[idx];
		if(start>r || end<l) return -1;
		int mid = (start+end)/2;
		return Math.max(query(tree,start,mid,l,r,2*idx+1),query(tree,mid+1,end,l,r,2*idx+2));
	}
	
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		long[] tree = new long[400000];
		long[] dp = new long[200000];
		int n = in.nextInt();
		for(int i=0;i<n+1;i++) dp[i]=0;
		int[] h = new int[n];
		long[] a = new long[n];
		for(int i=0;i<n;i++)
		{
			h[i] = in.nextInt();
		}
		for(int i=0;i<n;i++)
		{
			a[i] = in.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			//System.out.print(query(tree, 0, n, 0, h[i], 0)+" ");
			dp[h[i]] = Math.max(dp[h[i]], a[i] + query(tree, 0, n, 0, h[i], 0));
			update(tree, dp[h[i]], 0, n, 0, h[i]);
		}
//		update(tree, 10, 0, 2*n+1, 0, 3);
//		update(tree, 20, 0, 2*n+1, 0, 1);
//		for(int i=0;i<2*n+1;i++)
//		{
//			System.out.print(tree[i]+" ");
//		}
//		System.out.print(query(tree, 0, 2*n+1, 0, 2, 0)+" ");
		long ans = 0;
//		for(int i=0;i<=n;i++) System.out.print(dp[i]+" ");
		for(int i=0;i<=n;i++) ans = Math.max(ans, dp[i]);
		System.out.print(ans);
	}
}


Compiler output:
Main.java:4: error: class apples is public, should be declared in a file named apples.java
public class apples {
       ^
1 error
Language: Java



import java.util.Scanner;

public class newdpstate {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int height[]=new int[n];
		long val[]=new long[n];
		long dp[]=new long[n];
		
		for(int i=0;i<n;i++)
			height[i]=scan.nextInt();
		for(int i=0;i<n;i++)
		{
			val[i]=scan.nextLong();
			dp[i]=val[i];
		}
		for(int i=1;i<n;i++)
		{
			int curheight=height[i];
			for(int j=0;j<i;j++)
			{
				if(height[j]<curheight) {
					dp[i]=Math.max(dp[i],dp[j]+val[i]);
				}
			}
		}
		System.out.println(dp[n-1]);
	}
}


Compiler output:
Main.java:5: error: class newdpstate is public, should be declared in a file named newdpstate.java
public class newdpstate {
       ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int h[200001];
long long t[600001];
long long query(int index,int lb,int rb,int lq,int rq)
{
	if((lb==lq&&rb==rq)||lb==rb)
		return t[index];
	int mid=(lb+rb)/2;
	long long maxn=0;
	if(rq<=mid)
		maxn=max(maxn,query(index*2,lb,mid,lq,mid));
	else if(lq>mid)
		maxn=max(maxn,query(index*2+1,mid+1,rb,mid+1,rq));
	else
	{
		maxn=max(maxn,query(index*2,lb,mid,lq,mid));
		maxn=max(maxn,query(index*2+1,mid+1,rb,mid+1,rq));
	}
	return maxn;
}
void update(int index,int lb,int rb,int id,long long value)
{
	if(lb==rb&&index==id)
		t[index]=max(t[index],value);
	int mid=(lb+rb)/2;
	if(id<=mid)
	{
		update(index*2,lb,mid,id,value);
		t[index]=max(t[index],t[index*2]);
	}
	else
	{
		update(index*2+1,mid+1,rb,id,value);
		t[index]=max(t[index],t[index*2+1]);
	}
}
int main()
{
	int n,i,tmp;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&tmp);
		update(1,1,n,h[i],query(1,1,n,1,h[i]-1)+a);
	}
	printf("%lld",t[1]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:57: error: 'a' was not declared in this scope
   49 |                 update(1,1,n,h[i],query(1,1,n,1,h[i]-1)+a);
      |                                                         ^
Language: C++

#include<bit/stdc++.h>
using namespace std;
int h[200001];
long long t[600001];
long long query(int index,int lb,int rb,int lq,int rq)
{
	if((lb==lq&&rb==rq)||lb==rb)
		return t[index];
	int mid=(lb+rb)/2;
	long long maxn=0;
	if(rq<=mid)
		maxn=max(maxn,query(index*2,lb,mid,lq,rq));
	else if(lq>mid)
		maxn=max(maxn,query(index*2+1,mid+1,rb,lq,rq));
	else
	{
		maxn=max(maxn,query(index*2,lb,mid,lq,mid));
		maxn=max(maxn,query(index*2+1,mid+1,rb,mid+1,rq));
	}
	return maxn;
}
void update(int index,int lb,int rb,int id,int value)
{
	if(lb==rb&&index==id)
		t[index]=max(t[index],value);
	int mid=(lb+rb)/2;
	if(ld<=mid)
	{
		update(index*2,lb,mid,ld,value);
		t[index]=max(t[index],t[index*2]);
	}
	else
	{
		update(index*2+1,mid+1,rb,ld,value);
		t[index]=max(t[index],t[index*2+1]);
	}
}
int main()
{
	int n,i,tmp;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&tmp);
		update(1,1,n,h[i],query(1,1,n,1,h[i]-1)+a);
	}
	printf("%lld",t[1]);
	return 0;
}

Compiler output:
a.cc:1:9: fatal error: bit/stdc++.h: No such file or directory
    1 | #include<bit/stdc++.h>
      |         ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<class V, int NV> struct SegTree { //[l,r)
    V comp(V& l, V& r) { return max(l, r); };
 
    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int x, int y, int l = 0, int r = NV, int k = 1) {
        if (r <= x || y <= l)return def; if (x <= l && r <= y)return val[k];
        auto a = get(x, y, l, (l + r) / 2, k * 2); 
        auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
        return comp(a, b);
    }
    void update(int i, V v) {
        i += NV; val[i] = v;
        while (i>1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
    }
    void add(int i, V v) { update(i, val[i + NV] + v); }
    V operator[](int x) { return get(x, x + 1); }
};

int main() {
    int n;
    cin >> n;
    vector<int> h(n), a(n);
    SegTree<ll, 1<<18> dp;
    rep(i, n) cin >> h[i];
    rep(i, n) cin >> a[i];

    rep(i, n) {
        ll opt = dp.get(0, h[i]) + a[i];
        dp.update(h[i], max(dp[h[i]], opt));
    }
    cout << dp.get(0, 1<<18) << endl;
}

Compiler output:
a.cc: In constructor 'SegTree<V, NV>::SegTree()':
a.cc:20:56: error: 'def' was not declared in this scope
   20 |     vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
      |                                                        ^~~
a.cc: In member function 'V SegTree<V, NV>::get(int, int, int, int, int)':
a.cc:22:37: error: 'def' was not declared in this scope
   22 |         if (r <= x || y <= l)return def; if (x <= l && r <= y)return val[k];
      |                                     ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int h[200001],a[200001];
long long t[800001];
long long maxquery(int index,int lb,int rb,int lq,int rq)
{
    if((lb==lq&&rb==rq)||lb==rb)
	return t[index];
    int mid=(lb+rb)/2;
    long long maxx=0;
    if(rq<=mid)
	maxx=max(maxx,maxquery(index*2,lb,mid,lq,rq));
    else if(lq>mid)
	maxx=max(maxx,maxquery(index*2+1,mid+1,rb,lq,rq));
    else
    {
	maxx=max(maxx,maxquery(index*2,lb,mid,lq,mid));
	maxx=max(maxx,maxquery(index*2+1,mid+1,rb,mid+1,rq));
    }
    return ret;
}
void update(int index,int lb,int rb,int ld,long long value)
{
    if(lb==rb&&lb==ld)
    {
	t[index]=max(t[index],value);
	return;
    }
    int mid=(lb+rb)/2;
    if(ld<=mid)
    {
	update(index*2,lb,mid,ld,value);
	t[index]=max(t[index],t[index*2]);
    }
    else
    {
	update(index*2+1,mid+1,rb,ld,value);
	t[index]=max(t[index],t[index*2+1]);
    }
}
int main()
{
    int n,i;
    long long tmp;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
	scanf("%d",&h[i]);
    for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
     	update(1,1,n,h[i],maxquery(1,1,n,1,h[i]-1)+a[i]);
    printf("%lld",t[1]);
    return 0;
}

Compiler output:
a.cc: In function 'long long int maxquery(int, int, int, int, int)':
a.cc:20:12: error: 'ret' was not declared in this scope
   20 |     return ret;
      |            ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int h[200001],a[200001];
long long t[800001];
long long maxquery(int index,int lb,int rb,int lq,int rq)
{
    if((lb==lq&&rb==rq)||lb==rb)
    {
	return t[index];
    }
    int mid=(lb+rb)/2;
    long long ret=0;
    if(rq<=mid)
    {
	ret=max(ret,maxquery(index*2,lb,mid,lq,rq));
    }
    else if(lq>mid)
    {
	ret=max(ret,maxquery(index*2+1,mid+1,rb,lq,rq));
    }
    else
    {
	ret=max(ret,maxquery(index*2,lb,mid,lq,mid));
	ret=max(ret,maxquery(index*2+1,mid+1,rb,mid+1,rq));
    }
    return ret;
}
void update(int index,int lb,int rb,int ld,long long value)
{
    if(lb==rb&&lb==leaf)
    {
	t[index]=max(t[index],value);
	return;
    }
    int mid=(lb+rb)/2;
    if(ld<=mid)
    {
	update(index*2,lb,mid,ld,value);
	t[index]=max(t[index],t[index*2]);
    }
    else
    {
	update(index*2+1,mid+1,rb,ld,value);
	t[index]=max(t[index],t[index*2+1]);
    }
}
int main()
{
    int n,i;
    long long tmp;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
	scanf("%d",&h[i]);
    for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
    {
	tmp=maxquery(1,1,n,1,h[i]-1);
     	update(1,1,n,h[i],tmp+a[i]);
    }
    printf("%lld",t[1]);
    return 0;
}

Compiler output:
a.cc: In function 'void update(int, int, int, int, long long int)':
a.cc:30:20: error: 'leaf' was not declared in this scope
   30 |     if(lb==rb&&lb==leaf)
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long t[800000],n;
long long h[200001],a[200001];
void update(int index,int lb,int rb,int ld,long long value)
{
    if(lb==ld&&rb==ld)
        t[index]=max(t[index],value);
    mid=(lb+rb)>>1;
    if(ld>mid)
        update(index*2+1,mid+1,rb,ld);
    else if(rd<=mid)
        update(index*2,lb,mid,ld);
    t[index]=max(t[index],value);
}
long long maxquery(int index,int lb,int rb,int lq,int rq)
{
    if(lb==rb||(lb==lq&&rb==rq))
        return t[index];
    mid=(lb+rb)>>1;
    if(lq>mid)
        return maxquery(index*2+1,mid+1,rb,lq,rq);
    else if(rq<=mid)
        return maxquery(index*2,lb,mid,lb,rq);
    else
    {
        return maxquery(index*2+1,mid+1,rb,mid+1,rq);
        return maxquery(index*2,lb,mid,lq,mid);
    }
}
int main()
{
    long long maxx=0,t,i;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
        scanf("%lld",&h[i]);
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(i=1;i<=n;i++)
    {
        t=maxquery(h[i],1,n,1,h[i]-1);
        maxx=max(maxx,t+a[i]);
        update(h[i],t+a[i]);
    }
    printf("%lld",t[1]);
    return 0;
}

Compiler output:
a.cc: In function 'void update(int, int, int, int, long long int)':
a.cc:9:5: error: 'mid' was not declared in this scope
    9 |     mid=(lb+rb)>>1;
      |     ^~~
a.cc:12:13: error: 'rd' was not declared in this scope; did you mean 'rb'?
   12 |     else if(rd<=mid)
      |             ^~
      |             rb
a.cc: In function 'long long int maxquery(int, int, int, int, int)':
a.cc:20:5: error: 'mid' was not declared in this scope
   20 |     mid=(lb+rb)>>1;
      |     ^~~
a.cc: In function 'int main()':
a.cc:43:15: error: too few arguments to function 'void update(int, int, int, int, long long int)'
   43 |         update(h[i],t+a[i]);
      |         ~~~~~~^~~~~~~~~~~~~
a.cc:5:6: note: declared here
    5 | void update(int index,int lb,int rb,int ld,long long value)
      |      ^~~~~~
a.cc:45:20: error: invalid types 'long long int[int]' for array subscript
   45 |     printf("%lld",t[1]);
      |                    ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long h[200001],value[200001];
long long t,n;
long long lowbit(long long x)
{
        return x&-x;
}
void maxupdate(long long index,long long max_value)
{
        while(index<=n)
        {  
                value[index]=max(value[index],max_value);
                index+=lowbit(index);
        }
}
long long maxrange(long long index)
{
        long long ret;
        while(index)
        {
                ret=max(ret,value[index]);
                index-=lowbit(index);
        }
        return ret;
}
int main()
{
        long long i,j,k,ans;
        scanf("%lld",&n);
        for(i=1;i<=n;i++)
        {
                scanf("%lld",&h[i]);
        }
        for(i=1;i<=n;i++)
        {
                scanf("%lld",&h[i]);
        }
        for(i=1;i<=n;i++)
        {
                t=maxrange(h[i]-1);
                maxupdate(h[i],t+a);
                ans=max(ans,t+a);
        }
        printf("%d",ans);
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:34: error: 'a' was not declared in this scope
   42 |                 maxupdate(h[i],t+a);
      |                                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long v[200000],c[200000],n;
long long lowbit(long long x)
{
	return x&(-x);
}
void update(long long index,long long max_value)
{
	while(index<=n)
	{
		c[index]=max(c[index],max_value);
		index+=lowbit(index);
	}
}
long long maxrange(long long index)
{
	long long ret=0;
	while(index)
	{
		ret=max(ret,c[index]);
		index-=lowbit(index);
	}
	return ret;
}
int main()
{
	long long i,t,s,ans=0;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&s);
		t=maxrange(a[i]-1);
		update(a[i],t+s);
		ans=max(ans,t+s);
	}
	printf("%lld",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:31: error: 'a' was not declared in this scope
   32 |                 scanf("%lld",&a[i]);
      |                               ^
a.cc:37:28: error: 'a' was not declared in this scope
   37 |                 t=maxrange(a[i]-1);
      |                            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int v[200000],c[200000],n;
int lowbit(int x)
{
	return x&(-x);
}
void update(int index,int max_value)
{
	while(index<=n)
	{
		c[index]=max(c[index],max_value);
		index+=lowbit(index);
	}
}
int maxrange(int index)
{
	int ret=0;
	while(index)
	{
		ret=max(ret,c[index]);
		index-=lowbit(index);
	}
	return ret;
}
int main()
{
	int i,t,s,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&s);
		t=maxrange(a[i]-1);
		update(a[i],t+s);
		ans=max(ans,t+s);
	}
	printf("%d",ans);
	return 0

Compiler output:
a.cc: In function 'int main()':
a.cc:32:29: error: 'a' was not declared in this scope
   32 |                 scanf("%d",&a[i]);
      |                             ^
a.cc:37:28: error: 'a' was not declared in this scope
   37 |                 t=maxrange(a[i]-1);
      |                            ^
a.cc:42:17: error: expected ';' at end of input
   42 |         return 0
      |                 ^
      |                 ;
a.cc:42:17: error: expected '}' at end of input
a.cc:27:1: note: to match this '{'
   27 | {
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long c[400002];
void f(int index)
{
	if(index==1)
		return;
	else if(index%2==1)
	{	
		c[index/2]+=c[index];
		f(index/2);
	}
	else if(c[index/2]<c[index])
	{
		c[index/2]=c[index];
		f(index/2);
	}
}
int main()
{
	int n,i;
	long long a,t;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a);
		c[h[i]]=a;
		f(h[i]);
	}
	printf("%lld",c[1]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:29: error: 'h' was not declared in this scope
   26 |                 scanf("%d",&h[i]);
      |                             ^
a.cc:31:19: error: 'h' was not declared in this scope
   31 |                 c[h[i]]=a;
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long c[200001];
int h[200001];
long long maxn;
int lowbit(int x)
{
	return x&-x;
}
void increase(int index,long long value)
{
	while(index<=200001)
	{
		c[index]=max(c[index],value);
		index+=lowbit(index);
	}
}
long long maxrange(int index)
{
	long long ret=0;
	while(index)
	{
		ret=max(ret,c[index]);
		index-=lowbit(index);
	}
	return ret;
}
int main()
{
	int n,i,t;
	long long a;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a);
		t=maxrange(h[i])+a;
		increase(h[i],t);
		maxn=max(maxn,t);
	}
	printf("%lld",maxn);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:25: error: no matching function for call to 'max(long long int&, int&)'
   42 |                 maxn=max(maxn,t);
      |                      ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:42:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   42 |                 maxn=max(maxn,t);
      |                      ~~~^~~~~~~~
/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:
/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:42:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   42 |                 maxn=max(maxn,t);
      |                      ~~~^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int c[200001];
int h[200001];
int maxn;
int lowbit(int x)
{
	return x&-x;
}
void increase(int index,int value)
{
	while(index<=200001)
	{
		c[index]=max(c[index],value);
		index+=lowbit(index);
	}
}
int maxrange(int index)
{
	int ret=0;
	while(index)
	{
		ret=max(ret,c[index]);
		index-=lowbit(index);
	}
	return ret;
}
int main()
{
	int n,i,a;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		increase(h[i],maxn+a);
		maxn=maxrange(h[i]);
	}
	printf("%d",max);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:15: error: overloaded function with no contextual type information
   42 |         printf("%d",max);
      |         ~~~~~~^~~~~~~~~~
Language: C++

#include<bit/stdc++.h>
using namespace std;
int c[200001];
int h[200001];
int maxn;
int lowbit(int x)
{
	return x&-x;
}
void increase(int index,int value)
{
	while(index<=200001)
	{
		c[index]=max(c[index],value);
		index+=lowbit(index);
	}
}
int maxrange(int index)
{
	int ret=0;
	while(index)
	{
		ret=max(ret,c[index]);
		index-=lowbit(index);
	}
	return ret;
}
int main()
{
	int n,i,a;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		increase(h[i],maxn+a);
		maxn=maxrange(h[i]);
	}
	printf("%d",max);
	return 0;
}

Compiler output:
a.cc:1:9: fatal error: bit/stdc++.h: No such file or directory
    1 | #include<bit/stdc++.h>
      |         ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
const ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

int n;
ll tree[(int)9e5+100];
ll query(int idx){
	ll ans=-1;
	for(;idx;idx-=idx&-idx){
		ans=max(tree[idx], ans);
	}
	return ans;
}
ll update(int pos, ll val){
	for(int idx=pos;idx<=n;++i) tree[idx]=max(tree[idx],val);
	return ;
}
///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

cin>>n;
vv<ll> h(n), a(n);
for(int i=0;i<n;++i) cin>>h[i];
for(int i=0;i<n;++i) cin>>a[i];
//for(int i=0;i<n;++i) DD(h[i], a[i]);
for(int i=0;i<n;++i){
	ll val=query(h[i]-1)+a[i];
	update(h[i], val);	
//	cerr<<val<<el;
}
cout<<query(n)<<el;

return 0;
}


Compiler output:
a.cc: In function 'll update(ll, ll)':
a.cc:36:34: error: 'i' was not declared in this scope; did you mean 'vi'?
   36 |         for(int idx=pos;idx<=n;++i) tree[idx]=max(tree[idx],val);
      |                                  ^
      |                                  vi
a.cc:37:9: error: return-statement with no value, in function returning 'll' {aka 'long long int'} [-fpermissive]
   37 |         return ;
      |         ^~~~~~
Language: C++

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=2e5+5;

int st[6*N],qt[6*N],a[N],h[N];

void update_tree(int cur,int s,int e,int pos,int val)
{
     if(pos<s || pos>=e)
          return;
     if(s==x && s==e-1)
     {
          st[cur]=val;
          return;
     }
     int c1=(cur<<1),c2=c1+1,m=(s+e)>>1;
     update_tree(c1,s,m,pos,val);
     update_tree(c2,m,e,pos,val);
     st[cur]=max(st[c1],st[c2]);
}

void query_tree(int cur,int s,int e,int l,int r)
{
     if(l>=e || r<=s)
     {
          qt[cur]=0;
          return;
     }
     if(s>=l && r>=e)
     {
          qt[cur]=st[cur];
          return;
     }
     int c1=2*cur,c2=c1+1,m=(s+e)>>1;
     query_tree(c1,s,m,l,r);
     query_tree(c2,m,e,l,r);
     qt[cur]=max(qt[c1],qt[c2]);
}

int32_t main()
{
     IOS;
     
     int n;
     cin>>n;
     for(int i=1;i<=n;i++)
          cin>>h[i];
     for(int i=1;i<=n;i++)
          cin>>a[i];
     int ans=0;     
     for(int i=1;i<=n;i++)
     {
          query_tree(1,1,n+1,1,h[i]);
          int temp=qt[1];
          temp+=a[i];
          ans=max(ans,temp);
          update_tree(1,1,n+1,h[i],temp);
     }
     cout<<ans;
     return 0;
}


Compiler output:
a.cc: In function 'void update_tree(long long int, long long int, long long int, long long int, long long int)':
a.cc:20:12: error: 'x' was not declared in this scope
   20 |      if(s==x && s==e-1)
      |            ^
Language: C++

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
#define def 0
template<class V, int NV> struct SegTree { //[l,r)
    V comp(V& l, V& r) { return max(l, r); };

    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int x, int y, int l = 0, int r = NV, int k = 1) {
        if (r <= x || y <= l)return def; if (x <= l && r <= y)return val[k];
        auto a = get(x, y, l, (l + r) / 2, k * 2); 
        auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
        return comp(a, b);
    }
    void update(int i, V v) {
        i += NV; val[i] = v;
        while (i>1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
    }
    void add(int i, V v) { update(i, val[i + NV] + v); }
    V operator[](int x) { return get(x, x + 1); }
};

/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/











int N, H[201010], A[201010];
SegTree<ll, 1 << 18> dp;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> H[i];
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N) {
        ll opt = dp.get(0, H[i]) + A[i];
        dp.update(H[i], max(dp[H[i]], opt));
    }

    cout << dp.get(0, z.size()) << endl;
}


Compiler output:
a.cc: In function 'void _main()':
a.cc:64:23: error: 'z' was not declared in this scope
   64 |     cout << dp.get(0, z.size()) << endl;
      |                       ^
Language: C++

long bit[2<<17];
n,h[2<<17],a;
long sum(i)
{
	long ans=0;
	for(;i>0;i-=i&-i)ans=fmax(ans,bit[i]);
	return ans;
}
add(i,a)long a;
{
	for(;i<2<<17;i+=i&-i)bit[i]=fmax(bit[i],a);
}
i,j;
main()
{
	for(scanf("%d",&n);i<n;)scanf("%d",h+i++);
	for(;~scanf("%d",&a);j++)add(h[j],sum(h[j])+a);
	printf("%ld",sum(n));
}

Compiler output:
a.cc:2:1: error: 'n' does not name a type
    2 | n,h[2<<17],a;
      | ^
a.cc:3:10: error: 'i' was not declared in this scope
    3 | long sum(i)
      |          ^
a.cc:9:4: error: expected constructor, destructor, or type conversion before '(' token
    9 | add(i,a)long a;
      |    ^
a.cc:10:1: error: expected unqualified-id before '{' token
   10 | {
      | ^
a.cc:13:1: error: 'i' does not name a type
   13 | i,j;
      | ^
a.cc:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:16:25: error: 'n' was not declared in this scope
   16 |         for(scanf("%d",&n);i<n;)scanf("%d",h+i++);
      |                         ^
a.cc:16:13: error: 'scanf' was not declared in this scope
   16 |         for(scanf("%d",&n);i<n;)scanf("%d",h+i++);
      |             ^~~~~
a.cc:16:28: error: 'i' was not declared in this scope
   16 |         for(scanf("%d",&n);i<n;)scanf("%d",h+i++);
      |                            ^
a.cc:16:44: error: 'h' was not declared in this scope
   16 |         for(scanf("%d",&n);i<n;)scanf("%d",h+i++);
      |                                            ^
a.cc:17:27: error: 'a' was not declared in this scope
   17 |         for(;~scanf("%d",&a);j++)add(h[j],sum(h[j])+a);
      |                           ^
a.cc:17:15: error: 'scanf' was not declared in this scope
   17 |         for(;~scanf("%d",&a);j++)add(h[j],sum(h[j])+a);
      |               ^~~~~
a.cc:17:30: error: 'j' was not declared in this scope
   17 |         for(;~scanf("%d",&a);j++)add(h[j],sum(h[j])+a);
      |                              ^
a.cc:17:38: error: 'h' was not declared in this scope
   17 |         for(;~scanf("%d",&a);j++)add(h[j],sum(h[j])+a);
      |                                      ^
a.cc:17:51: error: 'sum' cannot be used as a function
   17 |         for(;~scanf("%d",&a);j++)add(h[j],sum(h[j])+a);
      |                                                   ^
a.cc:17:34: error: 'add' was not declared in this scope
   17 |         for(;~scanf("%d",&a);j++)add(h[j],sum(h[j])+a);
      |                                  ^~~
a.cc:18:26: error: 'n' was not declared in this scope
   18 |         printf("%ld",sum(n));
      |                          ^
a.cc:18:27: error: 'sum' cannot be used as a function
   18 |         printf("%ld",sum(n));
      |                           ^
a.cc:18:9: error: 'printf' was not declared in this scope
   18 |         printf("%ld",sum(n));
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | long bit[2<<17];
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
template<class T>
struct BIT{
    //0-indexed
    vector<T> data;
    BIT(int size){
        data.assign(size+1,0);
    }
    T sum(int k){
        //[0,k]
        T res=0;
        for(++k;k>0;k-=k&-k){
            chmax(res,data[k]);
        }
        return res;
    }
    void add(int k,T x){
        data[k++]=x;
        for(;k<data.size();k+=k&-k){
            chmax(data[k],x);
        }
    }
};
int main(){
    int n;
    cin>>n;
    vi h(n);
    priority_queue<P,vp,greater<P>> que;
    REP(i,n){
        cin>>h[i];
        que.push({h[i],i});
    }
    BIT<ll> tr(n);
    vl a(n);
    REP(i,n){
        cin>>a[i];
    }
    while(que.size()){
        P p=que.top();que.pop();
        tr.add(p.se,dp[p.se]);
    }
    cout<<tr.sum(n-1)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:21: error: 'dp' was not declared in this scope; did you mean 'p'?
   63 |         tr.add(p.se,dp[p.se]);
      |                     ^~
      |                     p
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
template<class T>
struct BIT{
    //0-indexed
    vector<T> data;
    BIT(int size){
        data.assign(size+1,0);
    }
    T sum(int k){
        //[0,k]
        T res=0;
        for(++k;k>0;k-=k&-k){
            chmax(res,data[k]);
        }
        return res;
    }
    void add(int k,T x){
        data[k++]=x;
        for(;k<data.size();k+=k&-k){
            chmax(data[k],x);
        }
    }
};
int main(){
    int n;
    cin>>n;
    vi h(n);
    priority_queue<P,vp,greater<P>> que;
    REP(i,n){
        cin>>h[i];
        que.push({h[i],i});
    }
    BIT<ll> tr(n);
    vl a(n);
    REP(i,n){
        cin>>a[i];
    }
    vl dp(n);
    while(que.size()){
        P p=que.top();que.pop();
        dp[p.se]=tr.sum(p.se-1)+a[p.se]
        tr.add(p.se,dp[p.se]);
    }
    cout<<tr.sum(n-1)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:40: error: expected ';' before 'tr'
   64 |         dp[p.se]=tr.sum(p.se-1)+a[p.se]
      |                                        ^
      |                                        ;
   65 |         tr.add(p.se,dp[p.se]);
      |         ~~
Language: C++

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

int n;
long long k;
vector<vector<int>>a;
vector<vector<int>> DP;
const int inf = (int)1e9 + 7;

vector<vector<int>> mult(vector<vector<int>>& a, vector<vector<int>>& b)
{
	vector<vector<int>> answer;
	answer.resize(n);
	for (int i = 0; i < n; i++) answer[i].resize(n, 0);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++) // calculate answer[i][j]
		{
			for (int k = 0; k < n; k++)
				answer[i][j] = (answer[i][j]+(a[i][k] * b[k][j])%inf)%inf;
		}
	}
	return answer;
}

void main()
{
	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; i++)
	{
		a[i].resize(n);
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	}

	// use matrix exponent to calculate number of paths (kth exponent of adj matrix)
	vector<vector<int>> prod;
	prod.resize(n);
	for (int i = 0; i < n; i++) prod[i].resize(n);
	for (int i = 0; i < n; i++) prod[i][i] = 1;

	while (k != 0)
	{
		if (k & 1)
			prod = mult(prod, a);
		a = mult(a, a);
		k = k >> 1;
	}

	int total = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			total = (total + prod[i][j]) % inf;
	}
	cout << total << endl;
}
	/*
	// memory use is k*n (can be reduced to k); computation k*n*n too much
	//2D DP[len][i] mean the total number of path with length of len that stops at ith node
	// to simulate, do k steps backward
	//DP[len][i] is equal to the sum of all DP[len-1][j] where there is a directed path from j to i
	DP.resize(k + 1);
	for (int i = 1; i < k + 1; i++)
	{
		DP[i].resize(n, 0);
	}
	DP[0].resize(n, 1);
	
	for (int len = 1; len < k + 1; len++)
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
			{
				if(a[j][i])
					DP[len][i] = (DP[len][i] + DP[len - 1][j])%inf;
			}
		}
	}

	int total = 0;
	for (int i = 0; i < n; i++)
		total = (total + DP[k][i]) % inf;
	cout << total << endl;
	*/


Compiler output:
a.cc:27:1: error: '::main' must return 'int'
   27 | void main()
      | ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
//const int N = 2e5+5, M = N;
//=========================================

const int SZ = 55;

struct matrix{
    int mat[SZ][SZ];

    matrix(int idd = 0){
        for(int i = 0; i < SZ; ++i){
            for(int j = 0; j < SZ; ++j)
                mat[i][j] = (idd ? (i == j) : 0);
        }
    }

    matrix operator*(const matrix& other)const{
        matrix ans;
        for(int i = 0; i < SZ; ++i){
            for(int j = 0; j < SZ; ++j){
                for(int k = 0; k < SZ; ++k){
                    ans.mat[i][j] += mat[i][k] * other.mat[k][j];
                    if(ans.mat[i][j] > mod) ans.mat[i][j] %= mod;
                }
            }
        }

        return ans;
    }
};


matrix exponentiation(matrix base, int K){
    matrix ans(1);

    while(K){
        if(k & 1)
            ans = ans * base;
        base = base * base;
        K >>= 1;
    }

    return ans;
}


int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N, K;
    cin >> N >> K;

    matrix base;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j)
            cin >> base.mat[i][j];
    }
    
    matrix ans = exponentiation(base, K);

    int paths = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j)
            paths = (paths + ans.mat[i][j]) % mod;
    }

    cout << paths << "\n";

    return 0;
}


Compiler output:
a.cc: In function 'matrix exponentiation(matrix, long long int)':
a.cc:67:12: error: 'k' was not declared in this scope
   67 |         if(k & 1)
      |            ^
Language: C

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 200007
ll a[51][51],res[51][51],t[51][51],n,k;

void power()
{
    int i,j,r;
    fo(i,0,n) res[i][i]=1;
    while (k > 0)
    {
       if (k & (1ll)){
            fo(i,0,n)
            {
                fo(j,0,n)
                {
                    t[i][j]=0;
                    fo(r,0,n)
                    {
                        t[i][j]=(t[i][j] + ((res[i][r])*(a[r][j]))%mo)%mo;
                    }
                }
            }
            fo(i,0,n)
            {
                fo(j,0,n) res[i][j]=t[i][j];
            }
       }
        k = k>>(1ll);
        fo(i,0,n)
        {
            fo(j,0,n)
            {
                t[i][j]=0;
                fo(r,0,n)
                {
                    t[i][j]=(t[i][j] + ((a[i][r])*(a[r][j]))%mo)%mo;
                }
            }
        }
        fo(i,0,n)
        {
            fo(j,0,n) a[i][j]=t[i][j];
        }
    }
}

int main()
{
    ll i,j,x,y,ans=0;
    cin>>n>>k;
    fo(i,0,n)
    {
        fo(j,0,n) cin>>a[i][j];
    }
    power();
    fo(i,0,n)
    {
        fo(j,0,n) ans=(ans + res[i][j])%mo;
    }
    cout<<ans<<endl;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.