qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def main():
    *S, = input()
    count = 0
    max = 0
    for i in S:
        print(i)
        if i == "A" or i == "C" or i == "G" or i == "T":
            count += 1
        else:
            if max < count:
                max = count
            count = 0
    print(max)
main()


Fixed code:
def main():
    *S, = input()
    count = 0
    maximum = 0
    for i in S:
        if i == "A" or i == "C" or i == "G" or i == "T":
            count += 1
        else:
            if maximum < count:
                maximum = count
            count = 0
    print(max(count, maximum))
main()
Buggy code:
string = input()
ch = string[0]
max_string_len = 0
prev_len = 0
for idx,ch in enumerate(string):
  if ch  in {"A","T","G","C"}:
    prev_len += 1
  	max_string_len = max(max_string_len,prev_len)
  else:
    prev_len = 0
    
print(max_string_len)

Fixed code:
string = input()
ch = string[0]
max_string_len = 0
prev_len = 0
for idx,ch in enumerate(string):
  if ch  in {"A","T","G","C"}:
    prev_len += 1
    max_string_len = max(max_string_len,prev_len)
  else:
    prev_len = 0
    
print(max_string_len)
Buggy code:
s=input()
x=['A','T','C','G']
a=[0]*len(s)
a[0]=1 if s[0] in x
for i in range(1,len(s)):
  if s[i] in x:
    a[i]=a[i-1]+1
print(max(a))
  
  

Fixed code:
s=input()
x=['A','T','C','G']
a=[0]*len(s)
if s[0] in x:
  a[0]=1
for i in range(1,len(s)):
  if s[i] in x:
    a[i]=a[i-1]+1
print(max(a))
Buggy code:
S = input()

cnt = 0
max = 0
for str in S:
  if str in {'A', 'C', 'G', 'T'}:
    cnt += 1
  else:
    if cnt < max:
      max = cnt
    cnt = 0

print(cnt)

Fixed code:
S = input()
cnt = 0
max = 0

for str in S:
  if str in {'A', 'C', 'G', 'T'}:
    cnt += 1
  else:
    if max < cnt:
      max = cnt
    cnt = 0
    
if max < cnt:
  max = cnt
  
print(max)
Buggy code:
S = input()

l = len(S)

max_cnt = 0
for i in range(l):
    for j in range(i, l):
        max_cnt = max(sum([1 if s == "A" or s == "C" or s == "G" or s == "T" else 0 for s in S[i : j + 1]]), max_cnt)
print(max_cnt)

Fixed code:
S = input()

l = len(S)

max_cnt = 0
for i in range(l):
    for j in range(i, l):
        res = [1 if s == "A" or s == "C" or s == "G" or s == "T" else 0 for s in S[i : j + 1]]
        if sum(res) == len(res):
            max_cnt = max(sum(res), max_cnt)
print(max_cnt)
Buggy code:
import re

split = re.split('[^ACGT]', input())
print(split)
print(max(map(len, split)))


Fixed code:
import re

split = re.split('[^ACGT]', input())

print(max(map(len, split)))
Buggy code:
S = str(input())
s_list=[]
string= ""
AGCT = ["A", "G", "C", "T"]
for s in S:
    if s in AGCT:
        string += s
    else:
        s_list.append(string)
        string=""
max(map(len, s_list))

Fixed code:
S = input()
s_list=[]
string= ""
AGCT = ["A", "G", "C", "T"]
for s in S:
    if s in AGCT:
        #string = string + s
        string += s
    else:
        s_list.append(string)
        string=""
s_list.append(string)
print(max(map(len, s_list)))
Buggy code:
S=input()
slist=[S]
for i in range(len(S)):
    for j in range(i+1, len(S)):
        slist.append(S[i:j])
ma=0
for s in slist:
    flag = True
    for w in s:
        if w not in ['A','C','G','T']:
            flag = False
    if flag:
        print(s)
        ma = max(ma, len(s))
