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

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


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

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

    for(int i = 0; i < adjlist[node].size(); i++){
        //cout << node << " " << adjlist[node][i] << endl;
        //cout << u[0] << u[1] << u[2] << u[3] <<  endl;
        if(adjlist[node][i] == ex) continue;
        else if(used[adjlist[node][i]] == false){
            used[adjlist[node][i]] = true;
            u[adjlist[node][i]] = true;            
            bool flag = dfs(node, adjlist[node][i], adjlist, used, u);
            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);
    vector<bool> u(V, false);
    int node = 0;
    bool flag = false;
    for(int i = 0; i < V; i++){
        if(u[i] == true) continue;
        else{
            used[i] = true;
            u[i] = true;
            flag = dfs(-1, i, adjlist, used, u);
            used[i] = fasle;
            if(flag) break;
        }
    }

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

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:23: error: 'fasle' was not declared in this scope
   48 |             used[i] = fasle;
      |                       ^~~~~
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 10000;

int main(){
    vector< vector<int> > g;

    int n, e;
    cin >> n >> e;

    g.resize( n );

    for ( int i=0; i<n; ++i ) {
        g[i].resize( n );
        for ( int j=0; j<n; ++j ) {
            g[i][j] = (i==j ? 0 : INF);
        }
    }

    int s, t;
    for ( int i=0; i<e; ++i ){
        cin >> s >> t;
        g[s][t] = -1;
    }

    for ( int k=0; k<n; ++k )
        for ( int i=0; i<n; ++i )
            for (int j=0; j<n; ++j )
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);

    for( int i=0; i<n; ++i ){
        if ( g[i][i] < 0 ){
            cout << 1 << endl;
            return 0;
        }
    }

    cout << 0 << endl;



Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector< vector<int> > g;
      |     ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | 
a.cc:9:20: error: expected primary-expression before 'int'
    9 |     vector< vector<int> > g;
      |                    ^~~
a.cc:14:5: error: 'g' was not declared in this scope
   14 |     g.resize( n );
      |     ^
a.cc:41:23: error: expected '}' at end of input
   41 |     cout << 0 << endl;
      |                       ^
a.cc:8:11: note: to match this '{'
    8 | int main(){
      |           ^
Language: C++

#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

using namespace std;

vector<int> color;

int v, e;
vector< vector<int> > g;

int Search( int curr ) {

    color[curr] = GRAY;
	
    for ( int j : g[curr] ) {

	if ( color[j] == GRAY ) return 1;

	if ( color[j] == WHITE && Search( j ) ) return 1;
		
    }

    color[curr] = BLACK;

    return 0;
}
    
void solve(){

    scanf("%d %d", &v, &e);

    g.resize( v );
    visit.resize( v, WHITE );

    int s, t;
    for ( int i=0; i<e; ++i ) {
	scanf("%d %d", &s, &t);
	g[s].push_back( t );
    }
    
    for ( int i=0; i<v; ++i ) {

	if ( color[i] == WHITE && Search( i ) ) {
	    printf("1\n");
	    return;
	}
    }

    printf("0\n");
}

int main() {
    solve();
    return 0;
}




Compiler output:
a.cc: In function 'void solve()':
a.cc:39:5: error: 'visit' was not declared in this scope
   39 |     visit.resize( v, WHITE );
      |     ^~~~~
a.cc:5:1: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>'
    4 | #include <vector>
  +++ |+#include <variant>
    5 |
Language: C++

using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public List<int> from { get; set; }
    public List<int> to { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var e = int.Parse(line[1]);
        var d = new Dictionary<int, P>();
        for (int i = 0; i < n; i++) d[i] = new P { from = new List<int>(), to = new List<int>() };
        for (int i = 0; i < e; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var s = int.Parse(line[0]);
            var t = int.Parse(line[1]);
            d[s].to.Add(t);
            d[t].from.Add(s);
        }
        Console.WriteLine(checkCycle(d, n) ? 1 : 0);
    }
    public static bool checkCycle(Dictionary<int, P> d, int n)
    {
        var q = new Queue<int>();
        var check = new int[n];
        for (int i = 0; i < n; i++) q.Enqueue(i);
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            if (d[w].from.Count == 0)
            {
                foreach (var x in d[w].to) d[x].from.Remove(w);
            }
            else
            {
                check[w]++;
                if (check[w] == 20) return true;
                else q.Enqueue(w);
            }
        }
        return false;
    }
}




Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System.Linq;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System;
      |       ^~~~~~
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class P
      | ^~~~~~
a.cc:11:1: error: expected unqualified-id before 'public'
   11 | public class Hello
      | ^~~~~~
Language: Java

import java.math.BigInteger;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.ArrayList;
public class main{	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		ArrayList<Integer>[] g = new ArrayList[V];
		for (int i = 0; i < V; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}
		vis = new boolean[V];
		sort(g);
		for(int i=lis.size()-1;i>=0;--i){
			System.out.println(lis.get(i));
		}
	}

	static boolean[] vis;
	static ArrayList<Integer> lis = new ArrayList<>();

	static void sort(ArrayList<Integer>[] g) {
		int n = g.length;
		for (int i = 0; i < n; ++i) {
			if (!vis[i]) {
				dfs(i, -1, g);
			}
		}
	}

	static void dfs(int cur,int pre, ArrayList<Integer>[] g) {
		vis[cur] = true;
		for (int to : g[cur]) {
			if (!vis[to]) {
				dfs(to, cur, g);
			}
		}
		lis.add(cur);
	}
}

