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

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int n;
int N = 100100;
int dp[N][2];
int head[N << 1], nxt[N << 1], to[N << 1];
int edgeCount;
int md = 1e9+7;
void addEdge(int x, int y)
{
    to[edgeCount] = y;
    nxt[edgeCount] = head[x];
    head[x] = edgeCount;
    ++edgeCount;
}
int f(int u, int p, bool blockBlack)
{
    int &ret = dp[u][blockBlack];
    if (~ret) return ret;
    ll ret1 = 1;
    ll ret2 = !blockBlack;
    for (int v = head[u]; ~v; v = nxt[v])
        if (to[v] != p)
        {
            ret1 *= f(to[v], u, 0);
            if (ret1 >= md)
                ret1 %= md;
            if (!blockBlack)
            {
                ret2 *= f(to[v], u, 1);
                if (ret2 >= md)
                    ret2 %= md;
            }
        }
    ret1 += ret2;
    if (ret1 >= md)
        ret1 -= md;
    return ret = ret1;
}
int main()
{
    memset(head, -1, sizeof head);
    memset(dp, -1, sizeof dp);

    scanf("%d", &n);
    for (int i = 1, x, y; i < n; ++i)
    {
        scanf("%d%d", &x, &y);
        --x; --y;
        addEdge(x, y);
        addEdge(y, x);
    }
    printf("%d\n", f(0, 0, 0));

    return 0;
}


Compiler output:
a.cc:8:8: error: size of array 'dp' is not an integral constant-expression
    8 | int dp[N][2];
      |        ^
a.cc:9:12: error: size of array 'head' is not an integral constant-expression
    9 | int head[N << 1], nxt[N << 1], to[N << 1];
      |          ~~^~~~
a.cc:9:25: error: size of array 'nxt' is not an integral constant-expression
    9 | int head[N << 1], nxt[N << 1], to[N << 1];
      |                       ~~^~~~
a.cc:9:37: error: size of array 'to' is not an integral constant-expression
    9 | int head[N << 1], nxt[N << 1], to[N << 1];
      |                                   ~~^~~~
Language: C++

#include <climits>
#include <cstring>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <fstream>
using namespace std;

//Primitive Data Type Stuff
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;

const int MAX_V = 1e5;
int N;

const int mod = 1e9 + 7;

ll White[1 + MAX_V];
ll Black[1 + MAX_V];

std::vector<int> edges[1 + MAX_V];

void dfs(int v, int p) {
	Black[v] = 1;
	White[v] = 1;
	for (int c : edges[v])
	{
		if (c == p)
			continue;
		dfs(c, v);
		Black[v] = (ll)Black[v] * White[c] % MOD;
		White[v] = (ll)White[v] * (White[c] + Black[c]) % MOD;
	}
}

int main() {
	re(N);
	for (int i = 0; i < N - 1; i++)
	{
		int a, b;
		re(a, b);
		edges[a].pb(b);
		edges[b].pb(a);
	}
	dfs(1, -1);
	int answer = (White[1] + Black[1]) % MOD;
	cout << answer;
	return 0;
}




Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:43:54: error: 'MOD' was not declared in this scope
   43 |                 Black[v] = (ll)Black[v] * White[c] % MOD;
      |                                                      ^~~
a.cc: In function 'int main()':
a.cc:49:9: error: 're' was not declared in this scope
   49 |         re(N);
      |         ^~
a.cc:54:26: error: 'class std::vector<int>' has no member named 'pb'
   54 |                 edges[a].pb(b);
      |                          ^~
a.cc:55:26: error: 'class std::vector<int>' has no member named 'pb'
   55 |                 edges[b].pb(a);
      |                          ^~
a.cc:58:46: error: 'MOD' was not declared in this scope
   58 |         int answer = (White[1] + Black[1]) % MOD;
      |                                              ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int>edges[max];
const int mod=1e9+7;
void dfs(int a,int parent){
  int all_white=1;
  int sth_is_black=0;
 for(int b:edges[a])
 {
   if(b!=parent){
     pair<int,int>p=dfs(b,a);
   int memo_all_white=all_white;
   all_white=mul(memo_all_white,p.first);
   +mul(sth_is_black,p.first+p.second)%mod;
  }
}
retrun make_pair(all_white,(all_white+sth_is_black)%mod;
                 
}
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n-1;i++)
  {
    int a,b;
    cin>>a>>b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
 pair<int,int>p=dfs(1,-1);
  int answer={p.first+p.second}%mod;
  printf("%d",answer);
}
  

Compiler output:
a.cc:3:21: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int'
    3 | vector<int>edges[max];
      |                     ^
a.cc:3:12: error: size of array 'edges' has non-integral type '<unresolved overloaded function type>'
    3 | vector<int>edges[max];
      |            ^~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:11:24: error: conversion from 'void' to non-scalar type 'std::pair<int, int>' requested
   11 |      pair<int,int>p=dfs(b,a);
      |                     ~~~^~~~~
a.cc:13:14: error: 'mul' was not declared in this scope; did you mean 'fmul'?
   13 |    all_white=mul(memo_all_white,p.first);
      |              ^~~
      |              fmul
