Language: C++

#include <bits/stdc++.h>
using namespace std;
int dp[102][100005];
int fun(int dp[][100005],vector<pair<int,int>>&v, int i, int n, int w){
  if(i==n)
    return 0;
  if(dp[i][w] != -1)
    return dp[i][w];
  int ans = 0;
  if(v[i].first >= w){
    ans = v[i].second + fun(dp, v, i+1, n, w - v[i].first);
  }
  ans = max(ans, fun(dp,v, i+1, n, w));
  dp[i][w] = ans;
  return ans;
}
int main(){
  int n, W;
  cin>>n>>W;
  vector<pair<int,int>>p;
  for(int i = 0;i<n;i++){
    pair pii;
    cin>>pii.first>>pii.second;
    p.push_back(pii);
  }
  memset(dp,-1,sizeof(dp));
  return fun(dp,p, 0,n,W);
 }

Compiler output:
a.cc: In function 'int main()':
a.cc:22:10: error: class template argument deduction failed:
   22 |     pair pii;
      |          ^~~
a.cc:22:10: error: no matching function for call to 'pair()'
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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_pair.h:913:28: 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<_ForwardIterator1, _ForwardIterator2>&&)-> std::pair<_T1, _T2>'
  913 |         explicit constexpr pair(pair<_U1, _U2>&& __p)
      |                            ^~~~
/usr/include/c++/14/bits/stl_pair.h:913:28: note:   candidate expects 1 argument, 0 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<_ForwardIterator1, _ForwardIterator2>&&)-> std::pair<_T1, _T2>'
  902 |         constexpr pair(pair<_U1, _U2>&& __p)
      |                   ^~~~
/usr/include/c++/14/bits/stl_pair.h:902:19: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_pair.h:891:28: 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>'
  891 |         explicit constexpr pair(_U1&& __x, _U2&& __y)
      |                            ^~~~
/usr/include/c++/14/bits/stl_pair.h:891:28: note:   candidate expects 2 arguments, 0 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, 0 provided
/usr/include/c++/14/bits/stl_pair.h:869: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::__not_<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>'
  869 |         pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
      |         ^~~~
/usr/include/c++/14/bits/stl_pair.h:869:9: note:   candidate expects at least 2 arguments, 0 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, 0 provided
/usr/include/c++/14/bits/stl_pair.h:843: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::__not_<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>'
  843 |         pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
      |         ^~~~
/usr/include/c++/14/bits/stl_pair.h:843:9: note:   candidate expects at least 2 arguments, 0 provided
/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, 0 provided
/usr/include/c++/14/bits/stl_pair.h:789:28: 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<_ForwardIterator1, _ForwardIterator2>&)-> std::pair<_T1, _T2>'
  789 |         explicit constexpr pair(const pair<_U1, _U2>& __p)
      |                            ^~~~
/usr/include/c++/14/bits/stl_pair.h:789:28: note:   candidate expects 1 argument, 0 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<_ForwardIterator1, _ForwardIterator2>&)-> std::pair<_T1, _T2>'
  779 |         constexpr pair(const pair<_U1, _U2>& __p)
      |                   ^~~~
/usr/include/c++/14/bits/stl_pair.h:779:19: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_pair.h:762:26: 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>'
  762 |       explicit constexpr pair(const _T1& __a, const _T2& __b)
      |                          ^~~~
/usr/include/c++/14/bits/stl_pair.h:762:26: note:   candidate expects 2 arguments, 0 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, 0 provided
/usr/include/c++/14/bits/stl_pair.h:737:26: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<std::__and_<std::is_default_constructible<_Allocator>, std::is_default_constructible<_U2>, std::__not_<std::__and_<std::__is_implicitly_default_constructible<_U1>, std::__is_implicitly_default_constructible<_U2> > > >::value, bool>::type <anonymous> > pair()-> std::pair<_T1, _T2>'
  737 |       explicit constexpr pair()
      |                          ^~~~
/usr/include/c++/14/bits/stl_pair.h:737:26: note:   template argument deduction/substitution failed:
a.cc:22:10: note:   couldn't deduce template parameter '_T1'
   22 |     pair pii;
      |          ^~~
/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:   template argument deduction/substitution failed:
a.cc:22:10: note:   couldn't deduce template parameter '_T1'
   22 |     pair pii;
      |          ^~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/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, 0 provided
/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<_