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

#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main(){
	int n;
	string s;
	int rc(0), gc(0), bc(0);
	cin >> n >> s;
	rep(i, n) {
		if (s[i] == 'R')++rc;
		if (s[i] == 'G')++gc;
		if (s[i] == 'B')++bc;
	}

	ll count;
	count = rc * gc * bc;
	rep(i, n) {
		for (int j = i + 1; j < n; ++j) {
			if (2*j - i < n) {
				if (s[i]!=s[j] &&s[j]!=s[2*j-i] && s[i]!=s[2*j-i]){				
						count--;
				}
			}

		}
	}
	cout << count;
	return 0;
}

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

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

int main(){
  int N;string s;
  Cin >> N >> s;
  
  int R = 0, G = 0, B = 0;
  for(int i = 0; i < N; i++){
    if(s.at(i) == 'R'){
      R++;
    }else if(s.at(i) == 'G'){
      G++;
    }else{
      B++;
    }
  }
  
  int count = 0;
  for(int i = 0; i < N-2; i++){
    for(int j = i + 1; j < (N - i + 1)/2 + i; j++){
      if(s.at(i) != s.at(j) && s.at(j) != s.at(2*j - i) && s.at(i) != s.at(2*j - i)){
        count++;
      }
    }
  }
  
  cout << R * G * B - count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'Cin' was not declared in this scope; did you mean 'sin'?
    6 |   Cin >> N >> s;
      |   ^~~
      |   sin
Language: C++

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

int main(){
  int N;string s;
  sin >> N >> s;
  
  int R = 0, G = 0, B = 0;
  for(int i = 0; i < N; i++){
    if(s.at(i) == 'R'){
      R++;
    }else if(s.at(i) == 'G'){
      G++;
    }else{
      B++;
    }
  }
  
  int count = 0;
  for(int i = 0; i < N-2; i++){
    for(int j = i + 1; j < (N - i + 1)/2 + i; j++){
      if(s.at(i) != s.at(j) && s.at(j) != s.at(2*j - i) && s.at(i) != s.at(2*j - i)){
        count++;
      }
    }
  }
  
  cout << R * G * B - count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:7: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator>>'
    6 |   sin >> N >> s;
      |   ~~~~^~~~
Language: C

// Aggressive Play
 
#include<bits/stdc++.h>
#define ll long long
 
using namespace std;
const int N = 4e3 + 5;
const int k = 3;
int a[N][k];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = "@" + s;
    map<char, int> mp;
    mp['R'] = 0;
    mp['G'] = 1;
    mp['B'] = 2;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < k; j++){
            a[i][j] = a[i - 1][j];
        }
        a[i][mp[s[i]]]++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i + 2; j <= n; j++){
            if(s[i] == s[j]) continue;
            vector<int> h(k, 0);
            for(int kk = 0; kk < k; kk++){
                h[kk] = a[j - 1][kk] - a[i][kk];
            }
            int diff = j - i;
            if(diff % 2 == 0){
                int mid = (i + j) / 2;
                h[mp[s[mid]]]--;
            }
            h[mp[s[i]]] = 0;
            h[mp[s[j]]] = 0;
            for(int kk = 0; kk < k; kk++)
                ans += h[kk];
        }
    }
    cout << ans;
return 0;
}

