qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
if sys.platform =='ios':
	sys.stdin=open('input.txt')

n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]

AC=[]
for i in range(n-1):
    if s[i]=="A":
        if s[i+1]=="C":
            AC.append(i)
print(AC)

from bisect import bisect_right as br
from bisect import bisect_left as bl
for i in range(q):
    a=bl(AC,lr[i][0]-1)
    print(i,AC,lr[i][0],a)
    b=br(AC,lr[i][1]-2)
    print(a,b)
    print(b-a)

Fixed code:
import sys
if sys.platform =='ios':
	sys.stdin=open('input.txt')

n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]

AC=[]
for i in range(n-1):
    if s[i]=="A":
        if s[i+1]=="C":
            AC.append(i)
#print(AC)

from bisect import bisect_right as br
from bisect import bisect_left as bl
for i in range(q):
    a=bl(AC,lr[i][0]-1)
    #print(i,AC,lr[i][0],a)
    b=br(AC,lr[i][1]-2)
    #print(a,b)
    print(b-a)
Buggy code:
N,Q=map(int,input().split())
S=input()
c=[0]
t = 0
for i in range(1,N):
    t += 1 if  S[i-1:i+1]=='AC' else 0
    c.append(t)
for _ in range(Q):
    l,r=map(int, intput().split))
    print(c[r]-c[l])


Fixed code:
N,Q=map(int,input().split())
S=input()
c=[0]
t = 0
for i in range(1,N):
    t += 1 if  S[i-1:i+1]=='AC' else 0
    c.append(t)
for _ in range(Q):
    l,r=map(int, input().split())
    print(c[r-1]-c[l-1])
Buggy code:
N,Q=[int(i) for i in input().split()]
S=input()

c=[0]
t = 0
for i in range(1,N):
   t += 1 if  (S[i-1]=='A' and S[i] == 'C') else 0
   c.append(t)
c.append(t)

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


Fixed code:
N,Q=[int(i) for i in input().split()]
S=input()

c=[0]
t = 0
for i in range(1,N):
   t += 1 if  (S[i-1]=='A' and S[i] == 'C') else 0
   c.append(t)

for _ in range(Q):
    l,r=[int(x)-1 for x in input().split()]
    print(c[r]-c[l])
Buggy code:
import numpy as np
N, Q = list(map(int, input().split()))
S = input()
t = [1 if S[j:j+2] == "AC" else 0 for j in range(N)]
for i in range(Q):
  l, r = list(map(int, input().split()))
  print(t[r-1]-t[l-1])

Fixed code:
import numpy as np
N, Q = list(map(int, input().split()))
S = input()
t = [0] * N
for j in range(1, N):
  t[j] = t[j-1] + 1 if S[j-1:j+1] == "AC" else t[j-1]
for i in range(Q):
  l, r = list(map(int, input().split()))
  print(t[r-1]-t[l-1])
Buggy code:
n, q = [int(i) for i in input().split()]
s = input()

count = [0] * (n + 1)
for i in range(n):
    count[i+1] += count[i]
    if s[i:i+2] == "AC":
        count[i+1] += 1
for i in range(q):
    l, r = [int(i) for i in input().split()]
    print(count(r-1) - count(l-1))


Fixed code:
n, q = [int(i) for i in input().split()]
s = input()

count = [0] * (n + 1)
for i in range(n):
    count[i+1] += count[i]
    if s[i:i+2] == "AC":
        count[i+1] += 1
for i in range(q):
    l, r = [int(i) for i in input().split()]
    print(count[r-1] - count[l-1])
Buggy code:
import numpy as np

n,q=map(int,input().split())
s=str(input())

line = np.zeros([n,])
count = 0
for i in range(1,n):
    if (s[i-1:i+1]=="AC"): 
        count += 1
    line[i]=count 
        
print(line)
for i in range(q):
    l,r = map(int,input().split())
    target = line[r-1] - line[l-1]
    print(int(target))

