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

import numpy as np
W = np.zeros((N, N))
for i in range(N-1):
    W[i, i] = 0.5
    W[i, i+1] = 0.5
W[N-1, N-1] = 0.5
W[N-1, 0] = 0.5

A = np.array(A)

x = (np.linalg.inv(W).dot(A)+0.1).astype(int)

for xx in x[:-1]:
    print(xx, end=' ')
print(x[-1])


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

x = [None] * N
x[0] = 0
for i in range(2, N, 2):
    x[i] = x[i-2] + (A[i-1] - A[i-2]) * 2
x[1] = x[-1] + (A[0] - A[-1]) * 2
for i in range(3, N-1, 2):
    x[i] = x[i-2] + (A[i-1] - A[i-2]) * 2

import numpy as np
ma = np.mean(A)
mx = np.mean(x)
x = (np.array(x) + ma - mx + 0.1).astype(int)
for i in range(N-1):
    print(x[i], end=" ")
print(x[-1])

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

import numpy as np
W = np.zeros((N, N))
for i in range(N-1):
    W[i, i] = 0.5
    W[i, i+1] = 0.5
W[N-1, N-1] = 0.5
W[N-1, 0] = 0.5

A = np.array(A)

x = np.linalg.inv(W).dot(A).astype(int)

for xx in x[:-1]:
    print(xx, end=' ')
print(x[-1])


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

x = [None] * N
x[0] = 0
for i in range(2, N, 2):
    x[i] = x[i-2] + (A[i-1] - A[i-2]) * 2
x[1] = x[-1] + (A[0] - A[-1]) * 2
for i in range(3, N-1, 2):
    x[i] = x[i-2] + (A[i-1] - A[i-2]) * 2

import numpy as np
ma = np.mean(A)
mx = np.mean(x)
x = (np.array(x) + ma - mx + 0.1).astype(int)
for i in range(N-1):
    print(x[i], end=" ")
print(x[-1])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

# 赤いボールの数
R = N - K

import itertools
import math
def comb(n, k):
    return math.factorial(n)//math.factorial(n-k)//math.factorial(k)



for i in range(1, K+1):
    a = comb(K-1, i-1)
    b = comb(R+1, i)
    print(a * b % 1000000007)


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

# 赤いボールの数
R = N - K

import itertools
import math
def comb(n, k):
    if n-k < 0:
        return 0
    return math.factorial(n)//math.factorial(n-k)//math.factorial(k)



for i in range(1, K+1):
    a = comb(K-1, i-1)
    b = comb(R+1, i)
    print(a * b % 1000000007)
Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())

dp_f = [None] * 10**5
def f(n):
    if n == 1:
        return 1
    elif n == 2:
        return 1
    elif dp_f[n] is not None:
        return dp_f[n]
    v = f(n-1) + f(n-2)
    dp_f[n] = v
    return dp_f[n]

if M == 0:
    print(f(N))
    sys.exit(0)

A = [int(input()) for i in range(M)]

S = []
S.append(A[0])
for i in range(1, M):
    if A[i] == A[i-1] + 1:
        print(0)
        sys.exit(0)
    S.append(A[i] - A[i-1] - 1)
S.append(N - A[-1])

m = 1
for s in S:
    m *= f(s)
    m %= 1000000007

print(m)

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

dp_f = [None] * (10**5 + 2)
dp_f[1] = 1
dp_f[2] = 1
for i in range(3, 10**5 + 1):
    dp_f[i] = dp_f[i-1] + dp_f[i-2]
def f(n):
    if n == 1:
        return 1
    elif n == 2:
        return 1
    elif dp_f[n] is not None:
        return dp_f[n]
    v = f(n-1) + f(n-2)
    dp_f[n] = v
    return dp_f[n]

if M == 0:
    m = f(N+1)
    m %= 1000000007
    print(m)
    sys.exit(0)

A = [int(input()) for i in range(M)]

S = []
S.append(A[0])
for i in range(1, M):
    if A[i] == A[i-1] + 1:
        print(0)
        sys.exit(0)
    S.append(A[i] - A[i-1] - 1)
S.append(N - A[-1])

m = 1
for s in S:
    m *= f(s)
    m %= 1000000007

