Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split(" "))


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2)
    
    L.append(H[k]-H[k+K])

print(min(L))


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


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2,k+K)
    
    L.append(H[k]-H[k+K-1])

print(min(L))

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


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2)
    
    L.append(H[k]-H[k+2])

print(min(L))


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


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2,k+K)
    
    L.append(H[k]-H[k+K-1])

print(min(L))
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())

for i in range(X+1):
    if Y == (2 * i + 4 * (X - T)):
        print('Yes')
        exit()
else:
    print('No')

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

for i in range(X+1):
    if Y == (2 * i + 4 * (X - i)):
        print('Yes')
        exit()
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
p = list(map(int,input().split()))
for i in range(101):
    if X - i not in p:
        print(x - i)
        exit()
    elif X + i not in p:
        print(x + i)
        exit()

Fixed submission:
X,N = map(int,input().split())
p = list(map(int,input().split()))
for i in range(101):
    if X - i not in p:
        print(X - i)
        exit()
    elif X + i not in p:
        print(X + i)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
T = input()
ans = ''
for t in T:
    if t == '?':
        ans += 'D'
    else:
        ans += t
print(ans) 

Fixed submission:
T = input()

for t in T:
    if t == '?':
        print('D', end='')
    else:
        print(t, end='')
Buggy python submission (verdict: Runtime Error):
from math import cos, radians, sqrt

A, B, H, M = list(map(int,input().split))

m = H * 60 + M
h = 360.0 / 60.0 * (m % 60)
mi = 360.0 / 720.0 * (m % 720)
arg = abs(h - mi)

print(sqrt(A**2 + B**2 - 2.0 * A * B * cos(radians(arg))))

Fixed submission:
from math import cos, radians, sqrt

A, B, H, M = list(map(int,input().split()))

m = H * 60 + M
h = 360.0 / 60.0 * (m % 60)
mi = 360.0 / 720.0 * (m % 720)
arg = abs(h - mi)

print(sqrt(A**2 + B**2 - 2.0 * A * B * cos(radians(arg))))
Buggy python submission (verdict: Runtime Error):
A,B,X = map(int,input().split())
print(min(B-1,N))

Fixed submission:
A,B,N = map(int,input().split())
x = min(B-1,N)
ans = int(A*x/B) - A*int(x/B)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    print(A.count(i))

Fixed submission:
import collections
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    A.append(i)
ans = collections.Counter(A)
tmp = sorted(ans.items())
for i in range(N):
    print(tmp[i][1]-1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(1,N+1):
    print(A.count(i))

Fixed submission:
import collections
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    A.append(i)
ans = collections.Counter(A)
tmp = sorted(ans.items())
for i in range(N):
    print(tmp[i][1]-1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())      
ans = 0           
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += math.gcd(math.gcd(a,b),math.gcd(b,c))
print(ans)

Fixed submission:
import math
K = int(input())      
ans = 0           
for a in range(1,K+1):
    for b in range(1,K+1):
        g = math.gcd(a,b)
        for c in range(1,K+1):
            ans += math.gcd(g,c)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
K = int(input())      
ans = 0           
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += math.gcd(a,b,c)
print(ans)

Fixed submission:
import math
K = int(input())      
ans = 0           
for a in range(1,K+1):
    for b in range(1,K+1):
        g = math.gcd(a,b)
        for c in range(1,K+1):
            ans += math.gcd(g,c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())

if K == 1:
    print(0)
    exit()
else:
    for i in range(100000000):
        k = abs(N-K)
        if k < N:
            N = k                
print(N)

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

if K == 1:
    print(0)
    exit()
elif N == 0:
    print(0)
    exit()    
else:
    a = N-K*(N//K)
    b =abs(N-K*(N//K +1))
    print(min(a,b))
Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
ans = 0
p.sort()
q.sort()
r.sort()
for i in range(X):
    if p[-1] >= r[-1]:
        ans += p[-1]
        del p[-1:]
        
    elif r[-1] > p[-1] >= q[-1]:
        
        ans += p[-1]
        del p[-1:]
    else:
        ans += r[-1]
        del r[-1:]    
         
for i in range(Y):
    if q[-1] >= r[-1]:
        ans += q[-1]
        del q[-1:]
        
    else:
        ans += r[-1]
        del r[-1:]
                   

print(ans)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ans = p[:X]+q[:Y]+r[:X+Y]
ans.sort(reverse=True)
su = sum(ans[:X+Y])

print(su)

Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
ans = 0
p.sort()
q.sort()
r.sort()
for i in range(X):
    if p[-1] >= r[-1]:
        ans += p[-1]
        del p[-1:]
        
    else:
        ans += r[-1]
        del r[-1:]
         
for i in range(Y):
    if q[-1] >= r[-1]:
        ans += q[-1]
        del q[-1:]
        
    else:
        ans += r[-1]
        del r[-1:]
                   

print(ans)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ans = p[:X]+q[:Y]+r[:X+Y]
ans.sort(reverse=True)
su = sum(ans[:X+Y])

print(su)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
from math import factorial

if N<= 1 and M <=1:
    print(0)

elif N >= 2 and M == 1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N == 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))

Fixed submission:
N,M = map(int,input().split())
from math import factorial

if N<= 1 and M <=1:
    print(0)

elif N >= 2 and M <=1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N <= 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
from math import factorial

if N==1 and M ==1:
    print(0)

elif N >= 2 and M == 1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N == 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))

