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

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N=sc.nextInt();
    String S = sc.next();
    String s[] =S.split("",0);
    int t[] =new int[N];
    int x=0;
    for(int i=0;i<N;i++){
      if(s[i].equals("R")){t[i]=1;}
      else if(s[i].equals("G")){t[i]=2;}
      else{t[i]=3;}}
    for(int j=1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        if(t[j-1]==t[k-1]){continue;}
        for(int l=k+1;l<N+1;l++){
          if(l!=2*k-j){
          if(t[j-1]+t[k-1]+t[l-1]==6){
            x=x+1;}}}}
    System.out.println(x);
  }
}


Compiler output:
Main.java:23: error: reached end of file while parsing
}
 ^
1 error
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++)
/*
*/

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    ll ans2 = 0;
    ll r = 0;
    ll b = 0;
    ll g = 0;
    for (int i = 0; i < N; i++) {
      if (S[i] == 'R') r++;
      if (S[i] == 'G') g++;
      if (S[i] == 'B') b++;
    }
    ll ans1 = r * g * b;

    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
          if (S[i] != S[j]) {
            int k = 2 * j - i;
            if(k >= N) continue;
            if (S[i] != S[k] && S[j] != S[k]) ans2++;
          }
        }
    }
    cout << ans1 - ans2 << 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