Fixed code:
import numpy as np

n,q=map(int,input().split())
s=str(input())

line = np.zeros([n,])
count = 0
for i in range(1,n):
    if (s[i-1:i+1]=="AC"): 
        count += 1
    line[i]=count 
        
for i in range(q):
    l,r = map(int,input().split())
    target = line[r-1] - line[l-1]
    print(int(target))
Buggy code:
N, Q = map(int, input().split())
S = input()
ac = [0, 0]
for i in range(len(S) - 1):
  if S[i] == "A" and S[i + 1] == "C":
    ac.append(ac[-1] + 1)
  else:
    ac.append(ac[-1])
for _ in range(Q):
  l, r = map(int, input().split())
  print(ac[r] - ac[l - 1])

Fixed code:
N, Q = map(int, input().split())
S = input()
ac = [0, 0]
for i in range(len(S) - 1):
  if S[i] == "A" and S[i + 1] == "C":
    ac.append(ac[-1] + 1)
  else:
    ac.append(ac[-1])
for _ in range(Q):
  l, r = map(int, input().split())
  print(ac[r] - ac[l])
Buggy code:
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for _ in range(q)]
a=[0]*n

for i in range(n):
  a[i]=s[:i+1].count('AC')

print(a)
for i in range(q):
  print(a[l[i][1]-1]-a[l[i][0]-1])

Fixed code:
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for _ in range(q)]
a=[0]*n

for i in range(n):
  a[i]=a[i-1]
  if s[i-1:i+1]=='AC':
    a[i]+=1

for i in range(q):
  print(a[l[i][1]-1]-a[l[i][0]-1])
Buggy code:
import re
n,q=map(int,input().split())
s=input()
a=[0]*n
b=[0]*n
i=[p.span()[0]for p in re.finditer('(AC){1,1}',s)]
c=0
for m in range(n):
  if c>=len(i):
    if m<n-1:a[m+1]=a[m]
    b[m]=b[m-1]
    continue
  if m==i[c]:
    if m>0:
      if m<n-1:a[m+1]=a[m]+1
      b[m]=b[m-1]+1
    else:
      a[m]=0
      a[m+1]=1
      b[m]+=1
    c+=1
  else:
    a[m+1]=a[m]
    b[m]=b[m-1]
for _ in range(q):
  l,r=map(int,input().split())
  print(max(a[r-1]-(b[l-1]-1),0))

Fixed code:
import re
n,q=map(int,input().split())
s=input()
a=[0]*n
b=[0]*n
i=[p.span()[0]for p in re.finditer('(AC){1,1}',s)]
c=0
for m in range(n):
  if c>=len(i):
    if m<n-1:a[m+1]=a[m]
    b[m]=b[m-1]
    continue
  if m==i[c]:
    if m>0:
      if m<n-1:a[m+1]=a[m]+1
      b[m]=b[m-1]+1
    else:
      a[m]=0
      a[m+1]=1
      b[m]+=1
    c+=1
  else:
    a[m+1]=a[m]
    b[m]=b[m-1]
for _ in range(q):
  l,r=map(int,input().split())
  if l>=2:
    print(a[r-1]-b[l-2])
  else:
    print(a[r-1])
Buggy code:
import numpy as np

