#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*/ add(unsigned short *, int, int);
int /*<<< orphan*/ init(unsigned short *, int);
int /*<<< orphan*/ printf(char *, int);
int query(unsigned short *, int, int);
int scanf(char *, ...);
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  unsigned short int nums[n];
  init(nums, n);
  int i = 0;
  char op;
  int val;
  while (i < m) {
    if (2 == scanf("%c %d", &op, &val)) {
      i++;
      if (op == 'C')
        add(nums, n, val);
      else if (op == 'Q')
        printf("%d\n", query(nums, n, val));
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(%rax,%rax,1),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%esi
call   1060 <init@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123c <main+0xec>
lea    0xe4b(%rip),%rdi
lea    -0x25(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
jne    1237 <main+0xe7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0x43,%eax
jne    1203 <main+0xb3>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1030 <add@plt>
jmp    1232 <main+0xe2>
movsbl -0x25(%rbp),%eax
cmp    $0x51,%eax
jne    122d <main+0xdd>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1050 <query@plt>
mov    %eax,%esi
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
jmp    1232 <main+0xe2>
jmp    1237 <main+0xe7>
jmp    11a8 <main+0x58>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe98(%rip),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x30(%rbp),%eax
mov    %rsp,%r14
add    %rax,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x30(%rbp),%esi
mov    %r14,%rdi
call   1060 <init@plt>
cmpl   $0x0,-0x38(%rbp)
jle    121b <main+0xcb>
lea    0xe5c(%rip),%r15
lea    -0x29(%rbp),%r12
lea    -0x34(%rbp),%rbx
xor    %r13d,%r13d
jmp    11e6 <main+0x96>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    %r14,%rdi
call   1050 <query@plt>
lea    0xe40(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    -0x38(%rbp),%r13d
jge    121b <main+0xcb>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    11e0 <main+0x90>
add    $0x1,%r13d
movzbl -0x29(%rbp),%eax
cmp    $0x51,%al
je     11b7 <main+0x67>
cmp    $0x43,%al
jne    11e0 <main+0x90>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    %r14,%rdi
call   1030 <add@plt>
jmp    11e0 <main+0x90>
mov    -0x40(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [6 x i8] c"%c %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %4
%13 = alloca i16, i64 %11
store i64 %11, i64* %5
%14 = load i32, i32* %2
%15 = call i32 @init(i16* %13, i32 %14)
store i32 0, i32* %6
br label %16
16: ; preds = %44, %0
%17 = load i32, i32* %6
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %45
20: ; preds = %16
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32* %8)
%22 = icmp eq i32 2, %21
br i1 %22, label %23, label %44
23: ; preds = %20
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
%26 = load i8, i8* %7
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 67
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = load i32, i32* %2
%31 = load i32, i32* %8
%32 = call i32 @add(i16* %13, i32 %30, i32 %31)
br label %43
33: ; preds = %23
%34 = load i8, i8* %7
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 81
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i32, i32* %2
%39 = load i32, i32* %8
%40 = call i32 @query(i16* %13, i32 %38, i32 %39)
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %37, %33
br label %43
43: ; preds = %42, %29
br label %44
44: ; preds = %43, %20
br label %16
45: ; preds = %16
%46 = load i8*, i8** %4
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [6 x i8] c"%c %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
%11 = alloca i16, i64 %9
%12 = load i32, i32* %1
%13 = call i32 @init(i16* %11, i32 %12)
%14 = bitcast i32* %4 to i8*
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %37
17: ; preds = %0, %33
%18 = phi i32 [ %34, %33 ], [ 0, %0 ]
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32* %4)
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = add nsw i32 %18, 1
%23 = load i8, i8* %3
switch i8 %23, label %33 [
i8 67, label %24
i8 81, label %28
]
24: ; preds = %21
%25 = load i32, i32* %1
%26 = load i32, i32* %4
%27 = call i32 @add(i16* %11, i32 %25, i32 %26)
br label %33
28: ; preds = %21
%29 = load i32, i32* %1
%30 = load i32, i32* %4
%31 = call i32 @query(i16* %11, i32 %29, i32 %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %21, %24, %28, %17
%34 = phi i32 [ %22, %24 ], [ %22, %28 ], [ %18, %17 ], [ %22, %21 ]
%35 = load i32, i32* %2
%36 = icmp slt i32 %34, %35
br i1 %36, label %17, label %37
37: ; preds = %33, %0
ret i32 0
}