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

#include <iostream>
using namespace std;

int n, all[3], cnt[3];
string s;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n >> s;
  for (char c: s) ++all[c%3];
  // B R G
  //
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ++cnt[s[i] % 3];
    ans += cnt[(s[i]+1)%3] * (all[(s[i]+2)%3]-cnt[(s[i]+2)%3]);
    ans += cnt[(s[i]+2)%3] * (all[(s[i]+1)%3]-cnt[(s[i]+1)%3]);
    for (int j = 0; 0 <= i - j && i + j < n; ++j) {
      if (s[i - j] != s[i] && s[i] != s[i + j] && s[i - j] != s[i + j]) --ans;
    }
  }
  cout << ans;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'll' was not declared in this scope; did you mean 'all'?
   13 |   ll ans = 0;
      |   ^~
      |   all
a.cc:16:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |     ans += cnt[(s[i]+1)%3] * (all[(s[i]+2)%3]-cnt[(s[i]+2)%3]);
      |     ^~~
      |     abs
a.cc:22:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |   cout << ans;
      |           ^~~
      |           abs
Language: C

        #include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18
 
        bool check(int n,int k){
            while(n%k==0){
                n=n/k;
            }
            return n%k==1;
        }
        
        signed main() {

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n;
        cin>>n;
        string s;
        cin>>s;
        int r=0,b=0,g=0;
        for(int i=0;i<s.length();i++){
            if(s[i]=='R')r++;
            if(s[i]=='B')b++;
            if(s[i]=='G')g++;
        }

        int ans=r*b*g;
        int k=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){

                if(s[i]!=s[j] && 2*j-i<n){
                    if(s[i]!=s[2*j-i]&&s[j]!=s[2*j-i])k++;
                }
            }
        }
        cout<<ans-k;


        return 0;
    }

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

