criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  char key[] = {'R', 'G', 'B'};
  int S[4040];
  int num[] = {0, 0, 0};
  for (int i = 0; i < N; i ++) {
    char c;
    cin >> c;
    for (int j = 0; j < 3; j ++) {
      if (c == key[j]) {
        S[i] = j;
        num[j] ++;
      }
    }
  }
  long long ans = 0ll;
  for (int i = 0; i < N; i ++) {
    for (int j = 0; j < N; j ++) {
      if (S[i] != S[j]) {
        int kj = 3 - i - j;
        int ku = num[kj];
        if (!((k + j) % 2) && S[(k + j) / 2] == kj) {
          ku --;
        }
        int a = 2 * i - j;
        if (a >= 0 && a < N && S[a] == kj) {
          ku --;
        }
        int b = 2 * j - i;
        if (b >= 0 && b < N && S[b] == kj) {
          ku --;
        }
        ans += ku;
      }
    }
  }
  ans /= 3;
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:16: error: 'k' was not declared in this scope; did you mean 'ku'?
   25 |         if (!((k + j) % 2) && S[(k + j) / 2] == kj) {
      |                ^
      |                ku
Language: C

#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int b,c=0;cin>>b;
  vector<char> a(b);
  rep(i,b)cin>>a;
  rep(i,a-2){
    for(int o=i+1;o<a-1;o++){
      for(int j=o+1;j<a;j++){
          if(a[i]!=a[o]&&a[o]!=a[j]&&a[i]!=a[j])c++;
      }
    }
  }
  cout<<c;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for(int i = 0;i <N;i++){
    for(int j = i+1;j <N;j++){
      for(int k = j+1;k <N;k++){
        if(S[i] != S[j] && S[i] != S[k] && S[j] != S[k] && j-i != k-j){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
//#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
int judge(char a) {
    if(a == 'R') return 1;
    if(a == 'G') return 2;
    if(a == 'B') return 3;
}
signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    //j,k決め打ち
    vector<vector<int>> V(3, vector<int>(N + 1, 0));
    rep(i, N) {
        if(S[i] == 'R') V[0][i + 1]++;
        if(S[i] == 'G') V[1][i + 1]++;
        if(S[i] == 'B') V[2][i + 1]++;
        rep(j, 3) V[j][i + 1] += V[j][i];
    }
    int ans = 0;
    for(int k = N - 1; k >= 2; k--) {
        for(int j = k - 1; j > 0; j--) {
            int a = judge(S[k]), b = judge(S[j]);
            if(a == b) continue;
            int c = 6 / a / b;
            ans += V[c - 1][j];
            if(j - (k - j) >= 0 && judge(S[j - (k - j)]) == c) ans--;
        }
    }
    cout << ans << endl;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
  ll N;
  in(N);
  string S;
  in(S);
  int ans =0;
  for(int i=0;i<N;i++){
   for(int j=i+1;j<N;j++){
    for(int k=j+1;k<N;k++){
      if(S[i] != S[j] && S[j] != S[j] != S[k] && S[k] != S[i] && j-i != k-j) ans++;
    }
   }
  }
  out(ans);
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

from itertools import permutations
n = int(input())
s = input()
s_num = []

for i in range(n):
    num = 0
    if s[i] == 'G':
        num = 1
    elif s[i] == 'B':
        num = 2
    s_num.append(num)
# R: 0, G: 1, B: 2

# RGB, RBG, GBR, GRB, BRG, BGR

indexs = [[], [], []]
for i, v in enumerate(s_num):
    indexs[v].append(i)

color_sum = [[len(indexs[0])], [len(indexs[1])], [len(indexs[2])]]
for i in range(n):
    for j in range(3):
        if s_num[i] == j:
            color_sum[j].append(color_sum[j][-1] - 1)
        else:
            color_sum[j].append(color_sum[j][-1])

ans = 0
for i, j, k in permutations([0, 1, 2]):
    for first in indexs[i]:
        for second in indexs[j]:
            if second < first:
                continue
            third_exp = second + (second - first)
            if third_exp < n:
                if s_num[third_exp] == k:
                    ans -= 1
            tmp = color_sum[k][second]
            ans += tmp
#             print(tmp, ans)
# print(color_sum)
print(ans)

Compiler output:
main.c:1:1: error: unknown type name 'from'
    1 | from itertools import permutations
      | ^~~~
main.c:1:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'import'
    1 | from itertools import permutations
      |                ^~~~~~
main.c:1:16: error: unknown type name 'import'
main.c:13:3: error: invalid preprocessing directive #R
   13 | # R: 0, G: 1, B: 2
      |   ^
main.c:15:3: error: invalid preprocessing directive #RGB
   15 | # RGB, RBG, GBR, GRB, BRG, BGR
      |   ^~~
main.c:41:15: error: invalid preprocessing directive #print
   41 | #             print(tmp, ans)
      |               ^~~~~
main.c:42:3: error: invalid preprocessing directive #print
   42 | # print(color_sum)
      |   ^~~~~
Language: C

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int N,cnt,ans;
string s;
vector <int> V1;
vector <int> V2;
int main() {
    cin >> N >> s;
    for(int x=0; x<N; x++) {
        if(s[x] == 'R') V1.push_back(x);
        if(s[x] == 'G') V2.push_back(x);
        if(s[x] == 'B') cnt++;
    }
    for(auto i : V1) {
        for(auto j : V2) {
            int mi = 0;
            int diff = abs(j-i);
            if(i < j) {
                if(j+diff < N && s[j+diff] == 'B') mi++;
                if(i-diff >=0 && s[i-diff] == 'B') mi++;
                if(diff % 2 == 0) {
                    if(s[i + diff/2] == 'B') mi++;
                }
            }
            else {
                if(i+diff < N && s[i+diff] == 'B') mi++;
                if(j-diff >=0 && s[j-diff] == 'B') mi++;
                if(diff % 2 == 0) {
                    if(s[j + diff/2] == 'B') mi++;
                }
            }
            ans += cnt - mi;
        }
    }
    cout<<ans;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }

int main(){
    int n; cin >> n;
    string s; cin >> s;
    ll ans = 0;
    rep(i,n-3){
        if(s[i] == 'R'){
            for(int j = i+1; j < n-1; j++){
                if(s[j] == 'R') continue;
                if(s[j] == 'G'){
                    for(int k = j+1; k < n; k++){
                        if(k-j == j-i) continue;
                        if(s[k] == 'B') ans++;
                    }
                }
                if(s[j] == 'B'){
                    for(int k = j+1; k < n; k++){
                        if(k-j == j-i) continue;
                        if(s[k] == 'G') ans++;
                    }
                }
            }
        } else if(s[i] == 'G'){
            for(int j = i+1; j < n-1; j++){
                if(s[j] == 'G') continue;
                if(s[j] == 'R'){
                    for(int k = j+1; k < n; k++){
                        if(k-j == j-i) continue;
                        if(s[k] == 'B') ans++;
                    }
                }
                if(s[j] == 'B'){
                    for(int k = j+1; k < n; k++){
                        if(k-j == j-i) continue;
                        if(s[k] == 'R') ans++;
                    }
                }
            }
        } else if(s[i] == 'B'){
            for(int j = i+1; j < n-1; j++){
                if(s[j] == 'B') continue;
                if(s[j] == 'R'){
                    for(int k = j+1; k < n; k++){
                        if(k-j == j-i) continue;
                        if(s[k] == 'G') ans++;
                    }
                }
                if(s[j] == 'G'){
                    for(int k = j+1; k < n; k++){
                        if(k-j == j-i) continue;
                        if(s[k] == 'R') ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;
long long n,ans,pref[4001][3],vals[4001];
string s;

int main(){
    cin >> n >> s;
    for(int i = 0 ; i < n ; i += 1){
        if(s[i] == 'R'){
            vals[i] = 0;
        }else if(s[i] == 'G'){
            vals[i] = 1;
        }else{
            vals[i] = 2;
        }
    }
    for(int i = n-1 ; i >= 0 ; i -= 1){
        for(int j = 0 ; j < 3 ; j += 1){
            pref[i][j] = pref[i+1][j];
        }
        pref[i][vals[i]] += 1;
    }
    for(int i = 0 ; i+1 < n ; i += 1){
        for(int j = i+1 ; j < n ; j += 1){
            if(vals[j] == vals[i]){
                continue;
            }
            ans += pref[j][3-vals[i]-vals[j]];
            if(2*j-i < n && vals[2*j-i] == 3-vals[i]-vals[j]){
                ans -= 1;
            }
        }
    }
    cout << ans << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const ll mod=1e9+7;

void solve(){
    int n; string s; cin>>n>>s;
    int dp[n][3];
    dp[n-1][0]=(s[n-1]=='R');
    dp[n-1][1]=(s[n-1]=='G');
    dp[n-1][2]=(s[n-1]=='B');
    ll ans=0;
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<3;j++){
            dp[i][j]=dp[i+1][j];
        }
        if(s[i]=='R') dp[i][0]++;
        else if(s[i]=='G') dp[i][1]++;
        else dp[i][2]++;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n-1;j++){
            if(s[i]==s[j]) continue;
            int k=0;
            if( (s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R') ) k=2;
            else if( (s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R') ) k=1;
            ans+=dp[j+1][k];
            if(j+j-i < n){

                if(s[j+j-i] =='R' && k==0) ans--;
                else if(s[j+j-i]=='G' && k==1) ans--;
                else if(s[j+j-i]=='B' && k==2) ans--;
            }
        }
    }
    cout<<ans<<'\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

//#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <set>

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 5e5+3;
const int INF = 1e9;


int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    string s; cin >> s;
    int r=0,b=0,g=0;
    for(char c: s) {
        if(c == 'R') r++;
        else if(c == 'B') b++;
        else g++;
    }

    LL ans = 1LL*r*b*g;
    fore(l,1,n) {
        fori(i,n) {
            int j = i+l;
            int k = j+l;
            if(k >= n) break;
            set<char> sc;
            sc.insert(s[i]);
            sc.insert(s[j]);
            sc.insert(s[k]);
            if(sc.size() == 3) ans--;
        }
    }

    cout << ans << endl;
    return 0;
}


Compiler output:
main.c:2:10: fatal error: iostream: No such file or directory
    2 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<long long,long long>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a);}
                a=(a*a);
                b>>=1;
        }
    return ans;
        
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int>v1,v2,v3;
    for(int i=0;i<n;i++){
        if(s[i]=='R')v1.push_back(i);
        else if(s[i]=='G')v2.push_back(i);
        else v3.push_back(i);
    }
    int ans=0;
    for(auto i:v1){
        int j=lower_bound(v2.begin(),v2.end(),i)-v2.begin();
        for(int k=j;k<v2.size();k++){
            int l=lower_bound(v3.begin(),v3.end(),v2[k])-v3.begin();
            ans+=v3.size()-l;
            if(binary_search(v3.begin(),v3.end(),i+2*(v2[k]-i)))ans--;
        }
    }
    for(auto i:v1){
        int j=lower_bound(v3.begin(),v3.end(),i)-v3.begin();
        for(int k=j;k<v3.size();k++){
            int l=lower_bound(v2.begin(),v2.end(),v3[k])-v2.begin();
            ans+=v2.size()-l;
            if(binary_search(v2.begin(),v2.end(),i+2*(v3[k]-i)))ans--;
        }
    }
    for(auto i:v2){
        int j=lower_bound(v3.begin(),v3.end(),i)-v3.begin();
        for(int k=j;k<v3.size();k++){
            int l=lower_bound(v1.begin(),v1.end(),v3[k])-v1.begin();
            ans+=v1.size()-l;
            if(binary_search(v1.begin(),v1.end(),i+2*(v3[k]-i)))ans--;
        }
    }
    for(auto i:v2){
        int j=lower_bound(v1.begin(),v1.end(),i)-v1.begin();
        for(int k=j;k<v1.size();k++){
            int l=lower_bound(v3.begin(),v3.end(),v1[k])-v3.begin();
            ans+=v3.size()-l;
            if(binary_search(v3.begin(),v3.end(),i+2*(v1[k]-i)))ans--;
        }
    }
    for(auto i:v3){
        int j=lower_bound(v2.begin(),v2.end(),i)-v2.begin();
        for(int k=j;k<v2.size();k++){
            int l=lower_bound(v1.begin(),v1.end(),v2[k])-v1.begin();
            ans+=v1.size()-l;
            if(binary_search(v1.begin(),v1.end(),i+2*(v2[k]-i)))ans--;
        }
    }
    for(auto i:v3){
        int j=lower_bound(v1.begin(),v1.end(),i)-v1.begin();
        for(int k=j;k<v1.size();k++){
            int l=lower_bound(v2.begin(),v2.end(),v1[k])-v2.begin();
            ans+=v2.size()-l;
            if(binary_search(v2.begin(),v2.end(),i+2*(v1[k]-i)))ans--;
        }
    }
    cout<<ans;
    return 0;
}

Compiler output:
main.c:4:9: fatal error: bits/stdc++.h: No such file or directory
    4 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

/* author   : mpily :-()
title : Competing.cpp
time :Fri Apr 10 17:19:34 2020

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int dp[4002][3];//dp[i][0] = number of R.. [i][1] number of B...[i][2] number of G
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	string s;
	map<char,int>nums;
	nums['R'] = 0;
	nums['B'] = 1;
	nums['G'] = 2;
	cin >> n >> s;
	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;
	for(int i = 0; i < n; ++i){
		if(i){
			dp[i][0] = dp[i-1][0];
			dp[i][1] = dp[i-1][1];
			dp[i][2] = dp[i-1][2];
		}
		dp[i][nums[s[i]]]+=1;
	}
	long long ans = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
			if(s[i] == s[j])continue;
			int tot = 'R'+'G'+'B';
			tot-=s[i];
			tot-=s[j];
			char a = tot;
			ans+=(dp[n-1][nums[a]] - dp[j][nums[a]]);
			if(s[j+j-i] == a)ans-=1;
		//	cout<<"at position "<<i<<" "<<s[i]<<" "<<s[j]<<" :: "<<a<<" "<<dp[n-1][nums[a]] - dp[j][nums[a]]<<"\n";
		}
	}
	cout<<ans<<"\n";
	return 0;
}


Compiler output:
main.c:6:9: fatal error: bits/stdc++.h: No such file or directory
    6 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  string S; cin>>S;
  int ans=0;
  vi R(N+1),G(N+1),B(N+1);
  REP(i,1,N){
    R[N-i]=R[N-i+1];
    G[N-i]=G[N-i+1];
    B[N-i]=B[N-i+1];
    if(S[N-i]=='R') R[N-i]++;
    else if(S[N-i]=='G') G[N-i]++;
    else B[N-i]++;
  }
  rep(i,0,N-2){
    rep(j,i+1,N-1){
      set<char> S;
      S.insert('R');
      S.insert('G');
      S.insert('B');
      S.erase(S[i]);
      S.erase(S[j]);
      if(S.size()==1){
        char X=*S.begin();
        if(X=='R'){
          ans+=R[j];
        }
        else if(X=='B'){
          ans+=B[j];
        }
        else{
          ans+=G[j];
        }
        int k=j+j-i;
        if(k<N&&S[k]==X) ans--;
      }
    }
  }
  cout<<ans<<endl;
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:38:16: error: no match for 'operator[]' (operand types are 'std::set<char>' and 'long long int')
   38 |       S.erase(S[i]);
      |                ^
a.cc:39:16: error: no match for 'operator[]' (operand types are 'std::set<char>' and 'long long int')
   39 |       S.erase(S[j]);
      |                ^
a.cc:52:18: error: no match for 'operator[]' (operand types are 'std::set<char>' and 'long long int')
   52 |         if(k<N&&S[k]==X) ans--;
      |                  ^
Language: C

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r=0, g=0, b=0;
  for (int i=0; i<n; i++) {
    if (s[i] == 'R') r++;
    else if (s[i] == 'G') g++;
    else b++;
  }
  int ans = r * g * b;

  for (int m=1; m<n; m++) {
    for (int i = 0; (i+m+m)<n; i++) {
      char x, y, z;
      x = s[i];
      y = s[i+m];
      z = s[i+m+m];
      if (x != y && y != z && z != x) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 4001

int N;
string S;

map <char,int> idx = {{'R',0},{'G',1},{'B',2}};

int dp[maxn][(1<<4)];

int dpf(int i,int bm){
	if (dp[i][bm] != -1) return dp[i][bm];
	
	if (bm == (1<<3) - 1) return 1;
	if (i == N) return 0;
	
	if (bm & (1<<idx[S[i]])) dp[i][bm] = dpf(i + 1, bm);
	else dp[i][bm] = dpf(i + 1,bm) + dpf(i + 1, bm | (1<<idx[S[i]]));
	
	return dp[i][bm];
}

int main(){
	fast;
	
	cin>>N>>S;
	
	mem(dp,-1);
	
	
	
	int ans = dpf(0,0);
	
	FOR(i,0,N-1){
		FOR(j,i+1,N-1){
			if (S[i] == S[j]) continue;
			
			int k = j + (j - i);
			
			if (k < N && S[k] != S[i] && S[k] != S[j]){
				//cout<<i<<' '<<j<<' '<<k<<'\n';
				ans--;
			}
		}
		
	}
	
	cout<<ans;
				
}



Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;

#define int ll
#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}

int32_t main() {
	int n;
	string s;
	cin >> n >> s;
	// vvi pref(n, vi(3, 0));
	// vvi suff(n, vi(3, 0));
	int pref[3] = {0}, suff[3] = {0};
	for(int i = 1; i < n; i++) {
		if(s[i] == 'R')
			suff[0] += 1;
		else if(s[i] == 'G')
			suff[1]++;
		else
			suff[2]++;
	}
	int res = 0;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'R') {
			res += pref[1]*suff[2] + pref[2]*suff[1];
			for(int j = 1; ; j++) {
				if(i + j >= n || i - j < 0)
					break;
				if(s[i + j] == 'G' && s[i - j] == 'B')
					res--;
				if(s[i + j] == 'B' && s[i - j] == 'G')
					res--;
			}
			pref[0]++;
			if(i + 1 < n) {
				if(s[i + 1] == 'R')
					suff[0]--;
				else if(s[i + 1] == 'G')
					suff[1]--;
				else
					suff[2]--;
			}
		}
		if(s[i] == 'G') {
			res += pref[0]*suff[2] + pref[2]*suff[0];
			for(int j = 1; ; j++) {
				if(i + j >= n || i - j < 0)
					break;
				if(s[i + j] == 'R' && s[i - j] == 'B')
					res--;
				if(s[i + j] == 'B' && s[i - j] == 'R')
					res--;
			}
			pref[1]++;
			if(i + 1 < n) {
				if(s[i + 1] == 'R')
					suff[0]--;
				else if(s[i + 1] == 'G')
					suff[1]--;
				else
					suff[2]--;
			}
		}
		if(s[i] == 'B') {
			res += pref[1]*suff[0] + pref[0]*suff[1];
			for(int j = 1; ; j++) {
				if(i + j >= n || i - j < 0)
					break;
				if(s[i + j] == 'G' && s[i - j] == 'R')
					res--;
				if(s[i + j] == 'R' && s[i - j] == 'G')
					res--;
			}
			if(i + 1 < n) {
				if(s[i + 1] == 'R')
					suff[0]--;
				else if(s[i + 1] == 'G')
					suff[1]--;
				else
					suff[2]--;
			}
			pref[2]++;
		}
	}
	cout << res;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

  int main(){
   lint n;
   lint countr=0;
   lint countg=0;
   lint countb=0;
   string s;
   cin>>n>>s;
   rep(i,s.size()){
       if(s[i]=='R')countr++;
       if(s[i]=='G')countg++;
       if(s[i]=='B')countb++;
   }
   lint ans=countr*countg*countb;
   lint countx=0;
    
   repp(i,1,n){
        rep(j,s.size()){
            if(s.size()-1<j+i*2)break;
                if(s[j]=='R'&&s[j+i]=='G'&&s[j+i*2]=='B')countx++;
                if(s[j]=='R'&&s[j+i]=='B'&&s[j+i*2]=='G')countx++;
                if(s[j]=='G'&&s[j+i]=='R'&&s[j+i*2]=='B')countx++;
                if(s[j]=='G'&&s[j+i]=='B'&&s[j+i*2]=='R')countx++;
                if(s[j]=='B'&&s[j+i]=='G'&&s[j+i*2]=='R')countx++;
                if(s[j]=='B'&&s[j+i]=='R'&&s[j+i*2]=='G')countx++;
        }
   }
    cout<<ans-countx;
  }
  
     


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N;
  string S;
  cin>>N>>S;
  ll res=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i+j<N&&i-j>=0&&S[i-j]!=S[i+j]&&S[i]!=S[i-j]&&S[i]!=S[i+j])res++;
    }
  }
  ll ans=0;
  vector<int>lR(N),rR(N);
  vector<int>lG(N),rG(N);
  vector<int>lB(N),rB(N);
  for(int i=1;i<N;i++){
    lR[i]=lR[i-1];
    lG[i]=lG[i-1];
    lB[i]=lB[i-1];
    if(S[i-1]=='R')lR[i]++;
    if(S[i-1]=='G')lG[i]++;
    if(S[i-1]=='B')lB[i]++;
  }
  for(int i=N-2;i>=0;i--){
    rR[i]=rR[i+1];
    rG[i]=rG[i+1];
    rB[i]=rB[i+1];
    if(S[i+1]=='R')rR[i]++;
    if(S[i+1]=='G')rG[i]++;
    if(S[i+1]=='B')rB[i]++;
  }
  for(int i=1;i<N-1;i++){
    if(S[i]=='R')ans+=lG[i]*rB[i]+lB[i]*rG[i];
    if(S[i]=='G')ans+=lR[i]*rB[i]+lB[i]*rR[i];
    if(S[i]=='B')ans+=lR[i]*rG[i]+lG[i]*rR[i];
  }
  cout<<ans-res<<endl;
  return 0;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 1e5+5;
const int MOD = 10000;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }

 int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int n;cin>>n;
	string s;cin>>s;
	ll ans = 0;
	_for(i,0,n-2){
		_for(j,i+1,n-1){
			_for(k,j+1,n){
				if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k]){
					if(j-i!=k-j)++ans;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Compiler output:
main.c:4:10: fatal error: bits/stdc++.h: No such file or directory
    4 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <iostream>

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;

    ll ans = 0;

    int r[n+1]={0},g[n+1]={0},b[n+1]={0};

    for(int i=n-1 ; i>=0 ; i--)
    {
        if(s[i]=='R')
            r[i] = r[i+1]+1;
        else
            r[i] = r[i+1];
    }

      for(int i=n-1 ; i>=0 ; i--)
    {
        if(s[i]=='G')
            g[i] = g[i+1]+1;
        else
            g[i] = g[i+1];
    }


      for(int i=n-1 ; i>=0 ; i--)
    {
        if(s[i]=='B')
            b[i] = b[i+1]+1;
        else
            b[i] = b[i+1];
    }



    for(int i=0 ; i<n ; i++)
    {
        for(int j=i+1 ; j<n ; j++)
        {
            if(s[i]=='R' && s[j]=='B')
            {
                ans += g[j+1];
                if(j+(j-i) < n && s[j+(j-i)]=='G')
                    ans--;
            }
            else if(s[i]=='R' && s[j]=='G')
            {
                ans += b[j+1];
                 if(j+(j-i) < n && s[j+(j-i)]=='B')
                    ans--;
            }
            else if(s[i]=='G' && s[j]=='R')
            {
                ans += b[j+1];
                 if(j+(j-i) < n && s[j+(j-i)]=='B')
                    ans--;
            }
            else if(s[i]=='G' && s[j]=='B')
            {
                ans += r[j+1];
                 if(j+(j-i) < n && s[j+(j-i)]=='R')
                    ans--;
            }
            else if(s[i]=='B' && s[j]=='G')
            {
                ans += r[j+1];
                 if(j+(j-i) < n && s[j+(j-i)]=='R')
                    ans--;
            }
            else if(s[i]=='B' && s[j]=='R')
            {
                ans += g[j+1];
                 if(j+(j-i) < n && s[j+(j-i)]=='G')
                    ans--;
            }
        }
    }
    cout << ans;
    return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
const int N = 200001;
using namespace std;




int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n;
    string s;
    cin >> n >> s;
    int dp[n + 1][3];
    memset(dp, 0, sizeof dp);

    for (int i = 0; i < n; i++) {
        dp[i + 1][0] = dp[i][0];
        dp[i + 1][1] = dp[i][1];
        dp[i + 1][2] = dp[i][2];

        if (s[i] == 'R') ++dp[i + 1][0];
        if (s[i] == 'G') ++dp[i + 1][1];
        if (s[i] == 'B') ++dp[i + 1][2];

    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 3; j < n; j++) {
            if (s[i] != s[j]) {
                int tarL;
                char ot;
                if (s[i] != 'R' && s[j] != 'R') {
                    tarL = 0;
                    ot = 'R';
                }
                if (s[i] != 'G' && s[j] != 'G') {
                    tarL = 1;
                    ot = 'G';
                }
                if (s[i] != 'B' && s[j] != 'B') {
                    tarL = 2;
                    ot = 'B';
                }

                ans += dp[j][tarL] - dp[i + 1][tarL];
                if ((j - i) % 2 == 0 && s[(i + j) / 2] == ot) {
                    --ans;
                }
            }
        }
    }

    cout << ans;


}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#pragma GCC optimize("O3")
#pragma GCC target("avx512")

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong r[4096];
llong g[4096];
llong b[4096];
string s;

int main() {
    cin >> n;
    cin >> s;

    for (int i = 0; i < n; i++) {
        r[i + 1] += r[i];
        g[i + 1] += g[i];
        b[i + 1] += b[i];

        if (s[i] == 'R') r[i + 1]++;
        if (s[i] == 'G') g[i + 1]++;
        if (s[i] == 'B') b[i + 1]++;
    }

    llong sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (s[i] == s[j]) continue;

            if (s[i] != 'R' && s[j] != 'R') {
                if (2 * j - i < n && s[2 * j - i] == 'R') {
                    sum += r[n] - r[j] - 1;
                }
                else {
                    sum += r[n] - r[j];
                }
            }
            else if (s[i] != 'G' && s[j] != 'G') {
                if (2 * j - i < n && s[2 * j - i] == 'G') {
                    sum += g[n] - g[j] - 1;
                }
                else {
                    sum += g[n] - g[j];
                }
            }
            else if (s[i] != 'B' && s[j] != 'B') {
                if (2 * j - i < n && s[2 * j - i] == 'B') {
                    sum += b[n] - b[j] - 1;
                }
                else {
                    sum += b[n] - b[j];
                }
            }
        }
    }
    
    cout << sum << endl;

    return 0;
}


Compiler output:
cc1plus: error: attribute 'target' argument 'avx512' is unknown
cc1plus: error: attribute 'target' argument 'avx512' is unknown
Language: C

from collections import defaultdict


def main():
    N = int(input())
    S = input()

    c = 0

    for i in range(N):
        for j in range(i, N):
            for k in range(j, N):
                if j - i != k - j and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                    c += 1

    print(c)


if __name__ == '__main__':
    main()


Compiler output:
main.c:1:1: error: unknown type name 'from'
    1 | from collections import defaultdict
      | ^~~~
main.c:1:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'import'
    1 | from collections import defaultdict
      |                  ^~~~~~
main.c:1:18: error: unknown type name 'import'
main.c:19:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   19 | if __name__ == '__main__':
      |                ^~~~~~~~~~
Language: C

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    if(a%b == 0) return b;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}



int main(){
    cin >> N;
    ll R = 0,G=0,B=0;
    string str;
     cin >> str;
     REP(i,N){
         if(str[i] == 'R') ++R;
         if(str[i] == 'B') ++B;
         if(str[i] == 'G') ++G;
     }
     //cout << R << " " << B <<  " " << G;
     ll ansu = R*(R-1)*(B+G)/2 + B*(B-1) * (R + G)/2 + G*(G-1) * (R+B)/2;
     ansu += R * (R-1)*(R-2)/6 + B * (B-1) * (B-2)/6 + G * (G-1) * (G-2)/6;
     for(int i = 0; i < N; ++i){
         for(int l = 1; l < N; ++l){
            if(i + 2*l >= N) continue;
            ++ansu;
            if(str[i] == str[i + l] or str[i] == str[i + 2*l] or str[i + l] == str[i + 2*l]) --ansu;
         }
     }
     cout << N * (N-1) * (N-2)/6 - ansu;
    return 0;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<iostream>
using namespace std;
#define int long long int
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    string str;
    cin>>str;
    int suffix1[n+1]={0};
    int suffix2[n+1]={0};
    int suffix3[n+1]={0};
    int i,j;
    for(j=0;j<n;j++)
    {
		if(str[j]=='R')
		{
			suffix1[j]++;
		}
		else if(str[j]=='G')
	    {
			suffix2[j]++;
		}
		else 
		{
			suffix3[j]++;
		}
	}	
	for(j=n-1;j>=0;j--)
	{
		suffix1[j]+=suffix1[j+1];
		suffix2[j]+=suffix2[j+1];
		suffix3[j]+=suffix3[j+1];
	}
	int answer=0;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if((str[i]=='R'&&str[j]=='G')||(str[i]=='G'&&str[j]=='R'))
			{
				answer=answer+suffix3[j];
				int diff=j-i;
				int k=j+diff;
				if(k<n&&str[k]=='B')
				{
					answer--;
				}
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if((str[i]=='R'&&str[j]=='B')||(str[i]=='B'&&str[j]=='R'))
			{
				answer=answer+suffix2[j];
				int diff=j-i;
				int k=j+diff;
				if(k<n&&str[k]=='G')
				{
					answer--;
				}
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if((str[i]=='B'&&str[j]=='G')||(str[i]=='G'&&str[j]=='B'))
			{
				answer=answer+suffix1[j];
				int diff=j-i;
				int k=j+diff;
				if(k<n&&str[k]=='R')
				{
					answer--;
				}
			}
		}
	}
	cout<<answer<<endl;
}


Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = (1e6)+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        int cnt[3][n];
        memset(cnt,0,sizeof(cnt));
        map<char,int> mp;
        mp['R'] = 0;
        mp['G'] = 1;
        mp['B'] = 2;
        for(int i=n-1;i>=0;i--)cnt[mp[s[i]]][i]++;
        for(int i=0;i<3;i++)
        {
            for(int j=n-2;j>=0;j--)cnt[i][j]+=cnt[i][j+1];
        }
        int ans = 0;
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if(s[i]==s[j])continue;
                int k = j+(j-i);
                int col = -1;
                int chk = mp[s[i]]^mp[s[j]];
                if(chk == 1)col = 2;
                else if(chk == 2)col = 1;
                else col = 0;
                if(j+1<n)ans+=cnt[col][j+1];
                if(k<n && mp[s[k]] == col)ans--;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
/*
Test Case
*/


Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

const int MAXN = 4001;

const int MASK = (1 << 3);

int dp[MAXN][MASK];

int bit(char k) {
    if (k == 'R') return 0;
    if (k == 'G') return 1;
    if (k == 'B') return 2;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    dp[0][0] = 1;
    dp[0][1 << bit(s[0])] = 1;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        int cur = (1 << bit(s[i]));
        for (int m = 0; m < (1 << 3); m++) {
            dp[i][m] += dp[i - 1][m];
            if ((m & cur) != 0) continue;
            dp[i][m | cur] += dp[i - 1][m];
        }
    }
    ans = dp[n - 1][7];
    int m;
    for (int i = 1; i < n - 1; i++) {
        for (int d = 1; d <= min(i, n - i - 1); d++) {
            m = (1 << bit(s[i])) + (1 << (bit(s[i - d]))) + (1 << (bit(s[i + d])));
            if (m == 7) {
//                cout << i - d << " " << i << " " << i + d << "\n";
                ans--;
            }
        }
    }
//    dbg(dp[n - 1][7]);
    cout << ans;
    //----------------------------------------------------------------------
    #ifdef LOCAL
        cout << "\n";
        cerr << "Time elapsed: " << (double)clock()/CLOCKS_PER_SEC << "s.\n";
    #endif
}
/*

*/


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vec vector<ll>
#define rev(a); reverse(a.begin(), a.end());
#define sorta(a); sort(a.begin(), a.end());
#define sortd(a); sort(a.begin(), a.end(), greater<int>());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)
#define printarray(a) FOR(Q,0,(int)(a).size()) cout<<(a)[Q]<<" "; cout<<'\n';
#define pb push_back
#define mp make_pair

ll MOD = 1000000007;
ll INF = 1LL << 60;

/*****************************************************************************/


bool same(int i, char c) {
	return ((i==0 && c=='R') || (i==1 && c=='G') || (i==2 && c=='B'));
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;cin>>n;
	string s;cin>>s;
	int cum[n][3];
	FOR(i,0,n) FOR(j,0,3) cum[i][j]=0;
	vector<set<int>> ind (3);
	FOR(i,0,n) {
		if (s[i]=='R') {
			cum[i][0]++;
			ind[0].insert(i);
		}
		if (s[i]=='G') {
			cum[i][1]++;
			ind[1].insert(i);
		}
		if (s[i]=='B') {
			cum[i][2]++;
			ind[2].insert(i);
		}
		if (i==0) continue;
		FOR(j,0,3) {
			cum[i][j]+=cum[i-1][j];
		}
	}

	FOR(j,0,3) {
		FOR(i,0,n) {
			cum[i][j] = cum[n-1][j] - cum[i][j];
			if (same(j, s[i])) cum[i][j]++;
		}
	}

	// FOR(i,0,n) cout<<cum[i][0]<<" ";cout<<endl;
	// for(int i : ind[0]) cout<<i<<" ";
	
	ll out=0;
	FOR(i,0,3) {
		FOR(j,0,3) {
			if (i==j) continue;
			int k=-1;
			FOR(l,0,3) {
				if (l!=i&&l!=j) {
					k=l;
					break;
				}
			}

			FOR(a,0,n-2) {
				if (!same(i,s[a])) continue;
				FOR(b,a+1,n-1) {
					if (!same(j,s[b])) continue;
					out += cum[b+1][k];
					int s = b-a;
					s = b+s;
					if (ind[k].count(s)) {
						out--;
					}
				}
			}
		}
	}

	cout<<out;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.