Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define for(i,a,b) for(ll i=a;i<b;i++)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  int n;
  string s;
  cin >> n >> s;
  vl r_dp(n,0),g_dp(n,0),b_dp(n,0);
  for(int i=1;i<n;i++){
    if(s[i]=='R'){
      r_dp[i]=r_dp[i-1]+1;
    }
    if(s[i]=='G'){
      g_dp[i]=g_dp[i-1]+1;
    }
    else
      b_dp[i]=b_dp[i-1]+1;
  }
  ll cnt=0;
  for(int i=1;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(s[i]!=s[j]){
        if(s[i]!='R'&&s[j]!='R'){
          cnt +=r_dp[i-1];
          if(2*i-j>=0&&s[2*i-j]=='R'){
            cnt--;
          }
        }
        if(s[i]!='G'&&s[j]!='G'){
            cnt +=g_dp[i-1];
            if(2*i-j>=0&&s[2*i-j]=='G'){
              cnt--;
           }
         }
    if(s[i]!='B'&&s[j]!='B'){
          cnt +=b_dp[i-1];
          if(2*i-j>=0&&s[2*i-j]=='B'){
            cnt--;
          }
        }
      }
    }
  }
  cout << cnt << endl;
}

Compiler output:
a.cc:19:22: error: macro "for" requires 3 arguments, but only 1 given
   19 |   for(int i=1;i<n;i++){
      |                      ^
a.cc:10:9: note: macro "for" defined here
   10 | #define for(i,a,b) for(ll i=a;i<b;i++)
      |         ^~~
a.cc:30:24: error: macro "for" requires 3 arguments, but only 1 given
   30 |   for(int i=1;i<n-1;i++){
      |                        ^
a.cc:10:9: note: macro "for" defined here
   10 | #define for(i,a,b) for(ll i=a;i<b;i++)
      |         ^~~
a.cc:31:26: error: macro "for" requires 3 arguments, but only 1 given
   31 |     for(int j=i+1;j<n;j++){
      |                          ^
a.cc:10:9: note: macro "for" defined here
   10 | #define for(i,a,b) for(ll i=a;i<b;i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:19:23: error: expected '(' before '{' token
   19 |   for(int i=1;i<n;i++){
      |                       ^
      |                       (
a.cc:19:23: error: expected primary-expression before '{' token
a.cc:30:3: error: expected primary-expression before 'for'
   30 |   for(int i=1;i<n-1;i++){
      |   ^~~
a.cc:29:12: error: expected ')' before 'for'
   29 |   ll cnt=0;
      |            ^
      |            )
   30 |   for(int i=1;i<n-1;i++){
      |   ~~~       
a.cc:19:23: note: to match this '('
   19 |   for(int i=1;i<n;i++){
      |                       ^
a.cc:30:25: error: expected '(' before '{' token
   30 |   for(int i=1;i<n-1;i++){
      |                         ^
      |                         (
a.cc:30:25: error: expected primary-expression before '{' token
a.cc:55:1: error: expected primary-expression before '}' token
   55 | }
      | ^
a.cc:54:23: error: expected ')' before '}' token
   54 |   cout << cnt << endl;
      |                       ^
      |                       )
   55 | }
      | ~                      
a.cc:30:25: note: to match this '('
   30 |   for(int i=1;i<n-1;i++){
      |                         ^
a.cc:55:1: error: expected primary-expression before '}' token
   55 | }
      | ^