Language: C++

#include<bits/stdc++.h>
using namespace std;
long long int find(vector<pair<int,long long int> >&arr,int W,int i,vector<long long int> &memo)
{
	if(i>=arr.size()||W<=0)
	   return 0;
    if(memo[i]>0)
      return memo[i];
	else
	{
		long long int x=0,y=0;
		if(arr[i].first>W){
          memo[i]=find(arr,W,i+1);
          return memo[i];
        }
        else{
          memo[i]=max(find(arr,W-arr[i].first,i+1)+arr[i].second,find(arr,W,i+1));
          return memo[i];
        }
	}
}
int main()
{
	int n,W;
	cin>>n>>W;
	vector<pair<int,long long int> >arr;
	for(int i=0;i<n;i++)
	{
		long long int w,v;
		cin>>w>>v;
		arr.push_back(make_pair(w,v));
	}
	vector<long long int>memo(n,0);
	cout<<find(arr,W,0,memo)<<"\n";
	
}


Compiler output:
a.cc: In function 'long long int find(std::vector<std::pair<int, long long int> >&, int, int, std::vector<long long int>&)':
a.cc:13:23: error: no matching function for call to 'find(std::vector<std::pair<int, long long int> >&, int&, int)'
   13 |           memo[i]=find(arr,W,i+1);
      |                   ~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   template argument deduction/substitution failed:
a.cc:13:23: note:   deduced conflicting types for parameter '_IIter' ('std::vector<std::pair<int, long long int> >' and 'int')
   13 |           memo[i]=find(arr,W,i+1);
      |                   ~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 3 provided
In file included from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:13:23: note:   'std::vector<std::pair<int, long long int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >'
   13 |           memo[i]=find(arr,W,i+1);
      |                   ~~~~^~~~~~~~~~~
a.cc:3:15: note: candidate: 'long long int find(std::vector<std::pair<int, long long int> >&, int, int, std::vector<long long int>&)'
    3 | long long int find(vector<pair<int,long long int> >&arr,int W,int i,vector<long long int> &memo)
      |               ^~~~
a.cc:3:15: note:   candidate expects 4 arguments, 3 provided
a.cc:17:27: error: no matching function for call to 'find(std::vector<std::pair<int, long long int> >&, int, int)'
   17 |           memo[i]=max(find(arr,W-arr[i].first,i+1)+arr[i].second,find(arr,W,i+1));
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   template argument deduction/substitution failed:
a.cc:17:27: note:   deduced conflicting types for parameter '_IIter' ('std::vector<std::pair<int, long long int> >' and 'int')
   17 |           memo[i]=max(find(arr,W-arr[i].first,i+1)+arr[i].second,find(arr,W,i+1));
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:17:27: note:   'std::vector<std::pair<int, long long int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >'
   17 |           memo[i]=max(find(arr,W-arr[i].first,i+1)+arr[i].second,find(arr,W,i+1));
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:3:15: note: candidate: 'long long int find(std::vector<std::pair<int, long long int> >&, int, int, std::vector<long long int>&)'
    3 | long long int find(vector<pair<int,long long int> >&arr,int W,int i,vector<long long int> &memo)
      |               ^~~~
a.cc:3:15: note:   candidate expects 4 arguments, 3 provided
a.cc:17:70: error: no matching function for call to 'find(std::vector<std::pair<int, long long int> >&, int&, int)'
   17 |           memo[i]=max(find(arr,W-arr[i].first,i+1)+arr[i].second,find(arr,W,i+1));
      |                                                                  ~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   template argument deduction/substitution failed:
a.cc:17:70: note:   deduced conflicting types for parameter '_IIter' ('std::vector<std::pair<int, long long int> >' and 'int')
   17 |           memo[i]=max(find(arr,W-arr[i].first,i+1)+arr[i].second,find(arr,W,i+1));
      |                                                                  ~~~~^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:17:70: note:   'std::vector<std::pair<int, long long int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >'
   17 |           memo[i]=max(find(arr,W-arr[i].first,i+1)+arr[i].second,find(arr,W,i+1));
      |                                                                  ~~~~^~~~~~~~~~~
a.cc:3:15: note: candidate: 'long long int find(std::vector<std::pair<int, long long int> >&, int, int, std::vector<long long int>&)'
    3 | long long int find(vector<pair<int,long long int> >&arr,int W,int i,vector<long long int> &memo)
      |               ^~~~
a.cc:3:15: note:   candidate expects 4 arguments, 3 provided