a.cc:17:1: error: 'retrun' was not declared in this scope
   17 | retrun make_pair(all_white,(all_white+sth_is_black)%mod;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:30:20: error: conversion from 'void' to non-scalar type 'std::pair<int, int>' requested
   30 |  pair<int,int>p=dfs(1,-1);
      |                 ~~~^~~~~~
a.cc:31:32: error: expected ',' or ';' before '%' token
   31 |   int answer={p.first+p.second}%mod;
      |                                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define ll long long
#define mod 1e9+7 
#define pb push_back
#define mb make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<ll> adj[100010];
ll v[100010];
ll dp[100010][2];
void dfs(ll i , ll p ){
	dp[i][0]=1;
	dp[i][1]=1;
	for(auto u:adj[i]){
		if(u!=p){
			dfs(u,i);
			dp[i][0] *= (dp[u][0]+dp[u][1]);
			dp[i][0]%=mod;
			dp[i][1] *= (dp[u][0]);
			dp[i][1]%=mod;
		}
	}
	
}
int main(){
	IOS;
	ll n; cin >> n;
	for(ll i = 1 ; i <= n; i++)
		v[i]=0,adj[i].clear();
	memset(dp,0,sizeof(dp));
	for(ll i = 0 ; i < n-1; i++){
		ll a,b; cin >> a >> b;
		adj[a].pb(b),adj[b].pb(a);
	}
	dfs(1,0);
	cout << (dp[1][0]+dp[1][1])%mod << endl;
	return 0;
}




Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:34:33: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   34 |                         dp[i][0]%=mod;
      |                                 ^
a.cc:34:33: note:   in evaluation of 'operator%=(long long int, double)'
a.cc:36:33: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   36 |                         dp[i][1]%=mod;
      |                                 ^
a.cc:36:33: note:   in evaluation of 'operator%=(long long int, double)'
a.cc: In function 'int main()':
a.cc:52:36: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   52 |         cout << (dp[1][0]+dp[1][1])%mod << endl;
      |                 ~~~~~~~~~~~~~~~~~~~^
      |                          |
      |                          long long int
Language: C++

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

const int mod = 1e9+7;
const int mx = 1e5+7;
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
int mul(int a, int b){
  return (ll)a * b % mod;
}
vector<int> edges[mx];
pair<int,int> dfs(int a, int parent){
  int all_white = 1, some_black = 0;
  for(int i=0;i<edges[a].size();i++){
    if(edges[a][i]!=parent){
      pair<int,int> p = dfs(edges[a][i],a);
      int memo_white = all_white;
      all_white = mul(all_white,p.second);
      some_black =  (mul(memo_white,p.first)+mul(some_black,p.first+p.second))%mod;
    }
  }
  return make_pair(all_white, (all_white+some_black)%mod);
}
int main(){
  int n;
  scanf("%d", &n);
  for(int i=0;i<n-1;++i){
    int a,b;
    scanf("%d%d", &a,&b);
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  pair<int,int> p = dfs(1,-1);
  int ans = (p.first+p.second)%mod;
  printf("%d", ans);
}


Compiler output:
a.cc: In function 'int mul(int, int)':
a.cc:14:11: error: 'll' was not declared in this scope
   14 |   return (ll)a * b % mod;
      |           ^~
a.cc:14:14: error: expected ';' before 'a'
   14 |   return (ll)a * b % mod;
      |              ^
      |              ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
 bool visited[100001];
 long long int p=1000000007;
 vector<long long int> v[100001];
 long long int dp[2][100001];
void dfs(int u){
    visited[u]=true;
    for(int i=0;i<v[u].size();i++){
        if(!visited[v[u][i]]){
            dfs(v[u][i]);
            dp[0][u]=(dp[0][u]%p*(dp[0][v[u][i]]%p+dp[1][v[u][i]]%p)%p)%p;
            dp[1][u]=(dp[1][u]%p*dp[0][v[u][i]]%p)%p;
        }
    }
    //cout<<u<<" "<<dp[0][u]<<" "<<dp[1][u]<<endl;
           if(u==1) dp[0][u]=(dp[0][u]%p+dp[1][u]%p)%p;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        dp[0][i+1]=1;dp[1][i+1]=1;
      if(i==n-2){dp[0][n]=1;dp[1][n]=1;}
    }
   if(n==1){
       cout<<2;return ;
   }
    dfs(1);
    cout<<dp[0][1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:16: error: return-statement with no value, in function returning 'int' [-fpermissive]
   31 |        cout<<2;return ;
      |                ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define N 100005
#define ll long long

vector <int> g[N];
ll dp[N][2];

void dfs(int node, int par){
	dp[node][0] = 1;
	dp[node][1] = 1;
	for(auto it : g[node]){
		if(it != par){
			dfs(it, node);
			dp[node][0] = (dp[node][0] * (dp[it][0] + dp[it][1]) % MOD) % MOD;
			dp[node][1] = (dp[node][1] * dp[it][0]) % MOD;
		}
	}
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n; cin>>n;
	int m, x, y, i;
	m = n-1;
	while(m--){
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1, 0);
	int ans = (dp[1][0] + dp[1][1]) % MOD;
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:22: error: 'class std::vector<int>' has no member named 'pb'
   31 |                 g[x].pb(y);
      |                      ^~
a.cc:32:22: error: 'class std::vector<int>' has no member named 'pb'
   32 |                 g[y].pb(x);
      |                      ^~
Language: C++

#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int, int>
#define vpii vector<pii>
using namespace std;
vvi a;
vvi dp;
int recurse(int x,int y,int z){
	if(dp[y][x]!=-1){
		//cout<<x<<" "<<y<<" "<<dp[y][x]<<endl;
		return dp[y][x];
	}
	ll v=1;
	for(int i=0;i<a[x].size();i++){
		if(a[x][i]!=z){
			if(y==0){
				v=(v%mod*((recurse(a[x][i],0,x)+recurse(a[x][i],1,x))%mod)%mod;
			}
			else{
				v=(v%mod*(recurse(a[x][i],0,x)%mod)%mod;
			}
		}
	}
	//cout<<x<<" "<<y<<" "<<v<<endl;
	return dp[y][x]=v%mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    //cin>>t;
    while(t--){
    	int n;
    	cin>>n;
    	a.clear();dp.clear();
    	int x,y;
    	a.resize(n);
    	Fr(i,0,n-2){
    		cin>>x>>y;
    		x--;y--;
    		a[x].pb(y);a[y].pb(x);
    	}
		x=1;    	
    	dp.resize(2,vi(n,-1));
 		ll ans=(recurse(0,0,-1)+recurse(0,1,-1))%mod;
 		cout<<ans<<endl;   	
    }
    return 0;
}


Compiler output:
a.cc: In function 'int recurse(int, int, int)':
a.cc:29:95: error: expected ')' before ';' token
   29 |                                 v=(v%mod*((recurse(a[x][i],0,x)+recurse(a[x][i],1,x))%mod)%mod;
      |                                   ~                                                           ^
a.cc:32:72: error: expected ')' before ';' token
   32 |                                 v=(v%mod*(recurse(a[x][i],0,x)%mod)%mod;
      |                                   ~                                    ^
Language: C++

#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int, int>
#define vpii vector<pii>
using namespace std;
vvi a;
vvi dp;
int recurse(int x,int y,int z){
	if(dp[y][x]!=-1){
		//cout<<x<<" "<<y<<" "<<dp[y][x]<<endl;
		return dp[y][x];
	}
	ll v=1;
	for(int i=0;i<a[x].size();i++){
		if(a[x][i]!=z){
			if(y==0){
				v=v*(recurse(a[x][i],0,x)+recurse(a[x][i],1,x));
			}
			else{
				v=v*recurse(a[x][i],0,x);
			}
		}
	}
	//cout<<x<<" "<<y<<" "<<v<<endl;
	return dp[y][x]=v%mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
    int t=1;
    //cin>>t;
    while(t--){
    	int n;
    	cin>>n;
    	a.clear();dp.clear();
    	int x,y;
    	a.resize(n);
    	Fr(i,0,n-2){
    		cin>>x>>y;
    		x--;y--;
    		a[x].pb(y);a[y].pb(x);
    	}
		x=1;    	
    	dp.resize(2,vi(n,-));
 		ll ans=(recurse(0,0,-1)+recurse(0,1,-1))%mod;
 		cout<<ans<<endl;   	
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:23: error: expected primary-expression before '(' token
   58 |         dp.resize(2,vi(n,-));
      |                       ^
a.cc:58:27: error: expected primary-expression before ')' token
   58 |         dp.resize(2,vi(n,-));
      |                           ^
Language: C++

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N = 1e5+1;
vector<int> adj[N];
ll dp[N][2];

ll solve(int u, int c, int p) {
	if (dp[u][c] != -1) return dp[u][c];
	ll res = 1;
	for (int v : adj[u]) {
		if (v != p) {
			if (c) {
				res = res * solve(v, c^1, u) % MOD;
            } else {
				res = res * (solve(v, c^1, u) + solve(v, c, u)) % MOD
            }
		}
	}
	return dp[u][c] = res % MOD;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	memset(dp, -1, sizeof dp);

	int n;
	cin >> n;
	For(i,n-1) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	cout << (solve(1, 0, 0) + solve(1, 1, 0)) % MOD << nl;

	return 0;
}


Compiler output:
a.cc: In function 'll solve(int, int, int)':
a.cc:45:86: error: expected ';' before '}' token
   45 |                                 res = res * (solve(v, c^1, u) + solve(v, c, u)) % MOD
      |                                                                                      ^
      |                                                                                      ;
   46 |             }
      |             ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10 , mod = 1e9 + 7;
int d[N][2];
vector < int > edges[N];
void dfs(int x , int p){
      int all_white = 1;
      int all = 1;
      for(int i : edges[x]){
            if(i != p){
                  dfs(i , x);
                  all_white *= d[i][0];
                  all_white %= mod;
                  all *= d[i][0] + d[i][1];
                  all %= mod;
            }
      }
      d[x][1] = all_white;
      d[x][0] = all % mod;
}
int main(){
      int n;
      cin >> n;
      for(int i = 1; i < n; i ++){
            int a , b;
            cin >> a >> b;
            edges[a].push_back(b);
            edges[b].push_back(a); 
      }
      dfs(1 , 0); 
      cout << (d[1][0] + d[1][1]) % mod << "\n";
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<vector<int>> da(n);
	for (int i = 0;i < n - 1;i++) {
		int x, y;
		cin >> x >> y;
		da[x - 1].push_back(y - 1);
		da[y - 1].push_back(x - 1);
	}
	queue<int> q;
	vector<long long> dp(n, 1), dpp(n, 1), gg(n);
	vector<bool> ju(n, false);
	for (int i = 0;i < n;i++) {
		gg[i] = da[i].size();
		if (gg[i] == 1) {
			gg[i]--;
			q.push(i);
			ju[i] = true;
		}
	}
	int co = n, ans = 0;
	while (co > 0) {
		int x = q.front();
		q.pop();
		ju[x] = true;
		long long b = 1, w = 1;
		for (int i = 0;i < da[x].size();i++) {
			gg[da[x][i]]--;
			if(ju[da[x][i]]) {
				w = (w*(dp[da[x][i]] + dpp[da[x][i]])) % 1000000007;
				b = (b*dp[da[x][i]]) % 1000000007;
			}
			if (gg[da[x][i]] == 1) {
				q.push(da[x][i]);
			}
		}
		dp[x] = w;
		dpp[x] = b;
		if (q.empty()) {
			ans = dp[x] + dpp[x];
			break;
		}
	}
	cout << ans << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:55:29: error: expected '}' at end of input
   55 |         cout << ans << endl;
      |                             ^
a.cc:11:12: note: to match this '{'
   11 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> dp(100010,vector<long long>(2,-1)),graph(100010);
long long n,a,b;

long long ans(long long curr , long long last , long long par){
    if(dp[curr][last] != -1){
        return dp[curr][last];
    }
    if(graph[curr].size() == 1 && graph[curr][0] == par){
        if(last == 0){
            return 2;
        }else{
            return 1;
        }
    }
    long long ret1=1,ret2=1;
    for(int i : graph[curr]){
        if(i != par){
            if(last == 0){
                ret1 *= ans(i,0,curr);
                ret2 *= ans(i,1,curr);
            }else{
                ret1 *= ans(i,0,curr);
            }
        }
    }
    long long ret;
    if(last == 0){
        ret = ret1+ret2;
    }else{
        ret = ret1;
    }
    ret %= 1000000007
    dp[curr][last] = ret;
    return ret;
}

int main()
{
    cin >> n;
    for(int i = 0 ; i < n-1 ; i += 1){
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    cout << ans(1,0,-1)%1000000007;
}

Compiler output:
a.cc: In function 'long long int ans(long long int, long long int, long long int)':
a.cc:34:22: error: expected ';' before 'dp'
   34 |     ret %= 1000000007
      |                      ^
      |                      ;
   35 |     dp[curr][last] = ret;
      |     ~~
Language: C++

#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 10025;
const int MOD = 1000000007;
typedef long long ll;
int eid,p[MAX_N];
ll dp[MAX_N][2];
struct edge{
    int v,next;
}e[MAX_N<<2];
void init(){
    memset(p,-1,sizeof(p));
    eid = 0;
    printf("%d",n);
    printf("%d",m);
}
void add(int u,int v){
    e[eid].v = v;
    e[eid].next =p[u];
    p[u] = eid++;
}
void dfs(int u,int fa){
    ll x = 1, y = 1;
    if(e[p[u]].next==-1&&e[p[u]].v == fa){
        dp[u][0] = dp[u][1] = 1;
        return ;
    }
    printf("%d %d\n",dp[u][0],dp[u][1]);
    for(int i = p[u];i+1;i=e[i].next){
        int v = e[i].v;
        if(v==fa) continue;
        dfs(v,u);
        x = (x*((dp[v][0] + dp[v][1])%MOD))%MOD;
        y = (y*(dp[v][0]))%MOD;
    }
    dp[u][0] = x,dp[u][1] = y;
}
int main(){
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,a,b;
    init();
    scanf("%d",&n);
    for(int i = 1;i<n;++i){
        scanf("%d%d",&a,&b);
        add(a,b);
        add(b,a);
    }
    dfs(1,0);
    printf("%d\n",(dp[1][0]+dp[1][1])%MOD);
    return 0;
}

Compiler output:
a.cc: In function 'void init()':
a.cc:16:17: error: 'n' was not declared in this scope; did you mean 'yn'?
   16 |     printf("%d",n);
      |                 ^
      |                 yn
a.cc:17:17: error: 'm' was not declared in this scope; did you mean 'tm'?
   17 |     printf("%d",m);
      |                 ^
      |                 tm
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 100025;
int eid,p[MAX_N];
ll dp[MAX_N][2];
struct edge
{
    int v,next;
}e[MAX_N<<2];
void init()
{
    memset(p,-1,sizeof(p));
    eid = 0;
}
void add(int u,int v)
{
    e[eid].v = v;
    e[eid].next =p[u];
    p[u] = eid++;
}
void dfs(int u,int fa)
{
    ll x = 1, y = 1;
    if(e[p[u]].next==-1&&e[p[u]].v == fa)
    {
        dp[u][0] = dp[u][1] = 1;
        return ;
    }
    for(int i = p[u];i+1;i=e[i].next)
    {
        int v = e[i].v;
        if(v==fa) continue;
        dfs(v,u);
        x = (x*((dp[v][0] + dp[v][1])%MOD))%MOD;
        y = (y*(dp[v][0]))%MOD;
    }
    dp[u][0] = x,dp[u][1] = y;
}
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,a,b;
    init();
    scanf("%d",&n);
    for(int i = 1;i<n;++i)
    {
        scanf("%d%d",&a,&b);
        add(a,b);
        add(b,a);
    }
    dfs(1,0);
    printf("%d\n",(dp[1][0]+dp[1][1])%MOD);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}

Compiler output:
a.cc:5:1: error: 'll' does not name a type
    5 | ll dp[MAX_N][2];
      | ^~
a.cc: In function 'void dfs(int, int)':
a.cc:23:5: error: 'll' was not declared in this scope
   23 |     ll x = 1, y = 1;
      |     ^~
a.cc:26:9: error: 'dp' was not declared in this scope; did you mean 'p'?
   26 |         dp[u][0] = dp[u][1] = 1;
      |         ^~
      |         p
a.cc:34:9: error: 'x' was not declared in this scope
   34 |         x = (x*((dp[v][0] + dp[v][1])%MOD))%MOD;
      |         ^
a.cc:34:18: error: 'dp' was not declared in this scope; did you mean 'p'?
   34 |         x = (x*((dp[v][0] + dp[v][1])%MOD))%MOD;
      |                  ^~
      |                  p
a.cc:34:39: error: 'MOD' was not declared in this scope
   34 |         x = (x*((dp[v][0] + dp[v][1])%MOD))%MOD;
      |                                       ^~~
a.cc:35:9: error: 'y' was not declared in this scope
   35 |         y = (y*(dp[v][0]))%MOD;
      |         ^
a.cc:37:5: error: 'dp' was not declared in this scope; did you mean 'p'?
   37 |     dp[u][0] = x,dp[u][1] = y;
      |     ^~
      |     p
a.cc:37:16: error: 'x' was not declared in this scope
   37 |     dp[u][0] = x,dp[u][1] = y;
      |                ^
a.cc:37:29: error: 'y' was not declared in this scope
   37 |     dp[u][0] = x,dp[u][1] = y;
      |                             ^
a.cc: In function 'int main()':
a.cc:54:20: error: 'dp' was not declared in this scope; did you mean 'p'?
   54 |     printf("%d\n",(dp[1][0]+dp[1][1])%MOD);
      |                    ^~
      |                    p
a.cc:54:39: error: 'MOD' was not declared in this scope
   54 |     printf("%d\n",(dp[1][0]+dp[1][1])%MOD);
      |                                       ^~~
Language: C++

#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

ifstream fin("file.in");
ofstream fout("file.out");

long longint nrnr, nr1, nr2;

struct str{
    long long int alb;
    long long int blk;
    bool check;
    vector <int> con;
} vec[100005];

void dfs(int poz){
    vec[poz].alb = 1;
    vec[poz].blk = 1;
    vec[poz].check = 1;
    for(int index = 0; index < vec[poz].con.size(); index++){
        if(!vec[vec[poz].con[index]].check){
            dfs(vec[poz].con[index]);
            vec[poz].alb = (vec[poz].alb * (vec[vec[poz].con[index]].alb + vec[vec[poz].con[index]].blk)) % 1000000007;
            vec[poz].blk = (vec[poz].blk * vec[vec[poz].con[index]].alb) % 1000000007;
        }
    }
    return;
}

int main()
{
    cin >> nrnr;
    while(cin >> nr1){
        cin >> nr2;
        vec[nr1].con.push_back(nr2);
        vec[nr2].con.push_back(nr1);
    }
    dfs(1);
    cout << (vec[1].alb + vec[1].blk) % 1000000007;
    return 0;
}


Compiler output:
a.cc:10:14: error: expected initializer before 'nrnr'
   10 | long longint nrnr, nr1, nr2;
      |              ^~~~
a.cc: In function 'int main()':
a.cc:35:12: error: 'nrnr' was not declared in this scope
   35 |     cin >> nrnr;
      |            ^~~~
a.cc:36:18: error: 'nr1' was not declared in this scope
   36 |     while(cin >> nr1){
      |                  ^~~
a.cc:37:16: error: 'nr2' was not declared in this scope
   37 |         cin >> nr2;
      |                ^~~
Language: C++

#include <bits/stdc++.h>
 using namespace  std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
typedef double ld;
//#define For(i,0,n) for(long long i = 0 ; i<n ;i++) 
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;
	
	cd res = fast_exp(a, b / 2);
		
	res = res * res;
	
	if (b % 2 == 1)
		res = res * a;
	
	return res;
}

long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;
	
	long long res=fastexpon(a,b/2,mod);
	
	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}


//TEMPLATE ENDS HERE!!!! ------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------


























ll n;
vector <ll> edge[100010];
ll dp[100010]={};
ll visited[100010]={};
ll ways(ll x)
{
	ll ways1=1 , ways2=1;
	visited[x]=1;
	//cout<<"hey";
	if(dp[x]>0)
		return dp[x];
	ll tovis=0;
	for(ll i=0 ;i<edge[x].size() ;i++)
	{
		if(!visited[edge[x][i]])
		tovis++;
	}
	if(tovis==0)
	{
		dp[x]=2;
		return dp[x];
	}

	if(edge[x].size()==1 && visited[edge[x][0]] == 1)
	{
		dp[x]=2;
		return dp[x];
	}
	for(ll i=0 ;i<edge[x].size() ;i++)
	{
		if(!visited[edge[x][i]])
		{
			ways1=(ways1*ways(edge[x][i]))%mod;
			visited[edge[x][i]]=0;
		}

	}

	for(ll i=0 ;i<edge[x][i] ;i++)
	{
		if(!visited[edge[x][i]])
		{
			visited[edge[x][i]]=1;

			for(auto e : edge[edge[x][i]])
			{
				//cout<<"hoo";
				if(e!=x)
				ways2=(ways2*ways(e))%mod;
			}
		}
	}

	
	dp[x]=(ways1+ways2)%mod;
	return dp[x];

}



int main()
 {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	if(n==1)
	{
		cout<<2<<'\n';
		return 0;
	}
	
	for(ll i=0 ;i<n-1 ;i++)
	{
		//cin>>n;
		ll a,b;
		cin>>a>>b;
		edge[a].pb(b);
		edge[b].pb(a);
	}

	cout<<ways(1)<<'\n';
	//cout<<ways(1)<<'\n'<<ways(2)<<'\n'<<ways(3)<<'\n';
	//cout<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}	

Compiler output:
a.cc:45:1: error: expected unqualified-id before '--' token
   45 | -------------------------------------------------------------------------------------------------------------------------------------------------------
      | ^~
a.cc: In function 'int main()':
a.cc:140:14: error: 'n' was not declared in this scope; did you mean 'yn'?
  140 |         cin>>n;
      |              ^
      |              yn
Language: C++

#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define MAXN ((ll)2e5+5)
#define MOD ((ll)1e9 + 7) 
#define ll long long
#define _ << " " <<
#define TRACE(x) cerr << #x << " = " << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"

ll n,m,t,k;
vector <ll> v[MAXN];
ll dw[MAXN];
ll db[MAXN];

ll add(ll&a,ll b)
{
	a+=b;
	if(a>MOD)
		a-=MOD;
}
ll mul(ll&a,ll b)
{
	a*=b;
	a-=(a/MOD)*MOD;
}


ll g(ll x,ll par);

ll f(ll x,ll par)
{
	if(dw[x]) return dw[x];
	ll ret=1;
	for (ll i = 0; i < (ll)v[x].size(); ++i)
		if(v[x][i] != par)
			mul(ret,add(g(v[x][i],x)+f(v[x][i],x)));

	return dw[x] = ret;
}
ll g(ll x,ll par)
{
	if(db[x]) return db[x];
	ll ret=1;
	for (ll i = 0; i < (ll)v[x].size(); ++i)
		if(v[x][i] != par)
			mul(ret,f(v[x][i],x));

	return db[x] =ret;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);

	cin >> n;
	for (ll i = 0; i < n-1; ++i)
	{
		ll a,b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	ll ans=0;
	add(ans,f(1,-1));
	add(ans,g(1,-1));

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'long long int add(long long int&, long long int)':
a.cc:24:1: warning: no return statement in function returning non-void [-Wreturn-type]
   24 | }
      | ^
a.cc: In function 'long long int mul(long long int&, long long int)':
a.cc:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
   29 | }
      | ^
a.cc: In function 'long long int f(long long int, long long int)':
a.cc:40:49: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int'
   40 |                         mul(ret,add(g(v[x][i],x)+f(v[x][i],x)));
      |                                     ~~~~~~~~~~~~^~~~~~~~~~~~~
a.cc:19:11: note: in passing argument 1 of 'long long int add(long long int&, long long int)'
   19 | ll add(ll&a,ll b)
      |           ^
Language: C++

#include <iostream>
#include <vector>
#define int long long
using namespace std;
const int NM = 100000+1;
const int MOD = 1e9+7;
int n;
bool visited[NM];
vector<int> graph[NM];
pair<int,int> colors[NM];

pair<int,int> getColor(int i) {
    if(colors[i].first and colors[i].second)
        return colors[i];
    colors[i].first = colors[i].second = 1;
    visited[i] = true;
    for(int j = 0;j<graph[i].size();j++) {
        if(not visited[graph[i][j]]) {
            auto c = getColor(graph[i][j]);
            colors[i].first = (colors[i].first * c.second)%MOD;
            colors[i].second = (colors[i].second * ((c.first + c.second)%MOD)%MOD;
        }
    }
    return colors[i];
}
void solve() {
    auto ans = getColor(1);
    cout << ans.first+ans.second<<'\n';
}
signed main() {
    cin>>n;
    for(int i=0;i<NM;i++) visited[i] = false;
    for(int i=0;i<NM;i++) colors[i].first = colors[i].second = 0;

    for(int i = 0;i<n-1;i++) {
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    solve();
//    for(int i =0;i<5;i++)
//        cout << colors[i].first << ' ' << colors[i].second << '\n';
}



Compiler output:
a.cc: In function 'std::pair<long long int, long long int> getColor(long long int)':
a.cc:21:82: error: expected ')' before ';' token
   21 |             colors[i].second = (colors[i].second * ((c.first + c.second)%MOD)%MOD;
      |                                ~                                                 ^
      |                                                                                  )
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define fi first
#define se second
#define mk make_pair
/*
3
1 2
2 3
*/
const int N = 2e5+10;
vector<int> gr[N];
const int mod = 1e9+7;
int mul(int a,int b){
  return (ll)a*b%mod;
}
//return number of ways {black,white} at this vertex
pair<int,int> dfs(int u,int parent){
  int all_white = 1;
  int sth_is_black = 0;
  for(int v:gr[u]){
    if(v != parent){
      pair<int,int> p = dfs(v,u);
      //p.first is number of ways we can paint it black
      //so subtree is all white
      int memo_all_white = all_white;
      all_white = mul(all_white,p.second);
      sth_is_black = mul(memo_all_white,st_is_black)
        +mul(sth_is_black,(p.fi+p.se))%mod;
    }
  }	
  return mk(all_white,(all_white + sth_is_black)%mod);
}
int main(){
  int n;
  scanf("%d",&n);
  int u,v,w;
  for(int i=0;i<n-1;++i){
    cin>>u>>v;
    gr[u].pb(v);
    gr[v].pb(u);
  }
  pair<int,int> p = dfs(1,-1);
  cout<<(p.fi+p.se)%mod<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'std::pair<int, int> dfs(int, int)':
a.cc:30:41: error: 'st_is_black' was not declared in this scope; did you mean 'sth_is_black'?
   30 |       sth_is_black = mul(memo_all_white,st_is_black)
      |                                         ^~~~~~~~~~~
      |                                         sth_is_black
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
/*
3
1 2
2 3
*/
const int N = 2e5+10;
vector<int> gr[N];
const int mod = 1e9+7;
int mul(int a,int b){
  return (ll)a*b%mod;
}
//return number of ways {black,white} at this vertex
pair<int,int> dfs(int u,int parent){
  int all_white = 1;
  int sth_is_black = 0;
  for(int v:gr[u]){
    if(v != parent){
      pair<int,int> p = dfs(v,u);
      //p.first is number of ways we can paint it black
      //so subtree is all white
      int memo_all_white = all_white;
      all_white = mul(all_white,p.second);
      sth_is_black = mul(memo_all_white,st_is_black)
        +mul(sth_is_black,(p.fi+p.se))%mod;
    }
  }	
  return mk(all_white,(all_white + sth_is_black)%mod);
}
int main(){
  int n;
  scanf("%d",&n);
  int u,v,w;
  for(int i=0;i<n-1;++i){
    cin>>u>>v;
    gr[u].pb(v);
    gr[v].pb(u);
  }
  pair<int,int> p = dfs(1,-1);
  cout<<(p.fi+p.se)%mod<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int mul(int, int)':
a.cc:14:11: error: 'll' was not declared in this scope
   14 |   return (ll)a*b%mod;
      |           ^~
a.cc:14:14: error: expected ';' before 'a'
   14 |   return (ll)a*b%mod;
      |              ^
      |              ;
a.cc: In function 'std::pair<int, int> dfs(int, int)':
a.cc:27:41: error: 'st_is_black' was not declared in this scope; did you mean 'sth_is_black'?
   27 |       sth_is_black = mul(memo_all_white,st_is_black)
      |                                         ^~~~~~~~~~~
      |                                         sth_is_black
a.cc:28:30: error: 'struct std::pair<int, int>' has no member named 'fi'
   28 |         +mul(sth_is_black,(p.fi+p.se))%mod;
      |                              ^~
a.cc:28:35: error: 'struct std::pair<int, int>' has no member named 'se'
   28 |         +mul(sth_is_black,(p.fi+p.se))%mod;
      |                                   ^~
a.cc: In function 'int main()':
a.cc:43:12: error: 'struct std::pair<int, int>' has no member named 'fi'
   43 |   cout<<(p.fi+p.se)%mod<<endl;
      |            ^~
a.cc:43:17: error: 'struct std::pair<int, int>' has no member named 'se'
   43 |   cout<<(p.fi+p.se)%mod<<endl;
      |                 ^~
Language: C++

#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

const int N=1e5+5;

int n,u,v,dep[N],in[N],out[N],timer;

ll mem[N][3],mod=1e9+7;

vector<int>adj[N];

void dfs(int x,int par)
{
    in[x]=++timer;
    dep[x]=1+dep[par];
    for (auto X:adj[x])
    {
        if (X!=par)
        {
            dfs(X,x);
        }
    }
    out[x]=timer;
}

ll dp(int u,int flag)
{
    if (in[u]==out[u])return 1;
    if (mem[u][flag]!=-1)return mem[u][flag];
    ll ans=1;
    for (auto X:adj[u])
    {
        if (dep[X]>dep[u])
        {
           if(flag){ans*=(dp(X,1)%mod+dp(X,0)%mod)%mod;ans%=mod;}
           else{ans*=dp(X,1)%mod;ret%=mod;}
        }
    }
    return mem[u][flag]=ans;
}

int main()
{
    memset(mem,-1,sizeof mem);
    scanf("%d",&n);
    for (int i=0;i<n-1;i++)
    {
        scanf("%d%d",&u,&v);
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(1,0);
    printf("%lld\n",((dp(1,1)%mod)+(dp(1,0)%mod)%mod));
    return 0;
}


Compiler output:
a.cc: In function 'long long int dp(int, int)':
a.cc:43:34: error: 'ret' was not declared in this scope
   43 |            else{ans*=dp(X,1)%mod;ret%=mod;}
      |                                  ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9+7;
const int Nmax = 1e5+5;
ifstream f("1.in");

int n;
vector <int> v[Nmax];

int mul(int a, int b)
{
    return (ll)a*b%MOD;
}

pair <int, int> dfs(int a, int parent)
{
    int all_white=1, sth_is_blck=0;
    for (auto b:v[a])
    {
        if(b != parent)
        {
            pair <int, int> p=dfs(b, a);
            int memo=all_white;
            all_white=mul(all_white, p.second);
            sth_is_blck=(mul(memo, p.first)+
                         mul(sth_is_blck, (p.first+p.second)))%MOD;
        }
    }
    return make_pair(all_white, (all_white+sth_is_blck)%MOD);
}


int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n-1; i++)
    {
        int a, b;
       	cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    pair <int, int> p=dfs(1, 0);
    cout << (p.first+p.second)%MOD;
    return 0;
}


Compiler output:
a.cc: In function 'int mul(int, int)':
a.cc:14:13: error: 'll' was not declared in this scope
   14 |     return (ll)a*b%MOD;
      |             ^~
a.cc:14:16: error: expected ';' before 'a'
   14 |     return (ll)a*b%MOD;
      |                ^
      |                ;
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

class DpP {
    static int n, ans;
    final static int N = (int)1e5+5, MOD = (int)1e9+7;
    static ArrayList<Integer>[] g = new ArrayList[N];
    static int[][] dp = new int[N][2];

    static int dfs(int vertex, int parent, int color){
        if(dp[vertex][color] != -1){
            return dp[vertex][color];
        }
        dp[vertex][color] = 1;
        for(int child : g[vertex]){
            if(child != parent){
                if(color == 1){
                    dp[vertex][color] *= dfs(child, vertex, 1);
                }
                else {
                    dp[vertex][color] *= (dfs(child, vertex, 0) + dfs(child, vertex, 1));
                }
                dp[vertex][color] %= MOD;
            }
        }
        return dp[vertex][color];
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for(int i = 0; i < N; ++i){
            g[i] = new ArrayList<Integer>();
        }
        for(int i = 0; i < n - 1; ++i){
            int x, y;
            x = in.nextInt();
            y = in.nextInt();
            g[x].add(y);
            g[y].add(x);
        }
        for(int i = 0; i < N; ++i) {
           dp[i][0] = -1;
           dp[i][1] = -1;
        }
        ans = 0;
        ans += dfs(1, 0, 0);
        ans %= MOD;
        ans += dfs(1, 0, 1);
        ans %= MOD;
        System.out.println(ans);
    }
}


Compiler output:
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

public class DpP {
    static int n, ans;
    final static int N = (int)1e5+5, MOD = (int)1e9+7;
    static ArrayList<Integer>[] g = new ArrayList[N];
    static int[][] dp = new int[N][2];

    static int dfs(int vertex, int parent, int color){
        if(dp[vertex][color] != -1){
            return dp[vertex][color];
        }
        dp[vertex][color] = 1;
        for(int child : g[vertex]){
            if(child != parent){
                if(color == 1){
                    dp[vertex][color] *= dfs(child, vertex, 1);
                }
                else {
                    dp[vertex][color] *= (dfs(child, vertex, 0) + dfs(child, vertex, 1));
                }
                dp[vertex][color] %= MOD;
            }
        }
        return dp[vertex][color];
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for(int i = 0; i < N; ++i){
            g[i] = new ArrayList<Integer>();
        }
        for(int i = 0; i < n - 1; ++i){
            int x, y;
            x = in.nextInt();
            y = in.nextInt();
            g[x].add(y);
            g[y].add(x);
        }
        for(int i = 0; i < N; ++i) {
           dp[i][0] = -1;
           dp[i][1] = -1;
        }
        ans = 0;
        ans += dfs(1, 0, 0);
        ans %= MOD;
        ans += dfs(1, 0, 1);
        ans %= MOD;
        System.out.println(ans);
    }
}


Compiler output:
Main.java:4: error: class DpP is public, should be declared in a file named DpP.java
public class DpP {
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class DpP {
    static int n, ans;
    final static int N = (int)1e5+5, MOD = (int)1e9+7;
    static ArrayList<Integer>[] g = new ArrayList[N];
    static int[][] dp = new int[N][2];

    static int dfs(int vertex, int parent, int color){
        if(dp[vertex][color] != -1){
            return dp[vertex][color];
        }
        dp[vertex][color] = 1;
        for(int child : g[vertex]){
            if(child != parent){
                if(color == 1){
                    dp[vertex][color] *= dfs(child, vertex, 1);
                }
                else {
                    dp[vertex][color] *= (dfs(child, vertex, 0) + dfs(child, vertex, 1));
                }
                dp[vertex][color] %= MOD;
            }
        }
        return dp[vertex][color];
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for(int i = 0; i < N; ++i){
            g[i] = new ArrayList<Integer>();
        }
        for(int i = 0; i < n - 1; ++i){
            int x, y;
            x = in.nextInt();
            y = in.nextInt();
            g[x].add(y);
            g[y].add(x);
        }
        for(int i = 0; i < N; ++i) {
           dp[i][0] = -1;
           dp[i][1] = -1;
        }
        ans = 0;
        ans += dfs(1, 0, 0);
        ans %= MOD;
        ans += dfs(1, 0, 1);
        ans %= MOD;
        System.out.println(ans);
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.lang.reflect.Array;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.ArrayList;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Arrays;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.Scanner;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class DpP {
      | ^~~~~~
Language: C++

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

int n;
int x,y;
int dp[100005][2];
vector<int> adj[100005]; // đỉnh kề với đỉnh i
bool vis[100005]; // đỉnh đã duyệt

void init(){
  for(int i=1;i<=n;i++)
	vis[i] = false;
}

void dfs(int s,int dp[][2]){
    if(vis[s]==false){
		vis[s]=true;
		int ch = 0;
//		cout << "doan ch " << ch<<"\n";
		for(auto x: adj[s])
			{
//				cout << x <<" doan ch x\n";
				if(vis[x]==false) { ch = 1; break; }
				}

		if(ch==0) {dp[s][0] = dp[s][1] = 1;}

		else{
			dp[s][0] = dp[s][1] = 1;
			for(auto x:adj[s]){
				if(vis[x]==false){
					dfs(x,dp);
					dp[s][0]*=(dp[x][0]+dp[x][1]);
					dp[s][0]%=mod;
					dp[s][1]*=dp[x][0];
					dp[s][1]%=mod;
				}
			}
		}

    }
}
int main(){
   cin >> n;
   for(int i=1;i<n;i++){
	cin >> x >> y;
	adj[x].push_back(y);
	adj[y].push_back(x);
   }

//   for(int i=1;i<=n;i++)
//   {
//   	for(auto x: adj[i])
//		cout << x <<" ";
//	cout << "\n";
//   }
   init();

   dfs(1,dp);

   cout << (dp[1][0]+dp[1][1])%=mod;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:31: error: no match for 'operator%=' (operand types are 'std::basic_ostream<char>' and 'int')
   62 |    cout << (dp[1][0]+dp[1][1])%=mod;
      |                               ^
Language: C++

#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

#define endl '\n'
#define int long long
const int MAXN = 1e5+5;
const int MOD = 1e9+7;
int n, u, v;
vector<int> adj[MAXN];
int visited[MAXN];
int dp[MAXN][2];
int ans = 0;

void dfs(int i)
{
    visited[i] = 1;
    for (auto j: adj[i])
    {
        if (!visited[j])
        {
            dfs(j);
            dp[i][0] *= (dp[j][0] + dp[j][1]);
            dp[i][0] %= MOD;
            dp[i][1] *= (dp[j][0]);
            do[i][1] %= MOD;
        }
    }
}
signed main()
{
    memset(visited,0,sizeof visited);
    cin >> n;

    for (int i = 1; i < n; i++)
    {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 1; i <= n; i++)
    dp[i][0] = dp[i][1] = 1;
    dfs(1);

    cout << (dp[1][0] + dp[1][1])%MOD;
}
/*
10
8 5
10 8
6 5
1 5
4 8
2 10
3 6
9 2
1 7
*/
/*
4
1 2
1 3
3 4
*/


Compiler output:
a.cc: In lambda function:
a.cc:27:18: error: expected '{' before '[' token
   27 |             do[i][1] %= MOD;
      |                  ^
a.cc: In function 'void dfs(long long int)':
a.cc:27:18: error: no match for 'operator[]' (operand types are 'dfs(long long int)::<lambda()>' and 'int')
a.cc:28:9: error: expected 'while' before '}' token
   28 |         }
      |         ^
a.cc:28:9: error: expected '(' before '}' token
   28 |         }
      |         ^
      |         (
a.cc:28:9: error: expected primary-expression before '}' token
a.cc:27:29: error: expected ')' before '}' token
   27 |             do[i][1] %= MOD;
      |                             ^
      |                             )
   28 |         }
      |         ~                    
a.cc:27:29: error: expected ';' before '}' token
   27 |             do[i][1] %= MOD;
      |                             ^
      |                             ;
   28 |         }
      |         ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100001][2];
vector<ll> g[100001];
bool vis[100001];
ll mod=1e9+7;
void dfs(ll cur)
{
    vis[cur]=1;
    if(g[cur].size()==1)
      {
      if(vis[g[cur][0]])
        dp[cur][0]=dp[cur][1]=1, return;
   } ll x1,x2;
      x1=x2=0;
    for(int i = 0;i<g[cur].size(); i++)
      {
      if(!vis[g[cur][i]])
        {
        y=g[cur][i];
         dfs(g[cur][i]);
        x1=(x1 + dp[y][0]+dp[y][1])%mod;
     x2=(x2 + dp[y][1])% mod; 
      }
      }
  dp[cur][0]=x1; dp[cur][1]=x2;
}
int main()
{
  ll n,i,u,v;
  cin>>n;
  for(i=0;i<n-1;i++)
    {
    cin>>u>>v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    }
  dfs(1);
  cout<<(dp[1][0]+dp[1][1])% mod<<endl;
}

Compiler output:
a.cc: In function 'void dfs(ll)':
a.cc:14:34: error: expected primary-expression before 'return'
   14 |         dp[cur][0]=dp[cur][1]=1, return;
      |                                  ^~~~~~
a.cc:21:9: error: 'y' was not declared in this scope
   21 |         y=g[cur][i];
      |         ^
a.cc: In function 'int main()':
a.cc:36:5: error: 'adj' was not declared in this scope
   36 |     adj[u].push_back(v);
      |     ^~~