/*input
39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
map<char,indexed_set> mp;
char asd[]={'R','G','B'};
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    REP(i,n) mp[s[i]].insert(i);
    ll ans=0;
    REP(i,n){
        for(int j=i+1;j<n;j++){
            if(s[i]==s[j]) continue;
            char nd='Z';
            REP(k,3){
                if(asd[k]!=s[i] and asd[k]!=s[j]) nd=asd[k];
            }
            assert(nd!='Z');
            int cnt=mp[nd].size()-mp[nd].order_of_key(j);
            if(mp[nd].find(j+(j-i))!=mp[nd].end()) --cnt;
            ans+=cnt;
        }
    }
    cout<<ans;
}

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 int long long
using namespace std;

signed main(){
	int N; string S; cin>>N>>S;
	vector<int> v(3,0);
	for(int i=0;i<N;i++){
		v[(S[i]-'0')%3]++;
	}
	int ans=v[0]*v[1]*v[2];
	for(int i=0;i<N-1;i++){
		for(int j=i;j<N;j++){
			int d=j-i,now=j+d;
			if(now<N){
				if(S[i]!=S[j] and S[i]!=S[now] and S[j]!=S[now])ans--;
			}
		}
	}
	cout<<ans<<endl;
}

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

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

int main() {
  int N,count=0;
  cin>>N;
  vector<char> S(N);
  rep(i,N){cin>>S[i];}
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      for(int k=1;k<=N;k++){
        if(!(i<j&&j<k)){continue;}
        else if(!((j-i)==(k-j))){
          if(!(S[i-1]==S[j-1])&&!(S[i-1]==S[k-1])&&!(S[j-1]==S[k-1])){
            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>
#define ll long long
#define ull unsigned long long
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pb push_back
#define maxn 100005
using namespace std;

int main()
{
    int l, b = 0;
    string s;

    cin >> l >> s;

    vector < int > r, g;
    map < int, bool > mp;

    for(int i = 0; i < l; i++){
        if(s[i] == 'R') r.pb(i);
        else if(s[i] == 'G') g.pb(i);
        else b++, mp[i] = 1;
    }

    int rs = r.size(), gs = g.size();
    ll ans = 0;

    for(int i = 0; i < rs; i++){
        for(int j = 0; j < gs; j++){
            int tmp = abs(r[i] - g[j]);

            ans += b;

            if(mp[r[i] + tmp]) ans--;
            if(mp[r[i] - tmp]) ans--;
            if(mp[g[j] + tmp]) ans--;
            if(mp[g[j] - tmp]) ans--;
            if((r[i] + g[j]) % 2 == 0 && mp[(r[i] + g[j]) / 2]) 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<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int N; string S;
    cin >> N >> S;
    set<int> r,g,b;
    for(int i=0; i<N; i++){
        if(S[i] == 'R') r.insert(i)
        else if(S[i] == 'G') g.insert(i)
        else (S[i] == 'B') b.insert(i)
    }
    ll ans = r.size()*g.size()*b.size();
    for(int i=1; i<=N; i++){
        for(int j=i+1; j<=N; j++){
            ll k = 2*j-i;
            if(k>N) break;
            set<char> x;
            x.insert(i-1);
            x.insert(j-1);
            x.insert(k-1);
            if(x.size() == 3) ans--;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:36: error: expected ';' before 'else'
   26 |         if(S[i] == 'R') r.insert(i)
      |                                    ^
      |                                    ;
   27 |         else if(S[i] == 'G') g.insert(i)
      |         ~~~~
Language: C


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N;
  std::string S;
  std::cin >> N >> S;
  int count[3] = {};
  for (char c: S) {
    ++count[c % 3];
  }
  long long ans = (long long) count[0] * count[1] * count[2];
  for (int i: range(0, N)) {
    for (int j: range(0, N + 1)) {
      if (i - j >= 0 && i + j < N) {
        if (S[i - j] != S[i] && S[i] != S[i + j] && S[i - j] != S[i + j]) {
          --ans;
        }
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

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

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

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

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=4e3+5;
char s[N];
int main() {
    int n;
    scanf("%d%s",&n,s);
    int a=0,b=0,c=0;
    for(int i=0;i<n;i++) {
        if(s[i]=='R') a++;
        if(s[i]=='G') b++;
        if(s[i]=='B') c++;
    }
    ll ans=1LL*a*b*c;
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            if(s[i]==s[j]) continue;
            if(2*j-i<n&&s[i]!=s[2*j-i]&&s[j]!=s[2*j-i]) ans--;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

D.cpp

Compiler output:
a.cc:26:1: error: 'D' does not name a type
   26 | D.cpp
      | ^
Language: C

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

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

int N;
string S;

void solve() {
    cin >> N >> S;
    int64_t count = 0;
    vector<int64_t> R(N + 1), G(N + 1), B(N + 1);
    R.at(0) = 0;
    G.at(0) = 0;
    B.at(0) = 0;

    rep(i, N) {
        if (S.at(i) == 'R') {
            R.at(i + 1) = R.at(i) + 1;
            G.at(i + 1) = G.at(i);
            B.at(i + 1) = B.at(i);
        }
        else if (S.at(i) == 'G') {
            R.at(i + 1) = R.at(i);
            G.at(i + 1) = G.at(i) + 1;
            B.at(i + 1) = B.at(i);
        }
        else {
            R.at(i + 1) = R.at(i);
            G.at(i + 1) = G.at(i);
            B.at(i + 1) = B.at(i) + 1;
        }
    }

    rep(i, N) {
        for (int j = i + 1; j < N; j++) {
            if (S.at(i) != S.at(j)) {
                if ((S.at(i) == 'R' && S.at(j) == 'G') || (S.at(i) == 'G' && S.at(j) == 'R')) {
                    count += (B.at(N) - B.at(j));
                }
                else if ((S.at(i) == 'R' && S.at(j) == 'B') || (S.at(i) == 'B' && S.at(j) == 'R')) {
                    count += (G.at(N) - G.at(j));
                }
                else {
                    count += (R.at(N) - R.at(j));
                }
                if (2 * j - i < N) {
                    if (S.at(2 * j - i) != S.at(i) && S.at(2 * j - i) != S.at(j)) {
                        count--;
                    }
                }
            }
        }
    }

    cout << count << endl;
    return;
}

int main() {
    solve();
}


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 <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	long long r = 0, g = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			r++;
		}
		else if (s[i] == 'G') {
			g++;
		}
		else {
			b++;
		}
	}
	long long co = 0;
	for (int j = 0; j < n; j++) {
		for (int k = j + 1; k < n; k++) {
			if (k + k - j >= n) {
				continue;
			}
			else {
				if (s[j] != s[k] && s[j] != s[k + k - j] && s[k] != s[k + k - j]) {
					co++;
				}
			}
		}
	}
	cout << r * g * b - co << endl;
	return 0;
}

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

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

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

int main(void){
    int n; cin >> n;
    string s; cin >> s;
    
    int r_cnt = 0;
    int g_cnt = 0;
    int b_cnt = 0;
    
    for(int i = 0; i < n; i++){
        if(s.at(i) == 'R') r_cnt++;
        if(s.at(i) == 'G') g_cnt++;
        if(s.at(i) == 'B') b_cnt++;
    }
    
    int total = r_cnt * g_cnt * b_cnt;
    
    for(int i = 0; i < n-2; i++){
        for(int j = i + 1; j < n-1; j++){
            int k = 2*j - i;
            if(k > n-1){
                continue;
            }
            if((s.at(i) != s.at(j)) && (s.at(i) != s.at(k)) && (s.at(j) != s.at(k))){
                total--;
            }
        }
    }
    
    cout << total << 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;

int main(){
    ll n,ans=0;
    string s;
    cin>>n>>s;
    for(ll i=0; i<n; i++) {
        for(ll j=0; j<i; j++) {
            if(s[i]==s[j]) continue;
            for(ll k=0; k<j; k++) {
                if(s[j] != s[k] && s[i] != s[k] && 2*j-i != k) ans++;
            }
        }
    }
    cout<<ans;
}

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

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define NMAX 4002
using namespace std;
int main(){
  long long N,ans = 0;
  char S[NMAX];
  vector<int> v[3];
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    cin >> S[i];
    if(S[i] == 'R') v[0].push_back(i);
    else if(S[i] == 'G') v[1].push_back(i);
    else if(S[i] == 'B') v[2].push_back(i);
  }
  for (int i = 0; i < v[0].size(); ++i)
  {
    for (int j = 0; j < v[1].size(); ++j)
    {
      int num = 0;
      if(find(v[2].begin(), v[2].end(),(v[0][i]*2-v[1][j])) != v[2].end()) num++;
      if(find(v[2].begin(), v[2].end(),(v[1][j]*2-v[0][i])) != v[2].end()) num++;
      if(find(v[2].begin(), v[2].end(),(v[0][i]+v[1][j])/2) != v[2].end() && (v[0][i]+v[1][j])%2 == 0) num++;
      ans += v[2].size() - num;
    }
  }
  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 <string>
#include <algorithm>

using namespace std;




int n;
string s;
int r,g,b;
long long res;
  
int main() {



  cin >>n>> s;

  
  for(char c : s){
    switch(c){
    case 'R': r++;break;
    case 'G': g++;break;
    case 'B': b++;break;
    }
  }

  res = r*g*b;

  
  for(int i=0 ; i<n ; i++){
    for(int j=i+1 ; j<n ; j++){
      
      int k = 2*j-i;
      
      if(i<j &&b j<k && k<n && (s[i]^s[j]^s[k]) == ('R'^'G'^'B'))
	res--;
   
    }
  }

  cout << res << endl;
  
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: expected ')' before 'j'
   38 |       if(i<j &&b j<k && k<n && (s[i]^s[j]^s[k]) == ('R'^'G'^'B'))
      |         ~       ^~
      |                 )
Language: C

#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define MOD 1000000007
#define mod 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2*1e9


int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<pair<int,pair<int,int> > >v(n);
    pair<int,pair<int,int> >p=make_pair(0,make_pair(0,0));
    for(int i=n-1;i>-1;i--)
    {
        if(s[i]=='R')
            p.first+=1;
        else if(s[i]=='G')
            p.second.first+=1;
        else
            p.second.second+=1;
        v[i]=p;
    }
    lli ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(s[i]=='R')
            {
                if(s[j]=='G')
                {
                    ans+=v[j].second.second;
                    int diff=j-i;
                    int ind=j+diff;
                    if(ind<n and s[ind]=='B')
                        ans-=1;
                }
                else if(s[j]=='B')
                {
                    ans+=v[j].second.first;
                    int diff=j-i;
                    int ind=j+diff;
                    if(ind<n and s[ind]=='G')
                        ans-=1;
                }
            }
            else if(s[i]=='G')
            {
                if(s[j]=='R')
                {
                    ans+=v[j].second.second;
                    int diff=j-i;
                    int ind=j+diff;
                    if(ind<n and s[ind]=='B')
                        ans-=1;
                }
                else if(s[j]=='B')
                {
                    ans+=v[j].first;
                    int diff=j-i;
                    int ind=j+diff;
                    if(ind<n and s[ind]=='R')
                        ans-=1;
                }
            }
            else if(s[i]=='B')
            {
                if(s[j]=='R')
                {
                    ans+=v[j].second.first;
                    int diff=j-i;
                    int ind=j+diff;
                    if(ind<n and s[ind]=='G')
                        ans-=1;
                }
                else if(s[j]=='G')
                {
                    ans+=v[j].first;
                    int diff=j-i;
                    int ind=j+diff;
                    if(ind<n and s[ind]=='R')
                        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;
 
int main(){
  int N;
  cin>>N;
  char p[4000];
  string S;
  cin>>S;
  int ans=0;
  int rn=0;
  int gn=0;
  int bn=0;
  for(int i=0;i<N;i++){
    p[i]=S.at(i);
    if(S.at(i)=='R') rn++;
    if(S.at(i)=='G') gn++;
    if(S.at(i)=='B') bn++;
  }
  ans=rn*gn*bn;
  int minus=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=((N-i-1)/2);j++){
      //N-iだとエラー　
      if (p[i]!=p[i+j] && p[i+j]!=p[i+j+j] && p[i+j+j]!=p[i]){
        //cout<<i<<" "<<j<<endl;
        minus++;
      }
    }
  }
  //cout<<rn<<" "<<gn<<" "<<ans<<" "<<minus<<endl;
  cout<<ans-minus<<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>
typedef long long ll;
using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;string s;
    cin >> n >> s;
    ll r=0,g=0,b=0;
    for(char t:s){
        if(t=='R')r++;
        else if(t=='G')g++;
        else b++;
    }
    //条件1を満たす組の数
    ll ans1 = r*g*b;
    ll ans2 = 0;
    REP(i,n-2){
        FOR(j,i+1,n-1){
            if (s[i]==s[j]) continue;
            int k = 2*j-i;
            if(k>=n||s[i]==s[k]||s[j]==s[k])continue;
            ans2++;
        }
    }
    COUT(ans1-ans2);
    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>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

// 3乗で通したお詫びにO(NlogN)で通します
// 参考 : https://twitter.com/SayakaAmemiya/status/1249515024541859842

template<int mod, int proot> struct NTT {
	int get_mod() { return mod; }
	int pow(int a, int b) {
	int res = 1;
		for (; b; b >>= 1) {
			if (b & 1) res = (int64_t) res * a % mod;
			a = (int64_t) a * a % mod;
		}
		return res;
	}
	int inv(int i) { return pow(i, mod - 2); }
	void ntt(std::vector<int> &a, bool inverse) {
		int n = a.size();
		assert((n & -n) == n);
		int h = pow(proot, (mod - 1) / n);
		if (inverse) h = inv(h);
		
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k > (i ^= k); k >>= 1);
			if (j < i) std::swap(a[i], a[j]);
		}
		for (int i = 1; i < n; i <<= 1) {
			int base = pow(h, n / i / 2);
			int w = 1;
			
			std::vector<int> ws(i);
			for (int j = 0; j < i; j++) ws[j] = w, w = (int64_t) w * base % mod;
			
			for (int j = 0; j < n; j += i << 1) {
				for (int k = 0; k < i; k++) {
					int u = a[k + j];
					int d = (int64_t) a[k + j + i] * ws[k] % mod;
					a[k + j] = u + d >= mod ? u + d - mod : u + d;
					a[k + j + i] = d > u ? u + mod - d : u - d;
				}
			}
		}
		if (inverse) {
			int ninv = inv(a.size());
			for (auto &i : a) i = (int64_t) i * ninv % mod;
		}
	}
};

int main() {
	int n = ri();
	int back[3] = { 0 };
	int forward[3] = { 0 };
	std::vector<int> a(n);
	{
		char tmp[4096];
		scanf("%s", tmp);
		for (int i = 0; i < n; i++) {
			a[i] = tmp[i] == 'R' ? 0 : tmp[i] == 'G' ? 1 : 2;
			back[a[i]]++;
		}
	}
	
	int64_t res = 0;
	// j - i != k - jを無視したの
	for (int j = 0; j < n; j++) {
		back[a[j]]--;
		res += forward[(a[j] + 1) % 3] * back[(a[j] + 2) % 3];
		res += forward[(a[j] + 2) % 3] * back[(a[j] + 1) % 3];
		forward[a[j]]++;
	}
	// j - i == k - jで相異なるものを引く
	int n2 = 1;
	for (; n2 < n + n - 1; n2 <<= 1);
	NTT<40961, 3> ntt;
	std::vector<int> count[3];
	for (auto &i : count) i.resize(n2);
	for (int i = 0; i < n; i++) count[a[i]][i]++;
	for (auto &i : count) ntt.ntt(i, false);
	
	std::vector<int> conved[3]; // conved count[i], count[(i + 1) % 3]
	for (int i = 0; i < 3; i++) {
		auto &cur = conved[i];
		cur.resize(n2);
		for (int j = 0; j < n2; j++) cur[j] = (int64_t) count[i][j] * count[(i + 1) % 3][j] % 40961;
		ntt.ntt(cur, true);
	}
	for (int j = 0; j < n; j++) res -= conved[(a[j] + 1) % 3][j + j];
	
	printf("%" PRId64 "\n", 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++

n=int(input())
s=input()

r=s.count('R')
g=s.count('G')
b=s.count('B')

ans=r*g*b
for i in range (n):
  for d in range (n):
    j=i+d
    k=j+d
    if k>=n:
      break
    if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
      ans-=1

print(ans)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n=int(input())
      | ^
Language: C++

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

int main () {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  for(int i=0; i < n-2; ++i) {
    for(int j=i+1;  j < n-1; ++j) {
      for(int k=j+1; k < n; ++k) {
        if (s[i] == s[j] or s[j] == s[k] or s[k] == s[i]) contine;
        if (j-i == k-j) contine;
        cnt++;
      }
    }
  }
  cout << cnt;
}
        

Compiler output:
a.cc: In function 'int main()':
a.cc:13:59: error: 'contine' was not declared in this scope
   13 |         if (s[i] == s[j] or s[j] == s[k] or s[k] == s[i]) contine;
      |                                                           ^~~~~~~
a.cc:14:25: error: 'contine' was not declared in this scope
   14 |         if (j-i == k-j) contine;
      |                         ^~~~~~~
Language: C++

#include<iostream>
using namespace std;
int main()
{
	int i,j,k,ans=0,n;
	cin >> n;
  long num[n],r[n]={0},g[n]={0},b[n]={0};
  string s;
	cin >> s;

  for (i = 0; i < n; i++) {
    if (s[i]=="R") num[i]=2;
    if (s[i]=="G") num[i]=3;
    if (s[i]=="B") num[i]=5;
  }
  for (i = n-1; i > 0; i--) {
    if (s[i]=="R") r[i-1]++;
    if (s[i]=="G") g[i-1]++;
    if (s[i]=="B") b[i-1]++;
  }

  for (i = 0; i < n-4; i++) {
    for (j = i+1; j < n-2; j++) {
      if (num[i]+num[j]==5){
        ans+=b[j];
        if (num[j+i]==5) ans--;
      }
      if (num[i]+num[j]==7){
        ans+=g[j];
        if (num[j+i]==3) ans--;
      }
      if (num[i]+num[j]==8){
        ans+=r[j];
        if (num[j+i]==2) ans--;
      }
    }
  }
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |     if (s[i]=="R") num[i]=2;
a.cc:13:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 |     if (s[i]=="G") num[i]=3;
a.cc:14:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |     if (s[i]=="B") num[i]=5;
a.cc:17:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |     if (s[i]=="R") r[i-1]++;
a.cc:18:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   18 |     if (s[i]=="G") g[i-1]++;
a.cc:19:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   19 |     if (s[i]=="B") b[i-1]++;
Language: C

/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    string s;
    cin >> n >> s;
    ll r = 0, g = 0, b = 0;
    forn(i, n) {
        r += s[i] == 'R', g += s[i] == 'G', b += s[i] == '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 && s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ans--;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 4010, M = 1010;

int n, cnt;
char s[N];

int check(int i, int j)
{
	if (s[i] == 'R' && s[j] == 'G' || s[i] == 'G' && s[j] == 'R')
	{
		int c = cnt, d = j - i;
		if (i - d >= 0 && s[i - d] == 'B') c -- ;
		if (j + d < n && s[j + d] == 'B') c -- ;

		d = (i + j) / 2;
		if (d - i == j - d && s[d] == 'B') c -- ;
		return c;
	}
	else return 0;
}

void solve()
{ 
	scanf("%d%s", &n, s);

	for (int i = 0; i < n; i ++ )
		if (s[i] == 'B')
			cnt ++ ;

	LL res = 0;
	for (int i = 0; i < n; i ++ )
		for (int j = i + 1; j < n; j ++ )
			res += check(i, j);

	printf("%lld\n", res);
}

int main()
{
	int T = 1;
	// scanf("%d", &T);
	// cin >> T;
	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 <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)
int main() {
	int n;
	string s;

	cin >> n >> s;
	int r=0;
	int g=0;
	int b=0;
	long long cnt;
	rep(i,n){
		if (s[i]=='R') r++;
		if (s[i]=='G') g++;
		if (s[i]=='B') b++;
	}
	cnt=r*g*b;
//	cout <<"r="<<r<<" g="<<g<<" b="<<b<<endl;
//	cout <<cnt<<endl;
	for(int i=1;i<n/2;i++){
		for(int j=0;j<n;j++){
			if (j+2*i<n){
				if(s[j]==s[j+i]||s[j]==s[j+i*2]||s[j+i]==s[j+i*2]){
					cnt--;
//					cout << "j=" << j << " j+i=" << j+i << " j+2i="  << j+2*i <<endl;
				}
			}
		}
	}
	cout <<cnt<<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>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define M 4100

int main() {
  int N, i, j, k;
  ll num=0;
  string S;
  cin >> N >> S;
  vector<int> r(N, -1);
  vector<int> g(N, -1);
  vector<int> b(N, -1);

  int x=0, y=0, z=0;
  rep(i, N){
    if (S.at(i) == 'R') {
      r.at(x++) = i;
    }else if (S.at(i) == 'G') {
      g.at(y++) = i;
    }else if (S.at(i) == 'B'){
      b.at(z++) = i;
    }
  }
  const int R = x;
  const int G = y;
  const int B = z;
  int sub=0;
  rep(x, R) {
    rep (y, G) {
      int rr=r.at(x), gg=g.at(y);
      i = rr < gg ? rr : gg;
      j = rr < gg ? gg : rr;
      k = j + (j - i);
      if (0 <= k && k < S.size() && S.at(k) == 'B'){
        sub ++;
      }
      k = (i + j) / 2;
      if ((i+j)%2 == 0 && 0 <= k && k < S.size() && S.at(k) == 'B'){
        sub ++;
      }
      k = i - (j - i);
      if (0 <= k && k < S.size() && S.at(k) == 'B'){
        sub ++;
      }

    }
  }
  num = R*G*B - sub;
  cout << num << 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;
	cin >> N;
	vector<char> S(N);
	int ans = 0;

	for(int i = 0; i < N; i++){
		cin >> S[i];
	}

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

	cout << "\n" << ans;


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:2: error: expected '}' at end of input
   32 | }
      |  ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C

//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {


    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    long long r=0, g=0, b=0;
    
    for(int i=0; i<n; i++)
    {
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else if(s[i] == 'B') b++;
    }
    
    // すべての組み合わせの数
    long long con1 = r * g * b;
    
    for(int i=0; i<n; i++)
    {
        for(int j=1; i+j+j<n; j++)
        {
            if(s[i] != s[i+j] && s[i+j] != s[i+j+j] && s[i] != s[i+j+j]) con1--;
        }
    }
    
    cout << con1 << endl;
    
    return 0;
}


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

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

int main(){
   int N;
   string S;
   cin >> N >> S;
   int r=0;
   int g=0;
   int b=0;

   ll r=0, g=0, b=0;
   for (auto c : S){
      if (c=='R') r++;
      if (c=='G') g++;
      if (c=='B') b++;
   }
   ll sum = r*g*b;

   for(int i=0;i<N-2;i++){
      for(int j=i+1;(2*j-i)<N;j++){
         int k = 2*j-i;
         if(k<N){
            if((S[k] != S[i]) and (S[k] != S[j]) and (S[i] != S[j])){
               sum--;
            }
         }
      }
   }
   cout << sum << endl;
   return 0;  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:7: error: conflicting declaration 'll r'
   15 |    ll r=0, g=0, b=0;
      |       ^
a.cc:11:8: note: previous declaration as 'int r'
   11 |    int r=0;
      |        ^
a.cc:15:12: error: conflicting declaration 'll g'
   15 |    ll r=0, g=0, b=0;
      |            ^
a.cc:12:8: note: previous declaration as 'int g'
   12 |    int g=0;
      |        ^
a.cc:15:17: error: conflicting declaration 'll b'
   15 |    ll r=0, g=0, b=0;
      |                 ^
a.cc:13:8: note: previous declaration as 'int b'
   13 |    int b=0;
      |        ^
Language: C

#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

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

    //cout<<"r.size()="<<r.size()<<endl;
    //cout<<"g.size()="<<g.size()<<endl;
    //cout<<"b.size()="<<b.size()<<endl;

    int rl=r.size();
    int gl=g.size();
    int bl=b.size();

	for(int i=0;i<rl;i++){
		for(int j=0;j<gl;j++){
            int x=r[i],y=g[j];
            int cnt=bl;
            auto b1=lower_bound(b.begin(),b.end(),2*y-x);
            auto b2=lower_bound(b.begin(),b.end(),(x+y)/2);
            auto b3=lower_bound(b.begin(),b.end(),2*x-y);
            if(b[distance(b.begin(),b1)]==2*y-x&&b1!=b.end()){
                cnt--;
                //cout<<r[i]<<","<<g[j]<<","<<*b1<<endl;
            }
            if(b[distance(b.begin(),b2)]==(x+y)/2&&(x+y)%2==0&&b2!=b.end()){
                cnt--;
                //cout<<r[i]<<","<<g[j]<<","<<*b2<<endl;
            }
            if(b[distance(b.begin(),b3)]==2*x-y&&b3!=b.end()){
                cnt--;
                //cout<<r[i]<<","<<g[j]<<","<<*b3<<endl;
            }
            ans+=cnt;
        }
    }
    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>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define cout(v) REP(i,v.size()) cout << v[i] << " "; cout << endl;
using namespace std;
using Graph = vector<vector<int>>;
 
int main(){
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  REP(i,n-2){
    FOR(j,i+1,n-1){
      FOR(k,j+1,n){
        if(s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k] && j-i!=k-j){
          ans++;
        }
      }
    }
  }
  cout << ans;
}

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

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int r=0;
  int g=0;
  int b=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      r++;
    }else if(S.at(i)=='G'){
      g++;
    }else{
      b++;
    }
  }
  int64_t ans=r*g*b;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S.at(i)==S.at(j)){
        continue;
      }
      int k=2*j-i;
      if(k>=N){
        break;
      }
      if((S.at(i)!=S.at(k))&&(S.at(j)!=S.at(k))){
        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

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

R = 0
G = 0
B = 0

# R,G,Bの数を数える
for i in range(N):
    if S[i] == 'R':
        R += 1
    elif S[i] == 'G':
        G += 1
    else:
        B += 1
    
# 等間隔で(R,G,B)の組み合わせとなっている数を数える
# 間隔(step)は1～1999のいずれか
count = 0
for step in range(1,2000):
    start = 0
    while (start + step * 2) < N:
        i,j,k = start, start+step, start+step*2
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            count += 1
        start += 1

# print(count)

print(R*G*B - count)

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:8:3: error: invalid preprocessing directive #R
    8 | # R,G,Bの数を数える
      |   ^
main.c:17:3: error: invalid preprocessing directive #\U00007b49\U00009593\U00009694\U00003067
   17 | # 等間隔で(R,G,B)の組み合わせとなっている数を数える
      |   ^~~~~~~~
main.c:18:3: error: invalid preprocessing directive #\U00009593\U00009694
   18 | # 間隔(step)は1～1999のいずれか
      |   ^~~~
main.c:28:3: error: invalid preprocessing directive #print
   28 | # print(count)
      |   ^~~~~
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))
#define rep2(i,s,n) for(int (i) = (s); (i) <=(int)(n); ++(i))

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

    for(auto c:s) {
        if(c == 'R') ++r;
        else if(c == 'G') ++g;
        else ++b;
    } 
    
    ll total = r * g * b;
   
    int sub = 0;
    rep(i, n){
        for(int j = i+1; j < n; ++j){
            if(s[i] == s[j]) continue;            
            int k = 2*j - i;
            if(k >= n) continue;
            if(s[i] == s[k] || s[j] == s[k]) continue;
            
            ++sub;
            // cout << i << ' ' << j << ' ' << k << endl;
        }
    }
    cout << total - sub << endl;

    
}

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


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

int main() {
cout<<fixed<<setprecision(10);
int N;
string S;
cin >>N >> S;

ll all=0;
ll count=0;
  
int r,g,b;
  r=0;
  g=0;
  b=0;
  for (int i=0; i<N;i++){
  	if (S.at(i)=='R') r++;
    if (S.at(i)=='G') g++;
    if (S.at(i)=='B') b++;
  }
  all=r*g*b;

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

}

Compiler output:
a.cc:35:1: error: 'cout' does not name a type
   35 | cout <<all - count;
      | ^~~~
a.cc:37:1: error: expected declaration before '}' token
   37 | }
      | ^
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.at(i)=='R')
      r++;
    else if(s.at(i)=='G')
      g++;
    else
      b++;
  }
  int sum=r*g*b;
  
 
      for (int j = 1; j <= n; j++)
      {
        for (int i = 1; i < n-1; i++)
        {
            if (m-d<0||m+d>n-1) continue;
            if (s[i-j]!=s[i+j] && s[i-j]!=s[i] && s[i]!=s[i+j]) sum--;
        }
      }
          cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:17: error: 'm' was not declared in this scope
   27 |             if (m-d<0||m+d>n-1) continue;
      |                 ^
a.cc:27:19: error: 'd' was not declared in this scope
   27 |             if (m-d<0||m+d>n-1) continue;
      |                   ^
Language: C

#include<stdio.h>
#define scanf scanf_s
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
char a[4001];
int main()
{
	int n, i,j,k,l,R,G,B;
	long long sum=0,sum1=0;
	j = k = l =R=G=B=0;
	scanf("%d", &n);
	getchar();
	gets(a);
	for (i = 0; i < n; i++)
	{
		if (a[i] == 'R')R++;
		else if (a[i] == 'G') G++;
		else if (a[i] == 'B') B++;
	}
	sum = (long long)R * G * B;
	/*for (i = 0; i < n; i++)
	{
		if (a[i] == 'R')  R--, sum += G*B;
		else if (a[i] == 'G')  G--,sum+=R*B;
		else if (a[i] == 'B')  B--,sum+=R*G;	
	}*/
	for (i = 0; i < n; i++)
	{
		for (j = i+2; j < n; j++)
		{
			if ((i + j) % 2 != 0) continue;
			if (a[i] != a[j] && a[i] != a[(i + j) / 2]&&a[j]!=a[(i+j)/2]) sum--;
		}
	}
	printf("%lld", sum );
}