print(ma)

Fixed code:
S=input()
slist=[]
for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        slist.append(S[i:j])
ma=0
for s in slist:
    flag = True
    for w in s:
        if w not in ['A','C','G','T']:
            flag = False
    if flag:
        ma = max(ma, len(s))
print(ma)
Buggy code:
s=input()

ans = 0
for i in range(len(s)):
    for j in range(i+1,len(s)):
        if s[i:j].count("A")==s[i:j].count("C")==s[i:j].count("G")==s[i:j].count("T")==0:
            ans = max(ans,j-i)
print(ans)


Fixed code:
s=input()

ans = 0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        if s[i:j].count("A")+s[i:j].count("C")+s[i:j].count("G")+s[i:j].count("T")==j-i:
            ans = max(ans,j-i)
print(ans)
Buggy code:
S=input()

l=len(S)

ans=0
ans_list=()

for i in range(l):
    if S[i] in ("A","G","C","T"):
        ans+=1
    else:
        ans_list.append(ans)
        ans=0
ans_list.append(ans)
print(ans)
    

Fixed code:
S=input()

l=len(S)

ans=0
ans_list=[]

for i in range(l):
    if S[i] in ("A","G","C","T"):
        ans+=1
    else:
        ans_list.append(ans)
        ans=0
ans_list.append(ans)
print(max(ans_list))
Buggy code:
S = input()
ans = ''
t = ''
acgt = 'ACGT'
for s in S:
    if (s in acgt):
        t += s
    else:
        if (len(ans) < len(t)):
            ans = t

if (len(ans) < len(t)):
    ans = t
print(ans)

Fixed code:
S = input()
ans = ''
t = ''
acgt = 'ACGT'
for s in S:
    if (s in acgt):
        t += s
    else:
        if (len(ans) < len(t)):
            ans = t
        t = ''

if (len(ans) < len(t)):
    ans = t
print(len(ans))
Buggy code:
S = str(input())
A = 'ACGT'
L = len(S)

cnt = 0
max_cnt = 0
for x in S:
    print(x, cnt)
    if x in A:
        cnt += 1
    else:
        if max_cnt < cnt:
            max_cnt = cnt
        cnt = 0

print(max_cnt)


Fixed code:
S = str(input())
A = 'ACGT'
L = len(S)

cnt = 0
max_cnt = 0
for x in S:
    if x in A:
        cnt += 1
    else:
        if max_cnt < cnt:
            max_cnt = cnt
        cnt = 0
if max_cnt < cnt:
    max_cnt = cnt

print(max_cnt)
Buggy code:
s = input()
t = ''
for i in range(len(s)):
    if s[i] in ('A', 'C', 'G', 'T'):
        t += '1'
    else:
        t += '0'
print(t)
print(t.split('0'))
print(max(map(len, t.split('0'))))

Fixed code:
s = input()
t = ''
for i in range(len(s)):
    if s[i] in ('A', 'C', 'G', 'T'):
        t += '1'
    else:
        t += '0'
"""
print(t)
print(t.split('0'))
"""

print(max(map(len, t.split('0'))))
Buggy code:
S = input()

target = list('ACGT')

count_list = [0] * len(S)
for i in range(len(S)):
    if S[i] in target:
        count_list[i] = 1

max_length = 0
for start in range(len(S)):
    if count_list[start] == 0:
        continue
    for end in range(start, len(S)):
        if count_list[end] == 0:
            break
        
        print(count_list[start : end+1])
        max_length = max(sum(count_list[start : end+1]), max_length)

print(max_length)

Fixed code:
S = input()

target = list('ACGT')

count_list = [0] * len(S)
for i in range(len(S)):
    if S[i] in target:
        count_list[i] = 1

max_length = 0
for start in range(len(S)):
    if count_list[start] == 0:
        continue
    for end in range(start, len(S)):
        if count_list[end] == 0:
            break

        max_length = max(sum(count_list[start : end+1]), max_length)