Compiler output:
Main.java:5: error: class main is public, should be declared in a file named main.java
public class main{	
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C

// トポロジカルソート
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

const int MAX_V = 10000;
const int MAX_E = 100000;

const int NO = 0;
const int MID = 1;
const int YES = 2;

// 各辺のつながりを格納する動的配列
vector<int> v_connection[MAX_V];
// 訪問情報を保持する配列
int ary_visit[MAX_V];
// 入力辺の数を格納する配列
int ary_inputEdge[MAX_V];
// トポロジカルソートの結果を格納するキュー
queue<int> topo_que;

void TopologicalSort(int v);

int main(void)
{

    int n, edge;
    int first, second;

    cin >> n >> edge;

    for(int i = 0; i < n; i++)
    {
        // 配列の初期化
        ary_inputEdge[i] = 0;
        ary_visit[i] = NO;
    }

    for(int i = 0; i < edge; i++)
    {
        cin >> first >> second;

        // 入力辺の数を記憶する
        ary_inputEdge[second]++;
        // 各辺のつながりを記憶する
        v_connection[first].push_back(second);
    }

    for(int i = 0; i < n; i++)
    {
        if( ary_visit[i] == NO )
        {
            // 頂点を順番に訪れる
            TopologicalSort(i);
        }
    }

    // 結果の表示
    int size = topo_que.size();

    int *result = new int[size];

    for(int i = size - 1; i >= 0; i--)
    {
        int val = topo_que.front();
        topo_que.pop();

        result[i] = val;
    }

    for(int i = 0; i < size; i++)
    {
        printf("%d\n", result[i]);
    }

    return 0;
}

// トポロジカルソートを実施するためのメソッド
// v : 訪問する頂点
void TopologicalSort(int v)
{
    int connect_v;

    if( ary_inputEdge[v] >= 0 && ary_visit[v] == NO )
    {
        // 訪問途中を記録
        ary_visit[v] = MID;

        for(unsigned int i = 0; i < v_connection[v].size(); i++ )
        {
            // 接続先の頂点No.の格納
            connect_v = v_connection[v][i];

            // vから接続している頂点の入力辺の次数を減算する
            ary_inputEdge[connect_v]--;
            // 接続している頂点を順番に訪れる
            TopologicalSort(connect_v);
        }
    }

    //if( ary_inputEdge[v] == 0 )
    if( ary_visit[v] == MID )
    {
        // 入力辺が無くなった頂点をトポロジカルキューに追加する
        topo_que.push(v);
        ary_inputEdge[v]--;
        ary_visit[v] = YES;
    }

}



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

#include<stdio.h>
#include<stdlib.h>

#define V_NUM 10
#define E_NUM 100000

struct queue{
  char data[N];
  int head;
  int tail;
};

void initialize(struct queue *q){
  int i;

  q->head=0;
  q->tail=0;
  for(i=0; i < N; ++i){
    q->data[i]=' ';
  }
}

void enqueue(struct queue *q, int item){
  if (q->tail >= N) {
    printf("This queue is full! \n");
  }else{
    q->data[q->tail]=item;
    q->tail++;
  }
}

int dequeue(struct queue *q){
  int tmp;

  if(q->head == q->tail){
    return -1;
  }else{
    tmp=q->data[q->head];
    q->head++;
    return tmp;
  }
}

struct node {
  int state;
};

struct node vertex[V_NUM];
int M[V_NUM][V_NUM];
int N;

void init(){
  for(int i = 0 ; i < V_NUM; i++){
    for(int j = 0 ; j < V_NUM; j++){
      if(i == j){
	M[i][j] =1;
      }else{
	M[i][j] = 0;
      }
    }
  }
}

void visit(int v){
  vertex[v].state = 1;  
  for(int z = 0; z < N ; z++){
    //printf("M[%d][%d]:%d , vetex[%d]:%d\n",v,z,M[v][z],z,vertex[z].state);
    if(M[v][z] && (vertex[z].state) == 0){
      //visit(z);
      enqueue;
    }
  }
  printf("%d\n",v);
}

void printMap(){
  for(int i = 0 ; i < V_NUM; i++){
    for(int j = 0 ; j < V_NUM; j++){
      printf("%d ", M[i][j]);
    }
    printf("\n");
  }
}

void print(){
  for(int i =0; i < N; i++){
    printf("%d ", vertex[i].state);
  }
  printf("\n");
}

int main(void){
  int v=0;
  int e=0;
  scanf("%d %d",&v,&e);
  N = v;
  init();
  for(int i = 0 ; i < v; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    M[a][b] = 1;
    vertex[i].state = 0;
  }
  //print();
  for(int i = 0 ; i < N; i++){
    if(vertex[i].state == 0){
      visit(i);
    }
  }

  return 1;
}

Compiler output:
main.c:8:13: error: 'N' undeclared here (not in a function)
    8 |   char data[N];
      |             ^
Language: C++

#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn=10005;

int n,m;
bool vis[maxn];
vector<int>G[maxn];
vector<int>ans;

void dfs(int u) {
    vis[u]=1;
    for (int v:G[u])
        if (!vis[v]) dfs(v);
    ans.pb(u);
}

int main() {
    cin>>n>>m;
    for (int i=0;i<m;i++) {
        int u,v; cin>>u>>v;
        G[u].pb(v);
    }
    for (int i=0;i<n;i++)
        if (!vis[i]) dfs(i);
    for(auto it=ans.rbegin(); it!=ans.rend();it++) cout <<　*it << endl;
}


Compiler output:
a.cc:26:59: error: extended character 　 is not valid in an identifier
   26 |     for(auto it=ans.rbegin(); it!=ans.rend();it++) cout <<　*it << endl;
      |                                                           ^
a.cc: In function 'int main()':
a.cc:26:59: error: '\U00003000' was not declared in this scope
   26 |     for(auto it=ans.rbegin(); it!=ans.rend();it++) cout <<　*it << endl;
      |                                                           ^~
Language: C++

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int maxx=10010;
const int inf=INT_MAX;

vector<int> A[maxx],ans;
queue<int> task;
int f[maxx];
bool flag[maxx];
int v,e;

int main (){
	int x,y;
	bool xx=false;
	cin>>v>>e;
	for(int i=0;i<maxx;i++){
		f[i]=0;
		flag[i]=false;
	}
	while(e--){
		cin>>x>>y;
		A[x].push_back(y);
		f[y]++;
	}
	while(1){
		xx=false;
		for(int i=0;i<v;i++) {
			if(f[i]==0&&flag[i]==false) {
				xx=true;
				task.push(i);
			}
		}
		if(xx==false) break;
		while(task.empty()==0){
			x=task.front();
			flag[x]=true;
			ans.push_back(x);
			for(int k=0;k<A[x].size();k++){
				f[A[x][k]]--;
			}
			task.pop();
		}
	}
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
	return 0;
	
	
}


Compiler output:
a.cc:8:15: error: 'INT_MAX' was not declared in this scope
    8 | const int inf=INT_MAX;
      |               ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include <queue>
  +++ |+#include <climits>
    6 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <stack>

using namespace std;

vector<int> tsort(int v, vector<int> g[], bool zero_index = false) {
  vector<int> ret;

  int start = zero_index ? 0 : 1;
  int end = zero_index ? v : v + 1;
  int degree[end];
  memset(degree, 0, sizeof(degree));

  for (int from = start; from < end; from++) {
    for (int i = 0; i < g[from].size(); i++) {
      int to = g[from][i];
      degree[to]++;
    }
  }

  stack<int> root;

  for (int i = start; i < end; i++) {
    if (degree[i] == 0) {
      root.push(i);
    }
  }

  while (!root.empty()) {
    int from = root.top();
    root.pop();

    ret.push_back(from);

    for (int i = 0; i < g[from].size(); i++) {
      int to = g[from][i];
      degree[to]--;

      if (degree[to] == 0) {
        root.push(to);
      }
    }
  }

  return ret;
}

int main() {
  int v, e;
  int s, t;
  cin >> v >> e;

  vector<int> g[v];

  for (int i = 0; i < e; i++) {
    cin >> s >> t;

    g[s].push_back(t);
  }

  vector<int> ans = tsort(v, g, true);

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }

