Language: C++

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using ll = long long;
using ld = long double;
inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main()
{
    fast_io();
    ll n;
    string s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    cin >> n >> s;
    ll num = 0;
    for (ll i = 0; i < n; i++) {
        if (s[i] == 'R')
            r.push_back(i + 1);
        if (s[i] == 'G')
            g.push_back(i + 1);
        if (s[i] == 'B')
            b.push_back(i + 1);
    }
    for (auto i : r)
        for (auto j : g)
            for (auto k : b) {
                if (2 * j == i + k)
                    continue;
                if (2 * k == i + j)
                    continue;
                if (2 * i == j + k)
                    continue;
                num++;
            }
    cout << num << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'string' was not declared in this scope
   25 |     string s;
      |     ^~~~~~
a.cc:25:5: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:5:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included 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:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:26:5: error: 'vector' was not declared in this scope
   26 |     vector<int> r;
      |     ^~~~~~
a.cc:26:5: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:12:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:26:12: error: expected primary-expression before 'int'
   26 |     vector<int> r;
      |            ^~~
a.cc:27:12: error: expected primary-expression before 'int'
   27 |     vector<int> g;
      |            ^~~
a.cc:28:12: error: expected primary-expression before 'int'
   28 |     vector<int> b;
      |            ^~~
a.cc:29:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   29 |     cin >> n >> s;
      |     ^~~
      |     std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:29:17: error: 's' was not declared in this scope
   29 |     cin >> n >> s;
      |                 ^
a.cc:33:13: error: 'r' was not declared in this scope
   33 |             r.push_back(i + 1);
      |             ^
a.cc:35:13: error: 'g' was not declared in this scope
   35 |             g.push_back(i + 1);
      |             ^
a.cc:37:13: error: 'b' was not declared in this scope
   37 |             b.push_back(i + 1);
      |             ^
a.cc:39:19: error: 'r' was not declared in this scope
   39 |     for (auto i : r)
      |                   ^
a.cc:40:23: error: 'g' was not declared in this scope
   40 |         for (auto j : g)
      |                       ^
a.cc:41:27: error: 'b' was not declared in this scope
   41 |             for (auto k : b) {
      |                           ^
a.cc:50:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   50 |     cout << num << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:50:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   50 |     cout << num << endl;
      |                    ^~~~
      |                    std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~