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

N = int(input())
S = input()
a = S.count("R") * S.count("G") * S.count("B")
c = 0
for i in range(N):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k >= N:
            continue
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            c += 1
print(a - c)


Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | N = int(input())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'N' [-Wimplicit-int]
main.c:1:5: error: expected expression before 'int'
    1 | N = int(input())
      |     ^~~
Language: C

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

int main() {
  int n, r = 0, g = 0, b = 0;
  string s;
  cin >> n >> s;

  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') r++;
    if (s[i] == 'G') g++;
    if (s[i] == 'B') b++;
  }

  int c = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (s[i] != s[j]) {
        for (int k = j + 1; k < n; k++) {
          if (s[i] != s[k] && s[j] != s[k] && (k - j == j - i)) c++;
        }
      }
    }
  }

  cout << r * g * b - c << 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 _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0, g = 0, b = 0;
    rep(i, n){
        if(s.at(i) == 'R') r++;
        if(s.at(i) == 'G') g++;
        if(s.at(i) == 'B') b++;
    }
    ll sum = r*g*b;
    r = 0; g = 0; b = 0;
    REP(i, n){
        rep(j, i){
            for(int k = j; k < n; k+=i){
                if(s.at(k) == 'R') r = 3;
                if(s.at(k) == 'G') g = 3;
                if(s.at(k) == 'B') b = 3;
                if(r > 0 && g > 0 && b > 0) sum--;
                r--; g--; b--;
                //cout << k << " ";
                //cout << r <<" "<< g <<" "<<b << endl;
            }
            //cout << endl;
            r = 0; g = 0; b = 0;
        }
    }
    cout << sum << 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 vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;



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

	int n;
	string s;
	cin >> n >> s;

	int r = 0, g = 0, b = 0;

	rep(i, n) {
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else b++;
	}

	ll ans = r * g * b;

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int k = 2 * j - i;
			if (k >= n) break;
			if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
				ans--;
			}
		}
	}

	out(ans);

	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>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll c1 = 0, c2 = 0, c3 = 0;
    for(ll i = 0; i < n; i++){
        if(s[i]=='R') c1++;
        if(s[i]=='G') c2++;
        if(s[i]=='B') c3++;
    }
    ll ans = c1*c2*c3;
    ll count = 0;
    for(ll i = 1; i < n; i++){
        for(ll j = i; j < n; j++){
            if(j-i < 0 || j+i >= n) break;
            if(s[j-i]!=s[j] && s[j]!=s[j+i] && s[j-i]!=s[j+i]){
                count++;
                //cout << s[j-1] << " " << s[j] << " " << s[j+1] << endl;
            }
        }
    }
    cout << ans-count << endl;
    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 rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    string s;
    cin >> n >> s;
    int r=0,g=0,b=0;
    rep(i,n) {
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    }
    ll ans = r*g*b;
    rep(i,n) rep(j,n) {
        if(i >= j) continue;
        if(s[i] == s[j]) continue;
        int k = 2*j-i;
        if(k < n && s[k] != s[i] && s[k] != s[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>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    string s;
    cin >> n >> s;
    int r=0,g=0,b=0;
    rep(i,n) {
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    }
    ll ans = r*g*b;
    rep(i,n) rep(j,n) {
        if(i >= j) continue;
        if(s[i] == s[j]) continue;
        int k = 2*j-i;
        if(k < n && s[k] != s[i] && s[k] != s[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 rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

string t = "RGB";

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<int>> v(3, vector<int>(n,0));
	vector<map<int,int>> mp(3);
	rep(i,n){
		if(s[i] == 'R') {
			v[0][i]++;
			mp[0][i]++;
		}
		if(s[i] == 'G'){
			v[1][i]++;
			mp[1][i]++;
		}
		if(s[i] == 'B'){
			v[2][i]++;
			mp[2][i]++;
		}
	}
	rep(i,3){
		rep(j,n){
			if(j>0) v[i][j] += v[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 id;
			rep(k,3){
				if(t[k] != s[i] && t[k] != s[j]) id = k;
			}
			ans += v[id][n-1] - v[id][j];
			if(2*j-i<n && mp[id][2*j-i] != 0) 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>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    int N;
    string S;
    cin >> N >> S;

    int rc = 0, gc = 0, bc = 0;
    for(char c: S){
        if(c == 'R') rc++;
        if(c == 'G') gc++;
        if(c == 'B') bc++;
    }
    ll ans = rc * gc * bc;
    for(int i = 1; i < S.size(); i++){ // 幅
        for(int j = 0; j < S.size(); j++){ //比較箇所のスライド
            if(j + i + i >= S.size()) break;
            string str;
            str.push_back(S[j]);
            str.push_back(S[j + i]);
            str.push_back(S[j + i + i]);
            sort(str.begin(), str.end());
            if (str == "BGR") {
                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<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

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


int solve( int x ){
    if( x == 0 )return 1;
    if( x < 0 )return 0;

    rep(i,6){
        return solve( x - 100 - i );
    }
}

int dp[ 100000 ];
int main(){
    int n;
    string s;
    cin >> n >> s;

    vector<int> r(n) ,g(n) ,b(n);
    rep(i , n){
        if( s[i] == 'R' )r[i]++;
        if( s[i] == 'G' )g[i]++;
        if( s[i] == 'B' )b[i]++;

        if( i != 0 )r[i] += r[i-1];
        if( i != 0 )g[i] += g[i-1];
        if( i != 0 )b[i] += b[i-1];
    }


    ll res = 0;
    rep(i , n){
        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){
                    res += r[n-1] - r[j];
                }

                else {
                    res += r[2*j-i-1] - r[j] + r[n-1] - r[2*j-i];
                }

            }

            if( s[i] != 'G' && s[j] != 'G' ){
                
                if( 2 * j - i >= n){
                    res += g[n-1] - g[j];
                }

                else {
                    res += g[2*j-i-1] - g[j] + g[n-1] - g[2*j-i];
                }
                
            }

            if( s[i] != 'B' && s[j] != 'B' ){
                
                if( 2 * j - i >= n){
                    res += b[n-1] - b[j];
                }

                else {
                    res += b[2*j-i-1] - b[j] + b[n-1] - b[2*j-i];
                }
                
            }

            //cout << res << endl;
        }
    }

    cout << res << 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>
using namespace std;

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << end
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    string s; cin >> s;
    ll res = 0;
    map<char,int> mp;
    rep(i,n) mp[s[i]]++;
    if(mp.size()==3)res=1;
    for(auto a:mp)res*=a.second;
    //cout << res << endl;
    for(int j=0;j<n;j++){
        for(int k=j+1;k<n;k++){
            int i = j - abs(k-j);
            if(i<0)continue;
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i])res--;
        }
    }
    cout << res << 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 int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; string s; cin>>n>>s;
  map<char,ll> m;
  rep(i,n){
    m[s[i]]++;
  }
  ll ans=m['R']*m['G']*m[B];
  ll span=1;
  ll tmp=0;
  while(span<n){
    rep(i,n){
      if(span*2+i>=n) break;
      if(s[i]!=s[i+span] && s[i+span]!=s[i+span*2] && s[i+span*2]!=s[i]) tmp++;
    }
    span++;
  }
  cout<<ans-tmp<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:26: error: 'B' was not declared in this scope
   53 |   ll ans=m['R']*m['G']*m[B];
      |                          ^
Language: C

#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  int n;
  string s;
  cin >> n >> s;
  int color[3][5005] = {};
  for(int i = n - 1;i >= 0;i --){
    if(s[i] == 'R'){
      color[0][i] ++;
    } else if(s[i] == 'G'){
      color[1][i] ++;
    } else {
      color[2][i] ++;
    }
    color[0][i] += color[0][i + 1];
    color[1][i] += color[1][i + 1];
    color[2][i] += color[2][i + 1];
  }
  lol ans = 0;
  rep(i, n){
    for(int j = i + 1;j < n;j ++){
      if(s[i] == 'R'){
	if(s[j] == 'G'){
	  ans += color[2][j + 1];
	  if(s[j + abs(j, i)] == 'B'){
	    ans --;
	  }
	} else if(s[j] == 'B'){
	  ans += color[1][j + 1];
	  if(s[j + abs(j, i)] == 'G'){
	    ans --;
	  }
	}
      } else if(s[i] == 'G'){
	if(s[j] == 'R'){
	  ans += color[2][j + 1];
	  if(s[j + abs(j, i)] == 'B'){
	    ans --;
	  }
	} else if(s[j] == 'B'){
	  ans += color[0][j + 1];
	  if(s[j + abs(j, i)] == 'R'){
	    ans --;
	  }
	}
      } else {
	if(s[j] == 'G'){
	  ans += color[0][j + 1];
	  if(s[j + abs(j, i)] == 'R'){
	    ans --;
	  }
	} else if(s[j] == 'R'){
	  ans += color[1][j + 1];
	  if(s[j + abs(j, i)] == 'G'){
	    ans --;
	  }
	}
      }
    }
  }
  cout << ans << '\n';
  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 int ll;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int sumr[n]={},sumg[n]={},sumb[n]={};
    if(s[0]=='R'){
        sumr[0]=1;
        sumg[0]=0;
        sumb[0]=0;
    }
    if(s[0]=='G'){
        sumg[0]=1;
        sumr[0]=0;
        sumb[0]=0;
    }
    if(s[0]=='R'){
        sumb[0]=1;
        sumg[0]=0;
        sumr[0]=0;
    }

    //cout << sumr[0] << " " << sumb[0] << " " << sumg[0] << endl; 
    for(int i=1; i<n; i++){
        if(s[i]=='R'){
            sumr[i]=sumr[i-1]+1;
            sumb[i]=sumb[i-1];
            sumg[i]=sumg[i-1];
        }
        if(s[i]=='G'){
            sumg[i]=sumg[i-1]+1;
            sumb[i]=sumb[i-1];
            sumr[i]=sumr[i-1];
        }
        if(s[i]=='B'){
            sumb[i]=sumb[i-1]+1;
            sumr[i]=sumr[i-1];
            sumg[i]=sumg[i-1];
        }
    }
   
    cout << endl;
    int cnt=0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            if(s[i]=='R'&&s[j]=='G'){
                cnt+=sumb[n-1]-sumb[j];
                if(2*j-i<n&&s[2*j-i]=='B')cnt--;
            }if(s[i]=='R'&&s[j]=='B'){
                cnt+=sumg[n-1]-sumg[j];
                if(2*j-i<n&&s[2*j-i]=='G')cnt--;
            }if(s[i]=='B'&&s[j]=='G'){
                cnt+=sumr[n-1]-sumr[j];
                if(2*j-i<n&&s[2*j-i]=='R')cnt--;
            }if(s[i]=='G'&&s[j]=='R'){
                cnt+=sumb[n-1]-sumb[j];
                if(2*j-i<n&&s[2*j-i]=='B')cnt--;
            }if(s[i]=='G'&&s[j]=='B'){
                cnt+=sumr[n-1]-sumr[j];
                if(2*j-i<n&&s[2*j-i]=='R')cnt--;
            }if(s[i]=='B'&&s[j]=='R'){
                cnt+=sumg[n-1]-sumg[j];
                if(2*j-i<n&&s[2*j-i]=='G')cnt--;
            }
        }
    }
    cout << cnt << 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;

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    string s = "RGB";
    sort(all(s));
    int n;
    string str;
    cin >> n >> str;

    ll ans = 0;
    do {
        char r = s[0], g = s[1], b = s[2];
        for (int i = 0, cnt_0 = 0, cnt_1 = 0; i < n; i++) {
            if (str[i] == r) cnt_0++;
            if (str[i] == g) cnt_1 += cnt_0;
            if (str[i] == b) ans += cnt_1;
        }
        rep(i, n - 2) {
            for (int d = 1; i < n - 2 * d; d++) {
                if (str[i] == r and str[i + d] == g and str[i + 2 * d] == b) ans--;
            }
        }
    } while (next_permutation(all(s)));

    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

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N;
  cin>>N;
  vector<int> R,G,B;
  for (int i = 0; i < N; i++)
  {
    char X; cin>>X;
    if(X == 'R') R.push_back(i+1);
    if(X == 'G') G.push_back(i+1);
    if(X == 'B') B.push_back(i+1);
  }
  int ANS = R.size()*G.size()*B.size();
  for (int i = 0; i < R.size(); i++)
  {
    for (int j = 0; j < G.size(); j++)
    {
      int xR = R[i];
      int xG = G[j];
      if((find(ALL(B),(xR+xG)/2) != B.end())&&(xR+xG)%2 == 0)
      {
        ANS--;
      }
      if((find(ALL(B),max(xR,xG) + abs(xR - xG)) != B.end()))ANS--;
      if((find(ALL(B),min(xR,xG) - abs(xR - xG)) != B.end()))ANS--;
    }
    
  }
  cout<<ANS<<endl;
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  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>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  ll n;
  cin >> n >> s;
  
  ll r=0, g=0, b=0;
  rep(i, 0, n) {
    if(s[i] == 'R') r++;
    if(s[i] == 'G') g++;
    if(s[i] == 'B') b++;
  }
  
  ll ans = r*g*b;
  rep(i, 1, n-1) {
    ll L = min(n-1-i+1, (ll)(i-0+1));
    rep(j, 1, L) {
      if(s[i-j] != s[i] and s[i] != s[i+j] and s[i+j] != s[i-j]) ans--;
    }
  }
  cout << ans << "\n";
}

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;

int n;

int rgb(string s) {
    int r, g, b;
    r = 0;
    g = 0;
    b = 0;
    for (int i = 0; i < n; i++) {
        if (s.at(i) == 'R') {
            r++;
        } else if (s.at(i) == 'G') {
            g++;
        } else {
            b++;
        }
    }

    int ans = r * g * b;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (2 * j - i >= n) {
                break;
            }
            if (s.at(i) != s.at(j) && s.at(j) != s.at(2 * j - i) && s.at(2 * j - i) != s.at(i)) {
                ans--;
            }
        }
    }

    return ans;
}

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

    int ans = rgb(s);

    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<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    vector<ll> cnt(3, 0);
    string rgb = "RGB";
    ll ans = 0;
    rep(i, 0, N) {
        rep(j, i + 1, N) {
            if (S[i] != S[j]) {
                rep(k, 0, 3) {
                    if (rgb[k] != S[i] && rgb[k] != S[j]) {
                        ans += cnt[k] - (2 * i - j >= 0 && S[2 * i - j] == rgb[k]);
                        break;
                    }
                }
            }
        }
        rep(j, 0, 3) {
            if (rgb[j] == S[i]) {
                ++cnt[j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()

signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a=0,b=0,c=0;
  fo(i,n){
    if(s[i]=='R')
      a++;
    else if(s[i]=='G')
      b++;
    else
      c++;
  }
  int ans=a*b*c;
  fo(i,n-2){
    for(int j=i+1; j<n-1; j++){
      int d=2*j-i;
      if(n<=d)
        continue;
      if(s[i]!=s[j]&&s[j]!=s[d]&&s[d]!=s[i])
        ans--:
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:14: error: expected ';' before ':' token
   50 |         ans--:
      |              ^
      |              ;
Language: C

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////
int n, ans;string s;
int a, b, c;
signed main(){
  cin>>n>>s;
  rep(i,n){
    if(s[i] == 'R')a++;
    else if(s[i] == 'G')b++;
    else c++;
  }
  ans = a*b*c;
  rep(i,n){
    repd(j,i+1,n){
      int k = j + (j-i);
      if(k < n && s[i] != s[j] && s[j] != s[k] && s[k] != s[i])ans--;
    }
  }
  cout << ans << endl;
}


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

#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	set<int> R, G, B;
	rep(i,n){
		if(s[i] == 'R') R.insert(i);
		else if(s[i] == 'G') G.insert(i);
		else B.insert(i);
	}
	ll ans = 0;
	for(auto r : R){
		for(auto g : G){
			int i = min(r, g) - abs(r - g);
			int j = (r + g) / 2;
			if((r+g)%2 != 0) j = -1;
			int k = max(r, g) + abs(r - g);
			ans += B.size();
			if(i >= 0){
				if(s[i] == 'B') ans--;
			}
			if(0 <= j && j <= n-1){
				if(s[j] == 'B') ans--;
			}
			if(k <= n-1){
				if(s[k] == 'B') 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;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()

signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a=0,b=0,c=0;
  fo(i,n){
    if(s[i]=='R')
      a++;
    else if(s[i]=='G')
      b++;
    else
      c++;
  }
  int ans=a*b*c;
  fo(i,n-2){
    for(int j=i+1; j<n-1: j++){
      int d=2*j-i;
      if(n<=d)
        continue;
      if(s[i]!=s[j]&&s[j]!=s[d]&&s[d]!=s[i])
        ans--:
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:20: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   45 |     for(int j=i+1; j<n-1: j++){
      |                    ^
a.cc:45:25: error: expected ';' before ':' token
   45 |     for(int j=i+1; j<n-1: j++){
      |                         ^
      |                         ;
a.cc:52:3: error: expected primary-expression before '}' token
   52 |   }
      |   ^
a.cc:51:6: error: expected ';' before '}' token
   51 |     }
      |      ^
      |      ;
   52 |   }
      |   ~   
a.cc:52:3: error: expected primary-expression before '}' token
   52 |   }
      |   ^
a.cc:51:6: error: expected ')' before '}' token
   51 |     }
      |      ^
      |      )
   52 |   }
      |   ~   
a.cc:45:8: note: to match this '('
   45 |     for(int j=i+1; j<n-1: j++){
      |        ^
a.cc:52:3: error: expected primary-expression before '}' token
   52 |   }
      |   ^
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n;
	string s;
	cin >> n >> s;
	ll r = 0, g = 0, b = 0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else b++;
	}
	ll ans = r * g * b;
	for (ll i = 0; i < n - 2; i++) {
		for (ll j = i + 1; j < n - 1; j++) {
			ll k = 2 * j - i;
			if (k < n) {
				if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
			}
		}
	}
	cout << ans << endl;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:3:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:186:14: note: called from here
  186 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~
Language: C

#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    map<char, int> m;
    vector<char> C = {'R', 'G', 'B'};
    for (int i = 0; i < N; i++) {
        ll tmp = 1;
        for (int j = 0; j < 3; j++) {
            if (S[i] != C[j]) {
                tmp *= m[C[j]];
            }
        }
        ans += tmp;
        for (int j = i + 1; j < N; j++) {
            int k = 2 * i - j;
            if (0 <= k && k < N && S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans--;
        }
        m[S[i]]++;
    }
    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

// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/16/20 07:31:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  string s; cin>>s;
  int cnt[3] = {};
  map<char, int> cmap;
  cmap['R']=0;
  cmap['G']=1;
  cmap['B']=2;
  for (auto c:s)
    cnt[cmap[c]]++;
  ll ans = cnt[0]*cnt[1]*cnt[2];
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      int k = j+j-i;
      if (k >= n) continue;
      if (s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k])
        ans--;
    }
  }
  cout << ans << endl;

  return 0;
}


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

#include<bits/stdc++.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n;
string s;
i64 a,b,c;
void solve(){
	cin >> n >> s;
	for(int i = 0; i < n; i++){
		if(s[i] == 'R') a++;
		if(s[i] == 'G') b++;
		if(s[i] == 'B') c++;
	}
	i64 ans = a*b*c;
	for(int i = 0; i < n; i++){
		for(int j = 1; i+j*2 < n; j++){
			set<char> st;
			st.insert(s[i]);
			st.insert(s[i+j]);
			st.insert(s[i+j*2]);
			if(st.size() == 3) ans--;
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	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>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r, g, b;
	r = g = b = 0;
	rep(i, s.size()){
		if(s[i] == 'R') r++;
		else if(s[i] == 'G') g++;
		else b++;
	}
	ll ans = (ll)r*g*b;
	cerr << ans << endl;
	rep(i, s.size()-1)rep2(j, i+1, s.size()){
		if(s[i] == s[j]) continue;
		int nx = i + (j-i)*2;
		if(nx >= s.size()) continue;
		if(s[i] != s[nx] && s[j] != s[nx]){
			// cerr << i << " " << j << " " << nx << endl;
			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>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> r(N + 1, 0), g(N + 1, 0), b(N + 1, 0);
    rep(i, N) {
        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]++;
    }
    ll ans = 0;
    rep(i, N - 2) {
        for (int j = i + 2; j < N; j++) {
            if (S[i] == S[j]) continue;
            if ((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')) {
                ans += b[j] - b[i];
                if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'B') ans--;
            }
            if ((S[i] == 'R' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'R')) {
                ans += g[j] - g[i];
                if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'G') ans--;
            }
            if ((S[i] == 'G' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'G')) {
                ans += r[j] - r[i];
                if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'R') ans--;
            }
        }
    }
    cout << ans << "\n";
}

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;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int RGB[3] = {0, 0, 0};
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            RGB[0]++;
        } else if (S[i] =='G') {
            RGB[1]++;
        } else {
            RGB[2]++;
        }
    }
    int pat = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < N; j++) {
            if (0 <= i-j && i+j < N && S[i-j] != S[i] && S[i] != S[i+j] && S[i+j] != S[i-j]) {
                pat++;
            }
        }
    }
    cout << (long long)RGB[0] * RGB[1] * RGB[2] - pat << 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;
using lint = long long;

signed main(){
  lint N; cin >> N;
  string s; cin >> s;
  lint cg = 0, cr  =0, cb = 0;
  for(lint i = 0; i < N; i++){
    if(s[i] == 'R') cr++;
    if(s[i] == 'G') cg++;
    if(s[i] == 'B') cb++;
  }
  lint ans = cg * cr * cb;
  for(lint i = 1; i <= N/2; i++){
    for(lint j = 0; j < N; j++){
      lint x = j, y = j + i, z = j + 2*i;
      if(y >= N || z >= N) continue;
      else if(s[x] != s[y] && s[y] != s[z] && s[x] != s[z]) 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;

int64_t solve(const string &S, char a, char b, char c) {
    int N = S.size();
    int64_t A = 0, C = 0;
    int64_t res = 0;
    for(int i = 0; i < N; ++i) C += (S[i] == c);
    for(int i = 0; i < N; ++i) {
        if(S[i] == a) A++;
        if(S[i] == b) res += A * C;
        if(S[i] == c) C--;
    }
    return res;
}

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int64_t ans = 0;
    ans += solve(S, 'R', 'G', 'B');
    ans += solve(S, 'B', 'G', 'R');
    ans += solve(S, 'B', 'R', 'G');
    ans += solve(S, 'G', 'R', 'B');
    ans += solve(S, 'G', 'B', 'R');
    ans += solve(S, 'R', 'B', 'G');
    for(int j = 1; j < N - 1; ++j) {
        for(int d = 0; d < N; ++d) {
            int i = j - d, k = j + d;
            if(i < 0 or k >= N) continue;
            if(S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) ans--;
        }
    }
    cout << ans << '\n';
    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;

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; string s; cin>>n>>s;
  map<char,ll> m;
  rep(i,n){
    m[s[i]]++;
  }
  ll ans=1;
  for(auto e: m){
    ans*=e.second;
  }
  ll span=1;
  ll tmp=0;
  while(span<n){
    rep(i,n){
      if(span*2+i>=n) break;
      if(s[i]!=s[i+span]&&s[i+span]!=s[i+span*2]&&s[i+span*2]!=s[i]) tmp++;
    }
    span++;
  }
  cout<<ans-tmp<<endl;
}

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