Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

r = int(sys.stdin.readline)
print(r**2)

Fixed submission:
import sys

r = int(sys.stdin.readline())
print(r**2)

Buggy python submission (verdict: Runtime Error):
radius = input()

print(radius * radius)

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

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

Fixed submission:
r = input()
print(int(r) * int(r))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
 
if n%2 == 1:
  print("No")
  return
 
slise = (n/2)
a = s[:int(slise)]
b = s[int(slise):]
 
if a==b:
  print("Yes")
else:
  print("No")

Fixed submission:
import sys

n = int(input())
s = input()
 
if n%2 == 1:
  print("No")
  sys.exit()
 
slise = (n/2)
a = s[:int(slise)]
b = s[int(slise):]
 
if a==b:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
 
if n%2 == 1:
  print("No")

slise = (n/2)*1
a = s[:int(start)]
b = s[int(slise):]

if a==b:
  print("Yes")
else:
  print("No")

Fixed submission:
import sys

n = int(input())
s = input()
 
if n%2 == 1:
  print("No")
  sys.exit()
 
slise = (n/2)
a = s[:int(slise)]
b = s[int(slise):]
 
if a==b:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

if n%2 ==1:
  print("No")

a = s[n/2:]
b = s[:n/2]
 
if a==b:
  print("Yes")
else:
  print("No")

Fixed submission:
import sys

n = int(input())
s = input()
 
if n%2 == 1:
  print("No")
  sys.exit()
 
slise = (n/2)
a = s[:int(slise)]
b = s[int(slise):]
 
if a==b:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

a = s[n/2:]
b = s[:n/2]

if a==b:
  print("Yes")
else:
  print("No")

Fixed submission:
import sys

n = int(input())
s = input()
 
if n%2 == 1:
  print("No")
  sys.exit()
 
slise = (n/2)
a = s[:int(slise)]
b = s[int(slise):]
 
if a==b:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
d = int(input())

if d == 22:
  print("Christmas Eve Eve Eve")
elif d == 23:
  print("Christmas Eve Eve")
elif d == 24:
  print("Christmas Eve")
elif d == 25:
  print("Christmas")
else:
  break


Fixed submission:
d = int(input())
 
if d == 22:
  print("Christmas Eve Eve Eve")
elif d == 23:
  print("Christmas Eve Eve")
elif d == 24:
  print("Christmas Eve")
elif d == 25:
  print("Christmas")
else:
  exit()
Buggy python submission (verdict: Runtime Error):
s = input()

counter = 0
moji = ""
for i in s:
  if i == "B":
	moji[:-1]
    continue
  else:
    moji+ i

Fixed submission:
s = input()
 
counter = 0
moji = ""
for i in s:
	
	if i == "B":
		moji = moji[:-1]
		
		continue
    	

	moji = moji+ i

print(moji)
Buggy python submission (verdict: Runtime Error):
a = r*r
print(a)

Fixed submission:
r = int(input())
print(r*r)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = map(int, input().split())

from itertools import combinations

comb = combinations(L, 3)

ans = 0
for c in comb:
    if 2*max(c)<sum(c):
        ans+=1
        
print(ans)

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

from bisect import bisect_right

L = sorted(L, reverse=True)
L = [-L[i] for i in range(N)]

cnt=0
for i in range(N-2):
    for j in range(i+1, N-1):
        diff = L[i]-L[j]
        idx = bisect_right(L, diff-1, j+1, N)
        cnt+=(idx-j)-1
    
print(cnt)

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

from itertools import combinations

comb = combinations(L, 3)

ans = 0
for c in comb:
    if 2*max(c)<sum(c):
        ans+=1
        
print(ans)

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

from bisect import bisect_right

L = sorted(L, reverse=True)
L = [-L[i] for i in range(N)]

cnt=0
for i in range(N-2):
    for j in range(i+1, N-1):
        diff = L[i]-L[j]
        idx = bisect_right(L, diff-1, j+1, N)
        cnt+=(idx-j)-1
    
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input()))

