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

/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {

    int n; cin >> n;
    string s; cin >> s;
    ll ans = 0;
    for(int i=0; i<=n-3; i++) {
        char si = s[i];
        for(int j=i+1; j<=n-2; j++) {
            if(si!=s[j]) {
                for(int k=j+1; k<=n-1; k++) {
                    if(j-i==k-j) continue;
                    if(s[k]!=s[j]&s[k]!=si) {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	ll i;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> r, g, b;
	ll ans = 0;
	rep(i, s.length())
	{
		if(s[i] == 'R')
		{
			r.push_back(i+1);
		}
		else if (s[i] == 'G')
		{
			g.push_back(i+1);
		}
		else
		{
			b.push_back(i+1);
		}
	}
	ans = r.size() * g.size() * b.size() ;
	rep(i, r.size())
	{
		rep(k,g.size()){
			int M = max(r[i], g[k]);
			int m = min(r[i], g[k]);
			int d = M - m;
			ans -= binary_search(b.begin(), b.end(), M + d) ? 1 : 0;
			ans -= binary_search(b.begin(), b.end(), m - d) ? 1 : 0;
			if(d%2!=0){
				continue;
			}
			ans -= binary_search(b.begin(), b.end(), m + d / 2) ? 1 : 0;
		}
	}
	cout << ans << endl;
}


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

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define en '\n'

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll r = 0, g = 0, b = 0, res;
    for(auto el : s){
        if(el == 'R'){
            ++r;
        }else if(el == 'G'){
            ++g;
        }else{
            ++b;
        }
    }
    res = r*g*b;
    for(int i = 1; i < n; ++i) {
        for(int j = 0; j < i; ++j){
            if((i-j-2)%2 == 0){
                int k = (i+j)/2;
                if(s[j] != s[k] and s[j] != s[i] and s[i] != s[k]){
                    --res;
                }
            }
        }
    }
    cout << 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 <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,sum=0;
    string s;
    lli i,j,k;
    vector<lli> R,G,B;
    cin>>n>>s;
    rep(i,0,n){
        switch(s[i]){
            case 'R':R.push_back(i);break;
            case 'G':G.push_back(i);break;
            case 'B':B.push_back(i);break;
        }
    }
    rep(i,0,R.size()){
        rep(j,0,G.size()){
                rep(k,0,B.size()){
                        if((abs(B[k]-G[j])==abs(G[j]-R[i]))||(abs(B[k]-G[j])==abs(B[k]-R[i]))||(abs(B[k]-R[i])==abs(G[j]-R[i]))){
                            sum++;
                        }
                }
        }
    }
    cout<<R.size()*G.size()*B.size()-sum<<endl;
}


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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int gcm(int a, int b) { return b ? gcm(b, a % b) : a;}

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


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

N = int(input())
S = input()
## [color][idx]
RGB = [[0 for i in range(N)] for j in "RGB"]
for idx,ch in enumerate(S):
  for color_idx in [0,1,2]:
    RGB[color_idx][idx] = RGB[color_idx][idx-1]
  RGB["RGB".index(ch)][idx] += 1
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    if S[i] != S[j]:
      nokori = {"R","G","B"} - {S[i],S[j]}
      n_ch = [ch for ch in nokori][0]
      n_idx = "RGB".index(n_ch)
      ans += RGB[n_idx][-1]-RGB[n_idx][j]-(1 if (j+(j-i)<N and  S[j + (j-i)] == n_ch) else 0)
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:5: error: expected expression before 'int'
    1 | N = int(input())
      |     ^~~
main.c:3:1: error: stray '##' in program
    3 | ## [color][idx]
      | ^~
main.c:13:30: error: expected identifier or '(' before '-' token
   13 |       nokori = {"R","G","B"} - {S[i],S[j]}
      |                              ^
main.c:14:7: warning: data definition has no type or storage class
   14 |       n_ch = [ch for ch in nokori][0]
      |       ^~~~
main.c:14:7: error: type defaults to 'int' in declaration of 'n_ch' [-Wimplicit-int]
main.c:14:14: error: expected expression before '[' token
   14 |       n_ch = [ch for ch in nokori][0]
      |              ^
main.c:14:15: error: 'ch' undeclared here (not in a function); did you mean 'n_ch'?
   14 |       n_ch = [ch for ch in nokori][0]
      |               ^~
      |               n_ch
main.c:15:7: error: expected ',' or ';' before 'n_idx'
   15 |       n_idx = "RGB".index(n_ch)
      |       ^~~~~
Language: C

#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 

const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


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





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

#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c,d,i,j,k,ct=0;
cin>>a;
string arr;
cin>>arr;
c=arr.size();
for(i=0;i<c-2;i++)
{
    for(j=i+1;j<c-1;j++)
    {
        if(arr[j]!=arr[i])
        {
            for(k=j+1;k<c;k++)
            {
              if((arr[j]!=arr[k])&&(arr[i]!=arr[k])&&(k-j!=j-i))
                ct++;
            }
        }
    }



}

cout<<ct;
}


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

#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

int main() {
  string s;
  int n;
  ll ans = 0;
  vector<int> r, g, b;
  cin >> n >> s;
  rep(i, n) {
    if (s.at(i) == 'R') {
      r.push_back(i);
    }
    if (s.at(i) == 'G') {
      g.push_back(i);
    }
    if (s.at(i) == 'B') {
      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++) {
        int x, y, z;
        x = min(min(r.at(i), g.at(j)), b.at(k));
        y = max(max(r.at(i), g.at(j)), b.at(k));
        z = r.at(i) + g.at(j) + b.at(k) - x - y;
        if (2 * z != x + y) 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<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
ll ans;
int n;
const int N=1e5+5;
char s[N];
void dfs(int i,int j,int k){
	//printf("i=%d,j=%d,k=%d\n",i,j,k);
	if(k>n) return; 
	if(j-i!=k-j&&s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])
		ans++;
	if(k<n)
	dfs(i,j,k+1);
	if(k==n&&j+2<=n) dfs(i,j+1,j+2);
	if(j==n-1&&i+3<=n) dfs(i+1,i+2,i+3);
}
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	if(strlen(s+1)<3){
	 printf("0\n");
	 return 0;
	}	
	dfs(1,2,3);
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: 'strlen' was not declared in this scope
   22 |         if(strlen(s+1)<3){
      |            ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<cstdio>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C

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

int n;
string s;

int main() {
  	ios_base::sync_with_stdio(false);
  	cin.tie(nullptr);
  
	cin >> n >> s;

	s.insert(0, "#");

	long long ans = 0LL;
	
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			for (int k = j + 1; k <= n; k++) {
				if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k] && (j - i != k - j)) {
					++ans;
				}
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    string S;
    cin >> N >> S;
    ll sum = 0;
    rep(i, N) {
        for (int j = i + 1; j < N; j++) {
            if (S.at(i) == S.at(j)) continue;
            for (int k = j + 1; k < N; k++) {
                if (j - i == k - j) continue;
                if (S.at(i) != S.at(k) && S.at(j) != S.at(k)) sum++;
            }
        }
    }
    cout << sum << 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 <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;




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

    vector<int>R(n,0);
    vector<int>G(n,0);
    vector<int>B(n,0);
    ll r,g,b = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r++;
            R[i]=r;
            G[i]=g;
            B[i]=b;
        }
        if(s[i]=='G'){
            g++;
            R[i]=r;
            G[i]=g;
            B[i]=b;
        }
        if(s[i]=='B'){
            b++;
            R[i]=r;
            G[i]=g;
            B[i]=b;
        }
    }
    ll ans=0;

    // for(int i=0;i<n;i++){
    //     cout<<G[i]<<endl;
    // }


    for(ll j=1;j<n-1;j++){
        if(s[j]=='R'){
            ans+=(G[j-1] * (B[n-1]-B[j]));
            ans+=(B[j-1] * (G[n-1]-G[j]));
            for(ll i=1;i<=min(j,n-j-1);i++){
                if((s[j-i]=='B' && s[j+i]=='G') || (s[j-i]=='G' && s[j+i]=='B')){
                    ans--;
                }
            }
        }

        if(s[j]=='G'){
            ans+=(B[j-1] * (R[n-1]-R[j]));
            // cout<<ans<<endl;
            ans+=(R[j-1] * (B[n-1]-B[j]));
            // cout<<ans<<endl;
            for(ll i=1;i<=min(j,n-j-1);i++){
                if((s[j-i]=='B' && s[j+i]=='R') || (s[j-i]=='R' && s[j+i]=='B')){
                    ans--;
                }
            }
        }

        if(s[j]=='B'){
            ans+=(R[j-1] * (G[n-1]-G[j]));
            ans+=(G[j-1] * (R[n-1]-R[j]));
            for(ll i=1;i<=min(j,n-j-1);i++){
                if((s[j-i]=='G' && s[j+i]=='R') || (s[j-i]=='R' && s[j+i]=='G')){
                    ans--;
                }
            }
        }
        // cout<<"ans="<<ans<<endl;
    }

    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;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:18:68: error: expected ';' before 'continue'
   18 |         if(S.at(j - 1) == S.at(k - 1) || S.at(k - 1) == S.at(i - 1)
      |                                                                    ^
      |                                                                    ;
   19 |            continue;
      |            ~~~~~~~~                                                 
a.cc:20:11: error: expected primary-expression before 'if'
   20 |           if(j - i != k - j)
      |           ^~
a.cc:19:21: error: expected ')' before 'if'
   19 |            continue;
      |                     ^
      |                     )
   20 |           if(j - i != k - j)
      |           ~~         
a.cc:18:11: note: to match this '('
   18 |         if(S.at(j - 1) == S.at(k - 1) || S.at(k - 1) == S.at(i - 1)
      |           ^
a.cc: At global scope:
a.cc:26:3: error: 'cout' does not name a type
   26 |   cout << ans << endl;
      |   ^~~~
a.cc:27:1: error: expected declaration before '}' token
   27 | }
      | ^
Language: C++

using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int mid(int a, int b, int c){
  if(max(max(a,b),c)==a && min(min(a,b),c)==b)
    return c;
  if(max(max(a,b),c)==a && min(min(a,b),c)==c)
    return b;
  if(max(max(a,b),c)==b && min(min(a,b),c)==a)
    return c;
  if(max(max(a,b),c)==b && min(min(a,b),c)==c)
    return a;
  if(max(max(a,b),c)==c && min(min(a,b),c)==a)
    return b;
  if(max(max(a,b),c)==c && min(min(a,b),c)==a)
    return a;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  string S;
  int R[],G[],B[];
  cin>>S;
  ll ans=0;
  rep(i,N){
    if(S[i]=="R")
      R.push_back(i);
    if(S[i]=="G")
      G.push_back(i);
    if(S[i]=="B")
      B.push_back(i);
  }
  rep(i,R.length()){
  	rep(j,G.length()){
  		rep(k,B.length()){
          if(mid(R[i],G[j],B[k])-min(min(R[i],G[j]),B[k])!=-mid(R[i],G[j],B[k])+max(max(R[i],G[j]),B[k]))
            ans+=1;
        }
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:7: error: storage size of 'R' isn't known
   52 |   int R[],G[],B[];
      |       ^
a.cc:52:11: error: storage size of 'G' isn't known
   52 |   int R[],G[],B[];
      |           ^
a.cc:52:15: error: storage size of 'B' isn't known
   52 |   int R[],G[],B[];
      |               ^
a.cc:56:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   56 |     if(S[i]=="R")
a.cc:58:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   58 |     if(S[i]=="G")
a.cc:60:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   60 |     if(S[i]=="B")
a.cc: In function 'int mid(int, int, int)':
a.cc:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^
Language: C

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r_so_far[n], g_so_far[n], b_so_far[n];
	memset(r_so_far, 0, sizeof(r_so_far));
	memset(g_so_far, 0, sizeof(g_so_far));
	memset(b_so_far, 0, sizeof(b_so_far));
	int r = 0, g = 0, b = 0;
	for(int i = 0; i < n; i++){
	    if(s[i] == 'R'){
	        r++;
	        r_so_far[i] = r;
	    }
	    else if(s[i] == 'G'){
	        g++;
	        g_so_far[i] = g;
	    }
	    else if(s[i] == 'B'){
	        b++;
	        b_so_far[i] = b;
	    }
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
	    for(int j = i + 1; j < n; j++){
	        if(s[i] == s[j]){
	            continue;
	        }
	        if(s[i] == 'R' && s[j] == 'G'){
	            ans += (b_so_far[n - 1] - b_so_far[j]);
	            int diff = j - i;
	            if(j + diff < n && s[j + diff] == 'B'){
	                ans -= 1;
	            }
	        }
	        else if(s[i] == 'R' && s[j] == 'B'){
	            ans += (g_so_far[n - 1] - g_so_far[j]);
	            int diff = j - i;
	            if(j + diff < n && s[j + diff] == 'G'){
	                ans -= 1;
	            }
	        }
	        else if(s[i] == 'G' && s[j] == 'R'){
	            ans += (b_so_far[n - 1] - b_so_far[j]);
	            int diff = j - i;
	            if(j + diff < n && s[j + diff] == 'B'){
	                ans -= 1;
	            }
	        }
	        else if(s[i] == 'G' && s[j] == 'B'){
	            ans += (r_so_far[n - 1] - r_so_far[j]);
	            int diff = j - i;
	            if(j + diff < n && s[j + diff] == 'R'){
	                ans -= 1;
	            }
	        }
	        else if(s[i] == 'B' && s[j] == 'G'){
	            ans += (r_so_far[n - 1] - r_so_far[j]);
	            int diff = j - i;
	            if(j + diff < n && s[j + diff] == 'R'){
	                ans -= 1;
	            }
	        }
	        else if(s[i] == 'B' && s[j] == 'R'){
	            ans += (g_so_far[n - 1] - g_so_far[j]);
	            int diff = j - i;
	            if(j + diff < n && s[j + diff] == 'G'){
	                ans -= 1;
	            }
	        }
	    }
	}
	cout << ans << endl;
	return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  string S;
  cin >> N >> S;
  vector<vector<long>> data(N, vector<long>(3));
  for(int i = N - 1; i >= 0; i--){
    if(S.at(i) == 'R')data.at(i).at(0)++;
    else if(S.at(i) == 'G')data.at(i).at(1)++;
    else data.at(i).at(2)++;
    if(i != 0){
      data.at(i - 1).at(0) = data.at(i).at(0);
      data.at(i - 1).at(1) = data.at(i).at(1);
      data.at(i - 1).at(2) = data.at(i).at(2);
    }
  }
  long ans = 0;
  for(int i = 0; i < N - 2; i++){
    for(int j = i + 1; j < N - 1; j++){
      if(S.at(i) != S.at(j)){
        if(S.at(i) == 'R' && S.at(j) == 'G'){
          ans += data.at(j + 1).at(2);
        } else if(S.at(i) == 'G' && S.at(j) == 'R'){
          ans += data.at(j + 1).at(2);
        } else if(S.at(i) == 'G' && S.at(j) == 'B'){
          ans += data.at(j + 1).at(0);
        } else if(S.at(i) == 'B' && S.at(j) == 'G'){
          ans += data.at(j + 1).at(0);
        } else if(S.at(i) == 'R' && S.at(j) == 'B'){
          ans += data.at(j + 1).at(1);
        } else if(S.at(i) == 'B' && S.at(j) == 'R'){
          ans += data.at(j + 1).at(1);
        }
        if(2 * j - i >= 0 && 2 * j - i <= N - 1){
          if(S.at(i) != S.at(j) && S.at(j) != S.at(2 * j - i) && S.at(i) != S.at(2 * j - i))ans--;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

int main (){
  int n;cin>>n;
  string s;cin>>s;
  ll numR=0,numG = 0,numB = 0;
  rep(i,n){
    if (s.at(i) == 'R'){
      numR++;
    }
    else if (s.at(i) == 'G'){
      numG++;
    }
    else if (s.at(i) =='B'){
      numB ++;
    }
  }
  ll sum = 0;
  rep(i,n){
    for (int j = 1;j<=(n-i-1)/2;j++){
      if (s.at(i) != s.at(i+j) && s.at(i) != s.at(i + 2*j) && s.at(i+j) != s.at(i+2*j)){
        sum++;
      }
    }
  }
  cout << numR*numG*numB - sum << 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;


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n;


    string st;

    cin >> n >> st;




    ll count = 0;

    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            for(int k=j+1; k<n; k++)
            {
                if((st[i]!=st[j] && st[j]!=st[k] && st[i]!=st[k]) && (j-i)!=(k-j))
                {
                    count++;
                }
            }
        }
    }

    cout << count << 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 <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, n) for (size_t i = 0; i < (n); i++)
#define REP(n) FOR(i, n)
#define cinv(v, n) REP(n) {cin>>(v)[i];}
#define nvec(T, v, n) vector<T> v(n); cinv(v, n)
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
 
#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))
 
#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )
 
#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}
 
#define acm accumulate
#define pub push_back
#define pof pop_front
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
 
#define GCD(v) gcd(ALL(v), 0l)
 
template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}
 
 
 
int main(){
  int n; string s;
  cin>>n>>s;
  int r=0,g=0,b=0;
  long long count = 0;
  for (size_t in = 0; in < n; in++) {
 
    if(s[in]=='R'){
      r++;
      count+=g*b;
      for (int i = in-2; i >= 0; i-=2) {
        if(i<0)break;
        if((s[i]=='G'&&s[(i+in)/2]=='B') || (s[i]=='B'&&s[(i+in)/2]=='G')){
          count--;
        }
      }
    }
 
    if(s[in]=='G'){
      g++;
      count+=r*b;
      for (int i = in-2; i >= 0; i-=2) {
        if(i<0)break;
        if((s[i]=='R'&&s[(i+in)/2]=='B') || (s[i]=='B'&&s[(i+in)/2]=='R')){
          count--;
        }
      }
    }
 
    if(s[in]=='B'){
      b++;
      count+=g*r;
      for (int i = in-2; i >= 0; i-=2) {
        if(i<0)break;
        if((s[i]=='G'&&s[(i+in)/2]=='R') || (s[i]=='R'&&s[(i+in)/2]=='G')){
          count--;
        }
      }
    }
 
    
  }
  cout<<count;
}
 
 
 
 
 
 
/* きょむ〜 */

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

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n; string s;
    cin >> n >> s;
    struct st{
        ll r;
        ll g;
        ll b;
    };
    vector<st> sv(n);
    sv[0].r = 0; sv[0].g = 0; sv[0].b = 0;
    for(int i = 1; i < n; i++){
        sv[i].r = sv[i-1].r; sv[i].g = sv[i-1].g; sv[i].b = sv[i-1].b;
        if(s[i] == 'R') sv[i].r++;
        if(s[i] == 'G') sv[i].g++;
        if(s[i] == 'B') sv[i].b++;
    }
    ll ans = 0;
    for(int i = 0; i < n-3; i++){
        for(int j = i+1; j < n-1; j++){
            if(s[i] == s[j]) continue;
            if(s[i] != 'R' && s[j] != 'R'){ //s[k]は'R'
                ans += sv[n-1].r - sv[j].r;
                if(s[j + (j-i)] == 'R') ans--;
            }
            if(s[i] != 'G' && s[j] != 'G'){
                ans += sv[n-1].g - sv[j].g;
                if(s[j + (j-i)] == 'G') ans--;
            }
            if(s[i] != 'B' && s[j] != 'B'){
                ans += sv[n-1].b - sv[j].b;
                if(s[j + (j-i)] == 'B') ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}




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

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,c=0;
  string S;
  cin>>N;
  cin>>S;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        if(i>=j || j>=k) continue;
        if(2*j==i+k) continue;
        if(S[i] == S[j]) continue;
        if(S[k] == S[j]) continue;
        if(S[i] == S[k]) continue;
        c++;
      }
    }
  }
  cont<<c<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:3: error: 'cont' was not declared in this scope; did you mean 'const'?
   20 |   cont<<c<<endl;
      |   ^~~~
      |   const
Language: C

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



int main() {
  
  int N,count=0;
  string S;
  
  cin >> N >> S;
  
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      for(int k = 0;k < N;k++){
        if(S.at(i) != S.at(j) && S.at(j) != S.at(k) && S.at(i) != S.at(k) && (j - i) != (k-j) ){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
  
  
  

}


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

#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  string S;
  cin >> N >> S;
  vector<vector<long>> data(N, vector<long>(3));
  for(int i = N - 1; i >= 0; i--){
    if(S.at(i) == 'R')data.at(i).at(0)++;
    else if(S.at(i) == 'G')data.at(i).at(1)++;
    else data.at(i).at(2)++;
    if(i != 0){
      data.at(i - 1).at(0) = data.at(i).at(0);
      data.at(i - 1).at(1) = data.at(i).at(1);
      data.at(i - 1).at(2) = data.at(i).at(2);
    }
  }
  long ans = 0;
  for(int i = 0; i < N - 2; i++){
    for(int j = i + 1; j < N - 1; j++){
      if(S.at(i) != S.at(j)){
        if(S.at(i) == 'R' && S.at(j) == 'G'){
          ans += data.at(j + 1).at(2);
        } else if(S.at(i) == 'G' && S.at(j) == 'R'){
          ans += data.at(j + 1).at(2);
        } else if(S.at(i) == 'G' && S.at(j) == 'B'){
          ans += data.at(j + 1).at(0);
        } else if(S.at(i) == 'B' && S.at(j) == 'G'){
          ans += data.at(j + 1).at(0);
        } else if(S.at(i) == 'R' && S.at(j) == 'B'){
          ans += data.at(j + 1).at(1);
        } else if(S.at(i) == 'B' && S.at(j) == 'R'){
          ans += data.at(j + 1).at(1);
        }
        if(2 * j - i >= 0 && 2 * j - i <= N - 1){
          if(S.at(i) != S.at(j) && S.at(j) != S.at(2 * j - i) && S.at(i) != S.at(2 * j - i))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++

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

    ll ans =0 ;
    REP(i, 0, n){
        REP(j, i+1, n){
            REP(k, j+1, n){
                if(s[i] != s[j] and s[j] != s[k] and s[k] != s[i] and (j - i) != (k - j)){
                    ans += 1;
                }
            }
        }
    }

    p(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'string' was not declared in this scope
    3 |     string s;
      |     ^~~~~~
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> n >> s;
      |     ^~~
a.cc:4:17: error: 's' was not declared in this scope
    4 |     cin >> n >> s;
      |                 ^
a.cc:6:5: error: 'll' was not declared in this scope
    6 |     ll ans =0 ;
      |     ^~
a.cc:7:9: error: 'i' was not declared in this scope
    7 |     REP(i, 0, n){
      |         ^
a.cc:7:5: error: 'REP' was not declared in this scope
    7 |     REP(i, 0, n){
      |     ^~~
a.cc:17:7: error: 'ans' was not declared in this scope
   17 |     p(ans);
      |       ^~~
a.cc:17:5: error: 'p' was not declared in this scope
   17 |     p(ans);
      |     ^
Language: C

#include <bits/stdc++.h>

using namespace std;

int main() {
    int N, res = 0;
    string S;

    cin >> N;
    cin >> S;

    for (int i = 0; i < N - 2; ++i) {
        for (int j = i + 1; j < N - 1; ++j) {
            if (S[i] == S[j]) {
                continue;
            }

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

                res++;
            }
        }
    }

    cout << res;
    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() {
  
  int N,count=0;
  string S;
  
  cin >> N >> S;
  
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;J++){
      for(int k = 0;k < N;k++){
        if(S.at(i) != S.at(j) && S.at(j) != S.at(k) && S.at(i) != S.at(k) && (j - i) != (k-j) ){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
  
  
  

}

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

#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;


int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	rep(i,n-2){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				if (j-i==k-j)continue;
				if (s[i]==s[j]) continue;
				if (s[i]==s[k]) continue;
				if (s[k]==s[j]) continue;
				cnt++;

			}
		}
	}
	cout<<cnt;


}


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

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> r, g, b;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r.push_back(i);
        }
        if (s[i] == 'G') {
            g.push_back(i);
        }
        if (s[i] == 'B') {
            b.push_back(i);
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (s[i] == s[j]) continue;
            if (s[i] != 'R' && s[j] != 'R') {
                auto itr0 = upper_bound(r.begin(), r.end(), j);
                auto itr1 = lower_bound(r.begin(), r.end(), 2 * j - i);
                ans += itr1 - itr0;
                auto itr2 = upper_bound(r.begin(), r.end(), 2 * j - i);
                ans += r.end() - itr2;
            }
            if (s[i] != 'G' && s[j] != 'G') {
                auto itr0 = upper_bound(g.begin(), g.end(), j);
                auto itr1 = lower_bound(g.begin(), g.end(), 2 * j - i);
                ans += itr1 - itr0;
                auto itr2 = upper_bound(g.begin(), g.end(), 2 * j - i);
                ans += g.end() - itr2;
            }
            if (s[i] != 'B' && s[j] != 'B') {
                auto itr0 = upper_bound(b.begin(), b.end(), j);
                auto itr1 = lower_bound(b.begin(), b.end(), 2 * j - i);
                ans += itr1 - itr0;
                auto itr2 = upper_bound(b.begin(), b.end(), 2 * j - i);
                ans += b.end() - itr2;
            }
        }
    }
    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>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main(){
    int N;
    string S;
    cin >> N >> S;
    int R,G,B;
    R = G = B = 0;
    for (int i = 0; i < N; i++)
    {
        if(S[i] == 'R') R++;
        else if(S[i] == 'G') G++;
        else B++;
    }
    ll ans = R*G*B;
    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[k] != S[j]) 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>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  string s;
  cin >> n >>s;
  int ans=0;
  rep(i,n) {
    rep(j,n) {
      rep(k,n) {
        if((j-i)==(k-j)) continue;
        else if(s[i]==s[k]||s[i]==s[j]||s[k]==s[j]) continue;
        else ans++
      }
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:19: error: expected ';' before '}' token
   15 |         else ans++
      |                   ^
      |                   ;
   16 |       }
      |       ~
Language: C

#include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	string S;
	cin >> S;
	vector<int>R(N + 1, 0), G(N + 1, 0), B(N + 1, 0);
	for (int i = N - 1; i >= 0; i--) {
		if (S.at(i) == 'R') {
			R.at(i) = R.at(i + 1) + 1;
			B.at(i) = B.at(i + 1);
			G.at(i) = G.at(i + 1);
		}
		if (S.at(i) == 'B') {
			R.at(i) = R.at(i + 1);
			B.at(i) = B.at(i + 1) + 1;
			G.at(i) = G.at(i + 1);
		}
		if (S.at(i) == 'G') {
			R.at(i) = R.at(i + 1);
			B.at(i) = B.at(i + 1);
			G.at(i) = G.at(i + 1) + 1;
		}
	}
	long long ans = 0;
	int k = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			k = j + 1;
			int l = j + j - i;
			if (k >= N || S.at(i) == S.at(j)) continue;
			if (S.at(i) == 'R') {
				if (S.at(j) == 'B') {
					ans += G.at(k);
					if (l < N) {
						if (S.at(l) == 'G') ans--;
					}
				}
				else {
					ans += B.at(k);
					if (l < N) {
						if (S.at(l) == 'B') ans--;
					}
				}
			}
			else if (S.at(i) == 'G') {
				if (S.at(j) == 'R') {
					ans += B.at(k);
					if (l < N) {
						if (S.at(l) == 'B') ans--;
					}
				}
				else {
					ans += R.at(k);
					if (l < N) {
						if (S.at(l) == 'R') ans--;
					}
				}
			}
			else if (S.at(i) == 'B') {
				if (S.at(j) == 'R') {
					ans += G.at(k);
					if (l < N) {
						if (S.at(l) == 'G') ans--;
					}
				}
				else {
					ans += R.at(k);
					if (l < N) {
						if (S.at(l) == 'R') ans--;
					}
				}
			}
		}
	}
	cout << ans << endl;
 }

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

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

int main()
{
  int n;
  string s;

  cin >> n >> s;
  ll ans = 0;

  char co[3];

  int i = 0, j = 0, k = 0;
  while(i < n){
    co[0] = s[i];
    j = i + 1;
    while(j < n){
      if(co[0] != s[j]){
        co[1] = s[j];
        k = j + 1;
        while(k < n){
          if(co[0] != s[k] && co[1] != s[k]){
            if(j - i != k - j){
              ans++;
            }
          }
          k++;
        }
      }
      j++;
    }
    i++;
  }

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

#define rep(i, n) for(lli i = 0; i < (lli)(n); i++)

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
lli n;
string s;
lli cr, cg, cb;
lli sub;

int main(void){
    //int ti = clock();
    cin >> n >> s;
    cr = cg = cb = sub = 0;
    rep(i, n){
        if(s[i] == 'R') cr++;
        else if(s[i] == 'G') cg++;
        else cb++;
    }
    for(int i = 0; i < n; i++){
        for(int k = 1; i+2*k < n; k++){
            if(s[i] != s[i+k] && s[i+k] != s[i+2*k] && s[i+2*k] != s[i]) sub++;
        }
    }
    cout << cr*cg*cb-sub << endl;
    //cout << fixed << setprecision(10) << 1.0*(clock()-ti)/CLOCKS_PER_SEC << 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<iostream>
#include<stdio.h>
#define ll long long
#define oo 1000000010
using namespace std;

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

	int n, ans = 0;
	cin >> n;
	string s;
	cin >> s;
	for(int i=0; i<n; i++){
		int l = i + 1, r = i + 2, cntR = 0, cntG = 0, cntB = 0;
		for(int j=i+1; j<n; j++){
			if(s[j] == 'R') cntR++;
			if(s[j] == 'G') cntG++;
			if(s[j] == 'B') cntB++;
		}
		if(s[i] == 'R'){
			ans += cntG*cntB;
			while(r < n){
				if(s[i] != s[r] && s[i] != s[l] && s[r] != s[l]) ans--;
				l++, r+=2;
			}
		}
		else if(s[i] == 'G'){
			ans += cntR*cntB;
			while(r < n){
				if(s[i] != s[r] && s[i] != s[l] && s[r] != s[l]) ans--;
				l++, r+=2;
			}
		}
		else if(s[i] == 'B'){
			ans += cntG*cntR;
			while(r < n){
				if(s[i] != s[r] && s[i] != s[l] && s[r] != s[l]) ans--;
				l++, r+=2;
			}
		}
	}
	cout << ans;

	return 0;
}


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

n = int(input())
S = input()
patterns = ["RGB","RBG","GBR","GRB","BRG","BGR"]
anss = [ [0] * (n + 1) for _ in range(n+1)]
acc  = [ [0] * (n + 1) for _ in range(n+1)]
ans = 0
for pattern in patterns:
    c1 = pattern[0]
    c2 = pattern[1]
    c3 = pattern[2]
    cands = []
    #i c1の位置で
    for i1 in range(n):
        for i2 in range(i1 + 1,n):
            if S[i1] == c2 and S[i2] == c3:
                cands.append((i1,i2-i1))
    # anss[i1][i2-i1]→左をi1に固定したときの、距離i2-i1の組の個数

    for  i in range(0,n):
        if S[i] == c1:
            for cand in cands:
                if  cand[0] - i  != cand[1] and cand[0] > i:
                    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:5: error: expected expression before 'int'
    1 | n = int(input())
      |     ^~~
main.c:12:6: error: invalid preprocessing directive #i; did you mean #if?
   12 |     #i c1の位置で
      |      ^
      |      if
main.c:17:7: error: invalid preprocessing directive #anss
   17 |     # anss[i1][i2-i1]→左をi1に固定したときの、距離i2-i1の組の個数
      |       ^~~~
Language: Java


import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;
import com.sun.xml.internal.ws.message.ByteArrayAttachment;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    long sum = 0;
    String[] s = scanner.next()
        .split("");

    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        int dist = -1;
        final String c1 = s[i];
        final String c2 = s[j];
        if (!s[i].equals(s[j])) {
          dist = j - i;
          sum += Stream.of(s)
              .skip(j)
              .filter(e -> !e.equals(c1) && !e.equals(c2))
              .count();
          if(j + dist < n && !s[j+dist].equals(c1) && !s[j+dist].equals(c2)) {
            sum--;
          }
        }
      }
    }
    System.out.println(sum);
  }
}


Compiler output:
Main.java:6: error: package com.sun.xml.internal.ws.message does not exist
import com.sun.xml.internal.ws.message.ByteArrayAttachment;
                                      ^
1 error
Language: C

#include <bits/stdc++.h>
using namespace std;
int main (){
  int i,j,k,t=0;
  int n;
  char a,b,c;
  string s;
  cin>>n>>s;
  for(i=1;i<=n-2;i++){
    //cout<<1;
    for(j=i+1;j<=n-1;j++){
      //cout<<2;
      for(k=j+1;k<=n;k++){
        a=s[i-1];b=s[j-1];c=s[k-1];
        //cout<<a<<b<<c<<j-1<<k-j;
        if((a!=b&&b!=c&&a!=c)&&(j-i)!=(k-j)){
          t++;
        }
      }
    }
  }
  cout<<t<<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.