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

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <climits>
#include <iomanip>
#include <limits>
#include <bitset>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = INT_MAX;
const ll linf = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = (m); i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<>()
#define SUM(a) accumulate((a).begin(), (a).end(), 0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
template <typename T>
int len(T tmp)
{
	int res = 0;
	while (tmp > 0)
	{
		res++;
		tmp /= 10;
	}
	return res;
}
template <typename T>
T gcd(T a, T b)
{
	T t;
	while (b != 0)
	{
		t = a % b;
		a = b;
		b = t;
	}
	return a;
}
template <typename T>
T recfact(T start, T n)
{
	T i;
	if (n <= 16)
	{
		T r = start;
		for (i = start + 1; i < start + n; i++)
			r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
template <typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
template <typename T>
T fct(T n)
{
	return recfact<T>(1, n);
}
template <typename T>
T ncm(T n, T m)
{
	if (n < m)
		return 0;
	T x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr)
{
	if (firstItr < 0 || secondItr > int(str.size() - 1))
		return str;
	while (firstItr < secondItr)
	{
		swap(str[firstItr], str[secondItr]);
		firstItr++;
		secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str)
{
	int itr = 0;
	std::string res;
	while (itr < int(str.size()))
	{
		char tmp = str[itr++];
		int length = 1;
		while (itr < int(str.size()) && str[itr] == tmp)
		{
			++itr;
			++length;
		}
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
str split(str str, size_t first_itr, size_t second_itr)
{
	string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++)
	{
		tmp.push_back(str.at(i));
	}
	return tmp;
}

int main(void)
{
	int n;
	cin >> n;
	ll r, g, b;
	r = g = b = 0;
	rep(i, n)
	{
		char tmp;
		cin >> tmp;
		switch (tmp)
		{
		case 'R':
			r++;
			break;
		case 'G':
			g++;
			break;
		case 'B':
			b++;
			break;
		}
	}
	ll ans = r * g * b;
	rep(i, n) for (int j = i + 1; j < n; j++)
	{
		int k = 2 * j - i;
		if (k < n)
			if (s.at(i) != s.at(j) && s.at(i) != s.at(k) && s.at(j) != s.at(k))
				ans--;
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:162:29: error: 's' was not declared in this scope
  162 |                         if (s.at(i) != s.at(j) && s.at(i) != s.at(k) && s.at(j) != s.at(k))
      |                             ^
Language: C++

#include <cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	int n;
        string s; 
       cin>>n>>s;
	map<char,int> count_;
	for(int i=0; i<n; i++)
                    count_[s[i]]++;
	ll res = (ll)count_['R'] * count_['G'] * count_['B'];
	for(int i=0; i<n-2; i++)
		for(int j=i+1,k=i+2; k<n;  k+=2,j++)
			if((s[i]^s[j]^s[k]) == ('R'^'G'^'B')) 
                                     res--;
	cout<< res <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'map' was not declared in this scope
    9 |         map<char,int> count_;
      |         ^~~
a.cc:3:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    2 | #include<iostream>
  +++ |+#include <map>
    3 | using namespace std;
a.cc:9:13: error: expected primary-expression before 'char'
    9 |         map<char,int> count_;
      |             ^~~~
a.cc:11:21: error: 'count_' was not declared in this scope
   11 |                     count_[s[i]]++;
      |                     ^~~~~~
a.cc:12:22: error: 'count_' was not declared in this scope
   12 |         ll res = (ll)count_['R'] * count_['G'] * count_['B'];
      |                      ^~~~~~
Language: C

#include <cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	int n;
        string s; 
       cin>>n>>s;
	map<char,int> count_;
	for(int i=0; i<n; i++)
                    count_[s[i]]++;
	ll res = (ll)count_['R'] * count_['G'] * count_['B'];
	for(int i=0; i<n-2; i++)
		for(int j=i+1,k=i+2; k<n;  k+=2,j++)
			if((s[i]^s[j]^s[k]) == ('R'^'G'^'B')) 
                                     res--;
	cout<< res <<endl;
}


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

import numpy as np
import itertools 
import math
import itertools 
import sys

input = sys.stdin.readline


N = int(input())

S = input()

color =list("RGB")

#色がRGBの３色ないとき
for x in color:
    if x not in S:
        print(0)
        exit()

r = 0
g = 0
b = 0
for i in range(len(S)):
    if S[i] == color[0]:
        r+=1
    elif S[i] == color[1]:
        g+=1
    elif S[i] == color[2]:
        b+=1

all = r*g*b

sub = 0
for i in range(N):
    for j in range(i+1,N):
        k = 2*j - i
        #kがN以上の位置にある
        if k >= N:
            continue

        #同じ色がある
        if S[i] == S[j] or S[j] == S[k] or S[k] == S[i] :
            continue
        sub+=1

print(all - sub)
        




Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import numpy as np
      | ^~~~~~
main.c:1:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'as'
    1 | import numpy as np
      |              ^~
main.c:1:14: error: unknown type name 'as'
main.c:16:2: error: invalid preprocessing directive #\U00008272\U0000304cRGB\U0000306e\U0000ff13\U00008272\U0000306a\U00003044\U00003068\U0000304d
   16 | #色がRGBの３色ないとき
      |  ^~~~~~~~~~~~~~~~~~~~~
main.c:39:10: error: invalid preprocessing directive #k\U0000304cN\U00004ee5\U00004e0a\U0000306e\U00004f4d\U00007f6e\U0000306b\U00003042\U0000308b
   39 |         #kがN以上の位置にある
      |          ^~~~~~~~~~~~~~~~~~~~
main.c:43:10: error: invalid preprocessing directive #\U0000540c\U00003058\U00008272\U0000304c\U00003042\U0000308b
   43 |         #同じ色がある
      |          ^~~~~~~~~~~~
Language: C

#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n;
    int r=0;
    int g=0;
    int b=0;
    cin>>n;
    char color[n];
    for (int i=0; i<n; i++){
        cin>>color[i];
        if (color[i]=='R') r+=1;
        if (color[i]=='G') g+=1;
        if (color[i]=='B') b+=1;
        
    }
    
    
    int count=0;
    for (int i=0; i<n-1; i++){
        for (int k=i+1; k<n; k++){
            if ((i+k)%2==1){
                continue;
            }
            
            int j=(i+k)/2;
            
            if (color[i]!=color[j] && color[j]!=color[k] && color[i]!=color[k]){
                count+=1;
            }
        }
    }
    
    cout<<r*g*b-count<<endl;
}

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

#include <cstring>
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  int counter=0;
  vector<int>R(4005);
  vector<int>G(4005);
  vector<int>B(4005);
  if(s.at(0)=='R'){
  R.at(0)=1;
  G.at(0)=0;
  B.at(0)=0;
  break;}
  else if(s.at(0)=='B'){
  R.at(0)=0;
  G.at(0)=0;
  B.at(0)=1;
  break;}
  else if(s.at(0)=='G'){
  R.at(0)=0;
  G.at(0)=1;
  B.at(0)=0;
  break;}
  for(int r=1; r<N;r++){
  if(s.at(r)=='R'){
  R.at(r)=R.at(r-1)+1;
  G.at(r)=G.at(r-1);
  B.at(r)=B.at(r-1);
  continue;}
  else if(s.at(r)=='G'){
  G.at(r)=G.at(r-1)+1;
  R.at(r)=R.at(r-1);
  B.at(r)=B.at(r-1);
  continue;}
  else if(s.at(r)=='B'){
  B.at(r)=B.at(r-1)+1;
  R.at(r)=R.at(r-1);
  G.at(r)=G.at(r-1);
  continue;}}
  for(int e=1; e<N-1;e++){
  if(s.at(e)=='R'){
  counter+=(B.at(e-1)*(G.at(N-1)-G.at(e)))+(G.at(e-1)*(B.at(N-1)-B.at(e)));
  continue;}
  else if(s.at(e)=='G'){
  counter+=(B.at(e-1)*(R.at(N-1)-R.at(e)))+(R.at(e-1)*(B.at(N-1)-B.at(e)));
  continue;}
  else{
  counter+=(R.at(e-1)*(G.at(N-1)-G.at(e)))+(G.at(e-1)*(R.at(N-1)-R.at(e)));}}
  int i,j,k;
  for(i=1;i<N-1;i++ ){
  for(j=i-1;j>=0; j-- ){
  for(k=i+1;k<N;k++ ){
  if((s.at(i)!=s.at(j))&&(s.at(i)!=s.at(k))&&(s.at(j)!=s.at(k))&&i-j==k-i){
  counter--;}}}}
  cout<<counter<<endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: break statement not within loop or switch
   19 |   break;}
      |   ^~~~~
a.cc:24:3: error: break statement not within loop or switch
   24 |   break;}
      |   ^~~~~
a.cc:29:3: error: break statement not within loop or switch
   29 |   break;}
      |   ^~~~~
Language: C++

#include <cstring>
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
string s;
cin>>s;
long long a,b=0;
  long long counter=0;
  long long counter1=0;
  vector<long long>R(4005);
  vector<long long>G(4005);
  vector<long long>B(4005);
  if(s.at(0)=='R'){
  R.at(0)=1;
  G.at(0)=0;
  B.at(0)=0;}
  else if(s.at(0)=='B'){
  R.at(0)=0;
  G.at(0)=0;
  B.at(0)=1;}
  else if(s.at(0)=='G'){
  R.at(0)=0;
  G.at(0)=1;
  B.at(0)=0;}
  for(int r=1; r<N;r++){
  if(s.at(r)=='R'){
  R.at(r)++;
  G.at(r)=G.at(r-1);
  B.at(r)=B.at(r-1);}
  else if(s.at(r)=='G'){
  G.at(r)++;
  R.at(r)=R.at(r-1);
  B.at(r)=B.at(r-1);}
  else if(s.at(r)=='B'){
  B.at(r)++;
  R.at(r)=R.at(r-1);
  G.at(r)=G.at(r-1);}}
  for(int e=1, e<N;e++){
  if(s.at(e)=='R'){
  counter+=(B.at(e-1)*(G.at(N-1)-G.at(e)))+(G.at(e-1)*(B.at(N-1)-B.at(e)));}
  else if(s.at(e)=='G'){
  counter+=(B.at(e-1)*(R.at(N-1)-R.at(e)))+(R.at(e-1)*(B.at(N-1)-B.at(e)));}
  else{
  counter+=(R.at(e-1)*(G.at(N-1)-G.at(e)))+(G.at(e-1)*(R.at(N-1)-R.at(e)));}}
  int i,j,k;
  for(i=1;i<N-1;i++ ){
  for(j=i-1;j>=0; j-- ){
  for(k=i+1;k<N;k++ ){
  if((s.at(i)!=s.at(j))&&(s.at(i)!=s.at(k))&&(s.at(j)!=s.at(k))){
  counter--;}}}}
  cout<<counter<<endl;}
  
  
    


