Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, Q = map(int, input().split())
S = input()
si = S.replace("AC","11")
si = si.translate(str.maketrans({"T":"0","G":"0","A":"0","C":"0"}))
for q in range(Q):
  l, r = map(int, input().split())
  if l>=2 and S[l-2:l]=="AC" and S[r-1:r+1]=="AC":
    print(int((np.sum(list(map(int,list(si[l-1:r]))))-2)/2))
  elif l>=2 and S[l-2:l]=="AC":
    print(int((np.sum(list(map(int,list(si[l-1:r]))))-1)/2))
  elif S[r-1:r+1]=="AC":
    print(int((np.sum(list(map(int,list(si[l-1:r]))))-1)/2))
  else:
    print(int(np.sum(list(map(int,list(si[l-1:r]))))/2))

Fixed submission:
n, q = map(int, input().split())
s = input()
c = [0]
for i in range(len(s)-1):
  if s[i] == "A" and s[i+1] == "C":
    c.append(c[-1]+1)
  else:
    c.append(c[-1])
    
for i in range(q):
  l, r = map(int, input().split())
  print(c[r-1] - c[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
si = S.replace("AC","11")
si = si.translate(str.maketrans({"T":"0","G":"0","A":"0","C":"0"}))
for q in range(Q):
  l, r = map(int, input().split())
  if l>=2 and S[l-2:l]=="AC" and S[r-1:r+1]=="AC":
    print(int((sum(map(int,list(si[l-1:r])))-2)/2))
  elif l>=2 and S[l-2:l]=="AC":
    print(int((sum(map(int,list(si[l-1:r])))-1)/2))
  elif S[r-1:r+1]=="AC":
    print(int((sum(map(int,list(si[l-1:r])))-1)/2))
  else:
    print(int(sum(map(int,list(si[l-1:r])))/2))

Fixed submission:
n, q = map(int, input().split())
s = input()
c = [0]
for i in range(len(s)-1):
  if s[i] == "A" and s[i+1] == "C":
    c.append(c[-1]+1)
  else:
    c.append(c[-1])
    
for i in range(q):
  l, r = map(int, input().split())
  print(c[r-1] - c[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
S = S.translate(str.maketrans({"T":"0","G":"0"}))
for q in range(Q):
  l, r = map(int, input().split())
  si = S[l-1:r].replace("AC","11")
  si = si.translate(str.maketrans({"A":"0","C":"0"}))
  print(int(sum(map(int,list(si)))/2))

Fixed submission:
n, q = map(int, input().split())
s = input()
c = [0]
for i in range(len(s)-1):
  if s[i] == "A" and s[i+1] == "C":
    c.append(c[-1]+1)
  else:
    c.append(c[-1])
    
for i in range(q):
  l, r = map(int, input().split())
  print(c[r-1] - c[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for q in range(Q):
  l, r = map(int, input().split())
  si = S[l-1:r].replace("AC","11")
  si = si.translate(str.maketrans({"A":"0","T":"0","G":"0","C":"0"}))
  print(int(sum(map(int,list(si)))/2))

Fixed submission:
n, q = map(int, input().split())
s = input()
c = [0]
for i in range(len(s)-1):
  if s[i] == "A" and s[i+1] == "C":
    c.append(c[-1]+1)
  else:
    c.append(c[-1])
    
for i in range(q):
  l, r = map(int, input().split())
  print(c[r-1] - c[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for q in range(Q):
  l, r = map(int, input().split())
  si = S[l-1:r]
  print(si.count("AC"))

Fixed submission:
n, q = map(int, input().split())
s = input()
c = [0]
for i in range(len(s)-1):
  if s[i] == "A" and s[i+1] == "C":
    c.append(c[-1]+1)
  else:
    c.append(c[-1])
    
for i in range(q):
  l, r = map(int, input().split())
  print(c[r-1] - c[l-1])