print(m)
Buggy python submission (verdict: Time Limit Exceeded):
'''
Sを連続する値の数のリストに変換
(ただし、左右端は必ず1が0個以上存在するとする)
S='0111010011' -> A=[0,1,3,1,1,2,2]

K=1なら、
sum(A[0:3]), sum(A[2:5]), sum(A[4:7])のmaxが答え
'''

N, K = map(int, input().split())
S = input()

# Sを0,1の区切りで分解したときのそれぞれの長さ
A = []
cur = S[0]
c = 0
for s in S[1:] + '*':
    c += 1
    if cur != s:
        cur = s
        A.append(c)
        c = 0

# 先頭、末尾が"0"のときは0を追加
if S[0] == '0':
    A = [0] + A
if S[-1] == '0':
    A = A + [0]

# Aの偶数番号インデックス(0始まり)から計算される
# 2K+1個の連続する要素の和の最大値が求める値
if len(A) <= 2 * K + 1:
    print(sum(A))
else:
    m = 0
    i = 0
    while i + 2*K+1 <= len(A):
        m = max(m, sum(A[i: i+2*K+1]))
        i += 2
    print(m)


Fixed submission:
'''
Sを連続する値の数のリストに変換
(ただし、左右端は必ず1が0個以上存在するとする)
S='0111010011' -> A=[0,1,3,1,1,2,2]

K=1なら、
sum(A[0:3]), sum(A[2:5]), sum(A[4:7])のmaxが答え
'''

N, K = map(int, input().split())
S = input()

# Sを0,1の区切りで分解したときのそれぞれの長さ
A = []
cur = S[0]
c = 0
for s in S[1:] + '*':
    c += 1
    if cur != s:
        cur = s
        A.append(c)
        c = 0

# 先頭、末尾が"0"のときは0を追加
if S[0] == '0':
    A = [0] + A
if S[-1] == '0':
    A = A + [0]

# Aの累積値を計算
AA = [None] * len(A)
AA[0] = A[0]
for i in range(1, len(A)):
    AA[i] = AA[i-1] + A[i]

# Aの偶数番号インデックス(0始まり)から計算される
# 2K+1個の連続する要素の和の最大値が求める値
if len(A) <= 2 * K + 1:
    print(sum(A))
else:
    m = 0
    i = 0
    while i + 2*K <= len(A):
        # p: sum(A[i: i+2*K+1])
        p = AA[i+2*K] - (AA[i-1] if i > 0 else 0)
        m = max(m, p)
        i += 2
    print(m)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())


_beki = [None] * 50
def ni_beki(n):
    return 2 ** n


# １-nのそれぞれの2進数で下からn桁目(n=0,1,...)の中の1の個数を返す関数
def f(x, n):
     a, b = divmod(x, ni_beki(n+1))
     p = ni_beki(n)
     return a * p + max(b - (p - 1), 0)

# 2進数での桁数を求める
def g(n):
    c = 0
    while True:
        if ni_beki(c) >= n + 1:
            return c
        c += 1

keta = g(B)
# 下から数えていく
d = []
for i in range(keta):
    p = f(B, i)
    q = f(A-1, i)
    d.append(p - q)

# 表示順に
d.reverse()

# 01文字に
e = list(map(lambda x: str(x % 2), d))

# 文字列に
e = ''.join(e)

print(int(e, 2))

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


_beki = [None] * 50
def ni_beki(n):
    return 2 ** n


# １-nのそれぞれの2進数で下からn桁目(n=0,1,...)の中の1の個数を返す関数
def f(x, n):
     a, b = divmod(x, ni_beki(n+1))
     p = ni_beki(n)
     return a * p + max(b - (p - 1), 0)

# 2進数での桁数を求める
def g(n):
    c = 0
    while True:
        if ni_beki(c) >= n + 1:
            return c
        c += 1

keta = g(B)
# 下から数えていく
d = []
for i in range(keta):
    p = f(B, i)
    q = f(A-1, i)
    d.append(p - q)

# 表示順に
d.reverse()

# 01文字に
e = list(map(lambda x: str(x % 2), d))

# 文字列に
e = ''.join(e)

if e == '':
    e = "0"
print(int(e, 2))
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())

aoki_new = (a+d-1)/d
taka_new1 = (c+b-1)/b

if aoki_new >= taka_new1:
	print("Yes") #takahasi is loses because its heath is zero first
else:
	print("No")






Fixed submission:
s,w = map(int,input().split())

if s<w or s==w:
	print("unsafe")
