Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
p = list(map(int,input().split()))

box = []
ans = 0

for i in range(N-(K-1)):
    tmp = []
    for _ in range(i,K+i):
        tmp.append(p[_])
    box.append(sum(tmp))
max_p = box.index(max(box))

for j in range(0,K):
    ans += (1 + p[max_p+j])/2
print(ans)


Fixed submission:
N,K = map(int,input().split())
p = list(map(int,input().split()))
R = [0]*(N+1)
ans = 0
for i in range(1,N+1):
    X = p[i-1]
    R[i] = R[i-1] + (X*(X+1))/2/X
    if i+1 >= K:
        ans = max(ans,R[i]-R[i-K])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
p = list(map(int,input().split()))
box = []
ans = 0

for i in range(N-(K-1)):
    tmp = []
    for _ in range(i,K+i):
        tmp.append(p[_])
    box.append(sum(tmp))
max_p = box.index(max(box))

for j in range(0,K):
    dice = []
    for k in range(1,p[max_p + j]+1):
        dice.append(k)
    ex = 0
    P = 1/len(dice)
    for l in dice:
        Px = P*l
        ex += Px
    ans += ex
print(ans)

Fixed submission:
N,K = map(int,input().split())
p = list(map(int,input().split()))
R = [0]*(N+1)
ans = 0
for i in range(1,N+1):
    X = p[i-1]
    R[i] = R[i-1] + (X*(X+1))/2/X
    if i+1 >= K:
        ans = max(ans,R[i]-R[i-K])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
H = list(map(int,input().split()))
for i in range(K):
    if not H: continue
    max_val = max(H)
    H.pop(H.index(max_val))
print(sum(H))

Fixed submission:
N,K = map(int,input().split())
H = list(map(int,input().split()))

sort_H = sorted(H)
if N >= K:
    print(sum(sort_H[0:N-K]))
else:
    print('0')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
    if P[i] == min(P[0:i+1]):
        ans += 1
print(ans)


Fixed submission:
N = int(input())
P = list(map(int,input().split()))
ans = 0
mini = P[0]

for i in range(N):
    if P[i] <= mini:
        mini = P[i]
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
cnt = 1

for i in range(1,N):
    j = i
    tmp = 0
    while i > 0:
        if P[j] <= P[i-1]:
            tmp += 1
        i -= 1
    if j == tmp:
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
ans = 0
mini = P[0]

for i in range(N):
    if P[i] <= mini:
        mini = P[i]
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from goto import goto, label

X = int(input())
max = 10 ** 5

for i in range(X,max):
    sqt = math.sqrt(i)
    for j in range(1, math.ceil(sqt)):
        cal = i % j
        if cal == 0:
            print(i)
            goto .END
label .END


Fixed submission:
import math
X = int(input())
key = 0

def prim(N):
    sqt = int(math.sqrt(N))
    for i in range(2,sqt+1):
        if N%i == 0:
            return False
    return True

while key == 0:
    if prim(X):
        key = 1
        break
    X += 1

print(X)
Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int, input().split())
max = A * B
lst = []
lst.append(max)

for i in range(max,0,-1):
    if (i % A == 0) and (i % B == 0):
        lst.append(i)
print(min(lst))


Fixed submission:
A,B = map(int, input().split())
for i in range(B):
    if ( A * (i+1) ) % B == 0:
        print(A*(i+1))
        break
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
XY = []
honest_count = []

for i in range(N):
    a = int(input())
    A.append(a)
    inter = []
    for x in range(a):
        xy = list(map(int,input().split()))
        inter.append(xy)
    XY.append(inter)

for i in range(2**N):
    pt = [0]*N
    ck = 1
    for j in range(N):
        if (i>>j)&1:
            pt[N-j-1]=1
    for k in range(N):
        if pt[k] ==1:
            for l in range(A[k]):
                if XY[k][l][1] != pt[XY[k][l][0] -1]:
                    ck = 0
    if ck == 1:
        honest_count.append(sum(pt))
print(max(honest_count))


Fixed submission:
A, B, C = map(int, input().split())
if A+B+C > 21:
    print('bust')
else:
    print('win')

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
XY = []
honest_count = []

for i in range(N):
    a = int(input())
    A.append(a)
    inter = []
    for x in range(a):
        xy = list(map(int,input().split()))
        inter.append(xy)
    XY.append(inter)

for i in range(2**N):
    pt = [0]*N
    ck = 1
    for j in range(N):
        if (i>>j)&1:
            pt[N-j-1]=1
    for k in range(N):
        if pt[k] ==1:
            for l in range(A[k]):
                if XY[k][l][1] != pt[XY[k][l][0] -1]:
    if ck == 1:
        honest_count.append(sum(pt))
