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

// atcoder/abc162/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  str s;
  while (cin >> n >> s) {
    vec<int> r, g, b;
    for (int i = 0; i < s.size(); ++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);
    }

    lli z = 0;
    const int sum = (int)'R' + (int)'G' + (int)'B';
    for (int i = 0; i < s.size(); ++i) {
      for (int j = i + 1; j < s.size(); ++j) {
        if (s[i] != s[j]) {
          const char c = sum - s[i] - s[j];
          if (c == 'R') {
            int x = r.end() - lower_bound(r.begin(), r.end(), j + 1);
            int y = binary_search(r.begin(), r.end(), j + abs(i - j));
            z += x - y;
          }
          if (c == 'G') {
            int x = g.end() - lower_bound(g.begin(), g.end(), j + 1);
            int y = binary_search(g.begin(), g.end(), j + abs(i - j));
            z += x - y;
          }
          if (c == 'B') {
            int x = b.end() - lower_bound(b.begin(), b.end(), j + 1);
            int y = binary_search(b.begin(), b.end(), j + abs(i - j));
            z += x - y;
          }
        }
      }
    }
    cout << z << endl;
  }

  return 0;
}


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

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

typedef long long ll;

ll check(vector<int> a, vector<int> b, vector<int> c){
    ll ans = 0;
    for(int i = 0; i < a.size(); i++){
        for(int j = 0; j < b.size(); j++){
            if(b[j] < a[i]){
                continue;
            }
            int target = b[j] + (b[j] - a[i]);
            auto itr = find(c.begin(), c.end(), target);
            if(itr != c.end()){
                ans++;
            }
        }
    }
    
    return ans;
}


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    cin >> N;
    string S ;
    cin >> S;

    vector<int> a;
    vector<int> b;
    vector<int> c;
    for(int i = 0; i < N; i++){
        if(S[i] == 'R' ) a.push_back(i+1);
        if(S[i] == 'G' ) b.push_back(i+1);
        if(S[i] == 'B' ) c.push_back(i+1);
    }
    ll ans = 0;
    ans = a.size() * b.size() * c.size();
    ans -= check(a,b,c);
    ans -= check(a,c,b);
    ans -= check(b,c,a);
    ans -= check(b,a,c);
    ans -= check(c,a,b);
    ans -= check(c,b,a);
    cout << ans << endl;
}


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

#include <bits/stdc++.h>
#define for0(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
  ll count=0;
  ll r=0,g=0,b=0;
  char RGB[4004];
	cin >> n;
  cin >>RGB;
  for(ll i=0 ; i< n ; ++i){
    if(RGB[i]=='R')r++;
    else if(RGB[i]=='G')g++;
    else if(RGB[i]=='B')b++;
  }
  count=r*g*b;
  for(ll i=0 ; i<n ; i++){
    for (ll j = i+1; j < n; j++) {
      k = 2*j-i ;
      if(RGB[i]!=RGB[j]){
          if(k<n && RGB[k]!=RGB[j] && RGB[i]!=RGB[k])count--;
      }
    }
  }
  cout<<count;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:7: error: 'k' was not declared in this scope
   29 |       k = 2*j-i ;
      |       ^
Language: C++

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

int main(){
  int N;
  cin >> N;
  string S;
  for(int i = 0; i < N; i++){
    char a;
    cin >> a;
    S += a;
  }
  int cnt_R, cnt_G, cnt_B;
  cnt_R = 0;
  cnt_G = 0;
  cnt_B = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'R') cnt_R++;
    if(S.at(i) == 'G') cnt_G++;
    if(S.at(i) == 'B') cnt_B++;
  }

  int t_ans = cnt_R * cnt_G * cnt_B;

  int cnt_num = 0;
  for(int j = 1; j < N; i++){
    for(int i = 0; i < j; i++){
      int k = 2 * j - i;
      if(k < N && S.at(i) != S.at(j) && S.at(i) != S.at(k) && S.at(j) != S.at(k)) cnt_num++;
    }
  }
  cout << t_ans - cnt_num << endl;
}


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

public class RGBTriples {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		char[] rgb = scan.next().toCharArray();
		scan.close();
		
		int numR = 0;
		int numG = 0;
		int numB = 0;
		for(char c : rgb) {
			switch(c) {
			case 'R' : numR++; break;
			case 'G' : numG++; break;
			case 'B' : numB++; break;
			}
		}