print(max_length)
Buggy code:
S = input()

res = []
tmp = ['']
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp.append(s)
    else:
        res.append(len(tmp))
        tmp = ['']

print(max(res))


Fixed code:
S = input()

res = []
tmp = []
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp.append(s)
    else:
        res.append(len(tmp))
        tmp = []
res.append(len(tmp))
print(max(res))
Buggy code:
s = input()
set = {'A', 'T', 'G', 'C'}
l, ans = 0, 0
for i in len(s):
  if s[i] in set:
    l += 1
  else:
    ans = max(l, ans)
    l = 0
print(ans)

Fixed code:
s = input()
set = {'A', 'T', 'G', 'C'}
l, ans = 0, 0
for i in range(len(s)):
  if s[i] in set:
    l += 1
  else:
    ans = max(l, ans)
    l = 0
ans = max(l, ans)
print(ans)
Buggy code:
S = input()
ans = 0
for i in range(len(S)):
  for j in range(i+1, len(S)+1):
	if all('ACTG'.count(c)==1 for c in S[i:j+1]):
      ans = max(ans, j+1-i)
print(ans)

Fixed code:
S = input()
N = len(S)
ans = 0
for i in range(N):
  for j in range(i, N):
    if all('ACGT'.count(c)==1 for c in S[i:j+1]):
      ans = max(ans, j-i+1)
print(ans)
Buggy code:
import re
pattern = re.compile('[ACGT]+')
S = input()
print(len(max(re.findall(pattern, S))))

Fixed code:
import re
pattern = re.compile('[ACGT]+')
S = input()
print(len(max(re.findall(pattern, S), key=len, default='')))
Buggy code:
def hantei(n):
    for i in range(len(n)):
        if n[i]!="A" and n[i]!="G" and n[i]!="T" and n[i]!="C":
            return False

s=input()
T=[]
n=[]
m=[]
x=0

for i in range(len(s)-1):
    for j in range(i+1,len(s)):
        T.append(s[i:j+1])

flag=False
for i in range(len(T)):
    w=T[i]
    if hantei(w)!=False:
        n.append(w)

for i in range(len(n)):
    m.append(len(n[i]))

if not m:
    print(0)
else:
    print(m)
    print(n)

Fixed code:
def hantei(n):
    for i in range(len(n)):
        if n[i]!="A" and n[i]!="G" and n[i]!="T" and n[i]!="C":
            return False

s=input()
T=[]
n=[]
m=[]
x=0

for i in range(len(s)-1):
    for j in range(i+1,len(s)):
        T.append(s[i:j+1])

for i in range(len(s)):
    T.append(s[i])

flag=False
for i in range(len(T)):
    w=T[i]
    if hantei(w)!=False:
        n.append(w)


for i in range(len(n)):
    m.append(len(n[i]))

if not m:
    print(0)
else:
    print(max(m))
Buggy code:
s = input()
def check(a):
    ALLOWED = "ACGT"
    for c in a:
        if not c in ALLOWED:
            return False
    return True

ans = 0
for i in range(len(s) - 1):
    for j in range(1, len(s) - i + 1):
        tmp = s[i: i + j]
        print(tmp)
        if check(tmp):
            ans = max(ans, len(tmp))
print(ans)


Fixed code:
s = input()
def check(a):
    ALLOWED = "ACGT"
    for c in a:
        if not c in ALLOWED:
            return False
    return True

ans = 0
for i in range(len(s)):
    for j in range(1, len(s) - i + 1):
        tmp = s[i: i + j]
        if check(tmp):
            ans = max(ans, len(tmp))
print(ans)
Buggy code:
target = set(["A", "C", "G", "T"])

S = list(input())

tmp = 0
ans = 0
for i in S:
    print(i)
    if i in target:
        print("aaa")
        tmp+=1
    else:
        ans = max(tmp,ans)
        tmp = 0

