Language: C++

#include<bits/stdc++.h>


#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define w(x)            int x; cin>>x; while(x--)

void c_p_c()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int dp[1000000];
long int ansnikal(unordered_map <int,pair<long,int>> &data,int start,int sum,long mw,int &n)
{
    if(mw<=0){
        return sum;
    }
    if (dp[sum]!=-1){
        return dp[sum];
    }
    else{
        int c=INT_MIN;
        for(int i=start;i<n;i++){
            if (mw-data[i].first<0){
                c=max(c,ansnikal(data,i+1,sum,mw-data[i].first,n));
            }
            else{
                c=max(c,ansnikal(data,i+1,sum+data[i].second,mw-data[i].first,n));
            }
        }
        return dp[sum]=c;
    }
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   //c_p_c();
   long int wm,n,temp1,temp2;
   cin>>n>>wm;
   memset(dp,-1,sizeof(dp));
   unordered_map <int,pair<long,int>> data;
   for(int i=0;i<n;i++){
       cin>>temp1>>temp2;
       data[i]={temp1,temp2};
   }
   cout<<ansnikal(data,0,0,wm,n)<<endl;
   return 0;
}

Compiler output:
a.cc: In function 'long int ansnikal(std::unordered_map<int, std::pair<long int, int> >&, int, int, long int, int&)':
a.cc:74:22: error: no matching function for call to 'max(int&, long int)'
   74 |                 c=max(c,ansnikal(data,i+1,sum,mw-data[i].first,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:74:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   74 |                 c=max(c,ansnikal(data,i+1,sum,mw-data[i].first,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:74:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |                 c=max(c,ansnikal(data,i+1,sum,mw-data[i].first,n));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:77:22: error: no matching function for call to 'max(int&, long int)'
   77 |                 c=max(c,ansnikal(data,i+1,sum+data[i].second,mw-data[i].first,n));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   77 |                 c=max(c,ansnikal(data,i+1,sum+data[i].second,mw-data[i].first,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
/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:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   77 |                 c=max(c,ansnikal(data,i+1,sum+data[i].second,mw-data[i].first,n));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:95:31: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long int'
   95 |    cout<<ansnikal(data,0,0,wm,n)<<endl;
      |                               ^
a.cc:62:91: note:   initializing argument 5 of 'long int ansnikal(std::unordered_map<int, std::pair<long int, int> >&, int, int, long int, int&)'
   62 | long int ansnikal(unordered_map <int,pair<long,int>> &data,int start,int sum,long mw,int &n)
      |                                                                                      ~~~~~^