Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
const int mod = 1000000007;
struct mint {
 long long x;
 mint(long long x = 0):x((x % mod + mod) % mod) {}
 mint operator-() const {return mint(-x);}
 mint& operator+=(const mint a) {
   if ((x += a.x) >= mod) x -= mod;
   return *this;
 }
 mint& operator-=(const mint a) {
   if ((x += mod - a.x) >= mod) x -= mod;
   return *this;
 }
 mint& operator*=(const mint a) {
   (x *= a.x) %= mod;
   return *this;
 }
 mint operator+(const mint a) const {
   mint res(*this);
   return res+=a;
 }
 mint operator-(const mint a) const {
   mint res(*this);
   return res-=a;
 }
 mint operator*(const mint a) const {
   mint res(*this);
   return res*=a;
 }
 mint pow(long long t) const {
   if (!t) return 1;
   mint a = pow(t>>1);
   a *= a;
   if (t&1) a *= *this;
   return a;
 }
 mint inv() const {
   return pow(mod-2);
 }
 mint& operator/=(const mint a) {
   return (*this) *= a.inv();
 }
 mint operator/(const mint a) const {
   mint res(*this);
   return res /= a;
 }
};

// 繰り返し二乗法で 2 の n 乗を計算する
mint f (int n) {
 if (n == 0) {
   return 1;
 }
 mint x = f(n / 2);
 x *= x;
 if (n % 2 == 1) {
   x *= 2;
 }
 return x;
}

// a 回のループで計算する
mint choose (int n, int a) {
 mint x = 1;
 mint y = 1;
 for (int i = 0; i < a; i++) {
   x *= n - i;
   y *= i + 1;
 }
 return x / y;
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans=0;
    int r,g,b;
    rep(i,n){
      if(s[i]=='R') r++;
      if(s[i]=='G') g++;
      if(s[i]=='B') b++;
    }   
    int ans=r*g*b;
    ll count=0;
    rep(i,n){
      rep(j,n){
        int k=2*j-i;
        if(k>=0 && i>=0 && j>=0){
          if(i!=j && j!=k && i!=k){
            if(s[i]!=s[j] && s[j]!=s[k] && s[i]!=s[k]){
              if(j-i==k-j){
                count++;
              }
            }
          }
        }
      }
    }
    cout << ans-count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:150:9: error: conflicting declaration 'int ans'
  150 |     int ans=r*g*b;
      |         ^~~
a.cc:143:8: note: previous declaration as 'll ans'
  143 |     ll ans=0;
      |        ^~~