Language: C

#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
 
using namespace std;
typedef pair<llint, llint> P;
 
llint n;
string s;
llint sum[3][4005];
 
int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	cin >> s;
	s = "#" + s;
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'R') s[i] = '0';
		if(s[i] == 'G') s[i] = '1';
		if(s[i] == 'B') s[i] = '2';
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 3; j++) sum[j][i] = sum[j][i-1];
		sum[s[i]-'0'][i]++;
	}
	
	for(int i = 1; i <= n; i++){
		llint c = s[i]-'0';
		ans += sum[(c+1)%3][i-1] * (sum[(c+2)%3][n] - sum[(c+2)%3][i]);
		ans += sum[(c+2)%3][i-1] * (sum[(c+1)%3][n] - sum[(c+1)%3][i]);
		for(int j = 1; j <= n; j++){
			if(i-j <= 0 || i+j > n) break;
			if(s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j]) ans--;
		}
	}
	cout << ans << endl;
	
	
	return 0;
}

Compiler output:
main.c:8:1: error: unknown type name 'using'
    8 | using namespace std;
      | ^~~~~
main.c:8:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
    8 | using namespace std;
      |                 ^~~
main.c:9:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    9 | typedef pair<llint, llint> P;
      |             ^
main.c:12:1: error: unknown type name 'string'
   12 | string s;
      | ^~~~~~
main.c: In function 'main':
main.c:17:9: error: 'ios' undeclared (first use in this function)
   17 |         ios::sync_with_stdio(0);
      |         ^~~
main.c:17:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:17:12: error: expected ';' before '::' token
   17 |         ios::sync_with_stdio(0);
      |            ^~
      |            ;
main.c:18:9: error: 'cin' undeclared (first use in this function)
   18 |         cin.tie(0);
      |         ^~~
main.c:22:11: error: assignment to 'int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
   22 |         s = "#" + s;
      |           ^
main.c:26:21: error: subscripted value is neither array nor pointer nor vector
   26 |                 if(s[i] == 'R') s[i] = '0';
      |                     ^
main.c:26:34: error: subscripted value is neither array nor pointer nor vector
   26 |                 if(s[i] == 'R') s[i] = '0';
      |                                  ^
main.c:27:21: error: subscripted value is neither array nor pointer nor vector
   27 |                 if(s[i] == 'G') s[i] = '1';
      |                     ^
main.c:27:34: error: subscripted value is neither array nor pointer nor vector
   27 |                 if(s[i] == 'G') s[i] = '1';
      |                                  ^
main.c:28:21: error: subscripted value is neither array nor pointer nor vector
   28 |                 if(s[i] == 'B') s[i] = '2';
      |                     ^
main.c:28:34: error: subscripted value is neither array nor pointer nor vector
   28 |                 if(s[i] == 'B') s[i] = '2';
      |                                  ^
main.c:32:22: error: subscripted value is neither array nor pointer nor vector
   32 |                 sum[s[i]-'0'][i]++;
      |                      ^
main.c:36:28: error: subscripted value is neither array nor pointer nor vector
   36 |                 llint c = s[i]-'0';
      |                            ^
main.c:41:29: error: subscripted value is neither array nor pointer nor vector
   41 |                         if(s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j]) ans--;
      |                             ^
main.c:41:39: error: subscripted value is neither array nor pointer nor vector
   41 |                         if(s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j]) ans--;
      |                                       ^
main.c:41:47: error: subscripted value is neither array nor pointer nor vector
   41 |                         if(s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j]) ans--;
      |                                               ^
main.c:41:55: error: subscripted value is neither array nor pointer nor vector
   41 |                         if(s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j]) ans--;
      |                                                       ^
main.c:41:65: error: subscripted value is neither array nor pointer nor vector
   41 |                         if(s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j]) ans--;
      |                                                                 ^
main.c:41:75: error: subscripted value is neither array nor pointer nor vector
   41 |                         if(s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j]) ans--;
      |                                                                           ^
main.c:44:9: error: 'cout' undeclared (first use in this function)
   44 |         cout << ans << endl;
      |         ^~~~
main.c:44:24: error: 'endl' undeclared (first use in this function)
   44 |         cout << ans << endl;
      |                        ^~~~