Language: C++

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
#define int long long
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

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

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

  // r,g,b のすべての組み合わせ
  // - r,g,b の組み合わせかつ index の差が等しい

  int ac = 0,gc = 0,bc = 0;

  rep(i,n) {
    if (s[i] == 'R') {
      ac += 1;
    } else if (s[i] == 'G') {
      gc += 1;
    } else if (s[i] == 'B') {
      bc += 1;
    }
  }
  // すべての組み合わせ
  ll sum = ac*gc*bc;

  // index の差が等しい
  ll minus = 0;
  for (int i = 0; i < n; i++)
  {
    for (int j = i+1; j < n; j++)
    {
      int k = j + j - i;
      if (k >= n) continue;
      if (s[i] == s[j] || s[i] == s[k] || s[j] == s[k]) continue;
      minus++;
    }
  }
  
  cout << sum - minus << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:4:35: note: in expansion of macro 'int'
    4 | #define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
      |                                   ^~~
a.cc:3:20: note: in expansion of macro 'repi'
    3 | #define _rep(i, n) repi(i, 0, n)
      |                    ^~~~
a.cc:2:43: note: in expansion of macro '_rep'
    2 | #define _overload3(_1, _2, _3, name, ...) name
      |                                           ^~~~
a.cc:5:18: note: in expansion of macro '_overload3'
    5 | #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
      |                  ^~~~~~~~~~
a.cc:27:3: note: in expansion of macro 'rep'
   27 |   rep(i,n) {
      |   ^~~
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:4:47: note: in expansion of macro 'int'
    4 | #define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
      |                                               ^~~
a.cc:3:20: note: in expansion of macro 'repi'
    3 | #define _rep(i, n) repi(i, 0, n)
      |                    ^~~~
a.cc:2:43: note: in expansion of macro '_rep'
    2 | #define _overload3(_1, _2, _3, name, ...) name
      |                                           ^~~~
a.cc:5:18: note: in expansion of macro '_overload3'
    5 | #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
      |                  ^~~~~~~~~~
a.cc:27:3: note: in expansion of macro 'rep'
   27 |   rep(i,n) {
      |   ^~~
a.cc:7:13: error: expected ';' before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:4:47: note: in expansion of macro 'int'
    4 | #define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
      |                                               ^~~
a.cc:3:20: note: in expansion of macro 'repi'
    3 | #define _rep(i, n) repi(i, 0, n)
      |                    ^~~~
a.cc:2:43: note: in expansion of macro '_rep'
    2 | #define _overload3(_1, _2, _3, name, ...) name
      |                                           ^~~~
a.cc:5:18: note: in expansion of macro '_overload3'
    5 | #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
      |                  ^~~~~~~~~~
a.cc:27:3: note: in expansion of macro 'rep'
   27 |   rep(i,n) {
      |   ^~~
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:4:47: note: in expansion of macro 'int'
    4 | #define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
      |                                               ^~~
a.cc:3:20: note: in expansion of macro 'repi'
    3 | #define _rep(i, n) repi(i, 0, n)
      |                    ^~~~
a.cc:2:43: note: in expansion of macro '_rep'
    2 | #define _overload3(_1, _2, _3, name, ...) name
      |                                           ^~~~
a.cc:5:18: note: in expansion of macro '_overload3'
    5 | #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
      |                  ^~~~~~~~~~
a.cc:27:3: note: in expansion of macro 'rep'
   27 |   rep(i,n) {
      |   ^~~
a.cc:7:13: error: expected ')' before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:4:47: note: in expansion of macro 'int'
    4 | #define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
      |                                               ^~~
a.cc:3:20: note: in expansion of macro 'repi'
    3 | #define _rep(i, n) repi(i, 0, n)
      |                    ^~~~
a.cc:2:43: note: in expansion of macro '_rep'
    2 | #define _overload3(_1, _2, _3, name, ...) name
      |                                           ^~~~
a.cc:5:18: note: in expansion of macro '_overload3'
    5 | #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
      |                  ^~~~~~~~~~
a.cc:27:3: note: in expansion of macro 'rep'
   27 |   rep(i,n) {
      |   ^~~
a.cc:4:26: note: to match this '('
    4 | #define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
      |                          ^
a.cc:3:20: note: in expansion of macro 'repi'
    3 | #define _rep(i, n) repi(i, 0, n)
      |                    ^~~~
a.cc:2:43: note: in expansion of macro '_rep'
    2 | #define _overload3(_1, _2, _3, name, ...) name
      |                                           ^~~~
a.cc:5:18: note: in expansion of macro '_overload3'
    5 | #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
      |                  ^~~~~~~~~~
a.cc:27:3: note: in expansion of macro 'rep'
   27 |   rep(i,n) {
      |   ^~~
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:4:47: note: in expansion of macro 'int'
    4 | #define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
      |                                               ^~~
a.cc:3:20: note: in expansion of macro 'repi'
    3 | #define _rep(i, n) repi(i, 0, n)
      |                    ^~~~
a.cc:2:43: note: in expansion of macro '_rep'
    2 | #define _overload3(_1, _2, _3, name, ...) name
      |                                           ^~~~
a.cc:5:18: note: in expansion of macro '_overload3'
    5 | #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
      |                  ^~~~~~~~~~
a.cc:27:3: note: in expansion of macro 'rep'
   27 |   rep(i,n) {
      |   ^~~
a.cc:27:7: error: 'i' was not declared in this scope
   27 |   rep(i,n) {
      |       ^
a.cc:4:59: note: in definition of macro 'repi'
    4 | #define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
      |                                                           ^
a.cc:2:43: note: in expansion of macro '_rep'
    2 | #define _overload3(_1, _2, _3, name, ...) name
      |                                           ^~~~
a.cc:27:3: note: in expansion of macro 'rep'
   27 |   rep(i,n) {
      |   ^~~