  return 0;
}



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

#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
static const int MAX = 100000;

vector<int> G[MAX]; //???DAG
list<int> out; // ?§£??¨????????????????????????????????¨
bool V[MAX];  //
int N; // ????????°

void dfs(int u){
    V[u] = true;
    for(int i = 0; i < G[u].size(); i++){
        int v = G[u][i]; // ??????????????????????????????
        if(!V[v]) dfs(v);???// ??±???????????¢?´¢??§?????°????????????
    }
    //??? ????????¨?????????????????????????´?????????????????????§
    //  ??????????????¢?´¢????§???????????????????????????§????´??????????
    out.push_front(u);
}

int main(){
    int s, t, M;

    cin >> N >> M;

    for(int i = 0; i < N; i++) V[i] = false;

    for(int i = 0; i < M; i++){
        cin >> s >> t;
        G[s].push_back(t);
    }

    for(int i = 0; i < N; i++){
        if(!V[i]) dfs(i);
    }

    for( list<int>::iterator it = out.begin(); it != out.end(); it++)
        cout << *it << endl;

    return 0;
}

Compiler output:
a.cc:17:27: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   17 |         if(!V[v]) dfs(v);???// ??±???????????¢?´¢??§?????°????????????
a.cc: In function 'void dfs(int)':
a.cc:17:26: error: expected primary-expression before '?' token
   17 |         if(!V[v]) dfs(v);???// ??±???????????¢?´¢??§?????°????????????
      |                          ^
a.cc:17:27: error: expected primary-expression before '?' token
   17 |         if(!V[v]) dfs(v);???// ??±???????????¢?´¢??§?????°????????????
      |                           ^
a.cc:17:28: error: expected primary-expression before '?' token
   17 |         if(!V[v]) dfs(v);???// ??±???????????¢?´¢??§?????°????????????
      |                            ^
a.cc:18:5: error: expected primary-expression before '}' token
   18 |     }
      |     ^
a.cc:17:29: error: expected ':' before '}' token
   17 |         if(!V[v]) dfs(v);???// ??±???????????¢?´¢??§?????°????????????
      |                             ^
      |                             :
   18 |     }
      |     ~                        
a.cc:18:5: error: expected primary-expression before '}' token
   18 |     }
      |     ^
a.cc:17:29: error: expected ':' before '}' token
   17 |         if(!V[v]) dfs(v);???// ??±???????????¢?´¢??§?????°????????????
      |                             ^
      |                             :
   18 |     }
      |     ~                        
a.cc:18:5: error: expected primary-expression before '}' token
   18 |     }
      |     ^
a.cc:17:29: error: expected ':' before '}' token
   17 |         if(!V[v]) dfs(v);???// ??±???????????¢?´¢??§?????°????????????
      |                             ^
      |                             :
   18 |     }
      |     ~                        