Fixed submission:
N,M = map(int,input().split())
from math import factorial

if N<= 1 and M <=1:
    print(0)

elif N >= 2 and M <=1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N <= 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))
Buggy python submission (verdict: Runtime Error):
import collections
from math import factorial
N = int(input())
A = list(map(int,input().split()))
ans = 0
aa = collections.Counter(A)
for i in range(N):
    for k,v in aa.items():
        if k == A[i]:
            if v >= 3:
                num = factorial(v-1) / factorial(2) / factorial(v - 3)
                ans += num
        else:
            if v >= 2:
                num = factorial(v) / factorial(2) / factorial(v - 2)
                ans += num
    print(int(ans))
    ans = 0

Fixed submission:
from itertools import groupby
import copy

def equalfind(A):
    A.sort()
    s=1
    count=0
    if len(A)==1:
        return count
    else:
        for i in range(0,len(A)-1):
            if A[i]==A[i+1]:
                s+=1
            else:
                count+=s*(s-1)//2
                s=1
        return count+s*(s-1)//2


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

B=copy.copy(A)
s=equalfind(B)
data=groupby(B)
ans=[0 for i in range(0,N+1)]
for key,group in data:
    g=len(list(group))
    ans[key]=g

for i in range(0,N):
    minus=ans[A[i]]-1
    print(s-minus)

Buggy python submission (verdict: Runtime Error):
import collections
from math import factorial
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
    x = A[i]
    del A[i]
    aa = collections.Counter(A)
    A.insert(i,x)
    for v in aa.values():
        if v >= 2:
            num = factorial(v) / factorial(2) / factorial(v - 2)
            ans += num
    print(int(ans))
    ans = 0

Fixed submission:
from itertools import groupby
import copy

def equalfind(A):
    A.sort()
    s=1
    count=0
    if len(A)==1:
        return count
    else:
        for i in range(0,len(A)-1):
            if A[i]==A[i+1]:
                s+=1
            else:
                count+=s*(s-1)//2
                s=1
        return count+s*(s-1)//2


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

B=copy.copy(A)
s=equalfind(B)
data=groupby(B)
ans=[0 for i in range(0,N+1)]
for key,group in data:
    g=len(list(group))
    ans[key]=g

for i in range(0,N):
    minus=ans[A[i]]-1
    print(s-minus)

Buggy python submission (verdict: Runtime Error):
import collections
from math import factorial
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
    x = A[i]
    del A[i]
    aa = collections.Counter(A)
    A.insert(i,x)
    for v in aa.values():
        if v >= 2:
            num = factorial(v) / factorial(2) / factorial(v - 2)
            ans += num
    print(int(ans))
    ans = 0