ans = max(tmp,ans)
print(ans)

Fixed code:
target = set(["A", "C", "G", "T"])

S = list(input())

tmp = 0
ans = 0
for i in S:
    if i in target:
        tmp+=1
    else:
        ans = max(tmp,ans)
        tmp = 0

ans = max(tmp,ans)
print(ans)
Buggy code:
S = input()
cnt = 0
ans = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt =
ans = max(ans, cnt)
print(ans)


Fixed code:
S = input()
cnt = 0
ans = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)
Buggy code:
s = input()
acgt = []
cnt = 0
for a in s:
    if a == 'A' or a == 'C' or a == 'T' or a == 'G':
        cnt += 1
    else:
        acgt.append(cnt)
        cnt = 0
acgt.appen(cnt)
print(max(acgt))
        

Fixed code:
s = input()
acgt = []
cnt = 0
for a in s:
    if a == 'A' or a == 'C' or a == 'T' or a == 'G':
        cnt += 1
    else:
        acgt.append(cnt)
        cnt = 0
acgt.append(cnt)
print(max(acgt))
Buggy code:
s=input()
le=len(s)
lis=[]
for i in range(0,le):
  if s[i]!="A" and s[i]!="" and s[i]!="T" and s[i]!="G":
    lis.append(i)
lo=0
for j in range(0,len(lis)-1):
  if lis[j+1]-lis[j]-1>=lo:
    lo=lis[j+1]-lis[j]-1
print(lo)

Fixed code:
s=input()
le=len(s)
lis=[]
for i in range(0,le):
  if s[i]!="A" and s[i]!="C" and s[i]!="T" and s[i]!="G":
    lis.append(i)
lo=0
for j in range(0,len(lis)-1):
  if lis[j+1]-lis[j]-1>=lo:
    lo=lis[j+1]-lis[j]-1
if bool(lis):
  if lis[0]>=lo:
    lo=lis[0]
  if le-lis[-1]-1>=lo:
    lo=le-lis[-1]-1
  print(lo)
else:
  print(le)
Buggy code:
S = input()
N = len(S)
ans = 0
for i in range(N):
	for j in range(i, N):
      if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
        ans = max(ans, j - i + 1)
print(ans)


Fixed code:
S = input()
N = len(S)
ans = 0
for i in range(N):
  for j in range(i, N):
    if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
        ans = max(ans, j - i + 1)
print(ans)
Buggy code:
s = input()
ans = 0
li = ["A", "C", "G", "T"]
count = 0
for i in s:
    if i in li:
        count += 1
    else:
        if count > ans:
            ans = count
        count = 0
if count == len(ans):
    print(count)
else:
    print(ans)


Fixed code:
s = input()
ans = 0
li = ["A", "C", "G", "T"]
count = 0
for i in s:
    if i in li:
        count += 1
    else:
        if count > ans:
            ans = count
        count = 0

if count > ans:
    ans = count
print(ans)
Buggy code:
S=list(input())
print(S)
c=0
max=0
for i in range(len(S)) :
  if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T' :
    c+=1
    if c>max :
      max=c
  else :
    c=0
  
print(max)



Fixed code:
S=list(input())

c=0
max=0
for i in range(len(S)) :
  if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T' :
    c+=1
    if c>max :
      max=c
  else :
    c=0
  
print(max)
Buggy code:
s='A'
clist=['A','C','G','T']
count=0
a=[]
for i in s:
  if i in clist:
    count+=1
  else:
    a.append(count)
    count=0
a.append(count)
print(max(a))

Fixed code:
s=input()
clist=['A','C','G','T']
count=0
a=[]
for i in s:
  if i in clist:
    count+=1
  else:
    a.append(count)
    count=0
a.append(count)
print(max(a))
Buggy code:
S = input()