N, Q = map(int, input().split())
S = input()
t = np.zeros(N+1)
for i in range(N):
    t[i+1] = t[i]+(1 if S[i-1:i+1]=='AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(int(t[r]-t[l-1]))

Fixed code:
import numpy as np

N, Q = map(int, input().split())
S = input()
t = np.zeros(N+1)
for i in range(N):
    t[i+1] = t[i]+(1 if S[i-1:i+1]=='AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(int(t[r]-t[l]))
Buggy code:
import bisect

N, Q = map(int, input().split())
S = input()
Qi = []
for i in range(Q):
    a = list(map(int, input().split()))
    Qi.append(a)

index_list = []
idx = 0
while idx < len(S):
    i2 = S.find("AC", idx)
    if i2 < 0:
        break
    index_list.append(i2)
    idx = i2 + 2

for q in Qi:
    if len(index_list) == 0:
        print(0)
        continue
    left = bisect.bisect_left(index_list, q[0] - 1)
    right = bisect.bisect_right(index_list, q[1] - 2)
    print(right - left, left, right)


Fixed code:
import bisect

N, Q = map(int, input().split())
S = input()
Qi = []
for i in range(Q):
    a = list(map(int, input().split()))
    Qi.append(a)

index_list = []
idx = 0
while idx < len(S):
    i2 = S.find("AC", idx)
    if i2 < 0:
        break
    index_list.append(i2)
    idx = i2 + 2

for q in Qi:
    if len(index_list) == 0:
        print(0)
        continue
    left = bisect.bisect_left(index_list, q[0] - 1)
    right = bisect.bisect_right(index_list, q[1] - 2)
    print(right - left)
Buggy code:
n, q = map(int, input().split())
s = input()
lis=[]
for i in range(q):
    lis.append(list(map(int, input().split())))
idx=0
acs=[0]*n
for _ in s:
    if s[idx]=="A" and s[idx+1]=="C":
        acs[idx+1] = 1
        idx+=1
    idx+=1
    if idx>=(len(s)-1):
        break
cnt=0
print(acs)
for i,el in enumerate(acs):
    if el!=0:
        cnt+=el
        acs[i]=cnt
    else:
        acs[i]=cnt
print(acs)
for i in lis:
    print(acs[i[1]-1]-acs[i[0]-1])

Fixed code:
n, q = map(int, input().split())
s = input()
lis=[]
for i in range(q):
    lis.append(list(map(int, input().split())))
idx=0
acs=[0]*n
for _ in s:
    if s[idx]=="A" and s[idx+1]=="C":
        acs[idx+1] = 1
        idx+=1
    idx+=1
    if idx>=(len(s)-1):
        break
cnt=0
#print(acs)
for i,el in enumerate(acs):
    if el!=0:
        cnt+=el
        acs[i]=cnt
    else:
        acs[i]=cnt
#print(acs)
for i in lis:
    print(acs[i[1]-1]-acs[i[0]-1])
Buggy code:
N, Q = map(int, input().split())
S = input()
T = [0]*(N+1)

for i in range(1, N):
    T[i+1] = T[i] + (1 if S[i-1:i+1]=='AC' else 0)
ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(T[r] - T[l])
print(T)
print(*ans, sep='\n')

Fixed code:
N, Q = map(int, input().split())
S = input()
T = [0]*(N+1)

for i in range(1, N):
    T[i+1] = T[i] + (1 if S[i-1:i+1]=='AC' else 0)
ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(T[r] - T[l])
print(*ans, sep='\n')
Buggy code:
N,Q = map(int,input().split())
S = input()
LR = [list(map(int,input().split())) for _ in range(Q)]
#print(LR)

C = [0 for _ in range(N+1)]
for i in range(1,N):
  if S[i-1] == 'A' and S[i] == 'C':
    C[i+1] = C[i] + 1
  else:
    C[i+1] = C[i]
print(C)
for l,r in LR:
  print(C[r]-C[l])

Fixed code:
N,Q = map(int,input().split())
S = input()
LR = [list(map(int,input().split())) for _ in range(Q)]
#print(LR)

C = [0 for _ in range(N+1)]
for i in range(1,N):
  if S[i-1] == 'A' and S[i] == 'C':
    C[i+1] = C[i] + 1
  else:
    C[i+1] = C[i]
#print(C)
for l,r in LR:
  print(C[r]-C[l])
Buggy code:
import bisect
N, Q = map(int, input().split())
S = input()
arr = []
for i in range(N-1):
  if S[i:i+2] == "AC":
    arr.append(i)
print(arr)
for i in range(Q):
  l, r = map(int, input().split())
  print(bisect.bisect_right(arr, r-2) - bisect.bisect_left(arr, l-1))
               

Fixed code:
import bisect
N, Q = map(int, input().split())
S = input()
arr = []
for i in range(N-1):
  if S[i:i+2] == "AC":
    arr.append(i)
#print(arr)
for i in range(Q):
  l, r = map(int, input().split())
  print(bisect.bisect_right(arr, r-2) - bisect.bisect_left(arr, l-1))
Buggy code:
n,q=map(int,input().split())
s=list(input())
li=[0]*n
cnt=0
ans=0

for i in range(n):
  if i==0:
    continue
  if s[i-1]=="A" and s[i]=="C":
    cnt+=1  
  li[i]=cnt
    
for i in range(q):
  l,r=map(int,input().split())
  ans=li[r]-li[l]
  print(ans)


Fixed code:
n,q=map(int,input().split())
s=list(input())
li=[0]*n
cnt=0
ans=0

for i in range(n):
  if i==0:
    continue
  if s[i-1]=="A" and s[i]=="C":
    cnt+=1  
  li[i]=cnt
    
for i in range(q):
  l,r=map(int,input().split())
  ans=li[r-1]-li[l-1]
  print(ans)
Buggy code:
N, Q = map(int, input().split())

S = str(input())

L = []
for i in range(Q):
    l,r = map(int, input().split())
    L.append((l-1,r-1))
    
    
check = []
for i in range(N-1):
    if S[i:i+2] == "AC":
        check.append(i)
        
for i in L:
    print(bisect_right(check, i[1]-1)-bisect_left(check, i[0]))

Fixed code:
N, Q = map(int, input().split())

S = str(input())

L = []
for i in range(Q):
    l,r = map(int, input().split())
    L.append((l-1,r-1))
    
check = []
for i in range(N-1):
    if S[i:i+2] == "AC":
        check.append(i)
        
from bisect import bisect_left,bisect_right
for i in L:
    print(bisect_right(check, i[1]-1)-bisect_left(check, i[0]))
Buggy code:
N, Q = (int(i) for i in input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

accum = [0] * N

def countAC():
    count = 0
    for i in range(1, N):
        if(S[i-1] == "A" and S[i] == "C"):
            count += 1
        accum[i] = count



countAC()

for i in range(Q):
    print(accum[LR[i][1]-1] - accum[LR[i][0]-1])

print(accum)



Fixed code:
N, Q = (int(i) for i in input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

accum = [0] * N

def countAC():
    count = 0
    for i in range(1, N):
        if(S[i-1] == "A" and S[i] == "C"):
            count += 1
        accum[i] = count



countAC()

for i in range(Q):
    print(accum[LR[i][1]-1] - accum[LR[i][0]-1])
Buggy code:
n, q = map(int, input().split())
s = input()
cnt_list = [0]*(n)
tmpi = 0
for i in range(1, n):
    if s[i-1] == "A":
        if s[i] == "C":
            cnt_list[i] = cnt_list[i-1] + 1
        else:
            cnt_list[i] = cnt_list[i-1]
    else:
        cnt_list[i] = cnt_list[i-1]
            
print(cnt_list)
for i in range(q):
    l, r = map(int, input().split())
    print(cnt_list[r-1] - cnt_list[l-1])

Fixed code:
n, q = map(int, input().split())
s = input()
cnt_list = [0]*(n)
tmpi = 0
for i in range(1, n):
    if s[i-1] == "A":
        if s[i] == "C":
            cnt_list[i] = cnt_list[i-1] + 1
        else:
            cnt_list[i] = cnt_list[i-1]
    else:
        cnt_list[i] = cnt_list[i-1]

for i in range(q):
    l, r = map(int, input().split())
    print(cnt_list[r-1] - cnt_list[l-1])
Buggy code:
n, q = map(int, input().split())
s = input()
appmap = [0] * (n + 1)
for i in range(n):
    appmap[i + 1] = appmap[i] + (1 if s[i: i + 2] == "AC" else 0)
print(appmap)
for i in range(q):
    l, r = map(int, input().split())
    print(appmap[r - 1] - appmap[l - 1])


Fixed code:
n, q = map(int, input().split())
s = input()
appmap = [0] * (n + 1)
for i in range(n):
    appmap[i + 1] = appmap[i] + (1 if s[i: i + 2] == "AC" else 0)
for i in range(q):
    l, r = map(int, input().split())
    print(appmap[r - 1] - appmap[l - 1])
Buggy code:
N, Q = map(int, input().split())
S = input()
lr = [0] * Q
for i in range(Q):
  lr[i] = list(map(int, input().split()))

b, t = 0, [0]*N
for i in range(1, N):
  if S[i-1:i+1] == 'AC':
    t[i] += 1
  else: t[i] = t[i-1]

for i in range(Q):
  print(t[lr[i][1]] - t[lr[i][0]])

Fixed code:
N, Q = map(int, input().split())
S = input()
lr = [0] * Q
for i in range(Q):
  lr[i] = list(map(lambda x: int(x) - 1, input().split()))

t = [0]*N
for i in range(1, N):
  t[i] = t[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)
  
for i in range(Q):
  print(t[lr[i][1]] - t[lr[i][0]])
Buggy code:
nq = list(map(int,input().split()))
n = nq[0]
q = nq[1]
s = input()
lr = [map(int, input().split()) for _ in range(q)]
l, r = [list(i) for i in zip(*lr)]
print(l)
sam = [0]*n
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        sam[i+1] = sam[i] + 1
    else:
        sam[i+1] = sam[i]
for i in range(q):
    ans = sam[r[i]-1] - sam[l[i]-1]
    print(ans)

Fixed code:
nq = list(map(int,input().split()))
n = nq[0]
q = nq[1]
s = input()
lr = [map(int, input().split()) for _ in range(q)]
l, r = [list(i) for i in zip(*lr)]
sam = [0]*n
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        sam[i+1] = sam[i] + 1
    else:
        sam[i+1] = sam[i]
for i in range(q):
    ans = sam[r[i]-1] - sam[l[i]-1]
    print(ans)
Buggy code:
N, Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]

dp = [0]*(N+1)
for i in range(N):
  if S[i:i+2]=="AC":
    dp[i+1] = dp[i] +1
  else:
    dp[i+1] = dp[i]

print(dp)

for i in range(Q):
  print(dp[lr[i][1]-1]-dp[lr[i][0]-1])

Fixed code:
N, Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]

dp = [0]*(N+1)
for i in range(N):
  if S[i:i+2]=="AC":
    dp[i+1] = dp[i] +1
  else:
    dp[i+1] = dp[i]

for i in range(Q):
  print(dp[lr[i][1]-1]-dp[lr[i][0]-1])
Buggy code:
# -*- coding:utf-8 -*-

def solve():
    N, Q = list(map(int, input().split()))
    S = input()

    dp = [0]*(N)
    dp[0] = 0
    for i in range(0, N-1):
        if S[i]=="A" and S[i+1]=="C":
            dp[i+1] = dp[i] + 1
        else:
            dp[i+1] = dp[i]
    
    for i in range(Q):
        l, r = list(map(int, input()))
        print(dp[r-1] - dp[l-1])
    
    

if __name__ == "__main__":
    solve()


Fixed code:
# -*- coding:utf-8 -*-

def solve():
    N, Q = list(map(int, input().split()))
    S = input()

    dp = [0]*(N)
    dp[0] = 0
    for i in range(0, N-1):
        if S[i]=="A" and S[i+1]=="C":
            dp[i+1] = dp[i] + 1
        else:
            dp[i+1] = dp[i]
    
    for i in range(Q):
        l, r = list(map(int, input().split()))
        print(dp[r-1] - dp[l-1])
    


if __name__ == "__main__":
    solve()
Buggy code:
N, Q = map(int, input().split())
S = input()
S_list = list(S)
count_list = [0]*N
print(S_list)

for i in range(1, N):
    count_list[i] += count_list[i-1] 
    if S_list[i-1] == "A" and S_list[i] == "C":
        count_list[i] += 1
        
print(count_list)

for i in range(Q):
    start, end = map(int, input().split())
    count = count_list[end-1] - count_list[start-1]
    print(count)

Fixed code:
N, Q = map(int, input().split())
S = input()
S_list = list(S)
count_list = [0]*N

for i in range(1, N):
    count_list[i] += count_list[i-1] 
    if S_list[i-1] == "A" and S_list[i] == "C":
        count_list[i] += 1

for i in range(Q):
    start, end = map(int, input().split())
    count = count_list[end-1] - count_list[start-1]
    print(count)
Buggy code:
import itertools

N,Q = map(int,input().split())
S = input()

b = [0]+[S[i]=='A' and S[i+1]=='C' for i in range(N-1)]
b = list(itertools.accumulate(b))

for _ in range(Q):
    l,r = map(int,input().split())
    print(b[r-1]-b[l-2])

Fixed code:
import itertools

N,Q = map(int,input().split())
S = input()

b = [S[i]=='A' and S[i+1]=='C' for i in range(N-1)]
b.insert(0,0)
b = list(itertools.accumulate(b))

for _ in range(Q):
    l,r = map(int,input().split())
    print(b[r-1]-b[l-1])
Buggy code:
N, Q = map(int, input().split())
S = str(input())
position = [0] * (N)
count = 0
for i in range(N):
    if S[i] == "A" and S[i + 1] == "C":
        count += 1
    position[i] = count

for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    answer = position[r] - position[l]
    print[answer]

Fixed code:
N, Q = map(int, input().split())
S = str(input())
position = [0] * N
count = 0
for i in range(N-1):
    if S[i] == "A" and S[i + 1] == "C":
        count += 1
    position[i+1] = count
answers = []
for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    answer = position[r] - position[l]
    answers.append(answer)
for i in range(Q):
    print(answers[i])
Buggy code:
n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]==A and s[i]==C:
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])