Compiler output:
main.c:3:9: fatal error: bits/stdc++.h: No such file or directory
    3 | #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 ans = 0;
  if(N > 2){
    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(j - i != k - j && s.at(i) != s.at(j) && s.at(i) != s.at(k) && s.at(j) != s.at(k)){
            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;

int main(){
  int N;string s;
  cin >> N >> s;
  
  int ans = 0;
  if(N > 2){
    for(int i = 0; i < N - 2){
      for(int j = i + 1; j < N - 1; j++){
        for(int k = j + 1; k < N; k++){
          if(j - i != k - j && s.at(i) != s.at(j) && s.at(i) != s.at(k) && s.at(j) != s.at(k)){
            ans++;
          }
        }
      }
    }
  }
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:29: error: expected ';' before ')' token
   10 |     for(int i = 0; i < N - 2){
      |                             ^
      |                             ;
Language: Java

        int N = sc.nextInt();
        StringBuilder S = new StringBuilder();
        S.append("i");
        S.append(sc.next());
        long r =0,g=0,b=0;
        for(int i=1;i<=N;i++){
            if(S.charAt(i)=='R') r++;
            else if(S.charAt(i)=='G')g++;
            else if(S.charAt(i)=='B')b++;
        }
        long opt = r*g*b;
        for(int i=1;i<=N-1;i++){
            for(int j=i+1;j<=(N+i)/2;j++){
                int k = 2*j-i;
                if(S.charAt(i)!=S.charAt(j)&&S.charAt(j)!=S.charAt(k)&&S.charAt(i)!=S.charAt(k))opt--;
            }
        }
        if(opt>=0)System.out.println(opt);
        else System.out.println(0);

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
        int N = sc.nextInt();
        ^
  (use --enable-preview to enable unnamed classes)
Main.java:3: error: class, interface, enum, or record expected
        S.append("i");
        ^
Main.java:4: error: class, interface, enum, or record expected
        S.append(sc.next());
        ^
Main.java:6: error: class, interface, enum, or record expected
        for(int i=1;i<=N;i++){
        ^
Main.java:6: error: class, interface, enum, or record expected
        for(int i=1;i<=N;i++){
                    ^
Main.java:6: error: class, interface, enum, or record expected
        for(int i=1;i<=N;i++){
                         ^
Main.java:8: error: class, interface, enum, or record expected
            else if(S.charAt(i)=='G')g++;
            ^
Main.java:9: error: class, interface, enum, or record expected
            else if(S.charAt(i)=='B')b++;
            ^
Main.java:10: error: class, interface, enum, or record expected
        }
        ^
Main.java:12: error: class, interface, enum, or record expected
        for(int i=1;i<=N-1;i++){
        ^
Main.java:12: error: class, interface, enum, or record expected
        for(int i=1;i<=N-1;i++){
                    ^
Main.java:12: error: class, interface, enum, or record expected
        for(int i=1;i<=N-1;i++){
                           ^
Main.java:13: error: class, interface, enum, or record expected
            for(int j=i+1;j<=(N+i)/2;j++){
                          ^
Main.java:13: error: class, interface, enum, or record expected
            for(int j=i+1;j<=(N+i)/2;j++){
                                     ^
Main.java:15: error: class, interface, enum, or record expected
                if(S.charAt(i)!=S.charAt(j)&&S.charAt(j)!=S.charAt(k)&&S.charAt(i)!=S.charAt(k))opt--;
                ^
Main.java:16: error: class, interface, enum, or record expected
            }
            ^
Main.java:19: error: class, interface, enum, or record expected
        else System.out.println(0);
        ^
17 errors
Language: C

#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.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;}

int main(){
  ll n,rcnt=0,gcnt=0,bcnt=0,ans,J,K;
  cin >> n;
  string s;
  cin >> s;

  rep(i,0,n){
    if(s[i]=='R')rcnt++;
    if(s[i]=='G')gcnt++;
    if(s[i]=='B')bcnt++;
  }
  ans= rcnt*gcnt*bcnt;

  rep(i,0,n){
    rep(d,1,n){
      J= i+d;
      K= J+d;
      if(K>=n)break;
      if(s[i]!=s[J] && s[i]!=s[K] && s[J]!=s[K]){
        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: Java

import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
		String st = sc.next();
      	char [] S = st.toCharArray();
		int sum =0;
		for(int i=0;i<N;i++){
          for(int j=i+1;j<N;j++){
            for(int k=j+1;j<N;j++){
			if(j-i!=k-j){
              if(S[i]!=S[J]&&S[i]!=S[k]){
              if(S[j]!=S[k]){
                sum+=1;
              	}
              }
            }
       		}
          }
        }
      System.out.println(sum);
	}
}

Compiler output:
Main.java:14: error: cannot find symbol
              if(S[i]!=S[J]&&S[i]!=S[k]){
                         ^
  symbol:   variable J
  location: class Main
1 error
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 st = sc.next();
      	char [] S = st.toCharArray();
		int sum =0;
		for(int i=0;i<N;i++){
          for(int j=1;j<N;j++){
            for(int k=2;j<N;j++){
			if(j-i!=k-j){
              if(S[i]!=S[J]&&S[i]!=S[k]){
              if(S[j]!=S[k]){
                sum+=1;
              	}
              }
            }
       		}
          }
        }
      System.out.println(sum);
	}
}

Compiler output:
Main.java:14: error: cannot find symbol
              if(S[i]!=S[J]&&S[i]!=S[k]){
                         ^
  symbol:   variable J
  location: class Main
1 error
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 st = sc.next();
      	char [] S = st.toCharArray();
		int sum =0;
		for(int i=0;i<N;i++){
          for(int j=1;j<N;j++){
            for(int k=2;j<N;j++){
			if(j-i!=k-j){
              if(S[i]!=S[J]&&S[i]!=S[k]){
              if(S[j]!=S[k]){
                sum+=1
              	}
              }
            }
       		}
          }
        }
      System.out.println(sum);
	}
}

Compiler output:
Main.java:16: error: ';' expected
                sum+=1
                      ^
1 error
Language: C

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;i++)

const ll INF = 1001001001;

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

int main(){
  int n; cin>>n;
  string s; cin>>s;
  int r=0;
  int g=0;
  int b=0;
  rep(i,n){
    if(s.at(i)=='R'){
      r++;
    }else if(s.at(i)=='G'){
      g++;
    }else{
      b++;
    }
  }
  int sum=r*g*b;
  int res=0;

  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      if(2*j-i<=n-1){
        if(s.at(i)!=s.at(j) && s.at(j)!=s.at(2*j-i)&&s.at(i)!=s.at(2*j-i)){
          res++;
        }
      }
      
    }
  }
  int ans=sum-res;
  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;
  cin>>N;
  string S;
  cin>>S;
  int R;
  int G;
  int B;
  int sum;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      R=R+1;
    }
    else if(S.at(i)=='G'){
      G=G+1;
    }
    else{
      B=B+1;
    }
  }
  sum=R*G*B;
  int count=0;
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      if((2*j-i)<N){
        if(S.at(i)==S.at(j)orS.at(i)==S.at(2*j-i)orS.at(2*j-i)==S.at(j)){
          count=count+1;
        }
      }
    }
  }
  cout<<sum-count<<endl;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:28:28: error: expected ')' before 'orS'
   28 |         if(S.at(i)==S.at(j)orS.at(i)==S.at(2*j-i)orS.at(2*j-i)==S.at(j)){
      |           ~                ^~~
      |                            )
Language: C

#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

vector<int> v;

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

    int len = size(s);
    rep(i, len){
        FOR(j, i + 1, len){
            if(s[i] == s[j]){
                continue;
            }

            FOR(k, j + 1, len){
                if(s[i] == s[k] || s[j] == s[k]){
                    continue;
                }

                int ji = j - i;
                int kj = k - j;
                if(ji == kj){
                    continue;
                }

                cout << (i + 1) << sp << (j + 1) << sp << (k + 1) << next;
            }
        }
    }
}


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;
int main() {
	int N;
	string S;
	cin >> N >> S;
	int e = 0;
  int r = 0,
  int a = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R'){ e++; }
		if (S[i] == 'G'){ r++;}
		if (S[i] == 'B'){ a++;}
	}
 
	int w = e * r * a;
 
	for (int j = 1; j<= N; j++) {
		for (int m = j; m < N; m++) {
			if (m - j < 0 || m + j >= N) ;
			if ((S[m - j] != S[m + j]) && (S[m] != S[m + j]) && S[m - j] != S[m]) w--;
		}
	}
	cout << w << endl;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: expected unqualified-id before 'int'
    9 |   int a = 0;
      |   ^~~
a.cc:13:35: error: 'a' was not declared in this scope
   13 |                 if (S[i] == 'B'){ a++;}
      |                                   ^
a.cc:16:25: error: 'a' was not declared in this scope
   16 |         int w = e * r * a;
      |                         ^
Language: C

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  string s;
  cin >> n >> s;

  ll r = 0, g = 0, b = 0;
  for(ll i = 0; i < n; i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'G') g++;
    if(s[i] == 'B') b++;
  }
  ll sum = r * g * b;
  cout << sum << endl;

  for(ll i = 0; i < n-2; i++){
    for(ll j = i+1; j < n-1; j++){
      if(j+j-i < n && s[i] != s[j] && s[j] != s[j+j-i] && s[j+j-i] != s[i]) sum--;
    }
  }
  cout << sum << endl;
  return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	string S;
	cin >> N >> S;
	int e = 0;
  int r = 0,
  int a = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') e++;
		if (S[i] == 'G') r++;
		if (S[i] == 'B') a++;
	}
 
	int w = e * r * a;
 
	for (int j = 1; j<= N; j++) {
		for (int m = j; m < N; m++) {
			if (m - j < 0 || m + j >= N) ;
			if ((S[m - j] != S[m + j]) && (S[m] != S[m + j]) && S[m - j] != S[m]) w--;
		}
	}
	cout << w << endl;
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: expected unqualified-id before 'int'
    9 |   int a = 0;
      |   ^~~
a.cc:13:34: error: 'a' was not declared in this scope
   13 |                 if (S[i] == 'B') a++;
      |                                  ^
a.cc:16:25: error: 'a' was not declared in this scope
   16 |         int w = e * r * a;
      |                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	string S;
	cin >> N >> S;
	int e = 0, int r = 0, int a = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') e++;
		if (S[i] == 'G') r++;
		if (S[i] == 'B') a++;
	}
 
	int w = e * r * a;
 
	for (int j = 1; j<= N; j++) {
		for (int m = j; m < N; m++) {
			if (m - j < 0 || m + j >= N) continue;
			if ((S[m - j] != S[m + j]) && (S[m] != S[m + j]) && S[m - j] != S[m]) w--;
		}
	}
	cout << w << endl;
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:20: error: expected unqualified-id before 'int'
    7 |         int e = 0, int r = 0, int a = 0;
      |                    ^~~
