Language: C++

#include <string>
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;
int main()
{
	std::string input;

	std::getline(std::cin, input);
	int N = std::stoi(input[0]);
	int Q = std::stoi(input[2]);

	std::vector<int> golems(N, 1);
	std::unordered_map<char, vector<int>> mapper;
	std::getline(std::cin, input);
	for(int inx = 0; inx < N; inx += 1)
	{
		mapper[input[inx]].emplace_back(inx);
	}

	while(std::getline(std::cin, input))
	{
		vector<int> squares = mapper[input[0]];
		vector<int> preGolems(golems);
		for(int& inx : squares)
		{
			if(input[2] == 'L')
			{
				if(inx > 0)
				{
					golems[inx - 1] += preGolems[inx];
				}
					golems[inx] -= preGolems[inx];
			}
			else
			{
				if(inx < N - 1)
				{
					golems[inx + 1] += preGolems[inx];
				}
					golems[inx] += preGolems[inx];
			}
		}
	}

	int sum = 0;
	for(int& num : golems)
	{
		sum += num;
	}
	std::cout << std::to_string(sum) << std::endl;

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:26: error: no matching function for call to 'stoi(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
   12 |         int N = std::stoi(input[0]);
      |                 ~~~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:22: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'}
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidate: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:23: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~
a.cc:13:26: error: no matching function for call to 'stoi(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
   13 |         int Q = std::stoi(input[2]);
      |                 ~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:22: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'}
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidate: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:23: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~