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


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.c:2:1: error: unknown type name 'import'
    2 | import java.lang.reflect.Array;
      | ^~~~~~
main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    2 | import java.lang.reflect.Array;
      |            ^
main.c:3:1: error: unknown type name 'import'
    3 | import java.util.Arrays;
      | ^~~~~~
main.c:3:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    3 | import java.util.Arrays;
      |            ^
main.c:4:1: error: unknown type name 'import'
    4 | import java.util.Scanner;
      | ^~~~~~
main.c:4:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    4 | import java.util.Scanner;
      |            ^
main.c:5:1: error: unknown type name 'import'
    5 | import java.util.stream.Stream;
      | ^~~~~~
main.c:5:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    5 | import java.util.stream.Stream;
      |            ^
main.c:6:1: error: unknown type name 'import'
    6 | import com.sun.xml.internal.ws.message.ByteArrayAttachment;
      | ^~~~~~
main.c:6:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    6 | import com.sun.xml.internal.ws.message.ByteArrayAttachment;
      |           ^
main.c:8:1: error: unknown type name 'public'
    8 | public class Main {
      | ^~~~~~
main.c:8:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
    8 | public class Main {
      |              ^~~~
Language: C

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr int INF = 1e9;
//constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<vector<ll>> sum(3, vector<ll>(N+1, 0));
  REP(i, N){
    if(S[i] == 'R') sum[0][i+1]++;
    if(S[i] == 'G') sum[1][i+1]++;
    if(S[i] == 'B') sum[2][i+1]++;
  }
  REP(i, 3){
    REP(j, N){
      sum[i][j+1] += sum[i][j];
    }
  }
  ll ans = 0;
  FOR(i, 1, N-1){
    int id;
    if(S[i] =='R') id = 0;
    if(S[i] =='G') id = 1;
    if(S[i] =='B') id = 2;
    REP(l, 3){
      REP(r, 3){
        if(l==r || r== id || l == id) continue;
        ans += sum[l][i] * (sum[r][N] - sum[r][i+1]);
      }
    }
    //cerr << "roop:" << i << " ans:" << ans << endl;
    FOR(w, 1, N){
      if(i-w< 0 || i+w >= N) break;
      if(!(S[i] == S[i-w] || S[i] == S[i+w]|| S[i-w]==S[i+w])){
        ans--;
      }
    }
    //cerr << "roop:" << i << " ans:" << ans << endl;
  }
  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>
using namespace std;

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

int A[3][4001];
int ss[4001];

int main(){
    int n;
    string s;
    cin>>n>>s;
    int col[3]={0,0,0};
    for(int i=0;i<n;i++){
        switch(s[i]){
            case 'R':
                col[0]++;ss[i]=0;break;
            case 'G':
                col[1]++;ss[i]=1;break;
            case 'B':
                col[2]++;ss[i]=2;break;
        }
        A[0][i]=col[0];A[1][i]=col[1];A[2][i]=col[2];
    }
    ll sum=0;
    for(int sta=0;sta<n;sta++){
        for(int x=1;sta+x+1<n;x++){
            if(ss[sta]==ss[sta+x]){continue;}
            int tmp=3-ss[sta]-ss[sta+x];
            sum+=A[tmp][n-1]-A[tmp][sta+x];
            if(sta+x+x<n){
                sum-=(A[tmp][sta+x+x]-A[tmp][sta+x+x-1]);
            }
        }
    }
    cout<<sum;

    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,N); for (int64_t i = 0; i<N; i++)
#define in(N); cin >> N
#define out(ans); cout << ans << endl;

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

}

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

#include <bits/stdc++.h>
#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: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 select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


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

    string s;
    cin >> s;

    ll cnt = 0;

    int i1, i2, i3;
    char c1, c2, c3;

    rep(i, n - 2) {
        i1 = i;
        c1 = s[i];

        rep(j, i + 1, n - 1) {
            if (s[j] != c1) {
                i2 = j;
                c2 = s[j];

                rep(k, j + 1, n) {
                    if (s[k] != c1 && s[k] != c2) {
                        i3 = k;
                        c3 = s[k];

                        if (i2 - i1 != i3 - i2) {
                            cnt++;
                        }
                    }
                }
            }
        }
    }

    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<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    string s;cin>>s;
    vector<int> r,g,b;
    rep(i,n){
        char x=s[i];
        if(x=='R')r.push_back(i);
        else if(x=='B')b.push_back(i);
        else g.push_back(i);
    }
    int rs=r.size(),bs=b.size(),gs=g.size();
    //b.push_back(-1);
    //b.push_back(-1);
    ll res=0;
    rep(i,rs){
        rep(j,gs){
            int R=r[i],G=g[j];
            if((R+G)%2==0){
                int mid=(R+G)/2;
                auto itr=lower_bound(b.begin(),b.end(),mid);
                int k=itr-b.begin();
                if(b[k]==mid)res--;
            }
            if(R<G){
                int buf=G-R;
                auto itr=lower_bound(b.begin(),b.end(),R-buf),itr2=upper_bound(b.begin(),b.end(),R-buf);
                int k=itr-b.begin(),k2=itr2-b.begin();
                if(k2-k)res--;
                if(G+buf<=b[bs-1]){
                itr=lower_bound(b.begin(),b.end(),G+buf),itr2=upper_bound(b.begin(),b.end(),G+buf);
                k=itr-b.begin(),k2=itr2-b.begin();
                if(k2-k)res--;
                }
            }
            else{
                int buf=R-G;
                auto itr=lower_bound(b.begin(),b.end(),G-buf),itr2=upper_bound(b.begin(),b.end(),G-buf);
                int k=itr-b.begin(),k2=itr2-b.begin();
                if(k2-k)res--;
                if(R+buf<=b[bs-1]){
                itr=lower_bound(b.begin(),b.end(),R+buf),itr2=upper_bound(b.begin(),b.end(),R+buf);
                k=itr-b.begin(),k2=itr2-b.begin();
                if(k2-k)res--;
                }
            }
            res+=bs;
        }
    }
    cout<<res<<endl;
}

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

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 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.at(i) != S.at(j)) && (S.at(i) != S.at(k)) && (S.at(j) != S.at(k)))
        {
          if(j - i != k - j)ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

ll count(vector<int> &R, vector<int> &G, vector<int> &B) {
  ll sum = 0;
  for (int i = 0; i < R.size(); i ++) {
    for (int j = 0; j < G.size(); j ++) {
      if (R[i] > G[j]) {
        continue;
      }
      int a = G[j] - R[i];
      for (int k = 0; k < B.size(); k ++) {
        if (G[j] > B[k]) {
          continue;
        }
        if (a == B[k] - G[j]) {
          continue;
        }
        sum ++;
      }
    }
  }
  return sum;
}

int main() {
  int N;
  char S;
  vector<int> R, G, B;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == 'R') {
      R.push_back(i);
    } else if(S == 'G') {
      G.push_back(i);
    } else if(S == 'B') {
      B.push_back(i);
    }
  }
  ll sum = 0;
  sum += count(R, B, G);
  sum += count(R, G, B);
  sum += count(B, R, G);
  sum += count(B, G, R);
  sum += count(G, R, B);
  sum += count(G, B, R);
  cout << sum << endl;
  return 0;
}

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

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

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

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    // 4000
    int n;
    cin >> n;
    string s;
    cin >> s;
    // 1 <= i < j < k <= N
    // j - i != k - j
    // triplets ...
    // RGB
    // subsequence
    // RRGB: RGB
    vector<vector<int>> idxes(3);
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'R') idxes[0].push_back(i);
        else if(s[i] == 'G') idxes[1].push_back(i);
        else idxes[2].push_back(i);
    }
    long long ans = 0LL;
    for(int i = 0; i < 3; ++i) {
        int jj = (i + 1) % 3;
        int kk = 3 - i - jj;
        vector<int> js = {jj, kk};
        for(int j : js) {
            int k = 3 - i - j;
            for(int ia = 0; ia < (int) idxes[i].size(); ++ia) {
                int a = idxes[i][ia];
                auto itb = lower_bound(idxes[j].begin(), idxes[j].end(), a);
                int start_b = itb - idxes[j].begin();
                for(int ib = start_b; ib < (int) idxes[j].size(); ++ib) {
                    int b = idxes[j][ib];
                    auto itc = lower_bound(idxes[k].begin(), idxes[k].end(), b);
                    // need to know if exit ib - ia == ic - ib
                    ans += idxes[k].end() - itc;
                    auto it = lower_bound(itc, idxes[k].end(), 2 * b - a);
                    if (it != idxes[k].end() && (*it) == 2 * b - a) ans -= 1;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;

}



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

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;
using P = pair<int,int>;

ll n,m,sum;
string s,t;

int main() {
  cin >> n >> s;
  rep(i,n)rep(j,i)rep(k,j){
    if(s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k]){
      if(j-i!=k-j) sum++;
    }
  }
  cout << 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;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> R(N + 1);
    vector<ll> G(N + 1);
    vector<ll> B(N + 1);
    for(int i = N;i >= 1;i--) {
        if(S.at(i - 1) == 'R') {
            R.at(i - 1) = R.at(i) + 1;
        }
        else {
            R.at(i - 1) = R.at(i);
        }
    }
    for(int i = N;i >= 1;i--) {
        if(S.at(i - 1) == 'B') {
            B.at(i - 1) = B.at(i) + 1;
        }
        else {
            B.at(i - 1) = B.at(i);
        }
    }
    for(int i = N;i >= 1;i--) {
        if(S.at(i - 1) == 'G') {
            G.at(i - 1) = G.at(i) + 1;
        }
        else {
            G.at(i - 1) = G.at(i);
        }
    }
    ll ret = 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) == 'G' && S.at(j) == 'B') || (S.at(i) == 'B' && S.at(j) == 'G')) {
                    if(j + j - i < N && S.at(j + j - i) == 'R') {
                        ret += R.at(j) - 1;
                    }
                    else {
                        ret += R.at(j);
                    }
                }
                if((S.at(i) == 'R' && S.at(j) == 'B') || (S.at(i) == 'B' && S.at(j) == 'R')) {
                    if(j + j - i < N && S.at(j + j - i) == 'G') {
                        ret += G.at(j) - 1;
                    }
                    else {
                        ret += G.at(j);
                    }
                }
                if((S.at(i) == 'R' && S.at(j) == 'G') || (S.at(i) == 'G' && S.at(j) == 'R')) {
                    if(j + j - i < N && S.at(j + j - i) == 'B') {
                        ret += B.at(j) - 1;
                    }
                    else {
                        ret += B.at(j);
                    }
                }
            }
        }
    }
    cout << ret << endl;
}

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