a.cc:10:34: error: 'r' was not declared in this scope
   10 |                 if (S[i] == 'G') r++;
      |                                  ^
a.cc:11:34: error: 'a' was not declared in this scope
   11 |                 if (S[i] == 'B') a++;
      |                                  ^
a.cc:14:21: error: 'r' was not declared in this scope
   14 |         int w = e * r * a;
      |                     ^
a.cc:14:25: error: 'a' was not declared in this scope
   14 |         int w = e * r * a;
      |                         ^
Language: C++

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

 
int main() {
	int N;
	string S;
	cin >> N >> S;
 
	int e = 0, int d = 0, int a = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') e++;
		if (S[i] == 'G') d++;
		if (S[i] == 'B') a++;
	}
 
	int  ans = e * d * a;
 
	for (int j = 1; j<= N; j++) {
		for (int m = j; m < N; m++) {
			if (m - j < 0 || m + j >= N) continue;
			if ((S[m - j] != S[m + j]) && (S[m] != S[m + j]) && S[m - j] != S[m]) ans--;
		}
	}
	cout << ans << endl;
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: expected unqualified-id before 'int'
   10 |         int e = 0, int d = 0, int a = 0;
      |                    ^~~
a.cc:13:34: error: 'd' was not declared in this scope
   13 |                 if (S[i] == 'G') d++;
      |                                  ^
