Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
typedef pair<char, char> cc;
typedef pair<char, int> ci;
using namespace std;

int main()
{
    int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
    vector<ci> spaces;
	vector<cc> moves;

	for(int i = 0; i < q; ++i){
		cc pair;
		cin >> pair.first >> pair.second;
		moves.push_back(pair);
	}
	for (int i = 0; i < s.length(); ++i){
		spaces.push_back(ci(s[i], 1));
	}

	for (int i = 0; i < q; ++i){
		auto move = moves[i];
		for (int j = 0; j < n; ++j){
			if (move.first == spaces[j].first){
					spaces[j].second--;
				if (move.second == 'L'){
					if (j > 0){
						spaces[j-1].second++;
					}

				} else { // R
					if (j < n - 1){
						spaces[j+1].second++;
					}
				}
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < n; ++i){
		sum += spaces[i].second;
	}
	cout << sum;
}

Compiler output:
a.cc:5:9: error: 'pair' does not name a type
    5 | typedef pair<char, char> cc;
      |         ^~~~
a.cc:6:9: error: 'pair' does not name a type
    6 | typedef pair<char, int> ci;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:15:12: error: 'ci' was not declared in this scope
   15 |     vector<ci> spaces;
      |            ^~
a.cc:15:14: error: template argument 1 is invalid
   15 |     vector<ci> spaces;
      |              ^
a.cc:15:14: error: template argument 2 is invalid
a.cc:16:16: error: 'cc' was not declared in this scope
   16 |         vector<cc> moves;
      |                ^~
a.cc:16:18: error: template argument 1 is invalid
   16 |         vector<cc> moves;
      |                  ^
a.cc:16:18: error: template argument 2 is invalid
a.cc:19:19: error: expected ';' before 'pair'
   19 |                 cc pair;
      |                   ^~~~~
      |                   ;
a.cc:20:28: error: missing template arguments before '.' token
   20 |                 cin >> pair.first >> pair.second;
      |                            ^
a.cc:20:42: error: missing template arguments before '.' token
   20 |                 cin >> pair.first >> pair.second;
      |                                          ^
a.cc:21:23: error: request for member 'push_back' in 'moves', which is of non-class type 'int'
   21 |                 moves.push_back(pair);
      |                       ^~~~~~~~~
a.cc:21:37: error: missing template arguments before ')' token
   21 |                 moves.push_back(pair);
      |                                     ^
a.cc:24:24: error: request for member 'push_back' in 'spaces', which is of non-class type 'int'
   24 |                 spaces.push_back(ci(s[i], 1));
      |                        ^~~~~~~~~
a.cc:28:34: error: invalid types 'int[int]' for array subscript
   28 |                 auto move = moves[i];
      |                                  ^
a.cc:30:49: error: invalid types 'int[int]' for array subscript
   30 |                         if (move.first == spaces[j].first){
      |                                                 ^
a.cc:31:47: error: invalid types 'int[int]' for array subscript
   31 |                                         spaces[j].second--;
      |                                               ^
a.cc:34:55: error: invalid types 'int[int]' for array subscript
   34 |                                                 spaces[j-1].second++;
      |                                                       ^
a.cc:39:55: error: invalid types 'int[int]' for array subscript
   39 |                                                 spaces[j+1].second++;
      |                                                       ^
a.cc:48:30: error: invalid types 'int[int]' for array subscript
   48 |                 sum += spaces[i].second;
      |                              ^