else:
	print("safe")

Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())

aoki_new = (a+d-1)/d
taka_new1 = (a+b-1)/b

if taka_new1 <= aoki_new :
	print("Yes") #takahasi is loses because its heath is zero first
else:
	print("No")






Fixed submission:
s,w = map(int,input().split())

if s<w or s==w:
	print("unsafe")
else:
	print("safe")

Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())

aoki_new = (a+d-1)/d
taka_new1 = (a+b-1)/b

if taka_new1 < aoki_new :
	print("No") #takahasi is loses because its heath is zero first
else:
	print("Yes")






Fixed submission:
s,w = map(int,input().split())

if s<w or s==w:
	print("unsafe")
else:
	print("safe")
Buggy python submission (verdict: Runtime Error):
n,l = map(int,input().split())
str1 = input()
str2 = input()
str3 = input()

blank = []
blank.append(str1)
blank.append(str2)
blank.append(str3)

blank.sort()
new = blank[0]+blank[1]+blank[2]
print(new)



Fixed submission:
n,l = map(int,input().split())
l = []
for i in range(n):
	string = input()
	l.append(string)


l.sort()
blank = ""
for i in range(len(l)):
	blank = blank + l[i]

print(blank)
Buggy python submission (verdict: Runtime Error):
import sympy

n = int(input())

cnt = 0
for i in range(n-1):
    cnt += sympy.divisor_count(i+1)
            
print(cnt)

Fixed submission:


n = int(input())
cnt = 0
for i in range(1,n):
    cnt += int((n-1)/i)
            
print(cnt)

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

n = int(input())

cnt = 0
for i in range(n-1):
    cnt += sympy.divisor_count(i+1)
            
print(cnt)

Fixed submission:


n = int(input())
cnt = 0
for i in range(1,n):
    cnt += int((n-1)/i)
            
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())

cnt = 0
for a in range(n-1):
    for b in range(n-1):
        for c in range(n-1):
            if (a+1) * (b+1) + (c+1) == n :
                cnt += 1
            
print(cnt)

Fixed submission:


n = int(input())
cnt = 0
for i in range(1,n):
    cnt += int((n-1)/i)
            
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

l = list(map(int,input().split()))

k = 1

for i in l:
    k = k*i

if k > 10**18:
    print(-1)
else:
    print(k)

Fixed submission:

n = int(input())

l = list(map(int,input().split()))

k = 1

if 0 in l:
    print(0)
    exit()

for i in l:
    k = k*i
    if k > 10**18 :
        print(-1)
        exit()

if k > 10**18:
    print(-1)
else:
    print(k)
Buggy python submission (verdict: Runtime Error):

room,path = map(int,input().split())
dic = {}
ans_dic = {}
g = [1]
g_m = []

def re(li,i):
    if li[0] == i:
        return li[1]
    else:
        return li[0]

def pile_del(g):
    t = []
    for key,i in dic.items():
        if i[0] in g and  i[1] in g:
            t.append(key)
    for i in t:
        dic.pop(i)
    return 0

def main(ans_dic,dic,k):
    dele = []
    for key,j in dic.items():
        if k in j :
            ans_dic[re(j,k)] = j
            dele.append(key)
            g.append(re(j,k))
            g_m.append(re(j,k))
    for i in dele:
        dic.pop(i)
    pile_del(g_m)

for i in range(path):
    dic[i+1] = list(map(int,input().split()))

for key,i in dic.items():
    if 1 in i :
        if i[0] == 1:
            g.append(re(i,i[0]))
            # g_m.append(re(i,i[0]))
            ans_dic[i[1]] = i
        else:
            g.append(re(i,i[1]))
            # g_m.append(re(i,i[1]))
            ans_dic[i[0]] = i

pile_del(g)

li_c = len(dic)

if li_c != 0:
    for k in g:
        main(ans_dic,dic,k)

while li_c != len(dic) and li_c != 0:
    li_c = len(dic)
    for k in g:
        main(ans_dic,dic,k)



if len(ans_dic) == room-1:
    print("Yes")
    for i in range(room-1):
        print(re(ans_dic[i+2],i+2))
else:
    print("No")
# print(ans_dic)

Fixed submission:
s = str(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]


if int(s[-1]) in hon:
    print("hon")
elif int(s[-1]) in pon:
    print("pon")
else:
    print("bon")