/*input
4
RRGB
*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
// const int inf = 1e18;
const int maxn = 6e5 +5;
void solve(int test ) 
{	
	int n;
	cin >> n;
	vector<int> v;
	string s;
	cin >> s;
	int r =0 , g =0  , b = 0;
	for ( int i = 0 ; i < n ; i++) {
		if ( s[i] == 'R') v.push_back(1) , r++;
		else if ( s[i] == 'G') v.push_back(2) , g++;
		else v.push_back( 3) , b++;
	}
	int ans = r * g  * b ;
	for ( int i = 0 ;i < n ; i++) {
		for ( int j = i +1 ; j < n ; j++){
			int dif = j - i;
			int k = j + dif;
			if ( k < n && (v[i] ^ v[j] ^ v[k]) == 0) ans--;
		}
	}
	cout << ans;

}
signed main(){
	bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	auto start = chrono::steady_clock::now();
	for ( int i = 0 ; i < t; i++)
	solve(i+1 );
	auto end = chrono::steady_clock::now();
	auto diff = end - start;
	// cout <<  (chrono::duration <double, milli> (diff).count()  / 1000 .0 )<< " s" << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  string check = "BGR";
  ll ans = 0;
  do
  {
    rep(i,s.size()-2){
      if(s[i] != check[0])continue;
      for (int j = i + 1; j < s.size()-1;j++){
        if(s[j] != check[1])continue;
        for (int k = j + 1;k<=s.size();k++){
          if(j-i == k-j)continue;
          if(s[k]!=check[2])continue;
          ans++;
        }
      }
    }
  } while (next_permutation(check.begin(), check.end()));
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope
    8 |   cin >> n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define rep(i, n) for (int i = 0; i < n; i++)
a.cc:9:3: error: 'string' was not declared in this scope
    9 |   string s;
      |   ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | #define rep(i, n) for (int i = 0; i < n; i++)
a.cc:10:10: error: 's' was not declared in this scope
   10 |   cin >> s;
      |          ^
a.cc:11:9: error: expected ';' before 'check'
   11 |   string check = "BGR";
      |         ^~~~~~
      |         ;
a.cc:16:18: error: 'check' was not declared in this scope
   16 |       if(s[i] != check[0])continue;
      |                  ^~~~~
a.cc:18:20: error: 'check' was not declared in this scope
   18 |         if(s[j] != check[1])continue;
      |                    ^~~~~
a.cc:21:20: error: 'check' was not declared in this scope
   21 |           if(s[k]!=check[2])continue;
      |                    ^~~~~
a.cc:26:29: error: 'check' was not declared in this scope
   26 |   } while (next_permutation(check.begin(), check.end()));
      |                             ^~~~~
a.cc:26:12: error: 'next_permutation' was not declared in this scope
   26 |   } while (next_permutation(check.begin(), check.end()));
      |            ^~~~~~~~~~~~~~~~
a.cc:27:5: error: 'cout' was not declared in this scope
   27 |     cout << ans << endl;
      |     ^~~~
a.cc:27:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:27:20: error: 'endl' was not declared in this scope
   27 |     cout << ans << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define rep(i, n) for (int i = 0; i < n; i++)
Language: C

#include<stdio.h>

int main(){
	int N;
	scanf("%d", &N);
	char s[N];
	scanf("%s", s);
  	int i = 0, j = 0, k = 0
	long long int r = 0, g = 0, b = 0, check = 0;
	for(i = 0; i < N; i++){
		if(s[i] == 'R'){
			r++;
		}else if(s[i] == 'G'){
			g++;
		}else{
			b++;
		}
	}
	for(i = 0; i < N - 2; i++){
		for(j = i + 1; j < N - 1; j++){
			for(k = j + 1; k< N ; k++){
				if(j - i == k - j ){
					if(s[i] != s[ j ] && s[i] != s[k] && s[ j ] != s[k]){
						check+=1;				
					}
				}
			}
		}
	}
	printf("%lld\n", r*g*b-check);
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:9:9: error: expected ',' or ';' before 'long'
    9 |         long long int r = 0, g = 0, b = 0, check = 0;
      |         ^~~~
main.c:12:25: error: 'r' undeclared (first use in this function)
   12 |                         r++;
      |                         ^
main.c:12:25: note: each undeclared identifier is reported only once for each function it appears in
main.c:14:25: error: 'g' undeclared (first use in this function)
   14 |                         g++;
      |                         ^
main.c:16:25: error: 'b' undeclared (first use in this function)
   16 |                         b++;
      |                         ^
main.c:24:49: error: 'check' undeclared (first use in this function)
   24 |                                                 check+=1;
      |                                                 ^~~~~
Language: C

#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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 dx[] = {0, 1, -1, 0, 1, -1, 1, -1}; // i<4:4way i<8:8way
int dy[] = {1, 0, 0, -1, 1, -1, -1, 1};

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int dp[4005][3]; // dp[i][j] := 右からi番目までの

// 0:Rの数
// 1:Gの数
// 2:Bの数

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == 'R')
            dp[i][0]++;
        else if (s[i] == 'G')
            dp[i][1]++;
        else
            dp[i][2]++;
        rep(j, 3) dp[i][j] += dp[i + 1][j];
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (s[i] == s[j])
                continue;
            int dis = j - i;
            if (dis + j >= n)
                dis = 0;
            if (s[i] == 'R')
            {
                if (s[j] == 'G')
                {
                    ans += dp[j + 1][2];
                    if (s[j + dis] == 'B')
                        ans--;
                }
                else if (s[j] == 'B')
                {
                    ans += dp[j + 1][1];
                    if (s[j + dis] == 'G')
                        ans--;
                }
            }
            else if (s[i] == 'G')
            {
                if (s[j] == 'R')
                {
                    ans += dp[j + 1][2];
                    if (s[j + dis] == 'B')
                        ans--;
                }
                else if (s[j] == 'B')
                {
                    ans += dp[j + 1][0];
                    if (s[j + dis] == 'R')
                        ans--;
                }
            }
            else if (s[i] == 'B')
            {
                if (s[j] == 'R')
                {
                    ans += dp[j + 1][1];
                    if (s[j + dis] == 'G')
                        ans--;
                }
                else if (s[j] == 'G')
                {
                    ans += dp[j + 1][0];
                    if (s[j + dis] == 'R')
                        ans--;
                }
            }
        }
    }
    cout << ans << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
#define 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;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  ll int cntr=0;
  ll int cntb=0;
  ll int cntg=0;
  rep(i,n){
    if(s[i]=='R') cntr++;
    if(s[i]=='B') cntb++;
    if(s[i]=='G') cntg++;
  }
  ll int ans=cntr*cntb*cntg;
  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[i]!=s[k]) ans--;
    }
  }
  cout<<ans<<endl;
}
        
        
        

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: two or more data types in declaration of 'cntr'
   12 |   ll int cntr=0;
      |   ^~
a.cc:13:3: error: two or more data types in declaration of 'cntb'
   13 |   ll int cntb=0;
      |   ^~
a.cc:14:3: error: two or more data types in declaration of 'cntg'
   14 |   ll int cntg=0;
      |   ^~
a.cc:16:19: error: 'cntr' was not declared in this scope
   16 |     if(s[i]=='R') cntr++;
      |                   ^~~~
a.cc:17:19: error: 'cntb' was not declared in this scope
   17 |     if(s[i]=='B') cntb++;
      |                   ^~~~
a.cc:18:19: error: 'cntg' was not declared in this scope
   18 |     if(s[i]=='G') cntg++;
      |                   ^~~~
a.cc:20:3: error: two or more data types in declaration of 'ans'
   20 |   ll int ans=cntr*cntb*cntg;
      |   ^~
a.cc:20:14: error: 'cntr' was not declared in this scope
   20 |   ll int ans=cntr*cntb*cntg;
      |              ^~~~
a.cc:20:19: error: 'cntb' was not declared in this scope
   20 |   ll int ans=cntr*cntb*cntg;
      |                   ^~~~
a.cc:20:24: error: 'cntg' was not declared in this scope
   20 |   ll int ans=cntr*cntb*cntg;
      |                        ^~~~
a.cc:25:46: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |       if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k]) ans--;
      |                                              ^~~
      |                                              abs
a.cc:28:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: Java

import java.util.Scanner;

public class MainClass {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();
        String S = scanner.nextLine();

        long R = 0, G = 0, B = 0;
        for (int i = 0;i < N;i++) {
            if (S.charAt(i) == 'R') R++;
            else if (S.charAt(i) == 'G') G++;
            else B++;
        }

        long ans = R * G * B;
        for(int i = 0;i < N;i++) {
            int j = i-1, k = i+1;
            while (j >= 0 && k < N) {
                if(S.charAt(i) != S.charAt(j)
                        && S.charAt(j) != S.charAt(k)
                        && S.charAt(i) != S.charAt(k))
                    ans--;
                j--;k++;
            }
        }
        System.out.println(ans);
    }
}


Compiler output:
Main.java:3: error: class MainClass is public, should be declared in a file named MainClass.java
public class MainClass {
       ^
1 error
Language: C

#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}

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;
    int r = 0, g = 0, b = 0;
    rep(i, N){
        if(S[i] == 'R')r++;
        if(S[i] == 'G')g++;
        if(S[i] == 'B')b++;
    }
    ll ans = r * g * b;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            if(2 * j - i < N){
                if(S[i] != S[j] && S[i] != S[2 * j - i] && S[j] != S[2 * j - i] ) 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;

int main() {
  int N, i, j, R, G, B;
  R = 0;
  G = 0;
  B = 0;
  string S;
  cin >> N >> S;
  if (N == 1 || N == 2 || N == 3) {
    cout << '0' << endl;
  }
  for (i = 0; i < N; i++) {
    if (S[i] == 'R') {
      R++;
    } else if (S[i] == 'G') {
      G++;
    } else {
      B++;
    }
  }
  long tmp = 0;
  for (i = 0; i < N - 2; i++) {
    for (j = i + 1; j < N - 1; j++) {
      if (2 * j - i < N) {
        if (S[i] != S[j] && S[j] != S[2 * j - i] && S[2 * j - i] != S[i]) {
          tmp++;
        }
      }
    }
  }
  //   cout << R << G << B << tmp << endl;
  cout << max((R * B * G) - tmp, 0) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:14: error: no matching function for call to 'max(long int, int)'
   34 |   cout << max((R * B * G) - tmp, 0) << endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:34:14: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   34 |   cout << max((R * B * G) - tmp, 0) << endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:34:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   34 |   cout << max((R * B * G) - tmp, 0) << endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~
Language: C

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

int main() {
  int N, i, j, k, R, G, B;
  R = 0;
  G = 0;
  B = 0;
  string S;
  cin >> N >> S;
  if (N == 1 || N == 2 || N == 3) {
    cout << '0' << endl;
  }
  for (i = 0; i < N; i++) {
    if (S[i] == 'R') {
      R++;
    } else if (S[i] == 'G') {
      G++;
    } else {
      B++;
    }
  }
  int tmp = 0;
  for (i = 0; i < N - 2; i++) {
    for (j = i + 1; j < N - 1; j++) {
      if (2 * j - i < N) {
        if (S[i] != S[j] && S[j] != S[2 * j - i] && S[2 * j - i] != S[i]) {
          tmp++;
        }
      }
    }
  }
  //   cout << R << G << B << tmp << endl;
  cout << max((R * B * G) - tmp, 0) << 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>
using namespace std;

int main(){
  long long int ans = 0;
  int n;
  char color[4001];
  int r = 0, g = 0, b = 0;
  cin >> n;
  if(n < 3){
    cout << 0 << '\n';
    return 0;
  }
  for(int i=1; i<=n; i++){
    cin >> color[i];
    if(color[i] == 'R'){
      r += 1;
    }else if(color[i] == 'G'){
      g += 1;
    }else{
      b += 1;
    }
  }
  if(rgb == 0){
    cout << 0 << '\n';
    return 0;
  }
  for(int i=1; i<=n-2; i++){
    if(color[i] == 'R'){
      for(int j=i+1; j<=n-1; j++){
        if(color[j] == 'G'){
          if(color[j + j - i] == 'B'){
            ans += 1;
          }
        }else if(color[j] == 'B'){
          if(color[j + j - i] == 'G'){
            ans += 1;
          }
        }
      }
    }else if(color[i] == 'G'){
      for(int j=i+1; j<=n-1; j++){
        if(color[j] == 'R'){
          if(color[j + j - i] == 'B'){
            ans += 1;
          }
        }else if(color[j] == 'B'){
          if(color[j + j - i] == 'R'){
            ans += 1;
          }
        }
      }
    }else{
      for(int j=i+1; j<=n-1; j++){
        if(color[j] == 'G'){
          if(color[j + j - i] == 'R'){
            ans += 1;
          }
        }else if(color[j] == 'R'){
          if(color[j + j - i] == 'G'){
            ans += 1;
          }
        }
      }
    }
  }
  cout << r*g*b - ans << '\n';
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:6: error: 'rgb' was not declared in this scope
   24 |   if(rgb == 0){
      |      ^~~
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] c = s.toCharArray();
        int r = 0;
        int g = 0;
        int b = 0;
//        for (int i = 0; i < c.length; i++) {
//            if (c[i] == 'R') r++;
//            if (c[i] == 'G') g++;
//            if (c[i] == 'B') b++;
//        }
        for (int i = 0; i < n; i++) {
            char c = s.charAt(i);
            if (c == 'R') r++;
            if (c == 'G') g++;
            if (c == 'B') b++;
        }

        //総数
        long ans = r*g*b;

        //(i,j,k)の中でiの位置を固定する。
        for (int st = 0; st < n - 2; st++) {
            //(i,j,k)の中でjの位置を固定する。つまりkの位置を決まる。
            for (int dist = 1; st + dist * 2 < n; dist++) {
                char si = s.charAt(st);
                char sj = s.charAt(st + dist);
                char sk = s.charAt(st + dist * 2);
                if (si != sj && sj != sk && sk != si)
                    ans--;
//                char i = c[st];
//                char j = c[st + dist];
//                char k = c[st + dist * 2];
//                if (i != j && j != k && i != k) ans--;
            }
        }
        System.out.println(ans);
    }
}


Compiler output:
Main.java:18: error: variable c is already defined in method main(String[])
            char c = s.charAt(i);
                 ^
1 error
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using M = map<int, int>;

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

  ll r, g, b;
  for(int i=0; i<n; ++i)
		s[i]=='R'? r++: s[i]=='G'? g++: b++;

  ll ans = r*g*b

  /*
  int cntR = 0, cntG = 0, cntB = 0;
  rep(i, n) {
    if (s[i] == 'R') cntR++;
    else if (s[i] == 'G') cntG++;
    else if (s[i] == 'B') cntB++;
  }

  ll ans = cntR * cntG * cntB;
  */


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

  cout << ans - ng << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:3: error: expected ',' or ';' before 'll'
   42 |   ll ng;
      |   ^~
