Buggy python submission (verdict: Runtime Error):

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()

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



def sc():
    global t
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    
    idbox = ind_Multi(com[0],com[1])
    print(t[com[1]-1] - t[com[0]-1])
        
    

    

for i in range(q):
    
    sc()

    

Fixed submission:

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()

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



def sc():
    global t
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    
    
    print(t[com[1]-1] - t[com[0]-1])
        
    

    

for i in range(q):
    
    sc()

Buggy python submission (verdict: Time Limit Exceeded):

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()

def ind_Multi(a,b): #a,b == 検索範囲   
    global n
    global s 
    index_L = []
    for i in range(a,b):
        if s[i] == "A":
            index_L.append(i)
    return index_L

            
        

def sc():
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    idbox = ind_Multi(com[0],com[1])
    if not idbox:
        print(0)
        return None
        
    

    
    for i in range(idbox[0],idbox[-1]+1): # i == 先頭の文字
        
        if (s[i+1]) == "C":
            count += 1
            
            
    print(count)

for i in range(q):
    
    sc()


Fixed submission:

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()

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



def sc():
    global t
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    
    
    print(t[com[1]-1] - t[com[0]-1])
        
    

    

for i in range(q):
    
    sc()

Buggy python submission (verdict: Time Limit Exceeded):

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()
def sc():
    global s
    global n
    global q
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    if "A" not in  s[com[0]:com[1]]:
        print(0)
        return None
    if "C" not in s[com[0] +1:com[1] + 1]:
        print(0)
        return None
    for i in range(com[0],com[1]): # i == 先頭の文字
        if (s[i] == "A") and(s[i+1] == "C"):
            count += 1      
    print(count)

for i in range(q):
    sc()


Fixed submission:

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()

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



def sc():
    global t
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    
    
    print(t[com[1]-1] - t[com[0]-1])
        
    

    

for i in range(q):
    
    sc()

Buggy python submission (verdict: Time Limit Exceeded):

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()
maxx = 0
count = 0
data = ["A","C","T","G"]

def sc():
    global s
    global n
    global q
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    for i in range(com[0], com[1] ): # i == 先頭の文字
        if (s[i] == "A") and(s[i+1] == "C"):
            count += 1
        
            
    print(count)

for i in range(q):
    sc()


Fixed submission:

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()

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



def sc():
    global t
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    
    
    print(t[com[1]-1] - t[com[0]-1])
        
    

    

for i in range(q):
    
    sc()

Buggy python submission (verdict: Time Limit Exceeded):

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()
maxx = 0
count = 0
data = ["A","C","T","G"]

def sc():
    global s
    global n
    global q
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    for i in range(com[0], com[1] + 1): # i == 先頭の文字
        for j in range(i,com[1] ): # j == 動かす文字
            if (s[j] == "A") and(s[j+1] == "C"):
                count += 1
                
            else:
                break
        

    print(count)

for i in range(q):
    sc()


Fixed submission:

x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()

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



def sc():
    global t
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    
    
    print(t[com[1]-1] - t[com[0]-1])
        
    

    

for i in range(q):
    
    sc()