Fixed submission:
from itertools import groupby
import copy

def equalfind(A):
    A.sort()
    s=1
    count=0
    if len(A)==1:
        return count
    else:
        for i in range(0,len(A)-1):
            if A[i]==A[i+1]:
                s+=1
            else:
                count+=s*(s-1)//2
                s=1
        return count+s*(s-1)//2


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

B=copy.copy(A)
s=equalfind(B)
data=groupby(B)
ans=[0 for i in range(0,N+1)]
for key,group in data:
    g=len(list(group))
    ans[key]=g

for i in range(0,N):
    minus=ans[A[i]]-1
    print(s-minus)
Buggy python submission (verdict: Runtime Error):
import math
H,W = map(int,input().split())
if H%2==0 and W%2== 0:
  print((H*W)/2)
elif H%2 == 1 and W%2==1:
  print(H*math.floor(W/2)+math.ceil(H/2))
elif H%2 == 1 and W%2==0:
  print(H*math.floor(W/2))
else:
print(W*math.floor(H/2))

Fixed submission:
import math
from decimal import Decimal
H,W = map(int,input().split())
if H==1 or W == 1:
  print(1)
elif H%2==0 and W%2== 0:
  print(Decimal((H*W)/2))
elif H%2 == 1 and W%2==1:
  print(Decimal(H*math.floor(W/2)+math.ceil(H/2)))
elif H%2 == 1 and W%2==0:
  print(Decimal(H*math.floor(W/2)))
else:
  print(Decimal(W*math.floor(H/2)))
Buggy python submission (verdict: Runtime Error):
N,R = map(int,input().split())
if N <= 10:
    print(R)
else:
    print(R + 1000 -10*K)

Fixed submission:
N,R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(R + 1000 -100*N)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0:
            continue
        elif A[i] % 5 == 0:
            continue
        else:
            print('DENIED')
            sys.exit()
print('APPROVED')

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

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0:
            continue
        elif A[i] % 5 == 0:
            continue
        else:
            print('DENIED')
            sys.exit()
print('APPROVED')
Buggy python submission (verdict: Time Limit Exceeded):
N ,K = map(int,input().split())
P = list(map(int,input().split()))
ex = []
ans = 0
for i in range(N-K+1):
    ans = (sum(P[i:i+K])+K)/2
    ex.append(ans)
    ans = 0
print(max(ex))

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
for i in range(N):
  P[i]=(P[i]+1)/2
point=sum(P[:K])
tmp=point
for i in range(N-K):
  tmp=tmp-P[i]+P[i+K]
  if tmp>point:point=tmp
  
print(point)

Buggy python submission (verdict: Time Limit Exceeded):
N ,K = map(int,input().split())
P = list(map(int,input().split()))
ex = []
ans = 0
for i in range(N-K+1):
    for j in range(K):
        ans += (P[i+j]+1)/2
    ex.append(ans)
    ans = 0
print(max(ex))

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
for i in range(N):
  P[i]=(P[i]+1)/2
point=sum(P[:K])
tmp=point
for i in range(N-K):
  tmp=tmp-P[i]+P[i+K]
  if tmp>point:point=tmp
  
print(point)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
p = list(map(int,input().split()))
num = 0
ans = 0
for i in range(N-K+1):
    for j in range(K):
        ans += p[i+j]
    ans += K
    ans /= 2
    
    if num < ans:
        num = ans
    ans = 0    
print(num)

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
for i in range(N):
  P[i]=(P[i]+1)/2
point=sum(P[:K])
tmp=point
for i in range(N-K):
  tmp=tmp-P[i]+P[i+K]
  if tmp>point:point=tmp
  
print(point)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
p = list(map(int,input().split()))
num = 0
ans = 0
for i in range(N-K+1):
    for j in range(K):
        ans += p[i+j]
    ans += K
    ans /= 2
    
    if num < ans:
        num = ans
    ans = 0    
print(num)

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
for i in range(N):
  P[i]=(P[i]+1)/2
