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

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



const int M_N=200000;

struct BIT{
    //1-indexed
    LL bit[M_N+1],n;
    //iまでの総和を返す
    LL sum(int i){
        LL s=0;
        while(i>0){
            s=(s + bit[i])%mod;
            i=i&(i-1);
        }
        return s;
    }
    //iにx加算する
    void add(int i,LL x){
        x %= mod;
        while(i<=n){
            bit[i]=(bit[i] + x)%mod;
            i+=i&-i;
        }
    }

};

int main(){
    int n;
    LL A,B;
    cin >> n >> A >> B;
    vector<LL> s(n+1,-LINF);
    for (int i = 0; i < n; i++) {
        cin >> s[i+1];
    }
    BIT bit[2];
    bit[0].n = bit[1].n = n + 1;
    bit[0].add(1,1);
    bit[1].add(1,1);
    int la = 0, lb = 0;
    for (int i = 1; i < n; i++) {
        auto x = upper_bound(ALL(s),s[i+1] - A) - s.begin();
        bit[0].add(i + 1,(bit[1].sum(min(i,(int)x))-bit[1].sum(lb)+mod)%mod);
        auto y = upper_bound(ALL(s),s[i+1] - B) - s.begin();
        bit[1].add(i + 1,(bit[0].sum(min(i,(int)y))-bit[0].sum(la)+mod)%mod);
        if(s[i+1] < s[i] + A) la = i;
        if(s[i+1] < s[i] + B) lb = i;
    }
    cout << (bit[0].sum(n+1) - bit[0].sum(la) + mod)%mod + (bit[1].sum(n+1) - bit[1].sum(lb) + mod)%mod)%mod << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:104: error: expected ';' before ')' token
   66 |     cout << (bit[0].sum(n+1) - bit[0].sum(la) + mod)%mod + (bit[1].sum(n+1) - bit[1].sum(lb) + mod)%mod)%mod << endl;
      |                                                                                                        ^
      |                                                                                                        ;
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
ll v[N],n;
class RangeSum{
public:
	vector<ll> cs;
	void Pb(ll x){
		ll news=x+cs[cs.size()-1];
		news%=mod;
		cs.push_back(news);
	}
	ll sum(ll l,ll r){
		ll res=cs[r]-cs[l-1];
		res%=mod;
		if(res<0)res+=mod;
		return res;
	}
};
class Surf{
public:
	int surf;
	void Update(int i){
		if(v[i]>v[i-1])x=i;
	}
};
class Cut{
	int D,cut;
	void Init(int d){
		D=d;
	}
	void Update(int i){
		if(v[i-1]+D>v[i])cut=i;
	}
};
ll a[N],b[N];
int main(){
	cin>>n;
	lol(i,n)cin>>v[i];
	a[0]=b[0]=1;
	lol(i,n){
		
	}
	return 0;
}


Compiler output:
a.cc: In member function 'void Surf::Update(int)':
a.cc:31:32: error: 'x' was not declared in this scope
   31 |                 if(v[i]>v[i-1])x=i;
      |                                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define int long long
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=100005,mod=1000000007;
ll n,a,b,arr[N];
int f[N],g[N],s1[N],s2[N],s3[N],s4[N];
signed main(){
	n=read(); a=read(); b=read();
	for(int i=1;i<=n;i++)arr[i]=read();
	arr[0]=-4e18;
	arr[n+1]=4e18; f[0]=g[0]=1; f[1]=g[1]=-1; s1[n+1]=s2[n+1]=n+1;
	for(int i=n;i;i--){
		s1[i]=arr[i+1]-arr[i]<a?i+1:s1[i+1];
		s2[i]=arr[i+1]-arr[i]<b?i+1:s2[i+1];
	}
	for(int i=0;i<=n;i++){
		if(i)s3[i]=s3[i-1]; while(arr[s3[i]+1]-arr[i]<a)s3[i]++;
		if(i)s4[i]=s4[i-1]; while(arr[s4[i]+1]-arr[i]<b)s4[i]++;
	}
	for(int i=0;i<n;i++){
		s3[i]=max(s3[i],i+1); s4[i]=max(s4[i],i+1);
		f[i+1]=(f[i+1]+f[i])%mod; 
		if(s3[i]<s2[i+1]){g[s3[i]]=(g[s3[i]]+f[i])%mod;
		g[s2[i+1]]=(g[s2[i+1]]-f[i])%mod;}
		g[i+1]=(g[i+1]+g[i])%mod;
		if(s4[i]<s1[i+1]){f[s4[i]]=(f[s4[i]]+g[i])%mod;
		f[s1[i+1]]=(f[s1[i+1]]-g[i])%mod;}
		//cout<<i<<" "<<f[i]<<" "<<g[i]<<" "<<s3[i]<<" "<<s2[i+1]<<" "<<s4[i]<<" "<<s1[i+1]<<endl;
	}
	cout<<(f[n]+g[n])%mod+mod)%mod;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:34: error: expected ';' before ')' token
   55 |         cout<<(f[n]+g[n])%mod+mod)%mod;
      |                                  ^
      |                                  ;
Language: C++

#include<bits/stdc++.h>
#define N 400005
#define P 1000000007
#define ll long long
#define inf ((ll)1e18)
using namespace std;
 