Fixed code:

n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])
Buggy code:
n, q = map(int, input().split())
s = input()

t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + 1 if s[i:i+2] == 'AC' else 0

for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])


Fixed code:
n, q = map(int, input().split())
S = input()
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if S[i : i+2] == "AC" else 0)

for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy code:
N,Q=map(int,input().split())
S=input()
list1=[list(map(int,input().split())) for _ in range(Q)]
list2=[0]*(N+1)
count=0
for i in range(N):
    if i>0:
        list2[i+1]=list2[i]
    if i==N-1:
        continue
    elif S[i:i+2]=="AC":
        list2[i+1]+=1
print(list2)
for tmp in list1:
    print(list2[tmp[1]-1]-list2[tmp[0]-1])

Fixed code:
N,Q=map(int,input().split())
S=input()
list1=[list(map(int,input().split())) for _ in range(Q)]
list2=[0]*(N+1)
count=0
for i in range(N):
    if i>0:
        list2[i+1]=list2[i]
    if i==N-1:
        continue
    elif S[i:i+2]=="AC":
        list2[i+1]+=1
for tmp in list1:
    print(list2[tmp[1]-1]-list2[tmp[0]-1])
Buggy code:
N, Q = map(int, input().split())
S = str(input())
 
#ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]
a = 0
lst = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    a += 1
  lst.append(a)