a.cc:14:34: error: 'a' was not declared in this scope
   14 |                 if (S[i] == 'B') a++;
      |                                  ^
a.cc:17:24: error: 'd' was not declared in this scope
   17 |         int  ans = e * d * a;
      |                        ^
a.cc:17:28: error: 'a' was not declared in this scope
   17 |         int  ans = e * d * a;
      |                            ^
Language: C

n = int(input())
s = list(input())
counter = 0
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    for k in range(j + 1, n):
      if ((j - i) != (k - j)):
        if (s[i] != s[j]) & (s[j] != s[k]) & (s[k] != s[i]):
          counter += 1
print(counter)

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

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

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

  // Count OKs
  int Rs = 0;
  int Gs = 0;
  int Bs = 0;
  for (int i = 0; i < N; i++) {
    if(S[i]=='R') Rs++;
    if(S[i]=='G') Gs++;
    if(S[i]=='B') Bs++;
  }

  // Count NGs
  int ngCount = 0;
  for (int i = 0; i < N-1; i++) {
    char first = S[i];
    for (int j = i+1; j < N; j++) {
      char second = S[j];
      int distance = j - i;
      if (first != second && j+distance < N){
        char third = S[j+distance];
        if(third != first && third != second){
          ngCount++;
        }
      }
    }
  }
    
  long answer = Rs*Gs*Bs - ngCount;
  
    cout << answer << 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 <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    string s;
    cin >> s;
    long long r = 0, g = 0, b = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            r ++;
        }else if(s[i] == 'G'){
            g ++;
        }else{
            b++;
        }
    }
    long long ans = r * g * b;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if((j-i)%2 == 0){
                int ave = (i+j)/2;
                if((s[i] != s[j] && s[i] != s[ave]) && s[j] != s[ave]){
                    ans --;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}





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

#include <iostream>
using namespace std;
using ll = long long;

int main() {
	int n; cin>>n;
  	string str; cin>>str;
  	
  	ll r = 0; ll g = 0; ll b = 0;
  	for (int i=0;i<n;i++) {
    	if (str[i]=='R') {
        	r++;
        } else if (str[i]=='G') {
        	g++;
        } else {
        	b++;
        }
    }
//  	cout << "R: " << r << " G: " << g << " B: " << b << endl;
  	ll totalNumOfCase=r*g*b;
//  	cout << "total num of case: " << totalNumOfCase << endl;
	ll totalNumOfInvalidCase=0;
	for (int i=0; i<n-2;i++) {
      	for (int j = 1; i+2*j < n; j++) {
//	      	cout << "i: " << i << endl;
//          	cout << "i+j: " << (i+j) << endl;
//          	cout << "i+j*2: " << i+j*2 << endl;
//          	if (k > n-1) { break; }
//	    	cout << "i: " << i << endl;
//        	cout << "j: " << j << endl;
//          	cout << "k: " << j+(j-i) << endl;
//          	cout << "***********" << endl;
//          	cout << "j+1: " << j+1 << endl;
          	if (str[i]!=str[j]&&str[i]!=str[k]&&str[j]!=str[k]) {
            	totalNumOfInvalidCase++;
            }
        }
//	    cout << "--------" << endl;
    }  	
    ll ans = totalNumOfCase-totalNumOfInvalidCase;
    cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:49: error: 'k' was not declared in this scope
   34 |                 if (str[i]!=str[j]&&str[i]!=str[k]&&str[j]!=str[k]) {
      |                                                 ^
Language: C

#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii unordered_map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=4e18;
  const int N=2e5+25;
  const int M=1e6;

 void doit()
 { 
   int n; cin>>n; string s; cin>>s; vi v;
   tr(i,s){
     if(i=='R') v.pb(0);
     else if(i=='G') v.pb(1);
     else v.pb(2); 
   }

   vi ct[3]; rep(i,0,3) ct[i].resize(n+1);

   for(int i=n-1;i>=0;--i){
      rep(j,0,3) ct[j][i]=ct[j][i+1];
      ct[v[i]][i]++;
   }

   int ans=0;

   for(int i=0;i<n;++i){
                             
      for(int j=i+1;j<n;++j){
          if(v[j]==v[i]) continue;
        int id;
        if(v[i]+v[j]==1) id=2;
        else if(v[i]+v[j]==2) id=1;
        else id=0;
        ans+=ct[id][j+1];
        if(j+j-i<n&&v[j+j-i]==id) ans--;
      }
   }

   cout<<ans;
                                
 }

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

 

   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }

 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<iostream>
#include<vector>
using namespace std;

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  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]){
        for(int k=j+1;k<N;k++){
          if(j-i!=k-j){
            if(S[i]!=S[k] && S[j]!=S[k]){
              c = c+1;
              //cout<<i<<" "<<j<<" "<<k<<" = "<<S[i]<<" "<<S[j]<<" "<<S[k]<<endl;
            }
          }
        }
      }
    }
  }
  cout<<c<<endl;

}

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