int n;ll A,B,a[N];
struct seg
{
	int val[N],tg[N];
	void mdy(int x,int l,int r,int p)
	{
		tg[x]=p;val[x]=(ll)p*(r-l+1)%P;
	}
	void dn(int x,int l,int r)
	{
		if (tg[x]!=-1)
		{
			int mid=l+r>>1;
			mdy(x<<1,l,mid,tg[x]);
			mdy(x<<1|1,mid+1,r,tg[x]);
			tg[x]=-1;
		}
	}
	void up(int x)
	{
		val[x]=(val[x<<1]+val[x<<1|1])%P;
	}
	void mdy(int k,int l,int r,int x,int y,int p)
	{
		if (x<=l&&r<=y)
		{
			mdy(k,l,r,p);
			return;
		}
		int mid=l+r>>1;dn(k,l,r);
		if (x<=mid) mdy(k<<1,l,mid,x,y,p);
		if (y>mid) mdy(k<<1|1,mid+1,r,x,y,p);
		up(k);
	}
	void add(int k,int l,int r,int x,int p)
	{
		if (l==r)
		{
			val[k]=(val[k]+p)%P;
			return;
		}
		int mid=l+r>>1;dn(k,l,r);
		if (x<=mid) add(k<<1,l,mid,x,p);
		else add(k<<1|1,mid+1,r,x,p);
		up(k);
	}
	int qry(int k,int l,int r,int x,int y)
	{
		if (x<=l&&r<=y) return val[k];
		int mid=l+r>>1,ans=0;dn(k,l,r)
		if (x<=mid) ans+=qry(k<<1,l,mid,x,y);
		if (y>mid) ans+=qry(k<<1|1,mid+1,r,x,y);
		return ans%P;
	}
	void mdy(int l,int r,int p)
	{
		mdy(1,0,n,l,r,p);
	}
	void add(int x,int y)
	{
		add(1,0,n,x,y);
	}
	int qry(int l,int r)
	{
		return qry(1,0,n,l,r);
	}
}TA,TB;
int main()
{
	scanf("%lld%lld%lld",&n,&A,&B);
	
	TA.add(0,1);
	TB.add(0,1);
	a[0]=-inf;
	scanf("%lld",&a[1]);
	for (int i=2;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		int t1=lower_bound(a+0,a+i,a[i]-A+1)-a-1,t2=lower_bound(a+0,a+i,a[i]-B+1)-a-1;
		int s1=TA.qry(0,t2),s2=TB.qry(0,t1);
		if (a[i-1]+A>a[i]) TA.mdy(0,n,0);
		if (a[i-1]+B>a[i]) TB.mdy(0,n,0);
		TA.add(i-1,s2);TB.add(i-1,s1);
	}
	printf("%lld\n",(TA.val[1]+TB.val[1])%P);
	
}

Compiler output:
a.cc: In member function 'int seg::qry(int, int, int, int, int)':
a.cc:58:17: error: expected ';' before 'if'
   58 |                 if (x<=mid) ans+=qry(k<<1,l,mid,x,y);
      |                 ^~
Language: C++

#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
inline ll read()
{
	ll x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
#define MOD 1000000007
ll s[MN+5];
int l[MN+5],f[MN+5][2],S[MN+5];
inline int mod(int x){return x<MOD?x:x-MOD;}
int main()
{
	int n,i,x;ll a,b;
	n=read();a=read();b=read();if(a>b)swap(a,b);
	for(i=1;i<=n;++i)s[i]=read();s[0]=-1e18;s[++n]=2e18;
	for(l[1]=i=1;++i<n;)l[i]=s[i]-s[i-1]<a?i:l[i-1];
	for(f[0][1]=S[0]=i=1;i<=n;++i)
	{
		if(s[i]-s[i-1]>=b)f[i][1]=mod(f[i-1][0]+f[i-1][1]);
		if(i>1)
		{
			x=min(i-2,upper_bound(s,s+n+1,s[i]-b)-s-1);
			if(l[i-1]-1<=x)f[i][0]=mod(S[x]+MOD-(l[i-1]-1>0?S[l[i-1]-2]:0));
		}
		S[i]=mod(S[i-1]+mod((s[i+1]-s[i-1]>=a?f[i][0]:0)+f[i][1]));
	}
	printf("%d",mod(f[n][0]+f[n][1]));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:30: error: no matching function for call to 'min(int, long int)'
   28 |                         x=min(i-2,upper_bound(s,s+n+1,s[i]-b)-s-1);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:28:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   28 |                         x=min(i-2,upper_bound(s,s+n+1,s[i]-b)-s-1);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:28:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |                         x=min(i-2,upper_bound(s,s+n+1,s[i]-b)-s-1);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,n_;
ll a,b;
ll s[100001];
ll dp[150001][2];
ll dat[1<<20];

void add(int k,ll a){
	k+=n_-1;
	dat[k]=a;
	while(k>0){
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1],dat[k*2+2]);
	}
}

ll query(ll a,ll b,int k=0,int l=0,int r=n_){
	if(b<=l || r<=a)return INF*INF;
	if(a<=l && r<=b)return dat[k];
	ll vl=query(a,b,k*2+1,l,(l+r)/2);
	ll vr=query(a,b,k*2+2,(l+r)/2,r);
	return min(vl,vr);
}

ll func(int v,int prev){
	if(dp[v][prev]!=-1)return dp[v][prev];
	if(v>=n)return 1LL;
	ll res=0;
	if(v==0){
		res=func(1,0);
		int nexa=lower_bound(s,s+n,s[v]+b)-s;
		if(nexa==v+1){
			res+=func(v+1,1);
		}else if(nexa==v+2){
			res+=func(v+2,0);
		}else if(query(v+1,nexa-1)>=a){
			res+=func(nexa,0);
		}
	}else{
		if(prev==0){
			if(s[v-1]+a<=s[v]){
				res=func(v+1,0);
			}
			int nexa=lower_bound(s,s+n,s[v]+b)-s;
			bool flag2=true;
			if(v!=n-1){
				if(nexa!=v+1 && s[v-1]+a>s[v+1]){
					flag2=false;
				}
			}
			if(nexa==v+1){
				res+=func(v+1,1);
			}else if(nexa==v+2){
				if(flag2)res+=func(v+2,0);
			}else if(query(v+1,nexa-1)>=a){
				if(flag2)res+=func(nexa,0);
			}
		}else{
			if(s[v-1]+b<=s[v]){
				res=func(v+1,1);
			}
			res+=func(v+1,0);
		}
	}
	return (dp[v][prev]=(res%MOD));
}

