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

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

using namespace std;

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

const int INF = 10000000;
int cap[202][202];
double cost[202][202];

int maximumFlow(int s, int t, int n, double upper){
	int res = 0;
	while(true){
		vector<int> prev(n,-1); prev[s] = 0;
		queue<int> qu; qu.push(s);
		while(!qu.empty()){
			int e = qu.front(); qu.pop();
			for(int i=0;i<n;i++){
				if(cost[e][i] > upper) continue;
				if(cap[e][i]>0&&prev[i]<0){
					prev[i] = e;
					qu.push(i);
				}
			}
		}
		if(prev[t]<0) return res;
		for(int i=t;i!=prev[i];i=prev[i]) cap[prev[i]][i]--, cap[i][prev[i]]++;
		res++;
	}
	return res;
}

int main(){
	int n, m;
	while(cin >> n >> m, n){
		int x[100], y[100], v[100], xx[100], yy[100];
		vector<double> dst;
		int capa[202][202];
		memset(capa, 0, sizeof(capa));
		for(int i=0;i<n;i++) cin >> x[i] >> y[i] >> v[i];
		for(int i=0;i<m;i++) cin >> xx[i] >> yy[i];
		for(int i=1;i<=n;i++) capa[0][i] = 1;
		for(int i=1;i<=n;i++){
			for(int j=n+1;j<=n+m;j++) capa[i][j] = 1;
		}
		for(int j=n+1;j<=n+m;j++) capa[j][n+m+1] = 1;
		for(int i=0;i<n+m+2;i++)
			for(int j=0;j<n+m+2;j++) cost[i][j] = 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				double dx = x[i]-xx[j];
				double dy = y[i]-yy[j];
				cost[i+1][n+j+1] = sqrt(dx*dx+dy*dy)/v[i];
				dst.push_back(cost[i+1][n+j+1]);
				cost[n+j+2][i+1] = -cost[i+1][i+j+2];
			}
		}
		sort(dst.begin(), dst.end());
		int L = 0, R = dst.size()-1;
		while(L!=R){
			int mid = (L+R)/2;
			memcpy(cap, capa, sizeof(capa));
			if(maximumFlow(0, n+m+1, n+m+2, dst[mid])==m) R = mid;
			else L = mid + 1;
		}
		printf("%.6lf\n",dst[L]); 
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:17: error: 'memset' was not declared in this scope
   48 |                 memset(capa, 0, sizeof(capa));
      |                 ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <algorithm>
  +++ |+#include <cstring>
    6 | 
a.cc:71:25: error: 'memcpy' was not declared in this scope
   71 |                         memcpy(cap, capa, sizeof(capa));
      |                         ^~~~~~
a.cc:71:25: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include<cstdio>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef double D;