rev = []
for a in A:
    rev.append(1/float(a))

print(1/float(sum(rev)))

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

rev = []
for a in A:
  rev.append(1.0/float(a))
  
print(1.0/float(sum(rev)))

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

rev = []
for a in A:
    rev.append(1/float(a))

print(1/sum(rev))

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

rev = []
for a in A:
  rev.append(1.0/float(a))
  
print(1.0/float(sum(rev)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for _ in range(N)]

from collections import Counter
from scipy.special import comb

nS = []
for s in S:
    s  = ''.join(sorted(s))
    nS.append(s)

c = Counter(nS)

acc = 0
for cnt in list(c.values()):
    acc+=comb(cnt, 2, exact=True)
print(acc)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]
 
from collections import Counter
 
nS = []
for s in S:
    s  = ''.join(sorted(s))
    nS.append(s)

c = Counter(nS)
 
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

acc = 0
for cnt in list(c.values()):
    if cnt!=1:
        acc+=cmb(cnt, 2)
    
print(acc)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

idx = max(enumerate(H), key=lambda x: x[1])[0]

cmp = H[idx]-1
flg = 0

if idx!=N-1:
    for i in range(idx, N):
        if H[i]<cmp:
            flg = 1
    if flg==0:
        print('Yes')
    else:
        print('No')

else:
    idx = max(enumerate(H[0:N-1]), key=lambda x: x[1])[0]
    cmp = H[idx]-1
    flg = 0
    for i in range(idx, N-1):
        if H[i]<cmp:
            flg = 1
    if flg==0:
        print('Yes')
    else:
        print('No')


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

idx = max(enumerate(H), key=lambda x: x[1])[0]

cmp = H[idx]-1
flg = 0

if N>1:
    if idx!=N-1:
        for i in range(idx, N):
            if H[i]<cmp:
                flg = 1
        if flg==0:
            print('Yes')
        else:
            print('No')

    else:
        idx = max(enumerate(H[0:N-1]), key=lambda x: x[1])[0]
        cmp = H[idx]-1
        flg = 0
        for i in range(idx, N-1):
            if H[i]<cmp:
                flg = 1
        if flg==0:
            print('Yes')
        else:
            print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

P = 10**9+7
LENGTH = len(S)

"""dp[i][j] -> あり得る全ての上からi+1桁目までの数を13で割った余りが j となる状態数"""
dp = [[0 for i in range(13)] for j in range(LENGTH)]

if S[0]=='?':
    for j in range(10):
        dp[0][j]+=1
else:
    dp[0][int(S[0])]+=1

for i in range(LENGTH-1):
    for j in range(13):
        if S[i+1]=='?':
            for k in range(10):
                dp[i+1][(10*j+k)%13]+=dp[i][j]%P
        else:
            dp[i+1][(10*j+int(S[i+1]))%13]+=dp[i][j]%P

print(dp[LENGTH-1][5]%P)

Fixed submission:
S = input()

P = 10**9+7
LENGTH = len(S)

"""dp[i][j] -> あり得る全ての上からi+1桁目までの数を13で割った余りが j となる状態数"""
dp = [[0 for i in range(13)] for j in range(LENGTH)]

if S[0]=='?':
    for j in range(10):
        dp[0][j]+=1
else:
    dp[0][int(S[0])]+=1

for i in range(LENGTH-1):
    for j in range(13):
        if S[i+1]=='?':
            for k in range(10):
                dp[i+1][(10*j+k)%13]+=dp[i][j]%P
        else:
            dp[i+1][(10*j+int(S[i+1]))%13]+=dp[i][j]%P

print(dp[LENGTH-1][5]%P)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

P = 2019

R = min(R, L+4038)

tmp = 3000
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min((i*j)%P, tmp)
        
print(tmp)

Fixed submission:
L, R = map(int, input().split())

P = 2019

R = min(R, L+673)

tmp = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min((i*j)%P, tmp)
        
