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

#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N], b[N];
vector<int> g[N]; 
int tot = -1, dfn[N], fa[N], dep[N], sz[N], son[N], top[N];
void pre(int u) {
  sz[u] = 1;
  for (auto v : g[u]) {
    if (v ^ fa[u]) {
      dep[v] = dep[u] + 1;
      fa[v] = u;
      pre(v);
      sz[u] += sz[v];
      if (sz[son[u]] < sz[v]) {
        son[u] = v;
      }
    }
  }
}
void dfs(int u) {
  dfn[u] = ++tot;
  if (son[u]) {
    top[son[u]] = top[u];
    dfs(son[u]);
  }
  for (auto v : g[u]) {
    if ((v ^ fa[u]) && (v ^ son[u])) {
      top[v] = v;
      dfs(v);
    }
  }
}
struct Data {
  int val, cnt, pos;
  inline void operator += (const Data &rhs) {
    val ^= rhs.val;
    cnt += rhs.cnt;
  }
  inline Data operator + (const Data &rhs) {
    if (cnt < rhs.cnt) {
      return *this;
    } else {
      return rhs;
    }
  }
}; 
struct node {
  Data info, tag;
} t[N << 2];
void build(int p, int l, int r) {
  t[p].info.pos = l;
  if (l ^ r) {
    int mid = l + r >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
  }
}
inline void pushup(int p) {
  t[p].info = t[p << 1].info + t[p << 1 | 1].info;
}
inline void tag(int p, Data add) {
  t[p].info += add;
  t[p].tag += add;
}
inline void pushdown(int p) {
  if (t[p].tag.cnt || t[p].tag.val) {
    tag(p << 1, t[p].tag);
    tag(p << 1 | 1, t[p].tag);
    t[p].tag = (Data) {0, 0};
  }
}
void modify(int p, int l, int r, int L, int R, Data add) {
  if (l >= L && r <= R) {
    tag(p, add);
    return;
  }
  pushdown(p);
  int mid = l + r >> 1;
  if (mid >= L) {
    modify(p << 1, l, mid, L, R, add);
  } 
  if (mid < R) {
    modify(p << 1 | 1, mid + 1, r, L, R, add);
  }
  pushup(p);
}
inline void modify(int u, int v, Data add) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) {
      swap(u, v);
    }
    modify(1, 1, tot, dfn[top[u]], dfn[u], add);
    u = fa[top[u]];
  }
  if (u ^ v) {
    if (dep[u] > dep[v]) {
      swap(u, v);
    }
    modify(1, 1, tot, dfn[u] + 1, dfn[v], add);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  pre(1);
  top[1] = 1;
  dfs(1);
  build(1, 1, tot);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    modify(a[i], b[i], (Data) {i, 1});
  }
  for (int i = 1; i < n; ++i) {
    int cnt = t[1].info.cnt;
    int idx = t[1].info.val;
    int pos = t[1].info.pos;
    if (cnt ^ 1) {
      puts("NO");
      return 0;
    }
    modify(1, 1, tot, pos, pos, (Data) {0, 1e9});
    modify(a[idx], b[idx], (Data) {idx, -1});
  }
  puts("YES");
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:127:44: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
  127 |     modify(1, 1, tot, pos, pos, (Data) {0, 1e9});
      |                                            ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N], b[N];
vector<int> g[N]; 
int tot = -1, dfn[N], fa[N], dep[N], sz[N], son[N], top[N];
void pre(int u) {
  sz[u] = 1;
  for (auto v : g[u]) {
    if (v ^ fa[u]) {
      dep[v] = dep[u] + 1;
      fa[v] = u;
      pre(v);
      sz[u] += sz[v];
      if (sz[son[u]] < sz[v]) {
        son[u] = v;
      }
    }
  }
}
void dfs(int u) {
  dfn[u] = ++tot;
  if (son[u]) {
    top[son[u]] = top[u];
    dfs(son[u]);
  }
  for (auto v : g[u]) {
    if ((v ^ fa[u]) && (v ^ son[u])) {
      top[v] = v;
      dfs(v);
    }
  }
}
struct Data {
  int val, cnt, pos;
  inline void operator += (const Data &rhs) {
    val ^= rhs.val;
    cnt += rhs.cnt;
  }
  inline Data operator + (const Data &rhs) {
    if (cnt < rhs.cnt) {
      return *this;
    } else {
      return rhs;
    }
  }
}; 
struct node {
  Data info, tag;
} t[N << 2];
void build(int p, int l, int r) {
  t[p].info.pos = l;
  if (l ^ r) {
    int mid = l + r >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
  }
}
inline void pushup(int p) {
  t[p].info = t[p << 1].info + t[p << 1 | 1].info;
}
inline void tag(int p, Data add) {
  t[p].info += add;
  t[p].tag += add;
}
inline void pushdown(int p) {
  if (t[p].tag.cnt || t[p].tag.val) {
    tag(p << 1, t[p].tag);
    tag(p << 1 | 1, t[p].tag);
    t[p].tag = (Data) {0, 0};
  }
}
void modify(int p, int l, int r, int L, int R, Data add) {
  if (l >= L && r <= R) {
    tag(p, add);
    return;
  }
  pushdown(p);
  int mid = l + r >> 1;
  if (mid >= L) {
    modify(p << 1, l, mid, L, R, add);
  } 
  if (mid < R) {
    modify(p << 1 | 1, mid + 1, r, L, R, add);
  }
  pushup(p);
}
inline void modify(int u, int v, Data add) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) {
      swap(u, v);
    }
    modify(1, 1, tot, dfn[top[u]], dfn[u], add);
    u = fa[top[u]];
  }
  if (u ^ v) {
    if (dep[u] > dep[v]) {
      swap(u, v);
    }
    modify(1, 1, tot, dfn[u] + 1, dfn[v], add);
  }
}
int main() {
  freopen("in.txt", "r", stdin);
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  pre(1);
  top[1] = 1;
  dfs(1);
  build(1, 1, tot);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    modify(a[i], b[i], (Data) {i, 1});
  }
  for (int i = 1; i < n; ++i) {
    int cnt = t[1].info.cnt;
    int idx = t[1].info.val;
    int pos = t[1].info.pos;
    if (cnt ^ 1) {
      printf("i = %d\n", i);
      puts("NO");
      return 0;
    }
    modify(1, 1, tot, pos, pos, (Data) {0, 1e9});
    modify(a[idx], b[idx], (Data) {idx, -1});
  }
  puts("YES");
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:129:44: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
  129 |     modify(1, 1, tot, pos, pos, (Data) {0, 1e9});
      |                                            ^~~