Compiler output:
main.c: In function 'main':
main.c:2:15: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    2 | #define scanf scanf_s
      |               ^~~~~~~
main.c:12:9: note: in expansion of macro 'scanf'
   12 |         scanf("%d", &n);
      |         ^~~~~
main.c:14:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration]
   14 |         gets(a);
      |         ^~~~
      |         fgets
Language: Java

n = gets.to_i
s = gets
ans = r = g = b = 0
0.upto(n-1) do |i|
  r += 1 if s[i] == "R"
  g += 1 if s[i] == "G"
  b += 1 if s[i] == "B"
  (i+1).upto(n-1) do |j|
    k = j + j - i
    if k < n && s[i] != s[j] && s[i] != s[k] && s[j] != s[k]
      ans += 1
    end
  end
end
puts (r * g * b - ans)

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
n = gets.to_i
^
1 error
Language: C

#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n,count,r,g,b;
	string s;
	cin>>n>>s;
	r=g=b=count=0;
	rep(i,n){
		if(s.at(i)=='R')r++;
		if(s.at(i)=='G')g++;
		if(s.at(i)=='B')b++;
	}
	rep(i,n)for(int j=i;j<n;j++){
		if(j==i)continue;
		if(n<=j+j-i)continue;
		if(s[i]!=s[j]&&s[j]!=s[j+j-i]&&s[j+j-i]!=s[i])count++;
	}
	cout<<r*g*b-count<<endl;
}	

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

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