max_length = 0
for i in range(len(S)):
  if S[i] in "ACGT":
    if i == len(S) - 1:
      length = 1
    else:
      for j in range(i+1, len(S)):
        length = j - i + 1
        if S[j] in "ACGT":
          continue
        else:
          break

    if length > max_length:
      max_length = length

print(max_length)

Fixed code:
S = input()

max_length = 0
for i in range(len(S)):
  if S[i] in "ACGT":
    if i == len(S) - 1:
      length = 1
    else:
      for j in range(i+1, len(S)):
        if S[j] in "ACGT":
          length = j - i + 1
        else:
          length = j - i
          break

    if length > max_length:
      max_length = length

print(max_length)
Buggy code:
S=list(input())
li=0
li2=[]
for i in S:
	if i=='A' or i=='C' or i=='G' or i=='T':
		li+=1
	else:
		li2.append(li)
		li=0
print(max(li2))
print(li2)

Fixed code:
S=list(input())
li=0
li2=[]
for i in S:
	if i=='A' or i=='C' or i=='G' or i=='T':
		li+=1
	else:
		li2.append(li)
		li=0
li2.append(li)
print(max(li2))
Buggy code:
s = input()

ans=0
counter = 0
for c in s:
  if c=='A' or c=='C' or c=='G' or c=-'T':
    counter+=1
  else:
    ans = max(ans,counter)
    counter==0
print(ans)
  

Fixed code:
s = input()
 
ans=0
counter = 0
for c in s:
  if c=='A' or c=='C' or c=='G' or c=='T':
    counter+=1
  else:
    ans = max(ans,counter)
    counter=0
ans = max(ans,counter)
print(ans)
Buggy code:
S = input()
count = 0
count_max = 0

for k in range(len(s)):
    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        count=0
print(count_max)


Fixed code:
S = input()
count = 0
count_max = 0

for k in range(len(S)):
    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        count=0
print(count_max)
Buggy code:
l = list(input())
ans = []
ans.append(0)
count = 0
for i in range(len(l)):
  if l[i] == ("A" or "G" or "T" or "C"):
    count += 1
  else:
    ans.append(count)
    count = 0
    
print(max(ans)))
  

Fixed code:
l = list(input())
ans = []
ans.append(0)
count = 0
for i in range(len(l)):
  if l[i] == "A" or  l[i] == "G" or  l[i] == "T" or  l[i] == "C":
    count += 1
  else:
    ans.append(count)
    count = 0
    
ans.append(count)
print(max(ans))
Buggy code:
import re

# str = input()

str = "HATAGAYA"

pattern = r"[ATCG]+"

matched_list = re.findall(pattern, str)

maxlength = 0
for item in matched_list:
    tmplength = len(item)
    if maxlength < tmplength:
        maxlength = tmplength

print(maxlength)

Fixed code:
import re

str = input()


pattern = r"[ATCG]+"

matched_list = re.findall(pattern, str)

maxlength = 0
for item in matched_list:
    tmplength = len(item)
    if maxlength < tmplength:
        maxlength = tmplength

print(maxlength)
Buggy code:
S = input()
N = len(S)
count = 0
max = 0
for i in range (N):
  if S[i] == "A" or "T" or "G" or "C":
    count = count + 1
  else:
    if count > max:
      max = count
      count = 0
if count > max:
  max = count
  
print(max)



Fixed code:
S = input()
N = len(S)
count = 0
max = 0
for i in range (N):
  if S[i] == "A" or S[i] == "T" or S[i] == "C" or S[i] == "G":
    count = count + 1
  else:
    if count > max:
      max = count
    count = 0
if count > max:
  max = count
  
print(max)
Buggy code:
#C
def f(x):
    return int(x) - 1

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

Fixed code:
#C
def f(x):
    return int(x) - 1

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)
# print(t)
for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])
Buggy code:
from itertools import accumulate
N,Q = list(map(int,input().split()))
S = list(input())
cnt = [0]*(N-1)
for i in range(N):
    if S[i] == 'A' and S[i+1] == 'C':
        cnt[i] = 1
