criyle/codenet-compile-errors huggingface dataset:
Language: Java


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


public class Main implements Runnable{
	@Override
	public void run(){
		new Main().solver();

	}
	// Template
	public static void main(String[] args) {
		new Thread(null, new scc(), "", 16 * 1024 * 1024).start(); 
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] e = new ArrayList[V];
		for (int i = 0; i < V; i++)
			e[i] = new ArrayList<>();
		for (int i = 0; i < E; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			e[s].add(t);
		}
		int Q = sc.nextInt();
		int[] scc = stronglyConnectedComponents(e);
		for (int i = 0; i < Q; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			if (scc[u]==scc[v]) {
				System.out.println(1);
			} else {
				System.out.println(0);
			}
		}

	}

	int[] dfsnum;
	int[] low;
	ArrayDeque<Integer> S = new ArrayDeque<>();
	ArrayList<Integer> T = new ArrayList<>();
	int N = 0;
	boolean[] used;
	int[] ret;

	int[] stronglyConnectedComponents(ArrayList<Integer> e[]) {
		int n = e.length;
		dfsnum = new int[n];
		low = new int[n];
		used = new boolean[n];
		ret = new int[n];

		for (int i = 0; i < n; i++) {
			if (used[i])
				continue;
			if (dfsnum[i] == 0) {
				dfs(e, i);
			}
		}
		return ret;
	}

	int NOW = 0;

	void dfs(ArrayList<Integer>[] e, int i) {
		S.addFirst(i);
		dfsnum[i] = N;
		N++;
		low[i] = dfsnum[i];
		for (int j : e[i]) {
			if (used[j])
				continue;
			if (!T.contains(j)) {
				T.add(j);
				dfs(e, j);
				low[i] = Math.min(low[i], low[j]);
			} else {
				low[i] = Math.min(dfsnum[j], low[i]);
			}
		}

		if (low[i] == dfsnum[i]) {
			int v;
			do {
				v = S.removeFirst();
				ret[v] = NOW;
				used[v] = true;
			} while (v != i);
			NOW++;
		}
		return;
	}
}

Compiler output:
Main.java:16: error: cannot find symbol
		new Thread(null, new scc(), "", 16 * 1024 * 1024).start(); 
		                     ^
  symbol:   class scc
  location: class Main
1 error
Language: Java



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



public class Main implements Runnable{
	@Override
	public void run(){
		new Main().solver();

	}
	// Template
	public static void main(String[] args) {
		new Thread(null, new scc(), "", 16 * 1024 * 1024).start(); 
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] e = new ArrayList[V];
		for (int i = 0; i < V; i++)
			e[i] = new ArrayList<>();
		for (int i = 0; i < E; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			e[s].add(t);
		}
		int Q = sc.nextInt();
		int[] scc = stronglyConnectedComponents(e);
		for (int i = 0; i < Q; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			if (scc[u]==scc[v]) {
				System.out.println(1);
			} else {
				System.out.println(0);
			}
		}

	}

	int[] dfsnum;
	int[] low;
	ArrayDeque<Integer> S = new ArrayDeque<>();
	ArrayList<Integer> T = new ArrayList<>();
	int N = 0;
	boolean[] used;
	int[] ret;

	int[] stronglyConnectedComponents(ArrayList<Integer> e[]) {
		int n = e.length;
		dfsnum = new int[n];
		low = new int[n];
		used = new boolean[n];
		ret = new int[n];

		for (int i = 0; i < n; i++) {
			if (used[i])
				continue;
			if (dfsnum[i] == 0) {
				dfs(e, i);
			}
		}
		return ret;
	}

	int NOW = 0;

	void dfs(ArrayList<Integer>[] e, int i) {
		S.addFirst(i);
		dfsnum[i] = N;
		N++;
		low[i] = dfsnum[i];
		for (int j : e[i]) {
			if (used[j])
				continue;
			if (!T.contains(j)) {
				T.add(j);
				dfs(e, j);
				low[i] = Math.min(low[i], low[j]);
			} else {
				low[i] = Math.min(dfsnum[j], low[i]);
			}
		}

		if (low[i] == dfsnum[i]) {
			int v;
			do {
				v = S.removeFirst();
				ret[v] = NOW;
				used[v] = true;
			} while (v != i);
			NOW++;
		}
		return;
	}
}

Compiler output:
Main.java:18: error: cannot find symbol
		new Thread(null, new scc(), "", 16 * 1024 * 1024).start(); 
		                     ^
  symbol:   class scc
  location: class Main
1 error
Language: C

#include<stdio.h>
int ta[10010],to[60010],nt[60010];
int id[10010],rid[10010],cmp[100010],r=0,f[10010]={0};
void sdfs(int e,int s,int k){
  int i;
  f[s]++;
  for(i=ta[s];i+1;i=nt[i]){
    if(i<e&&k<0&&f[to[i]]==0||i>=e&&k>=0&&f[to[i]]==1)sdfs(e,to[i],k);
  }
  k<0?id[rid[s]=r++]=s:cmp[s]=k;
}
void scc(int v,int e,int *a,int *b){
  int i,k;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    ta[a[i]]=i;
    ta[b[i]]=i+e;
  }
  for(i=k=0;i<v;i++){
    if(f[i]==0)sdfs(e,i,-1);
  }
  for(i=r;i;i--){
    if(f[id[i-1]]==1)sdfs(e,id[i-1],id[i-1]);
  }
}
int main(){
  int v,e,a[100010],b[100010],s,t,i;
  scanf("%d %d",&v,&e);
  for(i=0;i<e;i++)scanf("%d %d",&a[i],&b[i]);
  scc(v,e,a,b);
  scanf("%d",&v);
  while(v--){
    scanf("%d %d",&s,&t);
    printf("%d\n",cmp[s]-cmp[t]?0:1);
  }
  return 0;
}

