[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
create new integer constant INF = 2147483647
define integer constant mod =1000000007
new constant integer tmod = 1000000009
let ma be a map from characters to integers
create new array of integers vis with size 25
declare vector of integers v
declare new array of integers sum with size 25
a1 is an array of integers with 5 elements
create new array of integers a2 with size 5
define the main function
    declare new integer called n
    read variable n from the input
    assign 0 to ma['R']
    change ma['G'] to 1
    assign the new value = 2 to ma['B']
    set ma['Y'] to 3
    assign the new value = 4 to ma['W']
    start for loop from i = 0 to n exclusive
        define string str
        read input to str
        declare new integer tmp = ma[str[0]] * 5 + str[1] - '1'
        change vis[tmp] to 1
    end of the block
    start for loop from i = 0 to 25 exclusive incrementing i
        if vis[i] is true, add i to v
    define integer ans = 10
    in a for loop, change s from 0 to 1 << 10 exclusive
        set the values of first sizeof(a1) bytes at the pointer a1 to 0
        set first sizeof(a2) bytes at the pointer a2 to 0
        change the values of first sizeof(sum) bytes at the pointer sum to 0
        create integer pos with value 1
        for integer i = 0 to 5 exclusive
            if (s >> i) & 1 != 0, change the value of a1[i] to pos and increment pos
        declare integer variable with name pos2 = 1
        for i from 5 to 10 exclusive
            if (s >> i) & 1 != 0, set a2[i % 5] to pos2 and increase pos2 by 1
        for integer i = 0 to (ength of v exclusive
            define integer tmp with value v[i]
            define new integer called l with value = value of a1[tmp / 5]
            new integer r = value of a2[tmp % 5]
            increment sum[l * 5 + r] by one
        end of the block
        create new boolean flag = true
        in a for loop, change i from 0 to 25 exclusive incrementing i
            if sum[i] is greater than 1
                assign the new value = false to flag
                stop the loop
            end of the block
        if flag is false, skip the rest of the loop
        change ans to min of ans and pos - 1 + pos2 - 1
    end of the block
    print ans and '\n'
    return to indicate successful execution
end of the block

[CODE]:

const int INF = 2147483647;
const int mod = 1000000007;
const int tmod = 1000000009;
map<char, int> ma;
int vis[25];
vector<int> v;
int sum[25];
int a1[5];
int a2[5];
int main() {
    int n;
    cin >> n;
    ma['R'] = 0;
    ma['G'] = 1;
    ma['B'] = 2;
    ma['Y'] = 3;
    ma['W'] = 4;
    for (int i = 0; i < (n); i++) {
        string str;
        cin >> str;
        int tmp = ma[str[0]] * 5 + str[1] - '1';
        vis[tmp] = 1;
    }
    for (int i = 0; i < (25); i++)
        if (vis[i]) v.push_back(i);
    int ans = 10;
    for (int s = 0; s < (1 << 10); s++) {
        memset(a1, 0, sizeof(a1));
        memset(a2, 0, sizeof(a2));
        memset(sum, 0, sizeof(sum));
        int pos = 1;
        for (int i = 0; i < 5; i++)
            if ((s >> i) & 1) a1[i] = pos++;
        int pos2 = 1;
        for (int i = 5; i < 10; i++)
            if ((s >> i) & 1) a2[i % 5] = pos2++;
        for (int i = 0; i < (v.size()); i++) {
            int tmp = v[i];
            int l = a1[tmp / 5];
            int r = a2[tmp % 5];
            sum[l * 5 + r]++;
        }
        bool flag = true;
        for (int i = 0; i < (25); i++)
            if (sum[i] > 1) {
                flag = false;
                break;
            }
        if (!flag) continue;
        ans = min(ans, pos - 1 + pos2 - 1);
    }
    cout << ans << '\n';
    return 0;
}