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

#include <bits/stdc++.h>

#define maxn 100010
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
int a[maxn], q[maxn];
long long f[maxn];
int main()
{
	int n,m,T;
        scanf("%d%d%d",&n,&m,&T);
	for (int i=1;i<=n;++i)scanf("%d",&a[i]);
	int p = 1, h = 0, t = 0;
        long long fp = 1234567891234567ll;
	for (int i = 1; i <= n; ++i)
	{
		while ((a[i] - a[p]) * 2 > T) cmin(fp, f[p - 1] - 2 * a[p]), ++p;
		while (head < tail && (a[i] - a[q[head + 1]]) * 2 > T) ++head;
		f[i] = 1ll * i * T;
		cmin(f[i], fp + 2 * a[i]);
		head < tail ? cmin(f[i], f[q[head + 1] - 1] + T) : 0;
		cmin(f[i], f[i - 1] + T);
		while (head < tail && f[q[tail] - 1] > f[i]) --tail;
		q[++tail] = i;
	}
	printf("%lld\n", f[n] + m);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:24: error: 'head' was not declared in this scope; did you mean 'read'?
   17 |                 while (head < tail && (a[i] - a[q[head + 1]]) * 2 > T) ++head;
      |                        ^~~~
      |                        read
a.cc:17:31: error: 'tail' was not declared in this scope; did you mean 'tanl'?
   17 |                 while (head < tail && (a[i] - a[q[head + 1]]) * 2 > T) ++head;
      |                               ^~~~
      |                               tanl
a.cc:20:17: error: 'head' was not declared in this scope; did you mean 'read'?
   20 |                 head < tail ? cmin(f[i], f[q[head + 1] - 1] + T) : 0;
      |                 ^~~~
      |                 read
a.cc:20:24: error: 'tail' was not declared in this scope; did you mean 'tanl'?
   20 |                 head < tail ? cmin(f[i], f[q[head + 1] - 1] + T) : 0;
      |                        ^~~~
      |                        tanl
Language: C++

#include <string>
#include <iostream>
#include <vector>

using namespace std;

int main(){
  long long int N, E, T, tot = 0;
  cin >> N >> E >> T;
  long long int x[N];

  for(int i; i<N; i++){
    tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
  }
  tot+=x[0]+(E-x[N-1]);

  cout << tot << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:53: error: no matching function for call to 'max(int, long long int)'
   13 |     tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
      |                                                  ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string: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:13:53: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   13 |     tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
      |                                                  ~~~^~~~~~~~~~~~~~~~~~~~
/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
a.cc:13:79: error: no matching function for call to 'max(int, long long int)'
   13 |     tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
      |                                                                            ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:13:79: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   13 |     tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
      |                                                                            ~~~^~~~~~~~~~~~~~~~~~~~~~
/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
Language: C++

#include <iostream>
#include <vector>

using namespace std;

#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}

vector<vector<pll>> E;

vector<pll> solve(int u, ll T) {
    if (E[u].empty()) {
        return {{0LL,0LL}};
    } else {
        auto A = solve(E[u][0].x, T);
        auto B = solve(E[u][1].x, T);
        for (auto &a: A) { a.x += E[u][0].y; a.y += E[u][0].y; }
        for (auto &b: B) { b.x += E[u][1].y; b.y += E[u][1].y; }
        vector<pll> Ans;
        for (int t = 0; t < 2; ++t) {
            int i = 0, j = B.size()-1;
            for (pll a: A) {
                while (i < B.size() && B[i].y + a.x > T) ++i;
                while (j >= 0 && B[j].x + a.x > T) --j;
                if (i != B.size()) Ans.emplace_back(min(a.y,B[i].x),max(a.y,B[i].x));
                if (j >= 0) Ans.emplace_back(min(a.y,B[i].y),max(a.y,B[i].y));
            }
            
            for (pll&a:A) swap(a.x, a.y);
            reverse(A.begin(),A.end());
        }

        sort(Ans.begin(),Ans.end());
        vector<pll> F;
        for (pll ans: Ans) if (F.empty() || F.back().y > ans.y) F.push_back(ans);
        return F;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    int N; cin >> N;
    E.resize(N);
    for (int i = 1; i < N; ++i) {
        int p, c; cin >> p >> c;
        --p;
        E[p].push_back({i,c});
    }

  //  solve(0, 4LL);
//return 0;
    cout << bsl(0LL, 18000000000LL, [](ll v) {
        auto s = solve(0, v);
        //cout << v << ' ' << s.empty() << endl;
        return !s.empty();
    }) << endl;
}


Compiler output:
a.cc: In function 'std::vector<std::pair<long long int, long long int> > solve(int, ll)':
a.cc:36:13: error: 'reverse' was not declared in this scope
   36 |             reverse(A.begin(),A.end());
      |             ^~~~~~~
a.cc:39:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   39 |         sort(Ans.begin(),Ans.end());
      |         ^~~~
      |         short
Language: C++

#include<bits/stdc++.h>

using namespace std;

inline int read()
{
    int x=0;char ch=getchar();
    while(ch<'0'|| ch>'9')ch=getchar();
    while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
    return x;
}

typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vec;
#define x first
#define y second
const int N=131100;

int n,fa[N];
vec g[N],f[N];
ll mid,mv[N];

inline bool cmpx(pr a,pr b){return a.x<b.x;}
inline bool cmpy(pr a,pr b){return a.y<b.y;}

inline void work(vec &ls,vec &rs,vec &f)
{
    if(ls.size()>rs.size())swap(ls,rs);
    int el=ls.size(),er=rs.size();

    sort(ls.begin(),ls.end(),cmpy);
    sort(rs.begin(),rs.end(),cmpx);Q

    mv[0]=rs[0].y;
    for(int i=1;i<er;i++)
        mv[i]=min(mv[i-1],rs[i].y);

    for(int i=0,j=er-1;i<el;i++)
    {
        while(j>=0 && ls[i].y+rs[j].x>mid)j--;
        if(j>=0)f.push_back(pr(ls[i].x,mv[j]));
    }

    sort(ls.begin(),ls.end(),cmpx);
    sort(rs.begin(),rs.end(),cmpy);
    mv[0]=rs[0].x;
    for(int i=1;i<er;i++)
        mv[i]=min(mv[i-1],rs[i].x);

    for(int i=0,j=er-1;i<el;i++)
    {
        while(j>=0 && ls[i].x+rs[j].y>mid)j--;
        if(j>=0)f.push_back(pr(mv[j],ls[i].y));
    }
}

inline void dfs(int u)
{
    if(!f[u].empty())f[u].clear();
    if(g[u].empty())
    {
        f[u].push_back(pr(0,0));
        return;
    }

    for(int i=0,e=g[u].size();i<e;i++)
        dfs(g[u][i].x);

    vec &ls=f[g[u][0].x];
    for(int i=0,e=ls.size(),c=g[u][0].y;i<e;i++)
        ls[i].x+=c,ls[i].y+=c;
    vec &rs=f[g[u][1].x];
    for(int i=0,e=rs.size(),c=g[u][1].y;i<e;i++)
        rs[i].x+=c,rs[i].y+=c;
cout<<ls.size()<<" "<<rs.size()<<endl;
    work(ls,rs,f[u]);
    ls.clear();
    rs.clear();
}

int main()
{
    n=read();
    for(int i=2,a;i<=n;i++)
    {
        fa[i]=read();
        g[fa[i]].push_back(pr(i,read()));
    }

    ll l=0,r=1e10,ans=1e10;
    while(l<=r)
    {
        mid=l+r>>1;
cout<<l<<" "<<r<<" "<<mid<<endl;
        dfs(1);
        if(f[1].empty())
            l=mid+1;
        else
            r=mid-1,ans=mid;
    }

    printf("%lld\n",ans);
    return 0;
}

Compiler output:
a.cc: In function 'void work(vec&, vec&, vec&)':
a.cc:33:36: error: 'Q' was not declared in this scope
   33 |     sort(rs.begin(),rs.end(),cmpx);Q
      |                                    ^
Language: C++

#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,a) for (int i=0; i<(a); ++i)
#define PER(i,a) for (int i=int(a)-1; i>=0; --i)
using namespace std;
typedef long long LL;

const int maxn = 150005;
struct node { LL x, y; } f[maxn], g[maxn];
int l[maxn], r[maxn], v[maxn], n, fa;
vector<node> a[maxn];
LL L, R, mid;

inline bool operator < (node a, node b) {
	return a.x < b.x || a.x == b.x && a.y < b.y;
}

void merge(vector<node> &a, vector<node> &b, vector<node> &c, LL limit) {
	int n = 0, m = 0, cur = 0, p = 1, q = 1;
	REP (i, a.size()) {
		while (cur + 1 < b.size() && a[i].y + b[cur+1].x <= limit) cur++;
		if (cur < b.size() && a[i].y + b[cur].x <= limit) f[++n] = (node){a[i].x, b[cur].y};
	}
	cur = int(b.size())-1;
	PER (i, a.size()) {
		while (cur - 1 >= 0 && a[i].x + b[cur-1].y <= limit) cur--;
		if (cur >= 0 && a[i].x + b[cur].y <= limit) g[++m] = (node){b[cur].x, a[i].y};
	}
	rep (i, 1, m/2) swap(g[i], g[m+1-i]);
	while (p <= n || q <= m) {
		if (p <= n && (q > m || f[p] < g[q])) c.push_back(f[p]);
		else c.push_back(g[q]);
		while (p <= n && (c.back().x == f[p].x || c.back().y <= f[p].y) p++;
		while (q <= m && (c.back().x == g[q].x || c.back().y <= g[q].y) q++;
	}
}

bool check(LL limit) {
	// printf("======= %lld =======\n", limit);
	per (i, n, 1) {
		a[i].clear();
		if (!l[i]) {
			a[i].push_back((node){v[i], v[i]});
			continue;
		}
		if (a[l[i]].size() < a[r[i]].size())
			merge(a[l[i]], a[r[i]], a[i], limit);
		else
			merge(a[r[i]], a[l[i]], a[i], limit);
		if (a[i].empty()) return 0;
		REP (j, a[i].size())
			a[i][j].x += v[i], a[i][j].y += v[i];
		// printf("%d  ", i);
		// REP (j, a[i].size())
			// printf("(%d,%d) ", a[i][j].x, a[i][j].y);
		// puts("");
	}
	return 1;
}

int main() {
	scanf("%d", &n);
	rep (i, 2, n) {
		scanf("%d%d", &fa, &v[i]);
		if (!l[fa]) l[fa] = i;
		else r[fa] = i;
	}
	L = 0; R = 1LL << 34;
	while (L < R) {
		mid = (L + R) >> 1;
		if (check(mid)) R = mid;
		else L = mid + 1;
	}
	printf("%lld\n", L);
	return 0;
}

Compiler output:
a.cc: In function 'void merge(std::vector<node>&, std::vector<node>&, std::vector<node>&, LL)':
a.cc:34:80: error: expected ')' before 'p'
   34 |                 while (p <= n && (c.back().x == f[p].x || c.back().y <= f[p].y) p++;
      |                       ~                                                        ^~
      |                                                                                )
a.cc:35:80: error: expected ')' before 'q'
   35 |                 while (q <= m && (c.back().x == g[q].x || c.back().y <= g[q].y) q++;
      |                       ~                                                        ^~
      |                                                                                )
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
 
using namespace std;
 
const int MAXN = 2e5 + 10;
long long oo = 100000000000007ll;
 
class Edges{
public:
	int next , to , v;
};
Edges edge[MAXN];
int fa[MAXN] , first[MAXN];
int n , te = 0 , ans = 0;
void add(int s , int t , int v){
	++ te;
	edge[te].to = t;
	edge[te].next = first[s];
	edge[te].v = v;
	first[s] = te;
}
long long work(int now){
	long long maxn = 0 , t = oo;
	for(int e = first[now] ; e ; e = edge[e].next){
		int to = edge[e].to;
                long long ret = work(to);
		maxn += ret + edge[e].v;
		t = min(ret + edge[e].v , t);
	}
	ans = max(ans , maxn);
	if(t == oo) t = 0;
	return t;
}
int main(){
	ios::sync_with_stdio(0);
	cin >> n;
	for(int i = 2 ; i <= n ; ++ i){
		int a , v;
		cin >> a >> v;
		add(a , i , v);
	}
	work(1);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'long long int work(int)':
a.cc:32:18: error: no matching function for call to 'max(int&, long long int&)'
   32 |         ans = max(ans , maxn);
      |               ~~~^~~~~~~~~~~~
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:32:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |         ans = max(ans , maxn);
      |               ~~~^~~~~~~~~~~~
/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
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
     
const int maxn = 2e5;
     
int n, son[maxn][2], len[maxn];
long long ans;
typedef pair<long long, long long> Pair;
vector<Pair> set[maxn];
     
void Combine(vector<Pair> &s, int u, int v) {
  s.clear();
  if (u.empty()) {
    return;
  }
  for (int i = 0, j = 0; i < set[u].size(); ++i) {
    if (len[u] + len[v] + set[u][i].second + set[v][j].first > ans) {
      continue;
    }
    while (j + 1 < set[v].size() &&
           len[u] + len[v] + set[u][i].second + set[v][j + 1].first <= ans) {
      ++j;
    }
    s.push_back(Pair(len[u] + set[u][i].first, len[v] + set[v][j].second));
  }
  int m = s.size();
  for (int i = set[u].size() - 1, j = set[v].size() - 1; i >= 0; --i) {
    if (len[u] + len[v] + set[v][j].second + set[u][i].first > ans) {
      continue;
    }
    while (j > 0 &&
           len[u] + len[v] + set[v][j - 1].second + set[u][i].first <= ans) {
      --j;
    }
    s.push_back(Pair(len[v] + set[v][j].first, len[u] + set[u][i].second));
  }
  inplace_merge(s.begin(), s.begin() + m, s.end());
  m = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (i == 0 || s[i].second < s[i - 1].second) {
      s[m++] = s[i];
    }
  }
  s.resize(m);
}
     
bool Check(void) {
  for (int i = n - 1; i >= 0; --i) {
    if (son[i][0] == -1) {
      set[i] = {Pair(0, 0)};
    } else {
      int &u = son[i][0], &v = son[i][1];
      if (set[u].size() > set[v].size()) {
        swap(u, v);
      }
      Combine(set[i], u, v);
    }
  }
  return set[0].size();
}
     
int main(void) {
  scanf("%d", &n);
  memset(son, -1, sizeof son);
  for (int i = 1; i < n; ++i) {
    int par;
    scanf("%d%d", &par, len + i);
    --par;
    swap(son[par][0], son[par][1]);
    son[par][0] = i;
  }
  long long low = 0, high = (long long)maxn * maxn;
  while (low < high) {
    long long mid = low + high >> 1;
    ans = mid;
    if (Check()) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  printf("%lld\n", low);
  return 0;
}


Compiler output:
a.cc: In function 'void Combine(std::vector<std::pair<long long int, long long int> >&, int, int)':
a.cc:16:9: error: request for member 'empty' in 'u', which is of non-class type 'int'
   16 |   if (u.empty()) {
      |         ^~~~~
Language: C++

#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;
typedef vector<pair<ll,ll> > Vp;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=140000+19;

struct Edge{
	int y,z,nxt;
} E[N*2];

int las[N];
int n,cnt,x;
Vp F[N];
ll l,r,mid;

void Add_Edge(int x,int y,int z){
	E[cnt]=(Edge){y,z,las[x]};las[x]=cnt++;
}
Vp Merge(Vp A,Vp B){
	Vp res,ans;
	int c=-1;
	For(i,0,A.size()){
		for (;c+1<B.size()&&A[i].se+B[c+1].fi<=mid;c++);
		if (c>=0) res.pb(mp(A[i].fi,B[c].se));
	}
	c=-1;
	For(i,0,B.size()){
		for (;c+1<A.size()&&B[i].se+A[c+1].fi<=mid;c++);
		if (c>=0) res.pb(mp(B[i].fi,A[c].se));
	}
	sort(res.begin(),res.end());
	For(i,0,res.size()){
		//if (res[i].fi>mid||res[i].se>mid) continue;
		if (!ans.empty()&&res[i].se>=ans.back().se) continue;
		ans.pb(res[i]);
	}
	return ans;
}
void dfs(int x){
	if (las[x]==-1){
		F[x]={mp(0,0)};
		return;
	}
	int len[2],to[2],c=0;
	for (int i=las[x],y;~i;i=E[i].nxt){
		to[c]=E[i].y;
		dfs(to[c]);
		len[c++]=E[i].z;
	}
	For(i,0,2) For(j,0,F[to[i]].size()){
		F[to[i]][j].fi+=len[i];
		F[to[i]][j].se+=len[i];
	}
	F[x7
1 1
1 1
2 1
2 1
3 1
3 1]=Merge(F[to[0]],F[to[1]]);
}

int main(){
	//freopen("048.txt","r",stdin);
	memset(las,-1,sizeof(las));
	n=IN();
	For(i,2,n+1){
		x=IN();
		Add_Edge(x,i,IN());
	}
	l=0,r=131072ll*n;
	while (l<=r){
		mid=(l+r)/2;
		dfs(1);
		if (!F[1].empty()) r=mid-1;else l=mid+1;
	}
	cout<<r+1<<endl;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:87:11: error: 'x7' was not declared in this scope; did you mean 'x'?
   87 |         F[x7
      |           ^~
      |           x
a.cc:87:13: error: expected ']' before numeric constant
   87 |         F[x7
      |             ^
      |             ]
   88 | 1 1
      | ~
Language: C++

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back
#define x first
#define y second
#define mp make_pair

using namespace std;

const int N = 132000;

typedef long long LL;
typedef pair<LL, LL> PII;

int lc[N], rc[N];
int val[N], fa[N], n;
vector<PII> c[N];
LL lim;

bool cmp(PII u, PII v){
	return u.x < v.x;
}

bool DFS(int o){
	if(!lc[o]){
		c[o].pb(mp(val[o], val[o]));
		return true;
	}

	if(!DFS(lc[o])) return false;
	if(!DFS(rc[o])) return false;
	if(c[lc[o]].size() > c[rc[o]].size()) swap(lc[o], rc[o]);

	int u = lc[o], v = rc[o];
	int m = c[v].size(), p = m - 1;
	for(PII i : c[u]){
		while(p >= 0 && i.x + c[v][p].x > lim) --p;
		if(p < 0) break;
		//printf("%lld %lld %d\n", i.x, c[v][p].x, p);
		c[o].pb(mp(i.y, c[v][p].y)), c[o].pb(mp(c[v][p].y, i.y));
	}
	sort(c[o].begin(), c[o].end(), cmp);

	if(!c[o].size()) return false;

	//printf("%d:\n", o);
	for(PII& i : c[o]){
		i.x += val[o], i.y += val[o];
	//	printf("%lld %lld\n", i.x, i.y);
	}
	return true;
}

int main(){
	scanf("%d", &n);
	For(i, 2, n){
		scanf("%d%d", &fa[i], &val[i]);
		if(lc[fa[i]]) rc[fa[i]] = i;
		else lc[fa[i]] = i;
	}
	LL L = 0, R = 1ll << 35;
	while(L < R){
		lim = (L + R) >> 1;
		For(i, 1, n) c[i].clear();
		//printf("------\n%lld\n", lim);
		if(DFS(1)) R = lim;
		else L = lim + 1;
	}
	printf("%lld\n", L);
	return 0;
}

Compiler output:
a.cc:23:1: error: 'vector' does not name a type
   23 | vector<PII> c[N];
      | ^~~~~~
a.cc: In function 'bool DFS(int)':
a.cc:32:17: error: 'c' was not declared in this scope
   32 |                 c[o].pb(mp(val[o], val[o]));
      |                 ^
a.cc:38:12: error: 'c' was not declared in this scope
   38 |         if(c[lc[o]].size() > c[rc[o]].size()) swap(lc[o], rc[o]);
      |            ^
a.cc:41:17: error: 'c' was not declared in this scope
   41 |         int m = c[v].size(), p = m - 1;
      |                 ^
a.cc:43:23: error: 'p' was not declared in this scope
   43 |                 while(p >= 0 && i.x + c[v][p].x > lim) --p;
      |                       ^
a.cc:44:20: error: 'p' was not declared in this scope
   44 |                 if(p < 0) break;
      |                    ^
a.cc:46:38: error: 'p' was not declared in this scope
   46 |                 c[o].pb(mp(i.y, c[v][p].y)), c[o].pb(mp(c[v][p].y, i.y));
      |                                      ^
a.cc: In function 'int main()':
a.cc:70:30: error: 'c' was not declared in this scope
   70 |                 For(i, 1, n) c[i].clear();
      |                              ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
typedef pair<ll,ll> P;
int N;
const int MN=1<<17;
int ch[MN][2],co[MN],sz[MN];
vector<P> vp[MN];
vector<P> tmp1,tmp2,tmp;

vector<P> norm(vector<P>& vc){
	vector<P> ret;
	for(P p:vc){
		if(ret.empty() || ret.back().sc!=p.sc) ret.pb(p);
	}
	return ret;
}
bool can(ll X){
	rep(i,N) vp[i].clear();
	for(int v=N-1;v>=0;v--){
		if(ch[v][0]==-1){
			sz[v]=1;
			vp[v].pb(P(co[v],co[v]));
		}else{
			tmp1.clear();tmp2.clear();
			int a=ch[v][0],b=ch[v][1];
			if(sz[a]>sz[b]) swap(a,b);
			int j=0;
			int A = vp[a].size();
			rep(i,A){
				P p=vp[a][i];
				ll left=X-p.sc;
				while(j<B && vp[b][j].fs<=left) j++;
				if(j==0) continue;
				ll l=p.fs+co[v],r=vp[b][j-1].sc+co[v];
				if(v==0) return 1;
				tmp1.pb(P(l,r));
			}
			tmp1=norm(tmp1);
			int K=tmp1.size();
			tmp2.assign(K,P(0,0));
			rep(i,K){
				P p=tmp1[i];
				tmp2[K-1-i]=P(p.sc,p.fs);
			}
			tmp.assign(2*K,P(0,0));
			merge(all(tmp1),all(tmp2),tmp.begin());
			ll mn=1e18;
			rep(i,2*K){
				P p=tmp[i];
				ll l=p.fs,r=p.sc;
				chmin(mn,r);
				if(i==2*K-1 || tmp[i].fs!=tmp[i+1].fs) vp[v].pb(P(l,mn));
			}
			tmp=vp[v];
			vp[v].clear();
			K=tmp.size();
			rep(i,K){
				if(i==K-1||tmp[i].sc!=tmp[i+1].sc) vp[v].pb(tmp[i]);
			}
		}
		if(vp[v].empty()) return 0;
	}
	return 1;
}
int main(){
	cin>>N;
	rep(i,N) rep(j,2) ch[i][j]=-1;
	rep(i,N-1){
		int a,v;
		cin>>a>>v;
		a--;
		if(ch[a][0]==-1){
			ch[a][0]=i+1;
		}else{
			ch[a][1]=i+1;
		}
		co[i+1]=v;
	}
	ll ub=131072*40,lb=-1;
	while(ub-lb>1){
		ll m=(ub+lb)/2;
		if(can(m)) ub=m;
		else lb=m;
	}
	cout<<ub<<endl;
}


Compiler output:
a.cc: In function 'bool can(ll)':
a.cc:44:41: error: 'B' was not declared in this scope
   44 |                                 while(j<B && vp[b][j].fs<=left) j++;
      |                                         ^
Language: C++

#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();

	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 150000 + 5;

struct node {
	LL a, b;
	node(LL _a = 0, LL _b = 0) {a = _a, b = _b;}
	bool operator < (const node &T) {
		if (a == T.a) return b < T.b;
		return a < T.a;
	}
};

int n; LL V;
std::vector<LL> w[N];
std::vector<int> v[N];
std::vector<node> S[N];

void dfs(int x) {
	//printf("%d\n", x);
	S[x].clear();
	if (!v[x].size()) {S[x].push_back(node(0, 0)); return;}
	int k = v[x][0], l = v[x][1];
	LL vk = w[x][0], vl = w[x][1];
	dfs(k); dfs(l);
	if (S[k].size() > S[l].size()) swap(k, l), swap(vk, vl);
	if (!S[k].size()) return;
	for (int i = 0, j = 0; i < S[k].size(); i++) {
		LL a = S[k][i].a, b = S[k][i].b;
		while (j + 1 < S[l].size() && b + S[l][j + 1].a + vk + vl <= V) j++;
		if (b + S[l][j].a + vk + vl <= V) S[x].push_back(node(a + vk, S[l][j].b + vl));
	}
	for (int i = 0, j = S[l].size() - 1; i < S[k].size(); i++) {
		LL a = S[k][i].a, b = S[k][i].b;
		while (j && a + S[l][j - 1].b + vk + vl <= V) j--;
		if (a + S[l][j].b + vk + vl <= V) S[x].push_back(node(S[l][j].a + vl, b + vk));
	}
	sort(S[x].begin(), S[x].end());
}

int check(LL val) {
	V = val; dfs(1);
	return S[1].size() ? 1 : 0;
}

int main() {
	//freopen("d.in", "r", stdin);
	read(n);
	LL l = 0, r = 0, ans;
	LL x, y;
	for (int i = 2; i <= n; i++) {
		read(x), read(y);
		v[x].push_back(i);
		w[x].push_back(y);
		r += y;
	}
	check
	while (l <= r) {
		LL m = (l + r) >> 1;
		if (check(m)) {
			ans = m;
			r = m - 1;
		} else l = m + 1;
	}
	while (1);
	printf("%lld\n", ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:72:14: error: expected ';' before 'while'
   72 |         check
      |              ^
      |              ;
   73 |         while (l <= r) {
      |         ~~~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e6;
int n,s[N+1],t[N+1];
int hea=1,tai,que[N+2];
int res;
void input(int x[])
{
	static char str[N+2];
	scanf("%s",str+1);
	for(int i=1;i<=n;++i) {
		x[i]=str[i]-'a';
	}
	return;
}
bool check0()
{
	for(int i=1;i<=n;++i) {
		if(s[i]!=t[i]) {
			return false;
		}
	}
	return true;
}
int main()
{
	scanf("%d",&n);
	input(s);
	input(t);
	if(check0()) {
		puts("0")
		return 0;
	}
	for(int spos=n,tpos=n;tpos;--tpos) {
		while((tpos>1)&&(t[tpos-1]==t[tpos])) {
			--tpos;
		}
		while(spos&&((spos>tpos)||(s[spos]!=t[tpos]))) {
			--spos;
		}
		if(!spos) {
			puts("-1");
			return 0;
		}
		while((hea<=tai)&&(que[hea]-(tai-hea+1)+1>tpos)) {
			++hea;
		}
		que[++tai]=spos;
		res=max(res,tai-hea+1);
	}
	++res;
	printf("%d\n",res);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:26: error: expected ';' before 'return'
   33 |                 puts("0")
      |                          ^
      |                          ;
   34 |                 return 0;
      |                 ~~~~~~
Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#incl ude <map>
using namespace std;
const int MAXN = 1000005;
char S[MAXN], T[MAXN];
int n, q[MAXN], head = 1, tail;
signed main () {
	scanf("%d%s%s", &n, S+1, T+1);
	if(strcmp(S+1, T+1) == 0) { puts("0"); return 0; }
	int ans = 0;
	for(int i = n, j = n; i >= 1; --i) {
		if(T[i] == T[i-1]) continue;
		j = min(j, i);
		for(; j && S[j] != T[i]; --j);
		if(!j) { puts("-1"); return 0; }
		while(head <= tail && q[head] - (tail-head+1) + 1 > i) ++head;
		q[++tail] = j;
		if(i != pos) ans = max(ans, tail-head+1);
	}
	printf("%d\n", ans+1);
}

Compiler output:
a.cc:6:2: error: invalid preprocessing directive #incl; did you mean #include?
    6 | #incl ude <map>
      |  ^~~~
      |  include
a.cc: In function 'int main()':
a.cc:22:25: error: 'pos' was not declared in this scope
   22 |                 if(i != pos) ans = max(ans, tail-head+1);
      |                         ^~~
Language: C++

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;
char s[1000005],t[1000005];
queue <int> Q;
int n;
bool check()
{
	for(int i=1;i<=n;i++)if(s[i]!=t[i])return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	scanf("%s%s",s+1,t+1);
	if(check()){printf("0\n");return 0;}
	int head=1,tail=0;
	int posi=n;
	int ans=0;
	for(int i=n;i>=1;i--)
	{
		if(t[i]==t[i-1])continue;
		posi=min(posi,i);
		while(posi&&t[i]!=s[posi])posi--;
		if(!posi){printf("-1\n");return 0;}
		while(!Q.empty())
		{
			if((int)Q.front()-(int)Q,size()>=i)Q.pop();
			else break;
		}
		Q.push(posi);
		if(i!=posi)ans=max(ans,(int)Q.size());
	}
	printf("%d\n",ans+1);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:43: error: invalid cast from type 'std::queue<int>' to type 'int'
   34 |                         if((int)Q.front()-(int)Q,size()>=i)Q.pop();
      |                                           ^~~~~~
a.cc:34:54: error: no matching function for call to 'size()'
   34 |                         if((int)Q.front()-(int)Q,size()>=i)Q.pop();
      |                                                  ~~~~^~
In file included from /usr/include/c++/14/string:53,
                 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:5:
/usr/include/c++/14/bits/range_access.h:262:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note:   candidate expects 1 argument, 0 provided
Language: C++

//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#define YESNO(x) OUT(three(x,YES,NO))
#define YesNo(x) OUT(three(x,Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define all ALL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef LL ll;
typedef double ld;
typedef LL ut;
const LL INF = 1LL << 60;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ppr, Vppr ,greater<ppr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 =2e6 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 22;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;const long double EPS = 1e-7;
ut N, M, K, X, L, Y,H,W,Q,D;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
LL A[SIZE], B[SIZE],I[SIZE];
string s, t;
LL solve() {
	cin >> N;
	cin >> s >> t;
	int now = N - 1;
	LL ans = 0;
	RREP(i, N) {
		now = min(now, i);
		while (now>=0 and s[now] != t[i]) now--;
		if (now < 0) return -1;
		A[i] = now;
		B[i] =abs(i - now)>0;

		if (i + 1 < N and A[i] == A[i + 1]) {
			if (abs(i - now) > 0) MX(B[i], last-1);
		}
		else {
			if(i!=now)
				B[i] = max<LL>(abs(i - now)>0, B[i + 1] + 1);

		}
		MX(ans, B[i]);
	}

	return ans;
}
signed main() {
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cout << solve() << endl;
	//	cin >> N;
	return 0;
}

Compiler output:
a.cc: In function 'LL solve()':
a.cc:81:56: error: 'last' was not declared in this scope
   81 |                         if (abs(i - now) > 0) MX(B[i], last-1);
      |                                                        ^~~~
Language: C++

#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#define RG register
using namespace std;
const int N=1e6+10;
int n,ans;
char st[N],ed[N];
queue<int> pn;
inline int mi(int a,int b){return a<b ? a : b;}
inline int mx(int a,int b){return a>b ? a : b;}
int main()
{
//	freopen("Shik and Copying String.in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%s%s",&n,st+1,ed+1);
	if(!strcmp(s+1,t+1)) return printf("-1\n"), 0;
	for(int i=n,j=n;i;i--)
	{
		if(ed[i]==ed[i-1]) continue;
		j=mi(i,j);
		while(ed[i]!=st[j] && j) j--;
		if(!j) return printf("-1\n"), 0;
		while(!pn.empty())
		{
			if((int)pn.front()-(int)pn.size()>=i) pn.pop();
			else break;
		}
		pn.push(j);
		if(i!=j) ans=mx(ans,(int)pn.size());
	}
	printf("%d\n",ans+1);
	//fclose(stdin); fclose(stdout);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:20: error: 's' was not declared in this scope; did you mean 'st'?
   18 |         if(!strcmp(s+1,t+1)) return printf("-1\n"), 0;
      |                    ^
      |                    st
a.cc:18:24: error: 't' was not declared in this scope; did you mean 'tm'?
   18 |         if(!strcmp(s+1,t+1)) return printf("-1\n"), 0;
      |                        ^
      |                        tm
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int N=1000005;
int n,m;
int b[N],tb=0,a[N];
int st[N],top=0;
char S[N],T[N];
int main(){
	scanf("%d%s%s",&n,S+1,T+1);
	T[0]=T[1]-1;
	for (int i=1;i<=n;i++)
		if (T[i]!=T[i-1])
			b[++tb]=i;
	ta=tb;
	for (int i=n;i>=1;i--)
		if (i<=b[ta]&&S[i]==T[b[ta]])
			a[ta--]=i;
	m=tb;
	if (ta>0)
		return puts("-1"),0;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'ta' was not declared in this scope; did you mean 'tm'?
   14 |         ta=tb;
      |         ^~
      |         tm
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 30, INF = 1e9, MAXN = 1e6 + 10;
int mn[MAX];
vector <int> index[MAX];
bitset <MAX> b, flag;
bool cmp(int a, int b) {
    return mn[a] < mn[b];
}
int h[MAX];
int32_t main () {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s, t;
    int n;
    cin >>n >>  s >> t;
    for (int i = 0; i < MAX; ++i)
        mn[i] = INF;
    bool zero = true;
    for (int i = 0; i < n; ++i) {
        if (s[i] != t[i])
            zero = false;
        if (mn[s[i] - 'a'] == INF)
            mn[s[i] - 'a'] = i;
        if (mn[t[i] - 'a'] == INF)
            return cout << -1, 0;
    }
    if (zero)
        return cout << 0, 0;
    for (int i = n - 1; i >= 0; --i) {
        b[t[i] - 'a'] = true;
        int now = s[i] - 'a';
        if (b[now])
            index[now].push_back(i);
    }
    vector <int> vctr;
    for (int i = 0; i < MAX; ++i)
        if (b[i])
            vctr.push_back(i);
    sort(vctr.begin(), vctr.end());
    int mx =0;
    for (auto i : vctr) {
        // cout << i << ':';
        if (index[i].empty())
            continue;
        h[i] = INF;
        for (auto j : index[i]) {
            if (s[j] == t[j])
                h[i] = 0;
            // cout << j << ' ';
            h[i] = min(h[i], h[t[j] - 'a'] + 1);
        }
        mx = max(mx, h[i]);
    }
    cout<< mx + 1;
    return 0;
}

Compiler output:
a.cc:6:23: error: 'std::vector<long long int> index [30]' redeclared as different kind of entity
    6 | vector <int> index[MAX];
      |                       ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int32_t main()':
a.cc:34:18: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   34 |             index[now].push_back(i);
      |                  ^
a.cc:44:18: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   44 |         if (index[i].empty())
      |                  ^
a.cc:47:28: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   47 |         for (auto j : index[i]) {
      |                            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,lst[1000100][26],gg[1000100];
char s[1000100],t[1000100];

struct treaps
{
	int son[1201000][2],size[1201000],num[1201000],tag[1201000],rd[1200100],tt;
	void update(int s){size[s]=size[son[s][0]]+size[son[s][1]]+1;}
	int build(int n)
	{
		if (n==0) return 0;
		int s=++tt;size[s]=1;rd[s]=rand();
		n--;
		son[s][0]=build(n/2);son[s][1]=build(n-n/2);
		update(s);
		return s;
	}
	void pushdown(int s)
	{
		if (son[s][0]) {tag[son[s][0]]+=tag[s];num[son[s][0]]+=tag[s];}
		if (son[s][1]) {tag[son[s][1]]+=tag[s];num[son[s][1]]+=tag[s];}
		tag[s]=0;
	}

	void addtag(int s) {tag[s]++;num[s]++;}
	int merge(int s,int t)
	{
		if (!s) return t;
		if (!t) return s;
		pushdown(s);pushdown(t);
		if (rd[s]>rd[t]) {son[s][1]=merge(son[s][1],t);update(s);return s;}
		else {son[t][0]=merge(s,son[t][0]);update(t);return t;}
	}
	pair<int,int> split(int s,int k)
	{
		if (!s) return pair<int,int>(0,0);
		pushdown(s);
		if (size[son[s][0]]>=k)
		{
			pair<int,int> ls=split(son[s][0],k);
			son[s][0]=ls.second;update(s);
			return pair<int,int>(ls.first,s);
		}
		pair<int,int> ls=split(son[s][1],k-size[son[s][0]]-1);
		son[s][1]=ls.first;update(s);
		return pair<int,int>(s,ls.second);
	}
	int findkth(int s,int k)
	{
		pushdown(s);
		if (size[son[s][0]]>=k) return findkth(son[s][0],k);
		if (size[son[s][0]]+1==k) return num[s];
		return findkth(son[s][1],k-(size[son[s][0]]+1));
	}
}treap;
int main()
{
	//freopen("in.txt","r",stdin);
	scanf("%d\n",&n);
	gets(s+1);gets(t+1);
	bool err=false;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<26;j++) lst[i][j]=lst[i-1][j];
		lst[i][s[i]-'a']=i;
		if (s[i]!=t[i]) err=true;
	}
	if (err==false) {printf("0\n");return 0;}
	int root=treap.build(n),ans=1,rem=n;
	for (int i=n;i>=1;i--) if (t[i]!=t[i-1])
	{
		//for (int j=1;j<=i;j++) cout<<treap.findkth(root,j)<<' ';cout<<endl;
		int w=treap.findkth(root,i);
		if ((w!=0)||(s[i]!=t[i])) ans=max(ans,w+2);
		int d=lst[min(i-(w!=0),rem)][t[i]-'a'];rem=d-1;
			if (d==0) {printf("-1\n");return 0;}
			pair<int,int> p=treap.split(root,d-1);
			pair<int,int> q=treap.split(p.second,1);
			treap.addtag(q.second);
			root=treap.merge(p.first,q.second);
		
	}
	printf("%d\n",ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   61 |         gets(s+1);gets(t+1);
      |         ^~~~
      |         getw
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,lst[1000100],gg[1000100];
char s[1000100],t[1000100];

struct treaps
{
	int son[1001000][2],size[1001000],num[1001000],tag[1001000],rd[1000100],tt;
	int build(int n)
	{
		if (n==0) return 0;
		int s=++tt;size[s]=1;rd[s]=rand();
		if (n==1) return s;
		n--;
		son[s][0]=build(n/2);son[s][1]=build(n-n/2);
		update(s);
		return s;
	}
	void pushdown(int s)
	{
		if (son[s][0]) {tag[son[s][0]]+=tag[s];num[son[s][0]]+=tag[s];}
		if (son[s][1]) {tag[son[s][1]]+=tag[s];num[son[s][1]]+=tag[s];}
		tag[s]=0;
	}
	void update(int s){size[s]=size[son[s][0]]+size[son[s][1]]+1;}
	void addtag(int s) {tag[s]++;num[s]++;}
	int merge(int s,int t)
	{
		if (!s) return t;
		if (!t) return s;
		pushdown(s);pushdown(t);
		if (rd[s]>rd[t]) {son[s][1]=merge(son[s][1],t);update(s);return s;}
		else {son[t][0]=merge(s,son[t][0]);update(t);return t;}
	}
	pair<int,int> split(int s,int k)
	{
		if (!s) return pair<int,int>(0,0);
		pushdown(s);
		if (size[son[s][0]]>=k)
		{
			pair<int,int> ls=split(son[s][0],k);
			son[s][0]=ls.second;update(s);
			return pair<int,int>(ls.first,s);
		}
		pair<int,int> ls=split(son[s][1],k-size[son[s][0]]-1);
		son[s][1]=ls.first;update(s);
		return pair<int,int>(s,ls.second);
	}
	int findkth(int s,int k)
	{
		pushdown(s);
		if (size[son[s][0]]>=k) return findkth(son[s][0],k);
		if (size[son[s][0]]+1==k) return num[s];
		return findkth(son[s][1],k-(size[son[s][0]]+1));
	}
}treap;
int p[1000100];
int main()
{
	scanf("%d\n%s\n%s\n",&n,s+1,t+1);
	bool err=false;
	for (int i=1;i<=n;i++)
	{
		gg[i]=p[t[i]];
		p[s[i]]=i;
		if (!p[t[i]]) {printf("-1\n");return 0;}
		lst[i]=p[t[i]];if (lst[i]!=i) err=true;
	}
	if (err==false) {printf("0\n");return 0;}
	int root=treap.build(n);int ans=0;
	for (int i=n;i>=1;i--) if (t[i]!=t[i-1])
	{
		//for (int j=1;j<=i;j++) cout<<treap.findkth(root,j)<<' ';cout<<endl;
		int w=treap.findkth(root,i);
		ans=max(ans,w);
		//if (w)
		{
			if (gg[i]==0) {printf("-1\n");return 0;}
			pair<int,int> p=treap.split(root,gg[i]-1);
			pair<int,int> q=treap.split(p.second,1);
			treap.addtag(q.second);
			root=treap.merge(p.first,q.second);
		}
		else
		{
		}
	}
	printf("%d\n",ans+2);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:17: error: expected '}' before 'else'
   84 |                 else
      |                 ^~~~
a.cc:72:9: note: to match this '{'
   72 |         {
      |         ^
a.cc: At global scope:
a.cc:88:15: error: expected constructor, destructor, or type conversion before '(' token
   88 |         printf("%d\n",ans+2);
      |               ^
a.cc:89:1: error: expected declaration before '}' token
   89 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S,T;
int tar[1010101];
 
int ma;
deque<int> D;

int H[1010100];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S>>T;
	
	if(S==T) return _P("0\n");
	
	MINUS(rev);
	MINUS(tar);
	int R=N-1;
	for(i=N-1;i>=0;i--) if(i==0 || T[i]!=T[i-1]) {
		R=min(i,R);
		while(R>=0 && T[i]!=S[R]) R--;
		if(R<0) return _P("-1\n");
		tar[i]=R;
		R--;
	}
	
	for(i=N-1;i>=0;i--) if(tar[i]>=0 && tar[i]!=i) {
		int cur=H[i]+1;
		for(j=i;j>=tar[i];j--) {
			x = H[j];
			H[j]=cur;
			cur=x+1;
		}
	}
	cout<<*max_element(H,H+N)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:31:15: error: 'rev' was not declared in this scope
   31 |         MINUS(rev);
      |               ^~~
a.cc:12:25: note: in definition of macro 'MINUS'
   12 | #define MINUS(a) memset(a,0xff,sizeof(a))
      |                         ^
Language: C++

#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=1000010;

char s[N],t[N];
int head[130],next[N];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;scanf("%d",&n);
	scanf("%s",s+1);scanf("%s",t+1);
	for (int i=1;i<=n;i++)
	{
		next[i]=head[s[i]];head[s[i]]=i;
	}
	int pre=n+1,ans=0,tmp=0;char ch;
	for (int i=n;i;i--)
	{
		char x;
		if (i<pre) tmp=0;
		if (i>=pre) x=ch; else x=s[i];
		if (x==t[i]) continue;x=t[i];
		tmp++;ans=max(ans,tmp);
		while (head[x]>=i||head[x]>=pre) head[x]=next[head[x]];
		if (!head[x]) {puts("-1");return 0;}
		pre=head[x];ch=x;
	}
	printf("%d\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: reference to 'next' is ambiguous
   21 |                 next[i]=head[s[i]];head[s[i]]=i;
      |                 ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:11:15: note:                 'int next [1000010]'
   11 | int head[130],next[N];
      |               ^~~~
a.cc:31:58: error: reference to 'next' is ambiguous
   31 |                 while (head[x]>=i||head[x]>=pre) head[x]=next[head[x]];
      |                                                          ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:11:15: note:                 'int next [1000010]'
   11 | int head[130],next[N];
      |               ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
set<int>st;
int main()
{
    int i,j,n,t,a,b,c;
    string s,s1,s2;
    cin>>a>>b>>c;
    if(a+b==c||a+c==b||b+c==a)
        cout"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    
    

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: expected ';' before string constant
   11 |         cout"Yes"<<"\n";
      |             ^~~~~
      |             ;
Language: Java

import java . util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int []x ={ input.nextInt(), input.nextInt(), input.nextInt()};
        for (int i = 0; i < x.length; i++) {
            Arrays.sort(x);           
        }
       if (x[2]==x[1]+x[0]){
           System.out.println("yes");
        System.out.println(" Give the pack with" +x[2] +"candies to one student, and give the two packs with"+  x[0]+" and "
                +x[1]+" candies to the other. Then, each gets " +x[2]+" candies");}
       
            System.out.println("no");
        System.out.println("In this case, the student who gets the pack with"  +x[2]+ 
"candies always has more candies than the other Note that every pack must be given to one of them.");

Compiler output:
Main.java:16: error: reached end of file while parsing
"candies always has more candies than the other Note that every pack must be given to one of them.");
                                                                                                     ^
1 error
Language: Java

import java.util.Scanner;

public class FightingOverCandies {
	public void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a, b, c;
		a = in.nextInt();
		b = in.nextInt();
		c = in.nextInt();
		if (a == b + c)
			System.out.println("yes");
		else if (b == a + c)
			System.out.println("yes");
		else if (c == b + a)
			System.out.println("yes");
		else
			System.out.println("no");
		in.close();

	}
}


Compiler output:
Main.java:3: error: class FightingOverCandies is public, should be declared in a file named FightingOverCandies.java
public class FightingOverCandies {
       ^
1 error