Compiler output:
main.c: In function 'sdfs':
main.c:10:30: error: lvalue required as left operand of assignment
   10 |   k<0?id[rid[s]=r++]=s:cmp[s]=k;
      |                              ^
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 999999;

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

typedef long long ll;

using namespace std;



/*
class LightSwitchingPuzzle
{
public:
	int minFlips(string s)
	{

	}
}
*/



int V, E;
vector<int> G[10000];
vector<int> rG[10000];
vector<int> vs;
bool used[10000];
int cmp[10000];


void add_edge(int from, int to)
{
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v)
{
	used[v] = true;
	for (int i=0; i<G[v].size(); i++)
	{
		if (!used[G[v][i]]) dfs(G[v][i]);
	}
	vs.push_back(v);
}

void rdfs(int v, int k)
{
	used[v] = true;
	cmp[v] = k;
	for (int i=0; i<rG[v].size(); i++)
	{
		if (!used[rG[v][i]]) rdfs(rG[v][i], k);
	}
}

int main()
{
	cin >> V >> E;
	
	REP(E)
	{
		int s, t;
		cin >> s >> t;
		add_edge(s, t);
	}
	
	memset(used, 0, sizeof(used));
	vs.clear();
	for (int v=0; v<V; v++)
	{
		if (!used[v]) dfs(v);
	}
	memset(used, 0, sizeof(used));
	int k = 0;
	for (int i=vs.size()-1; i>=0; i--)
	{
		if (!used[vs[i]]) rdfs(vs[i], k++);
	}
	
	int Q;
	
	cin >> Q;
	REP(Q)
	{
		int u, v;
		cin >> u >> v;
		if (cmp[u] == cmp[v])
		{
			cout << 1 << endl;
		} else {
			cout << 0 << endl;
		}
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:9: error: 'memset' was not declared in this scope
   84 |         memset(used, 0, sizeof(used));
      |         ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   11 | #include <set>
  +++ |+#include <cstring>
   12 |
Language: C++

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

#define MAX_V 10000

int V, E, Q;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from, int to) {
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v) {
  used[v] = true;
  for(int i = 0; i < G[v].size(); i++) {
    if(!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for(int i = 0; i < rG[v].size(); i++) {
    if(!used[rG[v][i]]) rdfs(rG[v][i], k);
  }
}

int scc() {
  memset(used, 0, sizeof(used));
  vs.clear();
  for(int v = 0; v < V; v++) {
    if(!used[v]) dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k = 0;
  for(int i = vs.size() - 1; i>= 0; i--) {
    if(!used[vs[i]]) rdfs(vs[i], k++);
  }
  return k;
}

int main () {
  cin >> V >> E;
  for(int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    add_edge(s, t);
  }

  scc();

  cin >> Q;
  for(int i = 0; i < Q; i++) {
    int u, v;
    cin >> u >> v;
    if(cmp[u] == cmp[v]) cout << 1 << endl;
    else cout << 0 << endl;
  }

}

Compiler output:
a.cc: In function 'int scc()':
a.cc:36:3: error: 'memset' was not declared in this scope
   36 |   memset(used, 0, 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 | using namespace std;
Language: C++

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

#define MAX_V 10000

int V, E, Q;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from, int to) {
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v) {
  used[v] = true;
  for(int i = 0; i < G[v].size(); i++) {
    if(!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for(int i = 0; i < rG[v].size(); i++) {
    if(!used[rG[v][i]]) rdfs(rG[v][i], k);
  }
}

int scc() {
  memset(used, 0, sizeof(used));
  vs.clear();
  for(int v = 0; v < V; v++) {
    if(!used[v]) dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k = 0;
  for(int i = vs.size() - 1; i>= 0; i--) {
    if(!used[vs[i]]) rdfs(vs[i], k++);
  }
  return k;
}

int main () {
  cin >> V >> E;
  for(int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    add_edge(s, t);
  }

  scc();

  cin >> Q;
  for(int i = 0; i < Q; i++) {
    int u, v;
    cin >> u >> v;
    if(cmp[u] == cmp[v]) cout << 1 << endl;
    else cout << 0 << endl;
  }

}

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

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

int dfs(int u, int& i, vector<vector<int> >& G, vector<int>& ord, vector<int>& low, vector<bool>& vis) {
	if (ord[u] != -1) return vis[u] ? ord[u] : INT_MAX;
	ord[u] = low[u] = i++;
	vis[u] = true;
	for (int v: G[u]) low[u] = min(low[u], dfs(v, i, G, ord, low, vis));
	vis[u] = false;
	return low[u];
}

vector<int> scc(vector<vector<int> >& G) {
	int N = G.size(), i = 0;
	vector<int> ord(N, -1), low(N);
	vector<bool> vis(N);
	for (int u = 0; u < N; u++)
		if (ord[u] == -1)
			dfs(u, i, G, ord, low, vis);
	return low;
}

int main() {
	int N; cin >> N;
	vector<vector<int> > G(N);
	int M; cin >> M;
	while (M--) {
		int u, v; scanf("%d%d", &u, &v);
		G[u].push_back(v);
	}
	vector<int> low = scc(G);
	int Q; cin >> Q;
	while (Q--) {
		int u, v; scanf("%d%d", &u, &v);
		printf("%d\n", low[u] == low[v]);
	}
}

Compiler output:
a.cc: In function 'int dfs(int, int&, std::vector<std::vector<int> >&, std::vector<int>&, std::vector<int>&, std::vector<bool>&)':
a.cc:6:52: error: 'INT_MAX' was not declared in this scope
    6 |         if (ord[u] != -1) return vis[u] ? ord[u] : INT_MAX;
      |                                                    ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
using namespace std;

const double pi=4*atan(1.0);

//#include"GraphAlgorithm.hpp"
//using namespace graph_algorithm;

using cEdges=std::vector<std::vector<int>>;

void strongly_connected_components_helper1(int start,const cEdges& Edges,vector<bool>& Vertices,list<int>& SearchOrderList){
	Vertices[start]=true;

	for(const auto& val:Edges[start]){
		if(!Vertices[val]){
			strongly_connected_components_helper1(val,Edges,Vertices,SearchOrderList);
		}
	}

	SearchOrderList.push_front(start);
}

void strongly_connected_components_helper2(int start,const cEdges& tEdges,vector<bool>& tVertices,vector<int>& scc){
	tVertices[start]=true;
	scc.push_back(start);

	for(const auto& val:tEdges[start]){
		if(!tVertices[val]){
			strongly_connected_components_helper2(val,tEdges,tVertices,scc);
		}
	}
}

vector<vector<int>> strongly_connected_components(const cEdges& Edges){
	if(Edges.empty())return vector<vector<int>>();

	cEdges tEdges(Edges.size(),vector<int>());
	for(int i=0;i<Edges.size();++i){
		for(const auto& val:Edges[i]){
			tEdges[val].push_back(i);
		}
	}

	list<int> SearchOrderList;
	vector<bool> Vertices(Edges.size(),false);
	for(int i=0;i<Vertices.size();++i){
		if(!Vertices[i])strongly_connected_components_helper1(i,Edges,Vertices,SearchOrderList);
	}

	for(auto& val:Vertices)val=false;
	vector<vector<int>> scc;
	for(const auto& val:SearchOrderList){
		if(!Vertices[val]){
			scc.emplace_back(vector<int>());
			strongly_connected_components_helper2(val,tEdges,Vertices,scc.back());
		}
	}

	return scc;
}


int main() {
	int N,M;
	cin>>N>>M;
	cEdges Edges(N);
	for(int i=0;i<M;++i){
		int u,v,w;
		cin>>u>>v;

		Edges[u].push_back(v);
	}

	auto ans=strongly_connected_components(Edges);

	vector<int> SCC_List(N,-1);
	for(int i=0;i<ans.size();++i){
		for(const auto& val:ans[i]){
			SCC_List[val]=i;
		}
	}
	
	cin>>M;
	for(int i=0;i<M;++i){
		int u,v;
		cin>>u>>v;

		if(SCC_List[u]==SCC_List[v])cout<<1<<"\n";
		else cout<<0<<"\n";
	}

	//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'std::vector<std::vector<int> > strongly_connected_components(const cEdges&)':
a.cc:61:23: error: cannot bind non-const lvalue reference of type 'std::_Bit_reference&' to an rvalue of type 'std::_Bit_iterator::reference'
   61 |         for(auto& val:Vertices)val=false;
      |                       ^~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
using namespace std;

const double pi=4*atan(1.0);

using cEdges=std::vector<std::vector<int>>;

void strongly_connected_components_helper1(int start,const cEdges& Edges,vector<bool>& Vertices,list<int>& SearchOrderList){
	Vertices[start]=true;

	for(const auto& val:Edges[start]){
		if(!Vertices[val]){
			strongly_connected_components_helper1(val,Edges,Vertices,SearchOrderList);
		}
	}

	SearchOrderList.push_front(start);
}

void strongly_connected_components_helper2(int start,const cEdges& tEdges,vector<bool>& tVertices,vector<int>& scc){
	tVertices[start]=true;
	scc.push_back(start);

	for(const auto& val:tEdges[start]){
		if(!tVertices[val]){
			strongly_connected_components_helper2(val,tEdges,tVertices,scc);
		}
	}
}

vector<vector<int>> strongly_connected_components(const cEdges& Edges){
	if(Edges.empty())return vector<vector<int>>();

	cEdges tEdges(Edges.size(),vector<int>());
	for(int i=0;i<Edges.size();++i){
		for(const auto& val:Edges[i]){
			tEdges[val].push_back(i);
		}
	}

	list<int> SearchOrderList;
	vector<bool> Vertices(Edges.size(),false);
	for(int i=0;i<Vertices.size();++i){
		if(!Vertices[i])strongly_connected_components_helper1(i,Edges,Vertices,SearchOrderList);
	}

	for(auto& val:Vertices)val=false;
	vector<vector<int>> scc;
	for(const auto& val:SearchOrderList){
		if(!Vertices[val]){
			scc.emplace_back(vector<int>());
			strongly_connected_components_helper2(val,tEdges,Vertices,scc.back());
		}
	}

	return scc;
}


int main() {
	int N,M;
	cin>>N>>M;
	cEdges Edges(N);
	for(int i=0;i<M;++i){
		int u,v,w;
		cin>>u>>v;

		Edges[u].push_back(v);
	}

	auto ans=strongly_connected_components(Edges);

	vector<int> SCC_List(N,-1);
	for(int i=0;i<ans.size();++i){
		for(const auto& val:ans[i]){
			SCC_List[val]=i;
		}
	}
	
	cin>>M;
	for(int i=0;i<M;++i){
		int u,v;
		cin>>u>>v;

		if(SCC_List[u]==SCC_List[v])cout<<1<<"\n";
		else cout<<0<<"\n";
	}

	//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'std::vector<std::vector<int> > strongly_connected_components(const cEdges&)':
a.cc:58:23: error: cannot bind non-const lvalue reference of type 'std::_Bit_reference&' to an rvalue of type 'std::_Bit_iterator::reference'
   58 |         for(auto& val:Vertices)val=false;
      |                       ^~~~~~~~
Language: C++

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

///?????£?????????????§£ (Kosaraju)///
#define MAX_V 10000//????????°
int V;
vector<int> G[MAX_V], rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
//cmp[v] = cmp[U]???????????????u, v??????????????£?????????
int cmp[MAX_V];//cmp[v] := ??????v?????????????????£???????????????????????????????????????????????\??????
//??£??\??????????????????
void add_edge(int from, int to){//0origin
	G[from].push_back(to);//???????????????????????°???????????£??\?????????
  	rG[to].push_back(from);//?????????????????°???????????¢??°????????????????????°???????????£??\?????????
}
//????????????dfs
void dfs(int v){
	used[v] = true;
	for (int i = 0; i < G[v].size(); ++i){
		if(!used[G[v][i]]) dfs(G[v][i]);
	}
	vs.push_back(v);//????????\????????????????????£?????????????????????vs????????????????????\????????????
}
//2?????????dfs
void rdfs(int v, int k){
	used[v] = true;
	cmp[v] = k;//??????v???????????????k????????¨?????£???????????§???????????¨??\??????
	for (int i = 0; i < rG[v].size(); ++i){
		if(!used[rG[v][i]]) rdfs(rG[v][i], k);
	}
}
int scc(){
	memset(used, 0, sizeof(used));//0(?????£?????????)??§?????????
	vs.clear();//?????????
	for (int v = 0; v < V; ++v){
		if(!used[v]) dfs(v);
	}
	memset(used, 0 , sizeof(used));
	int k = 0;//?????£???????????????????????????
	for (int i = vs.size() - 1; i >= 0; --i){//vs?????\??£??????????????????????????????dfs
		if(!used[vs[i]]){
			rdfs(vs[i], k); k++;
		}
	}
	return k;
}

int main(void){
	int E, s, t;
	cin >> V >> E;
	rep(i, E){
		cin >> s >> t;
		add_edge(s, t);//??????s??¨t????????¨???????????????s -> t
	}
	scc();//?????£??????????????????
	int q, u, v; cin >> q;
	rep(i, q){
		cin >> u >> v;
		if(cmp[u] == cmp[v]) printf("1\n");
		else printf("0\n");
	}
	return 0;
}

Compiler output:
a.cc: In function 'int scc()':
a.cc:37:9: error: 'memset' was not declared in this scope
   37 |         memset(used, 0, sizeof(used));//0(?????£?????????)??§?????????
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cstdio>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

///?????£?????????????§£ (Kosaraju)///
#define MAX_V 10000//????????°
int V;
vector<int> G[MAX_V], rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
//cmp[v] = cmp[U]???????????????u, v??????????????£?????????
int cmp[MAX_V];//cmp[v] := ??????v?????????????????£???????????????????????????????????????????????\??????
//??£??\??????????????????
void add_edge(int from, int to){//0origin
	G[from].push_back(to);//???????????????????????°???????????£??\?????????
  	rG[to].push_back(from);//?????????????????°???????????¢??°????????????????????°???????????£??\?????????
}
//????????????dfs
void dfs(int v){
	used[v] = true;
	for (int i = 0; i < G[v].size(); ++i){
		if(!used[G[v][i]]) dfs(G[v][i]);
	}
	vs.push_back(v);//????????\????????????????????£?????????????????????vs????????????????????\????????????
}
//2?????????dfs
void rdfs(int v, int k){
	used[v] = true;
	cmp[v] = k;//??????v???????????????k????????¨?????£???????????§???????????¨??\??????
	for (int i = 0; i < rG[v].size(); ++i){
		if(!used[rG[v][i]]) rdfs(rG[v][i], k);
	}
}
int scc(){
	memset(used, 0, sizeof(used));//0(?????£?????????)??§?????????
	vs.clear();//?????????
	for (int v = 0; v < V; ++v){
		if(!used[v]) dfs(v);
	}
	memset(used, 0 , sizeof(used));
	int k = 0;//?????£???????????????????????????
	for (int i = vs.size() - 1; i >= 0; --i){//vs?????\??£??????????????????????????????dfs
		if(!used[vs[i]]){
			rdfs(vs[i], k); k++;
		}
	}
	return k;
}

int main(void){
	int E, s, t;
	cin >> V >> E;
	rep(i, E){
		cin >> s >> t;
		add_edge(s, t);//??????s??¨t????????¨???????????????s -> t
	}
	scc();//?????£??????????????????
	int q, u, v; cin >> q;
	rep(i, q){
		cin >> u >> v;
		if(cmp[u] == cmp[v]) printf("1\n");
		else printf("0\n");
	}
	return 0;
}

Compiler output:
a.cc: In function 'int scc()':
a.cc:38:9: error: 'memset' was not declared in this scope
   38 |         memset(used, 0, sizeof(used));//0(?????£?????????)??§?????????
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cstdio>
  +++ |+#include <cstring>
    4 | #include <string>
Language: C++

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

namespace SCC{
    void visit(const vector<vector<int>>&G,vector<int>&vs,vector<int>&used,int v){
        used[v]=true;
        for(auto u:G[v]){
            if(!used[u])visit(G,vs,used,u);
        }
        vs.push_back(v);
    }

    void visit2(const vector<vector<int>>&T,vector<int>&used,vector<int>&comp,int k,int v){
        comp[v]=k;
        used[v]=true;
        for(auto u:T[v]){
            if(!used[u])visit2(T,used,comp,k,u);
        }
    }

    decompose(const vector<vector<int>>&G,vector<vector<int>>&H,vector<int>&comp){
        vector<vector<int>>T(G.size());
        for(int i=0;i<G.size();i++){
            for(auto v:G[i]){
                T[v].push_back(i);
            }
        }
        comp.resize(G.size());

        vector<int>vs(G.size());
        vector<int>used(G.size());
        for(int i=0;i<G.size();i++){
            if(!used[i])visit(G,vs,used,i);
        }
        reverse(vs.begin(),vs.end());
        fill(used.begin(),used.end(),0);

        int K=0;
        for(auto v:vs){
            if(!used[v]){
                visit2(T,used,comp,K++,v);
            }
        }

        H.resize(K);
        for(int i=0;i<G.size();i++){
            for(auto v:G[i]){
                H[comp[i]].push_back(comp[v]);
            }
        }
        for(int i=0;i<K;i++){
            sort(H[i].begin(),H[i].end());
            H[i].erase(unique(H[i].begin(),H[i].end()),H[i].end());
        }
    }
}

signed main(){
    int N,M;
    scanf("%lld%lld",&N,&M);
    vector<vector<int>>G(N);
    rep(i,M){
        int a,b;
        scanf("%lld%lld",&a,&b);
        G[a].push_back(b);
    }

    vector<vector<int>>H;
    vector<int>comp;

    SCC::decompose(G,H,comp);

    int Q;
    scanf("%lld",&Q);
    while(Q--){
        int a,b;
        scanf("%lld%lld",&a,&b);
        printf("%lld\n",(int)(comp[a]==comp[b]));
    }
    return 0;
}

Compiler output:
a.cc:35:5: error: ISO C++ forbids declaration of 'decompose' with no type [-fpermissive]
   35 |     decompose(const vector<vector<int>>&G,vector<vector<int>>&H,vector<int>&comp){
      |     ^~~~~~~~~
a.cc: In function 'int SCC::decompose(const std::vector<std::vector<long long int> >&, std::vector<std::vector<long long int> >&, std::vector<long long int>&)':
a.cc:69:5: warning: no return statement in function returning non-void [-Wreturn-type]
   69 |     }
      |     ^
Language: C++

#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define MAX_V 1000

int V, cmp[MAX_V];
bool used[MAX_V];
vector<int> G[MAX_V], rG[MAX_V], vs;

void add_edge(int from, int to)
{
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v)
{
    used[v] = true;
    for (int i = 0; i < (int)G[v].size(); i++) {
	if (!used[G[v][i]]) {
            dfs(G[v][i]);
        }
    }
    vs.push_back(v);
}

void rdfs(int v, int k)
{
    used[v] = true;
    cmp[v] = k;
    for (int i = 0; i < (int)rG[v].size(); i++) {
	if (!used[rG[v][i]]) {
            rdfs(rG[v][i], k);
        }
    }
}

int scc()
{
    memset(used, false, sizeof(used));
    vs.clear();
    for (int v = 0; v < V; v++) {
	if (!used[v]) {
            dfs(v);
        }
    }
    memset(used, false, sizeof(used));
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--) {
	if (!used[vs[i]]) {
            rdfs(vs[i], k++);
        }
    }
    return k;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

                if(cmp[u]!=-1)continue;
                int s=0;
                stk[s++]=u;
                while(s!=0){
                        int v=stk[--s];
                        cmp[v]=k;
                        for(auto &e:rg[v]){
                                int t=e.to;
                                if(cmp[t]==-1)stk[s++]=t;
                        }
                }
                ++k;
        }
        return cmp;
}

int main(){
        int V,E;
        cin>>V>>E;
        Graph g(V);
        for(int i=0;i<E;++i){
                int s,t;cin>>s>>t;
                g[s].emplace_back(s,t);
        }
        int Q;cin>>Q;
        vector<int>SCC=kosaraju(g);
        for(int i=0;i<Q;++i){
                int u,v;cin>>u>>v;
                cout<<(SCC[u]==SCC[v])<<endl;
        }
}

Compiler output:
a.cc:1:17: error: expected unqualified-id before 'if'
    1 |                 if(cmp[u]!=-1)continue;
      |                 ^~
a.cc:3:17: error: 'stk' does not name a type
    3 |                 stk[s++]=u;
      |                 ^~~
a.cc:4:17: error: expected unqualified-id before 'while'
    4 |                 while(s!=0){
      |                 ^~~~~
a.cc:12:17: error: expected unqualified-id before '++' token
   12 |                 ++k;
      |                 ^~
a.cc:13:9: error: expected declaration before '}' token
   13 |         }
      |         ^
a.cc:14:9: error: expected unqualified-id before 'return'
   14 |         return cmp;
      |         ^~~~~~
a.cc:15:1: error: expected declaration before '}' token
   15 | }
      | ^
a.cc: In function 'int main()':
a.cc:19:9: error: 'cin' was not declared in this scope
   19 |         cin>>V>>E;
      |         ^~~
a.cc:20:9: error: 'Graph' was not declared in this scope
   20 |         Graph g(V);
      |         ^~~~~
a.cc:23:17: error: 'g' was not declared in this scope
   23 |                 g[s].emplace_back(s,t);
      |                 ^
a.cc:26:9: error: 'vector' was not declared in this scope
   26 |         vector<int>SCC=kosaraju(g);
      |         ^~~~~~
a.cc:26:16: error: expected primary-expression before 'int'
   26 |         vector<int>SCC=kosaraju(g);
      |                ^~~
a.cc:29:17: error: 'cout' was not declared in this scope
   29 |                 cout<<(SCC[u]==SCC[v])<<endl;
      |                 ^~~~
a.cc:29:24: error: 'SCC' was not declared in this scope
   29 |                 cout<<(SCC[u]==SCC[v])<<endl;
      |                        ^~~
a.cc:29:41: error: 'endl' was not declared in this scope
   29 |                 cout<<(SCC[u]==SCC[v])<<endl;
      |                                         ^~~~
Language: C++

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

using namespace std;

const int MAX_N = 10000;
const int V = 10000;

vector<int> G[MAX_N];
vector<int> rG[MAX_N];
vector<int> vs; //??°?????????????????????
bool used[MAX_N]; //?????§????????????????????????
int cmp[MAX_N];	//?±????????????£????????????????????????????????????

void add_edge(int from,int to)
{
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v)
{
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
	vs.push_back(v);
}

void rdfs(int v,int k)
{
	used[v] = true;
	cmp[v] = k;
	for(int i=0;i<rG[v].size();i++){
		if(!used[rG[v][i]]){
			rdfs(rG[v][i],k);
		}
	}
}

int scc(m)	//?????£??????????????°?????????
{
	memset(used,0,sizeof(used));
	vs.clear();
	for(int v=0;v<m;v++){
		if(!used[v]){
			dfs(v);
		}
	}
	memset(used,0,sizeof(used));
	int k=0;
	for(int i=vs.size()-1;i>=0;i--){
		if(!used[vs[i]]){
			rdfs(vs[i],k++);
		}
	}
	return k;
}

int main()
{
	int n,m,from,to,k,l,u,v;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> from >> to;
		add_edge(from,to);
	}
	k = scc(m);	
	cin >> l;
	for(int i=0;i<l;i++){
		cin >> u >> v;
		printf("%d\n",(cmp[u] == cmp[v]));
	}
}

Compiler output:
a.cc:46:9: error: 'm' was not declared in this scope; did you mean 'tm'?
   46 | int scc(m)      //?????£??????????????°?????????
      |         ^
      |         tm
a.cc: In function 'int main()':
a.cc:73:16: error: 'scc' cannot be used as a function
   73 |         k = scc(m);
      |             ~~~^~~
Language: C++

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

#define MAX_V 10000

int V;
vector<int> G[MAX_V], rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from, int to) {
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v) {
  used[v] = true;
  for(unsigned i=0; i<G[v].size(); i++) {
	if(!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for(unsigned i=0; i<rG[v].size(); i++) {
	if(!used[rG[v][i]]) rdfs(rG[v][i], k);
  }
}

int scc() {
  memset(used, 0, sizeof(used));
  vs.clear();
  for(int v = 0; v < V; v++) {
	if(!used[v]) dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k = 0;
  for(int i=vs.size()-1; i>=0; i--) {
	if(!used[vs[i]]) rdfs(vs[i], k++);
  }
  return k;
}

int main() {
  int E, s, t;
  cin >> V >> E;
  while(E--) {
	cin >> s >> t;
	add_edge(s, t);
  }
  
  scc();
  
  int q, u, v;
  cin >> q;
  while(q--) {
	cin >> u >> v;
	cout << ( cmp[u] == cmp[v] ) << endl;
  }
  
  return 0;
}

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

import java.util.*;

public class Main {
    private static HashMap<Integer, List<Integer>> graph;
    public static void main(String[] args) throws Exception{
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int V = scanner.nextInt();
        int E = scanner.nextInt();

        graph = new HashMap<>(V);
        for(int i = 0; i < V; ++i){
            graph.put(i, new LinkedList<>());
        }

        for(int i = 0; i < E; ++i){
            int u = scanner.nextInt();
            int v = scanner.nextInt();
            graph.get(u).add(v);
        }

        boolean[] visited = new boolean[V];

        for(int i = 0; i < V; ++i){
            boolean[] recStack = new boolean[V];
            if(!visited[i] && cyclicUtil(i, visited, recStack)){
                System.out.println("1");
                return;
            }
        }

        System.out.println("0");
        return;
    }

    private static boolean cyclicUtil(int cur, boolean[] visited, boolean[] recStack){
        visited[cur] = true;
        recStack[cur] = true;

        for(Integer adj : graph.get(cur)){
            if(recStack[adj]){
                return true;
            }
            else if(!visited[adj] && cyclicUtil(adj, visited, recStack)){
                return true;
            }
        }

        recStack[cur] = false;
        return false;
    }
}

Compiler output:
Main.java:6: error: cannot find symbol
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
                                          ^
  symbol:   class BufferedReader
  location: class Main
Main.java:6: error: cannot find symbol
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
                                                             ^
  symbol:   class InputStreamReader
  location: class Main
2 errors
Language: Java


import java.util.Scanner;

public class cycleDetection {
	static int ar[][];
	static int nodes;
	static String color[];
	static int lastCount;
	static int parent[];
	static int breaker;
	static String ans="";
	static void doDfs(int i)
	{
		int source = i;
		color[source] = "grey";
		for(int ii = 0; ii<nodes; ii++)
		{
			if(ar[i][ii]==1)
			{
				if(color[ii]=="grey")
				{
					lastCount = ii;
					breaker = 1;
					parent[ii] = source;
					break;
				}
				else if(color[ii]=="white")
				{
					parent[ii] = source;
					doDfs(ii);
				}
			}
		}
		color[source] = "black";
		
	}
	static void printPath(int a)
	{
		int source = parent[a];
		if(source==lastCount)
		{
			System.out.println(ans+lastCount);
		}
		else
		{
			ans = ans+source+" ";
			//System.out.println("Inside");
			printPath(source);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		nodes = sc.nextInt();
		int edges = sc.nextInt();
		ar =new int[nodes][nodes];
		for(int i = 0; i<edges; i++)
		{
			int a = sc.nextInt();
			int b = sc.nextInt();
			ar[a][b] = 1;
		}
		color=new String[nodes];
		parent = new int[nodes];
		for(int i =0; i<color.length; i++)
		{
			color[i] = "white";
		}
		for(int i = 0; i<color.length; i++)
		{
			if(color[i]=="white")
			{
				doDfs(i);
				if(breaker ==1)
				{
					break;
				}
			}
		}
		if(breaker==1)
		{
			System.out.println("1");
			//printPath(lastCount);
		}
		else
		{
			System.out.println("0");
		}
		

	}

}



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

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int V,E;
struct edge
{
	int from,to,cost;
	edge(int _from,int _to,int _cost){
		from =_from;
		to =_to;
		cost =_cost;
	}
};
vector<edge> G;

//trueなら負の閉路が存在するd[i]=0と初期化して発見する
int d[120];//最短距離
bool find_negative(){
	memset(d, 0, sizeof(d));
	for(int i =0;i <V;i++){
		for(int j =0;j <E;j++){
			edge e =G[j];
			if(d[e.to] >d[e.from]+e.cost){
				d[e.to] =d[e.from]+e.cost;
			//もしn回目に更新があるなら負の閉路が存在する
				if(i==V-1){
					return true;
				}
			}
		}
	}
	return false;
}

int main(){
	cin>>V>>E;
	for(int i =0;i <E;i++){
		int s,t;
		cin>>s>>t;
		G.push_back(edge(s,t,-1));
	}
	if(find_negative()){
		cout <<1<<endl;
	}else{
		cout <<0<<endl;
	}
	return 0;
}

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

const int MAX_V = 100;
std::vector<int> G[MAX_V];
int used[MAX_V];

int main(){
    int V, E;
    std::cin >> V >> E;
    
    REP(i, E){
        int u, v;
        std::cin >> u >> v;
        G[u].push_back(v);
    }

    std::queue<int> q;
    q.push(0);
    
    bool f = false;
    while(!q.empty()){
        int v = q.front();
        q.pop();
        used[v] = 1;

        REP(i, G[v].size()){
            int u = G[v][i];
            if(!used[u]){
                q.push(u);
            }else{
                f = true;
            }
        }
    }

    if(f){puts("1");}
    else{puts("0");}
}

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

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INFLL=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

vector<int> graph[10000],topo_ord;
int state[10000]; //0:まだ訪れていない、1:途中、2:探索済み

bool topo_dfs(int v){
    if(state[v]==1) return false;
    if(state[v]==2) return true;
    
    state[v]=1;
    for(auto u:graph[v]) if(!topo_dfs(u)) return false;
    state[v]=2;
    
    topo_ord.push_back(v);
    return true;
}

bool topological_sort(){ //閉路があるならばfalse、ないならばtrueを返す
    for(int v=0; v<graph.size(); ++v) if(!topo_dfs(v)) return false;
    reverse(topo_ord.begin(),topo_ord.end());
    return true;
}

void solve(){
    int v,e;
    cin >> v >> e;
    rep(i,0,e){
        int s,t;
        cin >> s >> t;
        graph[s].push_back(t);
    }
    
    if(!topological_sort()) cout << 1 << endl;
    else cout << 0 << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Compiler output:
a.cc: In function 'bool topological_sort()':
a.cc:49:26: error: request for member 'size' in 'graph', which is of non-class type 'std::vector<int> [10000]'
   49 |     for(int v=0; v<graph.size(); ++v) if(!topo_dfs(v)) return false;
      |                          ^~~~
Language: C++

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

bool findCycle(int **Edges, int numEdge, int numVert)
{
	int **R = (int**)malloc(sizeof(int*) * numVert);
	int **T = (int**)malloc(sizeof(int*) * numVert);
	R[0] = (int*)malloc(sizeof(int) * numVert * numVert);
	T[0] = (int*)malloc(sizeof(int) * numVert * numVert);

	for(int i = 0; i < numVert; i++)
	{
		R[i] = &R[0][i * numVert];
		memset(R[i], 0, sizeof(int) * numVert);
		T[i] = &T[0][i * numVert];
		memset(T[i], 0, sizeof(int) * numVert);
	}

	for(int i = 0; i < numEdge; i++)
	{
		R[Edges[i][0]][Edges[i][1]] = 1;
		T[Edges[i][0]][Edges[i][1]] = 1;
	}
	
	for(int k = 0; k < numVert; k++)
	{
		for(int i = 0; i < numVert; i++)
		{
			for(int j = 0; j < numVert; j++)
			{
				T[i][j] = T[i][j] || (T[i][k] && T[k][j]);
				if(i == j && T[i][j] == 1)
				{
					/*for(int i = 0; i < maximum; i++)
					{
						for(int j = 0; j < maximum; j++)
						{
							cout<<T[i][j]<<" ";
						}
						cout<<endl;
					}*/
					return 1;
				}
			}
		}
	}

	/*for(int i = 0; i < numVert; i++)
	{
		for(int j = 0; j < numVert; j++)
		{
			cout<<T[i][j]<<" ";
		}
		cout<<endl;
	}*/
	return 0;
}

int main()
{
	int numVert,numEdge;
	
	cin>>numVert>>numEdge;

	int **Edges = (int**)malloc(sizeof(int*) * numEdge);
	Edges[0] = (int*)malloc(sizeof(int) * numEdge * 2);
	for(int i = 0; i < numEdge; i++)
	{
		Edges[i] = &Edges[0][i*2];
		cin>>Edges[i][0]>>Edges[i][1];
	}

	/*for(int i = 0; i < numEdge; i++)
	{
		cout<<Edges[i][0]<<" "<<Edges[i][1]<<endl;
	}*/

	cout<<findCycle(Edges, numEdge, numVert)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'bool findCycle(int**, int, int)':
a.cc:15:17: error: 'memset' was not declared in this scope
   15 |                 memset(R[i], 0, sizeof(int) * numVert);
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <iostream>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;

bool findCycle(int **Edges, int numEdge, int numVert)
{
	int **R = (int**)malloc(sizeof(int*) * numVert);
	int **T = (int**)malloc(sizeof(int*) * numVert);
	R[0] = (int*)malloc(sizeof(int) * numVert * numVert);
	T[0] = (int*)malloc(sizeof(int) * numVert * numVert);

	for(int i = 0; i < numVert; i++)
	{
		R[i] = &R[0][i * numVert];
		memset(R[i], 0, sizeof(int) * numVert);
		T[i] = &T[0][i * numVert];
		memset(T[i], 0, sizeof(int) * numVert);
	}

	for(int i = 0; i < numEdge; i++)
	{
		R[Edges[i][0]][Edges[i][1]] = 1;
		T[Edges[i][0]][Edges[i][1]] = 1;
	}
	
	for(int k = 0; k < numVert; k++)
	{
		for(int i = 0; i < numVert; i++)
		{
			for(int j = 0; j < numVert; j++)
			{
				T[i][j] = T[i][j] || (T[i][k] && T[k][j]);
				if(i == j && T[i][j] == 1)
				{
					/*for(int i = 0; i < maximum; i++)
					{
						for(int j = 0; j < maximum; j++)
						{
							cout<<T[i][j]<<" ";
						}
						cout<<endl;
					}*/
					return 1;
				}
			}
		}
	}

	/*for(int i = 0; i < numVert; i++)
	{
		for(int j = 0; j < numVert; j++)
		{
			cout<<T[i][j]<<" ";
		}
		cout<<endl;
	}*/
	return 0;
}

int main()
{
	int numVert,numEdge;
	
	cin>>numVert>>numEdge;

	int **Edges = (int**)malloc(sizeof(int*) * numEdge);
	Edges[0] = (int*)malloc(sizeof(int) * numEdge * 2);
	for(int i = 0; i < numEdge; i++)
	{
		Edges[i] = &Edges[0][i*2];
		cin>>Edges[i][0]>>Edges[i][1];
	}

	/*for(int i = 0; i < numEdge; i++)
	{
		cout<<Edges[i][0]<<" "<<Edges[i][1]<<endl;
	}*/

	cout<<findCycle(Edges, numEdge, numVert)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'bool findCycle(int**, int, int)':
a.cc:16:17: error: 'memset' was not declared in this scope
   16 |                 memset(R[i], 0, sizeof(int) * numVert);
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <iostream>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

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

vector<int> d(100), f(100), color(100);
vector<vector<int> > adj(100);
int n, m, t;
bool has_loop;

#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs(int i)
{
	color[i] = GRAY;
	d[i] = ++t;
	for(int j = 0; j < adj[i].size(); j++){
		if(color[adj[i][j]] == GRAY) has_loop = true;
		if(color[adj[i][j]] == WHITE){
			dfs(adj[i][j]);
		}
	}
	color[i] = BLACK;
	f[i] = ++t;
}

int main()
{
	scanf("%d %d", &n, &m);
	int i, s, t;
	for(i = 0; i < m; i++){
		scanf("%d %d", &s, &t);
		adj[s].push_back(t);
	}
	for(i = 0; i < n; i++){ color[i] = WHITE; }

	t = 0;
	has_loop = false;
	for(i = 0; i < n; i++){ if(color[i] == WHITE){ dfs(i); } }

	printf((has_loop ? 1 : 0));

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:26: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
   43 |         printf((has_loop ? 1 : 0));
      |                ~~~~~~~~~~^~~~~~~~
      |                          |
      |                          int
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdio.h:363:43: note:   initializing argument 1 of 'int printf(const char*, ...)'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
Language: C++

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

struct Edge{
  int to, cost;

  Edge(int t, int c = 0): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
using Graph =  vector< vector<Edge> >;

bool topo_sort(const Graph& G, VI& order){
  int N = G.size();
  VI color(N, 0);
  
  function<bool(int)> visit = [&](int v)->bool{
	color[v] = 1;
	for(const auto& e: G[v]){
	  if(color[e.to] == 2) continue;
	  if(color[e.to] == 1) return false;
	  if(!visit(e.to)) return false;
	}
	order.push_back(v);
	color[v] = 2;
	return true;
  };

  for(int u=0;u<N;++u)
	if(!color[u] && !visit(u))
	  return false;
  reverse(begin(order), end(order));
  return true;
}

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

  int V, E;
  cin >> V >> E;
  Graph G(N);
  REP(i,E){
	int s, t;
	cin >> s >> t;
	G[s].emplace_back(t);
  }
  VI dump(V);
  cout << (topo_sort(G, dump)? 0: 1) << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:94:11: error: 'N' was not declared in this scope
   94 |   Graph G(N);
      |           ^
Language: C++

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


//閉路があることの判定
//dfs(再帰)による実装

bool dfs(int ex, int node, vector<vector<int> > adjlist, vector<bool>& used){

    for(int i = 0; i < adjlist[node].size(); i++){
        //cout << node << " " << adjlist[node][i] << endl;
        //cout << used[0] << used[1] << used[2] << endl;
        if(adjlist[node][i] == ex) continue;
        else if(used[adjlist[node][i]] == false){
            used[adjlist[node][i]] = true;
            bool flag = dfs(node, adjlist[node][i], adjlist, used);
            if(flag) return true;
            used[adjlist[node][i]] = false;
        }else{
            return true;
        }
    }
    return false;
}

int main(){

    int V, E; cin >> V >> E;                          // V:= 頂点の数    E:= 辺の数
    vector<vector<int> > adjlist(V);                  //first := 行先　second := コスト

    //入力
    for(int i = 0; i < E; i++){
        int a, b; cin >> a >> b;                      // a ←→ b に コスト c の辺がある
        adjlist[a].push_back(b);
    }

    vector<bool> used(V, false);
    used[0] = true;
    int node = 0;
    while(node < V){
        bool flag = dfs(-1, node, adjlist, used);
        if(flag) break;

        for(int i = node; i < V; i++){
            if(used[i] == false){
                node = i;
                break;
            }

            if(i == V - 1) node = V;
        }

    }
    if(flag) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:8: error: 'flag' was not declared in this scope
   54 |     if(flag) cout << 1 << endl;
      |        ^~~~