Language: C++

#include<bits/stdc++.h>

#define file(s) freopen(s".in","r",stdin), freopen(s".out","w",stdout)

#define Grt ch=getchar()
#define DeBug(x) std::cout<<#x<<'='<<x<<std::endl

const int MaxN=2e5+10;

namespace IO
{
	char buf[1<<15], *fs, *ft;
	inline char getc() { return ft==fs && (ft=(fs=buf)+fread(buf, 1, 1<<15, stdin), ft==fs) ? 0 : *fs++; }
	template <typename T> inline void read(T &x)
	{
		x=0;
		T f=1, Grt;
		while (!isdigit(ch) && ch^'-') Grt;
		if (ch=='-') f=-1, Grt;
		while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), Grt;
		x*=f;
	}

	template <typename T, typename... Args>
	inline void read(T &x, Args &...args) { read(x); read(args...); }

	char Out[1<<24], *fe=Out;
	inline void flush() { fwrite(Out, 1, fe-Out, stdout); fe=Out; }
	template <typename T> inline void write(T x, char str)
	{
		if (!x) *fe++=48;
		if (x<0) *fe++='-', x=-x;
		T num=0, ch[20];
		while (x) ch[++num]=x%10+48, x/=10;
		while (num) *fe++=ch[num--];
		*fe++=str;
	}
}

using IO::read;
using IO::write;

template <typename T> inline bool chkMin(T &a, const T &b) { return a>b ? (a=b, true) : false; }
template <typename T> inline bool chkMax(T &a, const T &b) { return a<b ? (a=b, true) : false; }
template <typename T> inline T min(T a, T b) { return a<b ? a : b; }
template <typename T> inline T max(T a, T b) { return a>b ? a : b; }

int v[MaxN], cnt[20], d[MaxN];
bool xr[MaxN];
int main()
{
    int n, ans=0, state=0; read(n);
    for  (int i=1,u,v,va; i<n; ++i)  read(x, y, z), v[x]^=z, v[y]^=z;
    for (int i=0; i< n; ++i) ++cnt[v[i]]; //贪心
    for (int i=1; i<=15; ++i) ans+=cnt[i]/2, state|=(cnt[i]&1)<<(i-1);

    for (int i=1; i< (1<<15) ++i) d[i]=d[i>>1]+(i&1);
    for (int i=1; i< (1<<15) ++i) --d[i];//预处理每个dp值的下界
    for (int i=1; i< (1<<15) ++i)
        for (int j=0; j< 15; ++j)
			if((i>>j)&1)sxr[i]^=(j+1);//预处理集合的异或和

    for (int i=1; i< (1<<15) ++i)//枚举子集进行转移
    {
        if (xr[i]!=0)continue;
        for (int k=(i-1)&i; k; k=(k-1)&i)
            if (xr[k]==0) chkMin(d[i], d[k]+d[i^k]);
    }
    write(ans+f[state], '\n');
    IO::flush();
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:43: error: 'x' was not declared in this scope
   53 |     for  (int i=1,u,v,va; i<n; ++i)  read(x, y, z), v[x]^=z, v[y]^=z;
      |                                           ^
a.cc:53:46: error: 'y' was not declared in this scope
   53 |     for  (int i=1,u,v,va; i<n; ++i)  read(x, y, z), v[x]^=z, v[y]^=z;
      |                                              ^
a.cc:53:49: error: 'z' was not declared in this scope
   53 |     for  (int i=1,u,v,va; i<n; ++i)  read(x, y, z), v[x]^=z, v[y]^=z;
      |                                                 ^
a.cc:57:24: error: increment of read-only location '(1 << 15)'
   57 |     for (int i=1; i< (1<<15) ++i) d[i]=d[i>>1]+(i&1);
      |                      ~~^~~~~
a.cc:57:24: error: lvalue required as increment operand
a.cc:57:32: error: expected ';' before 'i'
   57 |     for (int i=1; i< (1<<15) ++i) d[i]=d[i>>1]+(i&1);
      |                                ^
      |                                ;
a.cc:58:24: error: increment of read-only location '(1 << 15)'
   58 |     for (int i=1; i< (1<<15) ++i) --d[i];//预处理每个dp值的下界
      |                      ~~^~~~~
a.cc:58:24: error: lvalue required as increment operand
a.cc:58:32: error: expected ';' before 'i'
   58 |     for (int i=1; i< (1<<15) ++i) --d[i];//预处理每个dp值的下界
      |                                ^
      |                                ;
a.cc:59:24: error: increment of read-only location '(1 << 15)'
   59 |     for (int i=1; i< (1<<15) ++i)
      |                      ~~^~~~~
a.cc:59:24: error: lvalue required as increment operand
a.cc:59:32: error: expected ';' before 'i'
   59 |     for (int i=1; i< (1<<15) ++i)
      |                                ^
      |                                ;
a.cc:61:37: error: 'sxr' was not declared in this scope; did you mean 'xr'?
   61 |                         if((i>>j)&1)sxr[i]^=(j+1);//预处理集合的异或和
      |                                     ^~~
      |                                     xr
a.cc:63:24: error: increment of read-only location '(1 << 15)'
   63 |     for (int i=1; i< (1<<15) ++i)//枚举子集进行转移
      |                      ~~^~~~~
a.cc:63:24: error: lvalue required as increment operand
a.cc:63:32: error: expected ';' before 'i'
   63 |     for (int i=1; i< (1<<15) ++i)//枚举子集进行转移
      |                                ^
      |                                ;
a.cc:69:15: error: 'f' was not declared in this scope
   69 |     write(ans+f[state], '\n');
      |               ^