Problem:
Score : 100 points

Problem Statement

AtCoder Inc. holds a contest every Saturday.

There are two types of contests called ABC and ARC, and just one of them is held at a time.

The company holds these two types of contests alternately: an ARC follows an ABC and vice versa.

Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.

Constraints

S is ABC or ARC.

Input

Input is given from Standard Input in the following format:

S

Output

Print the string representing the type of the contest held this week.

Sample Input 1

ABC

Sample Output 1

ARC

They held an ABC last week, so they will hold an ARC this week.

Solution in Rust (1.42.0) (judge verdict: Accepted)

fn solve(s: &str) -> String {
    if s == "ABC" { "ARC" } else { "ABC" }.to_owned()
}

fn main() {
    use input::{Input, InputContent};
    use output::Output;
    let ((), s) = input::Stdin::lock().string().line().finish().build();
    let s = solve(s);
    output::Stdout::lock().string(s).line();
}

mod input {
    use std::io::BufRead;

    impl<I> FinishInput<I>
    where
        I: Input,
    {
        pub fn build(self) -> I::Payload {
            let source = self.input.get_source();
            self.input.build(source)
        }
    }

    pub trait Input {
        type Payload;
        type Source: BufRead;

        fn finish(self) -> FinishInput<Self>
        where
            Self: Sized,
        {
            FinishInput { input: self }
        }

        fn build(self, _: Self::Source) -> Self::Payload;

        fn get_source(&self) -> Self::Source;

        fn string(self) -> StringContent<'static, Self>
        where
            Self: Sized,
        {
            StringContent {
                prev_input: self,
                _lifetime_ph: &std::marker::PhantomData,
            }
        }
    }

    pub trait InputContent {
        type Content;
        type PrevInput: Input;

        fn line(self) -> Line<Self::Content, Self::PrevInput>
        where
            Self: Sized,
        {
            Line {
                prev_input: self.prev(),
                _input_content_ph: std::marker::PhantomData::<Self::Content>,
            }
        }

        fn prev(self) -> Self::PrevInput;
    }

    impl<'a> Input for Stdin<'a> {
        type Payload = ();
        type Source = std::io::StdinLock<'a>;

        fn build(self, _: Self::Source) -> Self::Payload {}

        fn get_source(&self) -> Self::Source {
            let stdin = Box::new(std::io::stdin());
            Box::leak::<'a>(stdin).lock()
        }
    }
    impl<'a> Stdin<'a> {
        pub fn lock() -> Self {
            Self {
                _life_time_ph: &std::marker::PhantomData,
            }
        }
    }

    impl<'a, P> Input for Line<&'a str, P>
    where
        P: Input,
    {
        type Payload = (P::Payload, &'a str);
        type Source = P::Source;

        fn build(self, mut source: Self::Source) -> Self::Payload {
            let s = {
                let mut s = Vec::new();
                let _ = source.read_until('\n' as u8, &mut s).unwrap();
                let s = Box::new(s);
                std::str::from_utf8(Box::leak::<'a>(s)).unwrap().trim()
            };
            (self.prev_input.build(source), s)
        }

        fn get_source(&self) -> Self::Source {
            self.prev_input.get_source()
        }
    }

    impl<'a, P> InputContent for StringContent<'a, P>
    where
        P: Input,
    {
        type Content = &'a str;
        type PrevInput = P;

        fn prev(self) -> Self::PrevInput {
            self.prev_input
        }
    }

    pub struct Stdin<'a> {
        _life_time_ph: &'a std::marker::PhantomData<()>,
    }

    pub struct Line<C, P>
    where
        P: Input,
    {
        prev_input: P,
        _input_content_ph: std::marker::PhantomData<C>,
    }

    pub struct StringContent<'a, P>
    where
        P: Input,
    {
        prev_input: P,
        _lifetime_ph: &'a std::marker::PhantomData<()>,
    }

    pub struct FinishInput<I>
    where
        I: Input,
    {
        input: I,
    }

    pub trait StripExtraTuple<T> {
        fn strip(self) -> T;
    }

    impl<T> StripExtraTuple<T> for ((), T) {
        fn strip(self) -> T {
            let ((), t) = self;
            t
        }
    }
}

mod output {
    use std::io::Write;

    pub trait Output {
        type Dest: Write;

        fn string(mut self, s: String) -> Self
        where
            Self: Sized,
        {
            s.write(self.get_dest());
            self
        }

        fn line(mut self) -> Self
        where
            Self: Sized,
        {
            let _ = self.get_dest().write_all(&['\n' as u8]).unwrap();
            self
        }

        fn get_dest(&mut self) -> &mut Self::Dest;
    }

    trait OutputContent<D>
    where
        D: Write,
    {
        fn write(self, dest: D);
    }

    impl<'a> Output for Stdout<'a> {
        type Dest = std::io::StdoutLock<'a>;

        fn get_dest(&mut self) -> &mut Self::Dest {
            &mut self.dest
        }
    }

    impl<'a> Stdout<'a> {
        pub fn lock() -> Self {
            let stdout = Box::new(std::io::stdout());
            Self {
                dest: Box::leak::<'a>(stdout).lock(),
            }
        }
    }

    impl<D> OutputContent<D> for String
    where
        D: Write,
    {
        fn write(self, mut dest: D) {
            let s = self.as_bytes();
            let _ = dest.write_all(&s).unwrap();
        }
    }

    pub struct Stdout<'a> {
        dest: std::io::StdoutLock<'a>,
    }
}