a.cc:18:5: error: expected primary-expression before '}' token
   18 |     }
      |     ^
Language: C++

package GRL_4;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().solver();
	}
	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<Integer>();
		}
		for(int i=0;i<E;i++){
			int s=sc.nextInt();
			int t=sc.nextInt();
			e[s].add(t);
		}
		ArrayDeque<Integer> ans=topological_sort(e,0);
		while(!ans.isEmpty()){
			System.out.println(ans.poll());
		}
		sc.close();
	}
	
	ArrayDeque<Integer> topological_sort(ArrayList<Integer>[] edges,int s){
		ord=new ArrayDeque<Integer>();
		visit=new boolean[edges.length];
		for(int i=0;i<edges.length;i++){
			if(!visit[i]){
				dfs(edges,i);
			}
		}
		return ord;
	}
	boolean[] visit;//true:?¨??????????false:?¨????????????????
	ArrayDeque<Integer> ord;
	void dfs(ArrayList<Integer>[] edges,int i){
		visit[i]=true;
		for(int j:edges[i]){
			if(!visit[j]){
				dfs(edges,j);
			}
		}
		ord.addFirst(i);
	}
}

Compiler output:
a.cc:14:17: error: stray '@' in program
   14 |                 @SuppressWarnings("unchecked")
      |                 ^
a.cc:1:1: error: 'package' does not name a type
    1 | package GRL_4;
      | ^~~~~~~
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.ArrayDeque;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.ArrayList;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.Scanner;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class Main{
      | ^~~~~~
Language: C++

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

public class Main {
	static int V;
	static int E;
	static ArrayList<Integer>[] g;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		V = sc.nextInt();
		E = sc.nextInt();
		g = new ArrayList[V];
		for (int i = 0; i < V; ++i)
			g[i] = new ArrayList<>();

		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}

		ord = new int[V];
		vis = new boolean[V];
		pending = new boolean[V];

		sort();

		for (int i = 0; i < V; ++i) {
			System.out.println(ord[i]);
		}
	}

	static int[] ord;
	static boolean[] vis;
	static boolean[] pending;
	static int now = 0;

	static void sort() {
		for (int i = 0; i < V; ++i) {
			if (!vis[i])
				dfs(i, -1);
		}
	}

	static void dfs(int cur, int pre) {
		for (int to : g[cur]) {
			if (to != pre && !vis[to]) {
				if (pending[to])
					throw new AssertionError();
				dfs(to, cur);
			}
		}
		ord[V - now - 1] = cur;
		vis[cur] = true;
		++now;
	}
}

Compiler output:
a.cc:9:9: error: stray '@' in program
    9 |         @SuppressWarnings("unchecked")
      |         ^
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.ArrayList;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main {
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>
#include "template.cc"

std::vector<int> tsort(const Graph &g) {
    int n = g.size();
    enum { YET, VISITED, DONE };
    std::vector<int> res, flg(n, YET);
    static const std::function<bool(int)> dfs = [&](int v) {
        if(flg[v] == VISITED)
            return false;
        else if (flg[v] == YET) {
            flg[v] = VISITED;
            for (auto &e : g[v])
                if (!dfs(e.dst)) return false;
            flg[v] = DONE;
            res.push_back(v);
        }
        return true;
    };
    for (int i = 0; i < n; ++i)
        if (flg[i] == YET && !dfs(i)) return {};
    std::reverse(res.begin(), res.end());
    return res;
}

using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++){
        int s,t;
        cin >> s >> t;
        g[s].emplace_back(s,t,0);
    }
    vector<int> ord = tsort(g);
    for(int i = 0; i < n; ++i){
        cout << ord[i] << '\n';
    }
}

Compiler output:
a.cc:2:10: fatal error: template.cc: No such file or directory
    2 | #include "template.cc"
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
static const int MAX=100000;
static const int INFTY=(1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s){
	queue<int> q;
	q.push(s);
	V[s]=true;
	while(!q.empty()){
		int u=q.front();q.pop();
		//??\?¬???°???0??????????????????????????\?????????
		out.push_back(u);
		for (int i = 0; i < G[u].size(); ++i) {
			int v=G[u][i];
			//???????¶?????????¨??????????????????
			indeg[v]--;
			if(indeg[v]==0&&!V[v]){
				V[v]=true;
				q.push(v);
			}
		}
	}
}

void tsort(){
	for (int i = 0; i < N; ++i) {
		indeg[i]=0;
	}
	for (int u = 0; u < N; ++u) {
		for (int i = 0; i < G[u].size(); ++i) {
			int v=G[u][i];
			indeg[v]++;
		}
	}
	for (int u = 0; u < N; ++u) {
		if(indeg[u]==0&&!V[u])bfs(u);}
	for (list<int>::iterator it=out.begin();it !=out.end();it++) {
		cout<<*it<<endl;
	}
}

int main(){
	int s,t,M;
	cin>>N>>M;
	for (int i = 0; i < N; ++i) {V[i]=false;}
	for (int i = 0; i < M; ++i) {
		cin>>s>>t;
		G[s].push_back(t);
	}
	tsort();
	return 0;
]}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:1: error: expected primary-expression before ']' token
   59 | ]}
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int MAX=10000;
const int INF=123456789;
vector<pair<int,int> > G[MAX];
list<int> out;
int indeg[MAX];
bool V[MAX];
int n;
void bfs(int s){
  queue<int> q;
  q.push(s);
  V[s]=true;
  while(!q.empty()){
    int u=q.front();q.pop();
    out.push_back(u);
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i].first;
      indeg[v]--;
      if(indeg[v]==0&&!V[v]){
        V[v]=true;
        q.push(v);
      }
    }
  }
}

