Language: C++

#include <bits/stdc++.h>
#define ll long long 
#define ld long double
using namespace std;
const ll INF = 1e18;
const ll MOD = 998244353;


vector<string> vec_splitter(string s) {
		s += ',';
		vector<string> res;
		while(!s.empty()) {
				res.push_back(s.substr(0, s.find(',')));
				s = s.substr(s.find(',') + 1);
		}
		return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
		if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
		stringstream ss; ss << H;
		cerr << args[idx] << " = " << ss.str();
		debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define deb(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define deb(...) 42
#endif
int dp[200000];
vector<vector<int>> edges;
bool line[200000];

void dfs(int u, int par = -1){
	for(auto v : edges[u]) {
		if(v != par){
			if((int)edges[v].size() == 2)	dfs(v, u);
			else {
				dp[v]++;
				return;
			}
		}
	}
}

int32_t main() {
	ios::sync_with_stdio(!cin.tie(NULL));

	int n;
	cin >> n;
	int u, v;
	edges.resize(n + 1);
	for(int i = 0; i < n - 1 ; i++){
		cin >> u >> v;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
	int root = 0;
	for(int i = 0; i < n; i++){
		if(edges[i].size() > edges[root].size())	root = i;
	}
	if(edges[root].size() < 3){
		cout << 1 << "\n";
		return 0;


	}
	memset(dp, 0, sizeof(dp));
	int res = 0;
	dfs(root);
	for(int i = 0; i < n; i++)	if((int)edges[i].size() == 1) dfs(i);
	for(int i = 0; i < n; i++)	res += max(0, dp[i] - 1);
	cout << max(1ll, res) << "\n";
}




Compiler output:
a.cc: In function 'int32_t main()':
a.cc:77:20: error: no matching function for call to 'max(long long int, int&)'
   77 |         cout << max(1ll, res) << "\n";
      |                 ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/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:77:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   77 |         cout << max(1ll, res) << "\n";
      |                 ~~~^~~~~~~~~~
/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:
/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:77:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   77 |         cout << max(1ll, res) << "\n";
      |                 ~~~^~~~~~~~~~