#include"bits/stdc++.h"

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
int INF=100000001;


int main(){
    int i,j,n,c[3]={0},a;
    char t[3]={'R','G','B'};
    cin>>n;
    char s[n+1];
    rep(i,n){
        cin>>s[i];
        if(s[i]=='R')c[0]+=1;
        else if (s[i]=='G')c[1]+=1;
        else c[2]+=1;
    }
    //入力
    //処理
    int count=0,l[3]={0},k[3]={0},x,y;
    if(s[0]=='R')l[0]+=1;        
    else if (s[i]=='G')l[1]+=1;
    else l[2]+=1;
    bool sei=false;
    rep(i,n-2){
        rep(a,3){
            if(s[i]==t[a])l[a]+=1;
        }
        rep(a,3){
            k[a]=l[a];
        }
        for(j=i+1;j<n-1;j++){
            rep(a,3){
                if(s[j]==t[a])k[a]+=1;
            }
            if(s[i]==s[j]){
                
                break;
            }else {
                rep(a,3){
                    if(s[i]==t[a])x=a;
                    if(s[j]==t[a])y=a;
                }
                if(2*j-i<n){
                    if(s[2*j-i]!=s[j]&&s[2*j-i]!=s[i])sei=true;
                }
                count+=c[6-x-y]-k[6-x-y];
                if(sei)count-=1;
            }
        }
    }
    //出力
    cout<<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 <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j++) {
      for (int k = j; k <= N; k++) {
        if (S[i-1] != S[j-1] && S[j-1] != S[k-1] && S[k-1] != S[i-1] && 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;
#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: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

if __name__ == '__main__':
    n = int(input())

    a = input()
    listr = [0]*n
    listg = [0]*n
    listb = [0]*n
    r =0
    g =0
    b =0

    count = 0

    for i in range(n):

        if a[i] == "R":
            r +=1
        if a[i] == "G":
            g +=1
        if a[i] == "B":
            b +=1
        listr[i] =r
        listb[i] =b
        listg[i] =g

    for i in range(n):

        if a[i] == "R":
            r -=1
        if a[i] == "G":
            g -=1
        if a[i] == "B":
            b -=1
        listr[i] =r
        listb[i] =b
        listg[i] =g

    for i in range(n-2):
        for j in range(i+1,n-1):
            if a[i] != a[j]:
                if a[i] =="R" and a[j] =="G":
                    count += listb[j]
                    if (j-i)+j < len(a) and a[(j-i)+j] =="B" and listb[j] >0:
                        count -=1
                    continue
                if a[i] =="R" and a[j] =="B":
                    count += listg[j]
                    if (j-i)+j < len(a) and a[(j-i)+j] =="G" and listg[j] >0:
                        count -=1
                    continue
                if a[i] =="G" and a[j] =="B":
                    count += listr[j]
                    if (j-i)+j < len(a) and a[(j-i)+j] =="R" and listr[j] >0:
                        count -=1
                    continue
                if a[i] =="G" and a[j] =="R":
                    count += listb[j]
                    if (j-i)+j < len(a) and a[(j-i)+j] =="B" and listb[j] >0:
                        count -=1
                    continue

                if a[i] =="B" and a[j] =="G":
                    count += listr[j]
                    if (j-i)+j < len(a) and a[(j-i)+j] =="R" and listr[j] >0:
                        count -=1
                    continue

                if a[i] =="B" and a[j] =="R":
                    count += listg[j]
                    if (j-i)+j < len(a) and a[(j-i)+j] =="G" and listg[j] >0:
                        count -=1
                    continue


    print(count)

Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import sys
      | ^~~~~~
main.c:2:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'import'
    2 | import copy
      | ^~~~~~
main.c:2:1: error: unknown type name 'import'
main.c:21:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   21 | if __name__ == '__main__':
      |                ^~~~~~~~~~
Language: C

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

const int M = 1e9+7;

int bs(vector<int> &v , int idx , int rest) {
    int n = v.size();
    int l = 0 , r = n-1 , ans = -1;
    while(l <= r) {
        int mid = l + (r-l)/2;
        if(v[mid] >= idx) {
            ans = mid;
            r = mid-1;
        }
        else l = mid+1;
    }
    int num = 0;
    if(ans != -1) num = n - ans;
    bool found = false;
    l = 0 , r = n-1;
    while(l <= r) {
        int mid = l + (r-l)/2;
        if(v[mid] > rest) r = mid-1;
        else if(v[mid] < rest) l = mid+1;
        else {
            found = true;
            break;
        }
    }
    if(found) num--;
    return num;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    unordered_map<char , vector<int>> map;
    for(int i = 0; i < n; i++) {
        map[s[i]].push_back(i);
    }
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            if(s[i] != s[j]) {
                int d = j-i;
                int num = 0;
                for(auto p : map) {
                    if(p.first != s[i] && p.first != s[j]) {
                        num = bs(p.second , j+1 , j+d);
                        break;
                    }
                }
                cnt += num;
            }
        }
    }
    cout << cnt << "\n";
    return 0;
}


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

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

ll solve(int n,string s){
    vector<int>a[3];
    rep(i,n){
        if(s[i]=='R')a[0].push_back(i);
        else if(s[i]=='G')a[1].push_back(i);
        else a[2].push_back(i);
    }
    int sr=a[0].size();
    int sg=a[1].size();
    int sb=a[2].size();
    ll ans=sr*sg*sb;
    rep(i,sr)rep(j,sg)rep(k,sb){
        int ni=a[0][i];
        int nj=a[1][j];
        int nk=a[2][k];

        if(ni<nj&&nj<nk)
        {
          if(nj-ni==nk-nj)ans--;
        }

        if(nj<ni&&ni<nk){
        if(ni-nj==nk-ni)ans--;
        }

         if(ni<nk&&nk<nj){
        if(nk-ni==nj-nk)ans--;
        }

        if(nk<nj&&nj<ni){
        if(nj-nk==ni-nj)ans--;
        }

        if(nk<ni&&ni<nj){
        if(ni-nk==nj-ni)ans--;
        }

        if(nj<nk&&nk<ni){
        if(nk-nj==ni-nk)ans--;
        }        

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

int n;
string s;
cin>>n>>s;

cout<<solve(n,s)<<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;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

typedef long long ll;

int main(){
    int n;
    string rgb;
    cin >> n;
    cin >> rgb;
    vector<int> r,g,b;
    rep(i,n){
        if(rgb[i] == 'R') r.push_back(i);
        else if(rgb[i] == 'B') b.push_back(i);
        else if(rgb[i] == 'G') g.push_back(i);
    }
    int count = 0;
    int s,m,l;
    rep(i,r.size()){
        rep(j,b.size()){
            rep(k,g.size()){
                s = min(r[i],b[j]);
                s = min(s,g[k]);
                l = max(r[i],b[j]);
                l = max(l,g[k]);
                if(r[i] != s && r[i] != l) m = r[i];
                else if(b[j] != s && b[j] != l) m = b[j];
                else m = g[k];

                if ((l - m) != (m-s)) count += 1;
            }
        }
    }
    cout << count << 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;

int main(){
  int64_t N;
  string S;
  cin >> N >> S;
  int64_t r=0,g=0,b=0;
  int64_t x=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      r++;
    }else if(S.at(i)=='G'){
      g++;
    }else{
      b++;
    }
    int y=(N-i)/2;
    if((N-i)%2==1) y++;
    for(int j=1;j<y;j++){
      if(S.at(i)!=S.at(i+j)&&S.at(i)!=S.at(i+2*j)&&S.at(i+2*j)!=S.at(i+j)){
        x--;
      }
    }
  }
  x+=r*b*g;
  cout << x << 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(){
  int N;
  string S; cin >> N >> S;
  ll ans=0;
  if(N<4){
    cout << 0 << endl;
    return 0;
  }
  vector<int> R(0);
  vector<int> B(0);
  vector<int> G(0);
  for(int i=0;i<N;i++){
    if(S[i]=='R'){
      R.push_back(i+1);
    }
    if(S[i]=='B'){
      B.push_back(i+1);
    }
    if(S[i]=='G'){
      G.push_back(i+1);
    }
  }
  int r=R.size();
  int b=B.size();
  int g=G.size();
  if(r==0 || b==0 || g==0){
    cout << 0 << endl;
    return 0;
  }
  for(int i=0;i<r;i++){
    for(int j=0;j<b;j++){
      for(int k=0;k<g;k++){
        if(3*max(R[i],max(B[j],G[k]))+3*min(R[i],min(B[j],G[k]))!=2*(R[i}+B[j]+G[k])){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:73: error: expected ']' before '}' token
   37 |         if(3*max(R[i],max(B[j],G[k]))+3*min(R[i],min(B[j],G[k]))!=2*(R[i}+B[j]+G[k])){
      |                                                                         ^
      |                                                                         ]
a.cc:37:73: error: expected ')' before '}' token
   37 |         if(3*max(R[i],max(B[j],G[k]))+3*min(R[i],min(B[j],G[k]))!=2*(R[i}+B[j]+G[k])){
      |                                                                     ~   ^
      |                                                                         )
a.cc:37:73: error: expected ')' before '}' token
   37 |         if(3*max(R[i],max(B[j],G[k]))+3*min(R[i],min(B[j],G[k]))!=2*(R[i}+B[j]+G[k])){
      |           ~                                                             ^
      |                                                                         )
a.cc:37:73: error: expected primary-expression before '}' token
a.cc:37:82: error: 'k' was not declared in this scope
   37 |         if(3*max(R[i],max(B[j],G[k]))+3*min(R[i],min(B[j],G[k]))!=2*(R[i}+B[j]+G[k])){
      |                                                                                  ^
a.cc: At global scope:
a.cc:43:3: error: 'cout' does not name a type
   43 |   cout << ans << endl;
      |   ^~~~
a.cc:44:3: error: expected unqualified-id before 'return'
   44 |   return 0;
      |   ^~~~~~
a.cc:45:1: error: expected declaration before '}' token
   45 | }
      | ^
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 <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;


int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	long long r = 0, g = 0, b = 0;
	for (int i = 0; i < n;i++) {
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else b++;
	}
	long long  ans = r * g * b;
	for (int i = 0; i < n - 2;i++) {
		for (int j = 1; j < n / 2;j++) {
			if (i + 2 * j < n && s[i] != s[i + j] && s[i] != s[i + 2 * j] && s[i + j] != s[i + 2 * j]) 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<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define int long long
signed main()
{
    int n,ans=0;
    scanf("%lld",&n);
    string ss;
    cin>>ss;
    for(int i=1;i<=n;i++)
        ans+=(n-i)/2;
    int r=0,g=0,b=0;
    for(int i=0;i<n;i++)
    {
        r+=(ss[i]=='R');
        g+=(ss[i]=='G');
        b+=(ss[i]=='B');
    }
    ans+=r*(r-1)/2*(n-r)+r*(r-1)*(r-2)/6;
    ans+=g*(g-1)/2*(n-g)+g*(g-1)*(g-2)/6;
    ans+=b*(b-1)/2*(n-b)+b*(b-1)*(b-2)/6;
    for(int i=0;i<n;i++)
        for(int j=1;i+j*2<n;j++)
            if(ss[i]==ss[i+j]||ss[i+j]==ss[i+j*2]||ss[i]==ss[i+j*2])
                ans--;
    ans=n*(n-1)*(n-2)/6-ans;
    printf("%lld\n",ans);
    return 0;
}


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

typedef long long ll;

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

    int k = n;

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

    cout << sum << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> n;
      |     ^~~
a.cc:6:5: error: 'string' was not declared in this scope
    6 |     string s;
      |     ^~~~~~
a.cc:7:12: error: 's' was not declared in this scope
    7 |     cin >> s;
      |            ^
a.cc:23:5: error: 'cout' was not declared in this scope
   23 |     cout << sum << endl;
      |     ^~~~
a.cc:23:20: error: 'endl' was not declared in this scope
   23 |     cout << sum << endl;
      |                    ^~~~
Language: C

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    string S = in<string>();
    vector<int> R(0);
    vector<int> G(0);
    vector<int> B(N);
    REP(i,N){
        if(S[i] == 'R')R.pb(i);
        if(S[i] == 'G')G.pb(i);
        if(S[i] == 'B')B[i] = 1;
    }
    ll sum = 0;
    REP(i,R.size()){
        REP(l,G.size()){
            int minus = 0;
            if(max(G[l],R[i])+abs(R[i] - G[l]) < N){
                if(B[max(G[l],R[i])+abs(R[i] - G[l])] == 1)minus++;
            }
            if(min(G[l],R[i])-abs(R[i] - G[l]) >= 0){
                if(B[min(G[l],R[i])-abs(R[i] - G[l])] == 1)minus++;
            }
            if(abs(R[i] - G[l])%2 == 0){
                if(B[min(G[l],R[i]) + abs(R[i] - G[l])/2]==1)minus++;
            }
            sum += N-R.size()-G.size()-minus;
        }
    }
    cout << sum << "\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 loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

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

int n;
string s;

int main()
{
    cin>>n>>s;
    ll sum=0;
    rep(i,n-2){
        loop(k,i+2,n){
            loop(j,i+1,k){
                if(k+i==2*j){continue;}
                else if(s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]){sum++;}
            }
        }
    }

    cout<<sum<<endl;


    return 0;

}




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

#include <bits/stdc++.h>

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

string t = "RGB";

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> r(n);
	vector<int> g(n);
	vector<int> b(n);
	vector<int> rf(n, 0);
	vector<int> gf(n, 0);
	vector<int> bf(n, 0);
	rep(i, n) {
		if (s[i] == 'R') {
			r[i]++;
			rf[i] = 1;
		}
		if (s[i] == 'G') {
			g[i]++;
			gf[i]++;
		}
		if (s[i] == 'B') {
			b[i]++;
			bf[i]++;
		}
	}
	rep(i, n) {
		if (i > 0) {
			r[i] += r[i - 1];
			g[i] += g[i - 1];
			b[i] += b[i - 1];
		}
	}
	
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if (s[i] == s[j]) continue;
			int id;
			int sa = j - i;
			rep(temp, 3) if (t[temp] != s[i] && t[temp] != s[j]) id = temp;
			//jより大きいところにidが何個あるか
			if (id == 0) {
				ans += r[n - 1] - r[j];
				if (sa + j < n && rf[sa + j] == 1) ans--;
			}
			if (id == 1) {
				ans += g[n - 1] - g[j];
				if (sa + j < n && gf[sa + j] == 1) ans--;
			}
			if (id == 2) {
				ans += b[n - 1] - b[j];
				if (sa + j < n && bf[sa + j] == 1) 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,cnt=0;
	string s;
	cin>>n;
	cin>>s;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				if(j-i!=k-j&&s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]) cnt++;
			}
		}
	}
	cout<<cnt<<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

#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	cin >> N;
	string s;
	cin >> s;
	vector<int> char_pos[3];
	rep(i, N) {
		if (s[i] == 'R') char_pos[0].push_back(i + 1);
		if (s[i] == 'G') char_pos[1].push_back(i + 1);
		if (s[i] == 'B') char_pos[2].push_back(i + 1);
	}
	int _count = 0;
	rep(i, char_pos[0].size()) {
		rep(j, char_pos[1].size()) {
			rep(k, char_pos[2].size()) {
				int arr[3];
				arr[0] = char_pos[0][i];
				arr[1] = char_pos[1][j];
				arr[2] = char_pos[2][k];
				sort(arr, arr + 3);
				if (arr[2] - arr[1] == arr[1] - arr[0]) continue;
				else _count++;
			}
		}
	}
	cout << _count;
}


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

#include <iostream>
#include <vector>

using namespace std;
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define reppe(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define repm(i, a, b) for (int i = (int)(a); i > (int)(b); --i)
#define repme(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)

typedef long long ll;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    return GCD(b, a % b);
}

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> cR(N);
    vector<int> cG(N);
    vector<int> cB(N);

    if (S[0] == 'R') cR[0] = 1;
    if (S[0] == 'G') cG[0] = 1;
    if (S[0] == 'B') cB[0] = 1;
    repp(i, 1, N) {
        cR[i] = cR[i - 1];
        cG[i] = cG[i - 1];
        cB[i] = cB[i - 1];
        if (S[i] == 'R') cR[i] += 1;
        if (S[i] == 'G') cG[i] += 1;
        if (S[i] == 'B') cB[i] += 1;
    }

    long long res = 0;
    repp(i, 0, N) {
        repp(j, i + 1, N) {
            if (S[i] == 'R') {
                if (S[j] == 'G') {
                    res += cB[j - 1] - cB[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'B') --res;
                } else if (S[j] == 'B') {
                    res += cG[j - 1] - cG[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'G') --res;
                }
            } else if (S[i] == 'G') {
                if (S[j] == 'B') {
                    res += cR[j - 1] - cR[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'R') --res;
                } else if (S[j] == 'R') {
                    res += cB[j - 1] - cB[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'B') --res;
                }
            } else if (S[i] == 'B') {
                if (S[j] == 'R') {
                    res += cG[j - 1] - cG[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'G') --res;
                } else if (S[j] == 'G') {
                    res += cR[j - 1] - cR[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'R') --res;
                }
            }
        }
    }
    cout << res << endl;
}


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

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

int main() {
  int n;
  cin >> n;
  char str[n];
  vector<set<int>> colors(3);
  for (int i = 0; i < n; ++i) {
    cin >> str[i];
    if (str[i] == 'R') colors[0].insert(i);
    else if (str[i] == 'G') colors[1].insert(i);
    else colors[2].insert(i);
  }
  long long ans(0);
  int i(0), j(1), k(2);
      for (int ii: colors[i]) {
        for (int ij: colors[j]) {
          int diff = abs(ii - ij);
          int mn = min(ii, ij);
          int mx = max(ii, ij);
          int c(0);
          if (diff % 2 == 0 && colors[k].count(mn + diff / 2)) {
            c--;
          }
          if (colors[k].count(mx + diff)) c--;
          if (colors[k].count(mn - diff)) c--;
          ans += (long long) colors[k].size() + c;
        }
      }
  cout << ans << '\n';
  return 0;
}

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

#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

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

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

    int 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((S.at(i) != S.at(j) && S.at(i) != S.at(k) && S.at(j) != S.at(k))
                && (j - i != k - j)){
                    count++;
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}


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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    string S;
    cin >> N >> S;
    long long res = 0;
    int r = 0;
    int g = 0;
    int b = 0;
    rep(i, 0, N) {
        if(S[i] == 'R') {
            r++;
        }
        if(S[i] == 'G') {
            g++;
        }
        if(S[i] == 'B') {
            b++;
        }
    }
    res = r * g * b;
  //  cout<<res<<endl;
    rep(i, 1, (N + 1) / 2) {
        rep(j, 1, N - 1) {
            if(j - i < 0 || j + i >= N) {
                continue;
            }
            if(S[j - i] != S[j] && S[j] != S[j + i] && S[j - i] != S[j + i]) {
                res--;

            }
        }
    }
    cout << res << endl;
}


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