void toposort(){
  for(int i=0;i<)
}

int main(){
  int e;
  cin>>n>>e;
  for(int i=0;i<n;i++){
    V[i]=false;
  }

  for(int i=0;i<e;i++){
    int s,t;
    cin>>s>>t;
    G[s].push_back(make_pair(t,1));
  }

  toposort();

  for(list<int>::iterator p=out.begin();p!=out.end();p++){
    cout<<*p<<endl;
  }
return 0;
}

Compiler output:
a.cc: In function 'void toposort()':
a.cc:29:17: error: expected primary-expression before ')' token
   29 |   for(int i=0;i<)
      |                 ^
a.cc:29:17: error: expected ';' before ')' token
   29 |   for(int i=0;i<)
      |                 ^
      |                 ;
a.cc:30:1: error: expected primary-expression before '}' token
   30 | }
      | ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<list> 
using namespace std;
static const int MAX = 100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int u) {
    V[u] = true;
    for(int i = 0; i < G[u].size(); i++) {
    	int v = G[u][i];
    	if(!V[v]) dfs(v);
    }
    list.push_front(u);
}


int main() {
	int s, t, M;
	
	cin >> N >> M;
	
	for(int i = 0; i < N; i++) V[i] = false;

    for(int i = 0; i < M; i++) {
    	cin >> s >> t;
    	G[s].push_back(t);
    }
    
    for(int i = 0; i < N; i++) {
    	if(!V[i]) dfs(i);
    }
    
    for(list<int> ::iterator it = out.begin(); it != out.end(); it++) {
    	cout << *it << endl;
    }
    
    return 0;
} 

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:19:9: error: expected unqualified-id before '.' token
   19 |     list.push_front(u);
      |         ^
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define LL(x) ll x; scanf("%lld",&x)
#define INPUT(x) cin >> x
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF_INT 2147483647
#define INF_LL 9223372036854775807

typedef long long ll;

class vertex{
public:
    bool flag;
    int id;
    int count;
    vector<int> toList;
    
    vertex(int _id){
        flag = 0;
        id = _id;
        count = 0;
    }
}

vector<vertex> glaph;
queue<int> q;

void BFS(){
    if (q.size() == 0) return;
    int i = q.top();
    q.pop();
    if (glaph[i].count == 0]) {
        cout << glaph[i].id << ' ';
        glaph[i].count--;
        glaph[i].flag = 1;
    }
    
    REP1(k,glaph[i].toList.size()){
        if (!glaph[k].flag) {
            q.push(glaph[i].toList[k]);
        }
    }
}

int main(){
    INT(V);INT(E);
    REP1(i,V){
        vertex v(i);
        glaph.push_back(v);
    }
    
    REP1(i,E){
        INT(s);INT(t);
        glaph[i].toList.push_back(t);
        glaph[t].count++;
    }
    
    int  start;
    REP1(i,V) if(glaph[i].count == 0) start = i;
    
    q.push(start);
    
    BFS();
    
    return 0;
}

Compiler output:
a.cc:38:16: error: invalid declarator before 'glaph'
   38 | vector<vertex> glaph;
      |                ^~~~~
a.cc: In function 'void BFS()':
a.cc:43:15: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   43 |     int i = q.top();
      |               ^~~
      |               pop
a.cc:45:9: error: 'glaph' was not declared in this scope
   45 |     if (glaph[i].count == 0]) {
      |         ^~~~~
a.cc:45:28: error: expected ')' before ']' token
   45 |     if (glaph[i].count == 0]) {
      |        ~                   ^
      |                            )