print(tmp)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

P = 2019

def mul(a, b):
    return ((a % P) * (b % P)) % P

R = min(R, L+4038)

tmp = 10**9
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min(mul(i, j), tmp)
        
print(tmp)

Fixed submission:
L, R = map(int, input().split())

P = 2019

R = min(R, L+673)

tmp = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min((i*j)%P, tmp)
        
print(tmp)

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

P = 2019

def mul(a, b):
    return ((a % P) * (b % P)) % P

R = min(R, l+4038)

tmp = 10**9
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min(mul(i, j), tmp)
        
print(tmp)

Fixed submission:
L, R = map(int, input().split())

P = 2019

R = min(R, L+673)

tmp = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min((i*j)%P, tmp)
        
print(tmp)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

import math

E = C*D/math.gcd(C, D)
interval = B-A+1


n1 = math.ceil(A/C)
n2 = math.ceil(A/D)
n3 = math.ceil(A/E)


m1 = math.floor(B/C)
m2 = math.floor(B/D)
m3 = math.floor(B/E)

cnt_c = m1-n1+1
cnt_d = m2-n2+1
cnt_cd = m3-n3+1

print(interval-(cnt_c+cnt_d-cnt_cd))

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

import math

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def myfunc(x, div1, div2):
    div3 = lcm(div1, div2)
    return x-x//div1-x//div2+x//div3

print(myfunc(B, C, D)-myfunc(A-1, C, D))

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

import math

interval = B-A+1

n1 = math.ceil(A/C)
n2 = math.ceil(A/D)
m1 = math.ceil(B/C)
m2 = math.ceil(B/D)

arr1 = []
arr2 = []

if B%C==0:
    for i in range(n1, m1+1):
        arr1.append(i*C)
else:
    for i in range(n1, m1):
        arr1.append(i*C)
        
if B%D==0:
    for j in range(n2, m2+1):
        arr2.append(j*D)
else:
    for j in range(n2, m2):
        arr2.append(j*D)
    
cnt_c = len(arr1)
cnt_d = len(arr2)
cnt_cd = sum([arr[i]%C==0 for i in range(len(arr))])
cnt = cnt_c+cnt_d-cnt_cd

print(interval-cnt)

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

import math

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def myfunc(x, div1, div2):
    div3 = lcm(div1, div2)
    return x-x//div1-x//div2+x//div3

print(myfunc(B, C, D)-myfunc(A-1, C, D))
Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

if (W==0)or(H==0):
    print(float(0))
    print(1)
else:
    if ((y*W-x*H)/W==float(0))or((y*W+x*H)/W==float(H)):
        print(H*W/2)
        print(1)
    else:
        print(H*W/2)
        print(0)

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

if X<A:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
List = list(map(int, input().split()))

i = 0
s = 0
while s<=X:
    s += List[i]
    i+=1
    
print(i)

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

s = 0
pS = []
for i in range(N):
    s += List[i]
    pS.append(s)
    
pS = [0]+pS

if pS[-1]<=X:
    print(len(pS))
    
