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

#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include "union-find.h"

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;

#define INF 1000000
#define MAX_V 10000
#define MAX_E 100000000
int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int V, E;

struct edge {
	int u, v, cost;
};

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
edge es[MAX_E];
union_find_tree uft;

int prim() {
	rep(i, 0, V) {
		mincost[i] = INF;
		used[i] = false;
	}

	mincost[0] = 0;
	int res = 0;
	while(true) {
		int v = -1;
		rep(u, 0, V) {
			if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
		}

		if(v == -1) break;
		used[v] = true;
		res += mincost[v];
		rep(u, 0, V) mincost[u] = min(mincost[u], cost[v][u]);
	}
	return res;
}

int kruskall() {
	sort(es, es + E, comp);
	uft.init(V);
	int res = 0;
	rep(i, 0, E) {
		edge e = es[i];
		if(!uft.same(e.u, e.v)) {
			uft.unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}
		

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

	cin >> V >> E;
	
	rep(i, 0, E) {
		int s, t, w;
		cin >> s >> t >> w;
		es[i].u = s;
		es[i].v = t;
		es[i].cost = w;
	}

	cout << kruskall() << endl;
}



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

//Minimum Spanning Tree
#include <iostream>
#include <vector>

using namespace std;

class DisjointSet {
public:
    vector<int> rank, p;
    DisjointSet(int size);
    void makeSet(int x);
    void unite(int x, int y);
    void link(int x, int y);
    int findSet(int x);
};

DisjointSet::DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i = 0; i < size; i++) makeSet(i);
}

void DisjointSet::makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
}

void DisjointSet::unite(int x, int y) {
    link(findSet(x), findSet(y));
}

void DisjointSet::link(int x, int y) {
    if(rank[x] > rank[y]) {
        p[y] = x;
    } else {
        p[x] = y;
        if(rank[x] == rank[y]) rank[y]++;
    }
}

int DisjointSet::findSet(int x) {
    if(x != p[x]) {
        p[x] = findSet(p[x]);
    }
    return p[x];
}

struct Edge {
public:
    int s, t, c;
    Edge(int s, int t, int c): s(s), t(t), c(c) {}
    bool operator < ( const Edge &e ) const {
        return c < e.c;
    }
};

int kruskal(vector<Edge> E) {
    int t = 0;
    DisjointSet D(int(E.size()));
    for(auto itr = E.begin(); itr != E.end(); itr++) {
        if(D.findSet(itr -> s) == D.findSet(itr -> t)) {
            D.unite(itr -> s, itr -> t);
            t += itr -> c;
        }
    }
    return t;
}

int main() {
    int N, M, s, t, c;
    vector<Edge> E;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        cin >> s >> t >> c;
        E.push_back(Edge(s, t, c));
    }
    sort(E.begin(), E.end());
    
    cout << t << endl;
}


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

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

/*
 * union-find???????£??????\???????????????
 */
#define MAX_V 100001

typedef struct UF{
    int parent;
}UF;

UF uf[MAX_V + 1];

/*
 * ?????????idx???parent??¨???????????????????¨??????????
 */
void initialize(int num){
    int i ;
    
    for (i=1; i <= num; i++) {
        uf[i].parent = i;
    }
}
/*
 * ??????????±?????????°????????????????????????
 */
int find(int a){
    
    if (a == uf[a].parent) {
        return a;
    }
    
    return uf[a].parent = find(uf[a].parent);
}

int isSame(int a, int b){
    
    if (find(a) == find(b)) {
        return 1;
    }
    else{
        return 0;
    }
}

void unite(int a, int b){
    a = find(a);
    b = find(b);
    
    if (a == b) {
        return;
    }
    
    uf[b].parent = a;
    
}

/*
 * ??\??????Kruskal??????????????°??????(??????????????\????????¨??????????£?)
 * ?¢???????????????????X?????????????????¢???????????????X???????????????????????¨??§????°???¨?????¨????±???????
 */

#define MAX_E 10001
#define MAX_V 100001
#define INF INT_MAX

typedef struct edge{
    int from;
    int to;
    int cost;
}edge;

edge es[MAX_E];

// cost?????????????????¢??°
bool cmp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

/*
 * e:???????????°
 * v:?????????????????°
 */
int Kruskal(int e, int v){
    
    int res = 0;
    
    //?????????????????????????????????
    sort(es, es + e, cmp);
    
    //union-find????????????
    initialize(v);
    
    for (int i = 0; i< e; i++) {
        edge e = es[i];
        if (!isSame(e.from, e.to)) {
            unite(e.from, e.to);
            res += e.cost;
        }
    }
    
    return res;
}

int main( ){
    
    int i, V, E, u, v, c, ans;
    cin >> V >> E;

    for (i = 0; i < E; i++) {
        cin >> u >> v >> c;
        es[i].from = u;
        es[i].to = v;
        es[i].cost = c;
    }
    
    ans = Kruskal(E, V);
    
    cout << ans << endl;
    
    
    return 0;
}

Compiler output:
a.cc: In function 'int Kruskal(int, int)':
a.cc:93:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   93 |     sort(es, es + e, cmp);
      |     ^~~~
      |     short
Language: C++

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

class DisjointSet {
  vector<int> p;
  vector<int> r;

public:
  DisjointSet(int n) {
    for (int i = 0; i < n; i++) {
      p.push_back(i);
      r.push_back(0);
    }
  }