print(lst)
for _ in range(Q):
  l, r = map(int, input().split())
  print(lst[r-1] - lst[l-1])

Fixed code:
N, Q = map(int, input().split())
S = str(input())
 
#ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]
a = 0
lst = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    a += 1
  lst.append(a)
for _ in range(Q):
  l, r = map(int, input().split())
  print(lst[r-1] - lst[l-1])
Buggy code:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input.split())
	print(t[r-1] - t[l-1])


Fixed code:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])
Buggy code:
n,q = map(int,input().split())
s = input()
ls = [0]
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        ls.append(ls[i]+1)
    else:
        ls.append(ls[i])
print(ls)
for i in range(q):
    l,r = map(int,input().split())
    print(ls[r-1]-ls[l-1])

Fixed code:
n,q = map(int,input().split())
s = input()
    
ans = 0
ls = [0]
for i in range(len(s)-1):
    if s[i] == "A" and s[i+1] == "C":
        ans += 1
        ls.append(1+ls[i-1])
    else:
        ls.append(ls[i])
        
for i in range(q):
    l,r = map(int,input().split())
    print(ls[r-1]-ls[l-1])
Buggy code:
n,q = map(int,input().split())
s = input()
t = [0] * (n + 1)
for i in range(q):
  t[i+1] = t[i] + (1 if s[i:i+2] == "AC" else 0)