else:
    for j in range(N):
        if (pS[j]<=X)&(X<pS[j+1]):
            print(j+1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
List = [list(map(int, input().split())) for _ in range(N)]

import itertools
import collections

arr = list(itertools.combinations(List, 2))
vec = []

for i in range(len(arr)):
    vec.append([arr[i][1][0]-arr[i][0][0], arr[i][1][1]-arr[i][0][1]])

counter = collections.Counter(map(tuple, vec))
num = counter.most_common(1)[0][1]

print(N-num)

Fixed submission:
N = int(input())
List = [list(map(int, input().split())) for _ in range(N)]

import itertools
import collections

if N==1:
    print(1)
    
else:
    arr = list(itertools.combinations(List, 2))
    vec1 = []
    vec2 = []
    for i in range(len(arr)):
        vec1.append([arr[i][1][0]-arr[i][0][0], arr[i][1][1]-arr[i][0][1]])
        vec2.append([arr[i][0][0]-arr[i][1][0], arr[i][0][1]-arr[i][1][1]])
        
    vec = vec1+vec2
    counter = collections.Counter(map(tuple, vec))
    
    v =  counter.most_common(1)[0][0]
    num = counter.most_common(1)[0][1]
    
    print(N-num)

Buggy python submission (verdict: Runtime Error):
N = int(input())
List = [list(map(int, input().split())) for _ in range(N)]

import itertools

arr = list(itertools.combinations(List, 2))
vec = []

for i in range(len(arr)):
    vec.append([arr[i][1][0]-arr[i][0][0], arr[i][1][1]-arr[i][0][1]])

counter = collections.Counter(map(tuple, vec))
num = counter.most_common(1)[0][1]

print(N-num)

Fixed submission:
N = int(input())
List = [list(map(int, input().split())) for _ in range(N)]

import itertools
import collections

if N==1:
    print(1)
    
else:
    arr = list(itertools.combinations(List, 2))
    vec1 = []
    vec2 = []
    for i in range(len(arr)):
        vec1.append([arr[i][1][0]-arr[i][0][0], arr[i][1][1]-arr[i][0][1]])
        vec2.append([arr[i][0][0]-arr[i][1][0], arr[i][0][1]-arr[i][1][1]])
        
    vec = vec1+vec2
    counter = collections.Counter(map(tuple, vec))
    
    v =  counter.most_common(1)[0][0]
    num = counter.most_common(1)[0][1]
    
    print(N-num)

Buggy python submission (verdict: Runtime Error):
N = int(input())
List = [list(map(int, input().split())) for _ in range(N)]

import itertools
import collections

arr = list(itertools.combinations(List, 2))
vec = []

for i in range(len(arr)):
    vec.append([arr[i][1][0]-arr[i][0][0], arr[i][1][1]-arr[i][0][1]])

counter = collections.Counter(map(tuple, vec))
num = counter.most_common(1)[0][1]

print(N-num)

Fixed submission:
N = int(input())
List = [list(map(int, input().split())) for _ in range(N)]

import itertools
import collections

if N==1:
    print(1)
    
else:
    arr = list(itertools.combinations(List, 2))
    vec1 = []
    vec2 = []
    for i in range(len(arr)):
        vec1.append([arr[i][1][0]-arr[i][0][0], arr[i][1][1]-arr[i][0][1]])
        vec2.append([arr[i][0][0]-arr[i][1][0], arr[i][0][1]-arr[i][1][1]])
        
    vec = vec1+vec2
    counter = collections.Counter(map(tuple, vec))
    
    v =  counter.most_common(1)[0][0]
    num = counter.most_common(1)[0][1]
    
    print(N-num)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(M)]

ones = [1]*N

for i in range(M):
    ones[List[i][1]:]=[0]*(N-List[i][1])
    ones[:List[i][0]-1]=[0]*(List[i][0]-1)
    
print(sum(ones))

Fixed submission:
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N
for i in range(M):
    if left<List[i][0]:
        left = List[i][0]
    if List[i][1]<right:
        right = List[i][1]

if right<left:
    print(0)