		long ans = numR*numG*numB;

		for(int d=1;d<=n;d++){
			for(int m=0;m<n;m++){
				if(m-d<0||m+d>=n) continue;
          
				if(rgb[m-d] != rgb[m+d] && rgb[m] != rgb[m+d] && rgb[m-d] != rgb[m]) ans--;
			}
		}
		
		System.out.println(ans);
	}
}

Compiler output:
Main.java:1: error: class RGBTriples is public, should be declared in a file named RGBTriples.java
public class RGBTriples {
       ^
Main.java:3: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class RGBTriples
Main.java:3: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		                   ^
  symbol:   class Scanner
  location: class RGBTriples
3 errors
Language: C

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		char[] rgb = scan.next().toCharArray();
		scan.close();
		
		int numR = 0;
		int numG = 0;
		int numB = 0;
		for(char c : rgb) {
			switch(c) {
			case 'R' : numR++; break;
			case 'G' : numG++; break;
			case 'B' : numB++; break;
			}
		}

		long ans = numR*numG*numB;

		for(int d=1;d<=n;d++){
			for(int m=0;m<n;m++){
				if(m-d<0||m+d>=n) continue;
          
				if(rgb[m-d]!=rgb[m+d]&&rgb[m]!=rgb[m+d]&&rgb[m-d]!=rgb[m]) 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 java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		char[] rgb = scan.next().toCharArray();
		scan.close();
		
		int numR = 0;
		int numG = 0;
		int numB = 0;
		for(char c : rgb) {
			switch(c) {
			case 'R' : numR++; break;
			case 'G' : numG++; break;
			case 'B' : numB++; break;
			}
		}

		long ans = numR*numG*numB;
		
		for(int d=1;d<=n;d++){
      for(int m=0;m<n;m++){
          if(m-d<0||m+d>=n) continue;
          
          if(rgb[m-d]!=rgb[m+d]&&rgb[m]!=rgb[m+d]&&rgb[m-d]!=rgb[m]) 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++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int count=0;
  for(int i=0;i<-2n;i++)
      for(int j=i+1;j<n-1;j++)
           for(int k=j+1;j<n;j++)
           {
              if(s[i]!=s[j] &&  s[i]!=s[k] && s[j]!=s[k] && ((j-i) != (k-j)))
                  count ++;
           }
    cout<<count<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: unable to find numeric literal operator 'operator""n'
   10 |   for(int i=0;i<-2n;i++)
      |                  ^~
Language: C

#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int N;
	string s;
	cin >> N >> s;
	vi arr(N);
	M00(i, N) {
		if(s[i] == 'R') arr[i] = 0;
		else if (s[i] == 'G') arr[i] = 1;
		else arr[i] = 2;
	}
	vi freq(3, 0);
	M00(i, N) freq[arr[i]]++;

	ll ans = 1;
	M00(i, 3) ans *= freq[i];

	M00(i, N) {
		for(int j = 1; i - j >= 0 && i + j < N; j++) {
			if(arr[i-j] != arr[i+j] && arr[i] != arr[i-j] && arr[i] != arr[i+j]) ans--;
		}
	}
	finish(ans);
}


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

/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  string str;
  cin >> str;
  long long count = 0;
  long long countR = 0;
  long long countG = 0;
  long long countB = 0;
  cout << N << endl;
  for (int i = 0; i < N; i++) {
    if (str.at(i) == 'R') {
      countR++;
    } else if (str.at(i) == 'G') {
      countG++;
    } else {
      countB++;
    }
  }
  for (int i = 0; i < N; i++) {
    if (str.at(i) == 'R') {
      for (int k = i + 1; k < N; k++) {
        if (str.at(k) == 'B' && 2 * k - i < N) {
          int l = 2 * k - i;
          if (str.at(l) == 'G') {
              count++;
          }
        }
      }
    }
  }
  cout << count << endl;
  for (int i = 0; i < N; i++) {
    if (str.at(i) == 'R') {
      for (int j = i + 1; j < N; j++) {
        if (str.at(j) == 'G' && 2 * j - i < N) {
          int k = 2 * j - i;
          if (str.at(k) == 'B') {
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;
  for (int i = 0; i < N; i++) {
    if (str.at(i) == 'G') {
      for (int j = i + 1; j < N; j++) {
        if (str.at(j) == 'R' && 2 * j - i < N) {
          int k = 2 * j - i;
          if (str.at(k) == 'B') {
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;
  for (int i = 0; i < N; i++) {
    if (str.at(i) == 'G') {
      for (int j = i + 1; j < N; j++) {
        if (str.at(j) == 'B' && 2 * j - i < N) {
          int k = 2 * j - i;
          if (str.at(k) == 'R') {
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;
  for (int i = 0; i < N; i++) {
    if (str.at(i) == 'B') {
      for (int j = i + 1; j < N; j++) {
        if (str.at(j) == 'R' && 2 * j - i < N) {
          int k = 2 * j - i;
          if (str.at(k) == 'G') {
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;
  for (int i = 0; i < N; i++) {
    if (str.at(i) == 'B') {
      for (int j = i + 1; j < N; j++) {
        if (str.at(j) == 'G' && 2 * j - i < N) {
          int k = 2 * j - i;
          if (str.at(k) == 'R') {
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;
  cout << countR * countB * countG - count << endl;
}

Compiler output:
a.cc:1:1: error: expected unqualified-id before '/' token
    1 | /stdc++.h>
      | ^
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >> N;
      |   ^~~
a.cc:7:3: error: 'string' was not declared in this scope
    7 |   string str;
      |   ^~~~~~
a.cc:8:10: error: 'str' was not declared in this scope; did you mean 'std'?
    8 |   cin >> str;
      |          ^~~
      |          std
a.cc:13:3: error: 'cout' was not declared in this scope; did you mean 'count'?
   13 |   cout << N << endl;
      |   ^~~~
      |   count
a.cc:13:16: error: 'endl' was not declared in this scope
   13 |   cout << N << endl;
      |                ^~~~
Language: C

#include <bits/stdc++.h>

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    cin >> n >> s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    for(int i = 0; i < n; i++) {
        if(s[i]=='R')      r.emplace_back(i);
        else if(s[i]=='G') g.emplace_back(i);
        else               b.emplace_back(i);
    }
    int rs=r.size();
    int gs=g.size();
    int bs=b.size();
    int ans=rs*bs*gs;
//    cout << rs << " " << bs << " " << gs << "\n";
    for(int w = 1; 2*w < n; w++) {
        for(int m = w; m+w <n ; m++) {
//        cout << m << " " << w << "\n";
            if(s[m]!=s[m-w]&&s[m]!=s[m+w]&&s[m-w]!=s[m+w]){
                ans--;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#include <bits/stdc++.h>
#include <math.h>
 
#define rep(i, n) for(int i = 0; (int)(i) < n; i++)
 
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  int r = 0;
  int g = 0;
  int b = 0;
  
  for(char c : S){
    if(c == 'R') r++;
    else if(c == 'G') g++;
    else b++;
  }
  long long all = r * g * b;
  int sub = 0;
  
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      if(S[i] == S[j]) continue;
      int k = j * 2 - i;
      if(k >= N || S[k] == S[i] || S[k] == S[j]) continue;
      sub++;
    }
  }
  cout << all - 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;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int r = 0, g = 0, b = 0;
  for (char c : S) c == 'R' ? r++ : c == 'G' ? g++ : b++;
  ans = r * g * b;
  for (int i = 0; i < N; i++) {
    for (int j = 1; i + j + j < N; j++) {
      if (S.at(i) ^ S.at(i + j) ^ S.at(i + j + j) == 87) ans--;
    }
  }
  cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   10 |   ans = r * g * b;
      |   ^~~
      |   abs
Language: C

#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;



main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin>>n;
string t;
cin>>t;
vector<ll> s[3];
for(ll i=0;i<t.size();i++)
{
	if(t[i]=='R')
	s[0].push_back(i);
	if(t[i]=='G')
	s[1].push_back(i);
	if(t[i]=='B')
	s[2].push_back(i);
}
ll ans=0;
for(ll i=0;i<n;i++)
{
	for(ll j=i+1;j<n;j++)
	{
		if((t[i]=='R' && t[j]=='G')||((t[i]=='G' && t[j]=='R')))
		{
		//	cout<<"shub";
			ans+=s[2].end()-lower_bound(s[2].begin(),s[2].end(),j);
			if(find(s[2].begin(),s[2].end(),2*j-i)!=s[2].end())
			ans--;
		}
			if((t[i]=='R' && t[j]=='B')||((t[i]=='B' && t[j]=='R')))
		{
			ans+=s[1].end()-lower_bound(s[1].begin(),s[1].end(),j);
			if(find(s[1].begin(),s[1].end(),2*j-i)!=s[1].end())
			ans--;
			
		}
			if((t[i]=='B' && t[j]=='G')||((t[i]=='G' && t[j]=='B')))
		{
			ans+=s[0].end()-lower_bound(s[0].begin(),s[0].end(),j);
			if(find(s[0].begin(),s[0].end(),2*j-i)!=s[0].end())
			ans--;
		}
		
	}
}
cout<<ans;
}

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

#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

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

  map<char, vector<int> > counts;
  vector<char> colors = {'R', 'G', 'B'};
  for (auto color : colors) {
    counts[color].resize(N);
  }

  // init (i = N - 1)
  for (auto color : colors) {
    counts[color][N - 1] = 0;
  }
  counts[S[N - 1]][N - 1]++;

  // iterate
  for (int i = N - 2; i >= 0; --i) {
    for (auto color : colors) {
      counts[color][i] = counts[color][i + 1];
    }
    counts[S[i]][i]++;
  }
  
  ll ans = 0;
  for (int i = 0; i < N - 2; ++i) {
    for (int j = i + 1; j < N - 1; ++j) {
      if (S[i] != S[j]) {
	char color;
	if (S[i] != 'R' and S[j] != 'R') {
	  color = 'R';
	} else if (S[i] != 'G' and S[j] != 'G') {
	  color = 'G';
	} else {
	  color = 'B';
	}
	ans += counts[color][j + 1];
	int k = j + (j - i);
	if (k < N and S[k] == color) {
	  --ans;
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  int n; cin >> n;
  string s; cin >> s;
  ll r=0;
  ll g=0;
  ll b=0;
  rep(i, n){
    if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else b++;
  }
  ll mu = r*g*b;
  int a, b, c;
  for(int i=0; i<n; i++){
    for(int j=1; i+j*2<n; j++){
      a = i;
      b = i+j;
      c = i+j*2;
      if(s[a]!=s[b] && s[a]!=s[c] && s[b]!=s[c]) mu--;
    }
  }
  cout << mu << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: conflicting declaration 'int b'
   19 |   int a, b, c;
      |          ^
a.cc:12:6: note: previous declaration as 'll b'
   12 |   ll b=0;
      |      ^
Language: C++

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int R = 0; int G = 0; int B = 0;
    for (int i = 0; i < n; i++) {
		if (S[i] == 'R') R++;
		else if (S[i] == 'G') G++;
		else B++;
	}

    long long int count = R*G*B;
    for(int i = 0; i < N-2; i++) {
        for(int j = i+1; j < N-1; j++) {
            int k = 2*j - i;
            if(k < N && S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) {
                count--;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:25: error: 'n' was not declared in this scope
   10 |     for (int i = 0; i < n; i++) {
      |                         ^
Language: Java

import java.util.*;
import java.io.*;
 
public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      int N = Integer.parseInt(br.readLine());
      String S = br.readLine();
      long r = 0, g = 0, b = 0;
      for(int i = 0; i < N; i++){
        char c = S.charAt(i);
        if(c == 'R'){
          r++;
        }else if(c == 'G'){
          g++;
        }else{
          b++;
        }
      }
      
      long ans = r * g * b;
      for(int i = 0; i < N; i++){
        char c1 = S.charAt(i);
        for(int j = i+1; j < N; j++){
          if(j+(j-i) >= N) break;
          char c2 = S.charAt(j);
          char c3 = S.charAt(j+(j-i));
          if(c1 != c2 && c2 != c3 && c1 != c3){
            ans--;
          }
        }
      }
      System.out.println(ans);
    }catch(Exception e){
      System.out.println(e.toString());
    }
  }
}
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      int N = Integer.parseInt(br.readLine());
      String S = br.readLine();
      long r = 0, g = 0, b = 0;
      for(int i = 0; i < N; i++){
        char c = S.charAt(i);
        if(c == 'R'){
          r++;
        }else if(c == 'G'){
          g++;
        }else{
          b++;
        }
      }
      
      long ans = r * g * b;
      for(int i = 0; i < N; i++){
        char c1 = S.charAt(i);
        for(int j = i+1; j < N; j++){
          if(j+(j-i) >= N) break;
          char c2 = S.charAt(j);
          char c3 = S.charAt(j+(j-i));
          if(c1 != c2 && c2 != c3 && c1 != c3){
            ans--;
          }
        }
      }
      System.out.println(ans);
    }catch(Exception e){
      System.out.println(e.toString());
    }
  }

Compiler output:
Main.java:40: error: class, interface, enum, or record expected
import java.util.*;
^
Main.java:41: error: class, interface, enum, or record expected
import java.io.*;
^
Main.java:77: error: reached end of file while parsing
  }
   ^
3 errors
Language: C

//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
int foo(string s,char ch1,char ch2,char ch3){
	int ans = 0;
	vector<int> suf(n);
	if(s[n-1] == ch3){
		suf[n-1] = 1;
	}
	for(int i=n-2;i>=0;i--){
		if(s[i] == ch3){
			suf[i] = 1;
		}
		suf[i] += suf[i+1];
	}
	for(int i=0;i<n;i++){
		if(s[i] == ch1){
			for(int j=i+1;j<n;j++){
				if(s[j] == ch2){
					ans += suf[j];
					if((2*j - i) < n){
						if(s[2*j - i] == ch3) ans--;
					}
				}
			}
		}
	}
	return ans;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	string s;
	cin >> s;
	vector<char> ch;
	ch.push_back('B');
	ch.push_back('G');
	ch.push_back('R');
	int ans = 0;
	do{
		ans += foo(s,ch[0],ch[1],ch[2]);
	}while(next_permutation(all(ch)));
	cout<<ans;
}
//.........

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

// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

vector<int> dpr(4005,0), dpg(4005,0), dpb(4005,0);
ll ans = 0;
void solve()
{
    int n; cin>>n;
    string s; cin>>s;
    rep(i,1,n+1)
    {
        dpr[i] = dpr[i-1] + (s[i-1] == 'R');
        dpg[i] = dpg[i-1] + (s[i-1] == 'G');
        dpb[i] = dpb[i-1] + (s[i-1] == 'B');
    }

    rep(i,1,n-1)
    {
        rep(j,i+2,n+1)
        {
            char x = s[i-1], y = s[j-1];
            if(x<y) swap(x,y);
            if(x == 'R' and y == 'G')
            {
                ans+=(dpb[j-1]-dpb[i] - ((j-i)%2 == 0 and s[(i+j)/2 - 1] == 'B'));
            }
            if(x == 'R' and y == 'B')
            {
                ans+=(dpg[j-1]-dpg[i] - ((j-i)%2 == 0 and s[(i+j)/2 - 1] == 'G'));
            }
            if(x == 'G' and y == 'B')
            {
                ans+=(dpr[j-1]-dpr[i] - ((j-i)%2 == 0 and s[(i+j)/2 - 1] == 'R'));
            }
        }
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    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;
    cin >> N;
    string S;
    cin >> S;
    int R = 0; int G = 0; int B = 0;
    R = count(S.begin(), S.end(), 'R');
    G = count(S.begin(), S.end(), 'G');
    B = count(S.begin(), S.end(), 'B');
    long long int count = R*G*B;
    for(int i = 0; i < N-2; i++) {
        for(int j = i+1; j < N-1; j++) {
            int k = 2*j - i;
            if(k < N && S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) {
                count--;
            }
        }
    }
    cout << count << endl;
    return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;


int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    string str;
    cin >> n >> str;

    int cntB = 0, cntR = 0, cntG = 0;
    for (char c : str) {
        cntB += (c == 'B');
        cntR += (c == 'R');
        cntG += (c == 'G');
    }

    ll ans = 1LL * cntB * cntR * cntG;
    loop(i, n) {
        range(j, i + 1, n - 1) {
            if (str[i] == str[j])continue;
            int len = j - i;
            int k = j + len;
            if (k < n && str[k] != str[i] && str[k] != str[j]) {
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

import collections

n = int(input())
strs = list(input())

index_s = collections.defaultdict(list)

for s in strs:
    index = strs.index(s)
    index_s[s].append(strs.index(s))
    strs[index] = "0"

# print(index_s)


r = index_s["R"]
b = index_s["B"]
g = index_s["G"]

sum = 0

for i in r:
    for j in b:
        for k in g:
            arr = sorted([i,j,k])
            if( arr[1]-arr[0]!=arr[2]-arr[1]):
                sum+=1
                

print(sum)

Compiler output:
a.cc:13:3: error: invalid preprocessing directive #print
   13 | # print(index_s)
      |   ^~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import collections
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>
using namespace std;

int rgb(string inp) {
    const int len = inp.length();
    int* r_count = new int[len + 1];
    int* g_count = new int[len + 1];
    int* b_count = new int[len + 1];
    int* arrToUse = NULL;

    r_count[len] = 0;
    g_count[len] = 0;
    b_count[len] = 0;

    for (int i = inp.length() - 1; i >= 0; i--) {
        r_count[i] = r_count[i + 1];
        g_count[i] = g_count[i + 1];
        b_count[i] = b_count[i + 1];

        if (inp[i] == 'R') r_count[i]++;
        if (inp[i] == 'G') g_count[i]++;
        if (inp[i] == 'B') b_count[i]++;
    }
    int ret = 0;
    
    for (int i = 0; i < inp.length() - 2; i++) {
        for (int j = i + 1; j < inp.length() - 1; j++) {
            if (inp[j] != inp[i]) {
                char third = getThird(inp[i], inp[j]);
                if (third == 'R') arrToUse = r_count;
                else if (third == 'G') arrToUse = g_count;
                else arrToUse = b_count;
                
                int val = arrToUse[j + 1];
                if (val > 0 && (j + (j - i) < inp.length()) && inp[j + (j - i)] == third) {
                    val--;
                }
                ret += val;
            }
        }
    }

    arrToUse = NULL;

    delete[] r_count;
    delete[] g_count;
    delete[] b_count;

    return ret;
}

int main() {
  int n;
  string inp;
  cin >> n;
  cin >> inp;
  cout << rgb(inp) << endl;
}

Compiler output:
a.cc: In function 'int rgb(std::string)':
a.cc:29:30: error: 'getThird' was not declared in this scope; did you mean 'third'?
   29 |                 char third = getThird(inp[i], inp[j]);
      |                              ^~~~~~~~
      |                              third
Language: C

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

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

  int n;
  string s;
  cin >> n >> s;
  vector<int> cnt(3);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') cnt[0]++;
    else if (s[i] == 'G') cnt[1]++;
    else if (s[i] == 'B') cnt[2]++;
  }
  int res = 0;
  res += cnt[0] * cnt[1] * cnt[2];
  for (int i = 0; i < n - 2; i ++) {
    for (int j = i + 1; 2 * j - i < n; j++) {
      int k = 2 * j - i;
      res -= s[i] != s[j] && s[j] != s[k] && s[k] != s[i];
    }
  }
  cout << res << '\n';
  return 0;
}

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

import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long r=0,g=0,b=0;
		String text = sc.next();
		char str[] = text.toCharArray();
		for(int i=0;i<n;i++){
			switch(str[i]){
				case 'R':
					r++;
					break;
				case 'G':
					g++;
					break;
				case 'B':
					b++;
					break;
			}
		}
		int pair = r*g*b;
		for(int i=1;i<n;i++){
			for(int j=0;j<i;j++){
				if(i+(i-j)<n){
					if(str[i]!=str[j]&&str[i]!=str[i+(i-j)]&&str[j]!=str[i+(i-j)])
					pair--;
				}
			}
		}
		System.out.println(pair);
	}
}


Compiler output:
Main.java:23: error: incompatible types: possible lossy conversion from long to int
		int pair = r*g*b;
		              ^
1 error
Language: C

#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
string str;
cin>>str;
int dp[n+1][3]={};
if(str[0]=='R')
{
    dp[0][0]=1;
}
else if(str[0]=='B')
{
    dp[0][1]=1;
}
else
    dp[0][2]=1;
for(int i=1;i<n;i++)
{
    if(str[i]=='R')
{
    dp[i][0]=1;

}
else if(str[i]=='B')
{
    dp[i][1]=1;
}
else
    dp[i][2]=1;

    dp[i][0]+=dp[i-1][0];
    dp[i][1]+=dp[i-1][1];
    dp[i][2]+=dp[i-1][2];
}

int ans=0;

/// r b g
for(int i=0;i<n;i++)
{
    for(int j=i+1;j<n-1;j++)
    {
        if(str[i]!=str[j])
        {
            int k=j-i;
           j+=k;
           if(str[i]=='R')
           {
               if(str[j]=='B')
               {
                   ans+=dp[n-1][2]-dp[j][2];
                   if(k<n&&str[k]=='G')
                   {
                       ans-=1;
                   }
               }
               else
               {
                   ans+=dp[n-1][1]-dp[j][1];
                    if(k<n&&str[k]=='B')
                   {
                       ans-=1;
                   }
               }
           }
           else if(str[i]=='B')
           {
               if(str[j]=='R')
               {
                   ans+=dp[n-1][2]-dp[j][2];
                   if(k<n&&str[k]=='G')
                   {
                       ans-=1;
                   }
               }
               else
               {
                    ans+=dp[n-1][0]-dp[j][0];
                     if(k<n&&str[k]=='R')
                   {
                       ans-=1;
                   }
               }
           }
           else
           {
               if(str[j]=='R')
               {
                   ans+=dp[n-1][1]-dp[j][1];
                    if(k<n&&str[k]=='B')
                   {
                       ans-=1;
                   }
               }
               else
               {
                ans+=dp[n-1][0]-dp[j][0];
                if(k<n&&str[k]=='R')
                   {
                       ans-=1;
                   }
               }
           }


        }
    }
}

cout<<ans<<endl;














    return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
const int INF = 1e9;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int r_cnt,g_cnt,b_cnt;
    r_cnt = count(s.cbegin(), s.cend(), 'R');
    g_cnt = count(s.cbegin(), s.cend(), 'G');
    b_cnt = count(s.cbegin(), s.cend(), 'B');
    
    int ans = r_cnt*g_cnt*b_cnt;
    for(int i=0;i<n;i++){
        for(int d=0;d<n;d++){
            int j = i + d;
            int k = j + d;
            if(k >= n) break;
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans -= 1;
        }
    }
    cout << ans << endl;
}

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

#include <bits/stdc++.h>
#include<iostream>
#include <vector>
using namespace std;
int main() {
    int N; string S;
    cin >> N >> S;
    int64_t r, g, b;
    for (auto c : S) {
        if (c == 'R') {
            r++;
        } else if (c == 'G') {
            g++;
        } else {
            b++;
        }
    }

    int64_t all = r + g + b;
    int64_t sub = 0;
    for (int i=0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if(S[i] == S[j]) {
                continue;
            }

            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) {
                continue;
            }

            sub++;
        }
    }

    cout << all - sub << 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;
int main()
{
  int64_t N,i=0,j,k,r=0,g=0,b=0,count=0;
  string S;
  cin>>N>>S;
  for(char c:S){if(c=='R')r++;else if(c=='G')g++;else b++;}
  count=r*g*b;
  while(i<N)
  {
    j=1;k=2*j;
    while(i+k<N)
    {
      if((S.at(i)^S.at(i+j)^S.at(i+k))==87)count--;
      j++;k=2*j;
    }
    i++;
  }
  return cout<<count<<endl,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

/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0, g = 0, b = 0;
    for(char ch : s) {
        if(ch == 'R') ++r;
        else if(ch == 'G') ++g;
        else ++b;
    }
    long long ans = 1LL * r * g * b;
    for(int i = 0; i < n - 1; ++i) {
        for(int j = i + 1; 2 * j - i < n; ++j) {
            if(s[i] != s[j] && s[i] != s[2 * j - i] && s[j] != s[2 * j - i]) {
                --ans;
            }
        }
    }
    cout << ans << "\n";

    return 0;
}



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

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = Integer.parseInt(input.nextLine());
		String S = input.nextLine();
		System.out.println(SOLVE(N,S));
	}
	public static long SOLVE(int N, String S) {
		if (N<=3) return 0;
		long cnt = 0;
		for (int gap = 1; gap < N-3; gap++) {
			for (int start = 0; start < N-gap-1; start++) {
				int middle = start+gap;
				for (int end = middle+1; end<N; end++) {
					if (S.charAt(start)!=S.charAt(middle)&&S.charAt(start)!=S.charAt(end)
						&&S.charAt(end)!=S.charAt(middle)&&end!=(middle+gap)) {
						cnt++;
					}
				}
			}
		} 
		return cnt;
	}
}

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

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll factorial(ll a) {
	ll ans = 1;
	for (ll i = 1; i <= a; i++) {
		ans *= i;
	}
	return ans;
}

int main() {
	//答えは(条件Aを満たすもの)-(条件Bを満たさないが条件Aを満たすもの)である
	int n;
	string s;
	cin >> n >> s;
	ll times_R = 0;
	ll times_G = 0;
	ll times_B = 0;
	rep(i, n) {
		if (s[i] == 'R') {
			times_R++;
		}
		else if (s[i] == 'G') {
			times_G++;
		}
		else times_B++;
	}

	ll ans = times_R * times_G * times_B;

	//以下のループ内は条件Bを満たさないもの
	rep(start, n - 2) {
		for (int space = start + 1; space + (space - start) < n; space++) {
			if (
				s[start] != s[space]
				&& s[space] != s[space + (space - start)]
				&& s[start] != s[space + (space - start)]
				) 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;

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

typedef long long LL;
const int M=4005;
char s[M];

int main()
{
	int n;
	scanf("%d%s",&n,s);
	int cntr=0,cntg=0,cntb=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
			cntr++;
		if(s[i]=='G')
			cntg++;
		if(s[i]=='B')
			cntb++;
	}
	LL ans=(LL)cntr*cntg*cntb;
	for(int i=2;i<n;i++)
		for(int j=i-1,k;(k=j-(i-j))>=0;j--)
		{
			if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])
				ans--;
		}
	printf("%lld\n",ans);
	return 0;
}

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
using namespace std;

void Main()
{
    int n;
    string s;
    cin >> n >> s;

    long c = 0;
    char s[n];
    for (int i = 0; i < n-3; i++)
    {
        for (int j = i+1; j < n-1; j++)
        {
            if(s[i] == s[j]) continue;
            for (int k = j+1; k < n; k++)
            {
                if(j-i == k-j) continue;
                if(s[j] == s[k]) continue;
                if(s[i] == s[k]) continue;
                c += 1;                
            }
        }
    }
    cout << c << endl;
}

int main(int argc, char **argv)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
    return 0;
}


Compiler output:
a.cc: In function 'void Main()':
a.cc:14:10: error: conflicting declaration 'char s [n]'
   14 |     char s[n];
      |          ^
a.cc:10:12: note: previous declaration as 'std::string s'
   10 |     string s;
      |            ^
Language: C

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int rcnt[3];

int fix(char c){
	if(c == 'R')return 0;
	if(c == 'G')return 1;
	else return 2;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	string s;
	cin >> n >> s;
	ll ans = 0;
	rep(i,0,n){
		int dual = 1;
		int cur = fix(s[i]);
		rep(j,0,3)if(j != cur)dual *= rcnt[j];

		rep(len,0,i){
			if(i - 2 * len < 0){
				break;
			}
			int x = i - 2*len;
			int y = i - len;
			if(s[x] != s[y] && s[y] != s[i] && s[i] != s[x]){
				--dual;
			}
		}
		ans += dual;
		++rcnt[cur];
	}
	cout << ans << '\n';
}


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

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

long long n, cnt[3] = {};
string rgb = "RGB", s;

long long solve();

int main() {
  cin >> n >> s;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 3; ++j)
      if (s[i] == rgb[j]) ++cnt[j];
  res = cnt[0] * cnt[1] * cnt[2];
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      int k = 2 * j - i;
      if (k >= n) continue;
      if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) --res;
    }
  return res;
}


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

#include <bits/stdc++.h>
using namespace std;
#define int long long 
using ldb = long double;
using pa = pair < int, int >;
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;
int r, g, b,n;
string s;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    f(i,0,n){
        if(s[i] == 'R'){
            r++;
        }
        else if(s[i] == 'G'){
            g++;
        }
        else
            b++;
    }
    int ans = r*g*b;
    f(i,0,n){
        f(j,1,n){
            int l = i-j;
            int rr = i+j;
            if(l >= 0 and l < n and rr >= 0 and rr < n and s[l] != s[i] and s[rr] != s[i] and s[l] != s[rr]){
                ans --;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
 

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

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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int a=0, b=0, c=0;
    long ans;
    for(int i = 0; i < n; ++i){
        if(s[i]=='G'){
            a++;
        }else if(s[i]=='R'){
            b++;
        }else{
            c++;
        }
    }
    ans = a*b*c;
    for(int i=0, i <= n; i++){
        for(int j = i+1; j <= n; j++){
            int k=2*(i+1)-i;
            if(k<n && s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]){
                ans--;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: expected ';' before '<=' token
   22 |     for(int i=0, i <= n; i++){
      |                   ^~~
      |                   ;
a.cc:22:20: error: expected primary-expression before '<=' token
   22 |     for(int i=0, i <= n; i++){
      |                    ^~