Buggy python submission (verdict: Runtime Error):



a = int(input())
b = int(input())
h = int(input())
m = int(input())
ans = 0

m_r = m/5

h_r = h + m/60

reg = (h_r - m_r)/12*360
ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(reg)))

print(ans)

Fixed submission:
s = str(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]


if int(s[-1]) in hon:
    print("hon")
elif int(s[-1]) in pon:
    print("pon")
else:
    print("bon")
Buggy python submission (verdict: Runtime Error):

import math

a = int(input())
b = int(input())
h = int(input())
m = int(input())
ans = 0

m_r = m/5
# print(m_r)
h_r = h + m/60
# print(h_r)
# print((h_r - m_r)/12*360)
reg = (h_r - m_r)/12*360
ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(reg)))

print(ans)

Fixed submission:
import math
a,b,h,m = map(int,input().split())

ans = 0

m_r = m/5
# print(m_r)
h_r = h + m/60
# print(h_r)
# print((h_r - m_r)/12*360)
reg = (h_r - m_r)/12*360
ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(reg)))

print(ans)
Buggy python submission (verdict: Runtime Error):
# bit全探索問題

N,M,X = map(int,input().split())
items = [list(map(int,input().split())) for _ in range(N)]
ans = -1
for i in range(1 << N):
    total = [0]*(M+1)
    for j in range(N):  
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            h = [x + y for (x, y) in zip(total, items[j])]
    # print(total)
    if all( k >= X for k in h[1:]) == True:
        if ans == -1:
            ans = h[0]
        else:
            ans = min(ans,total[0]) 
print(ans)



Fixed submission:
# bit全探索問題

N,M,X = map(int,input().split())
items = [list(map(int,input().split())) for _ in range(N)]
ans = -1
for i in range(1 << N):
    total = [0]*(M+1)
    for j in range(N):  
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            total = [x + y for (x, y) in zip(total, items[j])]
    # print(total)
    if all( k >= X for k in total[1:]) == True:
        if ans == -1:
            ans = total[0]
        else:
            ans = min(ans,total[0]) 
print(ans)

Buggy python submission (verdict: Runtime Error):
# bit全探索問題

N,M,X = map(int,input().split())
items = [list(map(int,input().split())) for _ in range(N)]
ans = []
for i in range(2 ** N):
    total = [0 for _ in range(M)]
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            total = [x + y for (x, y) in zip(total, items[j])]
    if all( k >= X for k in total) == True:
       ans.append(total[0])
    # print(total)
if len(total) == 0:
    print(-1)
else:
    print(min(ans))

Fixed submission:
# bit全探索問題

N,M,X = map(int,input().split())
items = [list(map(int,input().split())) for _ in range(N)]
ans = -1
for i in range(1 << N):
    total = [0]*(M+1)
    for j in range(N):  
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            total = [x + y for (x, y) in zip(total, items[j])]
    # print(total)
    if all( k >= X for k in total[1:]) == True:
        if ans == -1:
            ans = total[0]
        else:
            ans = min(ans,total[0]) 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):


n,k = map(int,input().split())
l = list(map(int,input().split()))
position = 1
for i in range(k):
    position = l[position-1]
print(position)

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    n,k = map(int,input().split())
    l = list(map(int,input().split()))
    roop = [1]
    stayed = [0]*n
    for i in range(n):
        next_city = l[roop[-1]-1]
        if stayed[next_city-1]:
            endindex = i
            for j,r in enumerate(roop):
                if r == next_city:
                    startindex = j
            break
        else:
            roop.append(next_city)
            stayed[next_city-1] = 1

    if k < startindex:
        print(roop[k])
    else:
        dis = endindex - startindex + 1
        a = (k - startindex) % dis
        print(roop[a + startindex])
main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())

maxpoint = 0
if b > n:
    for i in range(n+1):
        tmp = int((a * i) / b)  - a * int(i/b) 
        maxpoint = max(tmp,maxpoint)
else:
    for i in reversed(range(n+1)):
        tmp = int((a * i) / b)  - a * int(i/b) 
        if b > 1:
            if i % (b-1) == 0 :
                maxpoint = max(tmp,maxpoint)
                print(maxpoint) 
                exit()
        elif b == 1:
            print(0)
            exit()
        maxpoint = max(tmp,maxpoint)
        # print(maxpoint)

print(maxpoint)

Fixed submission:

