qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,Q = map(int,input().split(' '))
S = input()

count_sum_list = [0]*(N+1)
start_A_pointa = [0]*(N+1)

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

output_list = []

for _ in range(Q):
    l,r = map(int,input().split(' '))
    if start_A_pointa[r] == 1:
        output_list.append(count_sum_list[r]-count_sum_list[l-1] -1)
    else:
        output_list.append(count_sum_list[r]-count_sum_list[l-1])

for out in output_list:
    print(out)

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

count_sum_list = [0]*(N+1)
start_A_pointa = [0]*(N+1)

for i in range(1,N+1):
    if i != N and S[i-1] == 'A' and S[i] == 'C':
        count_sum_list[i] = count_sum_list[i-1] + 1
        start_A_pointa[i] = 1
    else:
        count_sum_list[i] = count_sum_list[i-1]
#print(count_sum_list)

output_list = []

for _ in range(Q):
    l,r = map(int,input().split(' '))
    if start_A_pointa[r] == 1:
        output_list.append(count_sum_list[r]-count_sum_list[l-1] -1)
    else:
        output_list.append(count_sum_list[r]-count_sum_list[l-1])

for out in output_list:
    print(out)
Buggy code:
n, q = [int(i) for i in input().split()]
s = input()
l_list = []
r_list = []
for i in range(q):
    l, r = [int(i) for i in input().split()]
    l_list.append(l)
    r_list.append(r)

ac_map = [0 for i in range(n+1)]
for i in range(1, n+1):
    if s[i-1:i+1] == "AC":
        ac_map[i] = ac_map[i-1] +1
    else:
        ac_map[i] = ac_map[i-1]
print(ac_map)
for i in range(q):
    ans = ac_map[r_list[i]-1] - ac_map[l_list[i]-1]
    print(ans)

Fixed code:
n, q = [int(i) for i in input().split()]
s = input()
l_list = []
r_list = []
for i in range(q):
    l, r = [int(i) for i in input().split()]
    l_list.append(l)
    r_list.append(r)

ac_map = [0 for i in range(n+1)]
for i in range(1, n+1):
    if s[i-1:i+1] == "AC":
        ac_map[i] = ac_map[i-1] +1
    else:
        ac_map[i] = ac_map[i-1]
for i in range(q):
    ans = ac_map[r_list[i]-1] - ac_map[l_list[i]-1]
    print(ans)
Buggy code:
n, q = map(int, input().split())
s = input()

m = []
total = 0
b = False

for c in s:
    if c == 'A':
        b = True
    elif c == 'C' and b:
        total += 1
        b = False
    else:
        b = False
    m.append(total)

print(m)

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


Fixed code:
n, q = map(int, input().split())
s = input()

m = []
total = 0
b = False

for c in s:
    if c == 'A':
        b = True
    elif c == 'C' and b:
        total += 1
        b = False
    else:
        b = False
    m.append(total)

for _ in range(q):
    l, r = map(int, input().split())
    print(m[r-1] - m[l-1])
Buggy code:
n, q = [int(x) for x in input().split()]

s = input()

arr = [0 for _ in range(len(s)+1)]

for i in range(len(s)-1):
	if s[i] == 'A' and s[i+1] == 'C':
		arr[i+2] += 1

for i in range(1, len(arr)):
	arr[i] = arr[i-1] + arr[i]

for i in range(1, len(arr)):
	print(arr[i], end=" ")
for _ in range(q):
	a, b = [int(x) for x in input().split()]
	print(str(arr[b]-arr[a]))

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

s = input()

arr = [0 for _ in range(len(s)+1)]

for i in range(len(s)-1):
	if s[i] == 'A' and s[i+1] == 'C':
		arr[i+2] += 1

for i in range(1, len(arr)):
	arr[i] = arr[i-1] + arr[i]

for _ in range(q):
	a, b = [int(x) for x in input().split()]
	print(str(arr[b]-arr[a]))
Buggy code:
n, q = map(int,input().split())
s = input()
l = [[int(i) for i in input().split()] for i in range(q)]
c = [0 for i in range(n)]
cc = 0
f = False
for i in range(n):
    if f:
        if s[i] == "C":
            cc += 1
            f = False
        else:
            f = False
    if s[i] == "A":
        f = True
    c[i] = cc
print(c)
for i in range(q):
    print(c[l[i][1]-1]-c[l[i][0]-1])

Fixed code:
n, q = map(int,input().split())
s = input()
l = [[int(i) for i in input().split()] for i in range(q)]
c = [0 for i in range(n)]
cc = 0
f = False
for i in range(n):
    if f:
        f = False
        if s[i] == "C":
            cc += 1
    if s[i] == "A":
        f = True
    c[i] = cc
