Language: C++

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

int n,memo[100005];
multiset<pair<int,long long>> edge[100005];

void dfs(int now)
{#include <bits/stdc++.h>
using namespace std;

multiset<int> edge[100005];
int memo[100005]={};

void dfs(int now)
{
	for (auto i = edge[now].begin(); i != edge[now].end(); ++i)
	{
		if (memo[*i]==0)
		{
			memo[*i]=1;
			dfs(*i);
		}
	}
}

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	int x,y,z;
	for (int i = 0; i < m; ++i)
	{
		cin>>x>>y>>z;--x;--y;
		edge[x].insert(y);
		edge[y].insert(x);
	}
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		if(memo[i]==0)
		{
			memo[i]=1;
			++ans;
			dfs(i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

	for (auto i = edge[now].begin(); i != edge[now].end(); ++i)
	{
		auto p=*i;
		if (memo[p.first]==-1)
		{
			memo[p.first]=memo[now];
			if (p.second%2LL==1)
			{
				++memo[p.first];
				memo[p.first]%=2;
			}
			dfs(p.first);
		}
	}
}

int main(int argc, char const *argv[])
{
	cin>>n;
	int u,v;
	long long w;
	for (int i = 0; i < n-1; ++i)
	{
		cin>>u>>v>>w;--u;--v;
		edge[u].insert(make_pair(v,w));
		edge[v].insert(make_pair(u,w));
	}
	for (int i = 0; i < n; ++i)
	{
		memo[i]=-1;
	}
	memo[0]=0;
	dfs(0);
	for (int i = 0; i < n; ++i)
	{
		cout<<memo[i]<<endl;
	}
	return 0;
}


Compiler output:
a.cc:8:2: error: stray '#' in program
    8 | {#include <bits/stdc++.h>
      |  ^
a.cc: In function 'void dfs(int)':
a.cc:8:3: error: 'include' was not declared in this scope
    8 | {#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:8:12: error: 'bits' was not declared in this scope
    8 | {#include <bits/stdc++.h>
      |            ^~~~
a.cc:8:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
    8 | {#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
a.cc:9:1: error: expected primary-expression before 'using'
    9 | using namespace std;
      | ^~~~~
a.cc:15:1: error: a function-definition is not allowed here before '{' token
   15 | {
      | ^
a.cc:27:1: error: a function-definition is not allowed here before '{' token
   27 | {
      | ^
a.cc:54:28: error: request for member 'first' in 'p', which is of non-class type 'int'
   54 |                 if (memo[p.first]==-1)
      |                            ^~~~~
a.cc:56:32: error: request for member 'first' in 'p', which is of non-class type 'int'
   56 |                         memo[p.first]=memo[now];
      |                                ^~~~~
a.cc:57:31: error: request for member 'second' in 'p', which is of non-class type 'int'
   57 |                         if (p.second%2LL==1)
      |                               ^~~~~~
a.cc:59:42: error: request for member 'first' in 'p', which is of non-class type 'int'
   59 |                                 ++memo[p.first];
      |                                          ^~~~~
a.cc:60:40: error: request for member 'first' in 'p', which is of non-class type 'int'
   60 |                                 memo[p.first]%=2;
      |                                        ^~~~~
a.cc:62:31: error: request for member 'first' in 'p', which is of non-class type 'int'
   62 |                         dfs(p.first);
      |                               ^~~~~