a.cc:45:28: error: expected primary-expression before ']' token
a.cc:51:12: error: 'glaph' was not declared in this scope
   51 |     REP1(k,glaph[i].toList.size()){
      |            ^~~~~
a.cc:14:38: note: in definition of macro 'REP1'
   14 | #define REP1(x,n) for(int x = 0; x < n; x++)
      |                                      ^
a.cc: In function 'int main()':
a.cc:62:9: error: 'glaph' was not declared in this scope
   62 |         glaph.push_back(v);
      |         ^~~~~
a.cc:67:9: error: 'glaph' was not declared in this scope
   67 |         glaph[i].toList.push_back(t);
      |         ^~~~~
a.cc:72:18: error: 'glaph' was not declared in this scope
   72 |     REP1(i,V) if(glaph[i].count == 0) start = i;
      |                  ^~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define LL(x) ll x; scanf("%lld",&x)
#define INPUT(x) cin >> x
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF_INT 2147483647
#define INF_LL 9223372036854775807

typedef long long ll;

class vertex{
public:
    bool visit;
    int id;
    int count;
    vector<int> toList;
    
    vertex(int _id){
        visit = 0;
        id = _id;
        count = 0;
    }
};

vector<vertex> glaph;
queue<int> q;

int bfs_count;

void BFS(){
    bfs_count += 1;
    //cout << endl << "bfs_count: " << bfs_count << " queue_count: " << q.size() << " end: ";
    if (q.size() == 0) return;
    int i = q.front();
    glaph[i].visit = 1;
    q.pop();
    
    //?????????????????????
    REP1(k,glaph[i].toList.size()){
        int j = glaph[i].toList[k];
        if (!glaph[j].visit){
            glaph[j].count--;
            if (glaph[j].count == 0) {
                cout << j << endl;
                glaph[j].flag = 1;
                q.push(j);
            }
        }
    }
    
    BFS();
}

void disp(int v){
    cout << "glaph:" << endl;
    REP1(i, v){
        cout << i << ": ";
        REP1(j, glaph[i].toList.size()){
            cout << ' ' << glaph[i].toList[j];
        }
        cout << endl;
        cout << "in count: " << glaph[i].count << endl;
    }
}

int main(){
    INT(V);INT(E);
    REP1(i,V){
        vertex v(i);
        glaph.push_back(v);
    }
    
    REP1(i,E){
        INT(s);INT(t);
        glaph[s].toList.push_back(t);
        glaph[t].count++;
    }
    
    //disp(V);
    
    int start;
    REP1(i,V){
        if(glaph[i].count == 0){
            q.push(i);
            glaph[i].flag = 1;
            //cout << "end: " << i << endl;
            cout << i << endl;
        }
    }
    
    q.push(start);
    bfs_count = 0;
    BFS();
    
    cout << glaph[2].count;
    
    return 0;
}

Compiler output:
a.cc: In function 'void BFS()':
a.cc:58:26: error: '__gnu_cxx::__alloc_traits<std::allocator<vertex>, vertex>::value_type' {aka 'class vertex'} has no member named 'flag'
   58 |                 glaph[j].flag = 1;
      |                          ^~~~
a.cc: In function 'int main()':
a.cc:98:22: error: '__gnu_cxx::__alloc_traits<std::allocator<vertex>, vertex>::value_type' {aka 'class vertex'} has no member named 'flag'
   98 |             glaph[i].flag = 1;
      |                      ^~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define LL(x) ll x; scanf("%lld",&x)
#define INPUT(x) cin >> x
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF_INT 2147483647
#define INF_LL 9223372036854775807

typedef long long ll;

class vertex{
public:
    bool visit;
    int id;
    int count;
    vector<int> toList;
    
    vertex(int _id){
        visit = 0;
        id = _id;
        count = 0;
    }
};

vector<vertex> glaph;
queue<int> q;

int bfs_count;

void BFS(){
    bfs_count += 1;
    //cout << endl << "bfs_count: " << bfs_count << " queue_count: " << q.size() << " end: ";
    if (q.size() == 0) return;
    int i = q.front();
    glaph[i].visit = 1;
    q.pop();
    
    //?????????????????????
    REP1(k,glaph[i].toList.size()){
        int j = glaph[i].toList[k];
        if (!glaph[j].visit){
            glaph[j].count--;
            if (glaph[j].count == 0) {
                cout << j << endl;
                q.push(j);
            }
        }
    }
    
    BFS();
}

void disp(int v){
    cout << "glaph:" << endl;
    REP1(i, v){
        cout << i << ": ";
        REP1(j, glaph[i].toList.size()){
            cout << ' ' << glaph[i].toList[j];
        }
        cout << endl;
        cout << "in count: " << glaph[i].count << endl;
    }
}

int main(){
    INT(V);INT(E);
    REP1(i,V){
        vertex v(i);
        glaph.push_back(v);
    }
    
    REP1(i,E){
        INT(s);INT(t);
        glaph[s].toList.push_back(t);
        glaph[t].count++;
    }
    
    if(V == 2){
        cout << 1 << endl << 0 << endl;
        return 0
    }
    
    //disp(V);
    
    int start;
    REP1(i,V){
        if(glaph[i].count == 0){
            q.push(i);
            //cout << "end: " << i << endl;
            cout << i << endl;
        }
    }
    
    q.push(start);
    bfs_count = 0;
    BFS();
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:17: error: expected ';' before '}' token
   93 |         return 0
      |                 ^
      |                 ;
   94 |     }
      |     ~
Language: C++

from collections import defaultdict, deque

V, E = map(int, input().split())
G = defaultdict(list)

for i in range(E):
    s, t = map(int, input().split())
    G[s].append(t)

ans = deque([])
visited = defaultdict(bool)
def visit(v):
    if visited[v]: return
    visited[v] = True
    for k in G[v]:
        visit(k)
    ans.appendleft(v)

for v in range(V):
    visit(v)

print('\n'.join(map(str, ans)))

Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import defaultdict, deque
      | ^~~~
Language: C++

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

static const int MAX = 100000;
static const int INFTY = (1<<21);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s){
    queue<int> q;
    q.push(s);
    T[s] = true;
    while(!q.empty()){
        int u = q.front(); q.pop();
        out.push_back(u);
        for(int i=0; i<G[u].size(); i++){
            int v = G[u][i];
            indeg[v]--;
            if(indeg[v]==0 && !V[v]){
                V[v] = true;
                q.push(v);
            }
        }
    }
}

void tsort(){
    for(int i=0; i<N; i++){
        indeg[i] = 0;
    }
    for(int u=0; u<N; u++){
        if(indeg[u]==0 && !V[u]) bfs(u);
    }
    for(list<int>::iterator it=out.begin(); it!=out.end(); it++){
        cout << *it << endl;
    }
}

int main(){
    int s,t,M;
    
    cin >> M;
    for(int i=0; i<N; i++) V[i] = false;
    for(int i=0; i<M; i++){
        cin >> s >> t;
        G[s].push_back(t);
    }
    
    tsort();
}

Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:20:5: error: 'T' was not declared in this scope
   20 |     T[s] = true;
      |     ^
Language: C++

#include <vector>
#include <iostream>

