Language: C++

#include<iostream>
#include<string>
#include<vector>
using namespace std;

int n,q;//nはマスの数で、qは唱える呪文の回数
vector<char>t(q),d(q);//tはアルファベットで、dは左右を表す
int main(){
    //入力
    cin >> n >> q;
    for(int i=0; i<q;i++)
    {
        cin >> t[i] >> d[i];
    }

    //処理
    /*考え方：最終的に何体のロボットが残っているかを考える。探す際は二分探索を用いる
    1.
    */
   int left=-1; right=n;
   for(int i=q-1; i>=0;i--)
   {
       if(d[i]=='L' and t[i]==s[left+1])left++;
       if(d[i]=='R' and t[i]==s[right-1])right++;
       if(d[i]=='L' and t[i]==s[right])right++;
       if(d[i]=='R' and t[i]==s[left])left++;
   }

   //出力
   cout << max(0,right-left-1) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:22: error: assignment of function 'std::ios_base& std::right(ios_base&)'
   20 |    int left=-1; right=n;
      |                 ~~~~~^~
a.cc:23:31: error: 's' was not declared in this scope
   23 |        if(d[i]=='L' and t[i]==s[left+1])left++;
      |                               ^
a.cc:24:31: error: 's' was not declared in this scope
   24 |        if(d[i]=='R' and t[i]==s[right-1])right++;
      |                               ^
a.cc:24:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   24 |        if(d[i]=='R' and t[i]==s[right-1])right++;
      |                                 ~~~~~^~
a.cc:24:42: warning: ISO C++ forbids incrementing a pointer of type 'std::ios_base& (*)(std::ios_base&)' [-Wpointer-arith]
   24 |        if(d[i]=='R' and t[i]==s[right-1])right++;
      |                                          ^~~~~
a.cc:24:47: error: lvalue required as increment operand
   24 |        if(d[i]=='R' and t[i]==s[right-1])right++;
      |                                               ^~
a.cc:25:31: error: 's' was not declared in this scope
   25 |        if(d[i]=='L' and t[i]==s[right])right++;
      |                               ^
a.cc:25:40: warning: ISO C++ forbids incrementing a pointer of type 'std::ios_base& (*)(std::ios_base&)' [-Wpointer-arith]
   25 |        if(d[i]=='L' and t[i]==s[right])right++;
      |                                        ^~~~~
a.cc:25:45: error: lvalue required as increment operand
   25 |        if(d[i]=='L' and t[i]==s[right])right++;
      |                                             ^~
a.cc:26:31: error: 's' was not declared in this scope
   26 |        if(d[i]=='R' and t[i]==s[left])left++;
      |                               ^
a.cc:30:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |    cout << max(0,right-left-1) << endl;
      |                  ~~~~~^~~~~
a.cc:30:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |    cout << max(0,right-left-1) << endl;
      |                  ~~~~~~~~~~^~
a.cc:30:15: error: no matching function for call to 'max(int, std::ios_base& (*)(std::ios_base&))'
   30 |    cout << max(0,right-left-1) << endl;
      |            ~~~^~~~~~~~~~~~~~~~
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:30:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::ios_base& (*)(std::ios_base&)')
   30 |    cout << max(0,right-left-1) << endl;
      |            ~~~^~~~~~~~~~~~~~~~
/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