for i in range(q):
    print(c[l[i][1]-1]-c[l[i][0]-1])
Buggy code:
n, q = map(int, input().split())
s = input()

L = [0]*len(s)
for i in range(1,len(s)):
    L[i] = L[i-1]
    if s[i-1] == "A" and s[i] == "C":
        L[i] += 1


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

Fixed code:
n, q = map(int, input().split())
s = input()

L = [0]*len(s)
for i in range(1,len(s)):
    L[i] = L[i-1]
    if s[i-1] == "A" and s[i] == "C":
        L[i] += 1


for _ in range(q):
    l, r = map(int, input().split())
    print(L[r-1]-L[l-1])
Buggy code:
import bisect

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

for i in range(N-1):
  if S[i] == "A" and S[i+1] == "C":
    idx.append(i+1)

print(idx)
for i in range(Q):
  l, r = map(int, input().split())
  lid = bisect.bisect_left(idx, l)
  rid = bisect.bisect_right(idx, r-1)
  print(rid-lid)
  

Fixed code:
import bisect

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

for i in range(N-1):
  if S[i] == "A" and S[i+1] == "C":
    idx.append(i+1)

for i in range(Q):
  l, r = map(int, input().split())
  lid = bisect.bisect_left(idx, l)
  rid = bisect.bisect_right(idx, r-1)
  print(rid-lid)
Buggy code:
N, Q = map(int, input().split())
S = input()
t = [0] * N
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,M = list(map(int,input().split()))
l_n = input()
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + (1 if l_n[i:i+2] == 'AC' else 0)
print(l_a)
for i in range(M):
    l,r = map(int,input().split())
    print(l_a[r-1]-l_a[l-1])

Fixed code:
N,M = list(map(int,input().split()))
l_n = input()
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + (1 if l_n[i:i+2] == 'AC' else 0)
for i in range(M):
    l,r = map(int,input().split())
    print(l_a[r-1]-l_a[l-1])
Buggy code:
    N, Q = [int(x) for x in input().split()]
    S = input()
    lr = [[int(x) for x in input().split()] for _ in range(Q)]
    for l, r in lr:
        cnt = 0
        for i in range(r-l):
            cnt += (S[l-1+i] == 'A' and S[l+i] == 'C')
        print(cnt)


Fixed code:
N, Q = [int(x) for x in input().split()]
S = input()
lr = [[int(x)-1 for x in input().split()] for _ in range(Q)]
lst = [0] * N
for i in range(N-1):
    lst[i+1] = lst[i] + (S[i] == 'A' and S[i+1] == 'C')
for l, r in lr:
    print(lst[r]-lst[l])
Buggy code:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = (1 if s[i:i + 2] == "AC" else 0) + t[i]
print(t)
for i in range(q):
    l, r = list(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] = (1 if s[i:i + 2] == "AC" else 0) + t[i]
for i in range(q):
    l, r = list(map(int, input().split()))
    print(t[r - 1] - t[l - 1])
Buggy code:
N,Q = map(int,input().split())
S = input()
l,r = [],[]
index = []
for i in range(Q):
    tmp1,tmp2 = map(int,input().split())
    l.append(tmp1)
    r.append(tmp2)
counter = 0
index.append(counter)
for i in range(1,len(S)):
    if(S[i-1] == 'A' and S[i] == 'C'):
        counter += 1
    index.append(counter)
print(index)
def f(l,r):
    return index[r-1] - index[l-1]
for i in range(Q):
    print(f(l[i],r[i]))

Fixed code:
N,Q = map(int,input().split())
S = input()
l,r = [],[]
index = []
for i in range(Q):
    tmp1,tmp2 = map(int,input().split())
    l.append(tmp1)
    r.append(tmp2)
counter = 0
index.append(counter)
for i in range(1,len(S)):
    if(S[i-1] == 'A' and S[i] == 'C'):
        counter += 1
    index.append(counter)
def f(l,r):
    return index[r-1] - index[l-1]
for i in range(Q):
    print(f(l[i],r[i]))
Buggy code:
N, Q = map(int, input().split())
S = input()

hit = [0] * N

for i in range(0, N - 1):
    hit[i + 1] = hit[i]

    if S[i:i+2] == 'AC':
        hit[i + 1] += 1

for _ in range(0, Q):
    result = hit[r - 1] - hit[l - 1]
    print(result)



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

hit = [0] * N

for i in range(0, N - 1):
    hit[i + 1] = hit[i]

    if S[i:i+2] == 'AC':
        hit[i + 1] += 1