bool flag[100001];
int main(void){
	scanf("%d%lld%lld",&n,&a,&b);
	if(n==1){
		printf("1\n");
		return 0;
	}
	n_=1;
	while(n_<n)n_*=2;
	if(a>b)swap(a,b);
	for(int i=0;i<n;i++){
		scanf("%lld",&s[i]);
	}
	for(int i=0;i<n-1;i++){
		add(i,s[i+1]-s[i]);
	}
	memset(dp,-1,sizeof(dp));
	printf("%lld\n",func(0,0));
	return 0;
}


Compiler output:
a.cc: In function 'll func(int, int)':
a.cc:81:34: error: 'MOD' was not declared in this scope
   81 |         return (dp[v][prev]=(res%MOD));
      |                                  ^~~
Language: C

#include <stdio.h>
int dp[2][200000 + 3];
int c[100000 + 1];

static inline int fg(int i, int j){
 return (i < j) ? i : i+j ;
}

int main() {
	int n;
  int a;
  int b;
  scanf("%d", &n);
  scanf("%d", &a);
  scanf("%d", &b);
  int min_diff = (a<b)? b+1 : a+1;
  scanf("%d", &c[0]);
  for(int i=1; i<n; i++){
    scanf("%d", &c[i]);
    if (c[i]-c[i-1]<mindiff) mindiff=c[i]-c[i-1];
    //min_diff = (c[i] - c[i-1] > min_diff) ? min_diff :c[i]-c[i-1];
  }
  //printf("%d\n", min_diff);

  dp[1][0]=1;
  dp[1][1]=1;

  for(int i=1; i<=n-2; i++){
    for(int j=0; j<=i-1; j++){
    int ij = dp[i%2][fg(i,j)]%1000000007;
    int ji = dp[i%2][fg(j,i)]%1000000007;
    if(c[i+1] - c[i] >= a) dp[(i+1)%2][fg(i+1,j)] += ij;// if c[i+1] - c[i] >= a
    if(c[i+1] - c[j] >= b) dp[(i+1)%2][fg(i,i+1)] += ij; 
    if(c[i+1] - c[i] >= b) dp[(i+1)%2][fg(j,i+1)] += ji; 
    if(c[i+1] - c[j] >= a) dp[(i+1)%2][fg(i+1,i)] += ji;
    dp[i%2][fg(i,j)]=0;
    dp[i%2][fg(j,i)]=0;
    }
  }

int sum = 0;
  if(min_diff>=a)sum += 1;
  if(min_diff>=b)sum += 1;
//sum += 1 if c.each_cons(2).map{|k| (k[1]-k[0]) >= a[1]}.all?#(TRUE)
//sum += 1 if c.each_cons(2).map{|k| (k[1]-k[0]) >= a[2]}.all?#(TRUE)
  for(int j=0;j<2*n-1;j++){
    sum += dp[(n-1)%2][j] % 1000000007;
  //printf("%d %d\n",j, dp[(n-1)%2][j]);
  //sum += dp[(n-1)%2][j];
  }
  printf("%d\n", sum);
  
}


Compiler output:
main.c: In function 'main':
main.c:20:21: error: 'mindiff' undeclared (first use in this function); did you mean 'min_diff'?
   20 |     if (c[i]-c[i-1]<mindiff) mindiff=c[i]-c[i-1];
      |                     ^~~~~~~
      |                     min_diff
main.c:20:21: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009
#define MOD MOD7

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

#define mp make_pair
#define MINF -1000000000000000000

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int dp[100010];