  int findRoot(int u) {
    while (u != p[u]) {
      p[u] = p[p[u]];
      u = p[u];
    }
    return p[u];
  }

  bool isSame(int u, int v) {
    return (findRoot(u) == findRoot(v));
  }

  void link(int u, int v) {
    int u_root = findRoot(u);
    int v_root = findRoot(v);

    if (r[u_root] < r[v_root]) {
      p[u_root] = v_root;
    } else {
      p[v_root] = u_root;
      if (r[u_root] == r[v_root]) r[u_root]++;
    }
  }
};
  
class Edge {
public:
  int s, t, w;
  Edge(int s, int t, int w): s(s), t(t), w(w) {}
  bool operator < (const Edge &e) const {
    return w < e.w;
  }
};

vector<Edge> Es;

void kruskal() {
  DisjointSet ds(Es.size());
  int cost = 0;

  sort(Es.begin(), Es.end());

  for (int i = 0; i < Es.size(); i++) {
    Edge e = Es[i];
    if (!ds.isSame(e.s, e.t)) {
      ds.link(e.s, e.t);
      cost += e.w;
    }
  }

  cout << cost << endl;
}

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

  Es.resize(v, Edge(0, 0, 0));

  for (int i = 0; i < e; i++) {
    int s, t, w; cin >> s >> t >> w;
    Es.push_back(Edge(s, t, w));
  }

  kruskal();

  return 0;
}

Compiler output:
a.cc: In function 'void kruskal()':
a.cc:57:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   57 |   sort(Es.begin(), Es.end());
      |   ^~~~
      |   short
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pii;
#define MAX_V 100010
struct edge{
	int from,to,cost;
};
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
bool operator < (const edge &a,const edge &b){
	return a.cost<b.cost;
}
vector<edge>G;
int V,E;
void kruskal(){
	int sum=0;
	sort(all(G));
	UnionFind uf(V);
	rep(i,G.size()){
		edge e=G[i];
		if(!findSet(e.from,e.to)){
			sum+=e.cost;
			unionSet(e.from,e.to);
		}
	}
	cout<<sum<<endl;
}
int main(){
	cin>>V>>E;
	while(E--){
		int a,b,c;
		cin>>a>>b>>c;
		edge t={a,b,c};
		G.pb(t);
	}
	kruskal();
}

Compiler output:
a.cc: In function 'void kruskal()':
a.cc:61:21: error: 'findSet' was not declared in this scope
   61 |                 if(!findSet(e.from,e.to)){
      |                     ^~~~~~~
a.cc:63:25: error: 'unionSet' was not declared in this scope; did you mean 'union'?
   63 |                         unionSet(e.from,e.to);
      |                         ^~~~~~~~
      |                         union
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#define INF 10000000

using namespace std;

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

struct edge{ int to, cost; };

int cost[10000][10000];
int mincost[10000];
bool used[10000];
int V;
int E;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

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

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

int main(void){

	cin >> V >> E;
	for(int i = 0;i < E;i++){
		int a, b;
		cin >> a >> b;
		cin >> cost[a][b];
		cost[b][a] = cost[a][b];
	}

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

	mincost[0] = 0;
	int res = 0;

	while(true){
		int v = -1;
		for(int u = 0;u < V;u++){
			if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
		}

		if(v == -1) break;
		used[v] = true;
		res += mincost[v];

		for(int u = 0;u < V;u++){
			mincost[u] = min(mincost[u], cost[v][u]);
		}
	}
	cout << res << endl;
	return 0;
}

Compiler output:
a.cc:61:2: error: expected ';' after class definition
   61 | }
      |  ^
      |  ;
Language: C++

#include <iostream>
using namespace std;
#define MAX_E 100000
#define MAX_V 10000

struct edge {
  int u, v, cost;
};

int V, E;
edge es[MAX_E];
int par[MAX_V];
int r[MAX_V];

void init_union_find(int v) {
  for(int i = 0; i < v; i++) {
    par[i] = i;
    r[i] = 0;
  }
}

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

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if(x == y) return ;

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

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

bool comp(const edge& e1, const edge& e2) {
  return e1.cost < e2.cost;
}

int kruskal() {
  sort(es, es + E, comp);
  init_union_find(V);
  int res = 0;
  for(int i = 0; i < E; i++) {
    edge e = es[i];
    if(!same(e.u, e.v)) {
      unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

int main () {
  cin >> V >> E;

  for(int i = 0; i < E; i++) {
    int v1, v2, c;
    cin >> v1 >> v2 >> c;
    es[i].u = v1;
    es[i].v = v2;
    es[i].cost = c;
  }

  cout << kruskal() << endl;

}

Compiler output:
a.cc: In function 'int kruskal()':
a.cc:49:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   49 |   sort(es, es + E, comp);
      |   ^~~~
      |   short
Language: C++

#include <iostream>

using namespace std;

struct Edge {
    int source, to, cost;
    bool operator<(const Edge& o) const {
        return cost < o.cost;
    }
};

const int SIZE = 100000;

struct UnionFind {
    int gid[SIZE], rank[SIZE];
    int groups;

    void init(int n) {
        for (int i = 0; i < n; ++i) {
            gid[i] = i;
            rank[i] = 0;
        }
        groups = n;
    }

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

    bool equals(int a, int b) {
        return find(a) == find(b);
    }

    int merge(int x, int y) {
        int rx = find(x);
        int ry = find(y);
        if (rx != ry) {
            if (rank[rx] < rank[ry]) {
                gid[rx] = ry;
            } else {
                gid[ry] = rx;
            }
            groups--;
        }
        return groups;
    }
};

const int MAX_V = 10000;
const int INF = 1 << 28;

int V, E;
bool done[MAX_V];

int main() {
    cin >> V >> E;
    Edge edges[E];
    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        edges[i] = (Edge) { s, t, w };
    }
    sort(edges, edges + E);
    UnionFind uf = UnionFind();
    uf.init(V);
    int costSum = 0;
    for (Edge e: edges) {
        if (uf.equals(e.source, e.to)) {
            continue;
        }
        costSum += e.cost;
        if (uf.merge(e.source, e.to) == 1) {
            break;
        }
    }

    cout << costSum << endl;
}

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

#include <bits/stdc++.h>
#define INF 1000000000
#define MAX_V 10000
#define MAX_E 100000
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
	edge(int to_, int cost_) : to(to_), cost(cost_) {}
};

int V, E;
vector<edge> G[MAX_V];

int Prim() {
	int res = 0;
	bool used[MAX_V];
	priority_queue<P, vector<P>, greater<P>> que;
	for (int i = 0; i < V; i++) {
		mincost[i] = INF;
		used[i] = false;
	}
	que.push(P(0, 0));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (used[v]) continue;
		used[v] = true;
		res += p.first;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			que.push(P(e.cost, e.to));
		}
	}
	return res;
}