R = [0]+list(accumulate(cnt))
print(R)
for k in range(Q):
    x,y = list(map(int,input().split()))
    print(R[y-1]-R[x-1])

Fixed code:
from itertools import accumulate
N,Q = list(map(int,input().split()))
S = list(input())
cnt = [0]*(N)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        cnt[i] = 1
R = [0]+list(accumulate(cnt))
for k in range(Q):
    x,y = list(map(int,input().split()))
    print(R[y-1]-R[x-1])
Buggy code:
import sys
stdin = sys.stdin

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, q = na()
s = ns()
ac = []
now = 0
f = False
for si in s:
    if si == "C" and f:
        now += 1
        f = False
    elif si == "A":
        f = True
    else:
        f = False
    ac.append(now)
ac.append(now)
for _ in range(q):
    l, r = na()
    print(ac[r] - ac[l-1])

Fixed code:
import sys
stdin = sys.stdin

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, q = na()
s = ns()
ac = list()
now = 0
f = False
for si in s:
    if si == "C" and f:
        now += 1
        f = False
    elif si == "A":
        f = True
    else:
        f = False
    ac.append(now)
for _ in range(q):
    l, r = na()
    l -= 1; r -= 1
    print(ac[r] - ac[l])
Buggy code:
import sys
imput =sys.stdin.readline
N, Q =map(int,input().split())
S =[i for i in input()]
q = [[int(i) for i in input().split()] for _ in range(Q)]
num = 0
for i in range(N-1):
    if S[i]+S[i+1]=="AC":
        num += 1
    S[i] = num
S[-1] = num
S.append(0)
print(q)
print(S)
for lr in q:
  print(S[lr[1]-2] -S[lr[0]-2])

Fixed code:
import sys
imput =sys.stdin.readline
N, Q =map(int,input().split())
S =[i for i in input()]
q = [[int(i) for i in input().split()] for _ in range(Q)]
num = 0
for i in range(N-1):
    if S[i]+S[i+1]=="AC":
        num += 1
    S[i] = num
S[-1] = num
S.append(0)
for lr in q:
  print(S[lr[1]-2] -S[lr[0]-2])
Buggy code:
n,q=map(int,input().split())
s=input()
f=[0,0]
g=[0]
x=0
for i in range(n-1):
  if s[i:i+2]=='AC':
    x+=1
  f.append(x)
  g.append(x)
g.append(x)
for i in range(q):
  l,r=map(int,input().split())
  print(f[r]-g[l-1])
print(f,g)

Fixed code:
n,q=map(int,input().split())
s=input()
f=[0,0]
g=[0]
x=0
for i in range(n-1):
  if s[i:i+2]=='AC':
    x+=1
  f.append(x)
  g.append(x)
g.append(x)
for i in range(q):
  l,r=map(int,input().split())
  print(f[r]-g[l-1])
Buggy code:
N, Q = map(int, input().split())
S = input()
lr_list = [map(int, input().split()) for _ in range(Q)]

sum_list = [0]

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

print(sum_list)

for l, r in lr_list:
    print(sum_list[r] - sum_list[l-1])


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

sum_list = [0]

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

# [sum_list.append(sum_list[-1]+1) if s == 'C' and S[i-1] == 'A' else sum_list.append(sum_list[-1]) for i, s in enumerate(S)]

for l, r in lr_list:
    print(sum_list[r] - sum_list[l])
Buggy code:
def countAC(s):
    index = []
    for i in range(len(s)):
        if i == len(s)-1:
            break
        if s[i] == 'A':
            if s[i+1] == 'C':
                index.append(1)
                continue
        index.append(0)
    return index

