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

#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll n,m;
    cin >> n >>m;
    vector < set<ll> >v1(n);
    vector < vector<ll> >v2(n);
    queue<ll> q;
    ll ans[n];
    ll tmpsize[n];
    ll tmp;
    ll a,b;
    ll i;
    for(i=0;i<n+m-1;i++){
      cin >> a >> b;
      v1[b-1].insert(a);
      v2[a-1].push_back(b);
    }
    for(i=0;i<n+m-1;i++){
      tmpsize[i]=v[i].size()
      if(tmpsize[i]==0){
        q.push(i)
        ans[i]=0;
      }
    }
    while(q.size!=0){
      tmp=q.pop();
      for(i=0;i<v2(tmp-1).size();i++){
        tmpsize[i]--;
        if(tmpsize[i]==1){
          q.push(i);
          ans[i]=~tmp;
        }
      }
    }
    for(i=0;i<n;i++){
      cout << ans[i];
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: 'set' was not declared in this scope
   14 |     vector < set<ll> >v1(n);
      |              ^~~
a.cc:9:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    8 | #include<map>
  +++ |+#include <set>
    9 | using namespace std;
a.cc:14:20: error: template argument 1 is invalid
   14 |     vector < set<ll> >v1(n);
      |                    ^
a.cc:14:20: error: template argument 2 is invalid
a.cc:14:22: error: expected unqualified-id before '>' token
   14 |     vector < set<ll> >v1(n);
      |                      ^
a.cc:24:7: error: 'v1' was not declared in this scope; did you mean '__pstl::execution::v1'?
   24 |       v1[b-1].insert(a);
      |       ^~
      |       __pstl::execution::v1
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from a.cc:5:
/usr/include/c++/14/pstl/execution_defs.h:19:18: note: '__pstl::execution::v1' declared here
   19 | inline namespace v1
      |                  ^~
a.cc:28:18: error: 'v' was not declared in this scope
   28 |       tmpsize[i]=v[i].size()
      |                  ^
a.cc:34:13: error: invalid use of member function 'std::queue<_Tp, _Sequence>::size_type std::queue<_Tp, _Sequence>::size() const [with _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >; size_type = long unsigned int]' (did you forget the '()' ?)
   34 |     while(q.size!=0){
      |           ~~^~~~
      |                 ()
a.cc:35:16: error: void value not ignored as it ought to be
   35 |       tmp=q.pop();
      |           ~~~~~^~
a.cc:36:19: error: no match for call to '(std::vector<std::vector<long long int> >) (long long int)'
   36 |       for(i=0;i<v2(tmp-1).size();i++){
      |                 ~~^~~~~~~
Language: C++

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] ne = new boolean[n];
        Arrays.fill(ne, true);
        ArrayList<Integer>[] g = new ArrayList[n];
        for(int i=0; i<n; i++){
            g[i] = new ArrayList<Integer>();
        }
        for(int i=0; i<n+m-1; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            ne[b] = false;
            g[a].add(b);
        }
        
        int root = -1;
        for(int i=0; i<n; i++){
            if(ne[i]){
                root = i;
                break;
            }
        }
        
        int[] dist = new int[n];
        Arrays.fill(dist, (int)1e9);
        dist[root] = 0;
        
        ArrayDeque<Integer> q = new ArrayDeque<Integer>();
        q.add(root);
        while(q.size()!=0){
            int now = q.pollFirst();
            
            for(int j=0; j<g[now].size(); j++){
                int next = g[now].get(j);
                dist[next] = dist[now]+1;
                q.add(next);
            }
        }
        
        int[] ans = new int[n];
        for(int i=0; i<n; i++){
            for(int j=0; j<g[i].size(); j++){
                int next = g[i].get(j);
                if(dist[i]+1 == dist[next]){
                    ans[next] = i+1;
                }
            }
        }
        
        for(int i=0; i<n; i++){
            System.out.println(ans[i]);
        }
        
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main{
      | ^~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
vector<int> g[100005];
bool used[100005];
int par[100005];

void GetPar(int k)
{
	for (int i = 0;i < g[k].size();i++) {
		int temp = g[k][i];
		par[temp] = k;
		GetPar(temp);
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 0;i < n - 1 + m;i++) {
		int u, v;
		scanf_s("%d%d", &u, &v);
		g[u].push_back(v);
		used[v] = 1;
	}

	int root = 0;
	for (int i = 1;i <= n;i++) {
		if (used[i] == 0) {
			root = i;
			break;
		}
	}
	par[root] = 0;
	GetPar(root);

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

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   45 |                 scanf_s("%d%d", &u, &v);
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

#include "Graph.h"
#include "ShortPath.h"

int N, M;
vector<int> A, B;

int main() {
	cin >> N >> M;
	for (int i = 0; i < N - 1 + M; i++) {
		int tmpa, tmpb;
		cin >> tmpa >> tmpb;
		A.push_back(tmpa);
		B.push_back(tmpb);
	}
	unordered_set<int> us;
	for (int i = 1; i <= N; i++)
	{
		us.insert(i);
	}
	for (const int b : B) {
		us.erase(b);
	}
	const int root = *us.begin();

	Graph g(N + 1);
	for (int i = 0; i < N - 1 + M; i++)
	{
		g.add_edge(A[i], B[i], -1);
	}
	vector<Weight> distance = bellman_ford(g, root, 9999);
	Graph originalg(N + 1);
	for (const auto e : g.edges)
	{
		if (distance[e->p_src->id] - distance[e->p_dst->id] == 1) {
			originalg.add_edge(e->p_dst->id, e->p_src->id, 0);
		}
	}
	for (int i = 1; i <= N; i++)
	{
		if (i == root) {
			cout << 0;
		}
		else {
			cout << (*(originalg.vertices[i]->edges.begin()))->p_dst->id;
		}
		cout << endl;
	}
	return 0;
}


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

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
vector<int> g[100005];
bool used[100005];
int par[100005];

int main()
{
	cin >> n >> m;
	for (int i = 0;i < n - 1 + m;i++) {
		int u, v;
		scanf_s("%d%d", &u, &v);
		g[u].push_back(v);
		used[v] = 1;
	}

	int root = 0;
	for (int i = 1;i <= n;i++) {
		if (used[i] == 0) {
			root = i;
			break;
		}
	}
	par[root] = 0;
	queue<int> q;
	q.push(root);

	while (!q.empty()) {
		int cur = q.front();q.pop();

		for (int i = 0;i < g[cur].size();i++) {
			int succ = g[cur][i];
			par[succ] = cur;	
			q.push(succ);
		}
	}

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

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   36 |                 scanf_s("%d%d", &u, &v);
      |                 ^~~~~~~
      |                 scanf
Language: C++

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

const int MAX_N = 1e+5 + 5;

int N, M;
vector<int> g[MAX_N];
bool is_used[MAX_N], is_ok[MAX_N];
vector<int> ans;
int parent[MAX_N];

void dfs(int u) {
    if (is_used[u]) return;
    is_used[u] = true;
    for (int i = 0; i < g[u].size(); i++) {
        dfs(g[u][i]);
    }
    ans.push_back(u);
}

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

int main() {
    int A, B;
    cin >> N >> M;
    for (int i = 0; i < N + M - 1; i++) {
        cin >> A >> B;
        A--, B--;
        g[A].push_back(B);
    }
    tsort();
    reverse(ans.begin(), ans.end());
    map<int, bool> MP;
    for (int i = 0; i < ans.size(); i++) {
        MP[ans[i]] = true;
        for (int j = 0; j < g[ans[i]].size(); j++) {
            int now_u = g[ans[i]][j];
            if (MP[now_u] && !is_ok[now_u]) {
                parent[now_u] = ans[i];
                is_ok[now_u] = true;
            }
        }
    }
    parent[ans[ans.size() - 1]] = -1;
    for (int i = 0; i < N; i++) {
        cout << parent[i] + 1 << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'void tsort()':
a.cc:25:5: error: 'reverse' was not declared in this scope
   25 |     reverse(ans.begin(), ans.end());
      |     ^~~~~~~
a.cc: In function 'int main()':
a.cc:37:5: error: 'reverse' was not declared in this scope
   37 |     reverse(ans.begin(), ans.end());
      |     ^~~~~~~
Language: C++

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

const int N = 1e5 + 7;
int visit[N], P[N], in[N], d[N];

vector <int> adj[N];

int dfs(int u, int p, int x) {

        if(d[u] < x) {
                d[u] = x;
                P[u] = p;
        }else return 0;
        for(int v: adj[u]) if(v != p) dfs(v, u);
}

int main() {
        int n, m; cin >> n >> m;
        for(int i = 1; i <= n + m - 1; i++) {
                int u, v; cin >> u >> v;
                adj[u].push_back(v);
                in[v]++;
        }
        for(int i = 1; i <= n; i++) if(!in[i]) dfs(i, 0);

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


Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:15:42: error: too few arguments to function 'int dfs(int, int, int)'
   15 |         for(int v: adj[u]) if(v != p) dfs(v, u);
      |                                       ~~~^~~~~~
a.cc:9:5: note: declared here
    9 | int dfs(int u, int p, int x) {
      |     ^~~
a.cc: In function 'int main()':
a.cc:25:51: error: too few arguments to function 'int dfs(int, int, int)'
   25 |         for(int i = 1; i <= n; i++) if(!in[i]) dfs(i, 0);
      |                                                ~~~^~~~~~
a.cc:9:5: note: declared here
    9 | int dfs(int u, int p, int x) {
      |     ^~~
a.cc: In function 'int dfs(int, int, int)':
a.cc:16:1: warning: control reaches end of non-void function [-Wreturn-type]
   16 | }
      | ^
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);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>>n>>m;
  for(int i=0;i<n+m-1;i++){
    ll a,b;cin>>a>>b;
    E[a].pb(b);
  }
  cout<<0<<endl;
  cout<<1<<endl;
  cout<<1<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:15: error: expected primary-expression before '>' token
   29 |   ll n,m;cin>>>n>>m;
      |               ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
vector<int> g[100005];
bool used[100005];
int par[100005];

int main()
{
	cin >> n >> m;
	for (int i = 0;i < n - 1 + m;i++) {
		int u, v;
		scanf_s("%d%d", &u, &v);
		g[u].push_back(v);
		used[v] = 1;
	}

	int root = 0;
	for (int i = 1;i <= n;i++) {
		if (used[i] == 0) {
			root = i;
			break;
		}
	}
	par[root] = 0;
	queue<int> q;
	q.push(root);
	memset(used, 0, sizeof used);
	used[root] = 1;

	while (!q.empty()) {
		int cur = q.front();q.pop();

		for (int i = 0;i < g[cur].size();i++) {
			int succ = g[cur][i];
			if (used[succ] == 0) {
				q.push(succ);
				used[succ] == 1;
				par[succ] = cur;
			}
		}

	}

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

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   36 |                 scanf_s("%d%d", &u, &v);
      |                 ^~~~~~~
      |                 scanf
Language: C

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

struct edge_t {
    int from;
    int to;
};
struct node_t {
    int parent;
    int depth;
    node_t():parent(-2),depth(-1){
    }
};

node_t parentFind(
    int i,
    int n,
    vector<vector<edge_t> > &abs,
    vector<node_t> &node
    ){
  if (node[i].parent!=-2) {
      return node[i];
  }
  if (abs[i].size()==0){
      node[i].parent = -1;
      node[i].depth = 0;
      return node[i];
  }
  vector<edge_t> &es(abs[i]);
  int m = es.size();
  for (int j=0;j<m;j++) {
    node_t p = parentFind(es[j].from,n,abs,node);
    if (node[i].depth < p.depth + 1) {
        node[i].depth = p.depth + 1;
        node[i].parent = es[j].from;
    }
  }
  return node[i];
}

int main() {
  int n, m, t;

  while (cin>>n>>m) {
    t = n - 1 + m;
    vector<vector<edge_t> > abs(n);
    vector<node_t> node(n);
    edge_t e;
    for (int i=0;i<t;i++) {
      cin >> e.from >> e.to;
      e.from--;
      e.to--;
      abs[e.to].push_back(e);
    }
    for (int i=0;i<n;i++) {
      cout << parentFind(i,n,abs,node).parent+1 << endl;
    }
  }
  return 0;
}


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

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n, m;
std::vector<int> edge[100005];
std::set<int> parent[100005];
int ans[100005];

void bfs(int rt){
	std::queue<int> que;
	que.push(rt);
	while(!que.empty()){
		int vis = que.front();
		que.pop();
		for(int i = 0; i < edge[vis].size(); i++){
			int next = edge[vis][i];
			if(parent[next].size() > 1){
				parent[next].erase(vis);
			}else{
				ans[next] = vis;
				que.push(next);
			}
		}
	}
	return;
}

signed main(){
	scanf("%ld %ld", &n, &m);
	for(int i = 0; i < n+m-1; i++){
		int a, b;
		scanf("%ld %ld", &a, &b);
		edge[a].push_back(b);
		parent[b].push(a);
	}
	for(int i = 1; i <= n; i++){
		if(parentcnt[i] == 0){
			bfs(i);
			break;
		}
	}
	for(int i = 1; i <= n; i++){
		printf("%ld\n", ans[i]);
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:27: error: 'class std::set<long int>' has no member named 'push'
   55 |                 parent[b].push(a);
      |                           ^~~~
a.cc:58:20: error: 'parentcnt' was not declared in this scope; did you mean 'parent'?
   58 |                 if(parentcnt[i] == 0){
      |                    ^~~~~~~~~
      |                    parent
Language: C++

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

vector<int> parent;
vector< vector<int> > child;
vector<int> rank;
void search(int root,int cur){
  for(int i = 0;i < child[root].size();i++){
    if(rank[child[root][i]] < cur+1){
      rank[child[root][i]] = cur+1;
      parent[child[root][i]] = root;
    }
    search(child[root][i],cur+1);
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  parent = vector<int>(n,-1);
  child = vector< vector<int> >(n);
  rank = vector<int>(n);
  for(int i = 0;i < n-1+m;i++){
    int u,v;
    cin >> u >> v;
    parent[v-1] = u-1;
    child[u-1].push_back(v-1);
  }
  int root;
  for(int i = 0;i < n;i++){
    if(parent[i] == -1){
      root = i;
      break;
    }
  }
  search(root,0);
  for(int i = 0;i < n;i++){
    cout << parent[i]+1 << " ";
  }
  cout << endl;
}


Compiler output:
a.cc: In function 'void search(int, int)':
a.cc:9:8: error: reference to 'rank' is ambiguous
    9 |     if(rank[child[root][i]] < cur+1){
      |        ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:6:13: note:                 'std::vector<int> rank'
    6 | vector<int> rank;
      |             ^~~~
a.cc:10:7: error: reference to 'rank' is ambiguous
   10 |       rank[child[root][i]] = cur+1;
      |       ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:6:13: note:                 'std::vector<int> rank'
    6 | vector<int> rank;
      |             ^~~~
a.cc: In function 'int main()':
a.cc:22:3: error: reference to 'rank' is ambiguous
   22 |   rank = vector<int>(n);
      |   ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:6:13: note:                 'std::vector<int> rank'
    6 | vector<int> rank;
      |             ^~~~
Language: C++

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    m += n - 1;
    vector< vector<int> > G(n);
    map< pair<int, int>, bool> jest;
    vector<int> st_we(n, 0);
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        ++st_we[b];
        jest[make_pair(a, b)] = true;
    }
    int root = 0;
    for (int i = 0; i < n; ++i)
        if (st_we[i] == 0)
            root = i
    stack<int> S;
    S.push(root);
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < G[akt].size(); ++i)
        {
            if (st_we[G[akt][i]] >= 2)
            {
                --st_we[G[akt][i]];
                jest[make_pair(akt, G[akt][i])] = false;
            }
            else
                S.push(G[akt][i]);
        }
    }
    vector<int> oj(n);
    oj[root] = -1;
    S.push(root);
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < G[akt].size(); ++i)
        {
            if (jest[make_pair(akt, G[akt][i])])
            {
                S.push(G[akt][i]);
                oj[G[akt][i]] = akt;
            }
        }
    }
    for (int i = 0; i < n; ++i)
        cout << oj[i] + 1 << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:21: error: expected ';' before 'stack'
   30 |             root = i
      |                     ^
      |                     ;
   31 |     stack<int> S;
      |     ~~~~~            
a.cc:32:5: error: 'S' was not declared in this scope
   32 |     S.push(root);
      |     ^
Language: C++

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

int n,m,deg[100010],a[100010];
vector<int> v[100010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n+m-1;i++){
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		g[y].push_back(x);
		deg[y]++;
	}
	int root=-1;
	for(int i=1;i<=n;i++) if(deg[i]==0){
		root=i;
		break;
	}
	queue<int> q;
	q.push(root);
	while(!q.empty())
	{
		int t=q.front();
		q.pop();
		for(int i=0;i<v[t].size();i++){
			int pos=v[t][i];
			deg[pos]--;
			if(deg[pos]==0){
				a[pos]=t;
				q.push(pos);
			}
		}
	}
	for(int i=1;i<=n;i++) cout<<a[i]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:17: error: 'g' was not declared in this scope
   16 |                 g[y].push_back(x);
      |                 ^
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
#include <cstdarg>
#include <sstream>
#include <functional>
using namespace std;

int const MAX_N = 100 * 1002;

vector<int> e[MAX_N];
bitset<MAX_N> bts[MAX_N];
int in_deg[MAX_N], ans[MAX_N], nnew[MAX_N];

bitset<MAX_N> sibl[MAX_N];
int flag[MAX_N];
void dfs_sibl(int v) {
	flag[v] = 1;
	sibl[v].set(v, 1);
	for (int i = 0; i < (int)e[v].size(); i++)
		if (!flag[e[v][i]]) {
			dfs_sibl(e[v][i]);
			sibl[v] |= sibl[e[v][i]];
		}
}


void dfs(int v) {
	nnew[v] = 1;
	for (int i = 0; i < (int)e[v].size(); i++)
		if (!nnew[e[v][i]])
			if ((sibl[v] & bts[e[v][i]]).count() == 0) {
				ans[e[v][i]] = v;
				dfs(e[v][i]);
			}
}


int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n - 1 + m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		e[a].push_back(b);
		in_deg[b]++;
		bts[b].set(a, 1);
	}

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

	ans[root] = -1;

	dfs_sibl(root);
	for (int i = 0; i < n; i++) sibl[i].set(i, 0);

	dfs(root);

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


Compiler output:
/tmp/cc5AuAxa.o: in function `dfs_sibl(int)':
a.cc:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc5AuAxa.o
collect2: error: ld returned 1 exit status
Language: C++

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

vector<int>X[100009], Y[100009], G;
int N, M, A[100009], B[100009], deg[100009], topo[100009]; bool used[100009];

void dfs(int pos) {
	used[pos] = true;
	for (int i = 0; i < X[pos].size(); i++) {
		if (used[X[pos][i]] == true) continue;
		dfs(X[pos][i]);
	}
	G.push_back(pos);
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N + M - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]); deg[B[i]]++;
		Y[B[i]].push_back(A[i]);
	}

	int root = 0;
	for (int i = 1; i <= N; i++) { if (deg[i] == 0) root = i; }

	dfs(root);
	reverse(G.begin(), G.end());
	for (int i = 0; i < G.size(); i++) { topo[G[i]] = i; }

	for (int i = 1; i <= N; i++) {
		pair<int, int>maxn = make_pair(-1, -1);
		for (int j = 0; j < Y[i].size(); j++) {
			if (maxn.first < topo[Y[i][j]]) maxn = make_pair(topo[Y[i][j]], Y[i][j]);
		}
		if (maxn == make_pair(-1, -1)) cout << "0" << endl;
		else cout << maxn.second << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'reverse' was not declared in this scope
   29 |         reverse(G.begin(), G.end());
      |         ^~~~~~~
Language: C++

#include <cstdio>
#include <cstring>
#include <set>

using namespace std;

int edge[300000],next[300000],first[300000];
int d[300000],e[300000],g[300000];
int i,m,n,x,y,head,tail,sum_edge;

inline void addedge(int x,int y)
{
	sum_edge++,edge[sum_edge]=y,next[sum_edge]=first[x],first[x]=sum_edge;
	return;
}

int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<n+m;i++)
		scanf("%d%d",&x,&y),addedge(x,y),d[y]++;
	for (i=1;i<=n;i++)
		if (! d[i])
			tail++,g[tail]=i;
	for (head=1;head<=tail;head++)
	{
		for (i=first[g[head]];i!=0;i=next[i])
		{
			d[edge[i]]--;
			if (! d[edge[i]])
				tail++,g[tail]=edge[i],e[g[tail]]=g[head];
		}
	}
	for (i=1;i<=n;i++)
		printf("%d\n",e[i]);
	return 0;
}

Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:13:37: error: reference to 'next' is ambiguous
   13 |         sum_edge++,edge[sum_edge]=y,next[sum_edge]=first[x],first[x]=sum_edge;
      |                                     ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/bits/stl_tree.h:63,
                 from /usr/include/c++/14/set:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:7:18: note:                 'int next [300000]'
    7 | int edge[300000],next[300000],first[300000];
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:27:46: error: reference to 'next' is ambiguous
   27 |                 for (i=first[g[head]];i!=0;i=next[i])
      |                                              ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:7:18: note:                 'int next [300000]'
    7 | int edge[300000],next[300000],first[300000];
      |                  ^~~~
Language: C++

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

struct Unionfind {
  // tree number
  vector<int> par;
  // constructor
  Unionfind(int n = 1) : par(n, -1) {}
  // search root
  int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }

  // add
  // already added, return 0
  int uni(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return x;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return x;
  }
  int size(int x) { return -par[root(x)]; }
};

struct edge {
  int x, y;
  long long c;
  bool operator<(const edge& r) {
    if (c != r.c) return c < r.c;
    if (x != r.x) return x < r.x;
    return y < r.y;
  }
};

long long n, m;
vector<edge> edges;
vector<long long> a, sum;
vector<vector<long long>> v;
Unionfind tmp, uf;

long long solve();

int main() {
  cin >> n >> m;
  a.resize(n);
  for (auto& p : a) cin >> p;
  edges.resize(m);
  for (int i = 0; i < m; ++i) {
    cin >> edges[i].x >> edges[i].y >> edges[i].c;
    --edges[i].x, --edges[i].y;
  }
  sort(edges.begin(), edges.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  uf = Unionfind(n);
  tmp = Unionfind(n);
  v.resize(n);
  sum = a;
  for (int i = 0; i < n; ++i) memo[i] = i;
  for (int i = 0; i < m; ++i)
    if (!tmp.issame(edges[i].x, edges[i].y)) {
      int x = tmp.root(edges[i].x), y = tmp.root(edges[i].y), r;
      v[x].push_back(i);
      if (v[y].size() > v[x].size()) swap(x, y);
      while (v[y].size()) {
        v[x].push_back(v[y].back());
        v[y].pop_back();
      }
      r = tmp.uni(x, y);
      sum[r] = sum[x] + sum[y];
      if (sum[r] >= edges[i].c)
        while (v[x].size()) {
          int id = v[x].back();
          uf.uni(edges[id].x, edges[id].y);
          v[x].pop_back();
        }
    }
  sum.assign(n, 0);
  for (int i = 0; i < n; ++i) sum[uf.root(i)] += a[i];
  long long res = m;
  for (int i = 0; i < m; ++i)
    if (uf.issame(edges[i].x, edges[i].y) &&
        sum[uf.root(edges[i].x)] >= edges[i].c)
      --res;
  return res;
}


Compiler output:
a.cc: In function 'long long int solve()':
a.cc:68:31: error: 'memo' was not declared in this scope
   68 |   for (int i = 0; i < n; ++i) memo[i] = i;
      |                               ^~~~
Language: C++

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

struct edge{
    ll u, v, w;
};

struct xzkaknazvat{
    ll cost, black;
};

bool operator < (edge a, edge b){
    return a.w < b.w;
}

ll n,m;
vector<ll> a;
vector<edge> g;
vector<ll> p;
vector<ll> sz;
vector<xzkaknazvat> d;

ll get_sqrt(ll v){
    if(p[v] == v){
        return v;
    }
    ll x = get_sqrt(p[v]);
    p[v] = x;
    return x;
}


bool check(int u, int v){
    return get_sqrt(u) == get_sqrt(v);
}

void unio(int u, int v, int typreb){
    if(check(u,v)){
        return;
    }
    if(sz[v] > sz[u]){
        swap(sz[v],sz[u]);
    }
    if(sz[v] == sz[u]){
        sz[u]++;
    }
    d[u].cost += d[v].cost;
    d[u].black += d[v].black;
    d[u].black*=typreb;
    d[u].black+=typreb;
    p[v] = u;
}


main(){
    cin >> n >> m;

    p.resize(n+1);
    for(int i=0;i<=n;++i){
        p[i] = i;
    }
    sz.assign(n+1, 1);
    a.resize(n+1);
    for(int i=1;i<=n;++i){
        cin >> a[i];
    }

    d.resize(n+1);
    for(int i=1;i<=n;++i){
        d[i] = {a[i], 0};
    }

    g.resize(m+1);
    ll f1,f2,f3;
    for(int i=0;i<m;++i){
        cin >> f1 >> f2 >> f3;
        g[i] = {f1,f2,f3};
    }
    sort(g.begin(),g.end());


    for(int i=0;i<m;++i){
        int u= get_sqrt(g[i].u);
        int v= get_sqrt(g[i].v);
        if(u == v){
            return;
        }
        if(sz[u] + sz[v] >= g[i].w){
            unio(u,v,0);
        }
        else{
            unio(u,v,1);
        }
    }

    cout << d[get_sqrt(1)].black;

}


Compiler output:
a.cc:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:87:13: error: return-statement with no value, in function returning 'int' [-fpermissive]
   87 |             return;
      |             ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};




int main(){

  int n,m;
  cin >> n >> m;
  ll x[n];
  rep(i,n) cin >> x[i];
  ll a[m],b[m],y[m];
  rep(i,m){
    cin >> a[i] >> b[i] >> y[i];
    a[i]--;b[i]--;
  }
  bool need[m];
  rep(i,m) need[i]=true;
  bool update = true;
  while(update){
    update=false;
    UnionFind uf(n);
    rep(i,m){
      if(need[i]) uf.unite(a[i],b[i]);        
    }
    ll weight[n];
    rep(i,n) weight[i]=0;
    rep(i,n){
      weight[uf.find(i)]+=x[i];
    }
    rep(i,m){
      if(need[i]){
	if(weight[uf.find(a[i])]<y[i]){
	  ka++;
	  need[i]=false;
	  update=true;
	}
      }
    }
  }
  int ans=0;
  rep(i,m) if(!need[i]) ans++;
  cout << ans << endl;
  return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:11: error: 'ka' was not declared in this scope; did you mean 'a'?
   66 |           ka++;
      |           ^~
      |           a
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;
const int MAXN = 1e5 + 7;
#define i64 long long
struct edge {
	int A, B;
	i64 Y;
}ed[MAXN];

int N, M;
i64 X[MAXN];
int qan[MAXN];
int qanprev[MAXN];
int p[MAXN];
int zib;

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


void merge(int x, int y)
{
	x = find(x);
	y = find(y);
	p[x] = y;
	qan[y] += qan[x];
	qanprev[y] += qanprev[x];
	X[y] += X[x];
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> X[i];
		qan[i] = 1;
		p[i] = i;
	}
	for (int i = 0; i <= M; i++) {
		cin >> ed[i].A >> ed[i].B >> ed[i].Y;
	}
	sort(ed, ed + M, [&](edge &a, edge&b) {return a.Y < b.Y; });
	for (int i = 0; i <= M; i++) {
		int firp = find(ed[i].A);
		int secp = find(ed[i].B);
		if (firp != secp) {
			merge(ed[i].A, ed[i].B);
			if (ed[i].Y <= X[firp]) {
				zib -= qanprev[firp];
				qanprev[firp] = qan[firp];
				zib += qanprev[firp];
			}
		}
		else {
			int frip = find(ed[i].A);
			++qan[frip];
			if (ed[i].Y <= X[frip]) {
				++qanprev[frip];
				++zib;
			}
		}
	}
	cout << m - zib << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:17: error: 'm' was not declared in this scope
   68 |         cout << m - zib << endl;
      |                 ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
int X[100005];

//-----UnionFind--------
vector<int> par, rk, cn;

void initUnion(int n)
{
	for (int i = 0;i < n;i++) {
		par.push_back(i);
		rk.push_back(1);
		cn.push_back(0);
	}
}

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

void unite(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	if (rx == ry) return;

	if (rk[ry] < rk[rx]) swap(rx, ry);
	X[ry] += X[rx];
	rk[ry] += rk[rx];
	cn[ry] += cn[rx];
	par[rx] = ry;
}

bool same(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}
//-----UnionFind--------

class edge {
public:
	int u;
	int v;
	int w;
};

bool comp(edge v, edge u)
{
	return v.w < u.w;
}

int main()
{
	cin >> n >> m;
	vector<edge> e(m);
	int u, v, w;

	for (int i = 0;i < n;i++) cin >> X[i];
	for (int i = 0;i < m;i++) {
		scanf_s("%d%d%d", &u, &v, &w);
		u--;
		v--;
		e[i].u = u;
		e[i].v = v;
		e[i].w = w;
	}

	sort(e.begin(), e.end(), comp);

	int ans = m;
	initUnion(n);

	for (int i = 0;i < m;i++) {
		int w = e[i].w;
		int v = e[i].v;
		int u = e[i].u;

		if (!same(u, v)) {
			int Ru = root(u);
			int Rv = root(v);
			unite(u, v);
		}

		int Ru = root(u);
		cn[Ru]++;

		if (X[Ru] >= w) {
			ans -= cn[Ru];
			cn[Ru] = 0;
		}
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:85:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   85 |                 scanf_s("%d%d%d", &u, &v, &w);
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int n,m,kq;
int a[N],b[N],x[N],y[N],p[N],id[N],ans[N];
int root(int x){return id[x]<0?x:id[x]=root(id[x]);}
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(nullptr);
    cin>>n>>m;
    for(int i=1;i<=n;++i) cin>>x[i],id[i]=-1;
    for(int i=1;i<=m;++i) cin>>a[i]>>b[i]>>y[i],p[i]=i;
    sort(p+1,p+m+1,[](int i,int j){return y[i]<y[j];});
    for(int i=1;i<=m;++i)
    {
        int u=root(a[p[i]]),v=root(b[p[i]]),c=y[p[i]];
        if(u==v) ans[u]+=c>x[u];
        else
        {
            x[u]+=x[v],id[v]=u;
            ans[u]+=ans[v];
            ans[u]=(c>x[u] ? ans[u]+1 : 0);
        }
    }
    for(int i=1;i<=n;++i) if(id[i]<0) kq+=ans[i];
    cout<<kq;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<int,int> P;
#define Mod 1000000007

int par[101010];
int ranki[101010];
ll weigh[101010];
ll loop;
int info[101010][5];


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

int find(int x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}
a
void unite(int x,int y){
    ll x0=x,y0=y;
    x=find(x);
    y=find(y);

    if(x==y) {
        info[loop][0]=0;
        info[loop][1]=x;
        info[loop][2]=weigh[x];
        info[loop][3]=y;
        info[loop][4]=weigh[y];
        return;
    }

    else {
    info[loop][0]=1;
    info[loop][1]=x;
    info[loop][2]=weigh[x];
    info[loop][3]=y;
    info[loop][4]=weigh[y];

    if(ranki[x]<ranki[y]){
        par[x]=y;
        weigh[y]=weigh[x]+weigh[y];
        weigh[x]=weigh[y];
    } else{
        par[y]=x;
        if(ranki[x]==ranki[y]) ranki[x]++;
        weigh[x]=weigh[x]+weigh[y];
        weigh[y]=weigh[x];
    }

    }

}


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

int main(){
    ll i,j;

    ll n,m;

    cin>>n>>m;

    init(n+10);
    ll x[n];
    for(i=0;i<n;i++){
        cin>>x[i];
        weigh[i]=x[i];
    }


    vector < pair < ll, pair<ll,ll> > > e;
    ll a,b,y;

    for(i=0;i<m;i++){
        cin>>a>>b>>y;
        e.pb(make_pair(y,make_pair(a-1,b-1)));
    }
    sort(e.begin(),e.end());

    loop=0;
    for(i=0;i<m;i++){
        unite(e[i].se.fi,e[i].se.se);
        loop++;
    }

    loop--;
    ll ans=0;

    for(i=loop;i>=0;i--){
        if(e[i].fi > weigh[info[i][1]]){
            ans++;
            if(info[i][0]==1){
            weigh[info[i][1]]=info[i][2];
            weigh[info[i][3]]=info[i][4];
            }
        }
    }

    cout<<ans<<endl;
    return 0;

    


}

Compiler output:
a.cc:28:1: error: 'a' does not name a type
   28 | a
      | ^
a.cc: In function 'int main()':
a.cc:96:9: error: 'unite' was not declared in this scope
   96 |         unite(e[i].se.fi,e[i].se.se);
      |         ^~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

const long long inf = 1000000000000000ll;

int main()
{
	int n, k;
	scanf_s("%d%d", &n, &k);
	vector<int> c(n);
	vector<long long> v(n);
	for (int i = 0;i<n;i++) {
		scanf_s("%d%lld", &c[i], &v[i]);
		c[i]--;
	}
	vector<vector<long long> > cv(k);
	for (int i = 0;i<n;i++) {
		cv[c[i]].push_back(v[i]);
	}
	vector<pair<long long, int> > v2(k + 1);
	multiset<long long> v3;
	for (int j = 0;j<k;j++) {
		sort(cv[j].begin(), cv[j].end(), greater<long long>());
		v2[j] = make_pair(cv[j][0] + cv[j][1], j);
		if (cv[j].size() >= 3) {
			v3.insert(cv[j][0] + cv[j][1] + cv[j][2]);
		}
	}
	v2[k] = make_pair(-inf, -1);
	v3.insert(-inf);
	sort(v2.begin(), v2.end(), greater<pair<long long, int> >());
	multiset<long long> s;
	s.insert(-inf);
	long long s1 = inf, s2 = inf;
	vector<long long> ans(n + 1);
	ans[0] = 0;
	for (int i = 0, j = 0;i<n;) {
		int k = v2[j].second;
		long long s1 = *s.rbegin(), s2 = v2[j].first;
		//printf("%d %lld %lld\n",k,s1,s2);
		if (2 * s1 >= s2) {
			ans[i + 1] = ans[i] + s1;
			s1 = s1;
			s.erase(s.find(s1));
			i++;
		}
		else {
			ans[i + 1] = max(-1ll, max(ans[i] + s1, max(ans[i] - s1 + s2, ans[i] - s2 + *v3.rbegin())));
			ans[i + 2] = ans[i] + s2;
			s2 = s2;
			for (int t = 2;t<cv[k].size();t++) {
				s.insert(cv[k][t]);
			}
			if (cv[k].size() >= 3) {
				v3.erase(v3.find(cv[k][0] + cv[k][1] + cv[k][2]));
			}
			i += 2;
			j++;
		}
	}
	for (int i = 1;i <= n;i++) {
		printf("%lld\n", ans[i]);
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   32 |         scanf_s("%d%d", &n, &k);
      |         ^~~~~~~
      |         scanf
Language: C++

#include"bits/stdc++.h"
using namespace std;
#define MOD 1000000007
long long int ppow(long long int i, long long int j) {
	long long int res = 1LL;
	while (j) {
		if ((j & 1LL)) {
			res *= i;
			if (res >= MOD) {
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD) {
			i %= MOD;
		}
	}
	return res;
}
long long int gcd(long long int a, long long int b) {
	if (a > b) {
		swap(a, b);
	}
	while (a) {
		swap(a, b);
		a %= b;
	}
	return b;
}
long long int lcm(long long int a, long long int b) {
	return a / gcd(a, b)*b;
}

int n;

vector<pair<int, int> > v;  //color, value

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		v.push_back(make_pair(a, b));
	}
	sort(v.begin(), v.end());
	for(int i=0;i<v.s)
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:25: error: 'class std::vector<std::pair<int, int> >' has no member named 's'
   47 |         for(int i=0;i<v.s)
      |                         ^
a.cc:47:26: error: expected ';' before ')' token
   47 |         for(int i=0;i<v.s)
      |                          ^
      |                          ;
Language: C

#include <bits/stdc++.h>
#define ll long long
using namespace std;
long long fpb(long long x, long long y) { 
    return (y == 0) ? x : fpb(y, x % y); 
}
long long kpk(long long x, long long y) { 
    return x * (y / fpb(x, y)); 
}
bool cmp(long long a,long long b)
{
    return a>b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}

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

#include<iostream>
using namespace std;
int main (void)
{
  int a,b,c;
  cin>>a>>b>>c;
  cout<<a*b*c/(2*max({a,b,c}))<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:21: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
    7 |   cout<<a*b*c/(2*max({a,b,c}))<<endl;
      |                  ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
Language: C++

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

int main()
{
  int s;
  cin >> s;
  set<int> st;
  st.insert(s);
  
  for(int i=0; i<1000000; i++)
  {
    if(s % 2 == 0)
      s /= 2;
    else
      s = 3 * s + 1;
    
    if(st.find(s) != st.end())
    {
      cout << i+1 << endl;
      return 0;
    }
    else
      st.inset(s);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:10: error: 'class std::set<int>' has no member named 'inset'; did you mean 'insert'?
   25 |       st.inset(s);
      |          ^~~~~
      |          insert
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int x,y,z;cin>>X>>Y>>Z;
    cout<<(X*Y)/2<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:20: error: 'X' was not declared in this scope
   30 |     int x,y,z;cin>>X>>Y>>Z;
      |                    ^
a.cc:30:23: error: 'Y' was not declared in this scope
   30 |     int x,y,z;cin>>X>>Y>>Z;
      |                       ^
a.cc:30:26: error: 'Z' was not declared in this scope
   30 |     int x,y,z;cin>>X>>Y>>Z;
      |                          ^
Language: C

#include<stdio.h>
int main()
{
int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a << c && b << c) printf("%d",a*b/2);
  if(a << b && c << b) printf("%d",a*c/2);
  else if printf("%d",b*c/2);
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:8:11: error: expected '(' before 'printf'
    8 |   else if printf("%d",b*c/2);
      |           ^~~~~~
      |           (
Language: C

#include<stdio.h>
int main()
{
int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a << c && b << c) printf("%d",a*b/2);
  if(a << b && c << b) printf("%d",a*c/2);
  else if printf("%d",a*b/2);
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:8:11: error: expected '(' before 'printf'
    8 |   else if printf("%d",a*b/2);
      |           ^~~~~~
      |           (
Language: C++

included <stdio.h>
int main(){
	int ab,bc;
	int area;
	scanf("%d %d", &ab, &bc);
	area=(ab*bc)/2;
	printf("%d",area);
	
	return 0;
}

Compiler output:
a.cc:1:1: error: 'included' does not name a type
    1 | included <stdio.h>
      | ^~~~~~~~
Language: C++

icluded <stdio.h>
int main(){
	int ab,bc;
	int area;
	scanf("%d %d", &ab, &bc);
	area=(ab*bc)/2;
	printf("%d",area);
	
	return 0;
}

Compiler output:
a.cc:1:1: error: 'icluded' does not name a type
    1 | icluded <stdio.h>
      | ^~~~~~~
Language: C++

#include <stdio.h>
intmain(){
	int ab,bc;
	int area;
	scanf("%d %d", &ab, &bc);
	area=(ab*bc)/2;
	printf("%d",area);
	
	return 0;
}

Compiler output:
a.cc:2:1: error: ISO C++ forbids declaration of 'intmain' with no type [-fpermissive]
    2 | intmain(){
      | ^~~~~~~