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 C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <stdlib.h>

struct pos {
	int l, r;
};

int main()
{
	int n, q, *sum;
	register int i, j, output;
	char *s, *result;
	struct pos *section;

	scanf("%d%d", &n, &q);

	if ((s = (char *)malloc(sizeof(char) * (n + 1))) == NULL)
		return 1;
	if ((result = (char *)malloc(sizeof(char) * n)) == NULL)
		return 1;
	if ((section = (struct pos *)malloc(sizeof(struct pos) * q)) == NULL)
		return 1;
	if ((sum = (int *)malloc(sizeof(int) * n)) == NULL)
		return 1;

	scanf("%s", s);
	for (i = 0; i < q; i++) 
		scanf("%d%d", &section[i].l, &section[i].r);

	for (i = 0; i < n; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C')
			result[i] = 1;
		else
			result[i] = 0;
	}

	sum[0] = result[0];
	for (i = 1; i < n; i++)
		sum[i] = sum[i - 1] + result[i];

	for (i = 0; i < q; i++) {
		printf("%d\n", sum[section[i].r - 2] - sum[section[i].l - 2]);
	}

    free(s);
	free(result);
	free(section);
	free(sum);

	return 0;
		}