#include<bits/stdc++.h>
#define fr first
#define se second
#define pb push_back
#define ll long long
#define TIME ios_base::sync_with_stdio(0);
using namespace std;
ll cnt, a , b , c , n , m , mx ,d , sum , temp , mx1;
const ll N = 1e4;
string s;
int main(){
    cin >> n >> s;
    for( int i = 0;i < n;i ++ ){
        if( s[i] == 'R' )
            a ++;
        if( s[i] == 'G' )
            b ++;
        if( s[i] == 'B' )
            c ++;
    }
    cnt = a * b * c;
    for( int i = 0;i < n;i ++ ){
        for( int j = 0;j * 2 + i < n;j ++ ){
            if( s[i] == 'R' and s[i + j] == 'G' and s[i + j * 2] == 'B' )
                cnt --;
            else if( s[i] == 'R' and s[i + j] == 'B' and s[i + j * 2] == 'G' )
                cnt --;
            else if(s[i] == 'B' and s[i + j] == 'R' and s[i + j * 2] == 'G' )
                cnt --;
            else if( s[i] == 'B' and s[i + j] == 'G' and s[i + j * 2] == 'R' )
                cnt --;
            else if( s[i] == 'G' and s[i + j] == 'B' and s[i + j * 2] == 'R' )
                cnt --;
            else if( s[i] == 'G' and s[i + j] == 'R' and s[i + j * 2] == 'B' )
                cnt --;
        }
    }
    cout << cnt;
}


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;

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    for (size_t i = 0; i < n; i++)
    {
        if(s[i]=='R')r.push_back(i);
        if(s[i]=='G')g.push_back(i);
        if(s[i]=='B')b.push_back(i);
    }
    ll ans = sz(r) * sz(g) * sz(b);
    ll sub = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j+2*i<= n-1; j++)
        {
            if (s[j] != s[j + i] && s[j + i] != s[j + 2 * i] && s[j] != s[j + 2 * i])
            {
                sub++;
            }
            
        }
        
    }
    cout << ans-sub << 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;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x));
