Language: C++

#include<bits/stdc++.h>

#include<cstring>

#
define ll long long
using namespace std;
long long power(ll x, ll n) {
  if (n == 0) return 1;
  ll temp = power(x, n / 2);
  if (n % 2 == 0) return temp * temp;
  else return x * temp * temp;

}
ll max(ll a, ll b) {
  return a > b ? a : b;

}

ll max(ll a, ll b, ll c) {
  return max(max(a, b), c);
}
ll min(ll x, ll y) {
  return x + y - max(x, y);
}
ll min(ll x, ll y, ll z) {
  return min(min(x, y), z);

}

void swap(int * a, int * b) {
  int t = * a;
  * a = * b;
  * b = t;
}

bool f(ll x, ll y) {
  return x > y;

}

int main() {
  ll n;
  cin >> n;
  cin.ignore();
  string s;
  cin >> s;
  ll total = (n * (n - 1) * (n - 2)) / 6;

  s = 'a' + s;

  ll r, b, g;
  r = b = g = 0;
  for (ll i = 1; i <= n; i++) {
    if (s[i] == 'R') r++;
    if (s[i] == 'B') b++;
    if (s[i] == 'G') g++;
  }

  ll count1 = (r * (r - 1) * (r - 2)) / 6 + (b * (b - 1) * (b - 2)) / 6 + (g * (g - 1) * (g - 2)) / 6;
  ll count2 = ((r * (r - 1)) * (b + g)) / 2 + ((b * (b - 1)) * (r + g)) / 2 + ((g * (g - 1)) * (b + r)) / 2;
  ll count3 = 0;

  for (ll i = 1; i <= n; i = i + 2) {
    for (ll k = i + 2; k <= n; k = k + 2) {
      ll j = (i + k) / 2;
      if ((s[i] != s[j]) && (s[i] != s[k]) && (s[j] != s[k])) count3++;

    }

  }
  for (ll i = 2; i <= n; i = i + 2) {
    for (ll k = i + 2; k <= n; k = k + 2) {
      ll j = (i + k) / 2;
      if ((s[i] != s[j]) && (s[i] != s[k]) && (s[j] != s[k])) count3++;

    }

  }
  cout << total - count1 - count2 - count3;

  return 0;
}

Compiler output:
a.cc:6:1: error: 'define' does not name a type
    6 | define ll long long
      | ^~~~~~
