Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,m;
  	cin >> n;
  	cin >> m;
  	int a,b;
    vector<int> g[n+5];
  	for(int i=0;i<m;i++)
    {
    	cin >> a>> b;
      	g[a].push_back(b);
    }
  	int check[n+5];
  	for(int i=0;i<n;i++)
    {
    	check[i]=0;
    }
  	stack st;
  	int cn = 0;
  	int max = INT_MIN;
  	for(int i=0;i<n;i++)
    {
      cn = 0;
    	if(check[i]==0)
        {
        	st.push(i);
          	cn++;
          	while(!st.empty())
            {
              top = st.top();
              st.pop();
              check[top]=1;
              int k = g[top].size();
              for(int j = 0;j<k;j++)
              {
                  if(check[g[top][j]]==0)
                  {
                    cn++;
                      st.push(g[top][j]);
                      check[g[top][j]] = 1;
                  }
              }
            }
          if(cn>max)
          {
            max = cn;
          }
        }
    }
  	cout << max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: class template argument deduction failed:
   20 |         stack st;
      |               ^~
a.cc:20:15: error: no matching function for call to 'stack()'
In file included from /usr/include/c++/14/stack:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:160,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_stack.h:199:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> stack(std::stack<_Tp, _Seq>&&, const _Alloc&)-> std::stack<_Tp, _Sequence>'
  199 |         stack(stack&& __q, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_stack.h:199:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_stack.h:195:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> stack(const std::stack<_Tp, _Seq>&, const _Alloc&)-> std::stack<_Tp, _Sequence>'
  195 |         stack(const stack& __q, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_stack.h:195:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_stack.h:191:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> stack(_Sequence&&, const _Alloc&)-> std::stack<_Tp, _Sequence>'
  191 |         stack(_Sequence&& __c, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_stack.h:191:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_stack.h:187:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> stack(const _Sequence&, const _Alloc&)-> std::stack<_Tp, _Sequence>'
  187 |         stack(const _Sequence& __c, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_stack.h:187:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_stack.h:183:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> stack(const _Alloc&)-> std::stack<_Tp, _Sequence>'
  183 |         stack(const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_stack.h:183:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_stack.h:170:7: note: candidate: 'template<class _Tp, class _Sequence> stack(_Sequence&&)-> std::stack<_Tp, _Sequence>'
  170 |       stack(_Sequence&& __c)
      |       ^~~~~
/usr/include/c++/14/bits/stl_stack.h:170:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_stack.h:166:7: note: candidate: 'template<class _Tp, class _Sequence> stack(const _Sequence&)-> std::stack<_Tp, _Sequence>'
  166 |       stack(const _Sequence& __c)
      |       ^~~~~
/usr/include/c++/14/bits/stl_stack.h:166:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_stack.h:162:9: note: candidate: 'template<class _Tp, class _Sequence, class _Seq, class _Requires> stack()-> std::stack<_Tp, _Sequence>'
  162 |         stack()
      |         ^~~~~
/usr/include/c++/14/bits/stl_stack.h:162:9: note:   template argument deduction/substitution failed:
a.cc:20:15: note:   couldn't deduce template parameter '_Tp'
   20 |         stack st;
      |               ^~
/usr/include/c++/14/bits/stl_stack.h:99:11: note: candidate: 'template<class _Tp, class _Sequence> stack(std::stack<_Tp, _Sequence>)-> std::stack<_Tp, _Sequence>'
   99 |     class stack
      |           ^~~~~
/usr/include/c++/14/bits/stl_stack.h:99:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_stack.h:319:5: note: candidate: 'template<class _Container, class _Allocator, class> std::stack(_Container, _Allocator)-> stack<typename _Container::value_type, _Container>'
  319 |     stack(_Container, _Allocator)
      |     ^~~~~
/usr/include/c++/14/bits/stl_stack.h:319:5: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_stack.h:315:5: note: candidate: 'template<class _Container, class> std::stack(_Container)-> stack<typename _Container::value_type, _Container>'
  315 |     stack(_Container) -> stack<typename _Container::value_type, _Container>;
      |     ^~~~~
/usr/include/c++/14/bits/stl_stack.h:315:5: note:   candidate expects 1 argument, 0 provided
a.cc:32:15: error: 'top' was not declared in this scope
   32 |               top = st.top();
      |               ^~~