for i in range(q):
  l,r = map(int,input().split())
  print(t[r-1] - t[l-1])


Fixed code:
n,q = map(int,input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
  t[i+1] = t[i] + (1 if s[i:i+2] == "AC" else 0)
for i in range(q):
  l,r = map(int,input().split())
  print(t[r-1] - t[l-1])
Buggy code:
N,Q=map(int,input().split())
S=input()
L=[]
for i in range(N+1):
  L.append(S.count('AC',0,i))
for j in range(Q):
  l,r=map(int,input().split())
  print(L[r]-L[l])
print(L)

Fixed code:
N,Q=map(int,input().split())
S=input()
L=[0]
T=0
for i in range(N-1):
  T+=S.count('AC',i,i+2)
  L.append(T)
for j in range(Q):
  l,r=map(int,input().split())
  print(L[r-1]-L[l-1])
Buggy code:
N,Q = map(int,input().split())
S = input()
S += 'J'
L = []
for i in range(Q):
  L.append(list(map(int,input().split())))
cnt = [0]*(N+1)
for i in range(N):
  if S[i] == 'A' and S[i+1] == 'C':
    cnt[i+1] = 1
for i in range(1,N+1):
  cnt[i] += cnt[i-1]
for j in range(Q):
  print(cnt[L[j][1]-1]-cnt[L[j][0]-1])
print(cnt)

Fixed code:
N,Q = map(int,input().split())
S = input()
S += 'J'
L = []
for i in range(Q):
  L.append(list(map(int,input().split())))
cnt = [0]*(N+1)
for i in range(N):
  if S[i] == 'A' and S[i+1] == 'C':
    cnt[i+1] = 1
for i in range(1,N+1):
  cnt[i] += cnt[i-1]
for j in range(Q):
  print(cnt[L[j][1]-1]-cnt[L[j][0]-1])
Buggy code:
n,q=map(int,input().split())
s=input()
ac=[0]
buf=0
for i in range(1,n):
    if s[i-1:i+1]=="AC":
        buf+=1
    ac.append(buf)
print(ac)
for i in range(q):
    l,r=map(int,input().split())
    ans=ac[r-1]-ac[l-1]
    print(ans)

Fixed code:
n,q=map(int,input().split())
s=input()
ac=[0]
buf=0
for i in range(1,n):
    if s[i-1:i+1]=="AC":
        buf+=1
    ac.append(buf)
for i in range(q):
    l,r=map(int,input().split())
    ans=ac[r-1]-ac[l-1]
    print(ans)
Buggy code:
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0]

    for i in range(0, N):
        if S[i] == 'A' and S[i+1] == 'C': sum[i+1] = sum[i] + 1
        else: sum[i+1] = sum[i]

    for i in range(0, Q):
        l, r = map(int, input().split())
        print(sum[r] - sum[l])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    print(end - start)


Fixed code:
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * (N + 1)

    for i in range(1, N):
        if S[i-1] == 'A' and S[i] == 'C': sum[i] = sum[i-1] + 1
        else: sum[i] = sum[i-1]

    for i in range(Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)