Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n;
    cin >> n;

    string s;
    cin >> s;

    vector<vector<int>> a(n, vector<int>(3));
    int r = 0, g = 0, b = 0;
    roop(i, n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;

        a[i][0] = r;
        a[i][1] = g;
        a[i][2] = b;
    }

    ll ans = 0;

    int temp = 0;
    for(int i  s[j+(j-i)] == 'G') ans--;
                    if(7 - temp == 4 && s[j+(j-i)] == 'B') ans--;
                }

                if(7 - temp == 1) ans += a[n-1][0]-a[j][0];
                if(7 - temp == 2) ans += a[n-1][1]-a[j][1];
                if(7 - temp == 4) ans += a[n-1][2]-a[j][2];
            }
            temp = 0;
        }
    }

    cout << ans << endl;

    return 0;
}
&= 0;i < n-2;i++){
        for(int j = i+1;j < n-1;j++){
            if(s[i] != s[j]){
                if(s[i] == 'R' || s[j] == 'R') temp += 1;
                if(s[i] == 'G' || s[j] == 'G') temp += 2;
                if(s[i] == 'B' || s[j] == 'B') temp += 4;

                if(j+(j-i) < n){
                    if(7 - temp == 1 && s[j+(j-i)] == 'R') ans--;
                    if(7 - temp == 2 &

Compiler output:
a.cc: In function 'int main()':
a.cc:32:14: error: expected ';' before 's'
   32 |     for(int i  s[j+(j-i)] == 'G') ans--;
      |              ^ ~
      |              ;
a.cc:32:18: error: 'j' was not declared in this scope
   32 |     for(int i  s[j+(j-i)] == 'G') ans--;
      |                  ^
a.cc:32:33: error: expected ';' before ')' token
   32 |     for(int i  s[j+(j-i)] == 'G') ans--;
      |                                 ^
      |                                 ;
a.cc:33:43: error: 'j' was not declared in this scope
   33 |                     if(7 - temp == 4 && s[j+(j-i)] == 'B') ans--;
      |                                           ^
a.cc:33:48: error: 'i' was not declared in this scope
   33 |                     if(7 - temp == 4 && s[j+(j-i)] == 'B') ans--;
      |                                                ^
a.cc: At global scope:
a.cc:36:17: error: expected unqualified-id before 'if'
   36 |                 if(7 - temp == 1) ans += a[n-1][0]-a[j][0];
      |                 ^~
a.cc:37:17: error: expected unqualified-id before 'if'
   37 |                 if(7 - temp == 2) ans += a[n-1][1]-a[j][1];
      |                 ^~
a.cc:38:17: error: expected unqualified-id before 'if'
   38 |                 if(7 - temp == 4) ans += a[n-1][2]-a[j][2];
      |                 ^~
a.cc:39:13: error: expected declaration before '}' token
   39 |             }
      |             ^
a.cc:40:13: error: 'temp' does not name a type; did you mean 'tm'?
   40 |             temp = 0;
      |             ^~~~
      |             tm
a.cc:41:9: error: expected declaration before '}' token
   41 |         }
      |         ^
a.cc:42:5: error: expected declaration before '}' token
   42 |     }
      |     ^
a.cc:44:5: error: 'cout' does not name a type
   44 |     cout << ans << endl;
      |     ^~~~
a.cc:46:5: error: expected unqualified-id before 'return'
   46 |     return 0;
      |     ^~~~~~
a.cc:47:1: error: expected declaration before '}' token
   47 | }
      | ^
a.cc:48:1: error: expected unqualified-id before '&=' token
   48 | &= 0;i < n-2;i++){
      | ^~
a.cc:48:6: error: 'i' does not name a type
   48 | &= 0;i < n-2;i++){
      |      ^
a.cc:48:14: error: 'i' does not name a type
   48 | &= 0;i < n-2;i++){
      |              ^