Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int i,n,count,ans;
    count=0;
    string s;
    cin >> s;
    n=s.length;
    vector<string> vec(n);
    vector<int> ans(n);
    for(i=0;i<n;i++){
        vec.at(i)=s.substr(i,1);
    }
    for(i=0;i<n;i++){
        if(vec.at(i)=="R"&&vec.at(i+1)=="L"){
            if(count%2==0){
                ans.at(i+1)++;
                break;
            }else{
                ans.at(i)++;
                break;
            }
        }
        else if(vec.at(i)=="L"&&vec.at(i-1)=="R"){
            if(count%2==0){
                ans.at(i-1)++;
                break;
            }else{
                ans.at(i)++;
                break;
            }
        }
        else if(vec.at(i)=="R"&&vec.at(i-1)=="R"){
            vec.at(i)==vec.at(i+1);
            count++;
        }
        else if(vec.at(i)=="L"&&vec.at(i-1)=="L"){
            vec.at(i)==vec.at(i-1);
            count++;
        }
    }
    for(i=0;i<n;i++){
    cout<<ans.at(i)<<endl;
    }


}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: cannot convert 'std::__cxx11::basic_string<char>::length' from type 'std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept' {aka 'long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept'} to type 'int'
    9 |     n=s.length;
      |         ^~~~~~
a.cc:11:17: error: conflicting declaration 'std::vector<int> ans'
   11 |     vector<int> ans(n);
      |                 ^~~
a.cc:5:19: note: previous declaration as 'int ans'
    5 |     int i,n,count,ans;
      |                   ^~~
a.cc:18:21: error: request for member 'at' in 'ans', which is of non-class type 'int'
   18 |                 ans.at(i+1)++;
      |                     ^~
a.cc:21:21: error: request for member 'at' in 'ans', which is of non-class type 'int'
   21 |                 ans.at(i)++;
      |                     ^~
a.cc:27:21: error: request for member 'at' in 'ans', which is of non-class type 'int'
   27 |                 ans.at(i-1)++;
      |                     ^~
a.cc:30:21: error: request for member 'at' in 'ans', which is of non-class type 'int'
   30 |                 ans.at(i)++;
      |                     ^~
a.cc:35:22: warning: ignoring return value of 'bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result]
   35 |             vec.at(i)==vec.at(i+1);
      |             ~~~~~~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:3755:5: note: declared here
 3755 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
a.cc:39:22: warning: ignoring return value of 'bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result]
   39 |             vec.at(i)==vec.at(i-1);
      |             ~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: declared here
 3755 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
a.cc:44:15: error: request for member 'at' in 'ans', which is of non-class type 'int'
   44 |     cout<<ans.at(i)<<endl;
      |               ^~