for _ in range(0, Q):
    l, r = map(int, input().split())
    result = hit[r - 1] - hit[l - 1]
    print(result)
Buggy code:
n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]
count=0
l=[0]*n
for i in range(1,n):
  if s[i-1]=="A" and s[i]=="C":
    count+=1
  l[i]=count
print(l)
for i in range(q):
  print(l[lr[i][1]-1]-l[lr[i][0]-1])

Fixed code:
n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]
count=0
l=[0]*n
for i in range(1,n):
  if s[i-1]=="A" and s[i]=="C":
    count+=1
  l[i]=count
for i in range(q):
  print(l[lr[i][1]-1]-l[lr[i][0]-1])
Buggy code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, q = LI()
    s = 'X' + SI()
    Q = [LI() for _ in range(q)]

    ac = [0]
    for i in range(1, n + 1):
        if (s[i], s[i - 1]) == ('C', 'A'):
            ac.append(ac[-1] + 1)
        else:
            ac.append(ac[-1])

    print(ac)
    for l, r in Q:
        print(ac[r] - ac[l])
    # return res


main()


Fixed code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, q = LI()
    s = 'X' + SI()
    Q = [LI() for _ in range(q)]

    ac = [0]
    for i in range(1, n + 1):
        if (s[i], s[i - 1]) == ('C', 'A'):
            ac.append(ac[-1] + 1)
        else:
            ac.append(ac[-1])

    for l, r in Q:
        print(ac[r] - ac[l])
    # return res


main()
Buggy code:
n,q = map(int,input().split())
s = input()

li = [0]*n

for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        li[i] += 1

from itertools import accumulate

lin = [0]+list(accumulate(li))
print(lin)
for _ in range(q):
    l,r = map(int,input().split())
    print(lin[r]-lin[l])

Fixed code:
n,q = map(int,input().split())
s = input()

li = [0]*n

for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        li[i] += 1

from itertools import accumulate

lin = [0]+list(accumulate(li))

for _ in range(q):
    l,r = map(int,input().split())
    print(lin[r]-lin[l])
Buggy code:
n,q=map(int,input().split())
s = input()
a = [0,0]
for i in range(1,n):
    a.append(a[i]+(s[i-1]=="A" and s[i]=='C'))
print(a)
for i in range(q):
    l,r=map(int,input().split())
    print(a[r]-a[l-1]-(s[l-2]=='A' and s[l-1]=='C'))


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

for i in range(1, N):
    if S[i-1:i+1] == "AC":
        ans[i] += 1
    ans[i] += ans[i-1]
print(ans)

for l, r in lr:
    l -= 1
    r -= 1
    print(ans[r] - ans[l])

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

for i in range(1, N+1):
    if S[i-1:i+1] == "AC":
        ans[i] += 1
    ans[i] += ans[i-1]

for l, r in lr:
    print(ans[r] - ans[l])
Buggy code:
n, q = map(int, input().split())
s = input()
a = []
for i in range(q):
	b = input().split()
	b[0] = int(b[0]) - 1
	b[1] = int(b[1]) - 1
	a.append(b)
counter = [0]
for i in range(1,len(s)):
	if s[i - 1] == "A" and s[i] == "C":
		counter.append(counter[i - 1] + 1)
	else:
		counter.append(counter[i - 1])
print(counter)

result = 0
for i in range(q):
	num = counter[a[i][1]] - counter[a[i][0]]
	result += num
	print(num)

Fixed code:
n, q = map(int, input().split())
s = input()
a = []
for i in range(q):
	b = input().split()
	b[0] = int(b[0]) - 1
	b[1] = int(b[1]) - 1
	a.append(b)
counter = [0]
for i in range(1,len(s)):
	if s[i - 1] == "A" and s[i] == "C":
		counter.append(counter[i - 1] + 1)
	else:
		counter.append(counter[i - 1])

result = 0
for i in range(q):
	num = counter[a[i][1]] - counter[a[i][0]]
	result += num
	print(num)
Buggy code:
N, Q = map(int, input().split())
S = input()
AClst = []
count = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)
AClst.append(c)

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

Fixed code:
N, Q = map(int, input().split())
S = input()
AClst = [0]
c = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)

for q in range(Q):
  l, r = map(int, input().split())
  print(AClst[r-1]-AClst[l-1])
Buggy code:
N, Q = map(int, input().split())
S = str(input())
SD = {}

cnt = 0
for n in range(1, N):
    if S[n-1] + S[n] == "AC":
        cnt += 1
    SD[n] = cnt

print(SD)