point=sum(P[:K])
tmp=point
for i in range(N-K):
  tmp=tmp-P[i]+P[i+K]
  if tmp>point:point=tmp
  
print(point)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
for i in range(K):
  if A >= 1:
    A -= 1
  elif B >= 1:
    B -= 1
print(A,B)

Fixed submission:
A,B,K = map(int,input().split())
if A >= K:
  print(A-K,B)
elif B + A - K >= 0:
  print(0,B+A-K)
else:
  print(0,0)
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int,input().split())
A = [int(input())for i in range(Q)]
for i in range(1,N+1):
  x=A.count(i)
  if K-Q+x>=1:
    print('Yes')
  else:
    print('No')

Fixed submission:
from collections import Counter
N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q)]
count = Counter(A)
f_p = [K-Q]*N
for k,v in count.items():
  f_p[k-1] += v
  
for ans in f_p:
  if ans >= 1:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a = int(ipnut())
s = str(input())
if a >= 3200:
    print(s)
else:
    print('red')

Fixed submission:
a = int(input())
s = str(input())
if a >= 3200:
    print(s)
else:
    print('red')
Buggy python submission (verdict: Runtime Error):
K,X = map(int,input().split())
mi = X-K+1
Ma = X+K-1
for i in range(mi,Ma+1):
    A.append(i)
print(*ans)

Fixed submission:
K,X = map(int,input().split())
mi = X-K+1
Ma = X+K-1
A = []
for i in range(mi,Ma+1):
    A.append(i)
print(*A)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i not in A:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))

Fixed submission:
N,M = map(int,input().split())
A = set(int(input()) for _ in range(M))
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i not in A:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))

Fixed submission:
N,M = map(int,input().split())
A = set(int(input()) for _ in range(M))
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))


Fixed submission:
N,M = map(int,input().split())
A = set(int(input()) for _ in range(M))
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))