int main()
{
	cin >> V >> E;
	for (int i = 0, s, t, c; i < E; i++) {
		cin >> s >> t >> c;
		G[s].push_back(edge(t, c));
		G[t].push_back(edge(s, c));
	}
	cout << Prim() << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int Prim()':
a.cc:20:17: error: 'mincost' was not declared in this scope; did you mean 'sincosl'?
   20 |                 mincost[i] = INF;
      |                 ^~~~~~~
      |                 sincosl
Language: C++

#include <cstdio>
#include <iostream>
#include <tuple>
#include <queue>
#include <functional>
#include <list>

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

const int MAX_NODE_NUM = 10005;
const int MAX_EDGE_NUM = 100005;

namespace Prim {
	static list<tuple<int, int>> adjLists[MAX_NODE_NUM];
	static bool isNodeInST[MAX_NODE_NUM];
	void run() {
		int n, m;
		cin >> n >> m;
		REP(i, m) {
			int w, s, t;
			cin >> s >> t >> w;
			adjLists[s].push_back(make_tuple(w, t));
			adjLists[t].push_back(make_tuple(w, s));
		}

		using EdgeType = tuple<int, int>;
		priority_queue<EdgeType, vector<EdgeType>, greater<EdgeType>> q;
		long long cost = 0;
		int stNodeNum = 0;
		int newNode = 0;
		int newCost = 0;
		q.push(make_tuple(newCost, newNode));
		while (stNodeNum < n) {
			tie(newCost, newNode) = q.top();
			q.pop();
			if (isNodeInST[newNode] == false) {
				isNodeInST[newNode] = true;
				cost += newCost;
				stNodeNum++;
				for (auto t : adjLists[newNode]) {
					q.push(t);
				}
			}
		}

		cout << cost << endl;

		return;
	}
};

namespace Kruskal {
	static tuple<int, int, int> edges[MAX_EDGE_NUM];
	static int parent[MAX_NODE_NUM];
	int root(int a) { return (a == parent[a]) ? a : (parent[a] = root(parent[a])); }
	bool unite(int a, int b) {
		int x = root(a), y = root(b);
		if (x == y) return false;
		parent[x] = y;
		return true;
	}
	void run() {
		int n, m;
		int s, t, w;
		cin >> n >> m;
		REP(i, m) {
			cin >> s >> t >> w;
			edges[i] = tie(w, s, t);
		}
		sort(edges, edges + m);
		REP(i, n) {
			parent[i] = i;
		}
		long long cost = 0;
		REP(i, m) {
			tie(w, s, t) = edges[i];
			if (unite(s, t)) {
				cost += w;
			}
		}
		cout << cost << endl;
	}
};

int main() {
//	Prim::run();
	Kruskal::run();

	return 0;
}

Compiler output:
a.cc: In function 'void Kruskal::run()':
a.cc:72:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   72 |                 sort(edges, edges + m);
      |                 ^~~~
      |                 short
Language: C++

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

class Disjonset{
public:
    vector<int> p;
    Disjonset(int n){
        p.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
        }
    }
    
    bool same(int x,int y){
        return findParent(x) == findParent(y);
    }
    void unite(int x,int y){
        x = findParent(x);
        y = findParent(y);
        p[x] = y;
    }
    
    int findParent(int x){
        if(x!=p[x]){
            p[x] = findParent(p[x]);
        }
        return p[x];
    }
};

class Edge{
public:
    //?????¶?????????????????¨??????
    int source,target,cost;
    Edge(int source=0, int target=0, int cost=0):
    source(source),target(target),cost(cost){}
    bool operator < (const Edge &e) const {
        return cost < e.cost;
    }
};




int kruskal(int N,vector<Edge> edges){
    Disjonset d = Disjonset(N+1);
    int totalCost = 0;
    sort(edges.begin(),edges.end());
    for(int i=0;i<edges.size();i++){
        if(!(d.same(edges[i].source,edges[i].target))){
            totalCost += edges[i].cost;
            d.unite(edges[i].source,edges[i].target);
        }
    }
    return totalCost;
}

