Language: C++

//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>

using namespace std;

const long long N = 2e5 + 5;
const long long M = 20;

long long n, m;
long long a[N];
long long ans;
long long cnt[M];
long long dp[1 << M];
long long dp2[1 << M];
vector<long long> v;

long long main()
{
	cin >> n;
	for (long long i = 1; i < n; i++)
	{
		long long u, v, x;
		cin >> v >> u >> x;
		a[u] = a[u] ^ x;
		a[v] = a[v] ^ x;
	}
	for (long long i = 0; i < n; i++)
	{
		cnt[a[i]]++;
	}
	ans = cnt[0];
	for (long long i = 1; i < n; i++)
	{
		if (cnt[a[i]] % 2)
		{
			v.push_back(a[i]);
		}
		ans += cnt[a[i]] / 2;
	}
	m = v.size();
	for (long long i = 0; i < (1 << m); i++)
	{
		for (long long j = 0; j < m; j++)
		{
			if ((i >> j) % 2 == 1)
			{
				dp2[i] ^= v[j];
			}
		}
	}
	for (long long mask = 1; mask < (1 << m); mask++)
	{
		if (dp2[mask] != 0)
		{
			continue;
		}
		dp[mask] = 1;
		long long mask2 = mask;
		while (mask2 > 0)
		{
			mask2 = (mask2 - 1) & mask;
			if (!dp2[mask2])
			{
				dp[mask] = max(dp[mask], dp[mask2] + dp[mask ^ mask2]);
			}
		}
	}
	cout << max(n - ans - dp[(1 << m) - 1], 0) << endl;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:80:20: error: no matching function for call to 'max(long long int, int)'
   80 |         cout << max(n - ans - dp[(1 << m) - 1], 0) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:80:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   80 |         cout << max(n - ans - dp[(1 << m) - 1], 0) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:80:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   80 |         cout << max(n - ans - dp[(1 << m) - 1], 0) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~