Language: C++

#include<iostream>
#include<map>
#include<string>
using namespace std;

int main(){
	int N,M;
	string blue[100];
	cin>>N;
	for(int i=0;i<N;++i) cin>>blue[i];
	string red[100];
	cin>>M;
	for(int i=0;i<M;++i) cin>>red[i];
	map<string,int> ans;
	for(int i=0;i<N;++i){
		if (ans.count(blue[i])==0) ans.insert(make_pair(blue[i],1));
		else ans[blue[i]]++;
	}
	for(int i=0;i<M;++i){
		if (ans.count(red[i])==0) ans.insert(make_pair(red[i],-1));
		else ans[red[i]]--;
	}
	int num=ans.begin()->second;
	for(pair itr=ans.begin();itr!=ans.end();++itr){
		if (itr->second>num) num=itr->second;
	}
	cout<<num<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:32: error: class template argument deduction failed:
   24 |         for(pair itr=ans.begin();itr!=ans.end();++itr){
      |                                ^
a.cc:24:32: error: no matching function for call to 'pair(std::map<std::__cxx11::basic_string<char>, int>::iterator)'
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1000:40: note: candidate: 'template<class _T1, class _T2> std::pair(_T1, _T2)-> pair<_T1, _T2>'
 1000 |   template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
      |                                        ^~~~
/usr/include/c++/14/bits/stl_pair.h:1000:40: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: candidate: 'template<class _T1, class _T2> pair(std::pair<_T1, _T2>)-> std::pair<_T1, _T2>'
 3013 |     struct pair;
      |            ^~~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note:   template argument deduction/substitution failed:
a.cc:24:32: note:   'std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, int> >' is not derived from 'std::pair<_T1, _T2>'
   24 |         for(pair itr=ans.begin();itr!=ans.end();++itr){
      |                                ^
/usr/include/c++/14/bits/stl_pair.h:294:17: note: candidate: 'template<class _T1, class _T2> pair(const std::pair<_T1, _T2>&)-> std::pair<_T1, _T2>'
  294 |       constexpr pair(const pair&) = default;    ///< Copy constructor
      |                 ^~~~
/usr/include/c++/14/bits/stl_pair.h:294:17: note:   template argument deduction/substitution failed:
a.cc:24:32: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'const std::pair<_T1, _T2>'
   24 |         for(pair itr=ans.begin();itr!=ans.end();++itr){
      |                                ^
/usr/include/c++/14/bits/stl_pair.h:295:17: note: candidate: 'template<class _T1, class _T2> pair(std::pair<_T1, _T2>&&)-> std::pair<_T1, _T2>'
  295 |       constexpr pair(pair&&) = default;         ///< Move constructor
      |                 ^~~~
/usr/include/c++/14/bits/stl_pair.h:295:17: note:   template argument deduction/substitution failed:
a.cc:24:32: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'std::pair<_T1, _T2>'
   24 |         for(pair itr=ans.begin();itr!=ans.end();++itr){
      |                                ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2874:7: note: candidate: 'template<class _T1, class _T2, class ... _Args1, class ... _Args2> pair(std::piecewise_construct_t, std::tuple<_Tp ...>, std::tuple<_Args2 ...>)-> std::pair<_T1, _T2>'
 2874 |       pair<_T1, _T2>::
      |       ^~~~~~~~~~~~~~
/usr/include/c++/14/tuple:2874:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/tuple:2886:7: note: candidate: 'template<class _T1, class _T2, class ... _Args1, long unsigned int ..._Indexes1, class ... _Args2, long unsigned int ..._Indexes2> pair(std::tuple<_Tp ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes2 ...>, std::_Index_tuple<_Indexes2 ...>)-> std::pair<_T1, _T2>'
 2886 |       pair<_T1, _T2>::
      |       ^~~~~~~~~~~~~~
/usr/include/c++/14/tuple:2886:7: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h:725:17: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<std::__and_<std::__is_implicitly_default_constructible<_U1>, std::__is_implicitly_default_constructible<_U2> >::value, bool>::type <anonymous> > pair()-> std::pair<_T1, _T2>'
  725 |       constexpr pair()
      |                 ^~~~
/usr/include/c++/14/bits/stl_pair.h:725:17: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h:752:17: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<true, _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(const _T1&, const _T2&)-> std::pair<_T1, _T2>'
  752 |       constexpr pair(const _T1& __a, const _T2& __b)
      |                 ^~~~
/usr/include/c++/14/bits/stl_pair.h:752:17: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h:779:19: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(const std::pair<_U1, _U2>&)-> std::pair<_T1, _T2>'
  779 |         constexpr pair(const pair<_U1, _U2>& __p)
      |                   ^~~~
/usr/include/c++/14/bits/stl_pair.h:779:19: note:   template argument deduction/substitution failed:
a.cc:24:32: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'const std::pair<_U1, _U2>'
   24 |         for(pair itr=ans.begin();itr!=ans.end();++itr){
      |                                ^
/usr/include/c++/14/bits/stl_pair.h:830:9: note: candidate: 'template<class _T1, class _T2, class _U1, typename std::enable_if<std::__and_<std::__not_<std::is_reference<_U2> >, std::is_pointer<_T2>, std::is_constructible<_T1, _U1>, std::__not_<std::is_constructible<_T1, const _U1&> >, std::is_convertible<_U1, _T1> >::value, bool>::type <anonymous> > pair(_U1&&, typename std::pair<_T1, _T2>::__zero_as_null_pointer_constant, ...)-> std::pair<_T1, _T2>'
  830 |         pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
      |         ^~~~
/usr/include/c++/14/bits/stl_pair.h:830:9: note:   candidate expects at least 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h:856:9: note: candidate: 'template<class _T1, class _T2, class _U2, typename std::enable_if<std::__and_<std::is_pointer<_Tp>, std::__not_<std::is_reference<_U2> >, std::is_constructible<_T2, _U2>, std::__not_<std::is_constructible<_T2, const _U2&> >, std::is_convertible<_U2, _T2> >::value, bool>::type <anonymous> > pair(typename std::pair<_T1, _T2>::__zero_as_null_pointer_constant, _U2&&, ...)-> std::pair<_T1, _T2>'
  856 |         pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
      |         ^~~~
/usr/include/c++/14/bits/stl_pair.h:856:9: note:   candidate expects at least 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h:881:19: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(_U1&&, _U2&&)-> std::pair<_T1, _T2>'
  881 |         constexpr pair(_U1&& __x, _U2&& __y)
      |                   ^~~~
/usr/include/c++/14/bits/stl_pair.h:881:19: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h:902:19: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(std::pair<_U1, _U2>&&)-> std::pair<_T1, _T2>'
  902 |         constexpr pair(pair<_U1, _U2>&& __p)
      |                   ^~~~
/usr/include/c++/14/bits/stl_pair.h:902:19: note:   template argument deduction/substitution failed:
a.cc:24:32: note:   'std::map<std::__cxx11::basic_string<char>, int>::iterator' {aka 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator'} is not derived from 'std::pair<_U1, _U2>'
   24 |         for(pair itr=ans.begin();itr!=ans.end();++itr){
      |                                ^
a.cc:24:32: note: explicit deduction guides not considered for copy-initialization