Buggy python submission (verdict: Time Limit Exceeded):
def find_AC(S):
  ret = []
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret.append(i)
  return ret

N, Q = [int(x) for x in input().split()]
S = input()
result = find_AC(S)
pos = [res+1 for res in result]

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = 0
  for p in pos:
    if p>=l and p<=r-1:
      ans += 1
  print(ans)


Fixed submission:
import numpy as np
def find_AC(S):
  ret = [0]*len(S)
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret[i+1] = 1
  return ret

N, Q = [int(x) for x in input().split()]
S = input()

cum = np.cumsum(find_AC(S))

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = cum[r-1] - cum[l-1]
  print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
import re

def find_AC(S):
  ret = []
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret.append(i)
  return re

N, Q = [int(x) for x in input().split()]
S = input()
result = find_AC(S)
#pos = np.array([res.start()+1 for res in result])
pos = [res.start()+1 for res in result]

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = 0
  for p in pos:
    if p>=l and p<=r-1:
      ans += 1
  print(ans)


Fixed submission:
import numpy as np
def find_AC(S):
  ret = [0]*len(S)
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret[i+1] = 1
  return ret

N, Q = [int(x) for x in input().split()]
S = input()

cum = np.cumsum(find_AC(S))

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = cum[r-1] - cum[l-1]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import re
prog = re.compile('AC')
N, Q = [int(x) for x in input().split()]
S = input()
result = prog.finditer(S)
#pos = np.array([res.start()+1 for res in result])
pos = [res.start()+1 for res in result]

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = 0
  for p in pos:
    if p>=l and p<=r-1:
      ans += 1
  print(ans)


Fixed submission:
import numpy as np
def find_AC(S):
  ret = [0]*len(S)
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret[i+1] = 1
  return ret

N, Q = [int(x) for x in input().split()]
S = input()

cum = np.cumsum(find_AC(S))

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = cum[r-1] - cum[l-1]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import re
prog = re.compile('AC')
N, Q = [int(x) for x in input().split()]
S = input()
result = prog.finditer(S)
pos = np.array([res.start()+1 for res in result])

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  print(np.count_nonzero(np.logical_and(pos>=l, pos<=r-1)))

Fixed submission:
import numpy as np
def find_AC(S):
  ret = [0]*len(S)
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret[i+1] = 1
  return ret

N, Q = [int(x) for x in input().split()]
S = input()

cum = np.cumsum(find_AC(S))

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = cum[r-1] - cum[l-1]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import re
prog = re.compile('AC')
N, Q = [int(x) for x in input().split()]
S = input()
result = prog.finditer(S)
pos = np.array([res.start()+1 for res in result])

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  print(len(pos[np.logical_and(pos>=l, pos<=r-1)]))


Fixed submission:
import numpy as np
def find_AC(S):
  ret = [0]*len(S)
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret[i+1] = 1
  return ret

N, Q = [int(x) for x in input().split()]
S = input()

cum = np.cumsum(find_AC(S))

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = cum[r-1] - cum[l-1]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import re
prog = re.compile('AC')
N, Q = [int(x) for x in input().split()]
S = input()
for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  result = prog.findall(S[l-1:r])
  if result:
  	print(len(result))
  else:
    print(0)


Fixed submission:
import numpy as np
def find_AC(S):
  ret = [0]*len(S)
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret[i+1] = 1
  return ret

N, Q = [int(x) for x in input().split()]
S = input()

cum = np.cumsum(find_AC(S))

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = cum[r-1] - cum[l-1]
  print(ans)