Language: C++

#include <bits/stdc++.h>

#define forsn(i, s, n)	for (int i = s; i < n; i++)
#define forn(i, n)		for (int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef unsigned int ui;

bool enRango(int x, int min, int max()) {
	return (x >= min && x <= max);
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> r;
	vector<int> g;
	vector<int> b;
	forn(i, n) {
		if (s[i] == 'R')
			r.push_back(i);
		else if (s[i] == 'G')
			g.push_back(i);
		else
			b.push_back(i);
	}
	
	ull ans = 0;
	forn(iR, r.size()) {
		forn(iG, g.size()) {
			ans += b.size();
			int iBForb = (iR+iG)/2;
			if (enRango(iBForb, 0, b.size()-1) && s[iBForb] == 'B' && abs(iBForb-iR) == abs(IBForb-iG))
				ans--;
			iBForb = max(iR, iG) + abs(iR - iG);
			if (enRango(iBForb, 0, b.size()-1) && s[iBForb] == 'B' && abs(iBForb-iR) == abs(IBForb-iG))
				ans--;
			iBForb = min(iR, iG) - abs(iR - iG);
			if (enRango(iBForb, 0, b.size()-1) && s[iBForb] == 'B' && abs(iBForb-iR) == abs(IBForb-iG))
				ans--;
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}


Compiler output:
a.cc: In function 'bool enRango(int, int, int (*)())':
a.cc:12:31: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |         return (x >= min && x <= max);
      |                             ~~^~~~~~
a.cc: In function 'int main()':
a.cc:31:9: error: 'ull' was not declared in this scope; did you mean 'll'?
   31 |         ull ans = 0;
      |         ^~~
      |         ll
a.cc:34:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |                         ans += b.size();
      |                         ^~~
      |                         abs
a.cc:36:56: error: invalid conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int (*)()' [-fpermissive]
   36 |                         if (enRango(iBForb, 0, b.size()-1) && s[iBForb] == 'B' && abs(iBForb-iR) == abs(IBForb-iG))
      |                                                ~~~~~~~~^~
      |                                                        |
      |                                                        std::vector<int>::size_type {aka long unsigned int}
a.cc:11:34: note:   initializing argument 3 of 'bool enRango(int, int, int (*)())'
   11 | bool enRango(int x, int min, int max()) {
      |                              ~~~~^~~~~
a.cc:36:105: error: 'IBForb' was not declared in this scope; did you mean 'iBForb'?
   36 |                         if (enRango(iBForb, 0, b.size()-1) && s[iBForb] == 'B' && abs(iBForb-iR) == abs(IBForb-iG))
      |                                                                                                         ^~~~~~
      |                                                                                                         iBForb
a.cc:39:56: error: invalid conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int (*)()' [-fpermissive]
   39 |                         if (enRango(iBForb, 0, b.size()-1) && s[iBForb] == 'B' && abs(iBForb-iR) == abs(IBForb-iG))
      |                                                ~~~~~~~~^~
      |                                                        |
      |                                                        std::vector<int>::size_type {aka long unsigned int}
a.cc:11:34: note:   initializing argument 3 of 'bool enRango(int, int, int (*)())'
   11 | bool enRango(int x, int min, int max()) {
      |                              ~~~~^~~~~
a.cc:39:105: error: 'IBForb' was not declared in this scope; did you mean 'iBForb'?
   39 |                         if (enRango(iBForb, 0, b.size()-1) && s[iBForb] == 'B' && abs(iBForb-iR) == abs(IBForb-iG))
      |                                                                                                         ^~~~~~
      |                                                                                                         iBForb
a.cc:42:56: error: invalid conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int (*)()' [-fpermissive]
   42 |                         if (enRango(iBForb, 0, b.size()-1) && s[iBForb] == 'B' && abs(iBForb-iR) == abs(IBForb-iG))
      |                                                ~~~~~~~~^~
      |                                                        |
      |                                                        std::vector<int>::size_type {aka long unsigned int}
a.cc:11:34: note:   initializing argument 3 of 'bool enRango(int, int, int (*)())'
   11 | bool enRango(int x, int min, int max()) {
      |                              ~~~~^~~~~
a.cc:42:105: error: 'IBForb' was not declared in this scope; did you mean 'iBForb'?
   42 |                         if (enRango(iBForb, 0, b.size()-1) && s[iBForb] == 'B' && abs(iBForb-iR) == abs(IBForb-iG))
      |                                                                                                         ^~~~~~
      |                                                                                                         iBForb
a.cc:47:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |         cout << ans << '\n';
      |                 ^~~
      |                 abs