int main(int argc, const char * argv[]) {
    int V,E;
    cin >> V >> E;
    vector<Edge> edges;
    for(int i=0;i<E;i++){
        int s,t,c;
        cin >> s>>t>>c;
        edges.push_back(Edge(s,t,c));
    }
    
    cout << kruskal(V, edges) << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int kruskal(int, std::vector<Edge>)':
a.cc:49:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   49 |     sort(edges.begin(),edges.end());
      |     ^~~~
      |     short
Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

pair<Weight, Edges> minimum_spanning_tree(const Graph &g, size_t s=0) {
    /* Prim */
    size_t V=g.size();
    Edges T;
    Weight total=0;

    vector<bool> visited(V);
    gp_queue<Edge> q; q.push(Edge(-1, s, 0));
    while (!q.empty()) {
        Edge e=q.top(); q.pop();
        if (visited[e.dst]) continue;

        T.push_back(e);
        total += e.weight;
        visited[e.dst] = true;
        for (const Edge &f: g[e.dst])
            if (!visited[f.dst])
                q.push(f);
    }

    return make_pair(total, T);
}

int main() {
    size_t V, E;
    scanf("%zu %zu", &V, &E);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight w;
        scanf("%zu %zu %lld", &s, &t, &w);

        join(g, s, t, w);
    }

    printf("%lld\n", minimum_spanning_tree(g).first);
    return 0;
}

Compiler output:
a.cc: In function 'std::pair<long long int, std::vector<Edge> > minimum_spanning_tree(const Graph&, size_t)':
a.cc:54:5: error: 'gp_queue' was not declared in this scope; did you mean 'lp_queue'?
   54 |     gp_queue<Edge> q; q.push(Edge(-1, s, 0));
      |     ^~~~~~~~
      |     lp_queue
a.cc:54:18: error: expected primary-expression before '>' token
   54 |     gp_queue<Edge> q; q.push(Edge(-1, s, 0));
      |                  ^
a.cc:54:20: error: 'q' was not declared in this scope
   54 |     gp_queue<Edge> q; q.push(Edge(-1, s, 0));
      |                    ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<bits/stdc++.h>

using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pii;

class uf{
public:
  uf();
  uf(lli _n){
    init(_n);
  }
  void init(lli _n){
    n = _n;
    rank.resize(n);
    parent.resize(n);
    for (lli i = 0; i < n; i++) {
      rank[i] = 0;
      parent[i] = i;
    }
  }
  lli find(lli x){
    if(x == parent[x])return x;
    else return parent[x] = find(parent[x]);
  }
  