else:
    print(right-left+1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
List = [list(map(int, input().split())) for _ in range(M)]
 
cnt = 0
for i in range(M):
    A+=[List[i][1]]*List[i][0]
    cnt+=List[i][0]
 
 
print(sum(sorted(A)[cnt:]))

Fixed submission:
from heapq import heappop, heappush, heapify

N, M = map(int, input().split())
A = list(map(int, input().split()))
List = [list(map(int, input().split())) for _ in range(M)]

List = sorted(List, reverse=True, key=lambda x: x[1])

heapify(A)

i = 0
while i<M:
    m = heappop(A)
    heappush(A, m)
    tmp = List[i][1]
    cnt = List[i][0]
    while (0<cnt) and (m<tmp):
            m = heappop(A)
            heappush(A, tmp)
            tmp = List[i][1]
            cnt-=1
    i+=1

print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop, heappush, heapify

N, M = map(int, input().split())
A = list(map(int, input().split()))
List = [list(map(int, input().split())) for _ in range(M)]

List = sorted(List, reverse=True, key=lambda x: x[1])

heapify(A)

i = 0
while i<M:
    m = min(A)
    tmp = List[i][1]
    cnt = List[i][0]
    while (0<cnt) and (m<tmp):
            m = heappop(A)
            heappush(A, tmp)
            tmp = List[i][1]
            cnt-=1
    i+=1

print(sum(A))

Fixed submission:
from heapq import heappop, heappush, heapify

N, M = map(int, input().split())
A = list(map(int, input().split()))
List = [list(map(int, input().split())) for _ in range(M)]

List = sorted(List, reverse=True, key=lambda x: x[1])

heapify(A)

i = 0
while i<M:
    m = heappop(A)
    heappush(A, m)
    tmp = List[i][1]
    cnt = List[i][0]
    while (0<cnt) and (m<tmp):
            m = heappop(A)
            heappush(A, tmp)
            tmp = List[i][1]
            cnt-=1
    i+=1

print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
List = [list(map(int, input().split())) for _ in range(M)]

cnt = 0
for i in range(M):
    A+=[List[i][1]]*List[i][0]
    cnt+=List[i][0]


print(sum(sorted(A)[cnt:]))

Fixed submission:
from heapq import heappop, heappush, heapify

N, M = map(int, input().split())
A = list(map(int, input().split()))
List = [list(map(int, input().split())) for _ in range(M)]

List = sorted(List, reverse=True, key=lambda x: x[1])

heapify(A)

i = 0
while i<M:
    m = heappop(A)
    heappush(A, m)
    tmp = List[i][1]
    cnt = List[i][0]
    while (0<cnt) and (m<tmp):
            m = heappop(A)
            heappush(A, tmp)
            tmp = List[i][1]
            cnt-=1
    i+=1

print(sum(A))
Buggy python submission (verdict: Runtime Error):
N = int(input())

import math

kmax1 = (N+1/4)**(1/2)-1/2


kmax = min(kmax1, kmax2)

acc = 0
for k in range(1, int(kmax+1)):
    if((N-k)%k==0&N>k):
        acc+=(N-k)/k
print(int(acc))

Fixed submission:
N = int(input())

kmax = (N+1/4)**(1/2)-1/2

acc = 0
for k in range(1, int(kmax+1)):
    m = (N-k)//k
    if(((N-k)%k==0)&(k<m)):
        acc+=m
print(int(acc))

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

kmax = math.floor((-1+math.sqrt(1+4*N))/2)
acc = 0
for k in range(1, kmax+1):
    if((N-k)%k==0):
        acc+=(N-k)/k
print(int(acc))

Fixed submission:
N = int(input())

kmax = (N+1/4)**(1/2)-1/2

acc = 0
for k in range(1, int(kmax+1)):
    m = (N-k)//k
    if(((N-k)%k==0)&(k<m)):
        acc+=m
print(int(acc))
Buggy python submission (verdict: Runtime Error):
List = [input() for _ in range(5)]

import math

unitsPlace = []
for i in range(5):
    if int(List[i][-1])!=0:
        unitsPlace.append(int(List[i][-1]))

minUnitsPlace = min(unitsPlace)

ceilList = [math.ceil(int(List[j])/10)*10 for j in range(5)]

res = sum(ceilList) + minUnitsPlace - 10

print(res)

Fixed submission:
List = [input() for _ in range(5)]

import math

unitsPlace = []
for i in range(5):
    if int(List[i][-1])!=0:
        unitsPlace.append(int(List[i][-1]))

if unitsPlace==[]:
    res = sum([int(List[i]) for i in range(5)])
    print(res)
else:
    minUnitsPlace = min(unitsPlace)
    
    ceilList = [math.ceil(int(List[j])/10)*10 for j in range(5)]
    res = sum(ceilList) + minUnitsPlace - 10
    
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
List = [list(map(int, input().split())) for _ in range(Q)]

for i in range(Q):
    w = S[List[i][0]-1:List[i][1]]
    cnt = w.count("AC")
    print(cnt)

Fixed submission:
from itertools import accumulate

N, Q = map(int, input().split())
S = input()
List = [list(map(int, input().split())) for _ in range(Q)]

flg = []
for i in range(N-1):
    tmp_S = S[i:i+2]
    if tmp_S == "AC":
        flg.append(1)
    else:
        flg.append(0)

flg_2 = [0]+flg
flg_2 = list(accumulate(flg_2))

for j in range(Q):
    print(flg_2[List[j][1]-1]-flg_2[List[j][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
List = [list(map(int, input().split())) for _ in range(Q)]

for i in range(Q):
    w = S[List[i][0]-1:List[i][1]]
    cnt = w.count("AC")
    print(cnt)

Fixed submission:
from itertools import accumulate

N, Q = map(int, input().split())
S = input()
List = [list(map(int, input().split())) for _ in range(Q)]

flg = []
for i in range(N-1):
    tmp_S = S[i:i+2]
    if tmp_S == "AC":
        flg.append(1)
    else:
        flg.append(0)

flg_2 = [0]+flg
flg_2 = list(accumulate(flg_2))

for j in range(Q):
    print(flg_2[List[j][1]-1]-flg_2[List[j][0]-1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(N)]

List.sort(key=lambda x:x[0])

amt = 0
money = 0
i=0
while amt<=M:
    money+=List[i][0]*List[i][1]
    amt+=List[i][1]
    i+=1
    
ans = money-(amt-M)*List[i-1][0]
print(ans)

Fixed submission:
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(N)]

List.sort(key=lambda x:x[0])

amt = 0
money = 0
i=0
while amt<M:
    money+=List[i][0]*List[i][1]
    amt+=List[i][1]
    i+=1

ans = money-(amt-M)*List[i-1][0]
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
H = np.array(input().split(), dtype=np.int32)

def myfunc(left, right):
    if right<left:
        return 0
    idx = left+H[left:right+1].argmin()
    m = H[idx]
    H[left:right+1]-=m
    return m+myfunc(left, idx-1)+myfunc(right, idx+1)

print(myfunc(0, N-1))

Fixed submission:
import numpy as np

N = int(input())
H = np.array(input().split(), dtype=np.int32)

def myfunc(left, right):
    if right<left:
        return 0
    idx = left+H[left:right+1].argmin()
    m = H[idx]
    H[left:right+1]-=m
    return m+myfunc(left, idx-1)+myfunc(idx+1, right)

print(myfunc(0, N-1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = np.array(input().split(), dtype=np.int32)

def myfunc(left, right):
    if right<left:
        return 0
    idx = left+H[left:right+1].argmin()
    m = H[idx]
    H[left:right+1]-=m
    return m+myfunc(left, idx-1)+myfunc(right, idx+1)

print(myfunc(0, N-1))

Fixed submission:
import numpy as np

N = int(input())
H = np.array(input().split(), dtype=np.int32)

def myfunc(left, right):
    if right<left:
        return 0
    idx = left+H[left:right+1].argmin()
    m = H[idx]
    H[left:right+1]-=m
    return m+myfunc(left, idx-1)+myfunc(idx+1, right)

print(myfunc(0, N-1))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
List = [int(input()) for _ in range(N)]

List = sorted(List)

tmp = 10**9
for i in range(N-K+1):
    lst = List[i:i+K]
    diff = max(lst)-min(lst)
    if diff<tmp:
        tmp = diff
print(tmp)

Fixed submission:
N, K = map(int, input().split())
List = [int(input()) for _ in range(N)]

List = sorted(List)

tmp = 10**9
for i in range(N-K+1):
    diff = List[i+K-1]-List[i]
    if diff<tmp:
        tmp = diff
print(tmp)