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

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 10;

int rui[3][4005];
int rev_rui[3][4005];

int N;
string S;

signed main()
{
	cin>>N>>S;
	S=' '+S;
	for (int i=1;i<=N;++i) {
		rep(j, 3) {
			rui[j][i] = rui[j][i-1];
		}
		if (S[i]=='R')rui[0][i]++;
		if (S[i]=='G')rui[1][i]++;
		if (S[i]=='B')rui[2][i]++;
	}
	for (int i=N;i>=1;--i) {
		rep(j, 3) {
			rev_rui[j][i] = rev_rui[j][i+1];
		}
		if (S[i]=='R')rev_rui[0][i]++;
		if (S[i]=='G')rev_rui[1][i]++;
		if (S[i]=='B')rev_rui[2][i]++;
	}

	int ans = 0;

	for (int i = 2; i <= N - 1; ++i) {
		if (S[i] == 'R') {
			for (int diff = 1; i + diff <= N; ++diff) {
				if (S[i + diff] == 'G') {
					int B = rui[2][i - 1];
					if (i - diff >= 0) B -= rui[2][i - diff];
					if (i - diff - 1 >= 0) B += rui[2][i - diff - 1];
					ans += B;
				}
				if (S[i + diff] == 'B') {
					int G = rui[1][i - 1];
					if (i - diff >= 0) G -= rui[1][i - diff];
					if (i - diff - 1 >= 0) G += rui[1][i - diff - 1];
					ans += G;
				}
			}
		}
		if (S[i] == 'G') {
			for (int diff = 1; i + diff <= N; ++diff) {
				if (S[i + diff] == 'R') {
					int B = rui[2][i - 1];
					if (i - diff >= 0) B -= rui[2][i - diff];
					if (i - diff - 1 >= 0) B += rui[2][i - diff - 1];
					ans += B;
				}
				if (S[i + diff] == 'B') {
					int R = rui[0][i - 1];
					if (i - diff >= 0) R -= rui[0][i - diff];
					if (i - diff - 1 >= 0) R += rui[0][i - diff - 1];
					ans += R;
				}
			}
		}
		if (S[i] == 'B') {
			for (int diff = 1; i + diff <= N; ++diff) {
				if (S[i + diff] == 'R') {
					int G = rui[1][i - 1];
					if (i - diff >= 0) G-= rui[1][i - diff];
					if (i - diff - 1 >= 0) G+= rui[1][i - diff - 1];
					ans += G;
				}
				if (S[i + diff] == 'G') {
					int R = rui[0][i - 1];
					if (i - diff >= 0) R -= rui[0][i - diff];
					if (i - diff - 1 >= 0) R += rui[0][i - diff - 1];
					ans += R;
				}
			}
		}
	}

	cout << ans << endl;
}




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 fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;

  vector<vi> S(3,vi(n+1,0));
  char c[] = {'R','G','B'};
  rep(i,3)rep(j,n){
    S[i][j+1] = S[i][j]+(s[j] == c[i]);
  }
  rep(i,n){
      srep(j,i+1,n){
        if(s[i] != s[j]){
          int k;
          if(s[i] != 'R' && s[j] != 'R') k = 0;
          if(s[i] != 'G' && s[j] != 'G') k = 1;
          if(s[i] != 'B' && s[j] != 'B') k = 2;
          int d = j-i;
          ans+= S[k][n]- S[k][j];
          if(j+d<n)ans-=(s[j+d] == c[k]);

        }
      }
  }

  print(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<bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define sz(v) (int) v.size()
#define all(v) v.begin(), v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int MAX_N = 4005;

int n;
string s;
int pref[MAX_N][26];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> s;
	for (int i = 0; i < n; ++i) {
		if (i) for (int j = 0; j < 26; ++j) pref[i][j] = pref[i - 1][j];
		pref[i][s[i] - 'A']++;
	}
	ll ans = 0;
	for (int j = 1; j < n; ++j) {
		for (int k = j + 1; k < n; ++k) {
			if (s[j] == s[k]) continue;
			if ('R' != s[j] && 'R' != s[k]) {
				ans += pref[j - 1]['R' - 'A'];
				if (2 * j - k > -1 && s[2 * j - k] == 'R') ans--;
			} else if ('G' != s[j] && 'G' != s[k]) {
				ans += pref[j - 1]['G' - 'A'];
				if (2 * j - k > -1 && s[2 * j - k] == 'G') ans--;
			} else {
				ans += pref[j - 1]['B' - 'A'];
				if (2 * j - k > -1 && s[2 * j - k] == 'B') ans--;
			}
		}
	}
	cout << ans << "\n";
	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;

int main() {
  int N;
  string S;
  cin >> N>>S;
  int A=0;
  for(int i=0; i<N; i++){
     for(int j=i; j<N; j++){
       if(S.at(i)==S.at(j))continue;
        for(int k=j; k<N; k++){
          if(S.at(k)==S.at(j)||S.at(i)==S.at(k))continue;
          else if (j-i!=k-j) A++;
        }
     }
    
          
  }
 cout <<A;
  
}


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;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> cR(N+1),cG(N+1),cB(N+1);
    for(int i=0;i<N;i++){
        if(S[i]=='R'){
            cR[i+1]=cR[i]+1;
            cG[i+1]=cG[i];
            cB[i+1]=cB[i];
        }
        if(S[i]=='G'){
            cR[i+1]=cR[i];
            cG[i+1]=cG[i]+1;
            cB[i+1]=cB[i];
        }
        if(S[i]=='B'){
            cR[i+1]=cR[i];
            cG[i+1]=cG[i];
            cB[i+1]=cB[i]+1;
        } 
    }
    ll ans = 0;
    for(int j=1;j<N-1;j++){
        if(S[j]=='R'){
            ans+=cG[j]*(cB[N]-cB[j+1]);
            ans+=cB[j]*(cG[N]-cG[j+1]);
            for(int l=1;(j-l>=0&&j+l<N);l++){
                if(S[j-l]=='G'&&S[j+l]=='B'){
                    ans--;
                }else if(S[j-l]=='B'&&S[j+l]=='G'){
                    ans--;
                }
            }
        }
        if(S[j]=='G'){
            ans+=cR[j]*(cB[N]-cB[j+1]);
            ans+=cB[j]*(cR[N]-cR[j+1]);
            for(int l=1;(j-l>=0&&j+l<N);l++){
                if(S[j-l]=='R'&&S[j+l]=='B'){
                    ans--;
                }else if(S[j-l]=='B'&&S[j+l]=='R'){
                    ans--;
                }
            }
        }
        if(S[j]=='B'){
            ans+=cR[j]*(cG[N]-cG[j+1]);
            ans+=cG[j]*(cR[N]-cR[j+1]);
            for(int l=1;(j-l>=0&&j+l<N);l++){
                if(S[j-l]=='R'&&S[j+l]=='G'){
                    ans--;
                }else if(S[j-l]=='G'&&S[j+l]=='R'){
                    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++

#inculde <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  ll n,ans=0;cin>>n;
  stinrg s;cin>>s;
  for(ll i=0;i<n;i++){
    for(ll j=i;j<n;j++){
      for(ll k=j;k<n;k++){
        if(a.at(i)!=a.at(j)&&a.at(i)!=a.at(k)&&a.at(k)!=a.at(j)){
          ans++;
        }
      }
    }
  }
  cout << ans<<endl;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inculde; did you mean #include?
    1 | #inculde <iostream>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:6:14: error: 'cin' was not declared in this scope
    6 |   ll n,ans=0;cin>>n;
      |              ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <string>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:7:3: error: 'stinrg' was not declared in this scope
    7 |   stinrg s;cin>>s;
      |   ^~~~~~
a.cc:7:17: error: 's' was not declared in this scope
    7 |   stinrg s;cin>>s;
      |                 ^
a.cc:11:12: error: 'a' was not declared in this scope
   11 |         if(a.at(i)!=a.at(j)&&a.at(i)!=a.at(k)&&a.at(k)!=a.at(j)){
      |            ^
a.cc:17:3: error: 'cout' was not declared in this scope
   17 |   cout << ans<<endl;
      |   ^~~~
a.cc:17:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:17:16: error: 'endl' was not declared in this scope
   17 |   cout << ans<<endl;
      |                ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <string>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C

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

int main() {
    ll n,ans=0;
    string s;
    cin >> n >> s;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            if(s[i] == s[j])continue;
            for(ll k=j+1;k<n;k++){
                if(2*j == k + i)continue;
                if(s[i]==s[k])continue;
                if(s[j]==s[k])continue;
                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>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  string s;
  cin >> n >> s;
  vector<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]++;
    if (s[i] == 'G') G[i]++;
    if (s[i] == 'B') B[i]++;
    R[i] += R[i+1];
    G[i] += G[i+1];
    B[i] += B[i+1];
  }
  ll ans = 0;
  auto f = [&](char si, char sj, int idx) {
    char tempi = si, tempj = sj;
    if (tempi - 'A' > tempj - 'A') swap(tempi,tempj); 
    if (tempi == 'B' && tempj == 'G') return R[idx];
    else if (tempi == 'B' && tempj == 'R') return G[idx];
    else return B[idx];
  };
  auto g = [&](char si, char sj) {
    char tempi = si, tempj = sj;
    if (tempi - 'A' > tempj - 'A') swap(tempi,tempj); 
    if (tempi == 'B' && tempj == 'G') return 'R';
    else if (tempi == 'B' && tempj == 'R') return 'G';
    else return 'B';
  };
  for (int i = 0; i <= n-3; ++i) {
    for (int j = i+1; j <= n-2; ++j) {
      if (s[i] == 'R') {
        if (s[j] == 'G' || s[j] == 'B') {
          ans += f(s[i], s[j], j+1);
          if (s[j+j-i] == g(s[i], s[j])) ans--; //j-i = k-jのとき
        }
      }
      else if (s[i] == 'G') {
        if (s[j] == 'R' || s[j] == 'B') {
          ans += f(s[i], s[j], j+1);
          if (s[j+j-i] == g(s[i], s[j])) ans--; //j-i = k-jのとき
        }
      }
      else if (s[i] == 'B') {
        if (s[j] == 'R' || s[j] == 'G') {
          ans += f(s[i], s[j], j+1);
          if (s[j+j-i] == g(s[i], s[j])) ans--; //j-i = k-jのとき
        }
      }
    }
  }
  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

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DRGBTriplets {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      string s; cin >> s;
      ll red = 0, green = 0, blue = 0;
      rep(i, n) {
        if (s[i] == 'R') {
          red++;
        } else if (s[i] == 'G') {
          green++;
        } else {
          blue++;
        }
      }
      ll all = red*green*blue;
      for(int i=1; i<n; i++) {
        for(int j=0; j<n; j++) {
          if (j+i+i>=n) continue;
          if (s[j] != s[j+i] && s[j+i] != s[j+i+i] && s[j+i+i] != s[j]) {
            all--;
          }
        }
      }
      cout << all << endl;

    }
};

signed main() {
  DRGBTriplets solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Compiler output:
main.c:7:9: 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;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    //vector<int> A(N);
    /*
    rep(i,N){
        if(S.at(i)=='R') A.at(i)=0;
        else if(S.at(i)=='G') A.at(i)=1;
        else A.at(i)=2;
    }*/
    ll ans=0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(S.at(i)!=S.at(j)){
                for(int k=j+1; k<N; k++){
                    if(S.at(k)!=S.at(i) && S.at(k)!=S.at(j) && j-i!=k-j){
                        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 rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  string s;
  cin >> n >>s;
  int ans=0;
  rep(i,n) {
    rep(j,n) {
      rep(k,n) {
        if((j-i)==(k-j)) continue;
        else if(s[i]==s[k]||s[i]==s[j]||s[k]==s[j]) continue;
        else 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;

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

// template<class T> void chmin(T& a, T b) {
//     if (a > b) {
//         a = b;
//     }
// }

// template<class T> void chmax(T& a, T b) {
//     if (a < b) {
//         a = b;
//     }
// }

int main(void) {
    ll n;
    cin >> n;

    string s;
    cin >> s;

    vector<ll> r;
    vector<ll> g;
    vector<ll> b;
    for(ll in=0;in<n;in++) {
        if(s.at(in)=='R') r.push_back(in+1);
        if(s.at(in)=='G') g.push_back(in+1);
        if(s.at(in)=='B') b.push_back(in+1);
    }

    ll ans=0;
    vector<int> rgb(3);
    for(auto ir:r) {
        for(auto ig:g) {
            for(auto ib:b) {
                rgb.at(0) = ir;
                rgb.at(1) = ig;
                rgb.at(2) = ib;
                sort(rgb.begin(), rgb.end());
                if(rgb.at(2)-rgb.at(1)!=rgb.at(1)-rgb.at(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

/*
 * Author: Anmol Choudhary
 */
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
// using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    vector<int>v[3];
    string s;
    cin>>s;
    rep0(i,n){
        if(s[i]=='R') v[0].pb(i);
        if(s[i]=='B') v[1].pb(i);
        if(s[i]=='G') v[2].pb(i);
    }
    int f1=v[0].si;
    int f2=v[1].si;
    int f3=v[2].si;
    int an=f1*f2*f3;
    rep0(i,n)rep0(j,n){
        int x=i;
        int y=x+1+j;
        int z=y+1+j;
        if(z>=n) break;
        if(s[x]!=s[y]&&s[x]!=s[z]&&s[y]!=s[z]) an--;
    }
    pr(an);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    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<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define MAX 200000
#define NIL -1

int N;
string S;


int ans;
int R[4000],G[4000],B[4000];



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

	cin >> N;
	cin >> S;

	FOR(i, 0, 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];
			G[i] += G[i - 1];
			B[i] += B[i - 1];
		}
	}

	FOR(j, 1, N-1) {
		FOR(k, j+1, N) {
			if (S[j] == S[k])continue;

			if (S[j] != 'R'&&S[k] != 'R')ans += R[j - 1];
			if (S[j] != 'G'&&S[k] != 'G')ans += G[j - 1];
			if (S[j] != 'B'&&S[k] != 'B')ans += B[j - 1];

			int i = j * 2 - k;
			if (i >= 0) {
				if (S[i] != S[j] && S[i] != S[k])ans--;
			}


		}
	}

	cout << ans << endl;

	return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
//#define int ll
int n; char s[N];
ll R[N],G[N],B[N],ans;
signed main(){
	cin>>n>>(s+1);
	repeat(i,1,n+1){
		R[i]=R[i-1]+(s[i]=='R');
		G[i]=G[i-1]+(s[i]=='G');
		B[i]=B[i-1]+(s[i]=='B');
	}
	repeat(i,1,n+1){
		#define x(R,G,B) if(s[i]==#R[0])ans+=G[i]*(B[n]-B[i])+B[i]*(G[n]-G[i]);
		x(R,G,B);
		x(G,R,B);
		x(B,G,R);
	}
	repeat(i,1,n+1){
		for(int j=1;j+i+i<=n;j++){
			if(s[j]!=s[j+i] && s[j]!=s[j+i+i] && s[j+i]!=s[j+i+i])
				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;
using ll = long long;
using ull = unsigned long long;

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  for(int i=1;i<=n-2;i++){
    for(int j=i+1;j<=n-1;j++){
      for(int k=j+1;k<=n;k++){
        if( j-i == k-j ) continue;
        if( s.at(i) != s.at(j) && s.at(i) != s.at(k) && s.at(j) != s.at(k) ){
          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 int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
ll num=1, ans=0, count=0, sum=0;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, red=0, green=0, blue=0;
  string S;
  
  cin >> N >> S;
  rep(i, N) {
    if(S[i]=='R') red++;
    if(S[i]=='G') green++;
    if(S[i]=='B') blue++;
  }
  ans = red*green*blue;
  
  rep(i, N-2) {
    ll d=1;
    while(i+d*2>N-1) {
      set<char> color;
      rep(j, 3) color.insert(S[i+d*j]);
      if(color=={'B','G','R'}) ans--;
      d++;
    }
  }
  
  cout << ans << '\n';
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:17: error: expected primary-expression before '{' token
   44 |       if(color=={'B','G','R'}) ans--;
      |                 ^
a.cc:44:17: error: expected ')' before '{' token
   44 |       if(color=={'B','G','R'}) ans--;
      |         ~       ^
      |                 )
Language: C

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

int main(){
    int n;
    string s;
    int ans = 0;
    cin >> n >> s;
    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[k] && s[k] != s[i] && j-i != k-j){
                    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 <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

#include <numeric>

using namespace std;

typedef unsigned long long LL;

char s[4444];

int r[4444], g[4444], b[4444], n;

LL ans;

LL get_ans(char x, char y, int i, int j) {
    LL ret = 0;
    char z;
    map<char, int> m;
    m['R'] = 1;
    m['B'] = 1;
    m['G'] = 1;
    m[x] -= 1;
    m[y] -= 1;
    if (m['R'] == 1) z = 'R';
    if (m['G'] == 1) z = 'G';
    if (m['B'] == 1) z = 'B';
    if (z == 'R') {
        ret = r[n] - r[j];
    }
    if (z == 'G') {
        ret = g[n] - g[j];
    }
    if (z == 'B') {
        ret = b[n] - b[j];
    }
    if (j + j - i <= n) {
        char zz = s[j + j - i];
        //cout << zz << endl;
        if (zz != x && zz != y) ret -= 1;
    }

    //cout << x << ' ' << y << ' ' << i << ' ' << j << ' ' << ret << endl;

    return ret;

}

int main() {

    cin >> n;

    scanf("%s", s + 1);

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

    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            if (s[j] == s[i]) continue;
            ans += get_ans(s[i], s[j], i, j);
        }
    }

    cout << ans << endl;


}

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

#include <iostream>
using namespace std;


int main(){
  int N;
  string S;
  cin >> N >> S;
  long long int ans = 0;
  for(int ii=0; ii<N; ii++){
    for(int jj=ii+1; jj<N; jj++){
      for(int kk=jj+1; kk<N; kk++){
        if(S[ii]==S[jj] || S[ii]==S[kk] || S[jj]==S[kk]) continue;
        if(jj-ii==kk-jj) continue;
        ans++;
      }
    }
  }
  cout << ans << 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 <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll N;
	string S;
	cin >> N >> S;

	ll rNum = 0;
	ll gNum = 0;
	ll bNum = 0;
	REP(i, N) {
		if (S[i] == 'R') rNum++;
		if (S[i] == 'G') gNum++;
		if (S[i] == 'B') bNum++;
	}
	ll ans = rNum * gNum * bNum;

	ll renzoku = 0;
	REP(i, N) {
//		ll lim = N /3 + 1;
		REPN(j, 1, N) {
			if (N <= i + j) continue;
			if (N <= i + j * 2) continue;
			char a = S[i];
			char b = S[i + j];
			char c = S[i + j * 2];
			if (a != b && b != c && c != a) {
				renzoku++;
			}
		}
	}

	ans -= renzoku;
	cout << ans << 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 <iostream>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    map<char, int> mp;
    rep(i, n) {
        mp[s[i]]++;
    }

    ll t = 0;
    rep(i, n) {
        REP(j, 1, (n - 1 - i) / 2 + 1) {

            if (s[i] != s[i + j] && s[i] != s[i + j * 2] && s[i + j] != s[i + j * 2]) t++;
        }
    }

    ll res = max((ll)0, mp['R'] * mp['G'] * mp['B'] - t);
    cout << res << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'map' was not declared in this scope
   22 |     map<char, int> mp;
      |     ^~~
a.cc:2:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    1 | #include <iostream>
  +++ |+#include <map>
    2 | #define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
a.cc:22:9: error: expected primary-expression before 'char'
   22 |     map<char, int> mp;
      |         ^~~~
a.cc:24:9: error: 'mp' was not declared in this scope
   24 |         mp[s[i]]++;
      |         ^~
a.cc:35:25: error: 'mp' was not declared in this scope
   35 |     ll res = max((ll)0, mp['R'] * mp['G'] * mp['B'] - t);
      |                         ^~
Language: C

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 4000+9;
ll f[N][N][3];
ll fs[N][3];
int a[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    string s; cin >> s;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') a[i] = 1;
        else if(s[i] == 'G') a[i] = 2;
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < i; j++) {
            if(a[i] != a[j]) {
                f[i][i-j][a[i]^a[j]^3]++;
                fs[i][a[i]^a[j]^3]++;
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < i; j++) {
            if(a[i] != a[j]) {
                ans += fs[j][a[i]] - f[j][i-j][a[i]];
            }
        }    
    }
    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<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;


ll gcd(ll N,ll M,ll L){
  while(M!=N)
  if(M>N) M=M-N;
  else N=N-M;

  while(M!=L)
  if(M>L) M=M-L;
  else L=L-M;
}

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


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

#include<bit/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  vector<ll> r,g,b,n;
  ll i,j,k,ans;
  string s,t;
  ans=0;
  cin >> n >>s;
  for(i=0;i<n;i++){
    t=s[i];
    if(t=="R")r.push_back(i);
    if(t=="G")g.push_back(i);
    if(t=="B")b.push_back(i);
  }
  for(i=0;i<r.size();i++){
    for(j=0;j<g.size();j++){
      for(k=0;k<b.size();k++){
        if((abs(r[i]-g[j])!=abs(g[j]-b[k]))&&(abs(g[j]-b[k])!=abs(b[k]-r[i]))&&(abs(b[k]-r[i])!=abs(r[i]-g[j]))){
          ans+=1;
        }
      }
    }
  }
  cout << ans;
} 

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

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll p[3][4005];
ll func(char a,char b){
	if((a=='0'&&b=='1')||(a=='1'&&b=='0'))
	return 2;
	if((a=='1'&&b=='2')||(a=='2'&&b=='1'))
	return 0;
	else
	return 1;
}
void solve(){
	ll n,res=0;
	string s;
	cin>>n>>s;
	for(ll i=0;i<n;i++){
		p[0][i+1]=p[0][i];
		p[1][i+1]=p[1][i];
		p[2][i+1]=p[2][i];
		if(s[i]=='R'){
		    p[0][i+1]++;
		    s[i]='0';
	    }
		else if(s[i]=='G'){
		    p[1][i+1]++;
		    s[i]='1';
	    }
		else{
		    p[2][i+1]++;
		    s[i]='2';
	    }
	}
	for(ll i=0;i<n;i++)
	for(ll j=i+1;j<n;j++)
	if(s[i]!=s[j]){
	    res+=p[func(s[i],s[j])][n]-p[func(s[i],s[j])][j+1];
	    if(2*j-i<n&&s[2*j-i]==char(func(s[i],s[j])+'0'))
	    res--;
    }
    cout<<res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll qc=1;
	for(ll i=1;i<=qc;i++)
	solve();
}


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 <string>
#include <vector>

int main(){
  
  int N;
  std::cin >> N;
  std::string str;
  std::cin >> str;
  
  int c = 0;
  for(int i=0; i<N-2; i++){
	for(int j=i+1; j<N-1; j++){
      if(s[i] == s[j])
        continue;
      for(int k=j+1; k<N; k++){
        if(s[i]==s[k] || s[j]==s[k] || j-1==k-j)
          continue;
        c++;
      }
    }
  }
  
  std::cout << c << std::endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:10: error: 's' was not declared in this scope
   15 |       if(s[i] == s[j])
      |          ^
a.cc:18:12: error: 's' was not declared in this scope
   18 |         if(s[i]==s[k] || s[j]==s[k] || j-1==k-j)
      |            ^
Language: C

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e3+7;
char buff[N];
int freq[3][N];

int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",buff);
	string str = (string)buff;
	
	for(int i = n-1 ; i >= 0 ; i--)
	{
		if (str[i] == 'R') freq[0][i] = 1;
		else if (str[i] == 'G') freq[1][i] = 1;
		else if (str[i] == 'B') freq[2][i] = 1;
		for(int j = 0 ; j < 3 ; j++) freq[j][i] += freq[j][i+1];
	}
	ll ans = 0;
	for(int i = 0 ; i < n ; i++)
	{
		for(int j = i+1 ; j < n ; j++)
		{
			if (str[i] == str[j]) continue;
			
			if ((str[i] == 'R' && str[j] == 'G') || (str[i] == 'G' && str[j] == 'R'))
			{
				ans += freq[2][j+1];
				if (2*j-i < n && str[j*2-i] == 'B') ans--;
			}
			if ((str[i] == 'B' && str[j] == 'G') || (str[i] == 'G' && str[j] == 'B'))
			{
				ans += freq[0][j+1];
				if (2*j-i < n && str[j*2-i] == 'R') ans--;
			}
			if ((str[i] == 'R' && str[j] == 'B') || (str[i] == 'B' && str[j] == 'R'))
			{
				ans += freq[1][j+1];
				if (2*j-i < n && str[j*2-i] == 'G') ans--;
			}
 		}
	}
	printf("%lld\n",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

//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> lR(n);
    vector<int> lG(n);
    vector<int> lB(n);
    vector<int> rR(n);
    vector<int> rG(n);
    vector<int> rB(n);
    FOR(i,0,n){
        if(s[i] == 'R') lR[i]=1;
        if(s[i] == 'G') lG[i]=1;
        if(s[i] == 'B') lB[i]=1;        
    }
    FOR(i,1,n){
        lR[i] += lR[i-1];
        lG[i] += lG[i-1];
        lB[i] += lB[i-1];        
    }

    FORr(i,0,n-1){
        if(s[i] == 'R') rR[i]=1;
        if(s[i] == 'G') rG[i]=1;
        if(s[i] == 'B') rB[i]=1;        
    }
    FORr(i,0,n-2){
        rR[i] += rR[i+1];
        rG[i] += rG[i+1];
        rB[i] += rB[i+1];        
    }


    ll ans = 0;
    FOR(i,0,n){
        if(s[i] == 'R'){
            ans += lG[i]*rB[i];
            ans += rG[i]*lB[i];            
        }
        if(s[i] == 'G'){
            ans += lR[i]*rB[i];
            ans += rR[i]*lB[i];            
        }
        if(s[i] == 'B'){
            ans += lG[i]*rR[i];
            ans += rG[i]*lR[i];            
        }       
    }   

    FOR(dif,1,n){
        FOR(l,0,n){
            ll m,r;
            m = l + dif;
            r = m + dif;
            if(r >= n)continue;
            if(s[l] != s[m] && s[m] != s[r] && s[r] != s[l]) ans--;
        }
    }
    cout<<ans<<endl;
    

    
    
}

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

#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

int const MAXN = 4005;
char s[MAXN];
int sum[3][MAXN];

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; cin >> n;
  cin >> (s + 1);
  for (RI i = 1; i <= n; ++i)
    if (s[i] == 'R') ++sum[0][i];
    else if (s[i] == 'G') ++sum[1][i];
    else ++sum[2][i];
  for (RI i = 1; i <= n; ++i) {
    sum[0][i] += sum[0][i - 1];
    sum[1][i] += sum[1][i - 1];
    sum[2][i] += sum[2][i - 1];
  }
  int ans = 0;
  for (RI i = 1; i <= n; ++i)
    for (RI j = i + 1; j <= n; ++j)
      if (s[i] != s[j]) {
        int tmp = 'R' + 'G' + 'B' - s[i] - s[j];
        if (tmp == 'R') {
          ans += sum[0][i - 1];
          int dis = j - i;
          if (i - dis > 0 && s[i - dis] == 'R') --ans;
        }
        if (tmp == 'G') {
          ans += sum[1][i - 1];
          int dis = j - i;
          if (i - dis > 0 && s[i - dis] == 'G') --ans;
        }
        if (tmp == 'B') {
          ans += sum[2][i - 1];
          int dis = j - i;
          if (i - dis > 0 && s[i - dis] == 'B') --ans;
        }
      }
  cout << ans;

  return 0;
}

// created by Daniel yuan


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 <vector>

std::vector<int> vec;

int rem(int a, int b)
{
    int r;
    for (int i = 0; i < 3; ++i)
    {
        if (i != a && i != b)
            r = i;
    }

    return r;
}

int main()
{

    int n;

    std::cin >> n;

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

    for (int i = 0; i < n; ++i)
    {
        char ch;
        std::cin >> ch;
        if (ch == 'R')
        {
            vec.push_back(0);
            ++r;
        }
        else if (ch == 'G')
        {
            vec.push_back(1);
            ++g;
        }
        else
        {
            vec.push_back(2);
            ++b;
        }
    }

    long long int sum = r * g * b;

    for (int i = 0; i < n; ++i)
    {
        for (int j = i; j * 2 - i < n; ++j)
        {
            int k = j * 2 - i;

            if (vec[i] != vec[j] && rem(vec[i], vec[j]) == vec[k])
                --sum;
        }
    }

    std::cout << sum << std::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 <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

#define ll signed long long

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

  ll r = 0;
  ll g = 0;
  ll b = 0;
  for (int i = 0; i < N; ++i) {
    if (s[i] == 'R') ++r;
    if (s[i] == 'G') ++g;
    if (s[i] == 'B') ++b;
  }
  if (r == 0 || g == 0 || b == 0) {
    cout << 0 << endl;
  }

  ll ans = r * g * b;

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

  cout << ans << 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>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int n;
    string s;
    cin>>n>>s;
    int ans = 0;
    for(int i = 0;i<n-2;i++){
        for(int j = i+1;j<n-1;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:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<queue>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>



using namespace std;

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

string s;
long long n,r[4444],g[4444],b[4444],ans=0ll;

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

	for(int i=0;i<n;i++){
		for(int j=i+2;j<n;j++){
			map<char,bool>rgb={{'R',false},{'G',false},{'B',false}};
			if(s[i]==s[j])continue;
			rgb[s[i]]=rgb[s[j]]=true;
			char lst;
			for(auto i:rgb)if(!i.second)lst=i.first;
			if((j-i)%2==0&&s[(i+j)/2]==lst)ans--;
			if(lst=='R')ans+=r[j]-r[i];
			if(lst=='G')ans+=g[j]-g[i];
			if(lst=='B')ans+=b[j]-b[i];
		}
	}
	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

from collections import defaultdict
n = int(input())
s = input()
d = defaultdict(int)
for c in s:
  d[c] += 1
ans = d['R'] * d['G'] * d['B']
for i in range(1, n):
  for j in range(n-2*i):
    if s[j] != s[j+i] and s[j+i] != s[j+2*i] and s[j+2*i] != s[j]:
      ans -= 1
print(ans)

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'
Language: C

#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////
 int n ; string s;
 ll suf[4003][3]; 
 ll ans;
 void func(char a, char b , int x)
 { //if(a=='G'&&b=='R'&&x==2)
// cout<<ans<<"*"<<endl; 
 	for(int i = 1; i<n-1; i++)
 	{
 		if(s[i]!=b)
 		continue; 
 		for(int j = 0; j<i; j++)
 		{
 			if(s[j]!=a)
 			continue; 
 			int pos = i+(i-j); 
 			ans+=(suf[i+1][x]); 
 			if(pos<n&&s[pos]!=a&&s[pos]!=b)
 			ans--; 
		 }
	 }
	// if(a=='G'&&b=='R'&&x==2)
 //cout<<ans<<"*"<<endl; 
 }
ll tn ; 
void solve()
{
 cin>>n>>s; 
 ll a[3]={0}; 
 for(int i = n-1; i>=0 ; i--)
 {
 	if(s[i]=='R')
 	a[0]++; 
 	else if(s[i]=='G')
 	a[1]++; 
 	else
 	a[2]++; 
 	suf[i][0]=a[0];
 	suf[i][1]=a[1];
 	suf[i][2]=a[2];
 	
 }
 ans = 0; 
 string temp = "RGB"; 
 for(int i = 0; i<3; i++)
 {
 	for(int j = 0; j<3; j++)
 	{
 		for(int k = 0; k<3; k++)
 		{
 			if(i!=j&&i!=k&&j!=k)
 			{
 				func(temp[i],temp[j],k); 
 				//cout<<i<<" "<<j<<" "<<k<<" "<<ans<<endl; 
			 }
		 }
	 }
 }
 
 cout<<ans; 
}
int main()
{ ios; 

ll t ;t = 1; 
  for(tn = 1; tn<=t; tn++)
	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.