Language: C++

int main() {
  Cinint(n);
  Cinstring(s);
  int64_t count = 0;
  int64_t Rcount = 0;
  int64_t Gcount = 0;
  int64_t Bcount = 0;
  rep(i, n) {
    if (s.at(i) == 'R') {
      Rcount++;
    }
    else if (s.at(i) == 'G') {
      Gcount++;
    }
    else {
      Bcount++;
    }
  }
  count = Rcount*Gcount*Bcount;
  rep(i, n-2) {
    for (int j = i+1; j < n-1; j++) {
      int sa = j-i;
      int k = j+sa;
      if (k <= n-1) {
        if (s.at(i) == 'R') {
          if (s.at(j) == 'G') {
            if (s.at(k) == 'B') {
              count--;
            }
          }
          else if (s.at(j) == 'B') {
            if (s.at(k) == 'G') {
              count--;
            }
          }
        }
        else if (s.at(i) == 'G') {
          if (s.at(j) == 'B') {
            if (s.at(k) == 'R') {
              count--;
            }
          }
          else if (s.at(j) == 'R') {
            if (s.at(k) == 'B') {
              count--;
            }
          }
        }
        else {
          if (s.at(j) == 'R') {
            if (s.at(k) == 'G') {
              count--;
            }
          }
          else if (s.at(j) == 'G') {
            if (s.at(k) == 'R') {
              count--;
            }
          }
        }
      }
    }
  }
  cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:10: error: 'n' was not declared in this scope
    2 |   Cinint(n);
      |          ^
a.cc:2:3: error: 'Cinint' was not declared in this scope
    2 |   Cinint(n);
      |   ^~~~~~
a.cc:3:13: error: 's' was not declared in this scope
    3 |   Cinstring(s);
      |             ^
a.cc:3:3: error: 'Cinstring' was not declared in this scope
    3 |   Cinstring(s);
      |   ^~~~~~~~~
a.cc:4:3: error: 'int64_t' was not declared in this scope
    4 |   int64_t count = 0;
      |   ^~~~~~~
a.cc:1:1: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
  +++ |+#include <cstdint>
    1 | int main() {
a.cc:5:10: error: expected ';' before 'Rcount'
    5 |   int64_t Rcount = 0;
      |          ^~~~~~~
      |          ;
a.cc:6:10: error: expected ';' before 'Gcount'
    6 |   int64_t Gcount = 0;
      |          ^~~~~~~
      |          ;
a.cc:7:10: error: expected ';' before 'Bcount'
    7 |   int64_t Bcount = 0;
      |          ^~~~~~~
      |          ;
a.cc:8:7: error: 'i' was not declared in this scope
    8 |   rep(i, n) {
      |       ^
a.cc:8:3: error: 'rep' was not declared in this scope
    8 |   rep(i, n) {
      |   ^~~
a.cc:19:3: error: 'count' was not declared in this scope
   19 |   count = Rcount*Gcount*Bcount;
      |   ^~~~~
a.cc:19:11: error: 'Rcount' was not declared in this scope
   19 |   count = Rcount*Gcount*Bcount;
      |           ^~~~~~
a.cc:19:18: error: 'Gcount' was not declared in this scope
   19 |   count = Rcount*Gcount*Bcount;
      |                  ^~~~~~
a.cc:19:25: error: 'Bcount' was not declared in this scope
   19 |   count = Rcount*Gcount*Bcount;
      |                         ^~~~~~
a.cc:64:3: error: 'cout' was not declared in this scope
   64 |   cout << count << endl;
      |   ^~~~
a.cc:64:20: error: 'endl' was not declared in this scope
   64 |   cout << count << endl;
      |                    ^~~~