Language: C++

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator
i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(),
j)-lower_bound(array.begin(), array.end(), i) //number of numbers
between i & j
#define vc clear()
#define fbo find_by_order //returns iterator
#define fok order_of_key //return index
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time
elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return
0
lli mod=998244353;
//string s=bitset<32>(n).to_string();
typedef tree<lli,null_type,less<lli>,rb_tree_tag, // change both to
lli if set is req insted of multiset
tree_order_statistics_node_update> indexed_set;
int main()
{
        lli n;cin>>n;
        string s;
        cin>>s;
        lli r=0,g=0,b=0;
        for(lli i=0;i<n;i++){
                if(s[i]=='R')r++;
                else if(s[i]=='G')g++;
                else b++;
        }
        lli temp=r*g*b;
        //lli temp2=0;
        for(lli i=0;i<n;i++){
                for(lli j=i+1;j<n;j++){
                        if(s[i]==s[j])continue;
                        lli k=j+(j-i);
                        if(k>=n)continue;
                        if(s[k]==s[i] || s[k]==s[j])continue;
                        temp--;
                }
        }
        cout<<temp;

    return 0;
}

Compiler output:
a.cc:46:62: warning: missing terminating " character
   46 | #define end_routine() int endtime = clock(); cerr << endl << "Time
      |                                                              ^
a.cc:47:62: warning: missing terminating " character
   47 | elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return
      |                                                              ^
a.cc:47:62: error: missing terminating " character
   47 | elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return
      |                                                              ^~~~~~~~~
a.cc:23:1: error: 'i' does not name a type; did you mean 'fi'?
   23 | i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
      | ^
      | fi
a.cc:23:16: error: 'i' does not name a type; did you mean 'fi'?
   23 | i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
      |                ^
      |                fi
a.cc:23:30: error: 'i' does not name a type; did you mean 'fi'?
   23 | i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
      |                              ^
      |                              fi
a.cc:36:1: error: 'j' does not name a type
   36 | j)-lower_bound(array.begin(), array.end(), i) //number of numbers
      | ^
a.cc:53:34: error: template argument 5 is invalid
   53 | tree_order_statistics_node_update> indexed_set;
      |                                  ^