Buggy python submission (verdict: Time Limit Exceeded):
n,q=[int(i) for i in input().split()]
s=input().replace("AC","10")
f=[1 if s[i]=="1" else 0 for i in range(n)]
for i in range(q):
  l,r=[int(i)-1 for i in input().split()]
  print(sum(f[l:r]))


Fixed submission:
n,q=map(int,input().split())
l=[0 for i in range(n)]
for i,v in enumerate(list(input().replace("AC","X!"))):
    l[i]=l[i-1]+(v=="!")
for c in range(q):
    h,m=map(int,input().split())
    print(l[m-1]-l[h-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input().replace("AC","10")
f=[1 if s[i]=="1" else 0 for i in range(n)]
for i in range(q):
  l,r=map(int,input().split())
  print(sum(f[l-1:r-1]))


Fixed submission:
n,q=map(int,input().split())
l=[0 for i in range(n)]
for i,v in enumerate(list(input().replace("AC","X!"))):
    l[i]=l[i-1]+(v=="!")
for c in range(q):
    h,m=map(int,input().split())
    print(l[m-1]-l[h-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input().replace("AC","10").replace("A","0").replace("T","0").replace("C","0").replace("G","0")
for i in range(q):
  l,r=map(int,input().split())
  print(len(s[l-1:r-1].replace("0","")))

Fixed submission:
n,q=map(int,input().split())
l=[0 for i in range(n)]
for i,v in enumerate(list(input().replace("AC","X!"))):
    l[i]=l[i-1]+(v=="!")
for c in range(q):
    h,m=map(int,input().split())
    print(l[m-1]-l[h-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=list(map(int,input().replace("AC","1 0 ").replace("A","0 ").replace("T","0 ").replace("C","0 ").replace("G","0 ").split()))
for i in range(q):
  l,r=map(int,input().split())
  print(sum(s[l-1:r-1]))

Fixed submission:
n,q=map(int,input().split())
l=[0 for i in range(n)]
for i,v in enumerate(list(input().replace("AC","X!"))):
    l[i]=l[i-1]+(v=="!")
for c in range(q):
    h,m=map(int,input().split())
    print(l[m-1]-l[h-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=list(map(int,input().replace("AC"," 1 0 ").replace("A"," 0 ").replace("T"," 0 ").replace("C"," 0 ").replace("G"," 0 ").replace("  "," ").split()))
for i in range(q):
  l,r=map(int,input().split())
  print(sum(s[l-1:r-1]))

Fixed submission:
n,q=map(int,input().split())
l=[0 for i in range(n)]
for i,v in enumerate(list(input().replace("AC","X!"))):
    l[i]=l[i-1]+(v=="!")
for c in range(q):
    h,m=map(int,input().split())
    print(l[m-1]-l[h-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
f=[0]*n
for i in range(n-1):
  if s[i:i+2]=="AC":f[i]=1
for i in range(q):
  l,r=map(int,input().split())
  print(sum(f[l-1:r-1]))

Fixed submission:
n,q=map(int,input().split())
l=[0 for i in range(n)]
for i,v in enumerate(list(input().replace("AC","X!"))):
    l[i]=l[i-1]+(v=="!")
for c in range(q):
    h,m=map(int,input().split())
    print(l[m-1]-l[h-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
f=[0]*n
for i,a in enumerate(zip(s,s[1:])):
  if a==("A","C"):f[i]=1
for i in range(q):
  l,r=map(int,input().split())
  print(sum(f[l-1:r-1]))

Fixed submission:
n,q=map(int,input().split())
l=[0 for i in range(n)]
for i,v in enumerate(list(input().replace("AC","X!"))):
    l[i]=l[i-1]+(v=="!")
for c in range(q):
    h,m=map(int,input().split())
    print(l[m-1]-l[h-1])