Language: C

function main(N, S) {
  // const N = input.split(' ')[0];
  // const S = input.split(' ')[1];

  const S_array = S.split('');

  let r = 0,
    g = 0,
    b = 0;
  for (s of S_array) {
    if (s === 'R') ++r;
    if (s === 'G') ++g;
    if (s === 'B') ++b;
  }

  const total = r * g * b;

  let res = 0;

  for (let i = 0; i < N; i++) {
    for (let j = i + 1; j < N; j++) {
      let k = 2 * j - i;
      if (k >= N || S_array[k] === S_array[i] || S_array[k] === S_array[j] || S_array[i] === S_array[j]) continue;

      ++res;
    }
  }
  console.log(total - res);
}
const N = require('fs').readFileSync('/dev/stdin', 'utf8');
const S = require('fs').readFileSync('/dev/stdin', 'utf8');
main(N, S);

Compiler output:
main.c:1:1: error: unknown type name 'function'; did you mean 'union'?
    1 | function main(N, S) {
      | ^~~~~~~~
      | union
main.c: In function 'main':
main.c:1:10: error: type of 'N' defaults to 'int' [-Wimplicit-int]
    1 | function main(N, S) {
      |          ^~~~
main.c:1:10: error: type of 'S' defaults to 'int' [-Wimplicit-int]
main.c:5:9: error: type defaults to 'int' in declaration of 'S_array' [-Wimplicit-int]
    5 |   const S_array = S.split('');
      |         ^~~~~~~
main.c:5:20: error: request for member 'split' in something not a structure or union
    5 |   const S_array = S.split('');
      |                    ^
main.c:5:27: error: empty character constant
    5 |   const S_array = S.split('');
      |                           ^~
main.c:7:3: error: unknown type name 'let'
    7 |   let r = 0,
      |   ^~~
main.c:10:8: error: unknown type name 's'
   10 |   for (s of S_array) {
      |        ^
main.c:10:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'S_array'
   10 |   for (s of S_array) {
      |             ^~~~~~~
main.c:16:3: error: expected expression before 'const'
   16 |   const total = r * g * b;
      |   ^~~~~
main.c:18:3: error: 'let' undeclared (first use in this function)
   18 |   let res = 0;
      |   ^~~
main.c:18:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:18:6: error: expected ')' before 'res'
   18 |   let res = 0;
      |      ^~~~
      |      )
main.c:10:7: note: to match this '('
   10 |   for (s of S_array) {
      |       ^
main.c:29:1: error: expected expression before '}' token
   29 | }
      | ^
main.c: At top level:
main.c:30:7: error: type defaults to 'int' in declaration of 'N' [-Wimplicit-int]
   30 | const N = require('fs').readFileSync('/dev/stdin', 'utf8');
      |       ^
main.c:30:11: error: implicit declaration of function 'require' [-Wimplicit-function-declaration]
   30 | const N = require('fs').readFileSync('/dev/stdin', 'utf8');
      |           ^~~~~~~
main.c:30:19: warning: multi-character character constant [-Wmultichar]
   30 | const N = require('fs').readFileSync('/dev/stdin', 'utf8');
      |                   ^~~~
main.c:30:24: error: request for member 'readFileSync' in something not a structure or union
   30 | const N = require('fs').readFileSync('/dev/stdin', 'utf8');
      |                        ^
main.c:30:38: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes
   30 | const N = require('fs').readFileSync('/dev/stdin', 'utf8');
      |                                      ^~~~~~~~~~~~
main.c:30:52: warning: multi-character character constant [-Wmultichar]
   30 | const N = require('fs').readFileSync('/dev/stdin', 'utf8');
      |                                                    ^~~~~~
main.c:31:7: error: type defaults to 'int' in declaration of 'S' [-Wimplicit-int]
   31 | const S = require('fs').readFileSync('/dev/stdin', 'utf8');
      |       ^
main.c:31:19: warning: multi-character character constant [-Wmultichar]
   31 | const S = require('fs').readFileSync('/dev/stdin', 'utf8');
      |                   ^~~~
main.c:31:24: error: request for member 'readFileSync' in something not a structure or union
   31 | const S = require('fs').readFileSync('/dev/stdin', 'utf8');
      |                        ^
main.c:31:38: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes
   31 | const S = require('fs').readFileSync('/dev/stdin', 'utf8');
      |                                      ^~~~~~~~~~~~
main.c:31:52: warning: multi-character character constant [-Wmultichar]
   31 | const S = require('fs').readFileSync('/dev/stdin', 'utf8');
      |                                                    ^~~~~~
main.c:32:1: warning: data definition has no type or storage class
   32 | main(N, S);
      | ^~~~
main.c:32:1: error: type defaults to 'int' in declaration of 'main' [-Wimplicit-int]
main.c:32:1: error: parameter names (without types) in function declaration [-Wdeclaration-missing-parameter-type]