Problem:
Score : 100 points

Problem Statement

On the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.

You are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.

Constraints

b is one of the letters A, C, G and T.

Input

Input is given from Standard Input in the following format:

b

Output

Print the letter representing the base that bonds with the base b.

Sample Input 1

A

Sample Output 1

T

Sample Input 2

G

Sample Output 2

C

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

use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let s:String = sc.next();
    let res = match s.as_str() {
        "A" => "T",
        "T" => "A",
        "C" => "G",
        "G" => "C",
        _ => panic!(),
    };
    println!("{}", res);
}

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

/// ```
/// use contest::math;
/// assert_eq!(3, math::inv(2,5));
/// assert_eq!(1, math::inv(1,2));
/// assert_eq!(1, math::inv(3,2));
/// ```
pub fn inv(value: i32, modulo_prime: i32) -> i32 {
    return pow_mod(value, modulo_prime - 2, modulo_prime);
}

/// ```
/// use contest::math;
/// assert_eq!(8, math::pow_mod(2,3,10));
/// assert_eq!(1, math::pow_mod(3,4,10));
/// assert_eq!(1, math::pow_mod(0,0,3));
/// assert_eq!(0, math::pow_mod(0,0,1));
/// ```
pub fn pow_mod(value: i32, exponent: i32, modulo: i32) -> i32 {
    if exponent < 0 {
        panic!("Exponent should >= 0.");
    }
    if modulo == 1 {
        return 0;
    }
    let modulo = modulo as i64;
    let mut value = value as i64;
    if value >= modulo {
        value %= modulo;
    }
    if value < 0 {
        value = value % modulo + value;
    }
    let mut res = 1;
    let mut exponent = exponent;
    while exponent > 0 {
        if (exponent & 1) == 1 {
            res = res * value % modulo;
        }
        value = value * value % modulo;
        exponent >>= 1;
    }
    res as i32
}

/// ```
/// use contest::vec;
/// let mut is = vec![2,3,1];
/// assert!(vec::next_permutation(&mut is));
/// assert_eq!(vec![3,1,2], is);
/// assert!(vec::next_permutation(&mut is));
/// assert_eq!(vec![3,2,1], is);
/// assert!(!vec::next_permutation(&mut is));
/// assert_eq!(vec![1,2,3], is);
///
/// let mut is = (0..3).collect();
/// let mut count = 0;
/// loop {
///     count+=1;
///     // Do something using is
///     if !vec::next_permutation(&mut is) {
///         break;
///     }
/// }
/// assert_eq!(6, count);
///
/// let mut is = vec![1,2,1];
/// assert!(vec::next_permutation(&mut is));
/// assert_eq!(vec![2,1,1], is);
/// assert!(!vec::next_permutation(&mut is));
/// assert_eq!(vec![1,1,2], is);
/// ```
pub fn next_permutation(is: &mut Vec<i32>) -> bool {
    let n = is.len();
    for i in (1..n).rev() {
        let i = i as usize;
        if is[i - 1] < is[i] {
            let mut j = n - 1;
            while is[i - 1] >= is[j] {
                j -= 1;
            }
            is.swap(i - 1, j);
            reverse(is, i, n);
            return true;
        }
    }
    is.reverse();
    false
}

fn reverse(v: &mut Vec<i32>, from_inclusive: usize, to_exclusive: usize) {
    let mut i = from_inclusive;
    let mut j = to_exclusive - 1;
    while i < j {
        v.swap(i, j);
        i += 1;
        j -= 1;
    }
}
/// Scanner
///
/// # Example
/// ```
/// use contest::scanner;
/// let mut sc = scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>());
/// assert_eq!(2, sc.next());
/// assert_eq!(3.5, sc.next());
///
/// // To create a scanner from stdin:
/// scanner::new(std::io::stdin());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

pub fn new<R: io::Read>(r: R) -> Scanner<R> {
    Scanner::new(r)
}

impl<R: io::Read> Scanner<R> {
    #[inline]
    fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        self.next_string()
            .map(|s| s.parse::<T>().expect("Parse failed: "))
            .expect("Unexpected EOF")
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}

#[test]
fn next() {
    let mut sc = new("hoge".as_bytes());
    let s: String = sc.next();
    assert_eq!("hoge", s);
}