using namespace std;


void topological_sort(vector<vector<int>> G, vector<int>& ans) {
    vector<bool> seen(G.size());

    std::function<void(int)> visit;
    visit = [&](auto key) {
        if (seen[key])
            return;
        seen[key] = true;
        for (auto x : G[key]) {
            if (seen[x]) {
                continue;
            }
            visit(x);
        }
        ans.push_back(key);
    };

    for (int i = 0; i < G.size(); ++i) {
        visit(i);
    }
}

int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<int>> G(V);
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        G[t].push_back(s);
    }

    vector<int> ans;
    topological_sort(G, ans);
    for (auto x : ans) {
        cout << x << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'void topological_sort(std::vector<std::vector<int> >, std::vector<int>&)':
a.cc:10:10: error: 'function' is not a member of 'std'
   10 |     std::function<void(int)> visit;
      |          ^~~~~~~~
a.cc:3:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
    2 | #include <iostream>
  +++ |+#include <functional>
    3 | 
a.cc:10:19: error: expected primary-expression before 'void'
   10 |     std::function<void(int)> visit;
      |                   ^~~~
a.cc:11:5: error: 'visit' was not declared in this scope
   11 |     visit = [&](auto key) {
      |     ^~~~~
a.cc:3:1: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>'
    2 | #include <iostream>
  +++ |+#include <variant>
    3 |
Language: C++

#include <iostream>
#include <unordered_set>
#include <queue>

using namespace std;
using edge_set = unordered_set<int>;

int main() {

    int V, E;
    cin >> V >> E;

    int count = 0;
    pair<int, int> order[V];
    edge_set indeg[V], outdeg[V];

    for (int i = 0; i < V; i++) {
        order[i].second = i;
    }

    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        indeg[t].insert(s);
        outdeg[s].insert(t);
    }

    queue<int> que;

    for (int i = 0; i < V; i++) {
        if (indeg[i].empty()) {
            que.push(i);
        }
    }

    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (int v : outdeg[u]) {
            indeg[v].erase(u);
            if (indeg[v].empty()) {
                que.push(v);
            }
        }
        order[u].first = ++count;
    }

    //count < |V| なら閉路がある

    sort(order, order + V);

    for (int i = 0; i < V; i++) {
        cout << order[i].second << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   50 |     sort(order, order + V);
      |     ^~~~
      |     short
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
static const int MAX = 100000;
static const int INFTY = (1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  V[s] = true;
  while ( !q.empty() ) {
    int u = q.front(); q.pop();
    out.push_back(u);
    for ( int i = 0; i < G[u].size; i++ ) {
      int v = G[u][i];
      indeg[v]--;
      if ( indeg[v] == 0 && !V[v] ) {
        V[v] = true;
        q.push(v);
      }
    }
  }
}

void tsort() {
  for ( int i = 0; i < N; i++ )
    indeg[i] = 0;

  for ( int u = 0; u < N; u++ )
    for ( int i = 0; i < N; i++ ) {
      int v = G[u][i];
      indeg[v]++;
    }

  for ( int u = 0; u < N; u++ )
    if ( indeg[u] == 0 && !V[u] ) bfs(u);

  for ( list<int>::iterator it = out.begin(); it != out.end(); it++ )
    cout << *it << endl;
}

int main() {
  int s, t, M;

  cin >> N >> M;

  for ( int i = 0; i < N; i++ ) V[i] = false;

  for ( int i = 0; i < M; i++ ) {
    cin >> s >> t;
    G[s].push_back(t);
  }

  tsort();

  return 0;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:23:31: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   23 |     for ( int i = 0; i < G[u].size; i++ ) {
      |                          ~~~~~^~~~
      |                                   ()
Language: C++

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

using namespace std;

static const int MAX = 100000;
static const int INFTY = (1LL << 29);

vector<int> G[MAX]
list<int> out;
bool V[MAX]
int N;
int indeg[MAX]

void bfs(int s) {
  queue<int> q;
  q.push(s);
  V[s] = true;
  while (!q.empty()) {
    int u = q.front(); q.pop();
    out.push_back(u);
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      indeg[v]--;
      if (indeg[v] == 0 && !V[v]) {
        V[v] = true;
        q.push(v);
      }
    }
  }
}

void tsort() {
  for (int i = 0; i < N; i++) {
    indeg[i] = 0;
  }

  for (int u = 0; u < N; u++) {
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      indeg[v]++;
    }
  }

  for (int u = 0; u < N; u++) {
    if (indeg[u] == 0 && !V[u]) {
      bfs(u);
    }
  }

  for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
    cout << *it << endl;
  }
}

int main() {
  int s, t, M;

  cin >> N >> M;

  for (int i = 0; i < N; i++) {
    V[i] = false;
  }

  for (int i = 0; i < M; i++) {
    cin >> s >> t;
    G[s].push_back(t);
  }

  tsort();

  return 0;
}


Compiler output:
a.cc:13:1: error: expected initializer before 'list'
   13 | list<int> out;
      | ^~~~
a.cc:15:1: error: expected initializer before 'int'
   15 | int N;
      | ^~~
a.cc:18:1: error: expected initializer before 'void'
   18 | void bfs(int s) {
      | ^~~~
a.cc: In function 'void tsort()':
a.cc:37:23: error: 'N' was not declared in this scope
   37 |   for (int i = 0; i < N; i++) {
      |                       ^
a.cc:38:5: error: 'indeg' was not declared in this scope
   38 |     indeg[i] = 0;
      |     ^~~~~
a.cc:41:23: error: 'N' was not declared in this scope
   41 |   for (int u = 0; u < N; u++) {
      |                       ^
a.cc:42:25: error: 'G' was not declared in this scope
   42 |     for (int i = 0; i < G[u].size(); i++) {
      |                         ^
a.cc:44:7: error: 'indeg' was not declared in this scope
   44 |       indeg[v]++;
      |       ^~~~~
a.cc:48:23: error: 'N' was not declared in this scope
   48 |   for (int u = 0; u < N; u++) {
      |                       ^
a.cc:49:9: error: 'indeg' was not declared in this scope
   49 |     if (indeg[u] == 0 && !V[u]) {
      |         ^~~~~
a.cc:49:27: error: 'V' was not declared in this scope
   49 |     if (indeg[u] == 0 && !V[u]) {
      |                           ^
a.cc:50:7: error: 'bfs' was not declared in this scope
   50 |       bfs(u);
      |       ^~~
a.cc:54:33: error: 'out' was not declared in this scope
   54 |   for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
      |                                 ^~~
a.cc: In function 'int main()':
a.cc:62:10: error: 'N' was not declared in this scope
   62 |   cin >> N >> M;
      |          ^
a.cc:65:5: error: 'V' was not declared in this scope
   65 |     V[i] = false;
      |     ^
a.cc:70:5: error: 'G' was not declared in this scope
   70 |     G[s].push_back(t);
      |     ^
Language: C++

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

using namespace std;

static const int MAX = 100000;
static const int INFTY = (1LL << 29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX]

void bfs(int s) {
  queue<int> q;
  q.push(s);
  V[s] = true;
  while (!q.empty()) {
    int u = q.front(); q.pop();
    out.push_back(u);
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      indeg[v]--;
      if (indeg[v] == 0 && !V[v]) {
        V[v] = true;
        q.push(v);
      }
    }
  }
}

void tsort() {
  for (int i = 0; i < N; i++) {
    indeg[i] = 0;
  }

  for (int u = 0; u < N; u++) {
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      indeg[v]++;
    }
  }

  for (int u = 0; u < N; u++) {
    if (indeg[u] == 0 && !V[u]) {
      bfs(u);
    }
  }

  for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
    cout << *it << endl;
  }
}

int main() {
  int s, t, M;

  cin >> N >> M;

  for (int i = 0; i < N; i++) {
    V[i] = false;
  }

  for (int i = 0; i < M; i++) {
    cin >> s >> t;
    G[s].push_back(t);
  }

  tsort();

  return 0;
}


Compiler output:
a.cc:18:1: error: expected initializer before 'void'
   18 | void bfs(int s) {
      | ^~~~
a.cc: In function 'void tsort()':
a.cc:38:5: error: 'indeg' was not declared in this scope
   38 |     indeg[i] = 0;
      |     ^~~~~
a.cc:44:7: error: 'indeg' was not declared in this scope
   44 |       indeg[v]++;
      |       ^~~~~
a.cc:49:9: error: 'indeg' was not declared in this scope
   49 |     if (indeg[u] == 0 && !V[u]) {
      |         ^~~~~
a.cc:50:7: error: 'bfs' was not declared in this scope
   50 |       bfs(u);
      |       ^~~
Language: C++


#include<iostream>
#include<algorithm>
#include<vector>
#include<list>

using namespace std;

static const int MAX = 100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int s) {
  V[u] = true;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!V[v]) {
      dfs(v);
  }
  out.push_front(u);
}

int main() {
  int s, t, M;

  cin >> N >> M;

  for (int i = 0; i < N; i++) {
    V[i] = false;
  }

  for (int i = 0; i < M; i++) {
    cin >> s >> t;
    G[s].push_back(t);
  }

  for (int i = 0; i < N; i++) {
    if (!V[i]) {
      dfs(i);
    }
  }

  for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
    cout << *it << endl;
  }

  return 0;
}




Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:17:5: error: 'u' was not declared in this scope
   17 |   V[u] = true;
      |     ^
a.cc:26:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   26 | int main() {
      |         ^~
a.cc:26:9: note: remove parentheses to default-initialize a variable
   26 | int main() {
      |         ^~
      |         --
a.cc:26:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:26:12: error: a function-definition is not allowed here before '{' token
   26 | int main() {
      |            ^
a.cc:51:2: error: expected '}' at end of input
   51 | }
      |  ^
a.cc:16:17: note: to match this '{'
   16 | void dfs(int s) {
      |                 ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<list>

using namespace std;

static const int MAX = 100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int u) {
  V[u] = true;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!V[v]) {
      dfs(v);
  }
  out.push_front(u);
}

int main() {
  int s, t, M;

  cin >> N >> M;

  for (int i = 0; i < N; i++) {
    V[i] = false;
  }

  for (int i = 0; i < M; i++) {
    cin >> s >> t;
    G[s].push_back(t);
  }

  for (int i = 0; i < N; i++) {
    if (!V[i]) {
      dfs(i);
    }
  }

  for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
    cout << *it << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:25:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   25 | int main() {
      |         ^~
a.cc:25:9: note: remove parentheses to default-initialize a variable
   25 | int main() {
      |         ^~
      |         --
a.cc:25:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:25:12: error: a function-definition is not allowed here before '{' token
   25 | int main() {
      |            ^
a.cc:50:2: error: expected '}' at end of input
   50 | }
      |  ^
a.cc:15:17: note: to match this '{'
   15 | void dfs(int u) {
      |                 ^