inline D dis(D x1, D y1, D x2, D y2){
  return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

const D EPS = 1e-8;

int n,m;
D x[110],y[110],v[110];
D px[110],py[110];
D t[110][110];
int match[210];
bool use[210];
vector<int> g[210];

bool dfs(int v){
  use[v] = true;
  rep(i,g[v].size()){
    int u = g[v][i], w = match[u];
    if(w<0 || !use[w] && dfs(w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bimatch(D lim){
  rep(i,n+m)g[i].clear();
  rep(i,n)rep(j,m){
    if(t[i][j] < lim + EPS){
      g[i].push_back(j+n);
      g[j+n].push_back(i);
    }
  }
  memset(match,-1,sizeof(match));

  int res = 0;
  rep(i,n+m){
    if(match[i]<0){
      memset(use,0,sizeof(use));
      if(dfs(i))res++;
    }
  }

  return res;
}

int main(){
  while(scanf("%d%d",&n,&m),n){
    rep(i,n)scanf("%lf%lf%lf",&x[i],&y[i],&v[i]);
    rep(i,m)scanf("%lf%lf",&px[i],&py[i]);
    
    rep(i,n)rep(j,m){
      t[i][j] = dis(x[i],y[i],px[j],py[j])/v[i];
    }

    D l = 0, r = 1e8;
    rep(i,100){
      D mid = (l+r)/2;
      if(bimatch(mid) == m)r = mid;
      else l = mid;
    }
    printf("%.10lf\n",r);
  }
}

Compiler output:
a.cc: In function 'int bimatch(D)':
a.cc:43:3: error: 'memset' was not declared in this scope
   43 |   memset(match,-1,sizeof(match));
      |   ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<cmath>
  +++ |+#include <cstring>
    4 | #define rep(i,n) for(int i=0;i<n;i++)
Language: C++

#include<iostream>
#include<vector>
#include<utility>

struct troop{
	troop(int a,int b,int c){
		x=a;
		y=b;
		v=c;
	}
	int x,y,v;
};
class base{
	int x,y,trID;
	public:
	base(int a,int b,int c){
		x=a;
		y=b;
		trID=c;
	}
	double time(troop &tr){
		return sqrt(((tr.x-x)*(tr.x-x)+(tr.y-y)*(tr.y-y)))/tr.v;
	}
	void setID(int id){
		trID=id;
		return;
	}
	int getID(void){
		return trID;
	}
};

void swapID(base a,base b){
	int i=a.getID();
	a.setID(b.getID());
	b.setID(i);
	return;
}

int main(void){
	int tnum,bnum;
	std::cin >> tnum >> bnum;
	std::vector<troop> vt;
	std::vector<base> vb;

	int tempx,tempy,tempv;
	for(int i=0;i<tnum;++i){
		std::cin >> tempx >> tempy >> tempv;
		vt.push_back(troop(tempx,tempy,tempv));
	}
	for(int i=0;i<bnum;++i){
		std::cin >> tempx >> tempy;
		vb.push_back(base(tempx,tempy,i));
	}
	
	int maxid=0;
	double maxtime=0;
	bool swapped=false;
	do{
		maxtime=0,maxid=0;
		for(int i=0;i<bnum;++i){
			if(maxtime<vb[i].time(vt[vb[i].getID()])){
				maxtime=vb[i].time(vt[vb[i].getID()]);
				maxid=i;
			}
		}
		int freetroop=vb[maxid].getID();//vb[maxid]と関連付けられているvt[freetroop]が遠いので組み換え
		for(int i=0;i<bnum;++i){
			if(vb[i].time(vt[freetroop])<maxtime){//vt[freetroop]から、vb[maxid]よりvb[i]の基地のほうが近い
				if(vb[maxid].time(vt[vb[i].getID()])<maxtime){
					swapID(vb[maxid],vb[i]);
					swapped=true;
				}
			}
		}
	}while(swapped);

	std::cout << maxtime;

	return 0;
}

Compiler output:
a.cc: In member function 'double base::time(troop&)':
a.cc:22:24: error: 'sqrt' was not declared in this scope
   22 |                 return sqrt(((tr.x-x)*(tr.x-x)+(tr.y-y)*(tr.y-y)))/tr.v;
      |                        ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<utility>

struct troop{
	troop(int a,int b,int c){
		x=a;
		y=b;
		v=c;
	}
	int x,y,v;
};
class base{
	int x,y,trID;
	public:
	base(int a,int b,int c){
		x=a;
		y=b;
		trID=c;
	}
	double time(troop &tr){
		return sqrt(((tr.x-x)*(tr.x-x)+(tr.y-y)*(tr.y-y)))/tr.v;
	}
	void setID(int id){
		trID=id;
		return;
	}
	int getID(void){
		return trID;
	}
};

void swapID(base a,base b){
	int i=a.getID();
	a.setID(b.getID());
	b.setID(i);
	return;
}

int main(void){
	int tnum,bnum;
	std::cin >> tnum >> bnum;
	std::vector<troop> vt;
	std::vector<base> vb;

	int tempx,tempy,tempv;
	for(int i=0;i<tnum;++i){
		std::cin >> tempx >> tempy >> tempv;
		vt.push_back(troop(tempx,tempy,tempv));
	}
	for(int i=0;i<bnum;++i){
		std::cin >> tempx >> tempy;
		vb.push_back(base(tempx,tempy,i));
	}
	
	int maxid=0;
	double maxtime=0;
	bool swapped=false;
	do{
		maxtime=0,maxid=0;
		for(int i=0;i<bnum;++i){
			if(maxtime<vb[i].time(vt[vb[i].getID()])){
				maxtime=vb[i].time(vt[vb[i].getID()]);
				maxid=i;
			}
		}
		int freetroop=vb[maxid].getID();
		for(int i=0;i<bnum;++i){
			if(vb[i].time(vt[freetroop])<maxtime){
				if(vb[maxid].time(vt[vb[i].getID()])<maxtime){
					swapID(vb[maxid],vb[i]);
					swapped=true;
				}
			}
		}
	}while(swapped);

	std::cout << maxtime;

	return 0;
}

Compiler output:
a.cc: In member function 'double base::time(troop&)':
a.cc:22:24: error: 'sqrt' was not declared in this scope
   22 |                 return sqrt(((tr.x-x)*(tr.x-x)+(tr.y-y)*(tr.y-y)))/tr.v;
      |                        ^~~~
Language: C++

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#define L 16*9*5*7*11
int Q[25][25]; // d周期のi時間目の量
int T[L];
int main(){
	int N,d,t,q;
	for(;scanf("%d",&N),N;){
		memset(Q,0,sizeof(Q));
		for(int i=0;i<N;++i){
			scanf("%d%d",&d,&t);
			for(int j=0;j<d;++j){
				scanf("%d",&q);
				Q[d][(j+d-t)%d] += q;
			}
		}
		int sum=0;
		memset(T,0,sizeof(T));
		for(int d=1;d<=24;++d){
			if(d==13 || d==17 || d==19 || d==23 || d==1)
				sum+=*std::max_element(Q[d],Q[d]+d);
			else
				for(int i=0;i<L;++i)T[i]+=Q[d][i%d];
		}
		printf("%d\n",sum+*std::max_element(T,T+L));
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:17: error: 'memset' was not declared in this scope
   10 |                 memset(Q,0,sizeof(Q));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cstdlib>
  +++ |+#include <cstring>
    4 | #define L 16*9*5*7*11
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int gcd(int a, int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a, int b) { return a*b/gcd(a,b); }

int main(){
	int n;
	while(cin >> n, n){
		int size[100];
		vector<int> vol[100];
		for(int i=0;i<n;i++){
			int offset;
			cin >> size[i] >> offset;
			vol[i].resize(size[i]);
			for(int j=0;j<size[i];j++) cin >> vol[i][(j+size[i]-offset)%size[i]];
		}
		int left = n;
		bool used[100];
		memset(used, false, sizeof(used));
		while(true){
			int prevsize = left;
			for(int i=0;i<n;i++){
				if(used[i]) continue;
				for(int j=0;j<n;j++){
					if(i==j||used[j]) continue;
					int gd = lcm(size[i], size[j]);
					if(gd==size[i]*size[j]) continue;
					vector<int> vi;
					for(int k=0;k<gd;k++)
						vi.push_back(vol[i][k%size[i]]+vol[j][k%size[j]]);
					size[i] = gd;
					vol[i] = vi;
					used[j] = true;
					left--;
				}
			}
			if(prevsize == left) break;
		}
		int ans = 0;
		for(int i=0;i<n;i++){
			if(used[i]) continue;
			int tmp = 0;
			for(int j=0;j<size[i];j++) tmp = max(tmp, vol[i][j]);
			ans += tmp;
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'memset' was not declared in this scope
   22 |                 memset(used, false, sizeof(used));
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | 
a.cc:50:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <iostream>

using namespace std;

int ans, w, h;
int a[20][20];

void search(int pos){
	for(int i=pos;i<=w*h;i++){
		if(i==w*h) { ans++; return; }
		int x = i%w, y = i/w;
		if(a[x][y]!=-1) continue;
		if(x!=0&&y!=0&&a[x-1][y]!=a[x-1][y-1]&&a[x-1][y-1]!=a[x][y-1]) return;
		a[x][y] = i;
		if(y!=h-1&&a[x][y+1]==-1){
			a[x][y+1] = i;
			search(pos+1);
			a[x][y+1] = -1;
		}
		if(x!=w-1&&a[x+1][y]==-1){
			a[x+1][y] = i;
			search(pos+2);
			a[x+1][y]  = -1;
		}
		a[x][y] = -1;
		break;
	}
}

int main(){
	while(cin >> w >> h, w){
		memset(a, -1, sizeof(a));
		ans = 0;
		search(0);
		cout << ans << endl;
	}
	return 0;
}

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

#include <iostream>
#include <cstdio>
#include <stdio.h>

using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int board[44][44];
int h, w;

int DFS(int x, int y, int n){
	int ret = 0;
	while(board[x][y] != 0){
		x++;
		if(x > w){
			y++;
			x = 1;
			if(y > h)return 1;
		}
	}
	//たて向き
	if(board[x][y+1]==0){
		int check = 0;
		if(board[x][y-1] != board[x+1][y-1])check++;
		if(board[x+1][y-1] != board[x+1][y])check++;
		if(check != 2){
			board[x][y] = n;
			board[x][y+1] = n;
			ret += DFS(x,y,n+1);
			board[x][y] = 0;
			board[x][y+1] = 0;
		}
	}
	//よこ向き
	if(board[x+1][y]==0){
		int check = 0;
		if(board[x+1][y-1] != board[x+2][y-1])check++;
		if(board[x+2][y] != board[x+2][y-1])check++;
		if(check != 2){
			board[x][y] = n;
			board[x+1][y] = n;
			ret += DFS(x,y,n+1);
			board[x][y] = 0;
			board[x+1][y] = 0;
		}
	}
	return ret;
}

int main(){
	while(1){
		memset(board, 0, sizeof(board));
		cin >> h>> w;
		if(h==0)break;
		REP(i,w+2){
			board[i][0] = 1000;
			board[i][h+1] = 1000;
		}
		REP(i,h+2){
			board[0][i] = 1000;
			board[w+1][i] = 1000;
		}
		if(h==0)return 0;
		cout << DFS(1, 1, 1) << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:17: error: 'memset' was not declared in this scope
   56 |                 memset(board, 0, sizeof(board));
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdio>
  +++ |+#include <cstring>
    3 | #include <stdio.h>
Language: C++

#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <string>

using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int board[44][44];
int h, w;

int DFS(int x, int y, int n){
	int ret = 0;
	while(board[x][y] != 0){
		x++;
		if(x > w){
			y++;
			x = 1;
			if(y > h)return 1;
		}
	}
	//たて向き
	if(board[x][y+1]==0){
		int check = 0;
		if(board[x][y-1] != board[x+1][y-1])check++;
		if(board[x+1][y-1] != board[x+1][y])check++;
		if(check != 2){
			board[x][y] = n;
			board[x][y+1] = n;
			ret += DFS(x,y,n+1);
			board[x][y] = 0;
			board[x][y+1] = 0;
		}
	}
	//よこ向き
	if(board[x+1][y]==0){
		int check = 0;
		if(board[x+1][y-1] != board[x+2][y-1])check++;
		if(board[x+2][y] != board[x+2][y-1])check++;
		if(check != 2){
			board[x][y] = n;
			board[x+1][y] = n;
			ret += DFS(x,y,n+1);
			board[x][y] = 0;
			board[x+1][y] = 0;
		}
	}
	return ret;
}

int main(){
	while(1){
		memset(board, 0, sizeof(board));
		cin >> h>> w;
		if(h==0)break;
		REP(i,w+2){
			board[i][0] = 1000;
			board[i][h+1] = 1000;
		}
		REP(i,h+2){
			board[0][i] = 1000;
			board[w+1][i] = 1000;
		}
		if(h==0)return 0;
		cout << DFS(1, 1, 1) << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:17: error: 'memset' was not declared in this scope
   57 |                 memset(board, 0, sizeof(board));
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdio>
  +++ |+#include <cstring>
    3 | #include <stdio.h>
Language: C++

#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <stack>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;


int r[16][16][16][257]={};
int ii[257]={};
int xx[16][16][16][257]={};

int main() 
{
	REP(i,16)REP(j,16)REP(k,16)REP(l,257){if(l==0)r[i][j][k][l]=i;else{r[i][j][k][l]=(j*r[i][j][k][l-1]+k)%256;}}

	int n;
	while(cin>>n&&n)
	{

		REP(i,n)
		{
			cin>>ii[i+1];
			REP(j,n)REP(k,n)REP(l,n)
			{
				xx[j][k][l][oo[j][k][l][ii[i+1]+r[j][k][l][i+1])%256]]++;
			}
		}
		
		double ans(10000);
		int x(0),y(0),z(0);
		
		REP(i,16)REP(j,16)REP(k,16)
		{
			double tmp(0);
			REP(l,256)
			{
				if(xx[i][j][k][l]>0)
				{
					tmp = -(double)xx[i][j][k][l]*(double)log((double)xx[i][j][k][l]);
				}
			}
			if(tmp<ans)
			{
				ans = tmp;
				x=i;
				y=j;
				z=k;
			}
			/**/cout<<i<<" "<<j<<" "<<k<<" "<<tmp<<endl;
		}
		cout<<x<<" "<<y<<" "<<z<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:45: error: 'oo' was not declared in this scope
   40 |                                 xx[j][k][l][oo[j][k][l][ii[i+1]+r[j][k][l][i+1])%256]]++;
      |                                             ^~
a.cc:40:80: error: expected ']' before ')' token
   40 |                                 xx[j][k][l][oo[j][k][l][ii[i+1]+r[j][k][l][i+1])%256]]++;
      |                                                                                ^
      |                                                                                ]
a.cc:40:80: error: expected ']' before ')' token
   40 |                                 xx[j][k][l][oo[j][k][l][ii[i+1]+r[j][k][l][i+1])%256]]++;
      |                                                                                ^
      |                                                                                ]
Language: C++

#include<iostream>
#define M 256
using namespace std;

int main()
{
	int N;
	while (cin >> N && N != 0)
	{
		int L[M];
		for (int i = 0; i < N; i++)
		{
			cin >> L[i];
		}
		int ansS = 0, ansA = 0, ansC = 0;
		double minH = 1e10;
		for (int s = 0; s <= 15; s++)
		{
			for (int a = 0; a <= 15; a++)
			{
				for (int c = 0; c <= 15; c++)
				{
					int R[M];
					int count[M];
					memset(count, 0, sizeof (int) * M);

					R[0] = (a * s + c) % M;
					for (int i = 1; i < N; i++)
					{
						R[i] = (a * R[i - 1] + c) % M;
					}

					double h = 0.0;

					for (int i = 0; i < N; i++)
					{
						count[(L[i] + R[i]) % M]++;
					}

					for (int i = 0; i < M; i++)
					{
						if (count[i] <= 0)continue;
						h -= ((double)count[i] / N) * log((double) count[i] / N);
					}

					if (h + (1e-10) < minH)
					{
						ansS = s;
						ansA = a;
						ansC = c;
						minH = h;
					}
				}
			}
		}

		cout << ansS << " " << ansA << " " << ansC << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:41: error: 'memset' was not declared in this scope
   25 |                                         memset(count, 0, sizeof (int) * M);
      |                                         ^~~~~~
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 | #define M 256
a.cc:43:79: error: 'log' was not declared in this scope; did you mean 'long'?
   43 |                                                 h -= ((double)count[i] / N) * log((double) count[i] / N);
      |                                                                               ^~~
      |                                                                               long
Language: C++

#include<iostream>
#include <stdio.h>
#define M 256
using namespace std;

int main()
{
	int N;
	while (cin >> N && N != 0)
	{
		int L[M];
		for (int i = 0; i < N; i++)
		{
			cin >> L[i];
		}
		int ansS = 0, ansA = 0, ansC = 0;
		double minH = 1e10;
		for (int s = 0; s <= 15; s++)
		{
			for (int a = 0; a <= 15; a++)
			{
				for (int c = 0; c <= 15; c++)
				{
					int R[M];
					int count[M];
					memset(count, 0, sizeof (int) * M);

					R[0] = (a * s + c) % M;
					for (int i = 1; i < N; i++)
					{
						R[i] = (a * R[i - 1] + c) % M;
					}

					double h = 0.0;

					for (int i = 0; i < N; i++)
					{
						count[(L[i] + R[i]) % M]++;
					}

					for (int i = 0; i < M; i++)
					{
						if (count[i] <= 0)continue;
						h -= ((double)count[i] / N) * log((double) count[i] / N);
					}

					if (h + (1e-10) < minH)
					{
						ansS = s;
						ansA = a;
						ansC = c;
						minH = h;
					}
				}
			}
		}

		cout << ansS << " " << ansA << " " << ansC << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:41: error: 'memset' was not declared in this scope
   26 |                                         memset(count, 0, sizeof (int) * M);
      |                                         ^~~~~~
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 | #include <stdio.h>
a.cc:44:79: error: 'log' was not declared in this scope; did you mean 'long'?
   44 |                                                 h -= ((double)count[i] / N) * log((double) count[i] / N);
      |                                                                               ^~~
      |                                                                               long
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#define m 256
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int ii[n+1],r[n+1],o[n+1];
		for(int i=1;i<=n;i++){
			cin>>ii[i];
		}
		int ss=16,aa=16,cc=16;
		float h,mh=100;
		for(int s=15;s>=0;s--){
			for(int a=15;a>=0;a--){
				for(int c=15;c>=0;c--){
					int oc[m];
					for(int i=0;i<m;i++){
						oc[i]=0;
					}
					h=0;
					r[0]=s;
					for(int i=1;i<=n;i++){
						r[i]=(a*r[i-1]+c)%m;
						o[i]=(r[i]+ii[i])%m;
						oc[o[i]]++;
					}
					for(int i=0;i<m;i++){
						if(oc[i]>0){
							float h1=oc[i],h2=n;
							h=h-(10*h1/h2)*log(h1/h2);
						}
					}
					if(h<mh){
						ss=s;
						aa=a;
						cc=c;
						mh=h;
					}
					else if(h==mh){
						if(s<ss||a<aa||c<cc){
							ss=s;
							aa=a;
							cc=c;
						}#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#define m 256
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int ii[n+1],r[n+1],o[n+1];
		for(int i=1;i<=n;i++){
			cin>>ii[i];
		}
		int ss=16,aa=16,cc=16;
		float h,mh=100;
		for(int s=15;s>=0;s--){
			for(int a=15;a>=0;a--){
				for(int c=15;c>=0;c--){
					int oc[m];
					for(int i=0;i<m;i++){
						oc[i]=0;
					}
					h=0;
					r[0]=s;
					for(int i=1;i<=n;i++){
						r[i]=(a*r[i-1]+c)%m;
						o[i]=(r[i]+ii[i])%m;
						oc[o[i]]++;
					}
					for(int i=0;i<m;i++){
						if(oc[i]>0){
							float h1=oc[i],h2=n;
							h=h-(10*h1/h2)*log(h1/h2);
						}
					}
					if(h<mh){
						ss=s;
						aa=a;
						cc=c;
						mh=h;
					}
					else if(h==mh){
						if(s<ss||a<aa||c<cc){
							ss=s;
							aa=a;
							cc=c;
						}
					}
				}
			}
		}
		cout<<ss<<" "<<aa<<" "<<cc<<endl;
	}
    return 0;
}
					}
				}
			}
		}
		cout<<ss<<" "<<aa<<" "<<cc<<endl;
	}
    return 0;
}

Compiler output:
a.cc:49:50: error: stray '#' in program
   49 |                                                 }#include <iostream>
      |                                                  ^
a.cc: In function 'int main()':
a.cc:49:51: error: 'include' was not declared in this scope
   49 |                                                 }#include <iostream>
      |                                                   ^~~~~~~
a.cc:49:68: error: expected primary-expression before '>' token
   49 |                                                 }#include <iostream>
      |                                                                    ^
a.cc:55:1: error: expected primary-expression before 'using'
   55 | using namespace std;
      | ^~~~~
a.cc:56:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   56 | int main(){
      |         ^~
a.cc:56:9: note: remove parentheses to default-initialize a variable
   56 | int main(){
      |         ^~
      |         --
a.cc:56:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:56:11: error: a function-definition is not allowed here before '{' token
   56 | int main(){
      |           ^
Language: C++

#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)

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

	const int mod = 256;

	for(int n; cin >> n, n;) {
		vector<int> l(n);
		for(int i = 0; i < n; ++i)
			cin >> l[i];

		int as, aa, ac;
		double mn = INT_MAX;
		for(int s = 0; s <= 15; ++s) {
			for(int a = 0; a <= 15; ++a) {
				for(int c = 0; c <= 15; ++c) {
					int r = s;
					map<int, int> cnt;

					for(int i = 0; i < n; ++i) {
						r = (a * r + c) % mod;
						++cnt[(l[i] + r) % mod];
					}

					double h = 0.0;
					FOR(it, cnt) {
						const double tmp = (double)it->second / n;
						h -= tmp * log2(tmp);
					}

					if(mn > h) {
						as = s;
						aa = a;
						ac = c;
						mn = h;
					}
				}
			}
		}

		cout << as << " " << aa << " " << ac << endl;
	}

	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:60: error: 'log2' was not declared in this scope
   36 |                                                 h -= tmp * log2(tmp);
      |                                                            ^~~~
Language: C++

#include<iostream>

using namespace std;

struct S{
	double min;
	int s, a, c;
};

int main(){

	int N, l[257],r[257],o[257],x[257];
	int s, a, c;
	double H;
	S ans;

	while (1){

		cin >> N;
		if (N == 0) break;

		for (int i = 1; i <= N; i++){
			cin >> l[i];
		}

		for (s = 0; s <= 15; s++){
			for (a = 0; a <= 15; a++){
				for (c = 0; c <= 15; c++){
					r[0] = s;
					for (int i = 1; i <= N; i++){
						r[i] = (a*r[i - 1] + c) % 256;
					}
					for (int i = 1; i <= N; i++){
						o[i] = (l[i] + r[i]) % 256;
					}
					for (int i = 0; i < 256; i++) {
						x[i] = 0;
					}
					for (int i = 1; i <= N; i++){
						x[o[i]]++;
					}
					H = 0;
					for (int i = 0; i < 256; i++){
						if(x[i]!=0) H += ((double)x[i] / N)*log((double)x[i] / N);
					}
					H *= -1;
					if (s == 0 && a == 0 && c == 0 || ans.min>H){
						ans.min = H;
						ans.s = s, ans.a = a, ans.c = c;
					}
				}
			}
		}
		cout << ans.s << " " << ans.a << " " << ans.c << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:85: error: 'log' was not declared in this scope; did you mean 'long'?
   44 |                                                 if(x[i]!=0) H += ((double)x[i] / N)*log((double)x[i] / N);
      |                                                                                     ^~~
      |                                                                                     long
Language: C++

#include<iostream>

using namespace std;

struct S{
	double min;
	int s, a, c;
};

int main(){

	int N, l[257],r[257],o[257],x[257];
	int s, a, c;
	double H;
	S ans;

	while (1){

		cin >> N;
		if (N == 0) break;

		for (int i = 1; i <= N; i++){
			cin >> l[i];
		}

		for (s = 0; s <= 15; s++){
			for (a = 0; a <= 15; a++){
				for (c = 0; c <= 15; c++){
					r[0] = s;
					for (int i = 1; i <= N; i++){
						r[i] = (a*r[i - 1] + c) % 256;
					}
					for (int i = 1; i <= N; i++){
						o[i] = (l[i] + r[i]) % 256;
					}
					for (int i = 0; i < 256; i++) {
						x[i] = 0;
					}
					for (int i = 1; i <= N; i++){
						x[o[i]]++;
					}
					H = 0;
					for (int i = 0; i < 256; i++){
						if(x[i]!=0) H += ((double)x[i] / N)*log((double)x[i] / N);
					}
					H *= -1;
					if (s == 0 && a == 0 && c == 0 || ans.min>H+1e-9){
						ans.min = H;
						ans.s = s, ans.a = a, ans.c = c;
					}
				}
			}
		}
		cout << ans.s << " " << ans.a << " " << ans.c << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:85: error: 'log' was not declared in this scope; did you mean 'long'?
   44 |                                                 if(x[i]!=0) H += ((double)x[i] / N)*log((double)x[i] / N);
      |                                                                                     ^~~
      |                                                                                     long
Language: C++

#include<stdio.h>
#include<algorithm>
using namespace std;
int b[100];
int d[110];
int dp[110][31];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",b+i);
		int c;scanf("%d",&c);
		for(int i=0;i<110;i++)d[i]=-1;
		for(int i=0;i<c;i++){
			int p,q;scanf("%d%d",&p,&q);
			p--;
			if(!~dp[p]||dp[p]>q)d[p]=q;
		}
		for(int i=0;i<110;i++)for(int j=0;j<31;j++)dp[i][j]=999999999;
		dp[0][0]=0;
		for(int i=0;i<100;i++){
			for(int j=0;j<a;j++){
		//		printf("%d %d: %d\n",i,j,dp[i][j]);
				if(!~d[i]||b[j]<=d[i])dp[i+1][(j+1)%a]=min(dp[i+1][(j+1)%a],dp[i][j]);
				dp[i+1][1%a]=min(dp[i+1][1%a],dp[i][j]+1);
			}
		}
		int ret=999999999;
		for(int i=0;i<a;i++)ret=min(ret,dp[100][i]);
		printf("%d\n",ret);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:34: error: wrong type argument to bit-complement
   16 |                         if(!~dp[p]||dp[p]>q)d[p]=q;
      |                              ~~~~^
a.cc:16:42: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |                         if(!~dp[p]||dp[p]>q)d[p]=q;
      |                                     ~~~~~^~
Language: C++

#include <iostream>
using namespace std;

int H, W, C, M, Nw, Nc, Nm, s, t, res;
int Win, Wout, Cin, Cout, Mio, V;
int cap[310][310];
bool used[310];
enum { source = 300, sink, nwin, nwout, ncin, ncout, nmio };

bool dfs(int v, int t)
{
	if(v == t) return true;
	used[v] = true;
	for(int i = 0; i < 310; ++i)
		if(cap[v][i] > 0 && !used[i])
			if(dfs(i, t)) {
				--cap[v][i]; ++cap[i][v]; return true;
			}
	return false;
}

int main()
{
	while(cin >> H >> W >> C >> M >> Nw >> Nc >> Nm && H >= 0)
	{
		Win  = H;
		Wout = Win  + W;
		Cin  = Wout + W;
		Cout = Cin  + C;
		Mio  = Cout + C;

		memset(cap, 0, sizeof(cap));
		for(int i = 0; i < H; ++i) {
			cap[source][i] = 1;
			cap[i][nwin] = 1;
		}
		for(int i = 0; i < W; ++i) {
			cin >> s;
			for(int j = 0; j < s; ++j) { cin >> t; cap[t-1][Win+i] = 1; }
			cap[Win+i][Wout+i] = 1;
			cap[Wout+i][ncin] = 1;
		}
		for(int i = 0; i < C; ++i) {
			cin >> s;
			for(int j = 0; j < s; ++j) { cin >> t; cap[Wout+t-1][Cin+i] = 1; }
			cap[nwout][Cin+i] = 1;
			cap[Cin+i][Cout+i] = 1;
			cap[Cout+i][nmio] = 1;
		}
		for(int i = 0; i < M; ++i) {
			cin >> s;
			for(int j = 0; j < s; ++j) { cin >> t; cap[Cout+t-1][Mio+i] = 1; }
			cap[ncout][Mio+i] = 1;
			cap[Mio+i][sink] = 1;
		}
		cap[nwin][nwout] = Nw;
		cap[ncin][ncout] = Nc;
		cap[nmio][sink]  = Nm;

		res = 0;
		while(true)
		{
			fill_n(used, 310, false);
			if(!dfs(source, sink)) break;
			++res;
		}
		cout << res << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: 'memset' was not declared in this scope
   32 |                 memset(cap, 0, sizeof(cap));
      |                 ^~~~~~
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 <string>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;


bool hs[1<<24];

int calchs(int c[8])
{
	int ret=0;
	for(int i=0; i<8; i++)
		ret|=c[i]<<(3*i);

	return ret;
}

class Octahedra
{
public:
	int f[8];

	void all_rotate()
	{
hs[calchs(f)]=1;
		for(int i=0; i<4; i++)
		{
			x_rot();
			for(int j=0; j<4; j++)
			{
				y_rot();
				for(int k=0; k<4; k++)
				{
					z_rot();
					hs[calchs(f)]=1;
				}
			}
		}
	}

	void x_rot()
	{
		int t1=f[0], t2=f[4];
		f[0]=f[1];
		f[1]=f[2];
		f[2]=f[3];
		f[3]=t1;

		f[4]=f[5];
		f[5]=f[6];
		f[6]=f[7];
		f[7]=t2;
		
	}

	void y_rot()
	{
		int t0=f[0], t1=f[1], t2=f[2], t3=f[3];
		f[0]=f[4];
		f[1]=f[5];
		f[2]=t0;
		f[3]=t1;
		f[4]=f[6];
		f[5]=f[7];
		f[6]=t2;
		f[7]=t3;
	}

	void z_rot()
	{
		int t0=f[0],t1=f[1], t2=f[2], t6=f[6];
		f[0]=f[4];
		f[1]=t0;
		f[2]=f[3];
		f[3]=f[7];
		f[4]=f[5];
		f[5]=t1;
		f[6]=t2;
		f[7]=t6;
	}

	Octahedra(int face[8])
	{
		for(int i=0; i<8; i++)
			f[i]=face[i];
	}
};

int main()
{
	int c[8];
	string s;
	while(1)
	{
		memset(hs, 0, sizeof(hs));
		int cnt=0;
		map<string, int> d;

		for(int i=0; i<8; i++)
		{
			if(!(cin >> s)) return 0;
			
			int color;			
			if(d.count(s) == 0)
			{
				color=cnt;
				d.insert(make_pair(s,cnt));
				cnt++;
			}
			else
			{
				color=d.find(s)->second;
			}

			c[i]=color;
		}
	

		int ans=0;
		sort(c, c+8);
		while(1)
		{
			Octahedra o(c);
			
			if(!hs[calchs(c)])
			{
				ans++;
				o.all_rotate();
			}

			if(!next_permutation(c, c+8)) break;
		}
		cout << ans << endl;
	}
}

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

#include<map>
#include<set>
#include<string>
#include<vector>
#include<iostream>

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

using namespace std;

typedef	vector<int>	vi;

void rotx(vi &v){
	vi t=v;
	v[0]=t[4];	v[1]=t[5];	v[2]=t[1];	v[3]=t[0];
	v[4]=t[7];	v[5]=t[6];	v[6]=t[2];	v[7]=t[3];
}

void roty(vi &v){
	vi t=v;
	v[0]=t[4];	v[1]=t[0];	v[2]=t[6];	v[3]=t[2];
	v[4]=t[5];	v[5]=t[1];	v[6]=t[7];	v[7]=t[3];
}

void rotz(vi &v){
	vi t=v;
	v[0]=t[3];	v[1]=t[0];	v[2]=t[1];	v[3]=t[2];
	v[4]=t[7];	v[5]=t[4];	v[6]=t[5];	v[7]=t[6];
}

vi findRegularPaint(const vi &_a){
	vi a=_a,reg=a;
	rep(i,4){
		rep(j,4){
			reg=min(reg,a);
			rotz(a);
		}
		rotx(a);
	}
	roty(a);
	rep(i,4){
		reg=min(reg,a);
		rotz(a);
	}
	roty(a),roty(a);
	rep(i,4){
		reg=min(reg,a);
		rotz(a);
	}

	return reg;
}

int vi2int(const vi &a){
	int res=0;
	rep(i,a.size())	res=res*10+a[i];
	return res;
}

int main(){
	while(1){
		string s[8];
		rep(i,8) if(!(cin>>s[i])) return 0;

		vi clr(8);
		{
			int id=0;
			map<string,int> colorid;
			rep(i,8){
				if(colorid.count(s[i])==0)	colorid[s[i]]=id++;
				clr[i]=colorid[s[i]];
			}
		}
		sort(clr.begin(),clr.end());

		set<int> cube;
		do{
			cube.insert(vi2int(findRegularPaint(clr)));
		}while(next_permutation(clr.begin(),clr.end()));

		cout<<cube.size()<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:74:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   74 |                 sort(clr.begin(),clr.end());
      |                 ^~~~
      |                 short
a.cc:79:24: error: 'next_permutation' was not declared in this scope
   79 |                 }while(next_permutation(clr.begin(),clr.end()));
      |                        ^~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

void shift(int &a, int &b, int &c, int &d){
  int tmp = a;
  a = b;
  b = c;
  c = d;
  d = tmp;
}

void rotx(vector<int> &v){
  shift(v[0], v[1], v[2], v[3]);
  shift(v[4], v[5], v[6], v[7]);
}

void roty(vector<int> &v){
  shift(v[0], v[1], v[5], v[4]);
  shift(v[6], v[7], v[3], v[2]);
}

void rotz(vector<int> &v){
  shift(v[0], v[4], v[7], v[3]);
  shift(v[1], v[2], v[6], v[5]);
}

vector<int> normalize(vector<int> v){
  vector<int> res = v;
  REP(i, 4){
    REP(j, 4){
      REP(k, 4){
        res = min(res, v);
        rotx(v);
      }
      roty(v);
    }
    rotx(v);
  }
  return res;
}

int main(){
  string line;
  while(getline(cin, line)){
    string tmp;
    istringstream in(line);

    int cc = 0;
    map<string, int> color;
    vector<int> v;
    
    while(in >> tmp){
      if(color.find(tmp) == color.end()) color[tmp] = cc++;
      v.push_back(color[tmp]);
    }
    
    vector<int> p(7);
    REP(i, 7) p[i] = i;

    set<vector<int > > oct_set;
    
    do{
      vector<int> oct(8);
      oct[7] = v[7];
      REP(i, 7) oct[p[i]] = v[i];
      oct_set.insert(normalize(oct));
    }while(next_permutation(ALL(p)));
    a
    cout << oct_set.size() << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:99:5: error: 'a' was not declared in this scope
   99 |     a
      |     ^
Language: Java

import java.util.*;

public class Main2{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int nodenum = sc.nextInt();
			int qnum = sc.nextInt();
			if(nodenum == 0 && qnum == 0){
				break;
			}
			initData(nodenum);

			for(int i = 2; i <= nodenum; i++){
				setParent(i, sc.nextInt());
			}
			sc.nextLine();

			Stack<int[]> op = new Stack<int[]>();
			Stack<int[]> mkdnd = new Stack<int[]>();
			for(int i = 0; i < qnum; i++){
				char[] d = sc.nextLine().toCharArray();
				int n = new Integer(d[2] - '0');

				switch(d[0]){
					case 'M':
						int[] t = {0, n, getParent(n)};
						op.push(t);
						mark(n);
						break;
					case 'Q':
						int[] f = {1, n};
						op.push(f);
						break;		
				}
			}

			int res = 0;
			while(!op.empty()){
				int[] o = op.pop();
				switch(o[0]){
					case 0:
					//case 'M':
						setParent(o[1], o[2]);
						break;
					case 1:
					//case 'Q':
						res = res + gmRoot(o[1]);
				}
			}

			System.out.println(res);
		}
	}

	static int gmRoot(int node){
		int res = -2;
		int p = getParent(node);

		if(p == 0){
			res = node;			
		}else{
			res = gmRoot(p);
			setParent(node, res);
		}

		return res;
	}
	
	static int[] data;
	static void initData(int nodenum){
		data = new int[nodenum];
		data[0] = -1;
	}
	static int getParent(int node){
		return data[node - 1] + 1;
	}
	static void setParent(int node, int parent){
		data[node - 1] = parent - 1;
	}
	static void mark(int node){
		data[node - 1] = -1;
	}
}

Compiler output:
Main.java:3: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2{
       ^
Main.java:23: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal
				int n = new Integer(d[2] - '0');
				        ^
1 error
1 warning
Language: C

 #include<iostream>

/**************
 * @Math
 **************/
#include<cmath>
#include<algorithm>

/**************
 * @String
 **************/

#include<cstring>
#include<string>
#include<string.h>

/**************
 * @container
 **************/
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;
#define maxSize 100001
bool mark[maxSize];
int p[maxSize] , f[maxSize];
vector<int> v[maxSize];
pair<char, int> query[maxSize];
void init()
{
	for (int i = 0; i < maxSize; ++i)
	{
		 p[i] = i;
	}
}
 
int parent(int i)
{
	if(p[i] == i) return i;
	return p[i] = parent(p[i]);
 }

void u(int a, int b) 
{
	p[parent(a)] =  parent(b);
	return ;
}

void Bfs() 
{
	queue<int> que;
	que.push (1);
	p[1] = 1;
	while(!que.empty())
	{
		int cur  = que.front();
		que.pop();
		for (int i = 0; i < v[cur].size(); ++i)
		{
			if(mark[v[cur][i]] == true) {p[v[cur][i]] = v[cur][i];}
			else  p[v[cur][i]] = p[cur];		 
			que.push(v[cur][i]);
			// cout << v[cur][i] << endl;
		}	
	}
	return ;
}

int main( )
{
	int  a, N, Q;	
	while ( cin >>  N >> Q  && N && Q) {
		memset(mark,0,sizeof(mark));
		for (int i = 1; i <= N; ++i)
		{
			 if(i == 1) { f[1] = 1; continue;}
			 cin >> a;
			 v[a].push_back(i);
			 f[i] = a;
		}
		mark[1] = true;
		for (int i = 1; i <= Q; ++i)
		{
			  cin >> query[i].first  >> query[i].second ;
			  if(query[i].first == 'M') mark[query[i].second] = true;
		}
		 
		Bfs();
		 
		stack<int> ans ;
		for (int i = Q; i >= 1; --i)
		{
			 if(query[i].first == 'Q') { ans.push(parent(query[i].second)) ; continue;}
			 mark[query[i].second] = false;
			 p[query[i].second] = p[f[query[i].second]];
			 for (int i = 0; i < v[query[i].second].size(); ++i) 
			 {
			 	p[v[query[i].second][i]] = p[f[query[i].second]];
			 }
		}
		int num =0;
		while(!ans.empty()) {
	 		num += ans.top();
	 	    	ans.pop();
		}
		cout << num << endl;
	}
	return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 |  #include<iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#include <stdlib.h>
#include <string>
#define MAX_N 100002
int par[MAX_N];
int rank[MAX_N];
int n,o,temp[MAX_N];

struct  node {
   int parent,mark;
} ;
struct node p[MAX_N];


void node_init(int n){
  int i;
  for (i = 0; i <= n; ++i) {
    p[i].parent = temp[i];
    if (i == 1) p[i].mark = 1;
    else p[i].mark = 0;
  }
}

//Union Find Tree?????????????????????
//????????¶?????§??????????????????????????§???
//?????¨??????????´???????????????????
void init(int n){
  int i;
  for(i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}


//x?????????????´?????±??????????????????£??¨????????????
int find(int x){
  if(par[x]==x){
    return x;
  }else {
    return par[x] = find(par[x]);
  }
}


//x,y????±?????????????????????¨??????
void unite(int x,int y){
  x =find(x);
  y =find(y);
  if(x==y){
    return ;
  }

    par[y] = x;

}


//x,y????±?????????????????????????????????????
int same(int x,int y){
  return find(x)==find(y);
}

void Tree_print(){
  int i;
  for (i = 1 ;i <= n;i++) printf("%d",par[i]);
  printf("\n");
}

int main() {
  int i,ob,current;
  long long int ans;
  char str[16],op;

  while(1){
    ans = 0;
    memset(temp,0, sizeof(temp));
    scanf("%d %d",&n,&o);
    //printf("%d %d\n",n,o);
    if( n == 0 && o == 0) break;
    init(n+1);

    for (i = 2; i <= n; ++i) {
      scanf("%d",&temp[i]);
      //printf("%d get\n",i);
    }

    node_init(n);

    for (i = n; i > 1 ; --i) {
      unite(p[i].parent,i);
      //Tree_print();
    }
    //Tree_print();

    for ( i= 0;  i < o; ++i) {
      if(i == 0 )getchar();
      fgets(str,16,stdin);
      sscanf(str,"%c %d",&op,&ob);
      //printf("%c %d\n",op,ob);
      if (op == 'M'){
        p[ob].mark = 1;
      }
      else{
        if (p[ob].mark == 1) ans += ob;
        else{
          current = par[ob];
          //printf("%d\n",current);
          while(p[current].mark != 1){
            if(par[current]  == current ) break;
            current =par[current];
          }
          ans+= current;

        }
      }
    }
    printf("%lld\n",ans);
    //printf("%d %d\n ",n,o);
  }

  return 0;
}

Compiler output:
main.c:3:10: fatal error: string: No such file or directory
    3 | #include <string>
      |          ^~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX_N 200000
int par[MAX_N];
int original_par[MAX_N];
int query_list[MAX_N][2];

void init(int n){
  int i;
  for(i=0;i<n;i++){
    par[i] = i;
  }
}
int find(int x){
  if(par[x]==x){
    return x;
  }else {
    return par[x] = find(par[x]);
  }
}
void unite(int x,int y){
  x =find(x);
  y =find(y);
  if(x==y){
    return ;
  }
  par[y] = x;
}
int same(int x,int y){
  return find(x)==find(y);
}
int main(){
  int N,Q;
  long long int ans;
  int i,j,k;
  int marked_list[MAX_N];
//??¨??¨????????§?????????????????§1?????¬???
  while(1){
    scanf("%d %d",&N,&Q);
    if(N==0&&Q==0)break;

    memset(marked_list,0,sizeof(int)*N);
    marked_list[0]=1;
    original_par[0]=0;
    ans=0;

    for(i=1;i<N;i++){
      scanf("%d\n",&original_par[i]);
      original_par[i]--;
    }
    for(i=0;i<Q;i++){
      char bc;
      scanf("%c %d\n",&bc,&query_list[i][1]);
      query_list[i][0] = bc;
      query_list[i][1]--;
    }

    init(N);
    for(i=0;i<Q;i++){
      if(query_list[i][0]=='M'){
        if(marked_list[query_list[i][1]]==1){
          query_list[i][0]='N';
      }
    }
    for(i=0;i<N;i++){
      if(0==marked_list[i]){
        unite(original_par[i],i);
      }
    }
    for(i=Q-1;i>=0;i--){
      if(query_list[i][0]=='Q'){
        int q_a = find(query_list[i][1])+1;
        ans += q_a;
      //  printf(":%d\n",ans);
      }else if(query_list[i][0]=='M'){
        int m = query_list[i][1];
        unite(original_par[m],m);
      }
    }
    printf("%lld\n",ans);
  }
  return 0;

}

Compiler output:
main.c: In function 'main':
main.c:85:1: error: expected declaration or statement at end of input
   85 | }
      | ^
Language: C

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <queue>
#include <vector>
#define SIZE 100010

typedef struct Node
{
	int father;
	int ancester;
	std::vector<int> childs;
} Node;

Node node[SIZE];

void mark(int num)
{
	std::queue<int> q;
	q.push(num);
	while (!q.empty())
	{
		int n = q.front();
		q.pop();
		if (node[n].ancester == n)
		{
			continue;
		}
		node[n].ancester = num;
		for (std::vector<int>::iterator it = node[n].childs.begin(); it != node[n].childs.end(); ++it)
		{
			q.push(*it);
		}
	}
}

int main()
{
	int count, order_count;
	while (scanf("%d%d", &count, &order_count), !(count == 0 && order_count == 0))
	{
		int sum = 0;
		int father;
		for (int i = 1; i <= count; ++i)
		{
			scanf("%d", &father);
			node[i].father = father;
			node[i].ancester = 1;
			node[father].childs.push_back(i);
			node[i].childs.clear();
		}
		char ch;
		int num;
		while (order_count--)
		{
			scanf("%c %d", &ch, &num);
			getchar();
			if (ch == 'Q')
			{
				sum += node[num].ancester;
			}
			else if (ch == 'M')
			{
				mark(num);
			}
		}
		printf("%d\n", sum);
	}
	return 0;
}

Compiler output:
main.c:2:10: fatal error: iostream: No such file or directory
    2 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define mem(name,value) memset(name,value,sizeof(name))
#define loop(i,from,to) for(int i=from;i<to;i++)
#define pb push_back
using namespace std;
typedef long long ll;

const int maxn=100000+5;
int par[maxn*2],n,q,ans,v;
char op;
bool marked[maxn];

void init(int N)
{
    loop(i,0,N)
        par[i]=i;
}

int main()
{
    while(scanf("%d%d",&n,&q)!=EOF){
        if(n==0 && q==0) break;
        init(n+1);
        mem(marked,false);
        marked[1]=true;
        ans=0;
        loop(i,2,n+1){
            scanf("%d",&v);
            par[i]=v;
        }
        loop(i,0,q){
            getchar();
            scanf("%c%d",&op,&v);
            if(op=='M') marked[v]=true;
            if(op=='Q'){
                do v=par[v];
                while(!marked[v]);
                ans+=v;
            }
        }
        cout<<ans<<endl;
    }
}

Compiler output:
main.c:1:9: fatal error: cstdio: No such file or directory
    1 | #include<cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C

#include<cstdio>
#include<cstring>
int n,q,f[100005],ans;
bool mkd[100005];
char c[5],d;
int main()
{
	int i,a;
	while(1)
	{
		scanf("%d%d",&n,&q);
		if(!n) break;
		memset(mkd,0,sizeof(mkd));ans=0;
		mkd[1]=true;
		for(i=2;i<=n;i++) scanf("%d",&f[i]);
		for(i=1;i<=q;i++)
		{
			scanf("%s",c);d=c[0];
			scanf("%d",&a);
			if(d=='M') mkd[a]=true;
			if(d=='Q')
			{
				for(;!mkd[a];a=f[a]);
				ans+=a;
			}
		}
		printf("%d\n",ans);
	}
}

Compiler output:
main.c:1:9: fatal error: cstdio: No such file or directory
    1 | #include<cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define ti printf("YES\n");
typedef long long ll;
const int maxn=100005;
const int INF=0x3f3f3f3f;
const int mod=1e6;

using namespace std;

int pre[maxn];

int Find(int x)
{
    return x==pre[x]?x:Find(pre[x]);
}

int main()
{
    int n,m,x;
    char s[2];
    while(scanf("%d%d",&n,&m)&&(n+m))
    {
        pre[1]=1;
        for(int i=2; i<=n; i++)
            scanf("%d",&pre[i]);
        int ans=0;
        while(m--)
        {
            scanf("%s%d",s,&x);
            if(s[0]=='Q')
                ans+=Find(pre[x]);
            else
                pre[x]=x;
        }
        printf("%d\n",ans);
    }
}

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