int N;
string S;
int sn[4000];

int main()
{
  int i,j,k;
  int rn=0,gn=0,bn=0;
  int d;
  int l;
  int t;
  long sum=0;

  cin >> N;
  cin >> S;

  for (i=0; i<N; i++) {
    switch(S[i]) {
    case 'R': rn++; sn[i] = 1; break;
    case 'G': gn++; sn[i] = 2; break;
    case 'B': bn++; sn[i] = 4; break;
    }
  }


  for (i=0; i<N-2; i++) {
    for (j=i+1; j+j-i<N; j++) {
      if ((sn[i]|sn[j]|sn[j+j-i])==7) sum++;
    }
  }

  printf("%ld\n", rn*gn*bn-sum);

  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;

long long main(void) {
  long long N;
  cin >> N;

  string S;
  cin >> S;

  long long r = 0;
  long long g = 0;
  long long b = 0;

  for (long long i=0; i<N; i++) {
    switch (S.at(i)){
      case 'R':
        r++;
        break;
      case 'G':
        g++;
        break;
      case 'B':
        b++;
        break;
    }
  }

  long long all = r * g * b;

  // k - j == j - i の場合を除去

  long long extra = 0;

  for (long long i=0; i<N-2; i++) {
    for (long long j=i+1; j<N-1; j++) {
      
      long long k = 2 * j - i; // この場合 k は 2*j-i に確定する
      if( k >= N || k < 0 ) continue; // オーバーフロー防止
      if( ( S.at(i)!=S.at(j) ) && ( S.at(j)!=S.at(k) ) && ( S.at(k)!=S.at(i) ) ){
        extra++;
      }
    }
  }

  cout << all - extra << endl; // 余分な場合を差し引いた分を出力
  
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    vector<int> r, g, b;
    int ans = 0;
    for (ll i = 0; i < n; i++) {
        if (s[i] == 'R') r.push_back(i + 1);
        if (s[i] == 'G') g.push_back(i + 1);
        if (s[i] == 'B') b.push_back(i + 1);
    }
    for (auto i : r) {
        for (auto j : g) {
            for (auto k : b) {
                if (2 * j == i + k) continue;
                if (2 * k == i + j) continue;
                if (2 * i == j + k) continue;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

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);
    else if (s[i] == 'G') g.push_back(i);
    else b.pb(i);
  }
  int ans = 0;
  for (auto i : r) {
    for (auto j : g) {
      for (auto k : b) {
        if (i + j == 2 * k) continue;
        if (j + k == 2 * i) continue;
        if (k + i == 2 * j) continue;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:12: error: 'class std::vector<int>' has no member named 'pb'
   23 |     else b.pb(i);
      |            ^~