#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
size_t strlen(char *);
int main() {
  char buffer[1000001];
  scanf("%s", buffer);
  size_t next = 0, len = strlen(buffer);
  while (next < len) {
    if (next + 2 < len && (((buffer[next]) == 'R'   ? 1
                            : (buffer[next]) == 'B' ? 2
                                                    : 4) |
                           ((buffer[next + 1]) == 'R'   ? 1
                            : (buffer[next + 1]) == 'B' ? 2
                                                        : 4) |
                           ((buffer[next + 2]) == 'R'   ? 1
                            : (buffer[next + 2]) == 'B' ? 2
                                                        : 4)) == 7) {
      printf("C");
      next += 3;
    } else {
      printf(buffer[next] == 'R' ? "S" : buffer[next] == 'B' ? "K" : "H");
      next++;
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4280,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xf4250(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1050 <scanf@plt>
movq   $0x0,-0xf4258(%rbp)
lea    -0xf4250(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0xf4260(%rbp)
mov    -0xf4258(%rbp),%rax
cmp    -0xf4260(%rbp),%rax
jae    1359 <main+0x229>
mov    -0xf4258(%rbp),%rax
add    $0x2,%rax
cmp    -0xf4260(%rbp),%rax
jae    12e0 <main+0x1b0>
mov    -0xf4258(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%eax
ff
cmp    $0x52,%eax
jne    11c7 <main+0x97>
mov    $0x1,%eax
mov    %eax,-0xf4264(%rbp)
jmp    11ec <main+0xbc>
mov    -0xf4258(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%edx
ff
mov    $0x4,%eax
mov    $0x2,%ecx
cmp    $0x42,%edx
cmove  %ecx,%eax
mov    %eax,-0xf4264(%rbp)
mov    -0xf4264(%rbp),%eax
mov    %eax,-0xf4268(%rbp)
mov    -0xf4258(%rbp),%rax
movsbl -0xf424f(%rbp,%rax,1),%eax
ff
cmp    $0x52,%eax
jne    1220 <main+0xf0>
mov    $0x1,%eax
mov    %eax,-0xf426c(%rbp)
jmp    1245 <main+0x115>
mov    -0xf4258(%rbp),%rax
movsbl -0xf424f(%rbp,%rax,1),%edx
ff
mov    $0x4,%eax
mov    $0x2,%ecx
cmp    $0x42,%edx
cmove  %ecx,%eax
mov    %eax,-0xf426c(%rbp)
mov    -0xf4268(%rbp),%eax
mov    -0xf426c(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0xf4270(%rbp)
mov    -0xf4258(%rbp),%rax
movsbl -0xf424e(%rbp,%rax,1),%eax
ff
cmp    $0x52,%eax
jne    1281 <main+0x151>
mov    $0x1,%eax
mov    %eax,-0xf4274(%rbp)
jmp    12a6 <main+0x176>
mov    -0xf4258(%rbp),%rax
movsbl -0xf424e(%rbp,%rax,1),%edx
ff
mov    $0x4,%eax
mov    $0x2,%ecx
cmp    $0x42,%edx
cmove  %ecx,%eax
mov    %eax,-0xf4274(%rbp)
mov    -0xf4270(%rbp),%eax
mov    -0xf4274(%rbp),%ecx
or     %ecx,%eax
cmp    $0x7,%eax
jne    12e0 <main+0x1b0>
lea    0xd3f(%rip),%rdi
call   1040 <printf@plt>
mov    -0xf4258(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0xf4258(%rbp)
jmp    1354 <main+0x224>
mov    -0xf4258(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%eax
ff
cmp    $0x52,%eax
jne    130b <main+0x1db>
lea    0xd06(%rip),%rax
mov    %rax,-0xf4280(%rbp)
jmp    1336 <main+0x206>
mov    -0xf4258(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%edx
ff
lea    0xce8(%rip),%rax
lea    0xcdf(%rip),%rcx
cmp    $0x42,%edx
cmove  %rcx,%rax
mov    %rax,-0xf4280(%rbp)
mov    -0xf4280(%rbp),%rdi
call   1040 <printf@plt>
mov    -0xf4258(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf4258(%rbp)
jmp    1173 <main+0x43>
lea    0xcab(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf4280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf4248,%rsp
lea    0xea8(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     1227 <main+0xe7>
mov    %rax,%r14
xor    %ebx,%ebx
mov    $0x1,%ebp
lea    0xe80(%rip),%r15
lea    0xe7b(%rip),%r12
lea    0xe70(%rip),%r13
jmp    11bd <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    $0x42,%al
mov    %r12,%rdi
cmove  %r15,%rdi
cmp    $0x52,%al
cmove  %r13,%rdi
call   1050 <printf@plt>
cmp    %r14,%rbx
jae    1227 <main+0xe7>
lea    0x2(%rbx),%rcx
movzbl (%rsp,%rbx,1),%eax
cmp    %r14,%rcx
jae    11a0 <main+0x60>
xor    %ecx,%ecx
cmp    $0x42,%al
setne  %cl
cmp    $0x52,%al
lea    0x2(%rcx,%rcx,1),%ecx
cmove  %ebp,%ecx
movzbl 0x1(%rsp,%rbx,1),%edx
movzbl 0x2(%rsp,%rbx,1),%esi
xor    %edi,%edi
cmp    $0x42,%dl
setne  %dil
cmp    $0x52,%dl
lea    0x2(%rdi,%rdi,1),%edx
cmove  %ebp,%edx
or     %ecx,%edx
xor    %ecx,%ecx
cmp    $0x42,%sil
setne  %cl
cmp    $0x52,%sil
lea    0x2(%rcx,%rcx,1),%ecx
cmove  %ebp,%ecx
or     %edx,%ecx
cmp    $0x7,%ecx
jne    11a0 <main+0x60>
mov    $0x43,%edi
call   1030 <putchar@plt>
add    $0x3,%rbx
cmp    %r14,%rbx
jb     11bd <main+0x7d>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xf4248,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"C\00"
@.str.2 = [2 x i8] c"S\00"
@.str.3 = [2 x i8] c"K\00"
@.str.4 = [2 x i8] c"H\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000001 x i8]
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
store i64 0, i64* %3
%7 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 0
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %4
br label %9
9: ; preds = %98, %0
%10 = load i64, i64* %3
%11 = load i64, i64* %4
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %99
13: ; preds = %9
%14 = load i64, i64* %3
%15 = add i64 %14, 2
%16 = load i64, i64* %4
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %78
18: ; preds = %13
%19 = load i64, i64* %3
%20 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 82
br i1 %23, label %24, label %25
24: ; preds = %18
br label %33
25: ; preds = %18
%26 = load i64, i64* %3
%27 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 66
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 2, i32 4
br label %33
33: ; preds = %25, %24
%34 = phi i32 [ 1, %24 ], [ %32, %25 ]
%35 = load i64, i64* %3
%36 = add i64 %35, 1
%37 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 82
br i1 %40, label %41, label %42
41: ; preds = %33
br label %51
42: ; preds = %33
%43 = load i64, i64* %3
%44 = add i64 %43, 1
%45 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 66
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 2, i32 4
br label %51
51: ; preds = %42, %41
%52 = phi i32 [ 1, %41 ], [ %50, %42 ]
%53 = or i32 %34, %52
%54 = load i64, i64* %3
%55 = add i64 %54, 2
%56 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 82
br i1 %59, label %60, label %61
60: ; preds = %51
br label %70
61: ; preds = %51
%62 = load i64, i64* %3
%63 = add i64 %62, 2
%64 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 66
%68 = zext i1 %67 to i64
%69 = select i1 %67, i32 2, i32 4
br label %70
70: ; preds = %61, %60
%71 = phi i32 [ 1, %60 ], [ %69, %61 ]
%72 = or i32 %53, %71
%73 = icmp eq i32 %72, 7
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%76 = load i64, i64* %3
%77 = add i64 %76, 3
store i64 %77, i64* %3
br label %98
78: ; preds = %70, %13
%79 = load i64, i64* %3
%80 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 82
br i1 %83, label %84, label %85
84: ; preds = %78
br label %93
85: ; preds = %78
%86 = load i64, i64* %3
%87 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %2, i64 0, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 66
%91 = zext i1 %90 to i64
%92 = select i1 %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
br label %93
93: ; preds = %85, %84
%94 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %84 ], [ %92, %85 ]
%95 = call i32 @printf(i8* %94)
%96 = load i64, i64* %3
%97 = add i64 %96, 1
store i64 %97, i64* %3
br label %98
98: ; preds = %93, %74
br label %9
99: ; preds = %9
%100 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"S\00"
@.str.3 = [2 x i8] c"K\00"
@.str.4 = [2 x i8] c"H\00"
define i32 @main() {
%1 = alloca [1000001 x i8]
%2 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i64 @strlen(i8* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %48, label %6
6: ; preds = %0, %45
%7 = phi i64 [ %46, %45 ], [ 0, %0 ]
%8 = add i64 %7, 2
%9 = icmp ult i64 %8, %4
%10 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %1, i64 0, i64 %7
%11 = load i8, i8* %10
br i1 %9, label %14, label %12
12: ; preds = %6
%13 = add nuw i64 %7, 1
br label %38
14: ; preds = %6
%15 = icmp eq i8 %11, 82
%16 = icmp eq i8 %11, 66
%17 = select i1 %16, i32 2, i32 4
%18 = select i1 %15, i32 1, i32 %17
%19 = add nuw i64 %7, 1
%20 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 82
%23 = icmp eq i8 %21, 66
%24 = select i1 %23, i32 2, i32 4
%25 = select i1 %22, i32 1, i32 %24
%26 = or i32 %25, %18
%27 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %1, i64 0, i64 %8
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 82
%30 = icmp eq i8 %28, 66
%31 = select i1 %30, i32 2, i32 4
%32 = select i1 %29, i32 1, i32 %31
%33 = or i32 %26, %32
%34 = icmp eq i32 %33, 7
br i1 %34, label %35, label %38
35: ; preds = %14
%36 = call i32 @putchar(i32 67)
%37 = add i64 %7, 3
br label %45
38: ; preds = %12, %14
%39 = phi i64 [ %13, %12 ], [ %19, %14 ]
%40 = icmp eq i8 %11, 82
%41 = icmp eq i8 %11, 66
%42 = select i1 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%43 = select i1 %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %42
%44 = call i32 @printf(i8* dereferenceable(1) %43)
br label %45
45: ; preds = %38, %35
%46 = phi i64 [ %37, %35 ], [ %39, %38 ]
%47 = icmp ult i64 %46, %4
br i1 %47, label %6, label %48
48: ; preds = %45, %0
%49 = call i32 @putchar(i32 10)
ret i32 0
}