N,Q = (int(_) for _ in input().split())
S = input()
SIndex = countAC(S)
out = 0
for i in range(Q):
    l,r = (int(_) for _ in input().split())
    s = SIndex[l-1:r]
    for x in range(len(s)):
        out += x
    print(out)
    out = 0


Fixed code:
def countAC(s):
    counter = 0
    index = [0]
    for i in range(1,N):
        if s[i-1] == 'A':
            if s[i] == 'C':
                counter += 1
                index.append(counter)
                continue
        index.append(counter)
    return index

N,Q = (int(_) for _ in input().split())
S = input()
SIndex = countAC(S)
out = 0
for i in range(Q):
    l,r = (int(_) for _ in input().split())
    print(SIndex[r-1] - SIndex[l-1])
Buggy code:
N, Q = map(int, input().split())
S = input()
li = [list(map(int, input().split())) for n in range(Q)]

t = [0] * len(S)

for index, s in enumerate(S):
  if index+1 > len(S)-1:
    break

  if s == 'A' and S[index+1] == 'C':
    t[index+1] = t[index] + 1
    
  else:
    t[index+1] = t[index]
    
print(t)

for i in li:
  print(t[i[1]-1] - t[i[0] - 1])

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

t = [0] * len(S)

for index, s in enumerate(S):
  if index+1 > len(S)-1:
    break

  if s == 'A' and S[index+1] == 'C':
    t[index+1] = t[index] + 1
    
  else:
    t[index+1] = t[index]

for i in li:
  print(t[i[1]-1] - t[i[0] - 1])
Buggy code:
N, Q = map(int, input().split())
S = str(input())
W = [0] * (N+1)
L = []
R = []
for q in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

for n in range(N-1):
    W[n+1] = W[n] + (1 if W[n:n+2] == 'AC' else 0)    

for q in range(Q):
    print(W[L[q]-1]-W[R[q]-1])

Fixed code:
N, Q = map(int, input().split())
S = str(input())
W = [0] * (N+1)
L = []
R = []
for q in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

for n in range(N-1):
    W[n+1] = W[n] + (1 if S[n:n+2] == 'AC' else 0)    

for q in range(Q):
    print(W[R[q]-1]-W[L[q]-1])
Buggy code:
import math
N, Q = map(int, input().split())
S = str(input())

for q in range(Q):
    q_list[q] = list(map(int, input().split()))

ac_list = [0] * len(S)
count = 0
for i in range(1, len(S)):
    if S[i - 1] == 'A' and S[i] == 'C':
        count += 1
        ac_list[i] = count
    else:
        ac_list[i] = count
#print(ac_list)
for item in q_list:
    l, r = item[0], item[1]

    print(ac_list[r - 1] - ac_list[l - 1])

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

q_list = [0] * Q

for q in range(Q):
    q_list[q] = list(map(int, input().split()))

ac_list = [0] * len(S)
count = 0
for i in range(1, len(S)):
    if S[i - 1] == 'A' and S[i] == 'C':
        count += 1
        ac_list[i] = count
    else:
        ac_list[i] = count

for item in q_list:
    l, r = item[0], item[1]

    print(ac_list[r - 1] - ac_list[l - 1])
Buggy code:
import numpy as np

N,Q=map(int,input().split())
y=input()
arr=np.zeros(len(y))
for i in range(len(y)-1):
    if y[i:i+2]=='AC':
        arr[i]=1
    else:
        arr[i]=0
        
arr=arr.cumsum()        
for q in range(Q):
    l,r=map(int,input().split())
    print(arr[r-2]-arr[l-1])

Fixed code:
import numpy as np

N,Q=map(int,input().split())
y=input()
arr=np.zeros(len(y))
for i in range(len(y)-1):
    if y[i:i+2]=='AC':
        arr[i+1]=arr[i]+1
    else:
        arr[i+1]=arr[i]
              
for q in range(Q):
    l,r=map(int,input().split())
    print(int(arr[r-1]-arr[l-1]))