k = int(input())
a,b = map(int,input().split())

for i in range(a,b+1):
    if i % k == 0:
        print('OK')
        exit()
print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

l = []

for _ in range(n):
    s = str(input())
    if not s in l:
        l.append(s)

print(len(l))

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

n = int(input())

l = [str(input()) for _ in range(n)]

print(len(set(l)))
Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())
l = list(map(int,input().split()))
for i in range(n):
    print(l.count(i+1))
    
    

Fixed submission:

n = int(input())
l = list(map(int,input().split()))
l.sort()
k = 0
j = 1
cnt = 0
for i in range(n):
    if i == n-1:
        print(cnt)
        for _ in range(n - j):
            print(0)
    elif j == l[i]:
        cnt += 1
    elif l[i] - j >= 1:
        print(cnt)
        cnt = 1
        a = l[i] - j
        for _ in range(a-1):
            print(0)
        j += l[i] -j
Buggy python submission (verdict: Time Limit Exceeded):

n,k = map(int,input().split())
li = list(map(int,input().split()))

ans = [0]*n
ans[0] = 0

for i in range(1,n):
    l = []
    if k > i:
        for j in range(i):
            l.append(abs(li[i]-li[j])+ans[j])
    else:
        for j in range(1,k+1):
            l.append(abs(li[i]-li[i-j])+ans[i-j])
    # print(l)
    ans[i] = min(l)

print(ans[-1])

Fixed submission:

n,k = map(int,input().split())
li = list(map(int,input().split()))

ans = [0]*n
# 地味に遅い
# for i in range(1,n):
#     l = []
#     if k > i:
#         for j in range(i):
#             l.append(abs(li[i]-li[j])+ans[j])
#     else:
#         for j in range(1,k+1):
#             l.append(abs(li[i]-li[i-j])+ans[i-j])
#     ans[i] = min(l)
# print(ans[-1])

for i in range(1,n):
    l = [ abs(li[i]-li[j]) + ans[j] for j in range(max(0,i-k),i)]
    # print(l)
    ans[i] = min(l)
print(ans[-1])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, K = map(int, input().split())

L = [list(map(int, input().split())) for _ in range(K)]

S = []

for left, right in L:
    S.extend(range(left, right+1))

S = sorted(list(set(S)))

n_list = [0] * N
n_list[0] = 1

for idx, value in enumerate(n_list):
    if value == 0:
        continue
    if S[0] + idx >= N:
        break
    for s in S:
        next_idx = s + idx
        if next_idx >= N:
            break
        n_list[next_idx] += value

print(n_list[-1] % 998244353)


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

N = int(input())

count = 0
for i in range(1, N+1):
    count += (N - 1) // i
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

d = 1000000000 + 7

s = 0
for i in range(N):
    s += A[i] * sum(A[i+1:])
print(s % d)

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

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

d = 1000000000 + 7

s = 0

sum_list = [A[0]]
for a in A[1:]:
    sum_list.append(a + sum_list[-1])
for i in range(N):
    s += A[i] * (sum_list[N-1] - sum_list[i])
print(s % d)

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

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

d = 1000000000 + 7

s = 0
for i in range(N):
    for t in range(N-i-1):
        j = i + t + 1
        s += A[i] * A[j]
print(s % d)

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

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

d = 1000000000 + 7

s = 0

sum_list = [A[0]]
for a in A[1:]:
    sum_list.append(a + sum_list[-1])
for i in range(N):
    s += A[i] * (sum_list[N-1] - sum_list[i])
print(s % d)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
p = map(int, input().split())

p = sorted(p)
print(sum(p:[K]))


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

N, K = map(int, input().split())
p = map(int, input().split())

p = sorted(p)
print(sum(p[:K]))
Buggy python submission (verdict: Runtime Error):
%
n = int(input())

def func(n, i):
    ans = 0
    while  n > 0:
        ans += n % i
        n // = i
    return ans

b = n
for i in range(n+1):
    tmp = func(i, 6) + func(n-1, 9)
    b = min(tmp, b)

print(b)

Fixed submission:
n = int(input())
def func(n, i):
    ans = 0
    while n>0:
        ans += n%i
        n //= i
    return ans
b=n
for i in range(n+1):
    tmp = func(i, 6) + func(n-i, 9)
    b = min(tmp, b)
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
S = tuple(input())