a.cc:8:17: error: 'll' was not declared in this scope
    8 | long long power(ll x, ll n) {
      |                 ^~
a.cc:8:23: error: 'll' was not declared in this scope
    8 | long long power(ll x, ll n) {
      |                       ^~
a.cc:8:27: error: expression list treated as compound expression in initializer [-fpermissive]
    8 | long long power(ll x, ll n) {
      |                           ^
a.cc:15:1: error: 'll' does not name a type
   15 | ll max(ll a, ll b) {
      | ^~
a.cc:20:1: error: 'll' does not name a type
   20 | ll max(ll a, ll b, ll c) {
      | ^~
a.cc:23:1: error: 'll' does not name a type
   23 | ll min(ll x, ll y) {
      | ^~
a.cc:26:1: error: 'll' does not name a type
   26 | ll min(ll x, ll y, ll z) {
      | ^~
a.cc:37:8: error: 'll' was not declared in this scope
   37 | bool f(ll x, ll y) {
      |        ^~
a.cc:37:14: error: 'll' was not declared in this scope
   37 | bool f(ll x, ll y) {
      |              ^~
a.cc:37:18: error: expression list treated as compound expression in initializer [-fpermissive]
   37 | bool f(ll x, ll y) {
      |                  ^
a.cc: In function 'int main()':
a.cc:43:3: error: 'll' was not declared in this scope
   43 |   ll n;
      |   ^~
a.cc:44:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   44 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:44:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   44 |   cin >> n;
      |          ^
      |          yn
a.cc:46:3: error: 'string' was not declared in this scope
   46 |   string s;
      |   ^~~~~~
a.cc:46:3: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:47:10: error: 's' was not declared in this scope
   47 |   cin >> s;
      |          ^
a.cc:48:5: error: expected ';' before 'total'
   48 |   ll total = (n * (n - 1) * (n - 2)) / 6;
      |     ^~~~~~
      |     ;
a.cc:52:5: error: expected ';' before 'r'
   52 |   ll r, b, g;
      |     ^~
      |     ;
a.cc:53:3: error: 'r' was not declared in this scope
   53 |   r = b = g = 0;
      |   ^
a.cc:53:7: error: 'b' was not declared in this scope
   53 |   r = b = g = 0;
      |       ^
a.cc:53:11: error: 'g' was not declared in this scope
   53 |   r = b = g = 0;
      |           ^
a.cc:54:10: error: expected ';' before 'i'
   54 |   for (ll i = 1; i <= n; i++) {
      |          ^~
      |          ;
a.cc:54:18: error: 'i' was not declared in this scope
   54 |   for (ll i = 1; i <= n; i++) {
      |                  ^
a.cc:60:5: error: expected ';' before 'count1'
   60 |   ll count1 = (r * (r - 1) * (r - 2)) / 6 + (b * (b - 1) * (b - 2)) / 6 + (g * (g - 1) * (g - 2)) / 6;
      |     ^~~~~~~
      |     ;
a.cc:61:5: error: expected ';' before 'count2'
   61 |   ll count2 = ((r * (r - 1)) * (b + g)) / 2 + ((b * (b - 1)) * (r + g)) / 2 + ((g * (g - 1)) * (b + r)) / 2;
      |     ^~~~~~~
      |     ;
a.cc:62:5: error: expected ';' before 'count3'
   62 |   ll count3 = 0;
      |     ^~~~~~~
      |     ;
a.cc:64:10: error: expected ';' before 'i'
   64 |   for (ll i = 1; i <= n; i = i + 2) {
      |          ^~
      |          ;
a.cc:64:18: error: 'i' was not declared in this scope
   64 |   for (ll i = 1; i <= n; i = i + 2) {
      |                  ^
a.cc:65:12: error: expected ';' before 'k'
   65 |     for (ll k = i + 2; k <= n; k = k + 2) {
      |            ^~
      |            ;
a.cc:65:24: error: 'k' was not declared in this scope
   65 |     for (ll k = i + 2; k <= n; k = k + 2) {
      |                        ^
a.cc:66:9: error: expected ';' before 'j'
   66 |       ll j = (i + k) / 2;
      |         ^~
      |         ;
a.cc:67:22: error: 'j' was not declared in this scope; did you mean 'jn'?
   67 |       if ((s[i] != s[j]) && (s[i] != s[k]) && (s[j] != s[k])) count3++;
      |                      ^
      |                      jn
a.cc:67:63: error: 'count3' was not declared in this scope
   67 |       if ((s[i] != s[j]) && (s[i] != s[k]) && (s[j] != s[k])) count3++;
      |                                                               ^~~~~~
a.cc:72:10: error: expected ';' before 'i'
   72 |   for (ll i = 2; i <= n; i = i + 2) {
      |          ^~
      |          ;
a.cc:72:18: error: 'i' was not declared in this scope
   72 |   for (ll i = 2; i <= n; i = i + 2) {
      |                  ^
a.cc:73:12: error: expected ';' before 'k'
   73 |     for (ll k = i + 2; k <= n; k = k + 2) {
      |            ^~
      |            ;
a.cc:73:24: error: 'k' was not declared in this scope
   73 |     for (ll k = i + 2; k <= n; k = k + 2) {
      |                        ^
a.cc:74:9: error: expected ';' before 'j'
   74 |       ll j = (i + k) / 2;
      |         ^~
      |         ;
a.cc:75:22: error: 'j' was not declared in this scope; did you mean 'jn'?
   75 |       if ((s[i] != s[j]) && (s[i] != s[k]) && (s[j] != s[k])) count3++;
      |                      ^
      |                      jn
a.cc:75:63: error: 'count3' was not declared in this scope
   75 |       if ((s[i] != s[j]) && (s[i] != s[k]) && (s[j] != s[k])) count3++;
      |                                                               ^~~~~~
a.cc:80:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   80 |   cout << total - count1 - count2 - count3;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:80:11: error: 'total' was not declared in this scope
   80 |   cout << total - count1 - count2 - count3;
      |           ^~~~~
a.cc:80:19: error: 'count1' was not declared in this scope
   80 |   cout << total - count1 - count2 - count3;
      |                   ^~~~~~
a.cc:80:28: error: 'count2' was not declared in this scope
   80 |   cout << total - count1 - count2 - count3;
      |                            ^~~~~~
a.cc:80:37: error: 'count3' was not declared in this scope
   80 |   cout << total - count1 - count2 - count3;
      |                                     ^~~~~~