Language: C++

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define loop(i, n) for(int i = 0 ; i < n ; ++i)
#define LOOP(i, a, b) for(int i = a ; i < b ; ++i)
#define max3(a, b, c) max(a, max(b,c))
#define max4(a, b, c, d) max3(a, b, max(c, d))
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18
#define inf 1e9
#define MOD 1000000007 //check
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int n, d[100005];
vvi e;
ll dp[100005][2];
bool vis[100005];

void bfs(int x){
	queue<int> q;
	vis[x] = 1;
	q.push(x);
	d[x] = 0;
	while(!q.empty()){
		int c = q.front();
		q.pop();
		for(auto i:e[c]){
			if(vis[i]) continue;
			vis[i] = 1;
			d[i] = d[c] + 1;
			q.push(i);
		}
	}
}

ll color(int i, int l)
{
	ll &ans = dp[i][l];
	if(ans != -1LL) return ans;
	ans = 1;
	bool f = 0;
	for(auto it : e[i])
	{
		if(d[it] < d[i]) continue;
		f = 1;
		if(l) ans *= color(it, 0);
		else ans *= color(it, 0) + color(it, 1);
	}
	ans %= MOD;
	if(!f) ans = 1;
	return ans;
}
int main() {
	_69e27;
	memset(vis, 0, sizeof(vis));
	memset(dp, -1LL, sizeof(dp));
	cin >> n;
	e.resize(n+5);
	loop(i, n-1)
	{
		int in1, in2;
		cin >> in1 >> in2;
		e[in1].pb(in2);
		e[in2].pb(in1);
	}

	bfs(1);
	cout << color(1, 0) + color(1, 1);
	return 0;
}#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define loop(i, n) for(int i = 0 ; i < n ; ++i)
#define LOOP(i, a, b) for(int i = a ; i < b ; ++i)
#define max3(a, b, c) max(a, max(b,c))
#define max4(a, b, c, d) max3(a, b, max(c, d))
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18
#define inf 1e9
#define MOD 1000000007 //check
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int n, d[100005];
vvi e;
ll dp[100005][2];
bool vis[100005];

void bfs(int x){
	queue<int> q;
	vis[x] = 1;
	q.push(x);
	d[x] = 0;
	while(!q.empty()){
		int c = q.front();
		q.pop();
		for(auto i:e[c]){
			if(vis[i]) continue;
			vis[i] = 1;
			d[i] = d[c] + 1;
			q.push(i);
		}
	}
}

ll color(int i, int l)
{
	ll &ans = dp[i][l];
	if(ans != -1LL) return ans;
	ans = 1;
	bool f = 0;
	for(auto it : e[i])
	{
		if(d[it] < d[i]) continue;
		f = 1;
		if(l) ans *= color(it, 0);
		else ans *= color(it, 0) + color(it, 1);
	}
	ans %= MOD;
	if(!f) ans = 1;
	return ans;
}
int main() {
	_69e27;
	memset(vis, 0, sizeof(vis));
	memset(dp, -1LL, sizeof(dp));
	cin >> n;
	e.resize(n+5);
	loop(i, n-1)
	{
		int in1, in2;
		cin >> in1 >> in2;
		e[in1].pb(in2);
		e[in2].pb(in1);
	}

	bfs(1);
	cout << color(1, 0) + color(1, 1);
	return 0;
}

Compiler output:
a.cc:86:2: error: stray '#' in program
   86 | }#include <iostream>
      |  ^
a.cc:86:3: error: 'include' does not name a type
   86 | }#include <iostream>
      |   ^~~~~~~
a.cc:115:5: error: redefinition of 'int n'
  115 | int n, d[100005];
      |     ^
a.cc:30:5: note: 'int n' previously declared here
   30 | int n, d[100005];
      |     ^
a.cc:115:8: error: redefinition of 'int d [100005]'
  115 | int n, d[100005];
      |        ^
a.cc:30:8: note: 'int d [100005]' previously declared here
   30 | int n, d[100005];
      |        ^
a.cc:116:5: error: redefinition of 'std::vector<std::vector<int> > e'
  116 | vvi e;
      |     ^
a.cc:31:5: note: 'std::vector<std::vector<int> > e' previously declared here
   31 | vvi e;
      |     ^
a.cc:117:4: error: redefinition of 'long long int dp [100005][2]'
  117 | ll dp[100005][2];
      |    ^~
a.cc:32:4: note: 'long long int dp [100005][2]' previously declared here
   32 | ll dp[100005][2];
      |    ^~
a.cc:118:6: error: redefinition of 'bool vis [100005]'
  118 | bool vis[100005];
      |      ^~~
a.cc:33:6: note: 'bool vis [100005]' previously declared here
   33 | bool vis[100005];
      |      ^~~
a.cc:120:6: error: redefinition of 'void bfs(int)'
  120 | void bfs(int x){
      |      ^~~
a.cc:35:6: note: 'void bfs(int)' previously defined here
   35 | void bfs(int x){
      |      ^~~
a.cc:137:4: error: redefinition of 'long long int color(int, int)'
  137 | ll color(int i, int l)
      |    ^~~~~
a.cc:52:4: note: 'long long int color(int, int)' previously defined here
   52 | ll color(int i, int l)
      |    ^~~~~
a.cc:154:5: error: redefinition of 'int main()'
  154 | int main() {
      |     ^~~~
a.cc:69:5: note: 'int main()' previously defined here
   69 | int main() {
      |     ^~~~