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

#include "bits/stdc++.h"

using namespace std;

class TopologicalSort
{
    using Graph = vector<vector<int>>;
    // 頂点数
    int n;
    vector<vector<int>> g;
    void dfs(int v, const Graph &G, vector<int> &res, vector<int> &used)
    {
        used[v] = 1;
        for (auto to : G[v])
            if (used[to] == 0)
            {
                dfs(to, G, res, used);
            }
        res.push_back(v);
    }

  public:
    TopologicalSort(int _n) : n(_n), g.resize(_n) {}
    void addEdge(int a, int b)
    {
        g[a].push_back(b);
    }
    vector<int> topoSort(const Graph &G)
    {
        int V = G.size();
        vector<int> ide(V);
        for (int i = 0; i < V; i++)
        {
            for (auto to : G[i])
            {
                ide[to]++;
            }
        }
        vector<int> res;
        vector<int> used(V);
        for (int i = V - 1; i >= 0; i--)
        {
            if (ide[i] == 0)
            {
                dfs(i, G, res, used);
            }
        }
        if (res.size() == 0)
            res = {-1};
        reverse(res.begin(), res.end());
        return res;
    }
};

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

    int n, m;
    cin >> n >> m;
    TopologicalSort g(n);
    Graph rev(n);
    for (int i = 0; i < n - 1 + m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g.addEdge(a, b);
        rev[b].push_back(a);
    }
    vector<int> ts = g.topoSort();
    vector<int> res(n, -1), pri(n);
    for (int i = 0; i < n; i++)
        pri[ts[i]] = i;
    res[ts[0]] = 0;
    for (int i = n - 1; i > 0; i--)
    {
        int v = ts[i];
        int ma = -1, idx = -1;
        for (auto u : rev[v])
        {
            if (pri[u] > ma)
            {
                ma = pri[u];
                idx = u;
            }
        }
        res[v] = idx + 1;
    }
    for (int i = 0; i < n; i++)
    {
        cout << res[i] << endl;
    }
}


Compiler output:
a.cc: In constructor 'TopologicalSort::TopologicalSort(int)':
a.cc:23:39: error: expected '(' before '.' token
   23 |     TopologicalSort(int _n) : n(_n), g.resize(_n) {}
      |                                       ^
a.cc:23:39: error: expected '{' before '.' token
a.cc: In function 'int main()':
a.cc:63:5: error: 'Graph' was not declared in this scope; did you mean 'isgraph'?
   63 |     Graph rev(n);
      |     ^~~~~
      |     isgraph
a.cc:71:9: error: 'rev' was not declared in this scope
   71 |         rev[b].push_back(a);
      |         ^~~
a.cc:73:32: error: no matching function for call to 'TopologicalSort::topoSort()'
   73 |     vector<int> ts = g.topoSort();
      |                      ~~~~~~~~~~^~
a.cc:28:17: note: candidate: 'std::vector<int> TopologicalSort::topoSort(const Graph&)'
   28 |     vector<int> topoSort(const Graph &G)
      |                 ^~~~~~~~
a.cc:28:17: note:   candidate expects 1 argument, 0 provided
a.cc:82:23: error: 'rev' was not declared in this scope; did you mean 'res'?
   82 |         for (auto u : rev[v])
      |                       ^~~
      |                       res
Language: C++

