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 Scala (2.11.7) (judge verdict: Runtime Error)

import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val indicesSetNumber = sc.nextLine().split(" ")(1).toInt
    getAC(sc, indicesSetNumber.toInt)
  }

  def getAC(sc: Scanner, indicesSetNumber: Int) = {
    val targetLetters: String = sc.nextLine()
    val acIndex: List[Int] = (targetLetters.slice(0, targetLetters.length() - 1) zip targetLetters.slice(1, targetLetters.length())).zipWithIndex.collect { case (elem, idx) if elem == ('A', 'C') => idx }.toList
    val acIndexLength: Int = acIndex.length

    def getAcNumberBefore(targetIndex: Int): Int = {
      acIndex.takeWhile(ind => ind < targetIndex).length
    }

    def getAcNumberAfter(targetIndex: Int): Int = {
      acIndex.dropWhile(ind => ind < targetIndex).length
    }

    @annotation.tailrec
    def go(n: Int): Unit = {
      if (n == 0) return
      else {
        val indices: Array[Int] = sc.nextLine().split(" ").map(i => i.toInt)
        if (indices(1) < targetLetters.length / 2){
          println(getAcNumberBefore(indices(1) - 1) - getAcNumberBefore(indices(0) - 1))
        }
        else {
          val beforeNumber: Int = getAcNumberBefore(indices(0) - 1)
          val afterNumber: Int = getAcNumberAfter(indices(1) - 1)
          println(acIndexLength - beforeNumber - afterNumber)
        }
        go(n - 1)
      }
    }

    go(indicesSetNumber)
  }
}