Fixed submission:
N,M = map(int,input().split())
A = set(int(input()) for _ in range(M))
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
#全ノードを取り敢えずinfにしておく
dp[0] = 0
for i in range(N-1):
    #足場を一個飛んだ時
    dp[i+1] = min(dp[i+1],dp[i] + abs(H[i+1] - H[i]))
    #足場をK個飛んだ時(2~K)
    for j in range(2,min(K+1,N-i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(H[i+j]- H[i]))
print(dp[N-1])

Fixed submission:
N,K = map(int,input().split())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
#全ノードを取り敢えずinfにしておく
dp[0] = 0
for i in range(N-1):
    #足場を一個飛んだ時
    dp[i+1] = min(dp[i+1],dp[i] + abs(H[i+1] - H[i]))
    #足場をK個飛んだ時(2~K)
    for j in range(2,min(K+1,N-i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(H[i+j]- H[i]))
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
num = 4**9
ans = 0
for i in range(num):
    a = 0
    b = 0
    c = 0
    d = 0
    s = i
    for j in range(9):
        a += 0 * int(s % 4 == 0) * 10 ** j
        b += 3 * int(s % 4 == 1) * 10 ** j
        c += 5 * int(s % 4 == 2) * 10 ** j
        d += 7 * int(s % 4 == 3) * 10 ** j
        s = s // 4
    tmp = a + b + c + d
    if tmp > n:
        break
    tmp = str(tmp)
    if b > 0 and c > 0 and d > 0 and tmp.count('0') == 0:
        ans += 1
print(ans)

Fixed submission:
import itertools
n = int(input())
num = 4**9
ans = 0
for i in range(num):
    a = 0
    b = 0
    c = 0
    d = 0
    s = i
    for j in range(9):
        a += 0 * int(s % 4 == 0) * 10 ** j
        b += 3 * int(s % 4 == 1) * 10 ** j
        c += 5 * int(s % 4 == 2) * 10 ** j
        d += 7 * int(s % 4 == 3) * 10 ** j
        s = s // 4
    tmp = a + b + c + d
    if tmp > n:
        break
    tmp = str(tmp)
    if b > 0 and c > 0 and d > 0 and tmp.count('0') == 0:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans =[0]*N
tmp = 0
ans[0] = N-1-S.count('E')
ans[-1] = N-S.count('W')
for i in range(1,N-1):
    A = S[:i]
    B = S[i+1:]
    tmp = (i-A.count('E'))+(N-(i+1)-B.count('W'))
    ans[i] = tmp
    tmp = 0
print(min(ans))

Fixed submission:
n = int(input())
s = input()
lstW = [0]
c = 0
#累積和
for i in range(1,len(s)):
    if s[i-1] == "W":
        c += 1
    lstW.append(c)
    
lstE = [0]
c = 0
for i in range(len(s)-2,-1,-1):
    if s[i+1] == "E":
        c += 1 
    lstE.append(c)
lst = []
for i in range(len(lstW)):
    lst.append(lstW[i] + lstE[n-i-1])
lst.sort()
print(lst[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans =[0]*N
tmp = 0
ans[0] = N-1-S.count('E')
ans[-1] = N-S.count('W')
for i in range(1,N-1):
    A = S[:i]
    B = S[i+1:]
    tmp = (i-A.count('E'))+(N-(i+1)-B.count('W'))
    ans[i] = tmp
    tmp = 0
print(min(ans))

Fixed submission:
n = int(input())
s = input()
lstW = [0]
c = 0
#累積和
for i in range(1,len(s)):
    if s[i-1] == "W":
        c += 1
    lstW.append(c)
    
lstE = [0]
c = 0
for i in range(len(s)-2,-1,-1):
    if s[i+1] == "E":
        c += 1 
    lstE.append(c)
lst = []
for i in range(len(lstW)):
    lst.append(lstW[i] + lstE[n-i-1])
lst.sort()
print(lst[0])
Buggy python submission (verdict: Runtime Error):
#累積和　AGC023
from collections import Counter
from math import factorial
def nC2(n):
    if n >= 2:
        return  factorial(n) / factorial(2) / factorial(n - 2) 
    else:
        return 0    
N = int(input())
A = list(map(int,input().split()))
B = [0]
ans = 0
for i in range(N):
    B.append(A[i] + B[i])
C = Counter(B)
for v in C.values():
    ans += nC2(v)
print(int(ans)) 

Fixed submission:
#累積和　AGC023
from collections import Counter
from math import factorial
def nC2(n):
    if n >= 2:
        return factorial(n) // (factorial(n-2)*factorial(2))
    else:
        return 0
N = int(input())
A = list(map(int,input().split()))
B = [0]
ans = 0
for i in range(N):
    B.append(A[i] + B[i])
C =Counter(B)

for v in C.values():
    ans += nC2(v)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,Y = map(int,input().split())
ans = '-1 -1 -1'
for i in range(2001):
    for j in range(2001):
        for k in range(2001):
            if 10000*i + 5000*j + 1000*k == Y and i+j+k == N:
                ans = str(i) + ' '+str(j) + ' '+ str(k)
                print(ans)
                sys.exit()
print(ans)

Fixed submission:
import sys
N,Y = map(int,input().split())
ans = '-1 -1 -1'

for i in range(2001):
    for j in range(2001):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y :
            if N-i-j >= 0:
                print(str(i) + ' '+str(j) + ' '+ str(N-i-j))
                sys.exit()
print(ans)

Buggy python submission (verdict: Runtime Error):
N,Y = map(int,input().split())
ans = '-1 -1 -1'
for i in range(2001):
    for j in range(2001):
        for k in range(2001):
            if 10000*i + 5000*j + 1000*k == Y and i+j+k == N:
                ans = str(i) + ' '+str(j) + ' '+ str(k)
                print(ans)
                sys.exit()
print(ans)

Fixed submission:
import sys
N,Y = map(int,input().split())
ans = '-1 -1 -1'

for i in range(2001):
    for j in range(2001):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y :
            if N-i-j >= 0:
                print(str(i) + ' '+str(j) + ' '+ str(N-i-j))
                sys.exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
print(min(N*A,B)

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