Language: C++

#include<iostream>
#include<vector>
#include<map>
using namespace std;
vector<int> binext(long long a){
    vector<int> ans;
    for(int i = 0;i<22;i++){
        ans.push_back(a%2);
        a/=2;
    }
    return ans;
}
int main(){
    int n;
    cin >> n;
    long long h;
    vector<int> binsum;
    map<int,int> mp;
    for(int i = 0;i<22;i++){
        mp[i] = 0;
    }
    long wall = 0;
    long rightwall = 0;
    long temwall;
    vector<int> bintem;
    long ans = 0;
    bool fl = false;
    for(int i = 0;i<22;i++){
        binsum.push_back(0);
    }
    for(int i = 1;i<=n;i++){
        cin >> h;
        bintem = binext(h);
        for(int j = 0;j<22;j++){
            binsum[j]+=bintem[j];
        }
        temwall = wall;
        for(int j = 0;j<22;j++){
            if(bintem[j]==1 && binsum[j]>=2){
                fl = true;
                temwall = max(temwall,mp[j]);
            }
        }
        for(int j = 0;j<22;j++){
            if(bintem[j]==1){
                mp[j] = i;
            }
        }
        if(fl){
            ans+=(((i-wall)*(i-wall-1)/2)-max(0,(rightwall-wall)*(rightwall-wall-1)/2));
            rightwall = i;
            fl = false;
            wall = temwall;
        }
    }
    ans+=(((n+1-wall)*(n-wall)/2)-max(0,(rightwall-wall)*(rightwall-wall-1)/2));
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:30: error: no matching function for call to 'max(long int&, std::map<int, int>::mapped_type&)'
   41 |                 temwall = max(temwall,mp[j]);
      |                           ~~~^~~~~~~~~~~~~~~
In file included 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_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:41:30: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'std::map<int, int>::mapped_type' {aka 'int'})
   41 |                 temwall = max(temwall,mp[j]);
      |                           ~~~^~~~~~~~~~~~~~~
/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
a.cc:50:46: error: no matching function for call to 'max(int, long int)'
   50 |             ans+=(((i-wall)*(i-wall-1)/2)-max(0,(rightwall-wall)*(rightwall-wall-1)/2));
      |                                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:50:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   50 |             ans+=(((i-wall)*(i-wall-1)/2)-max(0,(rightwall-wall)*(rightwall-wall-1)/2));
      |                                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
a.cc:56:38: error: no matching function for call to 'max(int, long int)'
   56 |     ans+=(((n+1-wall)*(n-wall)/2)-max(0,(rightwall-wall)*(rightwall-wall-1)/2));
      |                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:56:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   56 |     ans+=(((n+1-wall)*(n-wall)/2)-max(0,(rightwall-wall)*(rightwall-wall-1)/2));
      |                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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