print(min([S[0:i].count('W') + S[i+1:].count('E') for i in range(N)]))


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

N = int(input())
S = input()

W_num = [0] * N
E_num = [0] * N

for i in range(1, N):
    k = N - (i - 1) - 2
    W_num[i] = W_num[i-1] + 1 if S[i-1] == 'W' else W_num[i-1]
    E_num[k] = E_num[k+1] + 1 if S[k+1] == 'E' else E_num[k+1]

print(min([W_num[i] + E_num[i] for i in range(N)]))

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

N = int(input())
S = input()

print(min([S[0:i].count('W') + S[i+1:].count('E') for i in range(N)]))


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

N = int(input())
S = input()

W_num = [0] * N
E_num = [0] * N

for i in range(1, N):
    k = N - (i - 1) - 2
    W_num[i] = W_num[i-1] + 1 if S[i-1] == 'W' else W_num[i-1]
    E_num[k] = E_num[k+1] + 1 if S[k+1] == 'E' else E_num[k+1]

print(min([W_num[i] + E_num[i] for i in range(N)]))
Buggy python submission (verdict: Runtime Error):
A, B, C, X [int(inpit()) for i in range(4)]
print(sum(500 * a + 100 *b + 50 *c == X) for a in range(A+1) for b in range(B + 1) for c in range(C + 1)))


Fixed submission:
A, B, C, X = [int(input()) for i in range(4)]
print(sum(500 * a + 100 * b + 50 * c == X for a in range(A+1) for b in range(B + 1) for c in range(C + 1)))
Buggy python submission (verdict: Runtime Error):
a, b = input().split(' ')

if a * b % 2 = 0:
    print('Even')
else:
    print('Odd')


Fixed submission:
a, b = map(int, input().split())
print('Even' if a * b % 2 == 0 else 'Odd')

Buggy python submission (verdict: Runtime Error):
a, b = input.split(' ')

if a * b % 0:
    print('Even')
else:
    print('Odd')


Fixed submission:
a, b = map(int, input().split())
print('Even' if a * b % 2 == 0 else 'Odd')
Buggy python submission (verdict: Runtime Error):
N = int(input())
p_list =  list(map(int, input().split()))

i = 0
count = 0
while i < N:
    if p_list[i] == i + 1:
        temp = p_list[i+1]
        p_list[i+1] = p_list[i]
        p_list[i] = temp
        count = count + 1
        i = i + 1
    i = i + 1

print(count)


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

i = 0
count = 0

if p_list[-1] == N:
    temp = p_list[-1]
    p_list[-1] = p_list[-2]
    p_list[-2] = temp
    count = count + 1

while i < N:
    if p_list[i] == i + 1:
        temp = p_list[i+1]
        p_list[i+1] = p_list[i]
        p_list[i] = temp
        count = count + 1
        i = i + 1
    i = i + 1

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

two_count = 0
two_sum = 0
four_count = 0
result = 'No'

for i in a_list:
    if i % 2 == 0:
        two_count += 1
        if i % 4 == 0:
            four_count += 1

if two_count == N:
    result = 'Yes'
elif two_count * 2 + 1 >= N:
    if (N - two_count) == 1:
        if four_count >= 1:
            result = 'Yes'
    else:
        if (N - two_count) - 1<= four_count:
            result = 'Yes'


print(result)


Fixed submission:
n ,m = [int(i) for i in input().split()]
print((n - 1) * (m - 1))

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

two_count = 0
two_sum = 0
four_count = 0
result = 'No'

for i in a_list:
    if i % 2 == 0:
        two_count += 1
        if i % 4 == 0:
            four_count += 1

if two_count * 2 + 1 >= N:
    if (N - two_count) == 1:
        if four_count == 1:
            result = 'Yes'
    else:
        if (N - two_count) - 1<= four_count:
            result = 'Yes'

print(result)


Fixed submission:
n ,m = [int(i) for i in input().split()]
print((n - 1) * (m - 1))

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

two_count = 0
two_sum = 0
four_count = 0
result = 'No'

for i in a_list:
    if i % 2 == 0:
        two_count += 1
        if i % 4 == 0:
            four_count += 1

if two_count * 2 + 1 >= N:
    if (N - two_count) - 1<= four_count:
        result = 'Yes'

print(result)


Fixed submission:
n ,m = [int(i) for i in input().split()]
print((n - 1) * (m - 1))