print(max(honest_count))


Fixed submission:
A, B, C = map(int, input().split())
if A+B+C > 21:
    print('bust')
else:
    print('win')
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())
ans = []
lst = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(len(S)):
    tmp = lst.index(S[i])
    tmp += N
    if tmp > 25:
        tmp -= 25
    ans.append(lst[tmp])
print(''.join(ans))


Fixed submission:
N = int(input())
S = str(input())
ans = []
lst = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(len(S)):
    tmp = lst.index(S[i])
    tmp += N
    if tmp > 25:
        tmp -= 26
    ans.append(lst[tmp])
print(''.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
ans = 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            if i != j and i != k and j != k:
                if (L[i] < (L[j] + L[k])) and (L[j] < (L[k] + L[i])) and (L[k] < (L[i] + L[j])):
                    ans += 1
                    #print(L[i],L[j],L[k])

print(ans//6)

Fixed submission:
# ３重ループではTLE
# a < b < c & c < a + b

import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0

for i in range(N):
    for j in range(i+1,N):
        t = L[i] + L[j]
        idx = bisect.bisect_left(L,t)
        ans += max(0, idx-j-1) # c < a + b の範囲を総取り
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
ans = 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            if i != j and i != k and j != k:
                if L[i] < (L[j] + L[k]):
                    if L[j] < (L[k] + L[i]):
                        if L[k] < (L[i] + L[j]):
                            ans += 1
                            #print(L[i],L[j],L[k])

print(ans//6)

Fixed submission:
# ３重ループではTLE
# a < b < c & c < a + b

import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0

for i in range(N):
    for j in range(i+1,N):
        t = L[i] + L[j]
        idx = bisect.bisect_left(L,t)
        ans += max(0, idx-j-1) # c < a + b の範囲を総取り
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
ans = 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            if i != j and i != k and j != k:
                if L[i] < (L[j] + L[k]):
                    if L[j] < (L[k] + L[i]):
                        if L[k] < (L[i] + L[j]):
                            ans += 1
                            #print(L[i],L[j],L[k])

print(ans//6)

Fixed submission:
# ３重ループではTLE
# a < b < c & c < a + b

import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0

for i in range(N):
    for j in range(i+1,N):
        t = L[i] + L[j]
        idx = bisect.bisect_left(L,t)
        ans += max(0, idx-j-1) # c < a + b の範囲を総取り
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
ans = 0

for i in range(N):
    if i == 0:
        ans += B[0]
    elif i == N-1:
        ans += B[-1]
    else:
        ans += min(B[i-1],B[i])
print(ans)


Fixed submission:
S = input()
if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
elif S == 'Rainy':
    print('Sunny')
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))

ans = []
cnt = 0

for i in range(N-1,0,-1):
    if H[i] <= H[i-1]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
    ans.append(cnt)
print(max(ans))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = []
cnt = 0
for i in range(N-1, 0, -1):
    if H[i] <= H[i-1]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
ans = "Yes"
for i in range(1,N):
    if H[i] > H[i+1] + 1:
        ans = "No"
        break
print(ans)


Fixed submission:
N = int(input())
H = list(map(int,input().split()))
for i in range(N-2,0,-1):
 if H[i]> H[i+1]:
   H[i] -=1
   if H[i] > H[i+1]:
     print('No')
     break
else:
 print('Yes')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    town_a = a[i]
    town_b = b[i+1]
    power = b[i]
    if power > town_a:
        ans += town_a
        power -= town_a
    else:
        ans += power
        continue
    if power > town_b:
        ans += town_b
        a[i+1] = 0
    else:
        ans += power
        a[i+1] -= power
print(ans)

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

ans = 0
for i in range(n):
    town_a = a[i]
    town_b = a[i+1]
    power = b[i]
    if power > town_a:
        ans += town_a
        power -= town_a
    else:
        ans += power
        continue
    if power > town_b:
        ans += town_b
        a[i+1] = 0
    else:
        ans += power
        a[i+1] -= power
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

L,R = map(int,input().split())
lst = []

if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        if i % 2019 == 0:
            print(0)
            break
        for j in range(i+1,R+1):
            if j % 2019 == 0:
                print(0)
                break
            lst.append((i * j) % 2019)
        else:
            continue
        break
        print(min(lst))


Fixed submission:
N, A, B = map(int, input().split())
print(min(A*N, B))

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

n,D = map(int,input().split())

point = []
for _ in range(n):
  x = list(map(int, input().split()))
  point.append(x)

cnt = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for d in range(D):
      dist += (point[i][d] - point[j][d])**2
    dist = math.sqrt(dist)
    if int(dist) == dist:
      cnt += 1
print(cnt)

Fixed submission:
N, A, B = map(int, input().split())
print(min(A*N, B))
Buggy python submission (verdict: Runtime Error):
import math

n,D = map(int,input().split())

point = []
for _ in range(n):
  x = list(map(int, input().split()))
  point.append(x)

cnt = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for d in range(D):
      dist += (point[i][d] - point[j][d])**2
    dist = mat.sqrt(dist)
    if int(dist) == dist:
      cnt += 1
print(cnt)

Fixed submission:
import math

n,D = map(int,input().split())

point = []
for _ in range(n):
  x = list(map(int, input().split()))
  point.append(x)

cnt = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for d in range(D):
      dist += (point[i][d] - point[j][d])**2
    dist = math.sqrt(dist)
    if int(dist) == dist:
      cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

L,R = map(int,input().split())
lst = []

if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        if i % 2019 == 0:
            print(0)
            break
        for j in range(i+1,R+1):
            if j % 2019 == 0:
                print(0)
            lst.append((i*j)%2019)
    print(min(lst))


Fixed submission:
import sys
input = sys.stdin.readline

L,R = map(int,input().split())
lst = []

if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        if i % 2019 == 0:
            lst.append(0)
            break
        for j in range(i+1,R+1):
            if j % 2019 == 0:
                lst.append(0)
                break
            lst.append((i * j) % 2019)
        else:
            continue
        break
    print(min(lst))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

L,R = map(int,input().split())
lst = []

if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            lst.append((i*j)%2019)
    print(min(lst))


Fixed submission:
import sys
input = sys.stdin.readline

L,R = map(int,input().split())
lst = []

if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        if i % 2019 == 0:
            lst.append(0)
            break
        for j in range(i+1,R+1):
            if j % 2019 == 0:
                lst.append(0)
                break
            lst.append((i * j) % 2019)
        else:
            continue
        break
    print(min(lst))
Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = [int, input().split()]
cnt = 0

for i in range(n-2):
  if lst[1][i] < lst[1][i+1] < lst[1][i+2] or lst[1][i] > lst[1][i+1] > lst[1][i+2] or lst[1][i] = lst[1][i+1] < lst[1][i+2] or lst[1][i] > lst[1][i+1] = lst[1][i+2]:
    cnt += 1
    
print(cnt)

Fixed submission:
n = int(input())
lst = list(map(int,input().split()))
cnt = 0

for i in range(n-2):
  if lst[i] < lst[i+1] < lst[i+2]  or \
     lst[i] > lst[i+1] > lst[i+2]:
    cnt += 1
    
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
lst = []

for i in range(N):
  lst.append(L + (i+1) - 1)
  
if L >= 0:
  print(sum(lst)-lst[0])
elif L+N-1 >= 0:
  print(sum(lst))
else:
  print(sum(lst) - lst[n-1])

Fixed submission:
N, L = map(int, input().split())
lst = []

for i in range(N):
  lst.append(L + (i+1) - 1)
  
if L >= 0:
  print(sum(lst)-lst[0])
elif L+N-1 >= 0:
  print(sum(lst))
else:
  print(sum(lst) - lst[N-1])
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x,y):
    return (x * y) // math.gcd(x,y)

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

cnt = 0
cnt += ((B // C) - ((A-1) // C))
cnt += ((B // D) - ((A-1) // D))

tmp = 0
tmp = ((B//lcm(C,D)) - (A//lcm(C,D)))

print(B-A+1-cnt+tmp)


Fixed submission:
from fractions import gcd

def lcm(a, b):
    return a // gcd(a, b) * b

A,B,C,D = list(map(int,input().split()))
C1 = B//C
C2 = (A-1)//C
C3 = B//D
C4 = (A-1)//D
C5 = B//lcm(C,D)
C6 = (A-1)//lcm(C,D)
print((B-(A-1))-((C1-C2)+(C3-C4)-(C5-C6)))

Buggy python submission (verdict: Runtime Error):
import math
def lcm(x,y):
    return (x * y) // math.gcd(x,y)

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

cnt = 0
cnt += ((B // C) - ((A-1) // C))
cnt += ((B // D) - ((A-1) // D))

tmp = 0
tmp = ((B//lcm(C,D)) - (A//lcm(C,D)))

print(B-A+1-cnt+tmp)


Fixed submission:
from fractions import gcd

def lcm(a, b):
    return a // gcd(a, b) * b

A,B,C,D = list(map(int,input().split()))
C1 = B//C
C2 = (A-1)//C
C3 = B//D
C4 = (A-1)//D
C5 = B//lcm(C,D)
C6 = (A-1)//lcm(C,D)
print((B-(A-1))-((C1-C2)+(C3-C4)-(C5-C6)))

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
cnt = 0
# print(B//C)
# print(A//C)
# print(B//D)
# print(A//D)
# print()
cnt += ((B // C) - ((A-1) // C))
# print(cnt)
cnt += ((B // D) - ((A-1) // D))
# print(cnt)

# print()
# print(B-A+1-cnt)

# かぶっているのを足し戻す
tmp = 0
def lcm(x,y):
    return (x * y) // math.gcd(x,y)
# print(lcm(C,D))

# print(B//lcm(C,D))
# print(A//lcm(C,D))
tmp = ((B//lcm(C,D)) - (A//lcm(C,D)))

print(B-A+1-cnt+tmp)


Fixed submission:
from fractions import gcd

def lcm(a, b):
    return a // gcd(a, b) * b

A,B,C,D = list(map(int,input().split()))
C1 = B//C
C2 = (A-1)//C
C3 = B//D
C4 = (A-1)//D
C5 = B//lcm(C,D)
C6 = (A-1)//lcm(C,D)
print((B-(A-1))-((C1-C2)+(C3-C4)-(C5-C6)))

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
cnt = 0
# print(B//C)
# print(A//C)
# print(B//D)
# print(A//D)
# print()
cnt += ((B // C) - ((A-1) // C))
# print(cnt)
cnt += ((B // D) - ((A-1) // D))
# print(cnt)

# print()
# print(B-A+1-cnt)

# かぶっているのを足し戻す
tmp = 0
def lcm(x,y):
    return (x * y) // math.gcd(x,y)
# print(lcm(C,D))

# print(B//lcm(C,D))
# print(A//lcm(C,D))
tmp = ((B//lcm(C,D)) - (A//lcm(C,D)))

print(B-A+1-cnt+tmp)


Fixed submission:
from fractions import gcd

def lcm(a, b):
    return a // gcd(a, b) * b

A,B,C,D = list(map(int,input().split()))
C1 = B//C
C2 = (A-1)//C
C3 = B//D
C4 = (A-1)//D
C5 = B//lcm(C,D)
C6 = (A-1)//lcm(C,D)
print((B-(A-1))-((C1-C2)+(C3-C4)-(C5-C6)))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
lst = []
lst2 = []
lst3 = []

for _ in range(M):
  lst.append(list(map(int,input().split())))

#print(lst)

for i in range(M):
  for j in range(min(lst[i]),max(lst[i])+1):
    lst2.append(j)

#print(lst2)

for k in range(1,N+1):
  lst3.append(lst2.count(k))
  
#print(lst3)

print(lst3.count(M))



Fixed submission:
N,M = map(int, input().split())
B = []
C = []

for _ in range(M):
  tmp1,tmp2 = map(int,input().split())
  B.append(tmp1)
  C.append(tmp2)

p = max(B)
q = min(C)
res = q - p + 1
if res < 0:
  res = 0
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
tmp=0
cnt=0

while tmp<3:
  if A > B:
    cnt+=A
    A-=1
    tmp+1
  elif A < B:
    cnt+=B
    B-=1
    tmp+1
  else:
    cnt+=A
    A-=1
    tmp+1
print(cnt)
  


Fixed submission:
A,B = map(int,input().split())
tmp=0
cnt=0

while tmp<2:
  if A > B:
    cnt+=A
    A-=1
    tmp+=1
  elif A < B:
    cnt+=B
    B-=1
    tmp+=1
  else:
    cnt+=A
    A-=1
    tmp+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
tmp=0
cnt=0

while tmp<3:
  if A > B:
    cnt+=A
    A-=1
  elif A < B:
    cnt+=B
    B-=1
  else:
    cnt+=A
   A-=1
print(cnt)
  


Fixed submission:
A,B = map(int,input().split())
tmp=0
cnt=0

while tmp<2:
  if A > B:
    cnt+=A
    A-=1
    tmp+=1
  elif A < B:
    cnt+=B
    B-=1
    tmp+=1
  else:
    cnt+=A
    A-=1
    tmp+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
tmp=0

while tmp<3:
  if A > B:
    cnt+=A
    A-=1
  elif A < B:
    cnt+=B
    B-=1
  else:
    cnt+=A
   A-=1
print(cnt)
  

Fixed submission:
A,B = map(int,input().split())
tmp=0
cnt=0

while tmp<2:
  if A > B:
    cnt+=A
    A-=1
    tmp+=1
  elif A < B:
    cnt+=B
    B-=1
    tmp+=1
  else:
    cnt+=A
    A-=1
    tmp+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N=input()
H=list(map(int,input().split()))

cnt=0

for i in range(0,N):
  if max(H[0:i+1] <= H[i]:
    cnt+=1
print(cnt)


Fixed submission:
N=int(input())
H=list(map(int,input().split()))

cnt=0

for i in range(0,N):
  if max(H[0:i+1]) <= H[i]:
    cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
N=input()
H=list(map(int,input().split()))

cnt=1

for i in range(N+1):
  if H[i] < H[i+1]:
    cnt+=1
print(cnt)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))

cnt=0

for i in range(0,N):
  if max(H[0:i+1]) <= H[i]:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
b = input()
if b == "A":
  print("T")
elif b == "C":
  print("G")
elif b == "G":
  print("C")
else b == "T":
  print("A")


Fixed submission:
b = input()

if b == "A":
  print("T")
elif b == "C":
  print("G")
elif b == "G":
  print("C")
else:
  print("A")

Buggy python submission (verdict: Runtime Error):
b = input()
if b == A:
  print("T")
elif b == C:
  print("G")
elif b == G:
  print("C")
else b == T:
  print("A")

Fixed submission:
b = input()

if b == "A":
  print("T")
elif b == "C":
  print("G")
elif b == "G":
  print("C")
else:
  print("A")
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input()
for i in range(Q):
  l,r = map(int,input().split())
  chk = S[l-1:r]
  print(chk.count("AC"))


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

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input()
for i in range(Q):
  l,r = map(int,input().split())
  chk = S[l-1:r]
  print(chk.count("AC"))


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

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input()
cnt = 0
for i in range(Q):
  l,r = map(int,input().split())
  chk = S[l-1:r]
  print(chk.count("AC"))


Fixed submission:
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)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
#N,M,C=map(int,input().split())
#B=[int,input() for _ in range(M)]
#
#for i in range(N):
#  A=[int,input() for _ in range(M)]

import numpy as np
  
N,M,C=map(int,input().split())
B=np.array([int,input() for _ in range(M)])
ans=0

for i in range(N):
  A=np.array([int,input() for _ in range(M)])
  if sum(A-B)-10 > 0:
    ans+=1



Fixed submission:
import numpy as np

N,M,C = map(int,input().split())
B=np.array(list(map(int,input().split())))
ans=0

for i in range(N):
  A=np.array(list(map(int,input().split())))
  if sum(A*B)+C > 0:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
hoge=[]

for i in range(1,101):
  if (A%i == 0 and B%i ==0):
    hoge.append(i)

print(hoge[K-1])


Fixed submission:
A,B,C = map(int,input().split())

if B - A*C >= 0:
  print(C)
else:
  print(B//A)
Buggy python submission (verdict: Runtime Error):
S=input()
S.replace("/","")
if (int(S) - "20190430") <= 0:
  print("Heisei")
else:
  print("TBD")

Fixed submission:
S=input()
if (int(S.replace("/","")) - 20190430) <= 0:
  print("Heisei")
else:
  print("TBD")
Buggy python submission (verdict: Runtime Error):
X,Y = map(int,input())
price = X + Y/2



Fixed submission:
X,Y = map(int,input().split())
price = X + Y/2
print(round(price))
Buggy python submission (verdict: Runtime Error):
N,T = map(int,input().split())
c = []
t = []
hoge = []
hogehoge = []

for i in range(N):
  a,b = map(int,input().split())
  c.append(a)
  t.append(b)

for i in range(N):
  if t[i] < T:
    hoge.append(c[i])
print(min(hoge))


Fixed submission:
N,T = map(int,input().split())
c = []
t = []
hoge = []

for i in range(N):
  a,b = map(int,input().split())
  c.append(a)
  t.append(b)

for i in range(N):
  if t[i] <= T:
    hoge.append(c[i])
if hoge != []:
  print(min(hoge))
else:
  print("TLE")
Buggy python submission (verdict: Runtime Error):
N = str(input())

print(N.replace('1', '9').replace('9', '1')

Fixed submission:
N = input()
L = list(N)

for i in range(3):
  if L[i] == "1":
    L[i] = "9"
  else:
    L[i] = "1"
print("".join(L))
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
M = []
cnt = 0
for j in range(N):
  M.append(int,input())
a=X-sum(M)
cnt=a//min(M)+N
print(cnt)


Fixed submission:
N,X = map(int,input().split())
M = [int(input()) for i in range(N)]
X -= sum(M)
M.sort()
ans = -1
while X >= 0:
  X -= M[0]
  ans += 1
print(ans+N)