Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
strings,num = map(int,input().split())
result = ""
str_array = []

for i in range (num):
    str_array.append(input())

str_array.sort()

for i in range (num):
    result += str_array[i]

print(result)

Fixed submission:
num,strings = map(int,input().split())
result = ""
str_array = []

for i in range (num):
    str_array.append(input())

str_array.sort()

for x in range (num):
    result = result + str_array[x]

print(result)

Buggy python submission (verdict: Runtime Error):
strings,num = map(int,input().split())
result = ""
str_array = []

for i in range (strings):
    str_array.append(input())

str_array.sort()

for i in range (num):
    result += str_array[i]

print(result)

Fixed submission:
num,strings = map(int,input().split())
result = ""
str_array = []

for i in range (num):
    str_array.append(input())

str_array.sort()

for x in range (num):
    result = result + str_array[x]

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
#142
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(1,n+1):
    print(str(a.index(i)+1)+' ', end="")


Fixed submission:
#142改
n = int(input())
a = list(map(int, input().split()))
b = [0]*n

for i in range(n):
    b[a[i]-1] += i+1
    
for i in range(n):
    print(str(b[i])+' ', end="")

Buggy python submission (verdict: Time Limit Exceeded):
#142
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(1,n+1):
    b.append(a.index(i)+1)
for j in range(n):
    print(str(b[j])+' ', end="")

Fixed submission:
#142改
n = int(input())
a = list(map(int, input().split()))
b = [0]*n

for i in range(n):
    b[a[i]-1] += i+1
    
for i in range(n):
    print(str(b[i])+' ', end="")
Buggy python submission (verdict: Runtime Error):
a

Fixed submission:
a, b, c = map(int, input().split())
i=0
while(a*i<=b and i<=c):
    i += 1
print(i-1)
Buggy python submission (verdict: Runtime Error):
#106
n = int(input())
if(n<105):
    print(0)
elif(n<135):
    print(1)
elif(n<165):
    print(2)
elif(n<189)
    print(3)
elif(n<195):
    print(4)
else:
    print(5)

Fixed submission:
#106
n = int(input())
if(n<105):
    print(0)
elif(n<135):
    print(1)
elif(n<165):
    print(2)
elif(n<189):
    print(3)
elif(n<195):
    print(4)
else:
    print(5)

Buggy python submission (verdict: Runtime Error):
#106
n = int(input())
if(n<105):
    print(0)
elif(n<135):
    print(1)
elif(n<165):
    print(2)
elif(n<195)
    print(3)
else:
    print(4)

Fixed submission:
#106
n = int(input())
if(n<105):
    print(0)
elif(n<135):
    print(1)
elif(n<165):
    print(2)
elif(n<189):
    print(3)
elif(n<195):
    print(4)
else:
    print(5)
Buggy python submission (verdict: Runtime Error):
s = input()
l = len(s)
if s[0] !="A":
    print("WA")
    break
else:
    s = s.replace(s[0],"a")
    index1 = s.find("C")
    index2 = s.find("C", 2)
    if index2 != -1 or (index1 < 2 or index1 > l-3):
        print("WA")
    else:
        s = s.replace("A","a")
        s_lower = s.lower()
        if s != s_lower:
            print("WA")
        else:
            print("AC")

Fixed submission:
#104
s = input()
if(s[0]=='A' and s[2:-1].count('C')==1):
    s1 = s.replace('A', "").replace("C","")
    if(s1==s1.lower()):
        print("AC")
    else:
        print("WA")
else:
    print("WA")
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
print(n*2/math.gcd(n,2))

Fixed submission:
n = int(input())
if n % 2==0:
    print(n)
else:
    print(2*n)
Buggy python submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = math.ceil((n-1)/(k-1))
print(ans)

Fixed submission:
inp = input()
plus = int(inp.count("+"))
minus = int(inp.count("-"))
print(plus-minus)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = int((n-k)/(k-1)+2)
print(ans)

Fixed submission:
inp = input()
plus = int(inp.count("+"))
minus = int(inp.count("-"))
print(plus-minus)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = int((n-k)/(k-1)+2)

Fixed submission:
inp = input()
plus = int(inp.count("+"))
minus = int(inp.count("-"))
print(plus-minus)
Buggy python submission (verdict: Runtime Error):
d,n = map(int, input().split())
print(n*(10**d)

Fixed submission:
d,n = map(int, input().split())
if n<100:
    print(n*(100**d))
else:
    print((n+1)*(100**d))
Buggy python submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = ans + (len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = 0
for i in a:
    ans = ans + (len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Buggy python submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = max(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = 0
for i in a:
    ans = ans + (len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
Buggy python submission (verdict: Runtime Error):
import math
N, X = map(int, input().split())
a = []
for i in range(N):
    a.append(input())
    
kosuu = len(a)
X = X - sum(a)

kosuu = kosuu + math.floor(X/min(a))

print(kosuu)

Fixed submission:
import math
N, X = map(int, input().split())
a = []
for i in range(N):
    a.append(int(input()))
    
kosuu = len(a)
X = X - sum(a)

kosuu = kosuu + math.floor(X/min(a))

print(kosuu)
Buggy python submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
count = 0

for i in range(X+1)
    count += A.count(i)

ans = min(count, len(A)-count)
print(ans)

Fixed submission:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
count = 0

for i in range(X+1):
    count += A.count(i)

ans = min(count, len(A)-count)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
D, X = map(int, input().split())
a = []
for i in range(N):
    a.append(input())
sum = 0
for i in range(N):
    sum += int((D-1) / a[i] + 1)
print(sum+X)

Fixed submission:
N = int(input())
D, X = map(int, input().split())
a = []
for i in range(N):
    a.append(int(input()))
sum = 0
for i in range(N):
    sum += int((D-1) / a[i] + 1)
print(sum+X)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = []
for i in range(N):
    s.append(input()

M = int(input())
t = []
for i in range(N):
    t.append(input())

sum = 0
for i in range(N):
    temp = 0
    sample = s[i]
    for j in range(N):
        if sample == s[j]:
            temp += 1
    for k in range(M):
        if sample == t[k]:
            temp -= 1
    if temp > sum:
        sum = temp
print(sum)

Fixed submission:
N = int(input())
s = []
for i in range(N):
    s.append(input())

M = int(input())
t = []
for i in range(M):
    t.append(input())

sum = 0
for i in range(N):
    temp = 0
    sample = s[i]
    for j in range(N):
        if sample == s[j]:
            temp += 1
    for k in range(M):
        if sample == t[k]:
            temp -= 1
    if temp > sum:
        sum = temp
print(sum)
Buggy python submission (verdict: Runtime Error):
a = []
for i in range(3)
    a.append(map(int, raw_input().split()))
print(a[0][0], a[1][1], a[2][2])

Fixed submission:
#ABC90
a = [input() for i in range(3)]
print(a[0][0]+a[1][1]+a[2][2])
Buggy python submission (verdict: Runtime Error):
#ABC73
n = input()
if(n[0]=="9" or n[1]=="9"):
    print(Yes)
else:
    print(No)



Fixed submission:
#ABC73
n = input()
if(n[0]=="9" or n[1]=="9"):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
#55
n = int(input())
ans = 1
for i in range(1, n+1):
    ans *= i
print(ans%(10**9+7))

Fixed submission:
#55改
import math
n = int(input())
ans =math.factorial(n)
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
    S=input()
    T=input()
    a=0
    for i in range(3):
        if S[i]==T[i]:
            a+=1
    print(a)

Fixed submission:
S=input()
T=input()
a=0
for i in range(3):
    if S[i]==T[i]:
            a+=1
print(a)
Buggy python submission (verdict: Runtime Error):
n=input()
print(n**3)


Fixed submission:
n=int(input())
print(n**3)

Buggy python submission (verdict: Runtime Error):
n=input()
print(int(n**3))


Fixed submission:
n=int(input())
print(n**3)

Buggy python submission (verdict: Runtime Error):
N=input()
print(int(N**3))


Fixed submission:
n=int(input())
print(n**3)

Buggy python submission (verdict: Runtime Error):
N=input()
print(N**3)


Fixed submission:
n=int(input())
print(n**3)

Buggy python submission (verdict: Runtime Error):
N=input()
ans = N**3
print(ans)

Fixed submission:
n=int(input())
print(n**3)

Buggy python submission (verdict: Runtime Error):
N=input()
 print(N^3)

Fixed submission:
n=int(input())
print(n**3)
Buggy python submission (verdict: Runtime Error):
    a,b = map(int, input().split())
    print( max(0, a-b*2) )

Fixed submission:
a,b = map(int, input().split())
print(max(0, a-b*2))

Buggy python submission (verdict: Runtime Error):
a,b = (int, input().split())
print( max(0, a-b*2) )

Fixed submission:
a,b = map(int, input().split())
print(max(0, a-b*2))
Buggy python submission (verdict: Runtime Error):

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

import bisect

color = []
color.append(a.pop(0))
color_count =0 
for i, ai in enumerate(a): 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.insert(0, ai)
print(len(color))

Fixed submission:
r = int(input())
print(3*r*r)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
amax = max(a)
amax_id = a.index(amax)
amax2 = max(a.pop(amax_id))
for i in range(n):
  if i == amax_id:
    print(amax2)
  else:
    print(amax)

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
amax = max(a)
amax_id = int(a.index(amax))
a.pop(amax_id)
amax2 = max(a)
for i in range(n):
  if i == amax_id:
    print(amax2)
  else:
    print(amax)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
for i in range(n):
  at = a.copy()
  at.pop(i)
  print(max(at))

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
amax = max(a)
amax_id = int(a.index(amax))
a.pop(amax_id)
amax2 = max(a)
for i in range(n):
  if i == amax_id:
    print(amax2)
  else:
    print(amax)
Buggy python submission (verdict: Runtime Error):
def addTimesheet(ts, a, b):
    for i in range(0, len(ts)):
        if(not ts[i] is 1):
            ts[i] = 1
            a -= 1
        if(a is 0):
            break
    if(not a is 0):
      return ts, False
    return ts, True

n = int(input())
a = []
b = []
for i in range(0, n):
    str = input().split(" ")
    a.append(int(str[0]))
    b.append(int(str[1]))

timesheet = [0]*max(b)
flag = True
for ia, ib in zip(a, b):
    timesheet, flag = addTimesheet(timesheet, ia, ib)
    if(flag is False):
    	break
if(flag is True):
	print("Yes")
else:
    print("No")

Fixed submission:
import numpy as np
    
N  = int(input())
    
AB = []
time = 0
    
for _ in range(N):
    AB.append(list(map(int, input().split())))
    
AB = np.array(AB)
    
sorted_AB = AB[AB[:,1].argsort(), :]
    
for i in range(N):
    time += sorted_AB[i,0]
    
    if time > sorted_AB[i,1]:
        print('No')
        exit()
    
print('Yes')

Buggy python submission (verdict: Runtime Error):
def addTimesheet(ts, a, b):
    for i in range(0, len(ts)):
        if(not ts[i] is 1):
            ts[i] = 1
            a -= 1
        if(a is 0):
            break
    if(not a is 0):
      return ts, False
    return ts, True

n = int(input())
a = []
b = []
for i in range(0, n):
    str = input().split(" ")
    a.append(int(str[0]))
    b.append(int(str[1]))

timesheet = [0]*max(b)

for ia, ib in zip(a, b):
    timesheet, flag = addTimesheet(timesheet, ia, ib)
    if(flag is False):
    	break
if(flag is True):
	print("Yes")
else:
    print("No")

Fixed submission:
import numpy as np
    
N  = int(input())
    
AB = []
time = 0
    
for _ in range(N):
    AB.append(list(map(int, input().split())))
    
AB = np.array(AB)
    
sorted_AB = AB[AB[:,1].argsort(), :]
    
for i in range(N):
    time += sorted_AB[i,0]
    
    if time > sorted_AB[i,1]:
        print('No')
        exit()
    
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
order_list = []
for i in range(1, N+1):
  order_list.append(A.index(i)+1)
print(*order_list)

Fixed submission:
N = int(input())
A = map(int, input().split())
order_list = []
for i,a in enumerate(A,1):
  order_list.append((i,a))
order_list.sort(key=lambda x:x[1])
print(' '.join(str(ans[0]) for ans in order_list))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in range(1, N+1):
  l.append(int(input()))
for i, Ai in enumerate(l):
  del l[i]
  print(max(l))
  l.insert(i, Ai)

Fixed submission:
N = int(input())
l = [int(input()) for i in range(N)]
l_ = sorted(l)
for Ai in l:
  if l_[-1] == Ai:
    print(l_[-2])
  else:
    print(l_[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
l = [[int(input())]]

for i in range(N-1):
  ai = int(input())
  flag = False
  for m in l:
    if max(m) < ai:
      m.append(ai)
      flag = True
      break
  if flag == False:
    l.append([ai])
    
print(len(l))

Fixed submission:
import sys
input = sys.stdin.readline
from bisect import bisect_right

N = int(input())
l = [-int(input())]

for i in range(N-1):
  ai = -int(input())
# 各色の最大値がlの要素になるようにリストを拡大させていく
  if l[-1] <= ai:
    l.append(ai)
  else:
    b = bisect_right(l, ai)
    l[b] = ai
    
print(len(l))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = int(input())
l = [int(input())]

for i in range(N-1):
  ai = int(input())
  flag = False
  for m in l:
    if max(m) < ai:
      m.append(ai)
      flag = True
      break
  if flag == False:
    l.append([ai])
    
print(len(l))

Fixed submission:
import sys
input = sys.stdin.readline
from bisect import bisect_right

N = int(input())
l = [-int(input())]

for i in range(N-1):
  ai = -int(input())
# 各色の最大値がlの要素になるようにリストを拡大させていく
  if l[-1] <= ai:
    l.append(ai)
  else:
    b = bisect_right(l, ai)
    l[b] = ai
    
print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
l = []

for ai in A:
  if l == []:
    l.append([ai])
    continue
    
  flag = False
  for m in l:
    if max(m) < ai:
      m.append(ai)
      flag = True
      break
  if flag == False:
    l.append([ai])
    
print(len(l))

Fixed submission:
import sys
input = sys.stdin.readline
from bisect import bisect_right

N = int(input())
l = [-int(input())]

for i in range(N-1):
  ai = -int(input())
# 各色の最大値がlの要素になるようにリストを拡大させていく
  if l[-1] <= ai:
    l.append(ai)
  else:
    b = bisect_right(l, ai)
    l[b] = ai
    
print(len(l))
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
s_count = []
for i in range(len(s)):
  if s[i:i+2] == "AC":
    s_count.append(1)
  else:
    s_count.append(0)

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

Fixed submission:
n,q = map(int,input().split())
s = input()
s_count = [0]
for i in range(len(s)):
  if s[i:i+2] == "AC":
    s_count.append(s_count[i] + 1)
  else:
    s_count.append(s_count[i])

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

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
count = 0
for i in range(q):
  l,r = input().split()
  l = int(l)
  r = int(r)
  t = s[l-1:r]
  count = 0
  for j in range(len(t)-1):
    if t[j:j+2] == "AC":
      count += 1
  print(count)
  count = 0

Fixed submission:
n,q = map(int,input().split())
s = input()
s_count = [0]
for i in range(len(s)):
  if s[i:i+2] == "AC":
    s_count.append(s_count[i] + 1)
  else:
    s_count.append(s_count[i])

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

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
count = 0
for i in range(q):
  l,r = input().split()
  l = int(l)
  r = int(r)
  t = s[l-1:r]
  count = t.count("AC")
  print(count)

Fixed submission:
n,q = map(int,input().split())
s = input()
s_count = [0]
for i in range(len(s)):
  if s[i:i+2] == "AC":
    s_count.append(s_count[i] + 1)
  else:
    s_count.append(s_count[i])

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

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
count = 0
for i in range(q):
  l,r = map(int,input().split())
  t = s[l-1:r]
  count = t.count("AC")
  print(count)

Fixed submission:
n,q = map(int,input().split())
s = input()
s_count = [0]
for i in range(len(s)):
  if s[i:i+2] == "AC":
    s_count.append(s_count[i] + 1)
  else:
    s_count.append(s_count[i])

for i in range(q):
  l,r = map(int,input().split())
  count = s_count[r-1] - s_count[l-1]
  print(count)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())

store = []

for i in range(n):
  price,stock = map(int,input().split())
  store.append([price,stock])

store.sort()

total_cost = 0
for i in range(n):
  if m > 0:
    buy = min([m,store[1][i]])
    total_cost += buy * store[0][i]
    m -= buy
  else:
    break

print(total_cost)

Fixed submission:
n,m = map(int,input().split())

store = []

for i in range(n):
  price,stock = map(int,input().split())
  store.append([price,stock])

store.sort()

total_cost = 0
for i in range(n):
  if m > 0:
    buy = min([m,store[i][1]])
    total_cost += buy * store[i][0]
    m -= buy
  else:
    break

print(total_cost)
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int, input().split())

t = [1,]
flag = 0

for i in range(1000):
    t.append((i+2)+ t[i])

for j in range(len(t)):
    for k in range(499500):
        if t[j] - k == a and t[j+1] - k == b:
            print(k)
            flag = 1
        if flag == 1:break
    if flag == 1: break

Fixed submission:
a,b = map(int, input().split())

t = [1,]

for i in range(1000):
    t.append((i+2)+ t[i])

for j in range(len(t)):
    if t[j] - a == t[j+1] - b:
        print(t[j] - a)
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S =input()

ans = float('inf')

for i in range(N):
    s1 = S[0:i]
    s2 = S[i+1:N]
    cnt = s1.count('W') + s2.count('E')
    ans = min(ans, cnt)

print(ans)

Fixed submission:
N = int(input())
S =input()

cntW, cntE = 0, S[1:].count('E')
ans = cntW + cntE
 
for i in range(N-1):
    if S[i+1] == 'E':
        cntE = cntE - 1 
    if S[i] == 'W':
        cntW = cntW + 1
    cnt = cntE + cntW
    ans = min(ans, cnt)

print(ans)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())

if R - L >= 2050:
    print(0)
else:
    ans = 20000000
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i * j) % 2019)
    print(ans)


Fixed submission:
N, A, B = map(int, input().split())
print(min(N*A, B))
Buggy python submission (verdict: Time Limit Exceeded):
def factorial(n):
    ans = 1
    for i in range(1, n+1):
        ans = ans * i

    return ans

def combination(n, r):
    #print(factorial(n) // (factorial(n-r) * factorial(r)))
    return factorial(n) // (factorial(n-r) * factorial(r))

def get_ans(N, K, i):
    #if K-1<i:
    #    return 0
    #else:
    return(combination(N-K+1, i) * combination(K-1, i-1))

N, K = tuple(map(int, input().split()))
for i in range(1, K+1):
    ans = get_ans(N, K, i)
    print(ans%(10**9+7))


Fixed submission:
def factorial(n):
    ans = 1
    for i in range(1, n+1):
        ans = ans * i

    return ans

def combination(n, r):
    #print(factorial(n) // (factorial(n-r) * factorial(r)))
    return factorial(n) // (factorial(n-r) * factorial(r))

def get_ans(N, K, i):
    if N-K+1<i:
        return 0
    else:
        return(combination(N-K+1, i) * combination(K-1, i-1))

N, K = tuple(map(int, input().split()))
for i in range(1, K+1):
    ans = get_ans(N, K, i)
    print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())

start = A // C
end = B // C
if A % C != 0:
    start = start + 1
C_num = end - start + 1

start = A // D
end = B // D
if A % D != 0:
    start = start + 1
D_num = end - start + 1

CD = C * D // math.gcd(C, D)
start = A // CD
end = B // CD
if A % CD != 0:
    start = start + 1
CD_num = end - start + 1

ans = (B - A + 1) - (C_num + D_num - CD_num)

print(ans)


Fixed submission:
def gcd(a, b): # a < b
    while True:
        c = b%a
        if c == 0:
            break
        b = a
        a = c

    return a


A, B, C, D = map(int, input().split())

start = A // C
end = B // C
if A % C != 0:
    start = start + 1
C_num = end - start + 1

start = A // D
end = B // D
if A % D != 0:
    start = start + 1
D_num = end - start + 1

CD = C * D // gcd(C, D)
start = A // CD
end = B // CD
if A % CD != 0:
    start = start + 1
CD_num = end - start + 1

ans = (B - A + 1) - (C_num + D_num - CD_num)

print(ans)
Buggy python submission (verdict: Runtime Error):
def get_answer(s):
    count = 0
    for i, c in enumerate(s):
        if i == len(s) - 1:
            return count
        if c == "A" and s[i + 1] == "C":
            count += 1

    return count

n, q = map(int, input().split())
s = str(input())
questions = []
for _ in range(q):
    a, b = map(int, input().split())
    questions.append((a - 1, b - 1))

for question in questions:
    print(get_answer(s[question[0]: question[1] + 1]))


Fixed submission:
map = {
    "A":"T",
    "T":"A",
    "C":"G",
    "G":"C"
}

a = str(input())
print(map[a])

Buggy python submission (verdict: Runtime Error):
def get_answer(s):
    count = 0
    for i, c in enumerate(s):
        if i == len(s) - 1:
            return count
        if c == "A" and s[i + 1] == "C":
            count += 1

    return count

n, q = map(int, input().split())
s = str(input())
questions = []
for i in range(q):
    a, b = map(int, input().split())
    questions.append((a - 1, b - 1))

for question in questions:
    print(get_answer(s[question[0]: question[1] + 1]))


Fixed submission:
map = {
    "A":"T",
    "T":"A",
    "C":"G",
    "G":"C"
}

a = str(input())
print(map[a])
Buggy python submission (verdict: Runtime Error):
s = str(input())

#0文字の場合をチェック
if ("A" not in s) and ("C" not in s) and ("G" not in s) and ("T" not in s):
    print 0

max = 0
for i, c in enumerate(s):
    if is_ACGT(c):
        if i == (len(s) - 1):
            break
        max = get_ACGT_length(s[i+1:])

print(max)

def is_ACGT(c):
    if (c == "A") or (c == "C") or (c == "G") or (c == "T"):
        return True
    else:
        return False

def get_ACGT_length(s):
    if len(s) == 0:
        return 0

    if not is_ACGT(s[0]):
        return 0

    if len(s) == 1:
        return 1
    return 1 + get_ACGT_length(s[1:])


Fixed submission:
def is_ACGT(c):
    if (c == "A") or (c == "C") or (c == "G") or (c == "T"):
        return True
    else:
        return False

def get_ACGT_length(s):
    if len(s) == 0:
        return 0

    if not is_ACGT(s[0]):
        return 0

    return 1 + (get_ACGT_length(s[1:]))


s = str(input())

result = 0
for i, c in enumerate(s):
    if is_ACGT(c):
        result = max(get_ACGT_length(s[i:]), result)

print(result)