Language: C++


#include<bits/stdc++.h>
const int maxn=1e5+10;
using namespace std;
int tot=0,head[maxn],n,x,y,siz[maxn],f[maxn];
struct line{int to,next;}e[maxn*2];
void pushline(int x,int y)
{
	e[++tot].x=y;e[tot].next=head[x],head[x]=tot;
}
bool dfs(int x,int fa)
{
	siz[x]=1;
	int cnt=0;
	for(int i=head[x];int v=e[i].to;i=e[i].next)
	{
		if(v==fa)continue;
		if(dfs(v,x))return 1;
		if(siz[v])
		{
			cnt++,siz[x]=0;
			if(cnt==2)return 1;
		}
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		pushline(x,y);pushline(y,x);
	}
	printf(dfs(1,0)||siz[1]?"First":"Second");
}
/*
*/

Compiler output:
a.cc: In function 'void pushline(int, int)':
a.cc:9:18: error: 'struct line' has no member named 'x'
    9 |         e[++tot].x=y;e[tot].next=head[x],head[x]=tot;
      |                  ^
Language: C++

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

struct custom_hash {
    typedef long long ll;
    typedef unsigned long long ull;
    const ull FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    static ull splitmix64(ull x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(ll x) const {
        return splitmix64(x + FIXED_RANDOM);
    }
    size_t operator()(const pair<int,int> &i)const{
        return splitmix64((((ll)i.first)^(((ll)i.second)<<32))+FIXED_RANDOM);
    }
};

struct ufds{
    int p[100005];

    ufds(){
        for (int x=0;x<100005;x++){
            p[x]=x;
        }
    }
    int parent(int i){return (p[i]==i)?i:p[i]=parent(p[i]);}
    void unions(int i,int j){
        i=parent(i),j=parent(j);
        p[i]=j;
    }
}dsu=*new ufds();



inline long long E(int i,int j){
    if (i>j) return (long long)i<<32|j;
    else return (long long)j<<32|i;
}

inline int f(long long i){
    return i>>32;
}

inline int s(long long i){
    return i&4294967295;
}

int n;
unordered_set<int,custom_hash> al[100005];
unordered_set<long long,custom_hash> edges;
vector<long long> del;

inline INS(long long temp){
    if (edges.count(temp)){
        edges.erase(temp);
        al[f(temp)].erase(s(temp));
        al[s(temp)].erase(f(temp));
        del.push_back(temp);
    }
    else{
        edges.insert(temp);
        al[f(temp)].insert(s(temp));
        al[s(temp)].insert(f(temp));
    }
}

inline DEL(int i,int j){
    edges.erase(E(i,j));
    al[i].erase(j);
}

int main(){
    scanf("%d",&n);
    
    int a,b;
    for (int x=2;x<2*n;x++){
        scanf("%d%d",&a,&b);
        INS(E(a,b));
    }
    
    long long curr;
    int u,v; //u->v merging
    while (!del.empty()){
        curr=del.back(),del.pop_back();
        
        u=dsu.parent(f(curr)),v=dsu.parent(s(curr));
        if (al[u].size()>al[v].size()) swap(u,v);
        
        for (auto &it:al[u]){
            DEL(it,u);
            INS(E(it,v));
        }
        
        dsu.unions(u,v);
    }
    
    if (edges.empty()) printf("YES\n");
    else printf("NO\n");
}

Compiler output:
a.cc:63:8: error: ISO C++ forbids declaration of 'INS' with no type [-fpermissive]
   63 | inline INS(long long temp){
      |        ^~~
a.cc: In function 'int INS(long long int)':
a.cc:75:1: warning: no return statement in function returning non-void [-Wreturn-type]
   75 | }
      | ^
a.cc: At global scope:
a.cc:77:8: error: ISO C++ forbids declaration of 'DEL' with no type [-fpermissive]
   77 | inline DEL(int i,int j){
      |        ^~~
a.cc: In function 'int DEL(int, int)':
a.cc:80:1: warning: no return statement in function returning non-void [-Wreturn-type]
   80 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
const int N = 100005;
set<int> g[N];
int p[N];
int num = 0;
int find(int x){
    return x == p[x] ? x : p[x]=findset(p[x]);
}
void merge(int u, int v){
    u = find(u), v = find(v);
    if (u == v) return;
    if (g[u].size() < g[v].size()) swap(u,v);
    printf("merge %d to %d\n",v,u);
    set<ii> que;
    for (auto &x: g[v]){
        if (x == u) continue;
        //printf("%d connected to %d\n",x,v);
        g[x].erase(v);
        if (g[x].count(u)){
            que.insert({x,u});
        }
        g[u].insert(x);
        g[x].insert(u);
    }
    g[u].erase(v);
    g[v].clear();
    p[v] = u;
    for (auto cur : que){
        merge(cur.first,cur.second);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    iota(p,p+N,0);
    for (int i = 1; i < n; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        g[a].insert(b);
        g[b].insert(a);

    }
    for (int i = 1; i < n; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        a = find(a); b = find(b);
        if (g[a].count(b)) merge(a,b);
        else{
            g[a].insert(b);
            g[b].insert(a);
        }
    }
    int c = find(1);
    printf("%d ",c);
    for (int i = 2; i <= n; i++){
        printf("%d ",find(i));
        if (c != find(i)){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
}


Compiler output:
a.cc: In function 'int find(int)':
a.cc:9:33: error: 'findset' was not declared in this scope
    9 |     return x == p[x] ? x : p[x]=findset(p[x]);
      |                                 ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
const int N = 100005;
set<int> g[N];
int p[N];
int num = 0;
int find(int x){
    return x == p[x] ? x : p[x];
}
void merge(int u, int v){
    u = find(u), v = find(v);
    if (u == v) return;
    if (g[u].size() < g[v].size()) swap(u,v);
    //printf("merge %d to %d\n",v,u);
    num++;
    vector<ii> que;
    for (auto x: g[v]){
        if (x == u) continue;
        //printf("%d connected to %d\n",x,v);
        g[x].erase(v);
        if (g[u].count(x)){
            que.push_back({u,x});
        }
        g[u].insert(x);
        g[x].insert(u);
    }
    p[v] = u;
    for (auto cur : que){
        merge(cur.first,cur.second);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    iota(p,p+N,0);
    for (int i = 0; i < 2*n-2; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        ct[{a,b}]++;
        ct[{b,a}]++;
        if (ct[{a,b}] >= 2) mer(a,b);
    }
    //printf("num %d ",num);
    printf("%s",num==n-1 ? "YES":"NO");
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:9: error: 'ct' was not declared in this scope
   40 |         ct[{a,b}]++;
      |         ^~
a.cc:42:29: error: 'mer' was not declared in this scope; did you mean 'merge'?
   42 |         if (ct[{a,b}] >= 2) mer(a,b);
      |                             ^~~
      |                             merge
Language: C++

#include<cstdio>
using namespace std;
int main(){
    cout<<"Yes";
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cout' was not declared in this scope
    4 |     cout<<"Yes";
      |     ^~~~
a.cc:2:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<cstdio>
  +++ |+#include <iostream>
    2 | using namespace std;
Language: C++

// luogu-judger-enable-o2
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<ctime>
#include<set>
#include<map>
#include<climits>
#include<algorithm>
#include<queue>
#define ll long long
using namespace std;
const int N=100010;
typedef set<int>::iterator It;
set<int> s[N];
queue<pair<int,int> > q;
int n,f[N];
int find(int x) {return f[x]==x?x:f[x]=find(f[x]);}
void erase(int x,int y)
{
	s[x].erase(y);
	s[y].erase(x);
}
void insert(int x,int y)
{
	s[x].insert(y);
	s[y].insert(x);
	if()
}
int main()
{
	int i,j,x,y,t1,t2;
	ll t;
	scanf("%d",&n);
	for(i=1;i<=n;i++) f[i]=i;
	for(i=1;i<2*n-1;i++)
	{
	    scanf("%d%d",&x,&y);
		insert(x,y);
	}
	for(i=1;i<n;i++)
	{
		if(q.empty()) break;
		x=q.front().first,y=q.front().second,q.pop();
		t1=find(x),t2=find(y);
		if(s[t1].size()<s[t2].size()) swap(t1,t2),swap(x,y);
		erase(x,y);
		f[t2]=t1;
		It it,j;
		for(It it=s[t2].begin();it!=s[t2].end();it=j) 
		{
			j=it;j++;
			erase(t2,find(*it));
			insert(t1,find(*it));
		}
	}
	if(i==n) printf("YES");
	else printf("NO");
	return 0;
}


Compiler output:
a.cc: In function 'void insert(int, int)':
a.cc:29:12: error: expected primary-expression before ')' token
   29 |         if()
      |            ^
a.cc:30:1: error: expected primary-expression before '}' token
   30 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
const double pi = acos(-1);
const int BUF_SIZE = (int)1e6 + 10;
template <typename T> inline bool chkmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}
template <typename T> inline bool chkmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
#define getchar IO.getchar
#define putchar IO.putchar
LL read() {
	char ch = getchar();
	LL x = 0, flag = 1;
	for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
	for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
	return x * flag;
}

const int Maxn = 1e5 + 9;
set <int> G[Maxn];
map<pair<int, int>, int> buc;
queue <pair<int, int> > que;
int fa[Maxn], n;
int find(int u) { return (fa[u] ^ u) ? (fa[u] = find(fa[u])) : u; }
void add(int u, int v) { G[u].insert(v); }

void link(int u, int v) {
	add(u, v), add(v, u);
	if (u > v) swap(u, v);
	if (++buc[make_pair(u, v)] == 2) que.push(make_pair(u, v));
}

void Init() {
	n = read();
	rep (i, 1, n) fa[i] = i;
	rep (i, 1, n - 1) link(read(), read());
	rep (i, 1, n - 1) link(read(), read());
}

void Solve() {
	int cnt = 0;
	while (!que.empty()) {
		pair<int, int> p = que.front(); que.pop(); 
		p.first = find(p.first), p.second = find(p.second);
		if (p.first == p.second) continue;

		int u = p.first, v = p.second;
		
		if (G[u].size() > G[v].size()) swap(u, v);
		++cnt, fa[u] = v;

		for (set <int> :: iterator IT = G[u].begin(); IT != G[u].end(); ++IT) {
			int q = find(*IT);
			if (q != v) link(q, v);
		}
	}
	printf("%s\n", cnt == n - 1 ? "YES" : "NO");
}

int main() {
//	freopen("bosky.in", "r", stdin);
//	freopen("bosky.out", "w", stdout);

	Init();
	Solve();

#ifdef Qrsikno
	debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
	return IO.flush();
}



Compiler output:
a.cc: In function 'LL read()':
a.cc:13:17: error: 'IO' was not declared in this scope; did you mean 'EIO'?
   13 | #define getchar IO.getchar
      |                 ^~
a.cc:16:19: note: in expansion of macro 'getchar'
   16 |         char ch = getchar();
      |                   ^~~~~~~
a.cc: In function 'int main()':
a.cc:74:16: error: 'IO' was not declared in this scope; did you mean 'EIO'?
   74 |         return IO.flush();
      |                ^~
      |                EIO
Language: C++

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
#include <complex>
#define pa pair<int,int>
#define mkp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
inline void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
inline void writeln(int x){
	write(x);puts("");
}
const int N=1e5+10;
map<pa,int>mp;
set<int>e[N];
int fa[N];
inline int find(int x){
	if(fa[x]==x)return x;
	return fa[x]=find(fa[x]);
}
int main()
{
	n=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		e[x].insert(y);
		e[y].insert(x);
		pa now=mkp(min(x,y),max(x,y));
		mp[now]++;
		if(mp[now]==3)return puts("NO")&0;
		if(mp[now]==2)q.push(now);
	}
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<n;i++){
		int x,y;
		while(1){
			if(q.empty())return puts("NO")&0;
			x=q.front().fi;y=q.front().se;
			q.pop();
			if(x!=y)break;
		}
		if(e[x].size()>e[y].size())swap(x,y);
		fa[]
	}
	puts("YES");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'n' was not declared in this scope
   43 |         n=read();
      |         ^
a.cc:51:31: error: 'q' was not declared in this scope
   51 |                 if(mp[now]==2)q.push(now);
      |                               ^
a.cc:57:28: error: 'q' was not declared in this scope
   57 |                         if(q.empty())return puts("NO")&0;
      |                            ^
a.cc:58:27: error: 'q' was not declared in this scope
   58 |                         x=q.front().fi;y=q.front().se;
      |                           ^
a.cc:63:20: error: expected primary-expression before ']' token
   63 |                 fa[]
      |                    ^
Language: C++

#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
typedef long long ll;
#define rg register

template <typename _Tp> inline _Tp read(_Tp&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();return x;
}

const int N=101000,ae=20,mod=14233333;
struct Edge{int v,nxt;}a[N*ae<<1];
int qx[N*ae],qy[N*ae],dad[N];
int head[N],_,sz[N];
unordered_map<ll,int> cnt;
int n,he=1,ta=0;

inline int find(int x){return dad[x]?dad[x]=find(dad[x]):x;}

inline void ins(int u,int v){++sz[u],a[++_].v=v,a[_].nxt=head[u],head[u]=_;}

#define h(x,y) ((x+1ll*n*y))
inline void add(int x,int y){
	ins(x,y),ins(y,x);
	if((++cnt[x<y?h(x,y):h(y,x)])==2)
		++ta,qx[ta]=x,qy[ta]=y;
}

int main(){
	read(n);int x,y,p;
	for(rg int i=n-2+n;i;--i)read(x),read(y),add(x,y);
	for(rg int i=1;i<n;++i){
		do	x=qx[he],y=qy[he],++he;
		while(find(x)==find(y)&&he<=ta);
		x=find(x),y=find(y);
		if(x==y){puts("NO");return 0;}
		if(sz[x]>sz[y])swap(x,y);
		cnt[x<y?h(x,y):h(y,x)]=0;
		for(rg int j=head[x];j;j=a[j].nxt){
			p=find(a[j].v);
			if(p^y)add(p,y);
		}dad[x]=y;
	}puts("YES");
	return 0;
}

Compiler output:
a.cc:17:1: error: reference to 'unordered_map' is ambiguous
   17 | unordered_map<ll,int> cnt;
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/14/tr1/unordered_map:44,
                 from a.cc:2:
/usr/include/c++/14/tr1/unordered_map.h:180:11: note: candidates are: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::tr1::unordered_map'
  180 |     class unordered_map
      |           ^~~~~~~~~~~~~
In file included from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/c++/14/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/unordered_map.h:109:11: note:                 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::unordered_map'
  109 |     class unordered_map
      |           ^~~~~~~~~~~~~
a.cc: In function 'void add(int, int)':
a.cc:27:15: error: 'cnt' was not declared in this scope; did you mean 'int'?
   27 |         if((++cnt[x<y?h(x,y):h(y,x)])==2)
      |               ^~~
      |               int
a.cc: In function 'int main()':
a.cc:33:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |         for(rg int i=n-2+n;i;--i)read(x),read(y),add(x,y);
      |                    ^
a.cc:34:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   34 |         for(rg int i=1;i<n;++i){
      |                    ^
a.cc:40:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
   40 |                 cnt[x<y?h(x,y):h(y,x)]=0;
      |                 ^~~
      |                 int
a.cc:41:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   41 |                 for(rg int j=head[x];j;j=a[j].nxt){
      |                            ^
Language: C++

//waz
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
 
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
 
int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}
 
const int N = 1e5 + 10;
 
map<int, int> h[N];
 
set<int> edge[N];
 
queue<PII> q;
 
void link(int u, int v)
{
	edge[u].insert(v);
	edge[v].insert(u);
	if (u > v) swap(u, v);
	++h[u][v];
	if (h[u][v] == 2)
	{
		q.push(now);
	}
	if (h[u][v] > 2)
	{
		puts("NO");
		exit(0);
	}
}
 
void cut(int u, int v)
{
	edge[u].erase(v);
	if (u > v) swap(u, v); 
	h[u].erase(v);
}
 
int fa[N], n;
 
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
 
int main()
{
	gi(n);
	for (int i = 1; i <= n; ++i) fa[i] = i;
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		gii(u, v);
		link(u, v);
	}
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		gii(u, v);
		link(u, v);
	}
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		do
		{
			if (q.empty())
			{
				puts("NO");
				return 0;
			}
			u = q.front().fi;
			v = q.front().se;
			u = find(u);
			v = find(v);
			q.pop();
		} while (u == v);
		if (SZ(edge[u]) > SZ(edge[v])) swap(u, v);
		fa[u] = v;
		cut(v, u);
		for (auto x : edge[u])
		{
			x = find(x);
			if (x == v) continue;
			link(x, v);
			cut(x, u);
		}
		edge[u].clear();
	}
	puts("YES");
	return 0;
} 

Compiler output:
a.cc: In function 'void link(int, int)':
a.cc:52:24: error: 'now' was not declared in this scope; did you mean 'pow'?
   52 |                 q.push(now);
      |                        ^~~
      |                        pow
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<map>
#define Pr pair<int,int>
using namespace std;
const int N=1e5+10;
struct xxx{
	int y,nxt;
}a[N*2];
queue<Pr> q;
map<Pr,int> cnt;
multiset<int> rec[N];
multiset<int>::iterator it,tmpit;
int h[N],f[N];
int req[N][2];
int n,m,tot;
Pr mp(int x,int y){if (x>y) swap(x,y); return make_pair(x,y);}
int get_f(int x){return f[x]=f[x]==x?f[x]:get_f(f[x]);}
bool link(int x,int y){
	Pr tmp;
	rec[x].insert(y); rec[y].insert(x);
	tmp=mp(x,y);
	++cnt[tmp];
	if (cnt[tmp]==2) q.push(tmp);
}
void cut(int x,int y){
	rec[x].erase(y); rec[y].erase(x);
	cnt.erase[mp(x,y)];
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("a.in","r",stdin);
#endif
	Pr tmp;
	int x,y,num;
	scanf("%d",&n);
	memset(h,-1,sizeof(h));
	tot=0;
	cnt.clear();
	for (int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		link(x,y);
	}
	for (int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		link(x,y);
	}
	for (int i=1;i<=n;++i) f[i]=i;
	for (int tm=1;tm<n;++tm){
		if (q.empty()){printf("NO\n"); return 0;}
		x=get_f(q.front().first); y=get_f(q.front().second); q.pop();
		if (x==y) continue;
		if (rec[x].size()>rec[y].size()) swap(x,y);
		f[x]=y;
		cut(x,y);
		for (it=rec[x].begin();it!=rec[x].end();it=tmpit){
			num=*it;
			tmpit=++it;
			num=get_f(num);
			cut(x,num);
			if (num==y) continue;
			link(y,num);
		}
	}
	printf("YES\n");
}

Compiler output:
a.cc: In function 'bool link(int, int)':
a.cc:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
   28 | }
      | ^
a.cc: In function 'void cut(int, int)':
a.cc:31:18: error: no match for 'operator[]' (operand types are '<unresolved overloaded function type>' and 'std::pair<int, int>')
   31 |         cnt.erase[mp(x,y)];
      |                  ^
Language: C++

    queue<Int> mg;
    for(auto z:H[v]){
      if(uf.same(z,v)||!G[v].count(z)) continue;
      mg.emplace(uf.find(z));
    }
    while(!mg.empty()){
      Int u=mg.front();mg.pop();
      u=uf.find(u);
      if(uf.same(u,v)) continue;
	
      if(H[v].size()<H[u].size()) swap(H[v],H[u]);
      if(G[v].size()<G[u].size()) swap(G[v],G[u]);
      
      for(auto x:G[u]){
	Int w=uf.find(x);
	if(H[u].count(x)||H[v].count(x)) mg.emplace(x);
	if(H[u].count(w)||H[v].count(w)) mg.emplace(w);
	G[v].emplace(x);
	G[v].emplace(w);
	G[x].emplace(v);
	G[w].emplace(v);
      }
      for(auto x:H[u]){
	Int w=uf.find(x);
	if(G[u].count(x)||G[v].count(x)) mg.emplace(x);
	if(G[u].count(w)||G[v].count(w)) mg.emplace(w);
	H[v].emplace(x);
	H[v].emplace(w);
	H[x].emplace(v);
	H[w].emplace(v);
      }
      H[u].clear();G[u].clear();
	
      uf.unite(v,u);
    }
    if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
  }
  cout<<(uf.r[uf.find(0)]==n?"YES":"NO")<<endl;
  return 0;
}


Compiler output:
a.cc:1:5: error: 'queue' does not name a type
    1 |     queue<Int> mg;
      |     ^~~~~
a.cc:2:5: error: expected unqualified-id before 'for'
    2 |     for(auto z:H[v]){
      |     ^~~
a.cc:6:5: error: expected unqualified-id before 'while'
    6 |     while(!mg.empty()){
      |     ^~~~~
a.cc:36:5: error: expected unqualified-id before 'if'
   36 |     if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
      |     ^~
a.cc:36:30: error: 'i' does not name a type
   36 |     if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
      |                              ^
a.cc:36:34: error: 'i' does not name a type
   36 |     if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
      |                                  ^
a.cc:37:3: error: expected declaration before '}' token
   37 |   }
      |   ^
a.cc:38:3: error: 'cout' does not name a type
   38 |   cout<<(uf.r[uf.find(0)]==n?"YES":"NO")<<endl;
      |   ^~~~
a.cc:39:3: error: expected unqualified-id before 'return'
   39 |   return 0;
      |   ^~~~~~
a.cc:40:1: error: expected declaration before '}' token
   40 | }
      | ^
Language: C++

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

struct UnionFind{
  Int n;
  vector<Int> r,p;
  UnionFind(){}
  UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    r[x]+=r[y];
    p[y]=x;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  
  vector<set<Int> > G(n),H(n);
  for(Int i=1;i<n;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace(y);
    G[y].emplace(x);
  }
  for(Int i=1;i<n;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    H[x].emplace(y);
    H[y].emplace(x);
  }

