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

//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
typedef pair<int,int> p;


int n,m;
const int MAX_N=100005;

//int used[MAX_N];
//int mark[MAX_N];
//map<int,vector<int> > child;

void dfs(int start,int root){
    if(used[start]==1) return ;
    mark[start]=root;
    for(int i=0;i<child[start].size();i++) dfs(child[start][i],root);
}
int main(){
    while(1){
        scanf("%d%d",&n,&m);
        if(n==0 and m==0)break;
        map<int,vector<int> > child;
        int used[MAX_N];
        int mark[MAX_N];
        /*
        for(int i=0;i<MAX_N;i++){
            used[i]=0;
            mark[i]=0;
            child[i].clear();

        }
        */

        for(int i=0;i<n-1;i++){
            int par;
            scanf("%d",&par);
            par--;
            child[par].push_back(i+1);
        }
        int ans=0;
        used[0]=1;

        for(int i=0;i<m;i++){
            char a;
            int b;
            cin>>a>>b;
            b--;
            if (a=='Q') {
                ans+=(mark[b]+1);
            }
            else {
                dfs(b,b);
                used[b]=1;
                //for(int i=0;i<10;i++) cout<<mark[i]<<endl;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
    

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:35:8: error: 'used' was not declared in this scope
   35 |     if(used[start]==1) return ;
      |        ^~~~
a.cc:36:5: error: 'mark' was not declared in this scope
   36 |     mark[start]=root;
      |     ^~~~
a.cc:37:19: error: 'child' was not declared in this scope
   37 |     for(int i=0;i<child[start].size();i++) dfs(child[start][i],root);
      |                   ^~~~~
Language: C++

#include<bits/stdc++.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAXN 100000+1109

using namespace std;

char ch[30];
int n,m;
int fa[MAXN];
int a[MAXN],Q[MAXN];
bool Is[MAXN];
long long Ans=0;

int find(int x)
{
	if(fa[x]==x) return x;
	if(Is[x]==true) return x;
	fa[x]=find(fa[x]);
	return fa[x];
}

void read();
void work();
void print();

int main()
{
	while(~scanf("%d%d",&n,&m);)
	{
		memset(Is,0,sizeof(Is));
		Ans=0;
		read();
		work();
		print();
	}
	return 0;
}

void read()
{
	
	if(n==0&&m==0) exit(0);
	fa[1]=1;
	for(int i=2;i<=n;i++)
		scanf("%d",&fa[i]);
	Is[1]=true;
	for(int i=1;i<=m;i++)
	{
		scanf("%s%d",ch,&Q[i]);
		if(ch[0]=='Q') a[i]=1;
		else a[i]=2,Is[Q[i]]=true;
	}
}
void work()
{
	for(int i=m;i;i--)
	{
		if(a[i]==1)
		{
			if(Q[i]==1) continue;
			if(Is[Q[i]])
				Ans+=find(fa[Q[i]]);
			else Ans+=find(Q[i]);
			//printf("%lld\n",Ans);
		}
		else Is[Q[i]]=false;
		/*for(int i=1;i<=n;i++)
			printf("%d ",fa[i]);
		printf("\n");
		for(int i=1;i<=n;i++)
			printf("%d ",Is[i]);
		printf("\n");*/
	}
}
void print()
{
	printf("%lld\n",Ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:35: error: expected ')' before ';' token
   29 |         while(~scanf("%d%d",&n,&m);)
      |              ~                    ^
      |                                   )
a.cc:29:36: error: expected primary-expression before ')' token
   29 |         while(~scanf("%d%d",&n,&m);)
      |                                    ^
Language: C++

#include<bits/stdc++.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAXN 100000+1109

using namespace std;

char ch[30];
long long n,m;
long long fa[MAXN];
long long a[MAXN],Q[MAXN];
bool Is[MAXN];
long long Ans=0;
long long Mark[MAXN];

long long find(long long x)
{
	if(fa[x]==x) return x;
	if(Is[x]==true) return x;
	fa[x]=find(fa[x]);
	return fa[x];
}

void read();
void work();
void print();

int main()
	while(~scanf("%lld%lld",&n,&m))
	{
		memset(Is,0,sizeof(Is));
		memset(fa,0,sizeof(fa));
		memset(a,0,sizeof(a));
		memset(Mark,0,sizeof(Mark));
		Ans=0;
		read();
		work();
		print();
	}
	return 0;
}

void read()
{
	
	if(n==0&&m==0) exit(0);
	fa[1]=1;
	for(long long i=2;i<=n;i++)
		scanf("%lld",&fa[i]);
	Is[1]=true;
	for(long long i=1;i<=m;i++)
	{
		scanf("%s%lld",ch,&Q[i]);
		if(ch[0]=='Q') a[i]=1;
		else
		{
			a[i]=2,Is[Q[i]]=true;
			if(Mark[Q[i]]) continue;
			Mark[Q[i]]=i;
		}
	}
}
void work()
{
	for(long long i=m;i;i--)
	{
		if(a[i]==1)
		{
			if(Q[i]==1) continue;
			Ans+=find(Q[i]);
		}
		else
		{
			if(Mark[Q[i]]!=i) continue;
			Is[Q[i]]=false;
		}
	}
}
void print()
{
	printf("%lld\n",Ans);
}

Compiler output:
a.cc:29:9: error: expected initializer before 'while'
   29 |         while(~scanf("%lld%lld",&n,&m))
      |         ^~~~~
a.cc:40:9: error: expected unqualified-id before 'return'
   40 |         return 0;
      |         ^~~~~~
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^
Language: C++

#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long int ll;
const int MAX_N = 100010;
struct UnionFind {
    int node[MAX_N];
    UnionFind() {}
    void init() {
        memset(node, -1, sizeof(node));
    }

    int find(int x) {
        return (node[x] < 0 ? x : node[x] = find(node[x]));
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -node[find(x)];
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if(same(x, y)) return;
        if(x > y) swap(x, y);
        // y を x に統合 (数字の小さい方に合わせる)
        node[x] += node[y];
        node[y] = x;
    }
};

struct Query {
    // q: mark -> 0, query -> 1
    int q, v;
    Query() {}
    Query(int a, int b) : q(a), v(b) {}
};

vector< vector<int> > G;
int N, Q, mark[100010], parent[100010];
Query qs[100010];
UnionFind uf;

void init(int root, int val) {
    for(size_t i=0; i<G[root].size(); i++) {
        int to = G[root][i];
        if(to == root) continue;
        if(mark[to]) init(to, to);
        else {
            uf.unite(root, to);
            init(to, val);
        }
    }
}

void debug() {
    /*
    for(int i=0; i<N; i++) {
        printf("node %d: root = %d\n", i+1, uf.find(i) + 1);
    }
    */
}

int main() {
    while(1) {
        // init
        uf.init();
        memset(mark, 0, sizeof(mark));
        memset(parent, -1, sizeof(parent));
        G.clear();

        scanf("%d%d", &N, &Q);
        if(N == Q && Q == 0) break;
        G.resize(N);

        for(int i=1; i<N; i++) {
            int par; scanf("%d", &par); par--;
            G[par].push_back(i);
            parent[i] = par;
        }

        for(int i=0; i<Q; i++) {
            char mode; int v;
            scanf(" %c%d", &mode, &v); v--;
            qs[i] = Query(mode == 'Q', v);
            if(mode == 'M') mark[v]++;
        }
        init(0, 0);
        debug();

        ll ans = 0;
        for(int i=0; i<Q; i++) {
            // mark
            if(qs[i].q == 0) {
                if(--mark[qs[i].v] == 0) {
                    int par = parent[qs[i].v];
                    if(par < 0) continue;
                    uf.unite(par, qs[i].v);
                }
            }
            // query
            else {
                ans += uf.find(qs[i].v) + 1;
            }
            debug();
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Compiler output:
a.cc:44:1: error: 'vector' does not name a type
   44 | vector< vector<int> > G;
      | ^~~~~~
a.cc: In function 'void init(int, int)':
a.cc:50:23: error: 'G' was not declared in this scope
   50 |     for(size_t i=0; i<G[root].size(); i++) {
      |                       ^
a.cc: In function 'int main()':
a.cc:75:9: error: 'G' was not declared in this scope
   75 |         G.clear();
      |         ^
Language: C++

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

typedef long long int ll;
const int MAX_N = 100010;
struct UnionFind {
    int node[MAX_N];
    UnionFind() {}
    void init() {
        memset(node, -1, sizeof(node));
    }

    int find(int x) {
        return (node[x] < 0 ? x : node[x] = find(node[x]));
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -node[find(x)];
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if(same(x, y)) return;
        if(x > y) swap(x, y);
        // y を x に統合 (数字の小さい方に合わせる)
        node[x] += node[y];
        node[y] = x;
    }
};

struct Query {
    // q: mark -> 0, query -> 1
    int q, v;
    Query() {}
    Query(int a, int b) : q(a), v(b) {}
};

vector< vector<int> > G;
int N, Q, mark[100010], parent[100010];
Query qs[100010];
UnionFind uf;

int main() {
    while(1) {
        // init
        uf.init();
        memset(mark, 0, sizeof(mark));
        memset(parent, -1, sizeof(parent));
        G.clear();

        scanf("%d%d", &N, &Q);
        if(N == Q && Q == 0) break;
        G.resize(N);

        for(int i=1; i<N; i++) {
            int par; scanf("%d", &par); par--;
            G[par].push_back(i);
            parent[i] = par;
        }

        for(int i=0; i<Q; i++) {
            char mode; int v;
            scanf(" %c%d", &mode, &v); v--;
            qs[i] = Query(mode == 'Q', v);
            if(mode == 'M') mark[v]++;
        }

        for(int i=1; i<N; i++) {
            if(!mark[i]) {
                uf.unite(i, parent[i]);
            }
        }
        debug();

        ll ans = 0;
        for(int i=0; i<Q; i++) {
            // mark
            if(qs[i].q == 0) {
                if(--mark[qs[i].v] == 0) {
                    int par = parent[qs[i].v];
                    if(par < 0) continue;
                    uf.unite(par, qs[i].v);
                }
            }
            // query
            else {
                ans += uf.find(qs[i].v) + 1;
            }
            debug();
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:80:9: error: 'debug' was not declared in this scope
   80 |         debug();
      |         ^~~~~
Language: C++

class UnionFindTree:
    """Disjoint-Set Data Structure
       Union-Find Tree
       complexity:
          init: O(n)
          find, unite, same: O(alpha(n))
       used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ)
    """
    def __init__(self, n):
        self.par = list(range(n))  # parent
        self.rank = [0] * n  # depth of tree

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


while True:
    N, Q = map(int, input().split())
    if N == Q == 0:
        break
    parents = [-1] + [int(input()) - 1 for _ in range(N - 1)]
    queries = []
    marked = set()
    for _ in range(Q):
        k, v = input().split()
        v = int(v) - 1
        queries.append((k, v))
        if k == "M":
            marked.add(v)
    uf = UnionFindTree(N)
    for i in range(1, N):
        if i not in marked:
            p_root = uf.find(parents[i])
            uf.par[i] = p_root
            uf.rank[p_root] = max(uf.rank[p_root], uf.par[i] + 1)
    ans = 0
    for k, v in reversed(queries):
        if k == "Q":
            ans += uf.find(v)
        elif not uf.same(v, parents[v]):
            p_root = uf.find(parents[i])
            uf.par[i] = p_root
            uf.rank[p_root] = max(uf.rank[p_root], uf.par[i] + 1)
    print(ans)



Compiler output:
a.cc:2:7: warning: missing terminating " character
    2 |     """Disjoint-Set Data Structure
      |       ^
a.cc:2:7: error: missing terminating " character
    2 |     """Disjoint-Set Data Structure
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:8:7: warning: missing terminating " character
    8 |     """
      |       ^
a.cc:8:7: error: missing terminating " character
a.cc:10:36: error: stray '#' in program
   10 |         self.par = list(range(n))  # parent
      |                                    ^
a.cc:11:30: error: stray '#' in program
   11 |         self.rank = [0] * n  # depth of tree
      |                              ^
a.cc:2:5: error: expected class-name before string constant
    2 |     """Disjoint-Set Data Structure
      |     ^~
a.cc:2:5: error: expected '{' before string constant
a.cc:2:5: error: expected unqualified-id before string constant
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int flag[100010],par[100010];
vector<int> gg[100010];
int n,q;
long long ans;
void setpar(int parr,int x)
{
	par[x]=parr;
	if(!flag[x])
	{
		for(int i=0;i<gg[x].size();i++)
			setpar(parr,gg[x][i]);
	}
}
int main()
{
	cin>>n>>q;
	flag[1]=1;
	int a;
	char b;
	par[i]=0;
	for(int i=2;i<=n;i++)
		par[i]=1;
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a);
		gg[a].push_back(i);
		getchar();
	}
	while(q--)
	{
		scanf("%c%d",&b,&a);
		getchar();
		if(b=='M')
		{
			flag[a]=1;
			for(int i=0;i<gg[a].size();i++)
				setpar(a,gg[a][i]);
		}
		else
		{
			ans+=par[a];
		}
	}
	cin>>n>>q;
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:13: error: 'i' was not declared in this scope
   26 |         par[i]=0;
      |             ^
Language: C++

#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;
const int MAX_N=100001;
vector<int>edge[MAX_N];
vector<int>id[MAX_N];
int vi[MAX_N*2];
int DFS(int n,int d)
{
	vi[d]=n;
	id[n].push_back(d);
	for(int i=0;i<edge[n].size();++i)
	{
		d=DFS(edge[n][i],d+1)+1;
		vi[d]=n;
		id[n].push_back(d);
	}
	return d;
}


int main()
{
	edge.resize(MAX_N);
	id.resize(MAX_N);
	int N,Q,x,i,t;
	char c;
	long long res;
	typedef map<int,int>M;
	M m;
	M::iterator ite;
	while(scanf("%d%d",&N,&Q),N)
	{
		m.clear();
		for(i=1;i<=N;++i)edge[i].clear();
		for(i=2;i<=N;++i)
		{
			scanf("%d",&x);
			edge[x].push_back(i);
		}
		DFS(1,1);
		m[1]=1;
		m[N*2]=-1;
		res=0;
		while(Q--)
		{
			scanf(" %c%d",&c,&x);
			if(c-'Q')
			{
				ite=m.lower_bound(x);
				if(ite->second==x)continue;
				t=(--ite)->second;
				for(i=0;i<id[x].size();++i)
				{
					m[id[x][i]]=x;
				}
				m[id[x].back()+1]=t;
			}
			else
			{
				ite=m.upper_bound(id[x][0]);
				res+=(--ite)->second;
			}
		}
		printf("%lld\n",res);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:14: error: request for member 'resize' in 'edge', which is of non-class type 'std::vector<int> [100001]'
   27 |         edge.resize(MAX_N);
      |              ^~~~~~
a.cc:28:12: error: request for member 'resize' in 'id', which is of non-class type 'std::vector<int> [100001]'
   28 |         id.resize(MAX_N);
      |            ^~~~~~
Language: C++

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int par[100000];
int mark[100000];
int uf[100000];
int root(int x){
  if(uf[x] == x) return x;
  return uf[x] = root(uf[x]);
}
int main(){
  int N, Q;
  while(cin>>N>>Q && N){
    par[0] = 0;
    uf[0] = 0;
    mark[0] = 1
    REP(i, N - 1){
      cin>>par[i + 1];
      par[i + 1]--;
      uf[i + 1] = par[i + 1];
    }
    memset(mark, 0, sizeof(mark));
    char c[100000];
    int v[100000];
    REP(i, Q){
      cin>>c[i]>>v[i];
      v[i]--;
      if(c[i] == 'M'){
        mark[v[i]]++;
      }
    }
    REP(i, N) if(mark[i] > 0){
      uf[i] = i;
    }
    ll ans = 0;
    for(int i = Q - 1; i >= 0; i--){
      if(c[i] == 'M'){
        mark[v[i]]--;
        if(mark[v[i]] == 0){
          uf[v[i]] = par[v[i]];
        }
      }else{
        ans += root(v[i]) + 1;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:16: error: expected ';' before 'for'
   43 |     mark[0] = 1
      |                ^
      |                ;
a.cc:44:9: error: 'i' was not declared in this scope
   44 |     REP(i, N - 1){
      |         ^
a.cc:18:35: note: in definition of macro 'FOR'
   18 | #define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
      |                                   ^
a.cc:44:5: note: in expansion of macro 'REP'
   44 |     REP(i, N - 1){
      |     ^~~
Language: C++

#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
 
int n, q, root[10500];
long long res;
bool marked[10500];
pair<char, int> query[10500];
 
int r(int x){
    if(marked[x])return x;
    return root[x]=r(root[x]);
}
 
int main() {
    while(true){
	cin >> n >> q;
	if(n == 0 && q == 0)return 0;
	res = 0;
	fill(marked, marked + n + 2, false);
	marked[1] = true;
	for(int i = 2;i <= n;i++){
	    cin >> root[i];
	}
	for(int i = 0;i < q;i++){
	    cin >> query[i].first >> query[i].second;
	    marked[query[i].second] = (query[i].first == 'M');
	}
	for(int i=Q-1;i>=0;i--){
	    if(query[i].first=='M'){
		marked[query[i].second] = false;
	    }else{
		res += r(query[i].second);
	    }
	}
	cout << res << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:19: error: 'Q' was not declared in this scope
   30 |         for(int i=Q-1;i>=0;i--){
      |                   ^
Language: C++

#include<iostream>
#include<stdio>
#include<map>
#include<algorithm>
using namespace std;
 
int n, q, root[105000];
long long res;
int marked[105000];
pair<char, int> query[105000];
 
int r(int x){
    if(marked[x])return x;
    return root[x]=r(root[x]);
}
 
int main() {
    while(true){
	scanf("%d%d", &n, &q);
//	cin >> n >> q;
	if(n == 0 && q == 0)return 0;
	res = 0;
	fill(marked, marked + n + 2, 0);
	marked[1] = true;
	for(int i = 1;i < n;i++){
	    cin >> root[i];
	    root[i]--;
	}
	for(int i = 0;i < q;i++){
	    cin >> query[i].first >> query[i].second;
	    query[i].second--;
	    marked[query[i].second] += (query[i].first == 'M');
	}
	for(int i=q;i-- > 0;){
	    if(query[i].first=='M'){
		marked[query[i].second]--;
	    }else{
		res += r(query[i].second) + 1;
	    }
	}
	printf("%lld\n", res);
//	cout << res << endl;
    }
}

Compiler output:
a.cc:2:9: fatal error: stdio: No such file or directory
    2 | #include<stdio>
      |         ^~~~~~~
compilation terminated.
Language: C++

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

int parent[100000];
bool is_mark[100000], is_root[100000];

class union_find {
private:
	vector<int> uf;

public:
	union_find(int n) {
		uf.resize(n, -1);
	}

	inline int find(int x) {
		return uf[x] < 0 ? x : uf[x] = find(uf[x]);
	}

	inline void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y)
			return;
		
		if(uf[x] > uf[y])
			swap(x, y);
		
		else if(uf[x] == uf[y])
			--uf[x];
		
		uf[y] = x;
	}

	inline bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	for(int n, q; cin >> n >> q, n | q;) {
		for(int i = 1; i < n; ++i) {
			int input;
			cin >> input;
			parent[i] = --input;
		}

		stack<int> value;
		memset(is_root, false, sizeof(is_root));
		is_root[0] = true;

		for(int i = 0; i < q; ++i) {
			char ope;
			int v;
			cin >> ope >> v;
			value.push(v);
			if(ope == 'Q')
				is_mark[i] = false;

			else {
				is_mark[i] = true;
				is_root[v] = true;
			}
		}

		union_find uf(n);
		for(int i = 0; i < n; ++i)
			if(!is_root[i])
				uf.unite(i, parent[i]);

		int ans = 0;
		for(int i = q - 1; i >= 0; --i) {
			int v = value.top();
			value.pop();

			if(is_mark[i])
				uf.unite(v, parent[v]);

			else
				ans += uf.find(v) + 1;

		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> G[100000];
bool vis[100000], marked[100000];
int qtype[100000], vertex[100000];

int par[100000], pp[100000];

void init()
{
	for (int i = 0; i < 100000; i++) par[i] = i;
}

int find(int x)
{
	if (par[x] == x) return (x);
	return (par[x] = find(par[x]));
}

void merge(int x, int y)
{
	x = find(x); y = find(y);
	if (x != y){
		par[y] = x;
	}
}

void dfs(int v, int p, int m)
{
	int nm = m;
	if (marked[v]) nm = v;
	pp[v] = p;
	
	merge(nm, v);
	
	for (int i = 0; i < G[v].size(); i++){
		dfs(G[v][i], v, nm);
	}
}

int main()
{
	int N, Q;
	
	while (scanf("%d %d", &N, &Q) && N){
		for (int i = 0; i < N; i++) G[i].clear();
		
		for (int i = 1; i < N; i++){
			int v;
			scanf("%d", &v);
			G[--v].push_back(i);
		}
		
		init();
		
		memset(marked, 0, sizeof(marked));
		marked[0] = true;
		for (int i = 0; i < Q; i++){
			char t[10];
			scanf("%s %d", t, vertex + i);
			qtype[i] = (t[0] == 'Q');
			--vertex[i];
			if (!qtype[i]) marked[vertex[i]] = true;
		}
		
		dfs(0, -1, -1);
		
		long long int ans = 0;
		for (int i = Q - 1; i >= 0; i--){
			if (qtype[i]){
				ans += find(vertex[i]) + 1;
			}
			else merge(pp[vertex[i]], vertex[i]);
		}
		
		printf("%lld\n", ans);
	}
	
	return (0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:17: error: 'memset' was not declared in this scope
   60 |                 memset(marked, 0, sizeof(marked));
      |                 ^~~~~~
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 |
Language: C++

#include<iostream>
#include<cstdio>

using namespace std;

int n,q;
int tree[100050];

int Find(int x)
{
    if(tree[x]==x)
        return x;
    return Find(tree[x]);
}

int main()
{
    while(scanf("%d %d",&n,&q)==2)
    {
        if(n==0&&q==0)
            break;
        tree[1]=1;
        for(int i=2;i<=n;i++)
            scanf("%d",&tree[i]);
        getchar();
        long long ans=0;
        for(int i=1;i<=q;i++)
        {
            int temp;
            char s[100];
            gets(s);
            sscanf(&s[2],"%d",&temp);
            if(s[0]=='M')
                tree[temp]=temp;
            else if(s[0]=='Q')
                ans+=Find(temp);
        }
        cout<<ans<<endl;
    }

    return 0;
}

[C++]

Compiler output:
a.cc: In function 'int main()':
a.cc:31:13: error: 'gets' was not declared in this scope; did you mean 'getw'?
   31 |             gets(s);
      |             ^~~~
      |             getw
a.cc: At global scope:
a.cc:44:1: error: expected unqualified-id before '[' token
   44 | [C++]
      | ^
Language: C++

#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, Q;
    bool mark[100001];
    int tree[100001];
    while (1) {
        cin >> N >> Q;
        if (N == 0 && Q == 0) {
            break;
        }

        memset(mark, false, sizeof(mark));
        mark[1] = true; 
        tree[1] = 0;
        for (int i=2; i<=N; ++i) {
            cin >> tree[i];
        } 

        long long sum = 0;
        for (int i=0; i<Q; ++i) {
            char ope;
            int v;
            cin >> ope >> v;
            if (ope == 'Q') {
                for (int j=v; j>=1; j=tree[j]) {
                    if (mark[j] == true) {
                        sum += j;
                        break;
                    }
                }
            } else if (ope == 'M') {
                mark[v] = true;
            }
        }
        cout << sum << "\n";
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'memset' was not declared in this scope
   16 |         memset(mark, false, sizeof(mark));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define INF (1<<29)


template<class T>
class BinomialHeap{
	struct Tree{
		T val;
		std::vector<Tree *> edge;
		Tree(T &v):val(v){}
		~Tree(){
			for(int i=0;i<degree();i++)delete edge[i];
		}	
		void add(Tree *t){edge.push_back(t);}
		void pop(Tree *t){edge.pop_back();}
		int degree()const{return edge.size();}
	};
	std::vector<Tree*> trees;
	mutable int imax;

	static Tree* add(Tree* a,Tree* b){
		if(a->val > b->val){
			a->add(b);
			return a;
		}else{
			b->add(a);
			return b;
		}
	}
	void findmax()const{
		for(int i=0;i<trees.size();i++)
			if(trees[i] && (imax==-1||trees[i]->val > trees[imax]->val))
				imax=i;
	}
	BinomialHeap(std::vector<Tree*>& e):trees(e),imax(-1){}
public:
	BinomialHeap():imax(-1){}
	~BinomialHeap(){
		clear();
	}
	//O(log n)
	void meld(BinomialHeap &h){
		imax=-1;
		Tree* carry=NULL;
		if(trees.size()<h.trees.size())trees.swap(h.trees);
		for(int i=0;i<trees.size();i++){
			if(carry){
				if(i<h.trees.size() && h.trees[i]){
					carry=add(carry,h.trees[i]);
					h.trees[i]=NULL;
				}else if(trees[i]){
					carry=add(carry,trees[i]);
					trees[i]=NULL;
				}else{
					trees[i]=carry;
					carry=NULL;
				}
			}else if(i<h.trees.size() && h.trees[i]){
				if(trees[i]){
					carry=add(trees[i],h.trees[i]);
					trees[i]=h.trees[i]=NULL;	
				}else{
					trees[i]=h.trees[i];
					h.trees[i]=NULL;		
				}
			}
		}
		if(carry)trees.push_back(carry);
		//h.clear();
		h.trees.clear();
	}
	//O(log n)
	void insert(T v){
		BinomialHeap h;
		h.trees.push_back(new Tree(v));
		meld(h);
	}
	T getmax()const{
		if(imax==-1)findmax();
		return trees[imax]->val;
	}
	void popmax(){
		if(imax==-1)findmax();
		BinomialHeap h(trees[imax]->edge);
		trees[imax]->edge.clear();	
		delete trees[imax];
		trees[imax]=NULL;	
		meld(h);
		while(!trees.empty() && trees.back()==NULL)trees.pop_back();
		imax=-1;
	}
	bool empty()const{
		return trees.empty();
	}
	void clear(){
		imax=-1;
		for(int i=0;i<trees.size();i++)
			if(trees[i])
				delete trees[i];
		trees.clear();
	}
	//void remove(int id){}
	//decrease_key remove(int id,T v){}
};



int n,q;
vector<int> edge[100000];
int marked[100000];
BinomialHeap<int> bh[100000];
int ans;


void dfs(int u){
	for(int i=0;i<edge[u].size();i++){
		dfs(edge[u][i]);
		bh[u].meld(bh[edge[u][i]]);
	}
	int t=marked[u];
	/*while(!bh[u].empty() && t<bh[u].getmax()){
		//cout<<' '<<u+1<<' '<<bh[u].getmax()<<endl;
		ans+=u+1;
		bh[u].popmax();
	}*/
}

int main(){
	while(cin>>n>>q,n|q){
		for(int i=0;i<n;i++)edge[i].clear();
		for(int i=0;i<n;i++)bh[i].clear();
		for(int i=0;i<n;i++)marked[i]=INF;
		marked[0]=0;
		for(int i=1;i<n;i++){
			int p;
			cin>>p;
			edge[p-1].push_back(i);
		}
		for(int i=0;i<q;i++){
			char op;
			int v;
			cin>>op>>v;
			v--;
			if(op=='M'){
				marked[v]=min(marked[v],i+1);
			}else{
				bh[v].insert(i+1);
			}
		}
		ans=0;
		dfs(0);
		cout<<ans<<endl;
	}
	return 0;
}



*/

Compiler output:
a.cc:162:2: error: expected unqualified-id before '/' token
  162 | */
      |  ^
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

class Edge{
public:
	int p, q, cost;
	Edge(int p, int q, int cost) : p(p), q(q), cost(cost) {}
	bool operator < (const Edge &e) const { return cost > e.cost; }
};

int main(){
	int n, s, t; 
	while(cin >> n >> s >> t, n){
		s--; t--;
		int cst[100][100];
		int sign[100], out[100];
		for(int i=0;i<n;i++) cin >> sign[i];
		vector< vector<Edge> > graph(n);
		memset(out,0,sizeof(out));
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin >> cst[i][j];
				if(cst[i][j]){ out[i]++; graph[i].push_back(Edge(i,j,cst[i][j])); }
			}
		}
		vector<int> dist(n,-1);
		priority_queue<Edge> qu; qu.push(Edge(-2,t,0));
		while(!qu.empty()){
			Edge e = qu.top(); qu.pop();
			int pos = e.q, ccost = e.cost;
			if(!(dist[pos]<0)) continue;
			dist[pos] = ccost;
			for(int i=0;i<graph[pos].size();i++)
				qu.push(Edge(pos,graph[pos][i].q,ccost+cst[pos][graph[pos][i].q]));
		}
		if(dist[s]==-1) { puts("impossible"); return 0; }
		double a[100][100], b[100];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++) a[i][j] = 0;
			b[i] = 0;
		}
		for(int i=0;i<n;i++){
			if(i==t){
				a[i][i] = 1.0; 
			} else if(sign[i]){
				a[i][i] = 1;
				int cnt = 0;
				for(int j=0;j<n;j++){
					if(cst[i][j]!=0&&dist[i]>-1&&dist[j]>-1&&dist[i]==dist[j]+cst[i][j]) cnt++;
				}
				for(int j=0;j<n;j++){
					if(cst[i][j]!=0&&dist[i]>-1&&dist[j]>-1&&dist[i]==dist[j]+cst[i][j]){
						a[i][j] -= 1.0/cnt;
						b[i] += (double)cst[i][j]/cnt;
					}
				}	
			} else {
				a[i][i] = 1;
				for(int j=0;j<n;j++){
					if(cst[i][j]){
						a[i][j] -= 1.0/out[i];
						b[i] += (double)cst[i][j]/out[i];
					}
				}
			}
		}
		for(int i=0;i<n;i++){
			int pivot = i;
			for(int j=i+1;j<n;j++)
				if(abs(a[j][i])>abs(a[pivot][i])) pivot = j;
			for(int j=0;j<n;j++) swap(a[i][j],a[pivot][j]);
			swap(b[i], b[pivot]);
			double div = a[i][i];
			for(int j=0;j<n;j++) a[i][j] /= div; b[i] /= div;
			for(int j=i+1;j<n;j++){
				double mul = a[j][i];
				for(int k=0;k<n;k++)
					a[j][k] -= a[i][k]*mul;
				b[j] -= b[i]*mul;
			}
		}
		for(int i=n-1;i>=0;i--){
			for(int j=0;j<i;j++){
				b[j] -= a[j][i]*b[i];
			}
		}
		double ans = 0.0;
		int cnt = 0;
		for(int i=0;i<n;i++){
			if(dist[i]!=-1){
				cnt++;
				ans += b[i];
			}
		}
		printf("%.9lf\n", b[s]);
	}
}

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

#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

typedef pair<int,int> pii;

const int INF = 1000000000;

const int N = 222;
int w,n;
vector<pii> block[N];

bool input(){
	cin>>w>>n;
	if(w==0)return false;
	
	rep(i,N)block[i].clear();
	
	rep(i,n){
		int m;
		cin>>m;
		rep(j,m){
			int a,b;
			cin>>a>>b;
			block[i].push_back(pii(a,b));
		}
	}
	return true;
}

typedef pair<int,double> pid;

vector<pid> edge[N];

double getlen(pii a, pii b){
	double d1 = a.first-b.first;
	double d2 = a.second-b.second;
	
	return sqrt(d1*d1 + d2*d2);
}

void mkedge_line(int num, double w){
	rep(i,n){
		double mini = INF;
		rep(j,block[i].size()){
			mini = min(mini,  getlen(pii(w,block[i][j].second), block[i][j]) );
		}
		edge[num].push_back(pid(i,mini));
		edge[i].push_back(pid(num,mini));
	}
}

void mkedge_block(){
	rep(i,n){
		reps(j,i+1,n){
			double mini = INF;
			rep(k,block[i].size()){
				rep(p, block[j].size()){
					mini = min(mini, getlen(block[i][k], block[j][p]) );
				}
			}
			edge[i].push_back(pid(j,mini));
			edge[j].push_back(pid(i,mini));
		}
	}
}

void mkedge(){
	rep(i,N)edge[i].clear();
	
	mkedge_line(n,0);
	mkedge_line(n+1, w);
	mkedge_block();
}

int visit[N];
double dijk(){
	
	rep(i,N)visit[i]=0;
	
	typedef pair<double,int> P;
	priority_queue<P> que;
	que.push(P(0,n));
	
	while(!que.empty()){
		
		P u = que.top();
		que.pop();
		
		if(visit[u.second]==1)continue;
		visit[u.second]=1;
		
		if(u.second==n+1)return -u.first;
		
		rep(i,edge[u.second].size()){
			pid e = edge[u.second][i];
			que.push( P(u.first- e.second, e.first) );
		}
	}
	return 0.0;
}
double solve(){
	
	if(n==0)return h;
	mkedge();
	return dijk();;
}

void printedge(){
	rep(i,n+2){
		printf("%d ",i);
		rep(j,edge[i].size())printf("(%d %lf)",edge[i][j].first,edge[i][j].second);puts("");
	}
}

int main(){
	while(input()){
		printf("%.9lf\n",solve());
		
		//printedge();
	}
}

Compiler output:
a.cc: In function 'double solve()':
a.cc:115:24: error: 'h' was not declared in this scope
  115 |         if(n==0)return h;
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
vector<int> m[100];
int N, D;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int _t, _s;
    while(cin >> N >> D && N){
        vector<int> sum(N, 0);
        rep(i, N){
            cin >> _t;
            rep(j, _t){
                cin >> _s;
                m[i].push_back(_s);
                sum[i] += _s;
            }
        }
        while(true){
            bool updated = false;
            rep(i, n)
              while(m[i].size()){
                  sum[i] -= m[i].back();
                  if(*max_element(sum.begin(), sum.end()) - sum[i] <= d){
                      m[i].pop_back();
                      updated = true;
                  }else{
                      sum[i] += m[i].back();
                      break;
                  }
              }
            if(!updated) break;
        }
        rep(i, N - 1) sum[i + 1] += sum[i];
        if(sum[N - 1] == 0)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:20: error: 'n' was not declared in this scope
   25 |             rep(i, n)
      |                    ^
a.cc:5:47: note: in definition of macro 'REP'
    5 | #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
      |                                               ^
a.cc:25:13: note: in expansion of macro 'rep'
   25 |             rep(i, n)
      |             ^~~
a.cc:28:71: error: 'd' was not declared in this scope
   28 |                   if(*max_element(sum.begin(), sum.end()) - sum[i] <= d){
      |                                                                       ^
Language: C++

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solver();
	}

	static void solver() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int d = sc.nextInt();
			if (n == 0 && d == 0)
				return;

			ArrayList<Country> cs = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				int m = sc.nextInt();
				int[] c = new int[m];
				for (int j = 0; j < m; j++) {
					c[j] = sc.nextInt();
				}
				cs.add(new Country(i, c, m));
			}
			cs.sort(null);
			int max = cs.get(cs.size() - 1).sum;
			int min = cs.get(0).sum;
			int max2=min;
			if(cs.size()>=2){
				max2=cs.get(cs.size()-2).num;
			}
			while (max - min <= d) {
				boolean removed = false;
				cs.sort(null);
				
				max = cs.get(cs.size() - 1).sum;
				max2=cs.get(cs.size()-2).sum;
				min = Math.min(cs.get(0).sum, min);

				for (int i = 0; i < cs.size(); i++) {
					Country nc = cs.get(i);
					int ns = nc.sum - nc.c.get(0);
					if (((i != 0 && Math.abs(ns - max) <= d)||(i==0&& Math.abs(ns - max2) <= d)) && Math.abs(ns - min) <= d) {
						cs.get(i).sum = ns;
						cs.get(i).c.remove(0);
						if (ns == 0) {
							cs.remove(i);
						}
						removed = true;
						break;
					}
				}
				if (!removed) {
					if (cs.size() == 0) {
						System.out.println("YES");
					} else
						System.out.println("NO");
					break;
				}else if(cs.size()==0){
					System.out.println("YES");
					break;
				}
			}
		}
	}
	static void tr(Object...o){System.out.println(Arrays.deepToString(o));}

	static class Country implements Comparable<Country> {
		int num;
		int sum = 0;
		ArrayList<Integer> c=new ArrayList<>();

		Country(int num, int[] c, int m) {
			this.num = num;
			for (int i = 0; i < m; i++) {
				this.c.add(c[i]);
				this.sum += c[i];
			}
		}

		@Override
		public int compareTo(Country o) {
			return Integer.compare(this.sum, o.sum);
		}
	}
}

Compiler output:
a.cc:83:17: error: stray '@' in program
   83 |                 @Override
      |                 ^
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.ArrayList;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Arrays;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
Language: C++

#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int** table;
int** ruisekiwa;
int N,D,num[100],index[100],total[100];

void func(){
	for(int i = 0; i < 100; i++)index[i] = 0;

	int sum,minimum = BIG_NUM,maximum = -1;
	bool FLG;

	for(int i = 0; i < N; i++){
		scanf("%d",&num[i]);

		sum = 0;

		for(int k = 0; k < num[i]; k++){
			scanf("%d",&table[i][k]);

			ruisekiwa[i][k] = table[i][k];
			sum += table[i][k];

		}
		total[i] = sum; //???i???????????????????????????????¨????
		minimum = min(minimum,sum);
		maximum = max(maximum,sum);

		for(int k = 1; k < num[i];k++){
			ruisekiwa[i][k] += ruisekiwa[i][k-1];
		}
	}

	while(true){
		FLG = false;

		for(int i = 0; i < N; i++){
			//?????§?????¨????????????????????????D??\????????????????°??????¨????????????????????????D??\?????§???????????????index???num[i]????????§????????????index????????????????????????
			while(abs(maximum-(total[i]-ruisekiwa[i][index[i]]) <= D) && abs(minimum-(total[i]-ruisekiwa[i][index]) <= D) && index[i] < num[i]){
				index[i]++;
				FLG = true;
			}
			maximum = max(maximum,total[i]-ruisekiwa[i][index[i]]);
			minimum = min(minimum,total[i]-ruisekiwa[i][index[i]]);

		}
		if(!FLG)break;
	}


	FLG = true;
	//?°?????????¨???1????????¨??¨??´?£???§????????????????????£??????false
	for(int i = 0; i < N; i++){
		if(index[i] != num[i]){
			FLG = false;
			break;
		}
	}

	if(FLG){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

}

int main(){

	table = new int*[100];
	ruisekiwa = new int*[100];
	for(int i = 0; i < 100; i++){
		table[i] = new int[10000];
		ruisekiwa = new int[10000];
	}

	while(true){
		scanf("%d %d",&N,&D);
		if(N == 0 && D == 0)break;

		func();
	}

	return 0;
}

Compiler output:
a.cc:17:18: warning: built-in function 'index' declared as non-function [-Wbuiltin-declaration-mismatch]
   17 | int N,D,num[100],index[100],total[100];
      |                  ^~~~~
a.cc: In function 'void func()':
a.cc:51:120: error: invalid types 'int*[int [100]]' for array subscript
   51 |                         while(abs(maximum-(total[i]-ruisekiwa[i][index[i]]) <= D) && abs(minimum-(total[i]-ruisekiwa[i][index]) <= D) && index[i] < num[i]){
      |                                                                                                                        ^
a.cc: In function 'int main()':
a.cc:86:29: error: cannot convert 'int*' to 'int**' in assignment
   86 |                 ruisekiwa = new int[10000];
      |                             ^~~~~~~~~~~~~~
      |                             |
      |                             int*
Language: C++

#include<iostream>
#include<stack>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

int INF = 10e8;
int n, d;
stack<int> st[1000];
int csum[1000];
int csort[1000];

void init(){
    REP(i, n){
        csort[i] = csum[i];
    }
}

void sortcsort(){
    sort(csort, csort+n, greater<int>());
}

int main(){
    while(1){
        cin >> n >> d;

        if(n==0) break;

        REP(i, n) csum[i] = 0;

        REP(i, n){
            int m;
            cin >> m;
            REP(j, m){
                int c;
                cin >> c;
                csum[i] += c;
                st[i].push(c);
            }
        }

        init();
        sortcsort();

        while(1){
            int end = true;
            REP(i, n){
                while(!st[i].empty()){
                    int c = st[i].top();
                    int max_c = csort[0];
                    if(max_c == csum[i]){
                        max_c = csort[1];
                    }
                    if(csum[i]-c>=max_c-d){
                        st[i].pop();
                        csum[i] -= c;
                        init();
                        sortcsort();
                        end = false;
                    } else {
                        break;
                    }
                }
            }

            int flag = true;
            REP(i, n){
                if(!st[i].empty()) flag = false;
            }
            if(flag){
                cout << "Yes" << endl;
                break;
            }
            if(end){
                cout << "No" << endl;
                break;
            }
        }
    }
}

Compiler output:
a.cc: In function 'void sortcsort()':
a.cc:21:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   21 |     sort(csort, csort+n, greater<int>());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
using namespace std;
int main(){
  int n, d;
  while(cin >> n >> d,n){
    int acum[n][10000+1];
    string ans = "Yes";
    for(int i = 0; i < n; ++i) fill(acum[i],acum[i]+n,0);
    int m, N = 0, last_id[n];
    for(int i = 0; i < n; ++i){
      cin >> m;
      N += m;
      last_id[i] = m;
      for(int j = 0; j < m; ++j){
        cin >> acum[i][j+1];
        acum[i][j+1] += acum[i][j];
      }
    }
    for(int _ = 0; _ < N; ++_){
      int power[n];
      for(int i = 0; i < n; ++i){
        int id = last_id[i];
        power[i] = acum[i][id];
      }
      sort(power,power+n,greater<int>());
      bool f = true;
      for(int i = 0; i < n; ++i){
        int id = last_id[i];
        if(id == 0) continue;
        if((acum[i][id] == power[0] && power[1] - acum[i][id-1] <= d) || 
           (acum[i][id] != power[0] && power[0] - acum[i][id-1] <= d)){
          --last_id[i];
          f = false;
          break;
        }
      }
      if(f){
        ans = "No";
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:7: error: 'sort' was not declared in this scope; did you mean 'short'?
   25 |       sort(power,power+n,greater<int>());
      |       ^~~~
      |       short
Language: C++

#include<cstdio>
#include<vector>
#include<queue>
#include<utility>

using namespace std;

typedef long long ll;
typedef pair<long, pair<int, int> > P;

int main(){
    int n,d;
    while(scanf("%d%d", &n, &d) && n){
        vector<ll> missile[n];
        int m;
        ll min_ = LLONG_MAX, max_ = 0LL;
        bool ans = true;
        vector<ll> v(n);
        priority_queue<P> que;
        for(int i=0;i<n;i++){
            scanf("%d", &m);
            ll c[m], total = 0;
            for(int j=0;j<m;j++){
                scanf("%lld", &c[j]);
                total += c[j];
            }
            missile[i].resize(m+1);
            missile[i][0] = total;
            for(int j=0;j<m;j++) missile[i][j+1] = missile[i][j] - c[j];

            que.push(P(total, pair<int, int>(i, 0)));
            v[i] = total;
            min_ = min(total, min_);
            max_ = max(total, max_);
        }

        if(max_ - min_ > d){
            ans = false;
        }

        while(ans && !que.empty()){
            P t = que.top(); que.pop();
            int i = t.second.first;
            int j = t.second.second;
            if(missile[i][j+1]){
                que.push(P(missile[i][j+1], pair<int, int>(i, j+1)));
                v[i] = missile[i][j+1];
            }else{
                v[i] = 0LL;
                min_ = 0LL;
            }
        
            if(t.first == min_){
                min_ = *min_element(v.begin(), v.end());
            }
            if(t.first == max_){
                max_ = *max_element(v.begin(), v.end());
            }
            if(max_ - min_ > d){
                ans = false;
            }
            // for(int i=0;i<n;i++) printf("%3lld", v[i]);
            // printf("\n");
        }
        printf("%s\n", ans?"Yes":"No");
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:19: error: 'LLONG_MAX' was not declared in this scope
   16 |         ll min_ = LLONG_MAX, max_ = 0LL;
      |                   ^~~~~~~~~
a.cc:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include<utility>
  +++ |+#include <climits>
    5 | 
a.cc:34:13: error: 'max_' was not declared in this scope
   34 |             max_ = max(total, max_);
      |             ^~~~
a.cc:37:12: error: 'max_' was not declared in this scope
   37 |         if(max_ - min_ > d){
      |            ^~~~
a.cc:54:25: error: 'min_element' was not declared in this scope
   54 |                 min_ = *min_element(v.begin(), v.end());
      |                         ^~~~~~~~~~~
a.cc:56:27: error: 'max_' was not declared in this scope
   56 |             if(t.first == max_){
      |                           ^~~~
a.cc:57:25: error: 'max_element' was not declared in this scope
   57 |                 max_ = *max_element(v.begin(), v.end());
      |                         ^~~~~~~~~~~
a.cc:59:16: error: 'max_' was not declared in this scope
   59 |             if(max_ - min_ > d){
      |                ^~~~