Language: C

use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();

    let mut R = vec![];
    let mut G = vec![];
    let mut B = vec![];

    for i in 0..n {
      if s[i] == 'R' {
        R.push(i);
      } else if s[i] == 'G' {
        G.push(i);
      } else {
        B.push(i);
      }
    }

    let mut ans: usize = 0;

    // (R, G, B)
    for &r in &R {
      for &g in &G {
        for &b in &B {
          let mut v = vec![r, g, b];
          v.sort();
          let (i, j, k) = (v[0], v[1], v[2]);
          if 2 * j != k + i {
            ans += 1;
          }
        }
      }
    }

    println!("{}", ans);
}


Compiler output:
main.c:1:1: error: unknown type name 'use'
    1 | use std::vec::Vec;
      | ^~~
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '::' token
    1 | use std::vec::Vec;
      |        ^~
main.c:3:1: error: unknown type name 'fn'
    3 | fn read<T: std::str::FromStr>() -> T {
      | ^~
main.c:3:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    3 | fn read<T: std::str::FromStr>() -> T {
      |        ^
main.c:9:1: error: unknown type name 'fn'
    9 | fn read_vec<T: std::str::FromStr>() -> Vec<T> {
      | ^~
main.c:9:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    9 | fn read_vec<T: std::str::FromStr>() -> Vec<T> {
      |            ^
main.c:13:1: error: unknown type name 'fn'
   13 | fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
      | ^~
main.c:13:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   13 | fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
      |               ^
main.c:19:1: error: unknown type name 'fn'
   19 | fn main() {
      | ^~
main.c: In function 'main':
main.c:20:5: error: unknown type name 'let'
   20 |     let n: usize = read();
      |     ^~~
main.c:20:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
   20 |     let n: usize = read();
      |          ^
main.c:21:5: error: unknown type name 'let'
   21 |     let s: Vec<char> = read::<String>().chars().collect();
      |     ^~~
main.c:21:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
   21 |     let s: Vec<char> = read::<String>().chars().collect();
      |          ^
main.c:23:5: error: unknown type name 'let'
   23 |     let mut R = vec![];
      |     ^~~
main.c:23:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'R'
   23 |     let mut R = vec![];
      |             ^
main.c:24:5: error: unknown type name 'let'
   24 |     let mut G = vec![];
      |     ^~~
main.c:24:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'G'
   24 |     let mut G = vec![];
      |             ^
main.c:25:5: error: unknown type name 'let'
   25 |     let mut B = vec![];
      |     ^~~
main.c:25:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'B'
   25 |     let mut B = vec![];
      |             ^
main.c:27:9: error: expected '(' before 'i'
   27 |     for i in 0..n {
      |         ^
      |         (
main.c:27:9: error: 'i' undeclared (first use in this function)
main.c:27:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:27:14: error: too many decimal points in number
   27 |     for i in 0..n {
      |              ^~~~
main.c:40:9: error: expected '(' before '&' token
   40 |     for &r in &R {
      |         ^
      |         (
main.c:40:10: error: 'r' undeclared (first use in this function)
   40 |     for &r in &R {
      |          ^