Problem: You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries:    * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does `AC` occurs as a substring?

Submission attempts (in order):
 # -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,q=map(int, io().split())
	s=list(io())
	
	ss=[0 for _ in s]
	sss=ss.copy()
	for i, c in enumerate(s[1:]):
		if s[i-1]=='A' and s[i]=='C':
			ss[i]=1
		sss[i] = ss[i] + sss[i-1]
	
	for i in range(q):
		r,l=map(int, io().split())
		#rr=sum(ss[r-1:l])-ss[l-1]
		rr=sss[l-1]-sss[r-1]
		#ret.append(str(rr))
		print(rr)
	
#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	#print (main(io))
	main(io)

# -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,q=map(int, io().split())
	s=list(io())
	
	ss=[0 for _ in s]
	for i, (c, cn) in enumerate(zip(s, s[1:])):
		if c=='A' and cn=='C':
			ss[i]=1
	print(ss)
	#ret=[]
	for i in range(q):
		r,l=map(int, io().split())
		rr=sum(ss[r-1:l])-ss[l-1]
		#ret.append(str(rr))
		print(rr)
	
#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	#print (main(io))
	main(io)

# -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,q=map(int, io().split())
	s=list(io())
	
	ss=[0 for _ in s[:-1]]
	for i, (c, cn) in enumerate(zip(s, s[1:])):
		if c=='A' and cn=='C':
			ss[i]=1
	
	ret=[]
	for i in range(q):
		r,l=map(int, io().split())
		rr=sum(ss[r-1:l])-ss[l-1]
		ret.append(str(rr))
		
	return "\n".join(ret)
	
	
#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

# -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,q=map(int, io().split())
	s=list(io())
	
	ss=[0 for _ in s[:-1]]
	for i, (c, cn) in enumerate(zip(s, s[1:])):
		if c=='A' and cn=='C':
			ss[i]=1
	
	#ret=[]
	for i in range(q):
		r,l=map(int, io().split())
		rr=sum(ss[r-1:l])-ss[l-1]
		#ret.append(str(rr))
		print(rr)
		
	#return "\n".join(ret)
	
	
#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	#print (main(io))
	main(io)

# -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,q=map(int, io().split())
	s=list(io())
	
	ss=[0 for _ in s[:-1]]
	for i, (c, cn) in enumerate(zip(s, s[1:])):
		if c=='A' and cn=='C':
			ss[i]=1
	
	print(ss)
	ret=[]
	for i in range(q):
		r,l=map(int, io().split())
		rr=sum(ss[r-1:l])-ss[l-1]
		ret.append(str(rr))
		
	return "\n".join(ret)
	
	
#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

# -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,q=map(int, io().split())
	s=list(io())
	
	ss=[0 for _ in s[:-1]]
	for i, (c, cn) in enumerate(zip(s, s[1:])):
		if c=='A' and cn=='C':
			ss[i]=1
	
	#ret=[]
	for i in range(q):
		r,l=map(int, io().split())
		rr=sum(ss[r-1:l])-ss[l-1]
		#ret.append(str(rr))
		print(rr)
		
	#return "\n".join(ret)
	
#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	#print (main(io))
	main(io)

 # -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,q=map(int, io().split())
	s=list(io())
	
	ss=[0 for _ in s]
	sss=ss.copy()
	for i, c in enumerate(s[1:],1):
		if s[i-1]=='A' and s[i]=='C':
			ss[i]=1
		sss[i] = ss[i] + sss[i-1]
	
	for i in range(q):
		r, l=map(int, io().split())
		#rr=sum(ss[r-1:l])-ss[l-1]
		rr=sss[l-1]-sss[r-1]
		#ret.append(str(rr))
		print(rr)
	
#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	#print (main(io))
	main(io)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted