Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
mnum, gnum = map(int, input().split())
array = list(map(int, input().split()))

for i in range(gnum):
	array.sort()
	array[len(array)-1] = array[len(array)-1]/2

print(sum(array))

Fixed submission:
text = input()

result = ''
if text == 'Sunny':
	result = 'Cloudy'
elif text == 'Cloudy':
	result = 'Rainy'
else:
	result = 'Sunny'
    
print(result)
Buggy python submission (verdict: Runtime Error):
text = input()

flg = 0
for i in range(len(text)):
	if i%2 == 0:
		if text[i:i+1] != 'R' and text[i:i+1] and 'U' and text[i:i+1] != 'D':
			flg = 1
	else:
		if  text[i:i+1] != 'U' and text[i:i+1] and 'U' and text[i:i+1] != 'D':
			flg = 1
if flg == 1:
	print('No')
else:
	pring('Yes')

Fixed submission:
text = input()
 
flg = 0
for i in range(len(text)):
	if i%2 == 0:
		if text[i:i+1] != 'R' and text[i:i+1] != 'U' and text[i:i+1] != 'D':
			flg = 1
	else:
		if  text[i:i+1] != 'L' and text[i:i+1] != 'U' and text[i:i+1] != 'D':
			flg = 1
if flg == 1:
	print('No')
else:
	print('Yes')
Buggy python submission (verdict: Runtime Error):
import heapq

mnum, gnum = map(int, input().split())
array = list(map(lambda a: -int(a), input().split()))

array.sort()
heapq.heapify(array)

for i in range(gnum):
	temp = heapq.heappop(array)
	temp /= 2.0
	heapq.heappush(array, temp)
    
amount = 0
for a in array:
  amount += math.floor(-a)
print(amount)

Fixed submission:
import math
import heapq

N, M = list(map(int, input().split()))
A = list(map(lambda a: -int(a), input().split()))
A.sort()
heapq.heapify(A)

for i in range(M):
  a = heapq.heappop(A)
  a /= 2.0
  heapq.heappush(A, a)

amount = 0
for a in A:
  amount += math.floor(-a)
print(amount)

Buggy python submission (verdict: Runtime Error):
import heapq

mnum, gnum = map(int, input().split())
array = list(map(lambda a: -int(a), input().split()))

array.sort()
heapq.heapify(array)

for i in range(gnum):
	temp = heapq.heappop(array)
	temp = temp/2
	heapq.heappush(array, temp)
    
amount = 0
for a in array:
  amount += math.floor(-a)
print(amount)

Fixed submission:
import math
import heapq

N, M = list(map(int, input().split()))
A = list(map(lambda a: -int(a), input().split()))
A.sort()
heapq.heapify(A)

for i in range(M):
  a = heapq.heappop(A)
  a /= 2.0
  heapq.heappush(A, a)

amount = 0
for a in A:
  amount += math.floor(-a)
print(amount)

Buggy python submission (verdict: Runtime Error):
mnum, gnum = map(int, input().split())
array = list(map(int, input().split())

for i in range(gnum):
	array.sort()
	array[len(array)-1] = array[len(array)-1]/2

print(sum(array))

Fixed submission:
import math
import heapq

N, M = list(map(int, input().split()))
A = list(map(lambda a: -int(a), input().split()))
A.sort()
heapq.heapify(A)

for i in range(M):
  a = heapq.heappop(A)
  a /= 2.0
  heapq.heappush(A, a)

amount = 0
for a in A:
  amount += math.floor(-a)
print(amount)
Buggy python submission (verdict: Runtime Error):
num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += b[a[i]-1]
	else:
		sum += b[a[i]-1]
		if (a[i]-1) == a[i-1]:
			sum += c[a[i-1]]
 
print(sum)

Fixed submission:
num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += b[a[i]-1]
	else:
		sum += b[a[i]-1]
		if (a[i]-1) == a[i-1]:
			sum += c[a[i-1]-1]
 
print(sum)

Buggy python submission (verdict: Runtime Error):
num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0

for i in range(num):
	if i == 0:
		sum += b[a[i]-1]
	else:
		sum += b[a[i]-1]
		if (a[i]-1) == a[i-1]:
			sum += c[a[i-1]]

print(sum)
          

Fixed submission:
num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += b[a[i]-1]
	else:
		sum += b[a[i]-1]
		if (a[i]-1) == a[i-1]:
			sum += c[a[i-1]-1]
 
print(sum)

Buggy python submission (verdict: Runtime Error):
num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0

for i in range(num):
	if i == 0:
		sum += b[a[i]-1]
	else:
		sum += b[a[i]-1]
		if (a[i]-1) == a[i-1]:
			sum += c[a[i-1]]

print(sum)
          

Fixed submission:
num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += b[a[i]-1]
	else:
		sum += b[a[i]-1]
		if (a[i]-1) == a[i-1]:
			sum += c[a[i-1]-1]
 
print(sum)

Buggy python submission (verdict: Runtime Error):
num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0

for i in range(num):
	if i == 0:
		sum += b[a[i]]
	else:
		sum += b[a[i]]
		if (a[i]-1) == a[i-1]:
			sum += c[i-1]

print(sum)
          

Fixed submission:
num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += b[a[i]-1]
	else:
		sum += b[a[i]-1]
		if (a[i]-1) == a[i-1]:
			sum += c[a[i-1]-1]
 
print(sum)
Buggy python submission (verdict: Runtime Error):
def main():
  size = input()
  a = map(int, input().split())
  a = merge_sort(a)
  
  alice_res = 0
  bob_res = 0
  
  for i in range(len(a)):
    if i%2 == 0:
      alice_res += a[i]
    else:
      bob_res += a[i]
 
  print(alice_res-bob_res)
  

def merge_sort(array):
  if len(array)<=1:
    return array
  
  spl_size = len(array)//2
  
  left_list = merge_sort(array[:spl_size])
  right_list = merge_sort(array[spl_size:])
  
  return merge_list(left_list, right_list)


def merge_list(left_list, right_list):
  left_index = 0
  right_index = 0
  sorted_list = []
  
  while left_index<len(left_list) and right_index<len(right_list):
    if left_list[left_index] < right_list[right_index]:
      sorted_list.append(right_list[right_index])
      right_index+=1
    else:
      sorted_list.append(left_list[left_index])
      left_index+=1
      
  if left_index == len(left_list):
    sorted_list.extend(right_list[right_index:])
  if right_index == len(right_list):
    sorted_list.extend(left_list[left_index:])
      
  return sorted_list
    
                          
main()

Fixed submission:
def main():
  size = input()
  a = list(map(int, input().split()))
  a = merge_sort(a)
  
  alice_res = 0
  bob_res = 0
  
  for i in range(len(a)):
    if i%2 == 0:
      alice_res += a[i]
    else:
      bob_res += a[i]
 
  print(alice_res-bob_res)
  
 
def merge_sort(array):
  if len(array)<=1:
    return array
  
  spl_size = len(array)//2
  
  left_list = merge_sort(array[:spl_size])
  right_list = merge_sort(array[spl_size:])
  
  return merge_list(left_list, right_list)
 
 
def merge_list(left_list, right_list):
  left_index = 0
  right_index = 0
  sorted_list = []
  
  while left_index<len(left_list) and right_index<len(right_list):
    if left_list[left_index] < right_list[right_index]:
      sorted_list.append(right_list[right_index])
      right_index+=1
    else:
      sorted_list.append(left_list[left_index])
      left_index+=1
      
  if left_index == len(left_list):
    sorted_list.extend(right_list[right_index:])
  if right_index == len(right_list):
    sorted_list.extend(left_list[left_index:])
      
  return sorted_list
    
                          
main()
Buggy python submission (verdict: Runtime Error):
def main():
  array = []
  
  size = input()
  for i in range(size):
    array.append(int(input()))
    
  array.sort(reverse=True)
  
  result = 1
  for i in range(len(array)-1):
    if array[i] != array[i+1]:
      result+=1
  
  print(result)
    
    
main()
  

Fixed submission:
def main():
  array = []
  
  size = int(input())
  for i in range(size):
    array.append(int(input()))
    
  array.sort(reverse=True)
  
  result = 1
  for i in range(len(array)-1):
    if array[i] != array[i+1]:
      result+=1
  
  print(result)
    
    
main()
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
res = 0

for i in range(1:n+1):
  sum = 0
  j=0
  while True:
    num = i/(10**j)%10
    if num != 0:
      sum += num
      j+=1
    else:
      break
  if a<=sum && sum<=b:
    res += sum;

print(res)
    

Fixed submission:
def main():
    N, A, B = [int(_) for _ in input().split()]

    ans = 0

    for num in range(1, N + 1):
        if A <= sum(map(int, list(str(num)))) <= B:
            ans += num

    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
import sys
 
size = int(input())
a = map(int, input().split())
cnt = 0
 
while True:
  for i in range(size):
    if(a[i]%2 == 1):
      print(cnt)
      sys.exit()
    
  a = list(map(lambda x:x/2, a))
  cnt+=1

Fixed submission:
a = input()
cnt = 0
for i in a:
  if i == '1':
    cnt+=1
    
print(cnt)

Buggy python submission (verdict: Runtime Error):
import sys

size = int(input())
a = map(int, input().split())
cnt = 0

while true:
  for i in range(size):
    if(a[i]%2 == 1):
      print(cnt)
      sys.exit()
    
  a = map(lambda x:x/2, a)
  cnt +=1
  

Fixed submission:
a = input()
cnt = 0
for i in a:
  if i == '1':
    cnt+=1
    
print(cnt)

Buggy python submission (verdict: Runtime Error):
loop = input()
a = map(int, input().split())
cnt = 0
 
while(1):
  flg = 0
  for i in a:
    if(a%2 == 1):
      flg = 1
      break
      
  if(flg == 0):
    a = map(lambda x:x/2, a)
    cnt += 1
  else:
    break
 
print(cnt)

Fixed submission:
a = input()
cnt = 0
for i in a:
  if i == '1':
    cnt+=1
    
print(cnt)

Buggy python submission (verdict: Runtime Error):
loop = input()
a = map(int, input().split())
cnt = 0
 
while(1):
  flg = 0
  for i in a:
    if(a%2 == 1):
      flg = 1
      
  if(flg == 0):
    a = map(lambda x:x/2, a)
    cnt += 1
  else:
    break
 
print(cnt)

Fixed submission:
a = input()
cnt = 0
for i in a:
  if i == '1':
    cnt+=1
    
print(cnt)

Buggy python submission (verdict: Runtime Error):
loop = input()
a = map(int, input().split())
cnt = 0
 
while(1):
  flg = 0
  for i in a:
    if(a%2 == 1):
      flg = 1
      
  if(flg == 0):
    a = map(lamda x:x/2, a)
    cnt += 1
  else:
    break
 
print(cnt)


Fixed submission:
a = input()
cnt = 0
for i in a:
  if i == '1':
    cnt+=1
    
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n=list(map(int,input().split()))
m=list(map(int,input().split()))
for i in range(n[1]):
  m.remove(max(m))
  if(len(m)==0):
    break
print(sum(m))


Fixed submission:
n=list(map(int,input().split()))
m=list(map(int,input().split()))
m.sort()
if(n[0]<=n[1]):
  print(0)
else:
  print(sum(m[0:n[0]-n[1]]))
Buggy python submission (verdict: Runtime Error):
s=list(map(int,input()))
if (s[0]+s[1]+s[2]>=22):
  print(bust)
else:
  print(win)


Fixed submission:
s=list(map(int,input().split()))
if (s[0]+s[1]+s[2]>=22):
  print("bust")
else:
  print("win")
Buggy python submission (verdict: Runtime Error):
cha=str(input())
if(cha==SUN):
  print(7)
if(cha==SAT):
  print(1)
if(cha==FRI):
  print(2)
if(cha==THR):
  print(3)
if(cha==WED):
  print(4)
if(cha==TUE):
  print(5)
if(cha==MON):
  print(6)

Fixed submission:
s=input()
if(s=="SUN"):
  print(7)
if(s=="MON"):
  print(6)
if(s=="TUE"):
  print(5)
if(s=="WED"):
  print(4)
if(s=="THU"):
  print(3)
if(s=="FRI"):
  print(2)
if(s=="SAT"):
  print(1)
Buggy python submission (verdict: Runtime Error):
print(r ** r)

Fixed submission:
m=int(input())
print(m * m)

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

Fixed submission:
m=int(input())
print(m * m)
Buggy python submission (verdict: Runtime Error):
import sys
n,r = list(map(int, input().split()))
if n >= 10:
    print(n)
else:
    print(n - 100*(10-k))

Fixed submission:
import sys
n,r = list(map(int, input().split()))
if n >= 10:
    print(r)
else:
    print(r + 100*(10-n))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

memo = [0]*100
counter = 0

for i in range(n):
    for j in range(i+1,n):
            if memo[int(s[i])*10+int(s[j])] == 0:
                memo[int(s[i])*10+int(s[j])] = 1
                counter += len(set(s[j+1:]))
        
print(counter)

Fixed submission:

n = int(input())
s = input()

imemo = [0]*10
memo = [0]*100
counter = 0

for i in range(n):
    if imemo[int(s[i])] == 0:
        imemo[int(s[i])] = 1
    else:
        continue
        
    for j in range(i+1,n):
        if memo[int(s[i])*10+int(s[j])] == 0:
                memo[int(s[i])*10+int(s[j])] = 1
                counter += len(set(s[j+1:]))
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

memo = [0]*1000
counter = 0

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if memo[int(s[i])*100+int(s[j])*10+int(s[k])] == 0:
                memo[int(s[i])*100+int(s[j])*10+int(s[k])] = 1
                counter += 1
print(counter)

Fixed submission:

n = int(input())
s = input()

imemo = [0]*10
memo = [0]*100
counter = 0

for i in range(n):
    if imemo[int(s[i])] == 0:
        imemo[int(s[i])] = 1
    else:
        continue
        
    for j in range(i+1,n):
        if memo[int(s[i])*10+int(s[j])] == 0:
                memo[int(s[i])*10+int(s[j])] = 1
                counter += len(set(s[j+1:]))
print(counter)
Buggy python submission (verdict: Runtime Error):
n,k,q = list(map(int, input().split()))
a = [0]*q
for i in range(q):
    tmp = int(input())
    a[tmp-1] += 1

b = ["No"]*n
    

for i in range(n):
    if k - q + a[i] > 0 :
        b[i] = "Yes"

for i in range(n):
    print(b[i])

Fixed submission:
n,k,q = list(map(int, input().split()))
a = [0]*n
for i in range(q):
    tmp = int(input())
    a[tmp-1] += 1

b = ["No"]*n
    

for i in range(n):
    if k - q + a[i] > 0 :
        b[i] = "Yes"

for i in range(n):
    print(b[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = list(map(int, input().split()))
a = [int(input()) for _ in range(q)]

b = ["No"]*n

for i in range(n):
    if k - q + a.count(i+1) > 0 :
        b[i] = "Yes"

for i in range(n):
    print(b[i])

Fixed submission:
n,k,q = list(map(int, input().split()))
a = [0]*n
for i in range(q):
    tmp = int(input())
    a[tmp-1] += 1

b = ["No"]*n
    

for i in range(n):
    if k - q + a[i] > 0 :
        b[i] = "Yes"

for i in range(n):
    print(b[i])
Buggy python submission (verdict: Runtime Error):
print((input())**3)

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

if keta == 1:
    print(n)
elif keta == 2:
    print(9)
elif keta == 3:
    print(n - 90 + 9)
elif keta == 4:
    print(909)
elif keta == 5:
    print(n - 9000 + 900 - 90 + 9)
else:
    print(90909)

Fixed submission:
n = input()
keta = len(n)
n = int(n)

if keta == 1:
    print(n)
elif keta == 2:
    print(9)
elif keta == 3:
    print(n - 90)
elif keta == 4:
    print(909)
elif keta == 5:
    print(n - 9000  - 90 )
else:
    print(90909)
Buggy python submission (verdict: Runtime Error):
s = list(input())
s.sort()

if len(set(s)) == 2 && s[0] == s[1] && s[2] == s[3]:
    print("Yes")
else:
    print("No")

Fixed submission:
s = list(input())
s.sort()

if len(set(s)) == 2 and s[0] == s[1] and s[2] == s[3]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,k = list(map(int, input().split()))

for i in range(1,k+1):
    print(combinations_count(n-k+1,i)*combinations_count((k-i)+(i-1),(i-1)) % (10**9+7))

Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,k = list(map(int, input().split()))

for i in range(1,k+1):
    if n-k+1 >= i:
        print(combinations_count(n-k+1,i)*combinations_count((k-i)+(i-1),(i-1)) % (10**9+7))
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
import fractions
a,b,c,d = list(map(int, input().split()))
a -= 1
l = c/fractions.gcd(c,d)*d
b = b - b //c - b // d + b //l
a = a - a //c - a // d + a //l
print("{:.0f}".format(b-a))

Fixed submission:
import sys
s = input()
for i in range(3):
    if s[i] == s[i+1]:
        print("Bad")
        sys.exit()
print("Good")
Buggy python submission (verdict: Runtime Error):
n = int(input())
z = [list(map(int, input().split())) for _ in range(n)]
z.sort()
pq_pattern = []
pq_counter = [1]*(n-1)

for i in range(n-1):
    #print([z[i+1][0] - z[i][0], z[i+1][1] - z[i][1]])
    if [z[i+1][0] - z[i][0], z[i+1][1] - z[i][1]] in pq_pattern:
        #print("YES!")
        pq_counter[pq_pattern.index([z[i+1][0] - z[i][0], z[i+1][1] - z[i][1]])] += 1
    else:
        pq_pattern.append([z[i+1][0] - z[i][0], z[i+1][1] - z[i][1]])
print(n - max(pq_counter))
#print(pq_counter)
#print(pq_pattern)
#print(z)


Fixed submission:
import sys
import collections
n = int(input())
z = [list(map(int, input().split())) for _ in range(n)]
z.sort()
pq_pattern = []
pq_counter = [1]*(n-1)*n

if n == 1:
    print(1)
    sys.exit()

for i in range(n):
    for j in range(n):
        if not i == j:
            if [z[j][0] - z[i][0], z[j][1] - z[i][1]] in pq_pattern:
                #print("YES!")
                pq_counter[pq_pattern.index([z[j][0] - z[i][0], z[j][1] - z[i][1]])] += 1
            else:
                pq_pattern.append([z[j][0] - z[i][0], z[j][1] - z[i][1]])
print(n-max(pq_counter))

Buggy python submission (verdict: Runtime Error):
n = int(input())
z = [list(map(int, input().split())) for _ in range(n)]
z.sort()
pq_pattern = []
pq_counter = [0]*(n-1)

for i in range(n-1):
    #print([z[i+1][0] - z[i][0], z[i+1][1] - z[i][1]])
    if [z[i+1][0] - z[i][0], z[i+1][1] - z[i][1]] in pq_pattern:
        pq_counter[pq_pattern.index([z[i+1][0] - z[i][0], z[i+1][1] - z[i][1]])] += 1
    else:
        pq_pattern.append([z[i+1][0] - z[i][0], z[i+1][1] - z[i][1]])
print(1+max(pq_counter))



Fixed submission:
import sys
import collections
n = int(input())
z = [list(map(int, input().split())) for _ in range(n)]
z.sort()
pq_pattern = []
pq_counter = [1]*(n-1)*n

if n == 1:
    print(1)
    sys.exit()

for i in range(n):
    for j in range(n):
        if not i == j:
            if [z[j][0] - z[i][0], z[j][1] - z[i][1]] in pq_pattern:
                #print("YES!")
                pq_counter[pq_pattern.index([z[j][0] - z[i][0], z[j][1] - z[i][1]])] += 1
            else:
                pq_pattern.append([z[j][0] - z[i][0], z[j][1] - z[i][1]])
print(n-max(pq_counter))
Buggy python submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(reverse = True, key = lambda x: x[1])
i = 0
counter = 0
while 1:
    for j in range(bc[i][0]):
        a.append(bc[i][1])
        counter += 1
        if counter == n:
            break
    if counter == n:
        break
    i += 1

a.sort(reverse = True)
print(sum(a[:n]))


Fixed submission:
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(reverse = True, key = lambda x: x[1])
i = 0
counter = 0
while 1:
    for j in range(bc[i][0]):
        a.append(bc[i][1])
        counter += 1
        if counter == n:
            break
    if counter == n or i == len(bc)-1:
        break
    i += 1

a.sort(reverse = True)
print(sum(a[:n]))
Buggy python submission (verdict: Runtime Error):
import sys
n,k = list(map(int, input().split()))
s = input()

if s[k-1] == "A":
    s[k-1] = "a"
elif s[k-1] == "B":
    s[k-1] = "b"
else:
    s[k-1] = "c"

print(s)

Fixed submission:
import sys
n,k = list(map(int, input().split()))
s = list(input())

if s[k-1] == "A":
    s[k-1] = "a"
elif s[k-1] == "B":
    s[k-1] = "b"
else:
    s[k-1] = "c"

print("".join(s))
Buggy python submission (verdict: Runtime Error):
import sys
a,b,t = list(map(int, input().split()))
print(b*(c//a))

Fixed submission:
import sys
a,b,t = list(map(int, input().split()))
print(b*(t//a))
Buggy python submission (verdict: Time Limit Exceeded):
_,q= list(map(int, input().split()))
S=list(input())
 
for i in range(q):
  a,b=list(map(int, input().split()))
  counter=0
 
  for j in range(b-a):
    if S[a-1+j] == "A":
      if S[a+j] == "C":
        counter +=1
 
  print(counter)

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

t=[0]*n

s=s.replace("AC", "Ac")
#s=s.translate(str.maketrans({'AC':'aC'})) maketransは置換元一文字じゃないといけんみたい
for i in range(n):
  if s[i] == "c":
    if i !=0:
      t[i]=1+t[i-1]
    else:
      t[i]=1
  else:
    t[i]=t[i-1]

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

Buggy python submission (verdict: Time Limit Exceeded):
n,q= list(map(int, input().split()))
S=list(input())

for i in range(q):
  a,b=list(map(int, input().split()))
  counter=0
 
  for j in range(len(S[a-1:b])-1):
    if S[a-1:b][j] == "A":
      if S[a-1:b][j+1] == "C":
        counter +=1

  print(counter)

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

t=[0]*n

s=s.replace("AC", "Ac")
#s=s.translate(str.maketrans({'AC':'aC'})) maketransは置換元一文字じゃないといけんみたい
for i in range(n):
  if s[i] == "c":
    if i !=0:
      t[i]=1+t[i-1]
    else:
      t[i]=1
  else:
    t[i]=t[i-1]

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

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

for i in range(q):
  a,b=list(map(int, input().split()))
  counter=0
 
  for j in range(len(s)-1):
    if S[a-1:b][j] == "A":
      if S[a-1:b][j+1] == "C":
        counter +=1

  print(counter)

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

t=[0]*n

s=s.replace("AC", "Ac")
#s=s.translate(str.maketrans({'AC':'aC'})) maketransは置換元一文字じゃないといけんみたい
for i in range(n):
  if s[i] == "c":
    if i !=0:
      t[i]=1+t[i-1]
    else:
      t[i]=1
  else:
    t[i]=t[i-1]

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

Buggy python submission (verdict: Time Limit Exceeded):
n,q= list(map(int, input().split()))
S=list(input())

for i in range(q):
  a,b=list(map(int, input().split()))
  s = S[a-1:b]
  counter=0
 
  for j in range(len(s)-1):
    if s[j] == "A":
      if s[j+1] == "C":
        counter +=1

  print(counter)

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

t=[0]*n

s=s.replace("AC", "Ac")
#s=s.translate(str.maketrans({'AC':'aC'})) maketransは置換元一文字じゃないといけんみたい
for i in range(n):
  if s[i] == "c":
    if i !=0:
      t[i]=1+t[i-1]
    else:
      t[i]=1
  else:
    t[i]=t[i-1]

#print(t)
for _ in range(q):
  l,r=list(map(int, input().split()))
  print(t[r-1]-t[l-1])
Buggy python submission (verdict: Runtime Error):
a,b,k = list(map(int, input().split()))
x=[]

for i in range(1, min(a, b)):
    if a%i == 0 and b%i==0:
      x.append(i)

x.sort(reverse=True)
print(x[k-1])

Fixed submission:
a,b,k = list(map(int, input().split()))
x=[]

for i in range(1, min(a, b)+1):
    if a%i == 0 and b%i==0:
      x.append(i)

x.sort(reverse=True)
print(x[k-1])

Buggy python submission (verdict: Runtime Error):
a,b,k = list(map(int, input().split()))
x=[]

for i in range(1, min(a, b)):
    if a%i == 0 and b%i==0:
      x.append(i)

x.sort(reverse=True)
print(x[k-1])

Fixed submission:
a,b,k = list(map(int, input().split()))
x=[]

for i in range(1, min(a, b)+1):
    if a%i == 0 and b%i==0:
      x.append(i)

x.sort(reverse=True)
print(x[k-1])
Buggy python submission (verdict: Runtime Error):
y,m,d = list(map(int, input().split("/")))

if y < 2019 or (y =2019 and m <=4):
  print(Heisei)
else:
  print(TBD)

Fixed submission:
y,m,d = list(map(int, input().split("/")))

if y < 2019:
  print(Heisei)
elif y ==2019 and m <=4:
  print("Heisei")
else:
  print("TBD")