a.cc:47:74: error: 'ng' was not declared in this scope; did you mean 'g'?
   47 |                         if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ng++;
      |                                                                          ^~
      |                                                                          g
a.cc:51:17: error: 'ng' was not declared in this scope; did you mean 'g'?
   51 |   cout << ans - ng << endl;
      |                 ^~
      |                 g
Language: C

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

int main() {
  int n;
  cin>>n;
  if(n<3){
    cout<<0<<endl;
    return 0;
  }
  string s;
  cin>>s;
  ll 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(2*j==i+k){
          continue;
        }
        if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[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>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;

int main(void) 
{
    int n;
    cin >> n;
    vector<char> s(n);
    rep(i,n) cin >> s[i];

    long long ans = 0;
    if(n < 3) {
        cout << 0 << endl;
        return 0;
    }

    int R = 0;
    int G = 0;
    int B = 0;

    rep(i,n){
       if(s[i] == 'R') R++;
       else if(s[i] == 'G') G++;
       else B++;
    }
    ans = R * G * B;
    if(ans <= 0) {
        cout << 0 << endl;
        return 0;
    }

    rep(i,n -2){
        for(int j = i + 1; j < n -1 ; j++++){
            if(s[i] == s[j]) continue;
            int k = j - i + j;
            if(k >= n) break;
            if(s[j] != s[k] && s[k] != s[i])
            {
                ans--;
                //printf("i:%d j:%d k:%d\n",i,j,k);
            }
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:40: error: lvalue required as increment operand
   36 |         for(int j = i + 1; j < n -1 ; j++++){
      |                                       ~^~
Language: C

#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi acos(-1)
typedef long unsigned int ll;
using namespace std;

int main()
{
    Fast;
    ll n,m,i,j,k;
    ll ans=0LL;
    string s;
    cin>>n>>s;
    ll v1=0,v2=0,v3=0;
    for(ll i=0; i<n; i++)
    {
        if(s[i]=='R')
        {
            v1++;
        }
        if(s[i]=='G')
        {
            v2++;
        }
        if(s[i]=='B')
        {
            v3++;
        }
    }
    ans=v1*v2*v3;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            k=(j+(j-i));
            if(k<n)
            {
                if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i])
                {
                    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;

long long n, r, g, b, m;
string s;

int main(){
	cin >> n >> s;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'R') r++;
		else if(s[i] == 'G') g++;
		else b++;
	}
	m = r*g*b;
	for(int i = 0; i < n; ++i){
		for(int j = 1; i+j+j < n; ++j){
			if(s[i]!=s[i+j]&&s[i]!=s[i+j+j]&&s[i+j]!=s[i+j+j]) m--;
		}
	}
	cout << m << 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

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] d = S.toCharArray();
        int red = 0;
        int green = 0;
        int blue = 0;
        for (int i = 0; i < d.length; i++) {
            if (d[i] == 'R') {
                red += 1;
            }
            if (d[i] == 'G') {
                green += 1;
            }
            if (d[i] == 'B') {
                blue += 1;
            }
        }
        int ans = red * green * blue;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (d[i] == d[j]) {
                    continue;
                }
                int k = j + j - i;
                if (N <= k) {
                    continue;
                }
                if (d[i] == d[k] || d[j] == d[k]) {
                    continue;
                }
                ans -= 1;
            }
        }
        System.out.println(ans);
    }

}


Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import java.io.BufferedReader;
      | ^~~~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    1 | import java.io.BufferedReader;
      |            ^
main.c:2:1: error: unknown type name 'import'
    2 | import java.io.InputStreamReader;
      | ^~~~~~
main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    2 | import java.io.InputStreamReader;
      |            ^
main.c:3:1: error: unknown type name 'import'
    3 | import java.util.*;
      | ^~~~~~
main.c:3:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    3 | import java.util.*;
      |            ^
main.c:5:1: error: unknown type name 'public'
    5 | public class Main {
      | ^~~~~~
main.c:5:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
    5 | public class Main {
      |              ^~~~
Language: C

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		
		int r = 0;
		int g = 0;
		int b = 0;
		
		for (int i = 0; i < n; i++) {
			char c = s.charAt(i);
			if (c == 'R') r++;
			if (c == 'G') g++;
			if (c == 'B') b++;
		}
		
		int ans = r * g * b;
		
		for (int st = 0; st < n - 2; st++) {
			for (int dist = 1; st + dist * 2 < n; dist++) {
				char si = s.charAt(st);
				char sj = s.charAt(st + dist);
				char sk = s.charAt(st + dist * 2);
				if (si != sj && sj != sk && sk != si)
					ans--;
			}
		}
		
		System.out.println(ans);
	}
}


Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import java.util.Scanner;
      | ^~~~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    1 | import java.util.Scanner;
      |            ^
main.c:3:1: error: unknown type name 'public'
    3 | public class Main {
      | ^~~~~~
main.c:3:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
    3 | public class Main {
      |              ^~~~
Language: C

import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = iss()
    mx = S.count('R') * S.count('G') * S.count('B')
    for i in range(N):
        for j in range(i + 1, N):
            k = j + j - i
            if k < N:
                if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                    mx -= 1

    print(mx)


if __name__ == '__main__':
    main()


Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import sys
      | ^~~~~~
main.c:2:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'import'
    2 | import os
      | ^~~~~~
main.c:2:1: error: unknown type name 'import'
main.c:34:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   34 | if __name__ == '__main__':
      |                ^~~~~~~~~~
Language: Java

import java.io.*;

class Main
{
    public static void main(String args[])
    {
        String buf;
        int num;
        int ans;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt( br.readLine() );
            char[] work = new char[buf.length()];
            char r = 'R';
            char g = 'G':
            char b = 'B':
            ans = 0;

            for(int i = 0; i < buf.length(); i++){
                work[i] = text.charAt(i);
            }
            for(int i = 0; i < buf.length(); i++){
                if (work[i] == r){
                    for(int j = i + 1; j < buf.length(); j++){
                        if (work[j] == g){
                            for(int k = j + 1; k < buf.length(); k++){
                                if (work[k] == b && j - i != k-j){
                                    ans += 1;
                                }
                            }
                        }
                    }
                }
            }
            
            System.out.println(Integer.toString(ans));
        } catch(Exception e) {}
  }
}

Compiler output:
Main.java:16: error: ';' expected
            char g = 'G':
                        ^
Main.java:17: error: ';' expected
            char b = 'B':
                        ^
2 errors
Language: C

// D - RGB Triplets
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
long long ng,r,g,b;

int main(){
	int N; string S; cin>>N>>S;
	rep(i, N){
		S[i]=='R'? r++: S[i]=='G'? g++: b++;
		rep(d, N/2){
			int j = i + d, k = j + d;
			if(k >= N) break;
			if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ng++;
		}
	}
	cout<< r*g*b - ng <<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>

using namespace std;

int main(){
    int_fast64_t n,cnt=0;
    string s;
    cin >>n >>s;
    list<int> n_r,n_g,n_b;

    for(int_fast16_t i=0;i<n;i++){
        if(s[i]=='R'){
            n_r.emplace_back(i);
            continue;
        }else if(s[i]=='G'){
            n_g.emplace_back(i);
            continue;
        }else if(s[i]=='B'){
            n_b.emplace_back(i);
        }
    }

    n_b.emplace_back(0);

    for(std::list<int>::iterator r = n_r.begin();r!=n_r.end();r++){
        for(std::list<int>::iterator g = n_g.begin();g!=n_g.end();g++){
           
                if(find(n_b.begin(),n_b.end(),(*r+*g)/2.) !=n_b.end() && find(n_b.begin(),n_b.end(),(*r *2-*g)) !=n_b.end() && find(n_b.begin(),n_b.end(),(*g*2-*r)) !=n_b.end() ){
                    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;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  long long int r=0,g=0,b=0;
  for(int i=0;i<N;i++){
    if(S.at(i) == 'R') ++r;
    if(S.at(i) == 'G') ++g;
    if(S.at(i) == 'B') ++b;
  }
  int count = r*g*b;

  for(int i=0;i<N;i++){
    int j = i + 1;
    for(;j<N;j++){
      if(S[i]==S[j]){
        break;
      }
      //cout << "i=" << i << endl;
      //cout << "j=" << j << endl;
      int k = 2j + 1;
      if(k>=N) continue;
      if(S[i]!=S[j] && S[j]!=S[k] && S[k]==S[i]){
        count--;
      }
    }
  }

  cout << count << endl;
  return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:18: error: cannot convert '__complex__ int' to 'int' in initialization
   25 |       int k = 2j + 1;
      |               ~~~^~~
      |                  |
      |                  __complex__ int
Language: C

def binary_search(list,target):

	result = -1
	left = 0
	right = len(list) - 1

	while left <= right:
		center = int((left + right)/2)
		if list[center] == target:
			result = center
			break
		elif list[center] < target:
			left = center + 1
		elif list[center] > target:
			right = center - 1

	if result == -1:
		return result
	else:
		return result


if __name__=="__main__":
    n=int(input())
    s=list(input())
    rlist=[]
    glist=[]
    blist=[]
    ans=0
    if len(s)<=3:
        print(0)
        exit()
    for i in range(n):
        if s[i]=="R":
            rlist.append(i)
        elif s[i]=="G":
            glist.append(i)
        else:
            blist.append(i)
    if len(rlist)==0 or len(glist)==0 or len(blist)==0:
        print(0)
        exit()
    ans+=len(rlist)*len(glist)*len(blist)
    for i in range(n-2):
        for j in range(i+1,n-1):
            k=2*j-i
            if s[i]==s[j]:
                continue
            elif k>len(s)-1:
                continue
            else:
                if s[k]!=s[i] and s[k]!=s[j]:
                    ans-=1

    print(ans)

Compiler output:
main.c:1:1: error: unknown type name 'def'
    1 | def binary_search(list,target):
      | ^~~
main.c: In function 'binary_search':
main.c:1:31: error: expected declaration specifiers before ':' token
    1 | def binary_search(list,target):
      |                               ^
main.c:1:5: error: type of 'list' defaults to 'int' [-Wimplicit-int]
    1 | def binary_search(list,target):
      |     ^~~~~~~~~~~~~
main.c:1:5: error: type of 'target' defaults to 'int' [-Wimplicit-int]
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 P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main() {
  ll n ;
  cin >>n ;
  string s ;
  cin >>s ;
  ll d=0 ;
  ll e=0 ;
  ll f=0 ;
  for(int i=0 ;i<n ;i++){
    if( s.at(i)== 'R')
    d ++ ;
  }
  for(int i=0; i<n ;i++){
    if(s.at(i)=='G')
     e++ ;
  }
  for(int i=0 ; i<n ;i++){
    if( s.at(i)=='B')
    f++ ;
  }
  ll sum= d*e*f ;
  for(int i=0 ; i<n ; i++){
   for(int j=1;j< min(i+1,(n-i+1)/2) ;j++ ){
     if(s.at(i)!=s.at(i+j) &&s.at(i)!=s.at(i-j))
     sum-- ;
   }
  }
  cout << sum <<endl ;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:22: error: no matching function for call to 'min(int, ll)'
   30 |    for(int j=1;j< min(i+1,(n-i+1)/2) ;j++ ){
      |                   ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:30:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   30 |    for(int j=1;j< min(i+1,(n-i+1)/2) ;j++ ){
      |                   ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:30:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |    for(int j=1;j< min(i+1,(n-i+1)/2) ;j++ ){
      |                   ~~~^~~~~~~~~~~~~~~
Language: C

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  {
    int n;
    cin>>n;
    string str;
    int r=0,b=0,g=0;
    cin>>str;
    int l=0;
    int ans=0;
    for(auto i:str){
      if(i=='R') r++;
      if(i=='G') g++;
      if(i=='B') b++;
      for(int j=l+1;2*j-l<n;j++)
      {
        int k=j-l+j;
        if(i!=str[j]&& str[j]!=str[k] && i!=str[k])
          ans--;
      }
      l++;
    }
    cout<<r*b*g+ans;
  }
  //time("");
  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

unittest
{
	assert( [ "4", "RRGB" ].parse.expand.solve == 1 );
	assert( [ "39", "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB" ].parse.expand.solve == 1800 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	const long[ dchar ] CS = [ 'R':0L, 'G':1L, 'B':2L ];
	
	auto tss = new long[][]( 1 + s.length, CS.length );
	foreach_reverse( i, c; s )
	{
		foreach( j; 0L .. tss[ i ].length.signed )
		{
			tss[ i ][ j ] = tss[ i + 1 ][ j ] + ( j == CS[ c ] );
		}
	}
	
	auto ans = 0L;
	foreach( i; 0L .. tss.length.signed - 3 )
	{
		foreach( j; i + 1 .. tss.length.signed - 2 )
		{
			if( s[ i ] == s[ j ] ) continue;
			auto d = j - i;
			auto c = CS.length.signed - CS[ s[ i ] ] - CS[ s[ j ] ];
			ans += tss[ j + 1 ][ c ] - ( j + d < s.length && CS[ s[ j + d ] ] == c );
		}
	}
	return ans;
}


Compiler output:
main.c:2:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    2 | {
      | ^
main.c:9:1: error: unknown type name 'import'
    9 | import std.conv;
      | ^~~~~~
main.c:9:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    9 | import std.conv;
      |           ^
main.c:10:1: error: unknown type name 'import'
   10 | import std.range;
      | ^~~~~~
main.c:10:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
   10 | import std.range;
      |           ^
main.c:11:1: error: unknown type name 'import'
   11 | import std.stdio;
      | ^~~~~~
main.c:11:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
   11 | import std.stdio;
      |           ^
main.c:12:1: error: unknown type name 'import'
   12 | import std.typecons;
      | ^~~~~~
main.c:12:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
   12 | import std.typecons;
      |           ^
main.c: In function 'main':
main.c:16:9: error: 'stdin' undeclared (first use in this function)
   16 |         stdin.byLineCopy.parse.expand.solve.writeln;
      |         ^~~~~
main.c:1:1: note: 'stdin' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
  +++ |+#include <stdio.h>
    1 | unittest
main.c:16:9: note: each undeclared identifier is reported only once for each function it appears in
   16 |         stdin.byLineCopy.parse.expand.solve.writeln;
      |         ^~~~~
main.c: At top level:
main.c:19:22: error: unknown type name 'Range'
   19 | auto parse( Range )( Range input )
      |                      ^~~~~
main.c:27:13: error: unknown type name 'dchar'; did you mean 'char'?
   27 | auto solve( dchar[] s )
      |             ^~~~~
      |             char
Language: C

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

int ans = 0;
int n;
string x;

void solve(string form)
{
    int p[n], cnt = 0;
    memset(p, 0, sizeof p);
    char c = form[2];
    for (int i = n - 1; i >= 0; i--) {
        if (c == x[i]) p[i] = ++cnt;
    }
    int re = 0;
    for (int i = 1; i <= n - 1; i++) {
        for (int j = 0; j < n; j++) {
            if (!(j + i < n)) break;


            if (x[j] == form[0] && x[j + i] == form[1]) {
                bool ok = false;
                if (j + 2 * i < n && x[j + 2 * i] == form[2]) {
                    ok = true;
                }
                int nxt = -1;
                for (int k = j + i + 1; k < n; k++) {
                    if (x[k] == form[2]) {
                        nxt = k;
                        break;
                    }
                }
                if (nxt == -1) break;
                else {
                    re += p[nxt];
                    if (ok) re--;
                }
            }
        }
    }
    ans += re;
}

int main()
{
    cin >> n >> x;
    solve("RGB");
    solve("BGR");
    solve("BRG");
    solve("GBR");
    solve("GRB");
    solve("RBG");
    cout << ans << "\n";
}


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