for q in range(1, Q+1):
    l, r = map(int, input().split())
    print(SD.get(r-1, 0)-SD.get(l-1, 0))

Fixed code:
N, Q = map(int, input().split())
S = str(input())
SD = {}

cnt = 0
for n in range(1, N):
    if S[n-1] + S[n] == "AC":
        cnt += 1
    SD[n] = cnt

for q in range(1, Q+1):
    l, r = map(int, input().split())
    print(SD.get(r-1, 0)-SD.get(l-1, 0))
Buggy code:
N,K = map(int,input().split())
moji = str(input())
ans = [0]
for i in range(N-1):
    if moji[i] == "A" and moji[i+1] == "C":
        ans.append(ans[i]+1)
    else:
        ans.append(ans[i])

        
for i in range(K):
    st,sp = map(int,input().split())
    print(ans[sp]-ans[st])
    

Fixed code:
N,K = map(int,input().split())
moji = str(input())
ans = [0]
for i in range(N-1):
    if moji[i] == "A" and moji[i+1] == "C":
        ans.append(ans[i]+1)
    else:
        ans.append(ans[i])

        
for i in range(K):
    st,sp = map(int,input().split())
    print(ans[sp-1]-ans[st-1])
Buggy code:
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(s[i]+1)
  else:
    list.append(s[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r]-list[l-1])

Fixed code:
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(list[i]+1)
  else:
    list.append(list[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r-1]-list[l-1])
Buggy code:
n,q = map(int,input().split())
s = list(input())
base = [0]*n
count = 0

for i in range(n-1):
  if (s[i] == "A") and (s[i+1] == "C"):
    count = count + 1
    base[i] = count
  else:
    base[i] = count

base[n-1] = base[n-2]

for i in range(q):
  l,r = map(int,input().split())
  ans = base[r-1] - base[l-1]
  
  if s[r-1] == "A":
    ans = ans - 1
    
  print(ans)

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

for i in range(1,n):
  if (s[i-1] == "A") and (s[i] == "C"):
    count = count + 1
    base[i] = count
  else:
    base[i] = count

for i in range(q):
  l,r = map(int,input().split())
  ans = base[r-1] - base[l-1]
 
    
  print(ans)
Buggy code:
def main():
  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])
if __name__=='__main__':
  main()

Fixed code:
def main():
  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])

if __name__=='__main__':
  main()
Buggy code:
N,Q = map(int,input().split(' '))
S = input()

lr = []
for _ in range(Q):
    lr.append(list(map(int,input().split(' '))))

index_list = []
#index_list = [0] * N
start = 0
for i in range(N):
    if S[i-1] == 'A' and S[i] == 'C':
        start += 1
        #index_list[i] = index_list[i-1] + 1
    #else:
    index_list.append(start)
        #index_list[i] = index_list[i-1]

print(index_list)
for l,r in lr:
    print(index_list[r-1] - index_list[l-1])

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

lr = []
for _ in range(Q):
    lr.append(list(map(int,input().split(' '))))

#index_list = []
index_list = [0] * N
start = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        index_list[i] = index_list[i-1] + 1
    else:
        index_list[i] = index_list[i-1]

for l,r in lr:
    print(index_list[r-1] - index_list[l-1])
Buggy code:
n, q = map(int, input().split())
s = input()
ruisekiwa = [0]
for i in range(len(s)-2):
    if s[i:i+2] == 'AC':
        ruisekiwa += [ ruisekiwa[-1] + 1 ]
    else:
        ruisekiwa += [ ruisekiwa[-1] ]

ruisekiwa += [ ruisekiwa[-1] ]

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


Fixed code:
n, q = map(int, input().split())
s = input()
ruisekiwa = [0]
for i in range(len(s)-1):
    if s[i:i+2] == 'AC':
        ruisekiwa += [ ruisekiwa[-1] + 1 ]
    else:
        ruisekiwa += [ ruisekiwa[-1] ]

ruisekiwa += [ ruisekiwa[-1] ]

for _ in range(q):
    l, r = map(int, input().split())
    l -= 1; r -= 1;
    print(ruisekiwa[r] - ruisekiwa[l])
Buggy code:
n,q = map(int,input().split())
s = input()
m = [list(map(int,input().split())) for i in range(q)]
count = [0]*(N+1)
 
for i in range(n):
    if S[i:i+2] == 'AC':
        comu[i+1] = comu[i] + 1
    else:
        comu[i+1] = comu[i]
 
for l,r in list:
    print(count[r-1]-count[l-1])

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

S_count = []
count = 0
A_flag = False