#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
namespace fastio{
	char in[100000];
	int itr=0,llen=0;
	char get(){
		if(itr==llen)llen=fread(in,1,100000,stdin),itr=0;
		if(llen==0)return EOF;
		return in[itr++];
	}
	char out[100000];
	int itr2=0;
	void put(char c){
		out[itr2++]=c;
		if(itr2==100000){
			fwrite(out,1,100000,stdout);
			itr2=0;
		}
	}
	int clear(){
		fwrite(out,1,itr2,stdout);
		itr2=0;
		return 0;
	}
	int getint(){
    	int r=0; bool ng=0; char c; c=get();
    	while (c!='-'&&(c<'0'||c>'9')) c=get();
   		if (c=='-') ng=1, c=get();
    	while (c>='0'&&c<='9') r=r*10+c-'0', c=get();
    	return ng?-r:r;
	}
	string getstr(){
		string ret="";
		char ch=get();
		while(ch==' '||ch=='\n')ch=get();
		while(ch!=' '&&ch!='\n')ret.push_back(ch),ch=get();
		return ret;
	}
	void putstr(string s){
		for(int i=0;i<s.size();i++)put(s[i]);
	}
	void putint(int x){
		if(x<0){
			put('-');
			x=-x;
		}
		if(x==0){
			put('0');
			return;
		}
		char c[20];int pos=0;
		while(x){
			c[pos++]='0'+x%10;
			x/=10;
		}
		for(int i=pos-1;i>=0;i--)put(c[i]);
	}
	void getarr(int arrname[],int size){
		 for(int i=0;i<size;i++)arrname[i]=getint();
	}
}
using namespace fastio;
#define fastio
#define SZ 300005
int n,m;
vector<int>g[SZ],g2[SZ];
int deg[SZ];
int dist[SZ];
int par[SZ];
signed main(){
	n=getint();m=getint();
	for(int i=0;i<n-1+m;i++){
		int a=getint(),b=getint();
		g[a].push_back(b);
		deg[b]++;
	}
	for(int i=1;i<=n;i++)if(deg[i]==0)q.push(i);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto to:g[x]){
			deg[to]--;
			if(deg[to]==0)par[to]=x,q.push(to); 
		}
	}
	for(int i=1;i<=n;i++){
		cout<<par[i]<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:85:43: error: 'q' was not declared in this scope
   85 |         for(int i=1;i<=n;i++)if(deg[i]==0)q.push(i);
      |                                           ^
a.cc:86:16: error: 'q' was not declared in this scope
   86 |         while(!q.empty()){
      |                ^
Language: C++

int main(){
  int N,M;
  cin>>N>>M;
  int a,b;
  vector<vector<int>> gh;
  gh.resize(N+100);
  int ghp[N+100][N+100]={};
  return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin>>N>>M;
      |   ^~~
a.cc:5:3: error: 'vector' was not declared in this scope
    5 |   vector<vector<int>> gh;
      |   ^~~~~~
a.cc:5:17: error: expected primary-expression before 'int'
    5 |   vector<vector<int>> gh;
      |                 ^~~
a.cc:6:3: error: 'gh' was not declared in this scope
    6 |   gh.resize(N+100);
      |   ^~
Language: C++



int main(){
  int N,M;
  cin>>N>>M;
  int a,b;
  vector<vector<int>> gh;
  int gh_n[N+100][N+100]={};
  gh.resize(N+100);
  //入次数の管理
  int h[N]={};
  //トポロジカルソート の実装
  for(int i=0;i<N+M-1;i++){
    cin>>a>>b;
    //aからbへの有向グラフ
    gh[a-1].push_back(b-1);
    gh_n[a-1][b-1]=1;
    h[b-1]+=1;
  }
  
  //入次数0の要素をキューとして管理
  queue<int> q;
  for(int i=0;i<N;i++){
    if(h[i]==0){
      q.push(i);
    }
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
    5 |   cin>>N>>M;
      |   ^~~
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<vector<int>> gh;
      |   ^~~~~~
a.cc:7:17: error: expected primary-expression before 'int'
    7 |   vector<vector<int>> gh;
      |                 ^~~
a.cc:9:3: error: 'gh' was not declared in this scope; did you mean 'gh_n'?
    9 |   gh.resize(N+100);
      |   ^~
      |   gh_n
a.cc:22:3: error: 'queue' was not declared in this scope
   22 |   queue<int> q;
      |   ^~~~~
a.cc:22:9: error: expected primary-expression before 'int'
   22 |   queue<int> q;
      |         ^~~
a.cc:25:7: error: 'q' was not declared in this scope
   25 |       q.push(i);
      |       ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
#include <queue>
using namespace std;


int main(){
  int N,M;
  cin>>N>>M;
  int a,b;
  vector<vector<int>> gh;
  int gh_n[N+10][N+10]={};
  gh.resize(N);
  //入次数の管理
  int h[N]={};
  //トポロジカルソート の実装
  for(int i=0;i<N+M-1;i++){
    cin>>a>>b;
    //aからbへの有向グラフ
    gh[a-1].push_back(b-1);
    gh_n[a-1][b-1]=1;
    h[b-1]+=1;
  }
  //入次数0の要素をキューとして管理
  queue<int> q;
  for(int i=0;i<N;i++){
    if(h[i]==0){
      q.push(i);
    }
  }

  vector<int> ans;
  int tmp,tmp_2;
  while(q.size()){
    int i=q.front();
    q.pop();
    ans.push_back(i);
    //隣接する頂点の入次数を-1する
    for(int j=0;j<gh[i].size();j++){
      tmp=gh[i][j];
      h[tmp]-=1;
      if(h[tmp]==0){
        q.push(tmp);
      }
    }
  }

  int result[N+10]={};
  result[ans[0]]=0;

  //順番に親を出力していく。親は入次してくる者のうち、もっともトポロジカルソートで下位の者
  for(int i=1;i<N;i++){
    tmp=ans[i];
    //tmpについて親を調べる
    for(int k=i-1;k>=0;k--){
      tmp_2=ans[k];
      //tmp2が親たりうるかしらベル
      if(gh_n[tmp_2][tmp]==1){
        result[tmp]=tmp_2+1;
        break;
      }
  }
  }

  for(int l=0;l<N;l++){
    cout<<result[i]<<"\n";
  }
  
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:18: error: 'i' was not declared in this scope
   74 |     cout<<result[i]<<"\n";
      |                  ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
#include <queue>
using namespace std;


int main(){
  int N,M;
  cin>>N>>M;
  int a,b;
  vector<vector<int>> gh;
  int gh_n[N+10][N+10]={};
  gh.resize(N);
  //入次数の管理
  int h[N]={};
  //トポロジカルソート の実装
  for(int i=0;i<N+M-1;i++){
    cin>>a>>b;
    //aからbへの有向グラフ
    gh[a-1].push_back(b-1);
    gh_n[a-1][b-1]=1;
    h[b-1]+=1;
  }
  //入次数0の要素をキューとして管理
  queue<int> q;
  for(int i=0;i<N;i++){
    if(h[i]==0){
      q.push(i);
    }
  }

  vector<int> ans;
  int tmp,tmp_2;
  while(q.size()){
    int i=q.front();
    q.pop();
    ans.push_back(i);
    //隣接する頂点の入次数を-1する
    for(int j=0;j<gh[i].size();j++){
      tmp=gh[i][j];
      h[tmp]-=1;
      if(h[tmp]==0){
        q.push(tmp);
      }
    }
  }

  int result[N+10]={};
  result[ans[0]]=0;

  //順番に親を出力していく。親は入次してくる者のうち、もっともトポロジカルソートで下位の者
  for(int i=1;i<N;i++){
    tmp=ans[i];
    //tmpについて親を調べる
    for(int k=i-1;k>=0;k--){
      tmp_2=ans[k];
      //tmp2が親たりうるかしらベル
      if(gh_n[tmp_2][tmp]==1){
        result[tmp]=tmp_2+1;
        break;
      }
  }
  }

  for(int l=0;l<N;l++){
    cout<<result[i]<<"\n";
  }
  
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:74:18: error: 'i' was not declared in this scope
   74 |     cout<<result[i]<<"\n";
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int SIZE=(1<<20);
int n,m,root,deg[SIZE];
vector<int> adj[SIZE];
void read()
{
	cin>>n>>m;
	for(int i=0;i<n-1+m;i++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		deg[v]++;
	}
}
bool vis[SIZE];
int ans[SIZE];
void dfs(int u,int pr)
{
	vis[u]=1;
	ans[u]=pr;
	for(int v:adj[u])
		deg[v]]--;
	for(int v:adj[u])
		if(!vis[v]&&deg[v]==0)
			dfs(u,adj[v]);
}
int main()
{
	read();
	for(int i=1;i<=n;i++)
		if(!deg[i])
			root=i;
	dfs(root,0);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:24:23: error: expected ';' before ']' token
   24 |                 deg[v]]--;
      |                       ^
      |                       ;
a.cc:27:36: error: cannot convert 'std::vector<int>' to 'int'
   27 |                         dfs(u,adj[v]);
      |                               ~~~~~^
      |                                    |
      |                                    std::vector<int>
a.cc:19:20: note:   initializing argument 2 of 'void dfs(int, int)'
   19 | void dfs(int u,int pr)
      |                ~~~~^~
Language: C++

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
using namespace std;
int n,m;
int num;
vector <int> g[100003];
bool vis[100003];
int parents[100003];
void dfs1(int x){
	for (int i=0;i<g[x].size();i++)
		if (!vis[g[x][i]]){
			vis[g[x][i]]=1;
			parents[g[x][i]]=x;
			dfs1(g[x][i]);
		}
}
int main(){
	memset (parents,0,sizeof(parents)); 
	memset (vis,0,sizeof(vis));
	for (int i=0;i<100003;i++) g[i].clear();
	cin>>n>>m;
	num=n;
	for (int i=0;i<m+n-1;vi++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		vis[y]=1; 
	}
	int res=1;
	for (int i=1;i<=n;i++)
		if (!vis[i]) res=i;
	memset (vis,0,sizeof(vis)); 
	dfs1(res);
	for (int i=1;i<=n;i++)
		cout<<parents[i]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:30: error: 'vi' was not declared in this scope; did you mean 'i'?
   47 |         for (int i=0;i<m+n-1;vi++){
      |                              ^~
      |                              i
Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
vvi E(100010);
int par[100010];
int dist[100010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  vi hoge(100010);
  for(int i=0;i<n+m-1;i++){
    int a,b;cin>>a>>b;
    E[a].pb(b);
    hoge[b]++;
  }
  for(int i=1;i<=n;i++){
    if(hoge[i]!=0)continue;
    queue<pair<ll,ll>>que;
    que.push(mp(i,0));
    while(!que.empty()){
      pair<int,int>now=que.front();
      que.pop();
      for(int j=0;j<E[now.F].size();j++){
	if(dist[E[now.F][j]]){
	  par[E[now.F][j]]=now.F;
	  dist[E[now.F][j]]=now.S+1;
	  que.push(mp(E[now.F][j],now.S+1));
	}else{par[E[now.F][j]]=now.F;
	  dist[E[now.F][j]]=now.S+1;
	  que.push(mp(E[now.F][j],now.S+1));}
	
      }
    }
  }
 }
for(int i=0;i<n;i++)cout<<par[i]<<endl;
return 0;
}

Compiler output:
a.cc:58:1: error: expected unqualified-id before 'for'
   58 | for(int i=0;i<n;i++)cout<<par[i]<<endl;
      | ^~~
a.cc:58:13: error: 'i' does not name a type; did you mean 'vi'?
   58 | for(int i=0;i<n;i++)cout<<par[i]<<endl;
      |             ^
      |             vi
a.cc:58:17: error: 'i' does not name a type; did you mean 'vi'?
   58 | for(int i=0;i<n;i++)cout<<par[i]<<endl;
      |                 ^
      |                 vi
a.cc:59:1: error: expected unqualified-id before 'return'
   59 | return 0;
      | ^~~~~~
a.cc:60:1: error: expected declaration before '}' token
   60 | }
      | ^
Language: C++

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

const int maxN = 100001;
// 隣接リスト
vector<int> G[maxN];
// 各辺の次数
int degree[maxN];
bool visited[maxN];
// 各頂点の親
int parent[maxN];

#define TEST
int main() {
  #ifdef TEST
    freopen("input.txt", "r", stdin);
  #endif
  int N, M;
  cin >> N >> M;

  for (int i = 0; i < maxN; i++) {
    degree[i] = 0;
    visited[i] = false;
    parent[i] = -1;
  }

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

  queue<int> q;
  for (int i = 0; i < N; i++) {
    if (degree[i] == 0) {
      q.push(i);
    }
  }
  // 根付き木なので根は1個しかない
  assert (q.size() == 1);

  vector<int> sorted;
  // topological sort
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    visited[u] = true;
    sorted.push_back(u);

    for (auto v : G[u]) {
      degree[v]--;
      if (degree[v] == 0 && visited[v] == false) {
        q.push(v);
        parent[v] = u;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    if (parent[i] == -1) {
      cout << 0 << endl;
    }
    else {
      cout << parent[i] + 1 << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:3: error: 'assert' was not declared in this scope
   43 |   assert (q.size() == 1);
      |   ^~~~~~
a.cc:4:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    3 | #include <queue>
  +++ |+#include <cassert>
    4 | using namespace std;
Language: C++

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

const int maxN = 100001;
// 隣接リスト
vector<int> G[maxN];
// 各辺の次数
int degree[maxN];
bool visited[maxN];
// 各頂点の親
int parent[maxN];

// #define TEST
int main() {
  #ifdef TEST
    freopen("input.txt", "r", stdin);
  #endif
  int N, M;
  cin >> N >> M;

  for (int i = 0; i < maxN; i++) {
    degree[i] = 0;
    visited[i] = false;
  }

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

  queue<int> q;
  for (int i = 0; i < N; i++) {
    if (degree[i] == 0) {
      q.push(i);
    }
  }
  // 根付き木なので根は1個しかない
  assert (q.size() == 1);

  // vector<int> sorted;
  // topological sort
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    visited[u] = true;
    // sorted.push_back(u);

    for (auto v : G[u]) {
      degree[v]--;
      if (degree[v] == 0 && visited[v] == false) {
        q.push(v);
        parent[v] = u;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    if (parent[i] == 0) {
      cout << parent[i] << endl;
    }
    else {
      cout << parent[i] + 1 << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:3: error: 'assert' was not declared in this scope
   42 |   assert (q.size() == 1);
      |   ^~~~~~
a.cc:4:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    3 | #include <queue>
  +++ |+#include <cassert>
    4 | using namespace std;
Language: C++

#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;

vector<int> G(100003);
int main(){
    int n, m;
    vector<int> fa(100003), rudu(100003);
    cin >> n >> m;
    queue<int> qq;
    rep(i, n + m){
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        rudu[y]++;
    }
    rep(i,n) if(rudu[i+1] == 0){
        qq.push(i+1);
        break;
    }
    while(!qq.empty()){
        int x = qq.front();
        qq.pop();
        for(int y:G[x]){
            rudu[y]--;
                if(rudu[y] == 0){
                    qq.push(y);
                    fa[y] = x;
                }
        }
    }
    rep(i, n) cout << fa[i+1] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: request for member 'push_back' in 'G.std::vector<int>::operator[](((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   21 |         G[x].push_back(y);
      |              ^~~~~~~~~
a.cc:31:22: error: 'begin' was not declared in this scope
   31 |         for(int y:G[x]){
      |                      ^
a.cc:31:22: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:31:22: error: 'end' was not declared in this scope
   31 |         for(int y:G[x]){
      |                      ^
a.cc:31:22: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
Language: C++

#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;

int main(){
    int n, m;
    vector<int> fa(100003), rudu(100003);
    cin >> n >> m;
    vector<int> G[100003];
    queue<int> qq;
    rep(i, n + m){
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        rudu[y]++;
    }
    rep(i,n) if(rudu[i+1] == 0){
        qq.push(i+1);
        break;
    }
    while(!qq.empty()){
        int x == qq.front();
        qq.pop();
        for(int y:G[x]){
            rudu[y]--;
                if(rudu[y] == 0){
                    qq.push(y);
                    fa[y] = x;
                }
        }
    }
    rep(i, n) cout << fa[i+1] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:15: error: expected initializer before '==' token
   29 |         int x == qq.front();
      |               ^~
a.cc:31:21: error: 'x' was not declared in this scope
   31 |         for(int y:G[x]){
      |                     ^
Language: C++

#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;

int main(){
    int n, m;
    vector<int> fa(100003), rudu(100003);
    cin >> n >> m;
    vector<int> G(100003);
    queue<int> qq;
    rep(i, n + m){
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        rudu[y]++;
    }
    rep(i,n) if(rudu[i+1] == 0){
        qq.push(i+1);
        break;
    }
    while(!qq.empty()){
        int x == qq.front();
        qq.pop();
        for(int y:G[x]){
            rudu[y]--;
                if(rudu[y] == 0){
                    qq.push(y);
                    fa[y] = x;
                }
        }
    }
    rep(i, n) cout << fa[i+1] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: request for member 'push_back' in 'G.std::vector<int>::operator[](((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   21 |         G[x].push_back(y);
      |              ^~~~~~~~~
a.cc:29:15: error: expected initializer before '==' token
   29 |         int x == qq.front();
      |               ^~
a.cc:31:21: error: 'x' was not declared in this scope
   31 |         for(int y:G[x]){
      |                     ^
Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
vvi E(100010);
ll par[100010];
map<pair<ll,ll>,ll>dist;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vi hoge(100010);
  for(int i=0;i<n+m-1;i++){
    ll a,b;cin>>a>>b;
    E[a].pb(b);
    hoge[b]++;
  }
  for(int i=1;i<=n;i++){
    if(hoge[b]!=0)continue;
    queue<pair<ll,ll>>que;
    que.push(mp(i,0));
    while(!que.empty()){
      pair<ll,ll>now=que.front();
      que.pop();
      for(int j=0;j<E[now.F].size();j++){
	if(par[E[now.F][j]]>0&&dist[mp(now.F,E[now.F][j])]<now.S+1){
	  par[E[now.F][j]]=now.F;
	  dist[mp(now.F,E[now.F][j])]=now.S+1;
	  que.push(mp(E[now.F][j],now.S+1));
	}else if(par[E[now.F][j]]==0){
	  par[E[now.F][j]]=now.F;
	  dist[mp(now.F,E[now.F][j])]=now.S+1;
	  que.push(mp(E[now.F][j],now.S+1));
	}
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<par[i]<<endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:13: error: 'b' was not declared in this scope
   39 |     if(hoge[b]!=0)continue;
      |             ^
Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
vvi E(100010);
ll par[100010];
map<pair<ll,ll>,ll>dist;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vi hoge(n+10);
  for(int i=0;i<n+m-1;i++){
    ll a,b;cin>>a>>b;
    E[a].pb(b);
    hoge[b]++;
  }
  for(int i=1;i<=n;i++){
    if(hoge[i]>0)continue;
    queue<ll>que;
    que.push(i);
    while(!que.empty()){
      pair<ll,ll>now=que.front();
      que.pop();
      for(int j=0;j<E[now.F].size();j++){
	if(par[E[now.F][j]]>0){
	  par[E[now.F][j]]=now.F;
	  que.push(E[now.F][j]);
	}else if(par[E[now.F][j]]==0){
	  par[E[now.F][j]]=now.F;
	  que.push(E[now.F][j]);
	}
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<par[i]<<endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:31: error: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to non-scalar type 'std::pair<long long int, long long int>' requested
   43 |       pair<ll,ll>now=que.front();
      |                      ~~~~~~~~~^~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>

std::vector<int> res_point;
std::vector<int> searched;

struct Point{
	bool root = true;
	std::vector<int> v;
};

std::vector<Point> point;

int main(){
	int N, M;
	
	std::cin >> N >> M;
	
	point.resize(N);
	res_point.resize(N);
	
	for(int i=0;i<N+M-1;i++){
		int A_, B_;
		std::cin >> A_ >> B_;
		point[A_].v.emplace_back(B_);
		point[B_].root = false;
	}
	
	int rootnum;

	for(int i=0;i<N;i++){
		if(point[i].root){
			searched.emplace_back(i);
			res_point[i] = 0;
			rootnum = i;
			break;
		}
	}
	
	a(rootnum);
	
	for(int i=0;i<N;i++){
		std::cout << res_point[i] << std::endl;
	}
	
	return 0;
}

void a(int search_p){
	std::vector<int> search_next;
	
	for(auto v_ : point[search_p].v){
		auto itr = std::find(searched.begin(), searched.end(), v_);
		size_t index = std::distance(searched.begin(), itr);
		if(index == searched.size()){
			searched.emplace_back(v_);
			res_point[v_] = search_p;
			search_next.emplace_back(v_);
		}
	}
	
	for(auto sn : search_next){
		a(sn);
	}
	
	return;
}

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

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>

std::vector<int> res_point;
std::vector<int> searched;

struct Point{
	bool root = true;
	std::vector<int> v;
};

std::vector<Point> point(N);

int main(){
	int N, M;
	
	std::cin >> N >> M;
	
	point.resize(N);
	res_point.resize(N);
	
	for(int i=0;i<N+M-1;i++){
		int A_, B_;
		std::cin >> A_ >> B_;
		point[A_].v.emplace_back(B_);
		point[B_].root = false;
	}
	
	int rootnum;

	for(int i=0;i<N;i++){
		if(point[i].root){
			searched.emplace_back(i);
			res_point[i] = 0;
			rootnum = i;
			break;
		}
	}
	
	a(rootnum);
	
	for(int i=0;i<N;i++){
		std::cout << res_point[i] << std::endl;
	}
	
	return 0;
}

void a(int search_p){
	std::vector<int> search_next;
	
	for(auto v_ : point[search_p].v){
		auto itr = std::find(searched.begin(), searched.end(), v_);
		size_t index = std::distance(searched.begin(), itr);
		if(index == searched.size()){
			searched.emplace_back(v_);
			res_point[v_] = search_p;
			search_next.emplace_back(v_);
		}
	}
	
	for(auto sn : search_next){
		a(sn);
	}
	
	return;
}

Compiler output:
a.cc:15:26: error: 'N' was not declared in this scope
   15 | std::vector<Point> point(N);
      |                          ^
a.cc: In function 'int main()':
a.cc:43:9: error: 'a' was not declared in this scope
   43 |         a(rootnum);
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long signed int ll;
int n,m;
int a[100005],b[100005];
int toit[100005];
vector<vector<int>> node;

queue<int> check;
int parent[100005];
bool removed[100005];
bool isroot(int k){
    if(toit[k]<=0) return true;
    return false;
    
}

void bfs(int root){
    check.push(root);
    while(check.size()){
        int k=check.front(); check.pop();
        for(int i : node[k]){
            
                
                parent[b[i]]=k;
                a[i]=-1;
                b[i]=-1;
                toit[b[i]]--;
                if(isroot(b[i])){
                    check.push(b[i]);
                }
            }
        }
        
        
    }
    
}
int main(){
    cin>>n>>m;
    int root=1;
    
    for(int i=0;i<n+m-1;i++){
        cin>>a[i]>>b[i];
        toit[b[i]]++;
        node[a[i]].push_back(b[i]);
    }
    while(!isroot(root)){
        root++;
    }
    //cout<<root<<endl;
    bfs(root);
    for(int i=1;i<n+1;i++){
        cout<<parent[i]<<endl;
    }
    return 0;
}


Compiler output:
a.cc:38:1: error: expected declaration before '}' token
   38 | }
      | ^
Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
vvi E(100010);
ll par[100010];
map<pair<ll,ll>,ll>dist;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vi hoge(n+10);
  for(int i=0;i<n+m-1;i++){
    ll a,b;cin>>a>>b;
    E[a].pb(b);
    hoge[b]++;
  }
  for(int i=1;i<=n;i++){
    if(hoge[b]>0)continue;
    queue<pair<ll,ll>>que;
    que.push(mp(i,0));
    while(!que.empty()){
      pair<ll,ll>now=que.front();
      que.pop();
      for(int j=0;j<E[now.F].size();j++){
	if(par[E[now.F][j]]>0&&dist[mp(now.F,E[now.F][j])]<now.S+1){
	  par[E[now.F][j]]=now.F;
	  dist[mp(now.F,E[now.F][j])]=now.S+1;
	  que.push(mp(E[now.F][j],now.S+1));
	}else if(par[E[now.F][j]]==0){
	  par[E[now.F][j]]=now.F;
	  dist[mp(now.F,E[now.F][j])]=now.S+1;
	  que.push(mp(E[now.F][j],now.S+1));
	}
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<par[i]<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:13: error: 'b' was not declared in this scope
   39 |     if(hoge[b]>0)continue;
      |             ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

#define MAX 100000
int N, M;
vector<int> G[MAX];
vector<int> H[MAX];
int P[MAX];
int F[MAX];
void dfs(int u, int depth)
{
	depth++;
	for(auto v : G[u])
	{
		if (P[v] != -100)
		{
			if (F[v] < depth)
			{
				F[v] = depth;
				P[v] = u;
				dfs(v, depth);
			}
			else
			{
				continue;
			}

		}
		else
		{
			F[v] = depth;
			P[v] = u;
			dfs(v, depth);
		}

	}
	depth--;
}

void solve()
{
	cin >> N;
	cin >> M;


	for (int i = 0; i < N; i++)
	{
		P[i] = -100;
		F[i] = -100;
	}

	for (int i = 0; i < N + M - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;


		G[a].push_back(b);
		H[b].push_back(a);
	}

	for (int i = 0; i < N; i++)
	{
		if (H[i].size() == 0)
		{
			P[i] = -1;
			F[i] = 0;

			queue<int> A;
			A.push(i);
			queue<int> B;
			queue<int> C;
			//var B = new Queue<int>();
			B.push(-1);
			//var C = new Queue<int>();
			C.push(0);

			while (A.size())
			{
				int u = A.front();
				int p = B.front();
				int d = C.front();
				A.pop();
				B.pop();
				C.pop();

				if (F[u] != d)
				{
					continue;
				}

				for(auto v : G[u])
				{

					if (F[v] < F[u] + 1)
					{
						P[v] = u;
						F[v] = F[u] + 1;

						A.push(v);
						B.push(u);
						C.push(F[v]);
					}

				}
			}

			break;
		}
	}

	for (int i = 0; i < N; i++)
	{
		cout <<(P[i] + 1) << endl;
	}
}

	//int root = -1;
	//for (int i = 0; i < N; i++)
	//{
	//	if (H[i].size() == 0)
	//	{
	//		root = i;
	//	}
	//}

	//P[root] = -1;
	//F[root] = 0;
	//

	//dfs(root, 0);
	//for (int i = 0; i < N; i++)
	//{
	//	cout << (P[i] + 1) << endl;;
	//}
}

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

Compiler output:
a.cc:147:1: error: expected declaration before '}' token
  147 | }
      | ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

vector<int> G[100001];
vector<int> rG[100001];

void dfs(int a){
  bool f=false;
  for(int i=0;i<rG[a].size();i++){
    if(!used[rG[a][i]]){
      f=true;
      used[rG[a][i]]=1;
      dfs(rG[a][i]);
      used[rG[a][i]]=0;
    }
  }
  if(!f)x=a;
}

signed main(){
  int n,m;
  cin>>n>>m;
  int v=n+m-1;
  map<int> mp;
  for(int i=0;i<v;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    mp[b]++;
    G[a].push_back(b);
    rG[b].push_back(a);
  }

  int x;
  for(int i=0;i<n;i++)if(mp[i]==0){
    x=i;
    break;
  }

  vector<int> ans(v+1);
  ans[x]=-1;
  queue<int> q;
  q.push(x);
  vector<int> visited(v+1,0);
  visited[x]=1;
  while(!q.empty()){
    int np=q.front();
    q.pop();
    for(int i=0;i<G[np].size();i++){
      if(!visited[G[np][i]]){
        ans[G[np][i]]=np;
        q.push(G[np][i]);
      }
    }
  }
  for(int i=0;i<n;i++)cout<<ans[i]+1<<endl;
}


Compiler output:
a.cc: In function 'void dfs(long long int)':
a.cc:13:9: error: 'used' was not declared in this scope
   13 |     if(!used[rG[a][i]]){
      |         ^~~~
a.cc:20:9: error: 'x' was not declared in this scope
   20 |   if(!f)x=a;
      |         ^
a.cc: In function 'int main()':
a.cc:27:10: error: wrong number of template arguments (1, should be at least 2)
   27 |   map<int> mp;
      |          ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
  102 |     class map
      |           ^~~
a.cc:33:7: error: invalid types 'int[long long int]' for array subscript
   33 |     mp[b]++;
      |       ^
a.cc:39:28: error: invalid types 'int[long long int]' for array subscript
   39 |   for(int i=0;i<n;i++)if(mp[i]==0){
      |                            ^
Language: C++

#include<bits/qdc++.h>
#include<tuple>
using namespace qd;
#define ll long long
vector<int> edge[100001];
int par[100001]={};


int main(){
  int n, m;
  int a,b;
  cin >> n >> m;
  int h[100001] = {};
  for(int i=0;i<n+m-1;i++){
    cin >> a >> b;
    edge[a].push_back(b);
    h[b]++;
  }
  int root;
  for(int i=1;i<=n;i++){
    if(h[i] == 0) root = i;
  }

  queue<int> q;
  
  for(int i=0;i<edge[root].size();i++){
    h[edge[root][i]]--;
    if(h[edge[root][i]] == 0){
      q.push(edge[root][i]);
      par[edge[root][i]] = root;
    }
  }
  par[root] = 0;
  while(!q.empty()){
    int crr=q.front();q.pop();
    for(int i=0;i<edge[crr].size();i++){
      h[edge[crr][i]]--;
      if(h[edge[root][i]] == 0){
        q.push(edge[crr][i]);
        par[edge[crr][i]] = crr;
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout << par[i]<< endl;
  }
}

Compiler output:
a.cc:1:9: fatal error: bits/qdc++.h: No such file or directory
    1 | #include<bits/qdc++.h>
      |         ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long signed int ll;
int n,m;
int a[100005],b[100005];
ll sum=0;
queue<int> check;
int parent[100005];
bool removed[100005];
bool isnotroot[100005];

void bfs(int root){
    check.push(root);
    while(check.size()){
        int k=check.front(); check.pop();
        for(int i=0;i<n+m-1;i++){
            if(a[i]==k){
                
                parent[b[i]]=k;
                a[i]=-1;
                
                if(isroot(b[i])){
                    check.push(b[i]);
                }else{
                    cout<<b[i]<<"is not root"<<endl;
                }
            }
        }
        
        
    }
    
}
int main(){
    cin>>n>>m;
    int root=1;
    
    for(int i=0;i<n+m-1;i++){
        cin>>a[i]>>b[i];
        isnotroot[b[i]]=true;
    }
    while(isnotroot[root]){
        root++;
    }
    cout<<root<<endl;
    bfs(root);
    for(int i=1;i<n+1;i++){
        cout<<parent[i]<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:22:20: error: 'isroot' was not declared in this scope; did you mean 'root'?
   22 |                 if(isroot(b[i])){
      |                    ^~~~~~
      |                    root
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

void swap(std::vector<int>& vec, int a, int b) {
  auto temp = vec[a];
  vec[a] = vec[b];
  vec[b] = temp;
}


class Connection
{
public:
  Connection(int n) {
    this->matrix.resize(n);
    for (int i=0; i<n; i++) {
      this->matrix[i].resize(n, 0);
    }
    
    this->n = n;
  }
  
  void addConnection(int a, int b) {
    this->matrix[a][b] = 1;
    this->matrix[b][a] = -1;
  }
  
  void shrinkLink(int a) {
    std::vector<int> parents;
    for (int i=0; this->n; i++) {
      if (this->matrix[a][i] == -1) {
        parents.push_back(i);
      }
    }
    
    if (parents.size() <= 1) {
      return;
    }
    
    if (parents.size() == 2) {
      // :(
    }
  }
  
  int parentIdx(int a) {
    std::vector<int> parents;
    for (int i=0; this->n; i++) {
      if (this->matrix[a][i] == -1) {
        parents.push_back(i);
      }
    }
    
    if (parents.size() == 0) {
      return -1;
    }
    
    return paretns[i];
  }

private:
  std::vector<std::vector<int>> matrix;
  int n;
}


int main(void)
{
  using namespace std;

  int N, M;
  vector<vector<int8_t>> m;

  std::cin >> N >> M;
  
  Connection c(N);

  for (int i=0; i<N-1+M; i++) {
    int a, b;
    std::cin >> a >> b;
    
    c.addConnection(a-1,b-1);
  }
  
  for (int i=0; i<N; i++) {
    c.shrinkLink(i);
  }
  
  for (int i=0; i<N; i++) {
    std::cout << c.parentIdx(i) + 1 << std::endl;
  }

  return 0;
}


Compiler output:
a.cc:65:2: error: expected ';' after class definition
   65 | }
      |  ^
      |  ;
a.cc: In member function 'int Connection::parentIdx(int)':
a.cc:59:12: error: 'paretns' was not declared in this scope; did you mean 'parents'?
   59 |     return paretns[i];
      |            ^~~~~~~
      |            parents
a.cc:59:20: error: 'i' was not declared in this scope
   59 |     return paretns[i];
      |                    ^
Language: C++

#include <iostream>
#include <algorithm>
#include <atomic>
#include <thread>
#include <mutex>
#include <string>
#include <string.h>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n, m, a, b, d[100010],e[100010];
vector<int> in[100010], out[100010];
set<P> st;
void dfs(int s, int kyori,int mae) {
	d[s] = kyori;
	e[s] = mae;
	for (int i : out[s]) {
		if (d[i] == INF)dfs(i, kyori + 1, s);
		else {
			st.insert({ e[i],i });
		}
	}
}
signed main() {
	cin >> n >> m;
	rep(i, n - 1 + m) {
		cin >> a >> b;
		out[a].push_back(b);
		in[b].push_back(a);
	}
	int ne;
	rep(i, n) {
		if (in[i + 1].empty())ne = i + 1;
	}
	fill(d, d + n + 1, INF);
	dfs(ne, 0, 0);
	for (int i = 1; i <= n; i++) {
		for (int j : in[i]) {
			if (st.find({ j,i }) == st.end())cout << j << endl;
		}
		if (i == ne)cout << 0 << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(long long int, long long int, long long int)':
a.cc:22:13: error: 'LLONG_MAX' was not declared in this scope
   22 | #define INF LLONG_MAX/3
      |             ^~~~~~~~~
a.cc:33:29: note: in expansion of macro 'INF'
   33 |                 if (d[i] == INF)dfs(i, kyori + 1, s);
      |                             ^~~
a.cc:17:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   16 | #include <unordered_set>
  +++ |+#include <climits>
   17 | #define rep(i,n) for(int i=0;i<n;i++)
a.cc: In function 'int main()':
a.cc:22:13: error: 'LLONG_MAX' was not declared in this scope
   22 | #define INF LLONG_MAX/3
      |             ^~~~~~~~~
a.cc:50:28: note: in expansion of macro 'INF'
   50 |         fill(d, d + n + 1, INF);
      |                            ^~~
a.cc:22:13: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   22 | #define INF LLONG_MAX/3
      |             ^~~~~~~~~
a.cc:50:28: note: in expansion of macro 'INF'
   50 |         fill(d, d + n + 1, INF);
      |                            ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_V = (int)1e5 + 5;
const int MAX_E = (int)1e5 + 5;

vector<int> G[MAX_V];
bool used[MAX_V];
int parent[MAX_V];
int maxDepth;
int candV;
vector<int> g[MAX_V];


void dfs0(int curr, int prev, int depth){
	used[curr] |= true;
	if (depth > maxDepth){
		candV = curr;
		maxDepth = depth;
	} // end if
	rep (i, (int)G[curr].size()){
		int next = G[curr][i];
		dfs0 (next, curr, depth + 1);
	} // end rep
}	

void dfs(int curr, int prev, int depth){
	used[curr] |= true;
	int cnt = 0;

	if (depth > maxDepth){
		candV = curr;
		maxDepth = depth;
	} // end if

	rep (i, (int)G[curr].size()){
		int next = G[curr][i];
		if (prev != -1){
			if (!used[next] && cnt == 0){
				dfs(next, curr, depth + 1);
				g[curr].push_back(next);
				g[next].push_back(curr);
				++cnt;
			} // end if
		}else{
			if (!used[next] && cnt <= 1){
				dfs(next, curr, depth + 1);
				g[curr].push_back(next);
				g[next].push_back(curr);
				++cnt;
			} // end if
		} // end if
	} // end rep
}

void dfs2(int curr, int prev){
	parent[curr] = prev;
	used[curr] |= true;
	int cnt = 0;
	rep (i, (int)g[curr].size()){
		int next = g[curr][i];
		if (!used[next] && cnt == 0){
			dfs2(next, curr);
			++cnt;
		} // end if
	} // end rep
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M; cin >> N >> M;
	rep (i, N) G[i].clear(), g[i].clear();
	vector<int> A(N - 1 + M, 0), B(N - 1 + M, 0);
	rep (i, N - 1 + M){
		cin >> A[i] >> B[i];
		--A[i], --B[i];
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	} // end rep

	maxDepth = 0;
	candV = -1;
	memset(used, false, sizeof(used));
	dfs0(0,-1,0);

	memset(used, false, sizeof(used));
	dfs(candV, -1);	

//	cerr << "candV: " << candV << endl;

	memset(parent, -1, sizeof(parent));
	memset(used, false, sizeof(used));
	dfs2(candV, -1);

	rep (i, N){
		cout << parent[i] + 1 << endl;
	} // end rep

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:95:12: error: too few arguments to function 'void dfs(int, int, int)'
   95 |         dfs(candV, -1);
      |         ~~~^~~~~~~~~~~
a.cc:33:6: note: declared here
   33 | void dfs(int curr, int prev, int depth){
      |      ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = int;

// 頂点数、変数
int v, e;
const int MAX_N = 100100;
// 隣接リスト
vector<int> g[MAX_N];
bool used[MAX_N];
// トポロジカルソートされた数列
vector<int> ans;

void dfs(int u) {
  if(used[u]) return;
  used[u] = true;
  for(auto& i: g[u]) dfs(i);
  // 帰りがけ順で追加
  ans.push_back(u);
}

int num[MAX_N];
bool used2[MAX_N];
int cou;

void dfs2(int v,int depth,int p) {
  used2[v] = true;


  rep(i,(int)g[v].size() ){
    int vnext = g[v][i];
    if (!used[vnext] ) {
      dfs2(vnext,depth+1,v);
    }
  }
  num[v] = cou;
  cou++;
}

void tsort() {
  for(int i=0; i<v; ++i) dfs(i);
  reverse(ans.begin(), ans.end());
}

int par[MAX_N];
vector<int> diff[MAX_N];

signed main(void)
{
  ll n,m;
  cin >> n>> m;

  v = n;
  e = n + m - 1;
  for(int i=0; i<e; ++i) {
    int s, t;
    cin >> s >> t;
    s--;t--;
    g[s].push_back(t);
    diff[s].push_back(1000000000);
  }

  tsort();
  dfs2(ans[0],1,-1);

  par[ans[0]] = -1;

  rep(i,v){
    rep(j,(int)g[i].size()) {
      if (diff[i][j] > num[G[i][j]] - num[i]){
        diff[i][j] = num[G[i][j]] - num[i];
        par[i] = g[i][j];
      }
    }
  }

  rep(i,n){
    cout << par[i] + 1 << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:28: error: 'G' was not declared in this scope
   71 |       if (diff[i][j] > num[G[i][j]] - num[i]){
      |                            ^