#define SORT(x) sort(ALL(x));
#define SUM(x) accumulate(ALL(A), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll N;
	ll result=0;
	string S;
	cin>>N;
	cin>>S;
	REP(k,N){
		REP(j,k){
			if(S[j]==S[k])
				continue;
			REP(i,j){
				if(S[i]==S[j]) continue;
				if(S[i]==S[k]) continue;
				if(j-i==k-j) continue;
				result++;
			}
		}
	}
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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;
  cin >> n;
  vector<char> vec(n);
  rep(i,n){
    char c;
    cin >> c;
    vec[i]=c;
  }
  int64_t count=0;
  rep(i,n){
    rep(j,n){
      rep(k,n){
        if(vec[i]!=vec[j]||vec[i]!=vec[k]||vec[j]!=vec[k]||i-j!=j-k||i-k!=k-j)
      }
    }
  }
  cout << count << endl;
}
        


Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: expected primary-expression before '}' token
   19 |       }
      |       ^
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;
  cin >> n;
  vector<char> vec(n);
  rep(i,n){
    char c;
    cin >> c;
    vec[i]=c;
  }
  int64_t count=0;
  rep(i,n){
    rep(j,n){
      rep(k,n){
        if(vec[i]!=vec[j]||vec[i]!=vec[k]||vec[j]!=vec[k]||i-j!=j-k||i-k!=k-j)
      }
    }
  }
  cout << count << 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<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;string s;
  cin>>n>>s;
  ll a=0,b=0,c=0;
  ll sum1,sum2=0;
  rep(i,n){
    if(s[i]=='R')
      a++;
    else if(s[i]=='G')
      b++;
    else
      c++;
  }
  sum1=a*b*c;
  rep(i,n){
    for(j=i+1;j<n;j++){
      if(s[i]==s[j]) continue;
      int k=2*j-i;
      if(s[i]==s[k]||s[j]==s[k]||k>=n)
        sum2++;
    }
  }
  cout<<sum1-sum2<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: 'j' was not declared in this scope
   30 |     for(j=i+1;j<n;j++){
      |         ^
Language: C

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;string s;
  cin>>n>>s;
  ll a=0,b=0,c=0;
  ll sum1,sum2=0;
  rep(i,n){
    if(s[i]=='R')
      a++;
    else if(s[i]=='G')
      b++;
    else
      c++;
  }
  sum1=a*b*c;
  rep(i,n){
    for(j=i+1;j<n;j++){
      if(s[i]==s[j]) continue;
      int k=2*j-i;
      if(s[i]==s[k]||s[j]==s[k]||k>=n)
        sum2++;
    }
  }
  cout<<sum1-sum2<<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(){
  long long N;
  long long countR=0,countG=0,countB=0;
  cin >> N;
  string S;
  cin >> S;
  for(long long i=0;i<N;i++){
    if(S[i]=='R'){
      countR++;
    }
    else if(S[i]=='G'){
      countG++;
    }
    else{
      countB++;
    }
  }
  long long ans = countR * countG * countB;
  for(long long i=0;i<N-2;i++){
    for(long long k=1; i+2*k<N; k++){
      if(S[i]!=S[i+k] && S[i+k]!=S[i+2*k] && S[i+2*k]!=S[i]){
        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<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

vector<int>pos[3];
set<int>t[3];

int main(void){
    int n;
    string s;
    cin>>n>>s;
    map<char,int>m;
    map<int,char>mi;
    m['R']=0;
    m['G']=1;
    m['B']=2;
    mi[0]='R';
    mi[1]='G';
    mi[2]='B';
    ll ans = 0;
    for(int i=0;i<n;i++){
        pos[m[s[i]]].push_back(i);
        t[m[s[i]]].insert(i);
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(i==j)continue;
            if(s[i]==s[j])continue;
            int index=0;
            for(int k=0;k<3;k++){
                if(s[i]==mi[k])continue;
                if(s[j]==mi[k])continue;
                index=k;
                break;
            }
            auto itr = upper_bound(pos[index].begin(),pos[index].end(),j);
            if(itr==pos[index].end())continue;
            int d=j-i;
            int siz = pos[index].size();
            int index2=itr-pos[index].begin();
            //cout<<i<<" "<<j<<" "<<index2<<endl;
            ans+=(siz-index2);
            if(t[index].count(j+d)==1)ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

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

    ll less = 0;
    for(int left=0;left<n;++left){
        for(int right=left+2;right<n;right += 2){
            int mid = (left + right) / 2;
            if(s[right]!=s[mid] && s[mid]!=s[left] && s[right]!=s[left]){
                ++less;
            }
        }
    }
    cout << r*g*b - less << 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 rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> sumr(n + 1);
	vector<int> sumg(n + 1);
	vector<int> sumb(n + 1);
	rep(i, n) {
		if (s[i] == 'R') sumr[i]++;
		if (s[i] == 'G') sumg[i]++;
		if (s[i] == 'B') sumb[i]++;
		sumr[i + 1] += sumr[i];
		sumg[i + 1] += sumg[i];
		sumb[i + 1] += sumb[i];
	}
	int ans = 0;
	rep(i, n - 1) {
		for (int j = i + 1; j < n; ++j) {
			if (s[i] == 'R' && s[j] == 'G') {
				int tmp = sumb[n] - sumb[j];
				ans += tmp;
				if (2 * j - i > n) continue;
				if (s[2 * j - i] == 'B') ans--;
			}
			if (s[i] == 'G' && s[j] == 'R') {
				int tmp = sumb[n] - sumb[j];
				ans += tmp;
				if (2 * j - i > n) continue;
				if (s[2 * j - i] == 'B') ans--;
			}
			if (s[i] == 'R' && s[j] == 'B') {
				int tmp = sumg[n] - sumg[j];
				ans += tmp;
				if (2 * j - i > n) continue;
				if (s[2 * j - i] == 'G') ans--;
			}
			if (s[i] == 'B' && s[j] == 'R') {
				int tmp = sumg[n] - sumg[j];
				ans += tmp;
				if (2 * j - i > n) continue;
				if (s[2 * j - i] == 'G') ans--;
			}
			if (s[i] == 'G' && s[j] == 'B') {
				int tmp = sumr[n] - sumr[j];
				ans += tmp;
				if (2 * j - i > n) continue;
				if (s[2 * j - i] == 'R') ans--;
			}
			if (s[i] == 'B' && s[j] == 'G') {
				int tmp = sumr[n] - sumr[j];
				ans += tmp;
				if (2 * j - i > n) continue;
				if (s[2 * j - i] == '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


def checkRGB(a,b,c):
    if a == b or b == c or c == a:
        return 0
    else:
        return 1

N = int(input())
S = input()

if N<4:
    print(0)
    exit()
sum1 = S.count("R")*S.count("G")*S.count("B")
sum2 = 0
for i in range(0,N-2):
    left = S[i]
    for j in range(i+1,(N+i)//2+(N+i)%2):
        center = S[j]
        right = S[2*j-i]
        if checkRGB(left,center,right):
            sum2 += 1
print(sum1-sum2)


Compiler output:
main.c:2:1: error: unknown type name 'def'
    2 | def checkRGB(a,b,c):
      | ^~~
main.c: In function 'checkRGB':
main.c:2:20: error: expected declaration specifiers before ':' token
    2 | def checkRGB(a,b,c):
      |                    ^
main.c:2:5: error: type of 'a' defaults to 'int' [-Wimplicit-int]
    2 | def checkRGB(a,b,c):
      |     ^~~~~~~~
main.c:2:5: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:2:5: error: type of 'c' defaults to 'int' [-Wimplicit-int]
Language: C

#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  string s;
  cin >> n >> s;
  vector<int>r(n+1);
  vector<int>g(n+1);
  vector<int>b(n+1);
  r[0]=g[0]=b[0]=0;
  
  rep(i,n){
    if(s[i]=='R'){
      r[i+1]=r[i]+1;
      g[i+1]=g[i];
      b[i+1]=b[i];
    }
    if(s[i]=='G'){
      r[i+1]=r[i];
      g[i+1]=g[i]+1;
      b[i+1]=b[i];
    }
    if(s[i]=='B'){
      r[i+1]=r[i];
      g[i+1]=g[i];
      b[i+1]=b[i]+1;
    }
  }
  ll ans=0;
  rep(i,n-2){
    for(int k=i+2;k<n;k++){
      if((i+k)%2==0 && s[i]!=s[(i+k)/2] && s[(i+k)/2]!=s[k] && s[k]!=s[i])ans--;
        if(s[i]=='R' && s[k]=='G'){
          ans+=b[k]-b[i+1];
        }
        if(s[i]=='G' && s[k]=='B'){
          ans+=r[k]-r[i+1];
        }
        if(s[i]=='B' && s[k]=='R'){
          ans+=g[k]-g[i+1];
        }
        if(s[i]=='R' && s[k]=='B'){
          ans+=g[k]-g[i];
        }
        if(s[i]=='G' && s[k]=='R'){
          ans+=b[k]-b[i+1];
        }
        if(s[i]=='B' && s[k]=='G'){
          ans+=r[k]-r[i+1];
        }
      
    }
  }
  cout << ans << endl;
}


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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  int N;
  cin >> N;
  vector<ll> R, G, B;
  rep(i,N){
    char a;
    cin >> a;
    if(a == 'R') R.push_back(i+1);
    if(a == 'G') G.push_back(i+1);
    if(a == 'B') B.push_back(i+1);
  }
  ll ans = R.size() * G.size() * B.size();
  for(ll i:R){
    for(ll j:G){
      ll a = 0, b = 0, c = 0;
      ll s = 2*i-j, t = 2*j-i;
      if((i+j)%2 == 0){
        a = (i+j)/2;
      }
      if(s <= N){
        b = s;
      }
      if(t <= N){
        c = t;
      }
      for(ll k:B){
        if(a == k || b == k || c == k){
          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

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

void solve()
{
  int n;
  string s;
  cin >> n >> s;
  ll cnt[3] = {};
  rep(i, n)
  {
    cnt[s[i] % 3]++;
  }

  ll ans = 1;
  rep(i, 3) ans *= cnt[i];
  rep(i, n) REP(j, i + 1, n)
  {
    int k = j + (j - i);
    if (k >= n)
      continue;
    if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i])
      ans--;
  }
  cout << ans << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  solve();
  return 0;
}


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;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    ll n;
    string s;
    cin >> n >> s;

    ll r = 0, g = 0, b = 0;
    for(auto &&i : s) {
        if(i == 'R')
            r++;
        else if(i == 'G')
            g++;
        else
            b++;
    }
    ll all = r * g * b;

    ll cnt = 0;

    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            if(s[i] == s[j])
                continue;
            ll k = 2 * j - i;
            if(k >= n || s[k] == s[i] || s[k] == s[j])
                continue;
            ++cnt;
        }
    }
    cout << all - 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
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N;string S;cin>>N>>S;
    ll cr=0,cg=0,cb=0;
    REP(i,N){
        (S[i]=='R'?cr:S[i]=='G'?cg:cb)++;
    }
    //cout<<cr<<" "<<cg<<" "<<cb<<"\n";
    ll cnt=cr*cg*cb;
    
    for(ll i=0;i<N-2;i++){
        for(ll k=1;i+2*k<N;k++)
        if((S[i]!=S[i+k] and S[i+k]!=S[i+2*k] and S[i]!=S[i+2*k]))cnt--;
    }
    cout<<cnt<<"\n";
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    string S;
    cin>>N>>S;
    ll r=0, g=0, b=0;
    rep(i, N){
        if(S[i]=='R') r++;
        else if(S[i]=='G') g++;
        else if(S[i]=='B') b++;
    }
    ll count=r*g*b;
    rep(i, N) rep1(d, (N-1-i)/2){
        //cout<<count<<endl;;
        if(S[i]!=S[i+d] && S[i+d]!=S[i+2*d] && S[i]!=S[i+2*d]) count--;
    }
    cout<<count<<endl;
    return 0;
}


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