for i in range(len(S)):
    if A_flag == True:
        if S[i] == "C" :
            count += 1
    else:
        if S[i] == "A" :
            A_flag = True
        else:
            A_flag = False
    S_count = count

for i in range(Q):
    print(S[R[i]] - S[L[i]])

Fixed code:
#c
N,Q = list(map(int,input().split()))
S = input()
L = []
R = []
for i in range(Q):
    a = list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])

S_count = []
count = 0
A_flag = False

for i in range(len(S)):
    if A_flag == True:
        if S[i] == "C" :
            count += 1
   
    if S[i] == "A" :
        A_flag = True
    else:
        A_flag = False
    S_count.append(count)

for i in range(Q):
    print(S_count[R[i] - 1] - S_count[L[i] - 1])
Buggy code:
N,Q=[int(i) for i in input().split()]
S=input()
lr=[]
for i in range(Q):
  lr.append([int(i) for i in input().split()])

acn=[0 for i in range(N)]
count=0
for i in range(1,N):
  if S[i-1]+S[i]=="AC":
    count+=1
  acn[i]=count
for i in range(Q):
  l=lr[i][0]
  r=lr[i][1]
  print(l,r)
  print(acn[r-1]-acn[l-1])

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

acn=[0 for i in range(N)]
count=0
for i in range(1,N):
  if S[i-1]+S[i]=="AC":
    count+=1
  acn[i]=count
for i in range(Q):
  l=lr[i][0]
  r=lr[i][1]
  print(acn[r-1]-acn[l-1])
Buggy code:
n, q = map(int, input().split())
S = input()

flag = False

ATList = [0]*n

for i in range(n):
    if (S[i] == "A"):
        ATList[i] = ATList[i-1]
        flag = True
    elif (S[i] == "C") and flag:
        ATList[i] = ATList[i-1] + 1
        flag = False
    else:
        ATList[i] = ATList[i-1]
        flag = False

print(ATList)

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


Fixed code:
n, q = map(int, input().split())
S = input()

flag = False

ATList = [0]*n

for i in range(n):
    if (S[i] == "A"):
        ATList[i] = ATList[i-1]
        flag = True
    elif (S[i] == "C") and flag:
        ATList[i] = ATList[i-1] + 1
        flag = False
    else:
        ATList[i] = ATList[i-1]
        flag = False

for i in range(q):
    l,r = map(int, input().split())
    print(ATList[r-1]-ATList[l-1])
Buggy code:
N,Q = map(int,input().split())
S = input()

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

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

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

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

for i in range(Q):
    l, r = map(int,input().split())
    print(AC_list[r-1]-AC_list[l-1])
Buggy code:
n ,q=map(int, input().split())
s=input()
t=[0]*(n+1)

for i in range(n):
    if s[i:i+2]=="AC":
        c=1
    else:
        c=0

    t[i+1]=t[i]+c

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

Fixed code:
n ,q=map(int, input().split())
s=input()
t=[0]*(n+1)

for i in range(n):
    if s[i:i+2]=="AC":
        c=1
    else:
        c=0

    t[i+1]=t[i]+c

for i in range(q):
    l, r=map(int, input().split())
    print(t[r-1]-t[l-1])
Buggy code:
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
s = input()
rr = (list(map(int, input().split())) for _ in range(k))

from collections import Counter

dc = [0, 0]
c = 0
for i in range(1, len(s)):
  if s[i-1]+s[i] == 'AC':
    c += 1
  dc.append(c)
for a, b in rr:
  print(dc[b] - dc[a-1])


Fixed code:
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
s = input()
rr = (list(map(int, input().split())) for _ in range(k))

from collections import Counter

dc = [0, 0]
c = 0
for i in range(1, len(s)):
  if s[i-1]+s[i] == 'AC':
    c += 1
  dc.append(c)
for a, b in rr:
  print(dc[b] - dc[a])
Buggy code:
N, Q = map(int, input().split())
S = input()

c = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        c[i+1] = c[i] + 1
    else:
        c[i+1] = c[i]

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

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

c = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        c[i+1] = c[i] + 1
    else:
        c[i+1] = c[i]

for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1] - c[l-1])
Buggy code:
n, q = map(int, input().split())
s = input()
lst = [0] * n
for i in range(1, n):
  lst[i] = lst[i-1]
  if lst[i-1:i+1] == 'AC':
    lst[i] += 1

for i 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 = input()
lst = [0] * n
for i in range(1, n):
  lst[i] = lst[i-1]
  if s[i-1:i+1] == 'AC':
    lst[i] += 1

for i 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()
count = 0
for i in range(q):
  l, r = map(int, input().split())
  count += s[l-1:r].count('AC')
print(count)

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