Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 202020;
int n;
int a[N];
int p[21][N];
int main() {
	scanf("%d", &n);
	rep(i, 0, n) scanf("%d", a + i);
	rep(i, 0, n) {
		rep(j, 0, 20) {
			p[j][i + 1] = p[j][i] + (a[i] >> j & 1);
		}
	}
	rep(i, 0, 20) p[i][n + 2] = N;
	ll ans = 0;
	rep(l, 1, n + 1) {
		int r = n + 1;
		rep(i, 0, 20) {
			r = min(1ll * r, upper_bound(p[i], p[i] + n + 1, p[i][l] + !(a[l - 1] >> i & 1)) - p[i]);
		}
		//de(r);
		ans += r - l;
	}
	printf("%lld\n", ans);
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:34:32: error: no matching function for call to 'min(long long int, long int)'
   34 |                         r = min(1ll * r, upper_bound(p[i], p[i] + n + 1, p[i][l] + !(a[l - 1] >> i & 1)) - p[i]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:34:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   34 |                         r = min(1ll * r, upper_bound(p[i], p[i] + n + 1, p[i][l] + !(a[l - 1] >> i & 1)) - p[i]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:34:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |                         r = min(1ll * r, upper_bound(p[i], p[i] + n + 1, p[i][l] + !(a[l - 1] >> i & 1)) - p[i]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~