Compiler output:
a.cc: In function 'int main()':
a.cc:42:17: error: expected ';' before '<' token
   42 |   for(int e=1, e<N;e++){
      |                 ^
      |                 ;
a.cc:42:17: error: expected primary-expression before '<' token
Language: C

#include <cstring>
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
string s;
cin>>s;
long long a,b=0;
  long long counter=0;
  long long counter1=0;
  vector<long long>R(4005);
  vector<long long>G(4005);
  vector<long long>B(4005);
  if(s.at(0)=='R'){
  R.at(0)=1;
  G.at(0)=0;
  B.at(0)=0;}
  else if(s.at(0)=='B'){
  R.at(0)=0;
  G.at(0)=0;
  B.at(0)=1;}
  else if(s.at(0)=='G'){
  R.at(0)=0;
  G.at(0)=1;
  B.at(0)=0;}
  for(int r=1; r<N;r++){
  if(s.at(r)=='R'){
  R.at(r)++;
  G.at(r)=G.at(r-1);
  B.at(r)=B.at(r-1);}
  else if(s.at(r)=='G'){
  G.at(r)++;
  R.at(r)=R.at(r-1);
  B.at(r)=B.at(r-1);}
  else if(s.at(r)=='B'){
  B.at(r)++;
  R.at(r)=R.at(r-1);
  G.at(r)=G.at(r-1);}}
  for(int e=1, e<N;e++){
  if(s.at(e)=='R'){
  counter+=(B.at(e-1)*(G.at(N-1)-G.at(e)))+(G.at(e-1)*(B.at(N-1)-B.at(e)));}
  else if(s.at(e)=='G'){
  counter+=(B.at(e-1)*(R.at(N-1)-R.at(e)))+(R.at(e-1)*(B.at(N-1)-B.at(e)));}
  else{
  counter+=(R.at(e-1)*(G.at(N-1)-G.at(e)))+(G.at(e-1)*(R.at(N-1)-R.at(e)));}}
  int i,j,k;
  for(i=1;i<N-1;i++ ){
  for(j=i-1;j>=0; j-- ){
  for(k=i+1;k<N;k++ ){
  if((s.at(i)!=s.at(j))&&(s.at(i)!=s.at(k))&&(s.at(j)!=s.at(k))){
  counter--;}}}}
  cout<<counter<<endl;}
  
  
    


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

