Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--) 

const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;

char s[maxn];
vector<int>l,r;
int v[maxn],ans[maxn];


ll Fast_power(ll x,ll y,ll mode)
{
  ll sum=1;
  while(y)
  {
    if(y&1)sum=((sum%mode)*(x%mode))%mode;  
    x=(x%mode)*(x%mode);
    y=y>>1;
  }
  return sum;
}


int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   cin >> s;
   int n = strlen(s);
   rep(i,0,n){
      if(s[i] == 'L') l.push_back(i);
      else r.push_back(i);
   }
   for(int i = 0; i < l.size(); i++){
        v[l[i]] = r[max(0,lower_bound(r.begin(),r.end(),l[i])-r.begin() - 1)];
   }
   for(int i = 0; i < r.size(); i++){
        v[r[i]] = l[max(0,lower_bound(l.begin(),l.end(),r[i])-l.begin())];
   }
   //for(int i = 0 ; i < n; i++) cout << v[i] << " ";
   rep(i,0,n){
      if(s[i] == 'R') ans[(v[i] - 1) + (v[i] - i + 1) % 2]++;
      else ans[v[i] + 1 - (i - v[i] - 1) % 2]++;
   }
   rep(i,0,n) cout << ans[i] << " ";
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:24: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   39 |         v[l[i]] = r[max(0,lower_bound(r.begin(),r.end(),l[i])-r.begin() - 1)];
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:39:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   39 |         v[l[i]] = r[max(0,lower_bound(r.begin(),r.end(),l[i])-r.begin() - 1)];
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:39:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   39 |         v[l[i]] = r[max(0,lower_bound(r.begin(),r.end(),l[i])-r.begin() - 1)];
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:42:24: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   42 |         v[r[i]] = l[max(0,lower_bound(l.begin(),l.end(),r[i])-l.begin())];
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:42:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   42 |         v[r[i]] = l[max(0,lower_bound(l.begin(),l.end(),r[i])-l.begin())];
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:42:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |         v[r[i]] = l[max(0,lower_bound(l.begin(),l.end(),r[i])-l.begin())];
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~