  UnionFind uf(n);
  queue<Int> q;
  for(Int i=0;i<n;i++) q.emplace(i);
  Int cnt=0;
  while(!q.empty()){
    Int v=q.front();q.pop();
    if(v!=uf.find(v)) continue;
    queue<Int> mg;
    for(auto z:H[v]){
      if(uf.same(z,v)||!G[v].count(z)) continue;
      mg.emplace(uf.find(z));
    }
    while(!mg.empty()){
      Int u=mg.front();mg.pop();
      u=uf.find(u);
      if(uf.same(u,v)) continue;
	
      if(H[v].size()<H[u].size()) swap(H[v],H[u]);
      if(G[v].size()<G[u].size()) swap(G[v],G[u]);
      
      for(auto x:G[u]){
	Int w=uf.find(x);
	if(H[u].count(x)||H[v].count(x)) mg.emplace(x);
	if(G[u].count(w)||G[v].count(w)) mg.emplace(w);
	G[v].emplace(x);
	G[v].emplace(w);
	G[x].emplace(v);
	G[w].emplace(v);
      }
      for(auto x:H[u]){
	if(G[u].count(x)||G[v].count(x)) mg.emplace(x);
	if(G[u].count(w)||G[v].count(w)) mg.emplace(w);
	H[v].emplace(x);
	H[v].emplace(w);
	H[x].emplace(v);
	H[w].emplace(v);
      }
      H[u].clear();G[u].clear();
	
      uf.unite(v,u);
    }
    if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
  }
  cout<<(uf.r[uf.find(0)]==n?"YES":"NO")<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:76:23: error: 'w' was not declared in this scope
   76 |         if(G[u].count(w)||G[v].count(w)) mg.emplace(w);
      |                       ^
a.cc:78:22: error: 'w' was not declared in this scope
   78 |         H[v].emplace(w);
      |                      ^
Language: C++

#include<bits/stdc++.h>
#define maxn 100009
#define mk make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> P;
multiset<int>st[maxn];
map<P,int>mp;
map<P,int>::iterator it;
multiset<int>::iterator jt;
int fa[maxn],sz[maxn];
queue<P>q;
vector<int>vec[maxn];
int find(int x){if(fa[x]!=x) fa[x]=find(fa[x]);return fa[x];}
int main(){
  int n,x,y;
  scanf("%d",&n);
  for(int i=1;i<n;i++){
    scanf("%d%d",&x,&y);
    st[x].insert(y),st[y].insert(x);
    mp[mk(x,y)]+=1,mp[mk(y,x)]+=1;
  }
  for(int i=1;i<n;i++){
    scanf("%d%d",&x,&y);
    st[x].insert(y),st[y].insert(x);
    mp[mk(x,y)]+=1,mp[mk(y,x)]+=1;
  }
  for(it=mp.begin();it!=mp.end();it++)
    if(it->se==2) q.push(it->fi);
  for(int i=1;i<=n;i++) fa[i]=i,sz[i]=1,vec[i].pb(i);
  for(int T=1;T<n;T++){
  tp:
    if(q.empty()) puts("NO"),exit(0);
    P u=q.front();q.pop();
    mp.erase(u);
    int x=find(u.fi),y=find(u.se);
    if(x==y) goto tp;
    if(sz[x]>sz[y]) swap(x,y);
    for(jt=st[x].begin();jt!=st[x].end();jt++){
      int k=find(*jt);if(k==y) continue;
      st[y].insert(k),st[k].insert(y),mp[mk(y,k)]+=1,mp[mk(k,y)]+=1;
      if(mp[mk(y,k)]==2) q.push(mk(y,k));
      if(mp[mk(k,y)]==2) q.push(mk(k,y));
      st[k].erase(st[k].find(x));
    }
    st[y].erase(x);t
    fa[x]=y,sz[y]+=sz[x];
  }
  puts("YES");
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:20: error: 't' was not declared in this scope
   48 |     st[y].erase(x);t
      |                    ^
Language: C++

#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
vector<int> bi[100005];
int n,m,i,j,x,y,sz[100005],rt;
struct ii
{
	int x,y;
}ed[100005];
void dfs(int x,int fa)
{
	int i;
	for (i=0;i<bi[x].size();i++)
	{
		if (bi[x][i]==fa)
		{
			continue;
		}
		
		getans(
		dfs2(bi[x][i],x);
int main()
{
	cin>>n;
	for (i=1;i<n;i++)
	{
		cin>>x>>y;
		bi[x].push_back(y);
		bi[y].push_back(x);
	}
	for (i=1;i<n;i++)
	{
		cin>>ed[i].x>>ed[i].y;
	}
	dfs2(1,0);
	rt=1;
	for (i=1;i<=n;i++)
	{
		if (max(sz[i],n-sz[i])<max(sz[rt],n-sz[rt]))
		{
			rt=i;
		}
	}
	dfs(rt,0);

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:28:17: error: 'dfs2' was not declared in this scope; did you mean 'dfs'?
   28 |                 dfs2(bi[x][i],x);
      |                 ^~~~
      |                 dfs
a.cc:29:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   29 | int main()
      |         ^~
a.cc:29:9: note: remove parentheses to default-initialize a variable
   29 | int main()
      |         ^~
      |         --
a.cc:29:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:30:1: error: a function-definition is not allowed here before '{' token
   30 | {
      | ^
a.cc:51:19: error: expected '}' at end of input
   51 |         dfs(rt,0);
      |                   ^
a.cc:21:9: note: to match this '{'
   21 |         {
      |         ^
a.cc:51:19: error: expected '}' at end of input
   51 |         dfs(rt,0);
      |                   ^
a.cc:18:1: note: to match this '{'
   18 | {
      | ^
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#define fi first
#define se second
#define N 100010
using namespace std;
typedef pair<int,int>P;
set<int>s[N],s2[N];
set<int>::iterator it;
int n,t,u,v,fa[N];
P q[N<<4];
inline void rd(int& x){
	static char ch;while(!isdigit(ch=getchar()));
	for(x=0;isdigit(ch);ch=getchar())x=x*10+ch-'0';
}
int get(int x){return fa[x]?fa[x]=get(fa[x]):x;}
inline int merge(int u,int v){
	if((u=get(u))==(v=get(v)))return 0;
	if(s[u].size()+s2[u].size()<s[v].size()+s2[v].size())swap(u,v);
	fa[v]=u;
	s[u].erase(s[u].find(v));
	s2[u].erase(s2[u].find(v));
	for(auto x:s[v]){
		if(x==u)continue;
		s[u].insert(x);
		s[x].erase(s[x].find(v));
		s[x].insert(u);
		if(s2[x].find(u)!=s2[x].end())q[++t]=(P){x,u};
	}
	for(auto x:s2[v]){
		if(x==u)continue;
		s2[u].insert(x);
		s2[x].erase(s2[x].find(v));
		s2[x].insert(u);
		if(s[x].find(u)!=s[x].end())q[++t]=(P){x,u};
	}
	return 1;
}
int main(){
	rd(n);
	for(int i=1;i<n;++i){
		rd(u),rd(v);
		s[u].insert(v);
		s[v].insert(u);
	}
	for(int i=1;i<n;++i){
		rd(u),rd(v);
		s2[u].insert(v);
		s2[v].insert(u);
		if(s[u].find(v)!=s[u].end())q[++t]=(P){u,v};
	}
	int tot=n;
	for(int h=1;h<=t;++h)tot-=merge(q[h].fi,q[h].se);
	puts(tot-1?"NO":"YES");
}

Compiler output:
a.cc: In function 'void rd(int&)':
a.cc:15:31: error: 'isdigit' was not declared in this scope
   15 |         static char ch;while(!isdigit(ch=getchar()));
      |                               ^~~~~~~
a.cc:16:17: error: 'isdigit' was not declared in this scope
   16 |         for(x=0;isdigit(ch);ch=getchar())x=x*10+ch-'0';
      |                 ^~~~~~~
Language: C++

#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cstring>

using namespace std;

const int MX=100011,MXT=262333;
int n;
struct Edge{int t,nxt;Edge(int _t=0,int _nxt=0):t(_t),nxt(_nxt){}}e[MX<<1];
int hed[MX],ec;
inline void ade(int f,int t){e[++ec]=Edge(t,hed[f]);hed[f]=ec;}
#define FE(k,i) for(int (i)=hed[k];(i);(i)=e[i].nxt)if(e[i].t!=f)
int sz[MX],fa[MX],d[MX],tp[MX],dc[MX];
int dfn[MX],dfc;
void dfs(int k,int f){
	sz[k]=1;
	FE(k,i)dfs(e[i].t,k),sz[k]+=sz[e[i].t];
}
void tcp(int k,int f,int _d,int _tp,int _dc){
	dfn[++dfc]=k;
	fa[k]=f,d[k]=_d,tp[k]=_tp,dc[k]=_dc;
	int mn=0,no=0;
	FE(k,i)if(sz[e[i].t]>mn)mn=sz[e[i].t],no=e[i].t;
	if(no){
		tcp(no,k,_d+1,_tp,_dc);
		FE(k,i)if(e[i].t!=no)tcp(e[i].t,k,_d+1,e[i].t,_dc+1);
	}
}
struct Seg{
	int mn,mnno;
	int ad;
	Seg(int _mn=0,int _mnno=0):mn(_mn),mnno(_mnno),ad(0){}
	inline void add(int x){ad+=x,mn+=x;}
}sg[MXT];
inline Seg operator+(const Seg &l,const Seg &r){return l.mn<=r.mn?Seg(l.mn,l.mnno):Seg(r.mn,r.mnno);}
inline void psdw(int no){if(sg[no].ad)sg[no<<1].add(sg[no].ad),sg[no<<1|1].add(sg[no].ad),sg[no].ad=0;}
inline void add(int no,int l,int r,int ll,int rr,int v){
	if(ll<=l&&rr>=r)sg[no].add(v);
	else{
		psdw(no);
		int mid=(l+r)>>1;
		if(ll<=mid)add(no<<1,l,mid,ll,rr,v);
		if(rr>mid)add(no<<1|1,mid+1,r,ll,rr,v);
		sg[no]=sg[no<<1]+sg[no<<1|1];
	}
}
inline Seg que(int no,int l,int r,int ll,int rr){
	if(ll<=l&&rr>=r)return sg[no];
	else{
		psdw(no);
		int mid=(l+r)>>1;
		if(rr<=mid)return que(no<<1,l,mid,ll,rr);
		else if(ll>mid)return que(no<<1|1,mid+1,r,ll,rr);
		else return que(no<<1,l,mid,ll,mid)+que(no<<1|1,mid+1,r,mid+1,rr);
	}
}
void build(int no,int l,int r){
	if(l==r)sg[no]=Seg(0,l);
	else{
		int mid=(l+r)>>1;
		build(no<<1,l,mid),build(no<<1|1,mid+1,r);
		sg[no]=sg[no<<1]+sg[no<<1|1];
	}
}
int C[MX],D[MX];
int xs[MX];
#define lbt(i) ((i)&(-(i)))
inline void upd(int x,int v){for(int i=x;i<=n;i+=lbt(i))xs[i]^=v;}
inline int que(int x){int r=0;for(int i=x;i;i^=lbt(i))r^=xs[i];return r;}
void add(int no,int V){
	int u=C[no],v=D[no];
	while(tp[u]!=tp[v]){
		if(dc[u]<dc[v])swap(u,v);
		add(1,2,n,dfn[tp[u]],dfn[u],V);
		upd(dfn[tp[u]],no),upd(dfn[u]+1,no);
		u=fa[tp[u]];
	}
	if(d[u]<d[v])swap(u,v);
	if(v!=u){
		add(1,2,n,dfn[v]+1,dfn[u],V);
		upd(dfn[v]+1,no);
		upd(dfn[u]+1,no);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		static int a,b;scanf("%d%d",&a,&b);
		ade(a,b),ade(b,a);
	}
	dfs(1,0);tcp(1,0,1,1,1);
	build(1,2,n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&C[i],&D[i]);
		add(i,1);
	}
	for(int i=1;i<n;i++){
		if(sg[1].mn>1)return puts("NO"),0;
		int no=que(sg[1].mnno);
		add(1,2,n,sg[1].mnno,sg[1].mnno,3);
		add(no,-1);
	}
	puts("YES");
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:87:9: error: 'scanf' was not declared in this scope
   87 |         scanf("%d",&n);
      |         ^~~~~
a.cc:99:38: error: 'puts' was not declared in this scope
   99 |                 if(sg[1].mn>1)return puts("NO"),0;
      |                                      ^~~~
a.cc:104:9: error: 'puts' was not declared in this scope
  104 |         puts("YES");
      |         ^~~~
Language: Java

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	long toKey(int a, int b) {
		if (a < b) {
			return (long) b << 32 | a;
		} else {
			return (long) a << 32 | b;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<Integer>[] g = new Set[N];
		for (int i = 0; i < N; ++i) {
			g[i] = new HashSet<>();
		}
		ArrayDeque<Long> pend = new ArrayDeque<>();
		for (int i = 0; i < 2 * (N - 1); ++i) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			--a;
			--b;
			if (g[a].contains(b)) {
				pend.add(toKey(a, b));
			}
			g[a].add(b);
			g[b].add(a);
		}
		DJSet ds = new DJSet(N);
		boolean[] contracted = new boolean[N];
		while (!pend.isEmpty()) {
			long key = pend.poll();
			int a = (int) (key >> 32);
			int b = (int) (key);
			if (ds.equiv(a, b) || contracted[a] || contracted[b])
				continue;
			ds.setUnion(a, b);
			if (g[a].size() < g[b].size()) {
				int tmp = a;
				a = b;
				b = tmp;
			}
			g[a].remove(b);
			g[b].remove(a);
			for (int v : g[b]) {
				g[v].remove(b);
				g[v].add(a);
				if (g[a].contains(v)) {
					pend.add(toKey(v, a));
			}
			g[a].addAll(g[b]);
			g[b].clear();
			contracted[b] = true;
		}
		if (ds.size(0) == N) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

	class DJSet {
		int n;
		int[] upper;

		public DJSet(int n) {
			this.n = n;
			upper = new int[n];
			Arrays.fill(upper, -1);
		}

		boolean equiv(int x, int y) {
			return root(x) == root(y);
		}

		int root(int x) {
			return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
		}

		void setUnion(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (size(x) < size(y)) {
				int tmp = x;
				x = y;
				y = tmp;
			}
			upper[x] += upper[y];
			upper[y] = x;
		}

		int size(int x) {
			return -upper[root(x)];
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


Compiler output:
Main.java:109: error: illegal start of expression
	private static void tr(Object... o) {
	^
1 error
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int N;

vector<set<int> > G;
vector<set<int> > T;

int main() {
    ios::sync_with_stdio(false);
    cin >> N;
    G.resize(N);
    T.resize(N);
    for (int i = 1;i < N;i++) {
    	int a, b;
    	cin >> a >> b;
    	a--;
    	b--;
    	G[a].insert(b);
    	G[b].insert(a);
    }
    for (int i = 1;i < N;i++) {
    	int a, b;
    	cin >> a >> b;
    	a--;
    	b--;
    	T[a].insert(b);
    	T[b].insert(a);
    }
    queue<int> D;
	set<int> E;
    for (int i = 0;i < N;i++) {
    	if (G[i].size() == 1 && T[i].size() == 1) {
    		D.push(i);
    		E.insert(m);
    	}
    }
    while (D.size() > 0) {
    	int m = D.front();
    	D.pop();
    	x++;
    	set<int> f;
    	for (auto it : G[m]) {
    		G[it].erase(m);
    		f.insert(it);
    	}
    	for (auto it : T[m]) {
    		T[it].erase(m);
    		f.insert(it);
    	}
    	G[m].clear();
    	T[m].clear();
    	for (auto it : f) {
    		if (G[it].size() <= 1 && T[it].size() <= 1 && E.find(it) == E.end()) {
    			D.push(it);
    			E.insert(it);
    		}
    	}
    }
    if (E.size() == N) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:26: error: 'm' was not declared in this scope
   57 |                 E.insert(m);
      |                          ^
a.cc:63:9: error: 'x' was not declared in this scope
   63 |         x++;
      |         ^
Language: C

using System;
class A{static void Main(){Console.WriteLine("YES");}}

Compiler output:
main.c:1:1: error: unknown type name 'using'
    1 | using System;
      | ^~~~~
main.c:2:1: error: unknown type name 'class'
    2 | class A{static void Main(){Console.WriteLine("YES");}}
      | ^~~~~
main.c:2:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    2 | class A{static void Main(){Console.WriteLine("YES");}}
      |        ^
Language: C

#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main()
{
int a;
cout<<"YES"<endl;
	return 0;
}

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

#include<stdio.h>
#include "stdafx.h"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main()
{
int a;
cout<<"YES"<endl;
	return 0;
}

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

まず黒い木の上に赤いpathをいっぱい書いて、それぞれの辺を赤いpathが何回通ったかと言うのを持っておくと、値が1のときにそのpathを消す、という操作を最後までできれば良くて、これはもとの木がpathの形なら区間minと区間addで出来て(どのpathか?っていうのはidのsumみたいなのを別に持つ),木だとHL_decompすればいい気がしたんですけど、正しい方針がわかりません。助けてください。

Compiler output:
a.cc:1:1: error: extended character 、 is not valid in an identifier
    1 | まず黒い木の上に赤いpathをいっぱい書いて、それぞれの辺を赤いpathが何回通ったかと言うのを持っておくと、値が1のときにそのpathを消す、という操作を最後までできれば良くて、これはもとの木がpathの形なら区間minと区間addで出来て(どのpathか?っていうのはidのsumみたいなのを別に持つ),木だとHL_decompすればいい気がしたんですけど、正しい方針がわかりません。助けてください。
      | ^
a.cc:1:1: error: extended character 、 is not valid in an identifier
a.cc:1:1: error: extended character 、 is not valid in an identifier
a.cc:1:1: error: extended character 、 is not valid in an identifier
a.cc:1:273: error: extended character 、 is not valid in an identifier
    1 | まず黒い木の上に赤いpathをいっぱい書いて、それぞれの辺を赤いpathが何回通ったかと言うのを持っておくと、値が1のときにそのpathを消す、という操作を最後までできれば良くて、これはもとの木がpathの形なら区間minと区間addで出来て(どのpathか?っていうのはidのsumみたいなのを別に持つ),木だとHL_decompすればいい気がしたんですけど、正しい方針がわかりません。助けてください。
      |                                                                                                                                                                                                                                                                                 ^
a.cc:1:273: error: extended character 。 is not valid in an identifier
a.cc:1:273: error: extended character 。 is not valid in an identifier
a.cc:1:220: error: expected constructor, destructor, or type conversion before '(' token
    1 | まず黒い木の上に赤いpathをいっぱい書いて、それぞれの辺を赤いpathが何回通ったかと言うのを持っておくと、値が1のときにそのpathを消す、という操作を最後までできれば良くて、これはもとの木がpathの形なら区間minと区間addで出来て(どのpathか?っていうのはidのsumみたいなのを別に持つ),木だとHL_decompすればいい気がしたんですけど、正しい方針がわかりません。助けてください。
      |                                                                                                                                                                                                                            ^