#include <iostream>
#include <string>

using namespace std;

int main(){
    int N = 0;
    string S;
    int ans = 0;

    cin >> N;
    cin >> S;

    for(int i = 0; i < N-2; i++){
//        if(S[i+1] == S[i]){
//            continue;
//        }
        for(int j = i+1; j < N-1; j++){     // jはi+1以上 
            for(int k = j+1; k < N; k++){   // kはj+1以上 
                // 条件1 
                if((S[i] != S[j]) && (S[k] != S[j]) && (S[i] != S[k])){
                    // 条件2
                    if((j - i) != (k - j)){
//                        cout << S[i] << S[j] << S[k] << endl;
                        ans++;
                    } 
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#include <iostream>
#include <map>
#include <vector>
using namespace std;

int count(map<char,vector<int>> &dic, char a, char b, char c)
{
    int result = 0;
    for(int x : dic[a])
    {
        vector<int>::iterator y = lower_bound(dic[b].begin(), dic[b].end(), x);
        for(; y != dic[b].end(); ++y)
        {
            vector<int>::iterator z = lower_bound(dic[c].begin(), dic[c].end(), *y);
            for(; z != dic[c].end(); ++z)
            {
                if(*y-x != *z-*y)
                {
                    ++result;
                }
            }
        }
    }
    return result;
}

int main()
{
    int n;
    cin >> n;
    string str;
    cin >> str;
    map<char,vector<int>> dic;
    for(int i = 0; i < n; ++i)
    {
        dic[str[i]].push_back(i);
    }
    int ans = 0;
    ans += count(dic,'R','G','B');
    ans += count(dic,'R','B','G');
    ans += count(dic,'G','R','B');
    ans += count(dic,'G','B','R');
    ans += count(dic,'B','R','G');
    ans += count(dic,'B','G','R');
    cout << ans << endl;
}

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

#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
  string s;
  int n;
  cin>>n;
  cin>>s;
  for(auto c:s){
    if(c=='R') ++r;
    else if(c=='G') ++g;
    else ++b;
  }
  long long all=r*b*g;
  long long 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:
a.cc: In function 'int main()':
a.cc:11:18: error: 'r' was not declared in this scope
   11 |     if(c=='R') ++r;
      |                  ^
a.cc:12:23: error: 'g' was not declared in this scope
   12 |     else if(c=='G') ++g;
      |                       ^
a.cc:13:12: error: 'b' was not declared in this scope
   13 |     else ++b;
      |            ^
a.cc:15:17: error: 'r' was not declared in this scope
   15 |   long long all=r*b*g;
      |                 ^
a.cc:15:19: error: 'b' was not declared in this scope
   15 |   long long all=r*b*g;
      |                   ^
a.cc:15:21: error: 'g' was not declared in this scope
   15 |   long long all=r*b*g;
      |                     ^
Language: C

#include<bits/stdc++.h>

using namespace std;

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

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, ans = 0;
	string str;
	
	cin >> n;
	cin >> str;
	
	vector<int> r, g, b;
	
	for(int i = 0; i < n; i++){
		if(str[i] == 'R'){
			r.push_back(i);
		}
		else if(str[i] == 'G'){
			g.push_back(i);
		}
		else{
			b.push_back(i);
		}
	}
	
	for(int i = 0; i < r.size(); i++){
		for(int j = 0; j < g.size(); j++){
			for(int k = 0; k < b.size(); k++){
				set<int> s;
				s.insert(r[i]);
				s.insert(g[j]);
				s.insert(b[k]);
				
				auto it = s.begin();
				int a = *it;
				it++;
				int b = *it;
				it++;
				int c = *it;
				
				//cout << a << " " << b << " " << c << endl;
				
				if(b - a != c - b){
					ans++;
				}
			}
		}
	}
	
	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;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,r = 0,g = 0,b = 0;
    cin >> n;
    string s;
    cin >> s;
    rep0(i, n){
        if(s[i] == 'R')++r;
        else if(s[i] == 'G')++g;
        else ++b;
    }
    ll ans = r*g*b;
    rep0(j, n)rep0(i, j){
        map<char,bool> c;
        c['R'] = false;
        c['G'] = false;
        c['B'] = false;
        c[s[i]] = true;
        c[s[j]] = true;
        c[s[j + j - i]] = true;
        if(c['R']&c['G']&c['B'])--ans;
    }
    pf(ans);
    return 0;
}



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

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//以上テンプレ
int main(){
    ll N;
    cin>>N;
    string S;
    cin>>S;
    map<char,int> RGB;
    rep(i,N){
        RGB[S.at(i)]++;
    }
    ll r=RGB['R'];
    ll g=RGB['G'];
    ll b=RGB['B'];
    ll Ans=r*g*b;
    rep(i,N){
        rep2(j,i+1,N){
            ll k=j*2-i;
            if(k<N&&S.at(k)!=S.at(j)&&S.at(k)!=S.at(i)&&S.at(j)!=S.at(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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  map<string,int> mp;
  int ans_mp[3];
  int tmp;

  rep(i,n){
    mp.clear();
    mp["s.at(i)"] = i;
    ans_mp[0] = i;
    repr(j,i+1,n){
      mp["s.at(j)] = j;
      if (mp.size() == 2 ){
        ans_mp[1] = j;
      }
      if (mp.size() == 3) {
        ans_mp[2] = j;
        if ((ans_mp[1] - ans_mp[0])&&(ans_mp[2] - ans_mp[1])) {
          ans++;
        }
      }
    }
  }
  //
  // (map["R"] - map[s.at(i)]) && (map[s.at(j)] - map[s.at()])
  // rep(i,n){
  //   repr(j,i+1,n){
  //     if (s.at(i) != s.at(j)){
  //       repr(k,j+1,n){
  //         // if ((s.at(i) == s.at(k))||(s.at(j) != s.at(k)) break;
  //         if ((s.at(i) != s.at(j))&&(s.at(i) != s.at(k))&&(s.at(j) != s.at(k))&&((j-i)!=(k-j))) {
  //           ans++;
  //         }
  //       }
  //     }
  //   }
  // }
  // cout << s.at(0) << '\n';
  cout << ans << '\n';
  return 0;
}


Compiler output:
a.cc:25:10: warning: missing terminating " character
   25 |       mp["s.at(j)] = j;
      |          ^
a.cc:25:10: error: missing terminating " character
   25 |       mp["s.at(j)] = j;
      |          ^~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:26:7: error: expected primary-expression before 'if'
   26 |       if (mp.size() == 2 ){
      |       ^~
a.cc:25:10: error: expected ']' before 'if'
   25 |       mp["s.at(j)] = j;
      |          ^
      |          ]
   26 |       if (mp.size() == 2 ){
      |       ~~
Language: C

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える




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

    ll ans = 0;

    map<char, int> rgb_map;
    rep(i, n){
        if(s[i] == 'R') rgb_map['R']++;
        else if(s[i] == 'G') rgb_map['G']++;
        else if(s[i] == 'B') rgb_map['B']++;
    }

    //とりあえずr,g,bの個数の積を保存
    ans += rgb_map['R'] * rgb_map['G'] * rgb_map['B'];

    //これからj-i == k-j かつ3文字が異なるモノを引いてゆく
    for(int i=0; i<(n-2); ++i) for(int j=i+1; j<(n-2); ++j){
        
        int k = 2*j - i;
        
        if(k >= n) break;

        else if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
    }

    cout << ans << endl;
}

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

#include<bits/stdc++.h>
using namespace std;
int check(int s,int r){
 	return 3 - (s+r);
}
int main(){
 	int n,k,i,j;
  	string s;
  	cin>>n>>s;
  	int ans = 0;
  	int cnt[n+1][3];
  	memset(cnt,0,sizeof(dp));
  	for(i=1;i<=n;++i){
      	if(s[i-1] == 'R'){
          	cnt[i][0] = cnt[i-1][0] + 1;
			cnt[i][1] = cnt[i-1][1];
          	cnt[i][2] = cnt[i-1][2];
        }
      	else if(s[i-1] == 'G'){
          	cnt[i][0] = cnt[i-1][0];
			cnt[i][1] = cnt[i-1][1] + 1;
          	cnt[i][2] = cnt[i-1][2];
        }
      else{
       		cnt[i][0] = cnt[i-1][0];
			cnt[i][1] = cnt[i-1][1];
          	cnt[i][2] = cnt[i-1][2]+1; 
      }
    }
  	map<char,int> mp;
  	mp['R'] = 0;
  	mp['G'] = 1;
  	mp['B'] = 2;
  	for(i=0;i<n;++i){
      for(j=0;j<i;++j){
      		ans += cnt[n][0] + cnt[n][1] + cnt[n][2] - cnt[j+1][0] + cnt[j+1][1] + cnt[j+1][2] - cnt[j+j-i][check(mp[s[i]],mp[s[j]])];
      }
    }
  	cout<<ans<<"\n";
}			


Compiler output:
a.cc: In function 'int main()':
a.cc:12:29: error: 'dp' was not declared in this scope; did you mean 'dup'?
   12 |         memset(cnt,0,sizeof(dp));
      |                             ^~
      |                             dup
Language: C

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

int main() {
  int X;
  long long ans,r,g,b;
  ans=0;
  cin >>X;
  string S;
  cin>>S;
  r=0;
  g=0;
  b=0;
  for(int i=0;i<X;i++){
          if(S[i]=='R'){
        r++;
      }      if(S[i]=='G'){
        g++;
      }      if(S[i]=='B'){
        b++;
      }
  }
  ans=r*g*b;
  for(int i=0;i<X;i++){
    for(int j=i+1;2*j-i<X;j++){
      if(S[i]!=S[j]&&S[j]!=S[2*j-i]&&S[i]!=S[2*j-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 <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i,n) for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'

void solve(){
	int n, r=0,g=0,b=0;
	string s;
	cin >> n >> s;
	for(int i=0; i<s.size();i++){
		if(s[i]=='R') r++;
		if(s[i]=='G') g++;
		if(s[i]=='B') b++;
	}
	int ans = r*g*b;
	if(n<3) {
	cout << 0 << en;
	return ;
	}
	fork(i,n) fork(h,n){
		int j = i+h, k=h+j;
		if(k>=n) break;
		if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k])ans--;
	}
	cout << ans << en;
}

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
 
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
    int t = 1;
    while(t--)
        solve();
    return 0;
}

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

#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int N;cin>>N;
  string S;cin>>S;
  vector<int> c(3,0);
  for(int i=0;i<N;i++){
    c[(S[i]=='R'?0:(S[i]=='B'?1:2))]++;
  }
  long long ans=c[0]*c[1]*c[2];
  long long count=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<n;j++)if(S[i]!=S[j]){
      if(2*j-i<N&&S[2*j-i]!=S[i]&&S[2*j-i]!=S[j]) count++;
    }
  }
  ans-=count;
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: 'n' was not declared in this scope
   15 |     for(int j=i+1;j<n;j++)if(S[i]!=S[j]){
      |                     ^
Language: C

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

int main() {
    int N;
  cin >> N;
  string S;
  cin >> S;
     int r = 0;
     int g = 0;
     int b = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'R') r += 1;
        else if(S[i] == 'G') g += 1;
        else if(S[i] == 'B') b += 1; 
    }

    ll ans = r * b * g;
    int s = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            
            if(S[i] == S[j]) continue;
            int k = 2 * j - i;
            if(k >= N || S[k] == S[j] || S[i] == S[k]) s++;
        }
    }

    cout << ans - s;

    return 0;

}

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


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(ll i = 0;i < n;++i)    
#define seg_size 524288

ll main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll>cnt(3,0);
    vector<vector<ll>>pl(3);
    rep(i,n){
        if(s[i]=='R'){
            cnt[0]++;
            pl[0].push_back(i);
        }
        if(s[i]=='G'){
            cnt[1]++;
            pl[1].push_back(i);
        }
        if(s[i]=='B'){
            cnt[2]++;
            pl[2].push_back(i);
        }
    }
    ll ans=cnt[0]*cnt[1]*cnt[2];
    if(ans==0){
        cout<<ans<<endl;
        return 0;
    }
    for(ll a:pl[0])for(ll b:pl[1]){
        ll aa=a;
        ll bb=b;
        if(aa>bb)swap(aa,bb);
        
        
        if(2*aa-bb>=0&&s[2*aa-bb]=='B')ans--;
        if(2*bb-aa<n&&s[2*bb-aa]=='B')ans--;
        if((aa+bb)%2==0&&s[(aa+bb)/2]=='B')ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc:11:1: error: '::main' must return 'int'
   11 | ll main(){
      | ^~
Language: C

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  vector<ll>cnt(3);
  rep(i,n){
    if(s[i]=='R') cnt[0]++;
    if(s[i]=='G') cnt[1]++;
    if(s[i]=='B') cnt[2]++;
  }
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  
  rep(j,n) rep(i,j){
    ll k = j + j - i;
    if(k<n){
      if(s[i]==s[j]) continue;
      if(s[i]==s[k]) continue;
      if(s[k]==s[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
}


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

#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

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

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

  ll to = r*g*b;
  rep(i,n){
    for(int j = i+1; j < n; j++){
      int k = 2*j - i;
      if(k >= n) break;
      if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i])
      to--;
    }
  }

  std::cout << to << '\n';
  return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll cnt = 0;
  rep(i,n){
    rep(j,n){
      rep(k,n){
        if(i<j && j<k){
          if(s[i]!=s[j]&&s[i]!=s[k]){
            if(j-i!=k-j) cnt++;
          }
        }
      }
    }
  }
  cout << cnt << endl;
}


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

#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;

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

    string s;
    cin >> s;   

    int len = s.size();

    vector<int> a(n);
    vector<int> num(3) = {0, 0, 0};
    
    

    for(int i=0;i<len;i++){
        if(s[i] == 'R') {
            a[i] = 0;
            num[0]++;
        }
        if(s[i] == 'G'){
            a[i] = 1;
            num[1]++;
        } 
        if(s[i] == 'B') {
            a[i] = 2;
            num[2]++;
        }
    }
    int ans = num[0]*num[1]*num[2];

    int k;

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

    cout << ans << endl;

}   

Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: expected ',' or ';' before '=' token
   23 |     vector<int> num(3) = {0, 0, 0};
      |                        ^
Language: C++

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

int main(){
  int N;
  string S;
  cin >> N;
  int ng = 0;
  int nb = 0;
  int nr = 0;
  for(i, N){
    if(S[i] == 'R'){
      nr++;
    }else if(S[i] == 'G'){
      ng++;
    }else{
      nb++;
    }
  }
  int ans = nr * ng * nb;
  for(int i = 0; i < N-2; i++){
    for(int j = i+1; j < N-1; j++){
      int k = 2*j-i;
      if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]){
        ans--;
      }
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   for(i, N){
      |       ^
a.cc:24:3: error: expected primary-expression before 'for'
   24 |   for(int i = 0; i < N-2; i++){
      |   ^~~
a.cc:23:26: error: expected ')' before 'for'
   23 |   int ans = nr * ng * nb;
      |                          ^
      |                          )
   24 |   for(int i = 0; i < N-2; i++){
      |   ~~~                     
a.cc:14:6: note: to match this '('
   14 |   for(i, N){
      |      ^
a.cc:32:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

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

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

  rep(i, s.length()){
    for(int j=i+1; j<s.length(); j++){
      if(0<=2*j-i && 2*j-i<s.length()){
        if(s[i]!=s[j] && s[j]!=s[2*j-i] && s[2*j-i]!=s[i]) cnt++;
      }
    }
  }
  if(r*g*b-cnt<0) out(0);
  else out(r*g*b-cnt);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:3: error: 'else' without a previous 'if'
   31 |   else out(r*g*b-cnt);
      |   ^~~~
Language: C

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt[3] = { 0 };
	rep(i, n) {
		if (s[i] == 'R') cnt[0]++;
		if (s[i] == 'G') cnt[1]++;
		if (s[i] == 'B') cnt[2]++;
	}
	int ans = 1;
	rep(i, 3) ans *= cnt[i];
	rep(j,n){
		rep(i,j ) {
			int k = 2 * j - i;
			if (k < n) {
				if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
					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 <stdio.h>
#include <iostream>
#include <string>

#define MAX_N 4010

int main() {
  int n;
  std::string s;
  scanf("%d", &n);
  std::cin >> s;
  int leftR[MAX_N], rightR[MAX_N];
  int leftG[MAX_N], rightG[MAX_N];
  int leftB[MAX_N], rightB[MAX_N];
  leftR[0] = 0;
  leftG[0] = 0;
  leftB[0] = 0;
  rightR[n-1] = 0;
  rightG[n - 1] = 0;
  rightB[n - 1] = 0;
  for (int i = 0; i < n-1; i++) {
    leftR[i+1] = leftR[i] + (s[i] == 'R');
    leftG[i + 1] = leftG[i] + (s[i] == 'G');
    leftB[i + 1] = leftB[i] + (s[i] == 'B');
  }
  for (int k = n-1; k >= 1; k--) {
    rightR[k-1] = rightR[k] + (s[k] == 'R');
    rightG[k - 1] = rightG[k] + (s[k] == 'G');
    rightB[k - 1] = rightB[k] + (s[k] == 'B');
  }
  long long ans = 0;
  for (int j = 1; j < n-1; j++) {
    if (s[j] == 'R') {
      ans += leftG[j] * rightB[j];
      ans += leftB[j] * rightG[j];
      for (int i = 0; i < j; i++) {
        if (s[i] == 'G' && 2*j-i < n && s[2*j-i] == 'B') ans--;
        if (s[i] == 'B' && 2 * j - i < n && s[2 * j - i] == 'G')
          ans--;
      }
    }
    if (s[j] == 'G') {
      ans += leftR[j] * rightB[j];
      ans += leftB[j] * rightR[j];
      for (int i = 0; i < j; i++) {
        if (s[i] == 'R' && 2 * j - i < n && s[2 * j - i] == 'B')
          ans--;
        if (s[i] == 'B' && 2 * j - i < n && s[2 * j - i] == 'R')
          ans--;
      }
    }
    if (s[j] == 'B') {
      ans += leftG[j] * rightR[j];
      ans += leftR[j] * rightG[j];
      for (int i = 0; i < j; i++) {
        if (s[i] == 'G' && 2 * j - i < n && s[2 * j - i] == 'R')
          ans--;
        if (s[i] == 'R' && 2 * j - i < n && s[2 * j - i] == 'G')
          ans--;
      }
    }
  }

  printf("%lld\n", ans);

  return 0;
}


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

n=int(input())
s=list(input())
ans=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
   if s[i]=='R':
       s[i]=1
   elif s[i]=='G':
       s[i]
   elif s[i]=='B':
       s[i]=4
for i in range(n):
   for j in range(i+1,n):
     k=2*j-i
     if k>=n:
       continue
     if s[i]+s[j]+s[k]==7:
         ans-=1
print(ans)

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:3: error: expected expression before 'int'
    1 | n=int(input())
      |   ^~~
Language: C

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll ans,n,r,g,b;
string s;
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')r++;
		if(s[i]=='G')g++;
		if(s[i]=='B')b++;
	}
	ans=r*g*b;
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n,2*j-i<n;j++)
	{
		if(s[i]!=s[j]&&s[j]!=s[2*j-i]&&s[i]!=s[2*j-1])
		ans--;
		
	}
	cout<<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: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String input	 = in.readLine();
		String S	 = in.readLine();

		int N = Integer.parseInt(input.split(" ")[0]);

		int[] s = new int[N];

		for(int i = 0;i<N;i++) {
			if(S.charAt(i)=='R') {
				s[i]=0;
			}else if(S.charAt(i)=='G') {
				s[i]=1;
			}else {
				s[i]=2;
			}
		}
		int ans=0;

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

		System.out.println(ans);
	}

Compiler output:
Main.java:40: error: reached end of file while parsing
	}
	 ^
1 error
Language: C

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


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

#include <iostream>
#include <map>
#include <set>
#include <string>

int countAligned(std::map<char, std::set<int>> &char2pos,
                 const char a, const char b, const char c) {
  int ans = 0;
  for (int i : char2pos[a]) {
    for (int j : char2pos[b]) {
      if (((i + j) & 1) != 0) {
        continue;
      }
      int k = (i + j) >> 1;
      if (char2pos[c].find(k) != char2pos[c].end()) {
        ans += 1;
      }
    }
  }
  return ans;
}

int main() {
  int len;
  std::string s;
  std::cin >> len;
  std::cin >> s;
  std::map<char, std::set<int>> char2pos;
  for (int pos = 0; pos < s.size(); pos++) {
    char2pos[s[pos]].push_back(pos);
  }
  int ans = char2pos['R'].size() * char2pos['G'].size() * char2pos['B'].size();
  ans -= countAligned(char2pos, 'R', 'G', 'B');
  ans -= countAligned(char2pos, 'R', 'B', 'G');
  ans -= countAligned(char2pos, 'G', 'B', 'R');
  return ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:22: error: 'std::map<char, std::set<int> >::mapped_type' {aka 'class std::set<int>'} has no member named 'push_back'
   30 |     char2pos[s[pos]].push_back(pos);
      |                      ^~~~~~~~~
Language: C++

#include <iostream>
#include <map>
#include <set>

int countAligned(std::map<char, std::set<int>> &char2pos,
                 const char a, const char b, const char c) {
  int ans = 0;
  for (int i : char2pos[a]) {
    for (int j : char2pos[b]) {
      if ((i + j) & 1 != 0) {
        continue;
      }
      int k = (i + j) >> 1;
      if (char2pos[c].find(k) != char2pos[c].end()) {
        ans += 1;
      }
    }
  }
  return ans;
}

int main() {
  int len, std::string s;
  std::cin >> len;
  std::cin >> s;
  std::map<char, std::set<int>> char2pos;
  for (int pos = 0; pos < s.size(); pos++) {
    char2pos[s[pos]].push_back(pos);
  }
  int ans = char2pos['R'].size() * char2pos['G'].size() * char2pos['B'].size();
  ans -= countAligned(char2pos, 'R', 'G', 'B');
  ans -= countAligned(char2pos, 'R', 'B', 'G');
  ans -= countAligned(char2pos, 'G', 'B', 'R');
  return ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: qualified-id in declaration before 's'
   23 |   int len, std::string s;
      |                        ^
a.cc:25:15: error: 's' was not declared in this scope
   25 |   std::cin >> s;
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int r = 0, g=0, b=0;
  for(int i=0; i < N; i++){
    if(S[i] =='R')r++;
    if(S[i] =='G')g++;
    if(S[i] =='B')b++;
  }
  int res = r*g*b;
  for(int i=0; i < N; i++){
    for(int d=1; d<N;d++){
      int j = i + d;
      int k = j + d;
      if(K>N)continue;
      if(S[i]!=S[j] && S[j] != S[k] && S[i] != S[k]){
        res --;
      }
    }
  }
  cout<<res<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: 'K' was not declared in this scope
   19 |       if(K>N)continue;
      |          ^
Language: C++

#include <iostream>
#include <set>

int countAligned(const std::map<char, std::set<int>> &char2pos,
                 const char a, const char b, const char c) {
  int ans = 0;
  for (int i : char2pos[a]) {
    for (int j : char2pos[b]) {
      if ((i + j) & 1 != 0) {
        continue;
      }
      int k = (i + j) >> 1;
      if (char2pos[c].find(k) != char2pos[c].end()) {
        ans += 1;
      }
    }
  }
  return ans;
}

int main() {
  int len, std::string s;
  std::cin >> len;
  std::cin >> s;
  std::map<char, std::set<int>> char2pos;
  for (int pos = 0; pos < s.size(); pos++) {
    char2pos[s[pos]].push_back(pos);
  }
  int ans = char2pos['R'].size() * char2pos['G'].size() * char2pos['B'].size();
  ans -= countAligned(char2pos, 'R', 'G', 'B');
  ans -= countAligned(char2pos, 'R', 'B', 'G');
  ans -= countAligned(char2pos, 'G', 'B', 'R');
  return ans;
}


Compiler output:
a.cc:4:29: error: 'map' in namespace 'std' does not name a template type
    4 | int countAligned(const std::map<char, std::set<int>> &char2pos,
      |                             ^~~
a.cc:3:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    2 | #include <set>
  +++ |+#include <map>
    3 | 
a.cc:4:32: error: expected ',' or '...' before '<' token
    4 | int countAligned(const std::map<char, std::set<int>> &char2pos,
      |                                ^
a.cc: In function 'int countAligned(int)':
a.cc:7:16: error: 'char2pos' was not declared in this scope
    7 |   for (int i : char2pos[a]) {
      |                ^~~~~~~~
a.cc:7:25: error: 'a' was not declared in this scope
    7 |   for (int i : char2pos[a]) {
      |                         ^
a.cc:8:27: error: 'b' was not declared in this scope
    8 |     for (int j : char2pos[b]) {
      |                           ^
a.cc:13:20: error: 'c' was not declared in this scope
   13 |       if (char2pos[c].find(k) != char2pos[c].end()) {
      |                    ^
a.cc: In function 'int main()':
a.cc:22:24: error: qualified-id in declaration before 's'
   22 |   int len, std::string s;
      |                        ^
a.cc:24:15: error: 's' was not declared in this scope
   24 |   std::cin >> s;
      |               ^
a.cc:25:8: error: 'map' is not a member of 'std'
   25 |   std::map<char, std::set<int>> char2pos;
      |        ^~~
a.cc:25:8: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
a.cc:25:12: error: expected primary-expression before 'char'
   25 |   std::map<char, std::set<int>> char2pos;
      |            ^~~~
a.cc:27:5: error: 'char2pos' was not declared in this scope
   27 |     char2pos[s[pos]].push_back(pos);
      |     ^~~~~~~~
a.cc:29:13: error: 'char2pos' was not declared in this scope
   29 |   int ans = char2pos['R'].size() * char2pos['G'].size() * char2pos['B'].size();
      |             ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_type();
  cin.tie(0);
  int n;
  cin>>n;
  char a[n];
  int i;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int p,j,k;
  p=0;
  for(i=0;i<n;i++)
  {for(j=0;i<n;j++)
  {for(k=0;k<n;k++)
  {
    if((a[i]!=a[j]!=a[k])&&((j-i!)=(k-i)))
    {
      p++;
    }}}}
  cout<<p;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:8: error: 'sync_with_type' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
    5 |   ios::sync_with_type();
      |        ^~~~~~~~~~~~~~
a.cc:21:33: error: expected ')' before '!' token
   21 |     if((a[i]!=a[j]!=a[k])&&((j-i!)=(k-i)))
      |                             ~   ^
      |                                 )
a.cc:24:6: error: expected ')' before '}' token
   24 |     }}}}
      |      ^
      |      )
a.cc:21:28: note: to match this '('
   21 |     if((a[i]!=a[j]!=a[k])&&((j-i!)=(k-i)))
      |                            ^
a.cc:24:6: error: expected ')' before '}' token
   24 |     }}}}
      |      ^
      |      )
a.cc:21:7: note: to match this '('
   21 |     if((a[i]!=a[j]!=a[k])&&((j-i!)=(k-i)))
      |       ^
a.cc:24:6: error: expected primary-expression before '}' token
   24 |     }}}}
      |      ^
Language: C

#include <bits/stdc++.h>
#define fin freopen("input", "r", stdin);
#define fout freopen("output", "w", stdout);
#define wt(x) cerr << #x << ": " << x << " ";
#define whatis(x) {cerr << #x << ": " << x << endl;}
#define whatis2(x, y) {wt(x); wt(y); cerr << endl;}
#define whatis3(x, y, z) {wt(x); wt(y); wt(z); cerr << endl;}
#define whatis4(x, y, z, a) {wt(x); wt(y); wt(z); wt(a); cerr << endl;}
using namespace std;

typedef long long ll; typedef unsigned long long ull; typedef long double ld;
const ll MOD = 1000000007; const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

string s;
int n;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    cin >> n;
    cin >> s;

    ll ans = 0;
    map <char, int> mp;
    for (auto i : s) mp[i] += 1;

    ans = mp['R'] * mp['G'] * mp['B'];
    ll minus = 0;

    for (int diff = 1; diff < n; ++diff) {
        for (int i = 0; i + 2*diff < n; ++i) {
            int r, g, b;
            r = i;
            g = i + diff;
            b = i + diff + diff;
            /* whatis3(r, g, b); */
            if (s[r] != s[g] && s[g] != s[b] && s[b] != s[r]) minus += 1;
        }
    }



    cout << ans - minus << endl;
    /* whatis(ans); */
    /* whatis(minus); */
    /* whatis(ans - minus); */


    


    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.