signed main() {
    int N, A, B;
    cin >> N >> A >> B;

    swap(A, B);

    vector<int> S;
    inputVector(S, N);
    rep(i, N - 2) {
	if (S[i + 2] - S[i] < B) {
	    cout << 0 << endl;
	    return 0;
	}
    }

    S.insert(S.begin(), -1000000000000000001);

    int dp[0] = 1;
    int pt = 0, pt2 = 0;;
    int sum = 1;
    int ret = 0;
    rep(ti, N) {
	int i = ti + 1;

	if (S[i] - S[i - 1] >= A) {
	    dp[i] = sum;

	    while (i < N && pt2 <= i && S[pt2 + 1] - S[pt2] >= B) {
		sum += S[pt2];
		sum %= MOD;
		pt2++;
		if (pt2 == N) break;
	    }
	} else {
	    while (pt < i) {
		sum -= S[pt];
		sum += MOD;
		sum %= MOD;
		pt++;
	    }
	    pt2 = i;

	    dp[i] = dp[i - 1];
	}
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:17: error: array must be initialized with a brace-enclosed initializer
   64 |     int dp[0] = 1;
      |                 ^
Language: C++

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A,B;
LL S[100002];
LL dp[100002];
LL MOD=1000000007;

const int MAX_N=10001;
int bit[MAX_N+1];

int sum(int i){
    int s=0;
    while(i>0){
       s+=bit[i];
       i-=i&-i;
    }
    return s;
}
void add(int i,int x){
     while(i<=N+1){
        bit[i]+=x;
        i+=i&-i;
     }
}

int main(){
        REP(i,100002){
            dp[i]=0;
        }
        dp[0]=1;
	cin>>N;
	cin>>A>>B;
	if(A>B){
	   LL temp=A;
	   A=B;
	   B=temp;
	}
	S[0]=-10000000000;
	REP(i,N){
	    cin>>S[i+1];
	}
	//A+S[i]>S[i+2]は解なし
	REP(i,N-1){
	    if(A+S[i]>S[i+2]){
	       cout<<0<<endl;
	       return 0;
	    }
	}
	
	int p=0;
	int s0=0;
	add(1,1);
	REP(i,N){
	   //S[i+1]をyに振り分ける時
	   int pp=((upper_bound(S,S+N+1,S[i+1]-B))-S);
	   //cout<<pp<<endl;
	   //REP(j,pp){
	   //    dp[i+1]+=dp[j];
	   //}
	   dp[i+1]=sum(pp);
	   add(i+1+1,dp[i+1]);
	   //S[i+1]をxに振り分ける時
	   if(S[i+1]-S[i]<A){
	   //cout<<"aaa"<<endl;
	      for(int j=s0;j<=i-1;j++){
	         add(j+1,-dp[j]);
	         dp[j]=0;
	      }
	      s0=i-1;
	   }
	   //REP(j,i+2){
	   //    cout<<dp[j]<<endl;
	   //}
	   //cout<<endl;
	}
	LL ans=0;
	REP(i,N+1){
	    ans+=dp[i];
	}
        cout<<ans<<endl;
	return(0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'cin' was not declared in this scope
   35 |         cin>>N;
      |         ^~~
a.cc:49:16: error: 'cout' was not declared in this scope
   49 |                cout<<0<<endl;
      |                ^~~~
a.cc:49:25: error: 'endl' was not declared in this scope
   49 |                cout<<0<<endl;
      |                         ^~~~
a.cc:59:21: error: 'upper_bound' was not declared in this scope
   59 |            int pp=((upper_bound(S,S+N+1,S[i+1]-B))-S);
      |                     ^~~~~~~~~~~
a.cc:84:9: error: 'cout' was not declared in this scope
   84 |         cout<<ans<<endl;
      |         ^~~~
a.cc:84:20: error: 'endl' was not declared in this scope
   84 |         cout<<ans<<endl;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>

#define pii pair <int, int>
#define ll long long
#define f first
#define s second
#define pb push_back

using namespace std;

const int N = 1e5 + 5;
ll d[3][N];
ll p[N];

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    for (int i =  1; i <= n; ++i) {
        scanf("%lld", &p[i]);
    }
    sort(p + 1, p + n + 1);
    int la, ra, lb, rb;
    la = ra = lb = rb = 0;
    d[1][1] = 1;
    d[2][1] = 1;
    d[1][0] = d[2][0] = 1; 
    p[0] = -2e18;
    for (int i = 2; i <= n; ++i) {
        while (p[i] - p[ra + 1] >= a)
            ra++;
        while (p[i] - p[rb + 1] >= b)
            rb++;
        if (la <= ra) {
            if (ra == i - 1)
                d[1][i] = d[1][i - 1] + d[2][i - 1];
            else
                d[1][i] = d[2][ra + 1];
        }
        if (lb <= rb) {
            if (rb == i - 1)
                d[2][i] = d[2][i - 1] + d[1][i - 1];
            else
                d[2][i] = d[1][rb + 1]; 
        }
        d[1][i] %= int(1e9) + 7;
        d[2][i] %= int(1e9) + 7;
        if (p[i] - p[i - 1] < b) {
            la = i - 1;
        }
        if (p[i] - p[i - 1] < a) {
            lb = i - 1;
        }
    }
    cout << (d[1][n] + d[2][n]) %= (int(1e9) + 7) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:51: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   54 |     cout << (d[1][n] + d[2][n]) %= (int(1e9) + 7) << endl;
      |                                    ~~~~~~~~~~~~~~~^~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

const int mod = 1e9 + 7;

void upd(int &a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

int main() {
	int n;
	long long A, B;
	cin >> n >> A >> B;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	if (n == 1) {
		cout << 2 << endl;
		return 0;
	}
	static int dp0[2][4];
	static int dp1[2][4];
	dp0[a[1] - a[0] < A][0]++;
	dp0[0][1]++;
	dp0[0][2]++;
	dp0[a[1] - a[0] < B][3]++;
	for (int i = 2; i < n; i++) {
		memset(dp1, 0, sizeof(dp1));
		for (int j = 0; j < 2; j++) {
			// AAA
			upd(dp1[j || a[i] - a[i - 1] < A][0], dp0[j][0]);

			// AAB
			upd(dp1[j][1], dp0[j][0]);
			
			// ABA
			upd(dp1[j || a[i] - a[i - 2] < A][2], dp0[j][1]);

			// ABB
			upd(dp1[j || a[i] - a[i - 1] < B][3], dp0[j][1]);

			// BAA
			upd(dp1[j || a[i] - a[i - 1] < A][0], dp0[j][2]);

			// BAB
			upd(dp1[j || a[i] - a[i - 2] < B][1], dp0[j][2]);

			// BBA
			upd(dp1[j][2], dp0[j][3]);

			// BBB
			upd(dp1[j || a[i] - a[i - 1] < B][3], dp0[j][3]);
		}
		swap(dp0, dp1);
	}
	int ans = 0;
	for (int k = 0; k < 4; k++) {
		upd(ans, dp0[0][k]);
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:17: error: 'memset' was not declared in this scope
   33 |                 memset(dp1, 0, sizeof(dp1));
      |                 ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <cstdlib>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int mod = 1e9 + 7;

void upd(int &a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

int main() {
	int n;
	long long A, B;
	cin >> n >> A >> B;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	if (n == 1) {
		cout << 2 << endl;
		return 0;
	}
	static int dp0[2][4];
	static int dp1[2][4];
	dp0[a[1] - a[0] < A][0]++;
	dp0[0][1]++;
	dp0[0][2]++;
	dp0[a[1] - a[0] < B][3]++;
	for (int i = 2; i < n; i++) {
		memset(dp1, 0, sizeof(dp1));
		for (int j = 0; j < 2; j++) {
			// AAA
			upd(dp1[j || a[i] - a[i - 1] < A][0], dp0[j][0]);

			// AAB
			upd(dp1[j][1], dp0[j][0]);
			
			// ABA
			upd(dp1[j || a[i] - a[i - 2] < A][2], dp0[j][1]);

			// ABB
			upd(dp1[j || a[i] - a[i - 1] < B][3], dp0[j][1]);

			// BAA
			upd(dp1[j || a[i] - a[i - 1] < A][0], dp0[j][2]);

			// BAB
			upd(dp1[j || a[i] - a[i - 2] < B][1], dp0[j][2]);

			// BBA
			upd(dp1[j][2], dp0[j][3]);

			// BBB
			upd(dp1[j || a[i] - a[i - 1] < B][3], dp0[j][3]);
		}
		swap(dp0, dp1);
	}
	int ans = 0;
	for (int k = 0; k < 4; k++) {
		upd(ans, dp0[0][k]);
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: 'memset' was not declared in this scope
   32 |                 memset(dp1, 0, sizeof(dp1));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include<bits/stdc++.h>
 
using namespace std;
 
 
typedef long long int64;
const int mod = 1e9 + 7;
 
struct BinaryIndexedTree
{
  vector< int > data;
 
  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
  }
 
  int sum(int k)
  {
    int ret = 0;
    for(++k; k > 0; k -= k & -k) (ret += data[k]) %= mod;
    return (ret);
  }
 
  void add(int k, int x)
  {
    for(++k; k < data.size(); k += k & -k) (data[k] += x) %= mod;
  }
 
  int get(int k)
  {
    return ((sum(k) - sum(k - 1) + mod) % mod);
  }
};
 
int main()
{
  int64 N, A, B, X[100000];
  int64 AA[100000], BB[100000];
 
  cin >> N >> A >> B;
  for(int i = 0; i < N; i++) {
    cin >> X[i];
    AA[i] = upper_bound(X, X + i + 1, X[i] - A) - X;
    BB[i] = upper_bound(X, X + i + 1, X[i] - B) - X;
  }
 
  BinaryIndexedTree dp1(N), dp2(N);
  dp1.add(0, 1);
  dp2.add(0, 1);
  int aa = 0, bb = 0;
 
  for(int i = 1; i < N; i++) {
    dp1.add(i, dp2.sum(AA[i]));
    dp2.add(i, dp1.sum(BB[i]));
    if(X[i] - X[i - 1] < A) 
      for(; aa<i; aa++) dp1.add(aa, mod - dp1.get(aa));
    if(X[i] - X[i - 1] < B)
      for(; bb<j; bb++) dp2.add(bb, mod - dp2.get(bb));
  }
 
  cout << (dp1.sum(N - 1) + dp2.sum(N - 1)) % mod << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:16: error: 'j' was not declared in this scope
   59 |       for(; bb<j; bb++) dp2.add(bb, mod - dp2.get(bb));
      |                ^
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;
ll A,B,S[101010];
ll mo=1000000007;

template<class V, int ME> class BIT {
public:
	V bit[1<<ME],val[1<<ME];
	V total(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	V add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
	V set(int e,V v) { add(e,v-val[e]);}
};

BIT<ll,20> BTA,BTB;
vector<int> VA,VB;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	S[0]=-1LL<<60;
	cin>>S[1];
	
	int LA=0,LB=0;
	
	BTA.add(0,1);
	BTB.add(0,1);
	VA.push_back(0);
	VB.push_back(0);
	for(i=2;i<=N;i++) {
		cin>>S[i];
		
		while(LA<i-2&&S[i]-S[LA+1]>=A) LA++;
		while(LB<i-2&&S[i]-S[LB+1]>=B) LB++;
		
		BTA.add(i-1,BTA.total(LA)%mo);
		BTB.add(i-1,BTB.total(LB)%mo);
		
		if(S[i]<S[i-1]+A) {
			FORR(r,VB) BTB.set(r,0);
			VB.clear();
		}
		if(S[i]<S[i-1]+B) {
			FORR(r,VA) BTA.set(r,0);
			VA.clear();
		}
		VA.push_back(i-1);
		VB.push_back(i-1);
	}
	
	ll ret=0;
	FOR(i,N+1) ret+=TA[i]+TB[i];
	cout<<ret%mo<<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:65:25: error: 'TA' was not declared in this scope; did you mean 'LA'?
   65 |         FOR(i,N+1) ret+=TA[i]+TB[i];
      |                         ^~
      |                         LA
a.cc:65:31: error: 'TB' was not declared in this scope; did you mean 'LB'?
   65 |         FOR(i,N+1) ret+=TA[i]+TB[i];
      |                               ^~
      |                               LB
a.cc: In instantiation of 'V BIT<V, ME>::add(int, V) [with V = long long int; int ME = 20]':
a.cc:39:9:   required from here
   39 |         BTA.add(0,1);
      |         ~~~~~~~^~~~~
a.cc:23:77: warning: no return statement in function returning non-void [-Wreturn-type]
   23 |         V add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
      |                                                                             ^
a.cc: In instantiation of 'V BIT<V, ME>::set(int, V) [with V = long long int; int ME = 20]':
a.cc:53:22:   required from here
   53 |                         FORR(r,VB) BTB.set(r,0);
      |                                    ~~~~~~~^~~~~
a.cc:24:44: warning: no return statement in function returning non-void [-Wreturn-type]
   24 |         V set(int e,V v) { add(e,v-val[e]);}
      |                                            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int N;
long long A, B;
vector<long long> S;
bool visited[100001];
long long memo[100001];

bool g(long long x, long long y, long long z) {
	if (y < 0) return true;
	return x - y >= z;
}
unordered_map<long long, unordered_map<long long, int>> memo_h;
int h(long long x, long long y, int pp) {
	++ pp;
	int c = 1;
	vector<pair<long long, long long>> hoge;
	while (pp < N) {
		if (memo_h.count(x) && memo_h[x].count(y)) { pp = memo_h[x][y]; break }
		bool xx = g(S[pp], x, A);
		bool yy = g(S[pp], y, B);
		if (xx && yy) break;
		if (xx) x = S[pp];
		else if (yy) y = S[pp];
		else { pp = -1; break; }
		++ c;
		if (c % 10 == 0) hoge.push_back({x,y});
		++ pp;
	}
	for (auto xy : hoge) memo_h[xy.first][xy.second] = pp;
	return pp;
}
long long f(int p) {
	if (p == N) return 1;
	if (visited[p]) return memo[p];
	visited[p] = true;
	long long r = 0;
	{
		int pp = h(S[p], -1, p);
		if (pp >= 0) r += f(pp);
	}
	{
		int pp = h(-1, S[p], p);
		if (pp >= 0) r += f(pp);
 	}
	return memo[p] = r % mod;
}
int main() {
	cin >> N >> A >> B;
	S.resize(N);
	for (auto& x : S) cin >> x;
	cout << f(0) << endl;
}


Compiler output:
a.cc: In function 'int h(long long int, long long int, int)':
a.cc:20:86: error: expected ';' before '}' token
   20 |                 if (memo_h.count(x) && memo_h[x].count(y)) { pp = memo_h[x][y]; break }
      |                                                                                      ^~
      |                                                                                      ;
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<unordered_map>
using namespace std;
typedef long long ll;

using namespace std;
#define N 100010
vector<ll> t[N];
//bool dead[N];
class DivideTree{
  public:
  bool dead[N];
  class FindCentroid{
      public:
      ll res,n;
      ll alt(ll x,ll from){
	  if(dead[x])return 0;
	  ll sum=1;
	  for(auto y:t[x]){
	      if(y!=from)sum+=alt(y,x);
	  }
	  return sum;
      }
      ll dfs(ll x,ll from){
	  if(dead[x])return 0;
	  ll sum=1,maxi=-1;
	  for(auto y:t[x]){
	      if(y==from)continue;
	      ll val=dfs(y,x);
	      sum+=val,maxi=max(maxi,val);
	  }
	  ll rem=n-sum;
	  maxi=max(maxi,rem);
	  if(maxi<=n/2)res=x;
	  return sum;
      }
      ll main(ll s){
	  n=alt(s,-1);
	  dfs(s,-1);
	  return res;
      }
  };FindCentroid fc;
  
  ll solve(ll s){
      //cout<<s<<":";
      s=fc.main(s);
      //cout<<s<<endl;
      dead[s]=1;
      ll res=-1;
      for(auto y:t[s]){
	  if(dead[y])continue;
	  res=max(res,solve(y));
      }
      dead[s]=0;
      return res+1;
  }
  ll main(){
      for(int i=0;i<N;i++)dead[i]=0;
      return solve(1);
  }
};DivideTree dt;

int main(){
    ll n,a,b;cin>>n;
    for(int i=0;i<n-1;i++){
	cin>>a>>b;
	t[a].push_back(b);
	t[b].push_back(a);
    }
    cout<<dt.main()<<endl;
    return 0;
}


Compiler output:
a.cc: In member function 'll DivideTree::FindCentroid::alt(ll, ll)':
a.cc:19:14: error: invalid use of non-static data member 'DivideTree::dead'
   19 |           if(dead[x])return 0;
      |              ^~~~
a.cc:14:8: note: declared here
   14 |   bool dead[N];
      |        ^~~~
a.cc: In member function 'll DivideTree::FindCentroid::dfs(ll, ll)':
a.cc:27:14: error: invalid use of non-static data member 'DivideTree::dead'
   27 |           if(dead[x])return 0;
      |              ^~~~
a.cc:14:8: note: declared here
   14 |   bool dead[N];
      |        ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,w[N],head[N],next[N];
void add(int f,int t){
	static int cnt=0;
	w[++cnt]=t;
	next[cnt]=head[f];
	head[f]=cnt;
}
int dep[N];
void dfs(int x,int fa){
	for (int i=head[x];i;i=next[i])
	if (w[i]!=fa) dep[w[i]]=dep[x]+1,dfs(w[i],x);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	dep[1]=1;dfs(1,0);
	int v=1;
	for (int i=1;i<=n;i++)
		if (dep[i]>dep[v]) v=i;
	dep[v]=1;dfs(v,0);
	int len=0;
	for (int i=1;i<=n;i++) len=max(len,dep[i]);
	//printf("%d\n",len);
	int k=1,ans=0;
	while (k<len) k=k*2+1,ans++;
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:8:9: error: reference to 'next' is ambiguous
    8 |         next[cnt]=head[f];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_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:4:20: note:                 'int next [200010]'
    4 | int n,w[N],head[N],next[N];
      |                    ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:13:32: error: reference to 'next' is ambiguous
   13 |         for (int i=head[x];i;i=next[i])
      |                                ^~~~
/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:4:20: note:                 'int next [200010]'
    4 | int n,w[N],head[N],next[N];
      |                    ^~~~
Language: C++

#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,dep[100100],ans;
struct edge
{
    int v;
    edge *nxt;
} pool[200100],*tp=pool,*fst[100100];

int dfs(int x,int fa)
{
    int ret=x;
    dep[x]=dep[fa]+1;
    for (edge *i=fst[x]; i; i=i->nxt)
        if (i->v!=fa)
        {
            int t=dfs(i->v,x);
            if (dep[t]>dep[ret])
                ret=t;
        }
    return ret;0
}

int main()
{
    scanf("%d",&n);
    repu(i,1,n-1)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        *tp=(edge){v,fst[u]},fst[u]=tp++;
        *tp=(edge){u,fst[v]},fst[v]=tp++;
    }
    int t=dep[dfs(dfs(1,0),0)];
    for (; t>1; t>>=1,++ans);
    printf("%d\n",ans);
    return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:24:17: error: expected ';' before '}' token
   24 |     return ret;0
      |                 ^
      |                 ;
   25 | }
      | ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
static vector<int> e[2][100000];
 
int recon(int i,int p,bool b,int &N)
{
  //printf("%d %d %d\n",i,p,N);
  int t=N;
  e[!b][t]=vector<int>(0);
  N++;
  int S=0;
  for(int x=0;x<e[b][i].size();x++){
    if(e[b][i][x].size()==1){
      S++;
    }
  }
  for(int x=0;x<e[b][i].size();x++){
    int j=e[b][i][x];
    if(j==p)continue;
    if(e[b][j].size()==2&&S>=e[b][i].size()-1){
      int k=(e[b][j][0]==i?e[b][j][1]:e[b][j][0]);
      int c=recon(k,j,b,N);
      e[!b][t].push_back(c);
      e[!b][c].push_back(t);
    }
    else if(e[b][j].size()>=2){
      int c=recon(j,i,b,N);
      e[!b][t].push_back(c);
      e[!b][c].push_back(t);
    }
  }
  return t;
}
 
int main()
{
  int n;
  scanf("%d",&n);
  bool b=0;
  for(int i=0;i<n-1;i++){
    int u,v;
    scanf("%d%d",&u,&v);
    u--,v--;
    e[b][u].push_back(v);
    e[b][v].push_back(u);
  }
  int N=n,t=0;
  while(N>1){
    //printf("%d\n",N);
    t++;
    int r;
    for(int i=0;i<N;i++){
      if(e[b][i].size()==1){
	r=e[b][i][0];
	break;
      }
    }
    N=0;
    recon(r,-1,b,N);
    b=!b;
  }
  printf("%d\n",t);
  return 0;
}


Compiler output:
a.cc: In function 'int recon(int, int, bool, int&)':
a.cc:14:19: error: request for member 'size' in 'e[((int)b)][i].std::vector<int>::operator[](((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   14 |     if(e[b][i][x].size()==1){
      |                   ^~~~
Language: C++

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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

vector<int> g[MAX];

int D[MAX];
int mx;

void go(int x, int p, int val, int diff)
{
	//cout<<x<<' '<<val<<' '<<mx<<endl;
	if (val == -1)
	{
		mx++;
		D[x] = mx;
		diff = 1;
	}
	else
	{
		if (val == mx - 1) diff = -1;
		D[x] = val;
	}


	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i];
		if (to == p) continue;

		go(to, x, val + diff, diff, mx);
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);


	int n;
	scanf("%d", &n);
	FOR (i, 0, n-1)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;
		g[x].PB(y);
		g[y].PB(x);
	}
mx = 0;
	go(0, -1, 0, -1);
	int res = 0;
	FOR (i, 0, n)
	{
		res = max(res, D[i]);
	//	cout<<i+1<<' '<<D[i]<<endl;
	}

	cout<<res<<endl;


}


Compiler output:
a.cc: In function 'void go(int, int, int, int)':
a.cc:50:19: error: too many arguments to function 'void go(int, int, int, int)'
   50 |                 go(to, x, val + diff, diff, mx);
      |                 ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:6: note: declared here
   29 | void go(int x, int p, int val, int diff)
      |      ^~
Language: C++

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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

vector<int> g[MAX];

int D[MAX];
int mx;

void go(int x, int p, int val, int diff)
{
	//cout<<x<<' '<<val<<' '<<mx<<endl;
	if (val == -1)
	{
		mx++;
		D[x] = mx;
		diff = 1;
	}
	else
	{
		if (val == mx - 1) diff = -1;
		D[x] = val;
	}


	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i];
		if (to == p) continue;

		go(to, x, val + diff, diff, mx);
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);


	int n;
	scanf("%d", &n);
	FOR (i, 0, n-1)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;
		g[x].PB(y);
		g[y].PB(x);
	}

	go(0, -1, 0, -1, 0);
	int res = 0;
	FOR (i, 0, n)
	{
		res = max(res, D[i]);
	//	cout<<i+1<<' '<<D[i]<<endl;
	}

	cout<<res<<endl;


}


Compiler output:
a.cc: In function 'void go(int, int, int, int)':
a.cc:50:19: error: too many arguments to function 'void go(int, int, int, int)'
   50 |                 go(to, x, val + diff, diff, mx);
      |                 ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:6: note: declared here
   29 | void go(int x, int p, int val, int diff)
      |      ^~
a.cc: In function 'int main()':
a.cc:72:11: error: too many arguments to function 'void go(int, int, int, int)'
   72 |         go(0, -1, 0, -1, 0);
      |         ~~^~~~~~~~~~~~~~~~~
a.cc:29:6: note: declared here
   29 | void go(int x, int p, int val, int diff)
      |      ^~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

class Tree {
  public:
    Tree(int size):
            m_edges(size),
            m_size(size) {}

    int size() const {
        return m_edges.size();
    }

    void addEdge(int x, int y) {
        m_edges[x].emplace_back(y);
        m_edges[y].emplace_back(x);
    }

    int uninity() {
        return dfsUninity(0);
    }

  private:
    int dfsUninity(int node) {
        if (m_edges[node].size() == 0)
            return 0;

        dfsSize(node);
        int center = node;
        while (true) {
            bool found_next = false;
            for (auto &x : m_edges[center])
                if (m_size[x] < m_size[center] && m_size[x] > m_size[node] / 2) {
                    center = x;
                    found_next = true;
                    break;
                }
            if (!found_next)
                break;
        }

        int answer = 0;
        for (auto &x : m_edges[center]) {
            m_edges[x].erase(find(m_edges[x].begin(), m_edges[x].end(), center));
            answer = max(answer, dfsUninity(x));
        }
        return answer + 1;
    }

    void dfsSize(int node, int father = -1) {
        m_size[node] = 1;
        for (auto &x : m_edges[node])
            if (x != father) {
                dfsSize(x, node);
                m_size[node] += m_size[x];
            }
    }

    vector< vector<int> > m_edges;
    vector<int> m_size;
};

int main() {
    int N; cin >> N;

    Tree T(N);
    for (int i = 1; i < N; ++i) {
        int x, y; cin >> x >> y;
        T.addEdge(x - 1, y - 1);
    }

    cout << T.uninity() << "\n";
}


Compiler output:
a.cc: In member function 'int Tree::dfsUninity(int)':
a.cc:46:34: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   46 |             m_edges[x].erase(find(m_edges[x].begin(), m_edges[x].end(), center));
      |                              ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:46:34: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   46 |             m_edges[x].erase(find(m_edges[x].begin(), m_edges[x].end(), center));
      |                              ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"basic.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
#endif

struct Node{
    vector<Node*> dests;
    void add(Node* n){
        dests.push_back(n);
    }
    void add2(Node* n){
        add(n);
        n->add(this);
    }
    pair<int, Node*> dfs(Node* from = nullptr){
        pair<int, Node*> ret = {0, this};
        for(Node* d : dests){
            if(d == from){ continue; }
            auto p = d -> dfs(this);
            p.first++;
            ret = max(ret, p);
        }
        return ret;
    }
};

int main(){
    int n; cin >> n;
    vector<Node> nodes(n);
    for(int i=0;i<n;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        nodes[a].add2(&nodes[b]);
    }
    auto f1 = nodes[0].dfs();
    auto f2 = f1.second->dfs();
    int d = f2.first;
    printd(d);
    int num = 0, ans = 0;
    for(int i=1;i<M;i++){
        num = num * 2 + 2;
        prints(num, d, i);
        if(num >= d){ ans = i; break; }
    }
    cout << ans << '\n';
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:5: error: 'printd' was not declared in this scope; did you mean 'prints'?
   59 |     printd(d);
      |     ^~~~~~
      |     prints
Language: C++

/*
	Author: zxy_hhhh
	date: 2019/12/10
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#define ll long long
inline ll rd() {
	ll _x=0;int _ch=getchar(),_f=1;
	for(;!isdigit(_ch)&&(_ch!='-')&&(_ch!=EOF);_ch=getchar());
	if (_ch=='-'){_f=0;_ch=getchar();}
	for(;isdigit(_ch);_ch=getchar()) _x=_x*10+_ch-'0';
	return _f?_x:-_x;
}
void write(ll _x){if (_x>=10) write(_x/10),putchar(_x%10+'0'); else putchar(_x+'0'); }
inline void wrt(ll _x,char _p){if (_x<0) putchar('-'),_x=-_x; write(_x); if (_p) putchar(_p);}
#define maxn 2005
#define mod 1000000007
int n,m,k;
int dp[maxn<<1][maxn<<1];

int main() {
	n=rd(),m=rd(),k=rd();
	int res=0;dp[0][0]=1;
	for(int i=0;i<=n;i++) {
		for(int j=0;j<=m;j++) if (f[i][j]){
			for(int c=0;c<=k-1;c++) {
				(dp[i+c][j+(k-1-c)]+=dp[i][j])%=mod;
			}
			int nxw=(n-i)%(k-1);
			if (!nxw) nxw+=k-1;
			if (i+nxw<=n&&j+(k-nxw)<=m) {
				(res+=dp[i][j])%=mod;
			}
		}
	}
	wrt(res,'\n');
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:43: error: 'f' was not declared in this scope
   34 |                 for(int j=0;j<=m;j++) if (f[i][j]){
      |                                           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=4005,mod=1000000007;
int n,m,k,dp[N],ans;
inline void add(int &a,int b){
	a=a+b>=mod?a+b-mod:a+b;
}
signed main(){
	n=read(); m=read(); k=read(); swap(n,m);
	int jb=k-1;
	for(int i=n;i;i--)if((n-i)%jb==0)nxt[i]=i; else nxt[i]=nxt[i+1];
	dp[0]=1; 
	for(int i=0;i<(n+m-1)/(k-1);i++){
		int meiju=min(n,i*(k-1)),mmm=min(n,(i+1)*(k-1));
		for(int j=1;j<=meiju;j++)add(dp[j],dp[j-1]);
		for(int j=meiju;j>=0;j--){
			if(j+k<=mmm)add(dp[j+k],mod-dp[j]);
			if(nxt[j]<=n&&(i+1)*jb-nxt[j]<m)ans=(ans+dp[j])%mod;
			//cout<<dp[j]<<" "<<i<<" "<<j<<" "<<(i+1)*jb-(j+(n-j)%jb)<<endl;
		}
	}
	cout<<(ans+mod)%mod<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:42: error: 'nxt' was not declared in this scope
   47 |         for(int i=n;i;i--)if((n-i)%jb==0)nxt[i]=i; else nxt[i]=nxt[i+1];
      |                                          ^~~
a.cc:47:57: error: 'nxt' was not declared in this scope
   47 |         for(int i=n;i;i--)if((n-i)%jb==0)nxt[i]=i; else nxt[i]=nxt[i+1];
      |                                                         ^~~
a.cc:54:28: error: 'nxt' was not declared in this scope
   54 |                         if(nxt[j]<=n&&(i+1)*jb-nxt[j]<m)ans=(ans+dp[j])%mod;
      |                            ^~~
Language: C++

#include <cstdio>
#include <vector>
#include <string>
using namespace std;

const int MOD = 1e9 + 7;

int dp[2001][2001];

int dfs(int a, int b, int k) {
        if (a + b == 1) return dp[a][b] = 1;
        if (a + b == k) {
                if (a == k || b == k) return dp[a][b] = 0;
                return dp[a][b] = 1;
        }
        if (dp[a][b] > 0) return dp[a][b];
        int &res = dp[a][b];
        res = 0;
        for (int i = 0; i < k; i ++) if (a >= i && b >= k - i - 1) (res += dfs(a - i, b - (k - i - 1), k)) %= MOD;
        return res;
}

int main() {
        int n, m, k, ans = 0;
        scanf("%d%d%d", &n, &m, &k);
        memset(dp, -1, sizeof dp);
        for (int i = n; i > 0; i -= k - 1) for (int j = m; j > 0; j -= k - 1) (ans += dfs(i, j, k)) %= MOD;
        printf("%d\n", ans);
        return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'memset' was not declared in this scope
   26 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <string>
  +++ |+#include <cstring>
    4 | using namespace std;