  void unite(lli x, lli y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      parent[x] = y;
    }else{
      parent[y] = x;
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(lli x, lli y){
    return find(x) == find(y);
  }
private:
  lli n;
  vector<lli> rank, parent;
};


struct edge{
  lli from, to, cost;
  bool operator<(const edge &e)const{
    return cost < e.cost;
  }
};

lli V, E;

lli kruskal(vector<edge> &es, vector<bool> &used){
  sort(es.begin(), es.end());
  uf u(V);
  lli res = 0;
  for (lli i = 0; i < es.size(); i++) {
    edge &e = es[i];
    if(not u.same(e.from, e.to)){
      u.unite(e.from, e.to);
      used[i] = true;
      res += e.cost;
    }
  }
  return res;
}

void dfs(vector<vector<edge> > &g, vector<vector<lli> > &mat, vector<bool> &used, int s, int v){
  used[v] = true;
  for (int i = 0; i < g[v].size(); i++) {
    edge &e = g[v][i];
    if(used[e.to] == true)continue;
    mat[s][e.to] = max(mat[s][e.to], e.cost);
    mat[e.to][s] = max(mat[e.to][s], e.cost);
    dfs(g, mat, used, s, e.to);
  }
}
         

int main(){
  lli n, m, w, h, q;
  std::cin >> n >> m;
  //vector<vector<lli> > mat(n, vector<lli>(n, 0));
  V = n;
  vector<edge> e(m);
  vector<bool> used(m, false);
  for (lli i = 0; i < m; i++) {
    std::cin >> e[i].from >> e[i].to >> e[i].cost;
    //e[i].from--, e[i].to--;
  }
  lli cost = kruskal(e, used);
  vector<vector<edge> > g(n);
  for (lli i = 0; i < m; i++) {
    if(used[i] == true){
      edge te = (edge){e[i].to, e[i].from, e[i].cost};
      g[e[i].from].emplace_back(e[i]);
      g[e[i].to].emplace_back(te);
      // mat[e[i].from][e[i].to] = e[i].cost;
      // mat[e[i].to][e[i].from] = e[i].cost;
    }
  }
  for (int i = 0; i < n; i++) {
    vector<bool> used(n, false);
    dfs(g, mat, used, i, i);
  }
  std::cout << cost << std::endl;
  // for (int i = 0; i < n; i++) {
  //   for (int j = 0; j < n; j++) {
  //     std::cout << mat[i][j] << " ";
  //   }
  //   std::cout << std::endl;
  // }
  // std::cin >> q;
  // vector<lli> s(q), t(q);
  // for (lli i = 0; i < q; i++) {
  //   std::cin >> s[i] >> t[i];
  //   std::cout << cost - mat[--s[i]][--t[i]] << std::endl;
  // }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:114:12: error: 'mat' was not declared in this scope
  114 |     dfs(g, mat, used, i, i);
      |            ^~~
Language: C++

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

pair<Weight, Edges> minimumSpanningTree(const Graph &g, int r1) {
  int n = g.size();
  Edges T;
  Weight total = 0;

  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push( Edge(-1, r1, 0) );
  //Q.push( Edge(-1, r2, 0) );
  while (!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    T.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    FOR(f, g[e.dst]) if (!visited[f->dst]) Q.push(*f);
  }
  return pair<Weight, Edges>(total, T);
}

int main(){
	int N,M,Q,a,b,c;
	scanf("%d%d",&N,&M);
	Graph g(N);
	for(;M--;){
		scanf("%d%d%d",&a,&b,&c);
		g[a].emplace_back(a,b,c);
		g[b].emplace_back(b,a,c);
	}
	//scanf("%d",&Q);
	//for(;Q--;){
	//	scanf("%d%d",&a,&b);
		printf("%d\n",minimumSpanningTree(g,0).first);
	//}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: 'scanf' was not declared in this scope
   45 |         scanf("%d%d",&N,&M);
      |         ^~~~~
a.cc:55:17: error: 'printf' was not declared in this scope
   55 |                 printf("%d\n",minimumSpanningTree(g,0).first);
      |                 ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include <queue>
  +++ |+#include <cstdio>
    3 | using namespace std;
Language: C++

class UnionFindTree:
    def __init__(self, V):
        self.parent = [i for i in range(V)]

    def root(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        self.parent[rx] = ry
        return

    def find(self, x, y):
        return self.root(x) == self.root(y)

class Edge:
    def __init__(self, s, t, w):
        self.s = s
        self.t = t
        self.w = w

    def __lt__(self, right):
        return self.w < right.w

def Kruscal(edges, V):
    utf = UnionFindTree(V)
    res = 0
    edges.sort()
    for e in edges:
        s = e.s
        t = e.t
        if not utf.find(e.s, e.t):
            res += e.w
            utf.unite(e.s, e.t)
    return res

def main():
    [V, E] = map(int, (raw_input()).split(" "))
    edges = [None]*E
    for i in range(E):
        [s,t,w] = map(int, (raw_input()).split(" "))
        edges[i] = Edge(s,t,w)

    print Kruscal(edges, V)

if __name__ == "__main__":
    main()

Compiler output:
a.cc:2:9: error: expected class-name before '__init__'
    2 |     def __init__(self, V):
      |         ^~~~~~~~
a.cc:2:9: error: expected '{' before '__init__'
a.cc:2:18: error: 'self' was not declared in this scope
    2 |     def __init__(self, V):
      |                  ^~~~
a.cc:2:24: error: 'V' was not declared in this scope
    2 |     def __init__(self, V):
      |                        ^
a.cc:2:25: error: expression list treated as compound expression in initializer [-fpermissive]
    2 |     def __init__(self, V):
      |                         ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX 10000
#define INFTY (1 << 29)

class DisjointSet {
	public:
	    vector<int> rank, p;
	    
	    DisjointSet() {}
	    DisjointSet(int size) {
    		rank.resize(size, 0);
    		p.resize(size, 0);
    		for(int i = 0; i < size; i++) makeSet(i);
    	}
    	
    	void makeSet(int x) {
    	    p[x] = x;
    	    rank[x] = 0;
    	}
    	
    	bool same(int x, int y) {
	    	return findSet(x) == findSet(y);
	    }
	    
	    void unite(int x, int y) {
    		link(findSet(x), findSet(y));
    	}
    	
    	void link(int x, int y) {
	    	if(rank[x] > rank[y]) {
	    		p[y] = x;
	    	} else {
	    		p[x] = y;
	    		if(rank[x] == rank[y]) {
		    		rank[y]++;
		    	}
	    	}
	    }
	    
	    int findSet(int x) {
    		if(x != p[x]) {
		    	p[x] = findSet(p[x]);
		    }
		    return p[x];
    	}
};

class Edge {
	public:
	int source, target, cost;
	Edge(int source = 0, int target = 0, int cost = 0):
	source(source), target(target), cost(cost) {}
	bool operator < (const Edge &e) const {
		return cost < e.cost;
	}
};

int kruskal(int N, vector<Edge> edges) {
	int totalCost = 0;
	sort(edges.begin(), edges.end());
	
	DisjointSet dset = DisjointSet(N + 1);
	
	for(int i = 0; i < N; i++) dset.makeSet(i);
	
	int source, int target;
	for(int i = 0; i < edges.size(); i++) {
		Edge e = edges[i];
		if(!dset.same(e.source, e.target)) {
			totalCost += e.cost;
			dset.link(e.source, e.target);
		}
	}
	return totalCost;
}

int main() {
	int N, M, cost;
	int source, target;
	
	cin >> N >> M;
	
	vector<Edge> edges;
	for(int i = 0; i < M; i++) {
		cin >> source >> target >> cost;
		edges.push_back(Edge(source, target, cost));
	} 
	
	cout << kruskal(N, edges) << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int kruskal(int, std::vector<Edge>)':
a.cc:69:21: error: expected unqualified-id before 'int'
   69 |         int source, int target;
      |                     ^~~
Language: C++

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

using Weight=long long int;

struct Edge{
    int src,dest;
    Weight weight;
    operator<(const Edge& rhs){
        return weight<rhs.weight;
    }
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;

class UnionFind {
    int N;
    vector<int> rank;
    vector<int> par;
    public:
    UnionFind(int n):N(n){
        rank.resize(n,0);
        par.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }

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

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

    void unite(int x,int y){
        x=find(x),y=find(y);
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            if(rank[x]==rank[y]) rank[x]++;
            par[y]=x;
        }
    }

};

Weight kruskal(int V,Edges &edges){
    sort(edges.begin(),edges.end());
    Weight res=0;
    UnionFind uf(V);
    for(auto e:edges){
        if(!uf.same(e.src,e.dest)){
            uf.unite(e.src,e.dest);
            res+=e.weight;
        }
    }
    return res;
}

Weight kruskal(Graph& g){
    Edges edges;
    for(auto es:g){
        edges.reserve(edges.size()+es.size());
        edges.insert(edges.end(),es.begin(),es.end());
    }
    return kruskal(g.size(),edges);
}

int main(){
    int V,E;
    cin>>V>>E;
    Edges edges(E);
    for(int i=0;i<E;i++){
        int s,t;
        Weight w;
        cin>>s>>t>>w;
        edges[i]=Edge{s,t,w};
    }
    cout<<kruskal(V,edges)<<endl;
    return 0;
}

Compiler output:
a.cc:9:5: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
    9 |     operator<(const Edge& rhs){
      |     ^~~~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

namespace uf {
const int maxE = 10001;
int parent[maxE];
int parent_rank[maxE];


void init(int max_element) {
	for (int i = 0; i < max_element; i++) {
		parent[i] = i;
		parent_rank[i] = 0; 
	}
}

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

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



void link(int x, int y) {
	if (parent_rank[x] > parent_rank[y]) {
		parent[y] = x;
		return;
	}
	parent[x] = y;
	if (parent_rank[x] == parent_rank[y]) {
		parent_rank[y]++;
	}
}

void unite(int x, int y) {
	link(find(x),find(y));
}
}

struct Edge {
	int src, dest, cost;
	Edge(int src = 0, int dest = 0, int cost = 0) :
	src(src),dest(dest),cost(cost) {};
	bool operator < ( const Edge &e) const {
		return cost < e.cost;
	}
};

vector<Edge> kruskal(int N, vector<Edge> edges) {
	//int totalCost = 0;
	vector<Edge> result;
	sort(edges.begin(), edges.end());
	uf::init(N);

	int src, dest;
	for (int i = 0; i < edges.size(); i++) {
		Edge e = edges[i];
		if (!uf::is_same(e.src, e.dest)) {
			result.push_back(e);
			//totalCost+= e.cost;
			uf::unite(e.src, e.dest);
		}
	}
	return result;
}


int main() {
	using namespace std;
	int V,E;
	cin >> V >> E;

	vector<Edge> edges;
	for (int i = 0; i < E; i++) {
		int s,t,w;

		cin >> s >> t >> w;

		edges.push_back(Edge(s,t,w));
	}
	vector<Edge> es = kruskal(V,edges);
	int cost = 0;
	for (const auto& e : es) {
		cost += e.cost;
	}

	cout << cost << endl; 
}

Compiler output:
a.cc: In function 'std::vector<Edge> kruskal(int, std::vector<Edge>)':
a.cc:60:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   60 |         sort(edges.begin(), edges.end());
      |         ^~~~
      |         short
Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;
const int MAX=100005;

int G[MAX][MAX];
int mincos[MAX];
bool used[MAX];
int V,E;

int prim(){
  rep(i,V){
    mincos[i]=INF;
    used[i]=false;
  }
  mincos[0]=0;
  int sum=0;
  while(1){
    int v=-1;
    rep(i,V){
      if(used[i]==false&&(v==-1||mincos[i]<mincos[v]))v=i;
    }
    if(v==-1)break;
    used[v]=true;
    sum+=mincos[v];
    rep(i,V)mincos[i]=min(mincos[i],G[v][i]);
  }
  return sum;
}


signed main(){
  cin>>V>>E;
  rep(i,V)rep(j,V)G[i][j]=INF;
  rep(i,E){
    int s,t,w;
    cin>>s>>t>>w;
    G[s][t]=G[t][s]=w;
  }

  cout<<prim()<<endl;

  return 0;
}

Compiler output:
/tmp/cciR64Pv.o: in function `prim()':
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `mincos' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0x30): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0x46): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `mincos' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0x78): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `mincos' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0xba): relocation truncated to fit: R_X86_64_PC32 against symbol `mincos' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0xef): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0x10c): relocation truncated to fit: R_X86_64_PC32 against symbol `mincos' defined in .bss section in /tmp/cciR64Pv.o
a.cc:(.text+0x155): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>

using namespace std;

template <class T>
struct Edge {
  using w_type = T;
  Edge(int u, int v, w_type w): u(u), v(v), w(w) { }
  int u, v;
  w_type w;
  bool operator<(const Edge<T> & rhs) const {
    if (w != rhs.w) { return w < rhs.w; }
    if (u != rhs.u) { return u < rhs.u; }
    return v < rhs.v;
  }
};

class DisjointSet {
public:
  DisjointSet(const unsigned n_sets): n_sets_(n_sets) {
    p_.reserve(n_sets);
    rank_.reserve(n_sets);
  }
  void MakeSet(const unsigned x) { p_[x] = x; rank_[x] = 0; }
  void Union(const unsigned lhs, const unsigned rhs) { Link(FindSet(lhs), FindSet(rhs)); }
  void Link(const unsigned lhs, const unsigned rhs) {
    if (rank_[lhs] > rank_[rhs]) { p_[rhs] = lhs; }
    else {
      p_[lhs] = rhs;
      if (rank_[lhs] == rank_[rhs]) { ++rank_[rhs]; }
    }
  }
  unsigned FindSet(const unsigned x) {
    if (x != p_[x]) { p_[x] = FindSet(p_[x]); }
    return p_[x];
  }

private:
  unsigned n_sets_;
  vector<unsigned> p_;
  vector<unsigned> rank_;
};

template class Edge<float>;

template <class Edge>
decltype(auto) Kruskal(vector<Edge> & edges) {
  using size_type = typename vector<Edge>::size_type;
  using const_it = typename vector<Edge>::const_iterator;
  using w_type = typename Edge::w_type;

  auto n = edges.size();
  w_type weight_sum = 0;
  size_type n_edges = 0;
  DisjointSet dis_set(n);
  for (size_type i = 0; i < n; ++i) { dis_set.MakeSet(i); }
  sort(edges.begin(), edges.end());
  for (auto & e: edges) {
    if (dis_set.FindSet(e.u) != dis_set.FindSet(e.v)) {
      weight_sum += e.w;
      dis_set.Union(e.u, e.v);
      ++n_edges;
    }
    if (n_edges == n - 1) { break; }
  }

  return weight_sum;
}

int main(int argc, char const *argv[]) {
  vector<Edge<float>> edges;
  unsigned V, E;
  cin >> V >> E;
  for (unsigned i = 0; i < E; ++i) {
    unsigned u, v;
    float w;
    cin >> u >> v >> w;
    edges.emplace_back(u, v, w);
  }
  cout << Kruskal(edges) << endl;
  return 0;
}

Compiler output:
a.cc: In instantiation of 'decltype(auto) Kruskal(std::vector<Edge>&) [with Edge = Edge<float>]':
a.cc:81:18:   required from here
   81 |   cout << Kruskal(edges) << endl;
      |           ~~~~~~~^~~~~~~
a.cc:58:7: error: 'sort' was not declared in this scope; did you mean 'short'?
   58 |   sort(edges.begin(), edges.end());
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |   short
Language: C++

#include <bits/stdc++.h>
using namespace std;
struct EDGE { int from, to, cost; };
bool operator < (const EDGE& a, const EDGE& b) {
    return a.cost < b.cost;
}
 
vector<EDGE> g;
int par[10000];
 
int find(int x)
{
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}
 
bool _union(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return false;
    par[x] = y;
    return true;
}
 
int main()
{
    int V, E;
    scanf("%d %d", &V, &E);
     
    for (int i = 0; i < V; i++) par[i] = i;
     
	for (int i = 0; i < n; i++) {
		int s, t, w;
		cin>>s>>t>>w;
		e.push_back(Edge{ s, t, w });
	}
     
    sort(g.begin(), g.end());
     
    int res = 0;
    for (int i = 0; i < g.size(); i++){
        EDGE &e = g[i];
        if (_union(e.from, e.to)) res += e.cost;
    }
     
    printf("%d\n", res);
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:29: error: 'n' was not declared in this scope
   33 |         for (int i = 0; i < n; i++) {
      |                             ^
a.cc:36:17: error: 'e' was not declared in this scope
   36 |                 e.push_back(Edge{ s, t, w });
      |                 ^
a.cc:36:29: error: 'Edge' was not declared in this scope
   36 |                 e.push_back(Edge{ s, t, w });
      |                             ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
struct EDGE { int from, to, cost; };
bool operator < (const EDGE& a, const EDGE& b) {
    return a.cost < b.cost;
}
 
vector<EDGE> g;
int par[10000];
 
int find(int x)
{
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}
 
bool _union(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return false;
    par[x] = y;
    return true;
}
 
int main()
{
    int V, E;
    scanf("%d %d", &V, &E);
     
    for (int i = 0; i < V; i++) par[i] = i;
     
	for (int i = 0; i < V; i++) {
		int s, t, w;
		cin>>s>>t>>w;
		e.push_back(Edge{ s, t, w });
	}
     
    sort(g.begin(), g.end());
     
    int res = 0;
    for (int i = 0; i < g.size(); i++){
        EDGE &e = g[i];
        if (_union(e.from, e.to)) res += e.cost;
    }
     
    printf("%d\n", res);
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: 'e' was not declared in this scope
   36 |                 e.push_back(Edge{ s, t, w });
      |                 ^
a.cc:36:29: error: 'Edge' was not declared in this scope
   36 |                 e.push_back(Edge{ s, t, w });
      |                             ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
struct EDGE { int from, to, cost; };
bool operator < (const EDGE& a, const EDGE& b) {
    return a.cost < b.cost;
}
 
vector<EDGE> g;
int par[10000];
 
int find(int x)
{
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}
 
bool _union(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return false;
    par[x] = y;
    return true;
}
 
int main()
{
    int V, E;
    scanf("%d %d", &V, &E);
     
    for (int i = 0; i < V; i++) par[i] = i;
     
	for (int i = 0; i < V; i++) {
		int s, t, w;
		cin>>s>>t>>w;
		g.push_back(Edge{ s, t, w });
	}
     
    sort(g.begin(), g.end());
     
    int res = 0;
    for (int i = 0; i < g.size(); i++){
        EDGE &e = g[i];
        if (_union(e.from, e.to)) res += e.cost;
    }
     
    printf("%d\n", res);
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:29: error: 'Edge' was not declared in this scope
   36 |                 g.push_back(Edge{ s, t, w });
      |                             ^~~~
Language: C++

#include "stdafx.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


const int MAX_V = 10000;
const int MAX_E = 100000;
int finde[MAX_V];

struct Edge {
	int first;
	int second;
	int weight;
};
vector<Edge> e;

bool operator < (const Edge& a, const Edge& b) {
	return a.weight < b.weight;
}

bool Judge(int m, int n) {
	while (finde[m] != m) m = finde[m];
	while (finde[n] != n) n = finde[n];
	if (m == n) {
		return false;
	}
	m = finde[n];
	return true;
}

int min_span_tree(int n, int m) {

	for (int i = 0; i < m; i++) finde[i] = i;
	int count = 0;
	int ret = 0;
	int f, s;
	for (int i = 0; count < m - 1; i++) {
		f = e[i].first;
		s = e[i].second;
		if (Judge(f,s)) {		
			ret += e[i].weight;
			count++;
		}
	}
	return ret;
}
int main() {
	int n, m;
	cin >> m >> n;
	for (int i = 0; i < n; i++) {
		int s, t, w;
		cin>>s>>t>>w;
		e.push_back(Edge{ s, t, w });
	}
	sort(e.begin(), e.end());
	int ret = min_span_tree(n, m);
	cout << ret << endl;
	return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

using Weight=long long;

struct Edge{
    int src,dst;
    Weight weight;
    Edge(int src,int dst,Weight weight):
    src(src),dst(dst),weight(weight){}
};

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else if(e.src!=f.src)return e.src<f.src;
    else return e.dst<f.dst;
}

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

template<typename T>
class UnionFind{
    vector<T>data;
    UnionFind(T n):data(n,-1){}
    bool unite(T x,T y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    T root(T x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    bool same(T x,T y){
        return root(x)==root(y);
    }
    T size(T x){
        return -data[root(x)];
    }
};

pair<Weight,Edges>kruskal(const Graph &g){
    int n=g.size();
    UnionFind<int> uf(n);
    priority_queue<Edge>q;
    for(int i=0;i<n;++i){
        for(auto e:g[i]){
            if(i<e.dst)q.push(e);
        }
    }
    Weight total=0;
    Edges forest;
    while(forest.size()<n-1 && !q.empty()){
        Edge e=q.top();q.pop();
        if(uf.unite(e.src,e.dst)){
            forest.push_back(e);
            total+=e.weight;
        }
    }
    return {total,forest};
}

int main(){
    int v,e;cin>>v>>e;
    Graph g(v);
    for(int i=0;i<e;++i){
        int s,t,w;cin>>s>>t>>w;
        g[s].emplace_back(s,t,w);
        g[t].emplace_back(t,s,w);
    }
    cout<<kruskal(g).first<<endl;
    return 0;
}
// be checked by AOJ(GRL-2-A).

Compiler output:
a.cc: In function 'std::pair<long long int, std::vector<Edge> > kruskal(const Graph&)':
a.cc:48:24: error: 'UnionFind<T>::UnionFind(T) [with T = int]' is private within this context
   48 |     UnionFind<int> uf(n);
      |                        ^
a.cc:26:5: note: declared private here
   26 |     UnionFind(T n):data(n,-1){}
      |     ^~~~~~~~~
a.cc:59:20: error: 'bool UnionFind<T>::unite(T, T) [with T = int]' is private within this context
   59 |         if(uf.unite(e.src,e.dst)){
      |            ~~~~~~~~^~~~~~~~~~~~~
a.cc:27:10: note: declared private here
   27 |     bool unite(T x,T y){
      |          ^~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

using Weight=long long;

struct Edge{
    int src,dst;
    Weight weight;
    Edge(int src,int dst,Weight weight):
    src(src),dst(dst),weight(weight){}
};

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else if(e.src!=f.src)return e.src<f.src;
    else return e.dst<f.dst;
}

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

template<typename T>
class UnionFind{
private:
    vector<T>data;
    UnionFind(T n):data(n,-1){}
public:
    bool unite(T x,T y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    T root(T x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    bool same(T x,T y){
        return root(x)==root(y);
    }
    T size(T x){
        return -data[root(x)];
    }
};

pair<Weight,Edges>kruskal(const Graph &g){
    int n=g.size();
    UnionFind<int> uf(n);
    priority_queue<Edge>q;
    for(int i=0;i<n;++i){
        for(auto e:g[i]){
            if(i<e.dst)q.push(e);
        }
    }
    Weight total=0;
    Edges forest;
    while(forest.size()<n-1 && !q.empty()){
        Edge e=q.top();q.pop();
        if(uf.unite(e.src,e.dst)){
            forest.push_back(e);
            total+=e.weight;
        }
    }
    return {total,forest};
}

int main(){
    int v,e;cin>>v>>e;
    Graph g(v);
    for(int i=0;i<e;++i){
        int s,t,w;cin>>s>>t>>w;
        g[s].emplace_back(s,t,w);
        g[t].emplace_back(t,s,w);
    }
    cout<<kruskal(g).first<<endl;
    return 0;
}
// be checked by AOJ(GRL-2-A).

Compiler output:
a.cc: In function 'std::pair<long long int, std::vector<Edge> > kruskal(const Graph&)':
a.cc:50:24: error: 'UnionFind<T>::UnionFind(T) [with T = int]' is private within this context
   50 |     UnionFind<int> uf(n);
      |                        ^
a.cc:27:5: note: declared private here
   27 |     UnionFind(T n):data(n,-1){}
      |     ^~~~~~~~~