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 C (GCC 9.2.1) (judge verdict: Time Limit Exceeded)

#include<stdio.h>

int main(){
  long n,a,b,c;
  scanf("%ld%ld%ld%ld",&n,&a,&b,&c);
  char s[n+1][3];
  for(long i=1;i<=n;i++)scanf("%s",s[i]);
  char ans[n+1];
  
  for(long i=1;i<=n;i++){
    if(s[i][0]=='A'&&s[i][1]=='B'){
      if(a>=b){a-=1;b+=1;ans[i]='B';}else{b-=1;a+=1;ans[i]='A';}
    }
    if(s[i][0]=='A'&&s[i][1]=='C'){
      if(c>=a){c-=1;a+=1;ans[i]='A';}else{a-=1;c+=1;ans[i]='C';}
    }
    if(s[i][0]=='B'&&s[i][1]=='C'){
      if(b>=c){b-=1;c+=1;ans[i]='C';}else{c-=1;b+=1;ans[i]='B';}
    }
    if(a<0||b<0||c<0){printf("No");return 0;}
  }
  printf("Yes\n");
  for(long i=1;i<=n;i++){
    printf("%c\n",ans[i]);
  }
  return 0;
}