Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# AtCorder-Candy Distribution Again

n,x = map(int, input().split())
list[] = list(map(int, input().split()))

a = 0
i = 0
list.sort()

if x < list[0]:
    print(0)

elif x >= list[0]:

    while x >= list[i] and x > 0:
        x -= list[i]
        a += 1
        if i < n-1 and x < list[i+1]:
            break
        if i == n-1:
            if x > list[i]:
                a = n-1
            else:
                a = n
            break
        i += 1

    print(a)

    

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

a = 0
i = 0

list.sort()

if list[0] > x:
    print(0)

elif x > sum(list):
    print(n-1)

else:
    while x > 0 and x >= list[i]:
        x -= list[i]
        i += 1
        a += 1
        if i == n:
            break

    print(a)

Buggy python submission (verdict: Runtime Error):
# AtCorder-Candy Distribution Again

n,x = map(int, input().split())
list[n] = list(map(int, input().split()))

a = 0
i = 0
list.sort()

if x < list[0]:
    print(0)

elif x >= list[0]:

    while x >= list[i] and x > 0:
        x -= list[i]
        a += 1
        if i < n-1 and x < list[i+1]:
            break
        if i == n-1:
            if x > list[i]:
                a = n-1
            else:
                a = n
            break
        i += 1

    print(a)


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

a = 0
i = 0

list.sort()

if list[0] > x:
    print(0)

elif x > sum(list):
    print(n-1)

else:
    while x > 0 and x >= list[i]:
        x -= list[i]
        i += 1
        a += 1
        if i == n:
            break

    print(a)

Buggy python submission (verdict: Runtime Error):
# AtCorder-Candy Distribution Again

n,x = map(int, input().split())
list = list(map(int, input().split()))

a = 0
i = 0
list.sort()

if x < list[0]:
    print(0)

elif x >= list[0]:

    while x > 0 and x >= list[i]:
        x -= list[i]
        a += 1
        if x < list[i+1]:
            break
        i += 1

    print(a)


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

a = 0
i = 0

list.sort()

if list[0] > x:
    print(0)

elif x > sum(list):
    print(n-1)

else:
    while x > 0 and x >= list[i]:
        x -= list[i]
        i += 1
        a += 1
        if i == n:
            break

    print(a)
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())

l = []
i = 0

l = [input() for i in range(n)]
result = sorted(l)
s = ''.join(result)
# for i in range(n):
print(s)


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

def judge():
    if a==5:
        if b==5:
            if c==7:
                return print("YES")
            else:
                return print("NO")
        elif b==7:
            if c==5:
                return print("YES")
            else:
                return print("NO")

    elif a==7:
        if b==5:
            if c==5:
                return print("YES")
            else:
                return print("NO")
        else:
            return print("NO")


    else:
        return print("NO")

judge()

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

    if a==5:
        if b==5:
            if c==7:
                return print("YES")
            else:
                return print("NO")
        elif b==7:
            if c==5:
                return print("YES")
            else:
                return print("NO")

    elif a==7:
        if b==5:
            if c==7:
                return print("YES")
            else:
                return print("NO")
        elif :
            return print("NO")


    else:
        return print("NO")

judge()


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

def judge():
    if a==5:
        if b==5:
            if c==7:
                return print("YES")
            else:
                return print("NO")
        elif b==7:
            if c==5:
                return print("YES")
            else:
                return print("NO")

    elif a==7:
        if b==5:
            if c==5:
                return print("YES")
            else:
                return print("NO")
        else:
            return print("NO")


    else:
        return print("NO")

judge()
Buggy python submission (verdict: Runtime Error):
l = map(int, raw_input().split())

if l[0] + l[1] < 2 * l[2]:
	if l[3] < l[4]:
		return l[3] * 2 * l[2] + (l[4] - l[3]) * l[1]
	else:
		return l[4] * 2 * l[2] + (l[3] - l[4])  * l[0]
else:
	return l[3] * l[0] + l[4] * l[1]

Fixed submission:
l = map(int, raw_input().split())

if l[0] + l[1] > 2 * l[2]:
	if l[3] < l[4]:
		if (l[4] - l[3]) * l[1] < (l[4] - l[3]) * 2 * l[2]:
			print l[3] * 2 * l[2] + (l[4] - l[3]) * l[1]
		else:
			print l[4] * 2 * l[2]
	else:
		if (l[3] - l[4]) * l[0] < (l[3] - l[4]) * 2 * l[2]:
			print l[4] * 2 * l[2] + (l[3] - l[4])  * l[0]
		else:
			print l[3] * 2 * l[2]
else:
	print l[3] * l[0] + l[4] * l[1]
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
m,a,r,c,h = 0
for i in range(N):
	S = raw_input()
	if S[:1] == "M":
		m += 1
	elif S[:1] == "A":
		a += 1
	elif S[:1] == "R":
		r += 1
	elif S[:1] == "C":
		c += 1
	elif S[:1] == "H":
		h += 1
print m*a*r+m*a*c+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h	

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

X = input()
print X//3

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input.split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N = -1:print('Three')

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

X = input()
print X//3

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

X = raw_input()
print X/3

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

X = input()
print X//3

Buggy python submission (verdict: Runtime Error):
X = raw_input()
print X//3

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

X = input()
print X//3
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input.split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N == -1:
	print('Three')

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input().split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N > -1:
	print('Three')

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input.split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N == -1:print('Three')

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input().split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N > -1:
	print('Three')

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input.split()
for i in range(N)
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N = -1:print('Three')

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input().split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N > -1:
	print('Three')

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input.split()
For i in range(N)
	if S[i] == "Y":
		print "Four"
		N = -1
		break
if N = -1:print "Three"

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
S = raw_input().split()
for i in range(N):
	if S[i] == 'Y':
		print('Four')
		N = -1
		break
if N > -1:
	print('Three')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
m,a,r,c,h = 0
for i in range(N):
	S = raw_input()
	if S[:1] == "M":
		m += 1
	elif S[:1] == "A":
		a += 1
	elif S[:1] == "R":
		r += 1
	elif S[:1] == "C":
		c += 1
	elif S[:1] == "H":
		h += 1
print m*a*r+m*a*c+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h	

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(N):
	S = raw_input()
	if S[:1] == "M":
		m += 1
	elif S[:1] == "A":
		a += 1
	elif S[:1] == "R":
		r += 1
	elif S[:1] == "C":
		c += 1
	elif S[:1] == "H":
		h += 1
print m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
for i in range(N):
	S = raw_input()
	if S[:1] == "M":
		m += 1
	elif S[:1] == "A":
		a += 1
	elif S[:1] == "R":
		r += 1
	elif S[:1] == "C":
		c += 1
	elif S[:1] == "H":
		h += 1
print m*a*r+m*a*c+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h	

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(N):
	S = raw_input()
	if S[:1] == "M":
		m += 1
	elif S[:1] == "A":
		a += 1
	elif S[:1] == "R":
		r += 1
	elif S[:1] == "C":
		c += 1
	elif S[:1] == "H":
		h += 1
print m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h
Buggy python submission (verdict: Runtime Error):
str = input()
n,k = [int(x) for x in str.split()]
str = input()
list = [int(x) for x in str.split()]
ans = 100000000
a:int
b:int
for i in range(0,n - k + 1):
	a = list[i]
	b = list[i + k - 1]
	if (a < 0) & (b > 0): #优先级需要加括号
	    ans = min(ans,min(b - a * 2,b * 2 - a))
	else:
		ans = min(ans,max(abs(a),abs(b)))
print(ans)

Fixed submission:
str = input()
n,k = [int(x) for x in str.split()]
str = input()
list = [int(x) for x in str.split()]
ans = 1000000000
for i in range(0,n - k + 1):
	a = list[i]
	b = list[i + k - 1]
	if (a < 0) & (b > 0): #优先级需要加括号
	    ans = min(ans,min(b - a * 2,b * 2 - a))
	else:
		ans = min(ans,max(abs(a),abs(b)))
print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a+b==15:
    print("+")
elif a*b==15:
    print("*")
else:
    print("x")

Fixed submission:
a,b=map(int,input().split())
if a+b==15:
    print("+")
elif a*b==15:
    print("*")
else:
    print("x")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N+1)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]+1] = chain[a[i]]+1
print(max(chain))

Fixed submission:
N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N+1)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]] = chain[a[i]-1]+1
print(N-max(chain))

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]] = chain[a[i]-1]+1
print(max(chain))

Fixed submission:
N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N+1)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]] = chain[a[i]-1]+1
print(N-max(chain))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
l = [[-1 for j in range(m)] for i in range(n)]
for i in range(n):
    for j in range(m):
        l[i][j] *= -1
        if (j-1) >= 0: l[i][j-1] *= -1
        if (j+1) < m: l[i][j+1] *= -1
        if (i-1) >= 0:
            l[i-1][j] *= -1
            if (j-1) >= 0: l[i-1][j-1] *= -1
            if (j+1) < m: l[i-1][j+1] *= -1
        if (i+1) < n:
            l[i+1][j] *= -1
            if (j-1) >= 0: l[i+1][j-1] *= -1
            if (j+1) < m: l[i+1][j+1] *= -1
ans = 0
for i in range(n):
    ans += l[i].count(1)
print(ans)


Fixed submission:
n, m = map(int, input().split())
print(abs((n-2)*(m-2)))
Buggy python submission (verdict: Runtime Error):
K = map(int, input())

odd_number = K // 2　+ 1
even_number = K // 2

print(odd_number*even_number)


Fixed submission:
K = int(input())
if K%2 == 0:
    odd_number = K // 2
elif K%2 == 1:    
    odd_number = K // 2 + 1
even_number = K // 2 

print(odd_number*even_number)

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

odd_number = K // 2　+ 1
even_number = K // 2

print(odd_number*even_number)


Fixed submission:
K = int(input())
if K%2 == 0:
    odd_number = K // 2
elif K%2 == 1:    
    odd_number = K // 2 + 1
even_number = K // 2 

print(odd_number*even_number)

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

odd_number = K // 2　+ 1
even_number = K // 2

print(odd_number*even_number)


Fixed submission:
K = int(input())
if K%2 == 0:
    odd_number = K // 2
elif K%2 == 1:    
    odd_number = K // 2 + 1
even_number = K // 2 

print(odd_number*even_number)
Buggy python submission (verdict: Runtime Error):
S = str(input())
flag = False
 
if S.startswith("A"):
  if ((S[2]) == "C") ^ (S["-2"]=="C"):
  	index = S.find("C")
    for i, s in enumerate(S):
      if (i == 0) or (i == index):
        continue
      if s.islower():
        continue
        if i == len(s):
          flag == True
 
if flag == True:
  print("AC")
else:
  print("WA")

Fixed submission:
R = int(input())
if R < 1200:
  print("ABC")
elif R < 2800:
  print("ARC")
else:
  print("AGC")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p_list = map(int, input().split())

pat = 1
sum = 0
for i, r_pos in enumerate(p_list):
    pat *= sum + 1
    if r_pos >= 2 * sum + 1: sum += 1
print(pat % 1000000007)

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

pat = 1
sum = 0
for i, r_pos in enumerate(p_list):
    pat = (pat * (sum + 1)) % 1000000007
    if r_pos >= 2 * sum + 1: sum += 1
print(pat)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
p_list = [int(x) for x in input().strip().split()]

pat = 1
sum = 0
for i, r_pos in enumerate(p_list):
    pat *= sum + 1
    if r_pos >= 2 * sum + 1:
        sum += 1

print(pat % 1000000007)

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

pat = 1
sum = 0
for i, r_pos in enumerate(p_list):
    pat = (pat * (sum + 1)) % 1000000007
    if r_pos >= 2 * sum + 1: sum += 1
print(pat)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce


# fin = open('mujin_a.txt')
# input = fin.readline
N = int(input())
p_list = [int(x) for x in input().strip().split()]

pat = 1
sum = 0
for i, r_pos in enumerate(p_list):
    if r_pos >= 2 * sum + 1:
        sum += 1
    else:
        pat *= sum + 1

print(reduce(lambda x, y: x * y, range(1, sum + 1), pat) % 1000000007)

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

pat = 1
sum = 0
for i, r_pos in enumerate(p_list):
    pat = (pat * (sum + 1)) % 1000000007
    if r_pos >= 2 * sum + 1: sum += 1
print(pat)
Buggy python submission (verdict: Runtime Error):
SHEEP = True
WOLF = False


def print_tree(tree):
    print(''.join(['S' if e else 'W' for e in tree]))


def calc_next_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos - 1]
        else:
            return not tree[cur_pos - 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos - 1]
        else:
            return tree[cur_pos - 1]


def calc_prev_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos + 1]
        else:
            return not tree[cur_pos + 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos + 1]
        else:
            return tree[cur_pos + 1]


def wfs(tree, cur_pos, N):
    tree[cur_pos + 1] = calc_next_animal(tree, cur_pos)
    cur_pos += 1
    if cur_pos == N - 1:
        return tree[0] == calc_next_animal(tree, cur_pos) and tree[cur_pos] == calc_prev_animal(tree, 0)
    else:
        return wfs(tree, cur_pos, N)


if __name__ == '__main__':
    N = int(input())
    answer = [True if i == 'o' else False for i in input().rstrip()]
    aa = [[WOLF, WOLF]
        , [WOLF, SHEEP]
        , [SHEEP, SHEEP]
        , [SHEEP, WOLF]]
    super_list = [0] * int(2E5)
    for a in aa:
        super_list[:2] = a
        if wfs(super_list, 1, N):
            print_tree(super_list[:N])
            break
    else:
        print(-1)

Fixed submission:
if __name__ == '__main__':
    N = int(input().rstrip())
    print(800 * N - 200 * (N // 15))
Buggy python submission (verdict: Runtime Error):
from itertools import product


n, m = [int(i) for i in input().rstrip().split()]
AA = [[0 if i == '.' else 1 for i in input().rstrip()] for _ in range(n)]
BB = [[0 if i == '.' else 1 for i in input().rstrip()] for _ in range(m)]

for i_r, i_c in product(range(n - m + 1), range(n - m + 1)):
    i_r -= 1
    i_c -= 1
    for k_r, k_c in product(range(m), range(m)):
        if AA[i_r + k_r][i_c + k_c] == BB[k_r][k_c]:
            continue
        else:
            break
    else:
        print('Yes')
        break
else:
    print('No')

Fixed submission:
table = {'2': 0,
         '3': 1,
         '4': 2,
         '5': 3,
         '6': 4,
         '7': 5,
         '8': 6,
         '9': 7,
         '10': 8,
         '11': 9,
         '12': 10,
         '13': 11,
         '1': 12, }
ary = [table[i] for i in input().strip().split()]
if (ary[1] - ary[0]) > 0:
    print('Bob')
elif ary[1] == ary[0]:
    print('Draw')
else:
    print('Alice')
Buggy python submission (verdict: Runtime Error):
N = input()
if len([a for a in input().rstrip().split() if a % 2]) % 2:
    print('NO')
else:
    print('YES')

Fixed submission:
N = input()
if len([a for a in input().rstrip().split() if int(a) % 2]) % 2:
    print('NO')
else:
    print('YES')
Buggy python submission (verdict: Runtime Error):
N = input()
print(N * (N + 1) / 2)


Fixed submission:
N = int(input())
print(int(N * (N + 1) / 2))
Buggy python submission (verdict: Runtime Error):
import math
n, fx = map(int, input().split())
x = list(map(int, input().split()))
x.append(fx)
x.sort()

ans = x[1]-x[0]
for i in range(2, len(x)):
  v = x[i]-x[i-1]
  ans = max(ans, math.gcd(ans, v))

print(ans)

Fixed submission:
import fractions
n, fx = map(int, input().split())
x = list(map(int, input().split()))
x.append(fx)
x.sort()

ans = x[1]-x[0]
for i in range(2, len(x)):
  v = x[i]-x[i-1]
  ans = fractions.gcd(ans, v)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,C = [int(i) for i in input().split()]
D = [[int(j) for j in input().split()] for i in range(C)]
c = [[int(j) for j in input().split()] for i in range(N)]
bank = [[],[],[]]
for i in range(N):
    for j in range(N):
        bank[(i+j)%3].append(c[i][j]-1)


min = 100000
for i in [ii for ii in range(C)]:
    for j in [jj for jj in range(C) if jj != i]:
        for k in [kk for kk in range(C) if kk != i and kk != j]:
            count = 0
            for x in bank[0]:
                if x != i:
                    count += D[x][i]
            for y in bank[1]:
                if y != j:
                    count += D[y][j]
            for z in bank[2]:
                if z != k:
                    count += D[z][k]
            if min > count:
                min = count
print(min)




Fixed submission:
N,C = [int(i) for i in input().split()]
D = [[int(j) for j in input().split()] for i in range(C)]
c_temp = [[int(j)-1 for j in input().split()] for i in range(N)]
c = [[0 for i in range(C)] for j in range(3)]
for i in range(N):
    for j in range(N):
        c[(i+j)%3][c_temp[i][j]] += 1

min = 10**15
for i in [ii for ii in range(C)]:
    for j in [jj for jj in range(C) if jj != i]:
        for k in [kk for kk in range(C) if kk != i and kk != j]:
            count = sum([D[x][i]*c[0][x] + D[x][j]*c[1][x] + D[x][k]*c[2][x] for x in range(C)])
            if min > count:
                min = count
print(min)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

s = list(S)
s.reverse()
s_bit = np.array([1 if i == 'E' else 0 for i in s])
bit_mask = np.array([pow(2,i) for i in range(N)])
bit = np.dot(s_bit, bit_mask)

global cost_N,min
cost_N = np.zeros(N)
def cost(i):
    global cost_N, min
    if i == 0:
        a = bit & (1 << i)
        b = (pow(2, N) - 1) - (pow(2, i + 1) - 1)
        c = b | a
        bit_cost = bit ^ c
        cost_N[0] = bin(bit_cost).count("1")
        return cost_N[0]
    else:
        cur = s_bit[i]
        bef = s_bit[i-1]
        cost_N[i] = cost(i-1) - (1^cur) + bef
        return cost_N[i]

cost(N-1)
print(int(min(cost_N)))


Fixed submission:
import numpy as np

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


s = list(S)


s.reverse()
s = np.array([1 if i == 'E' else 0 for i in s])
#str = S.replace('E','1')
#bit_str = str.replace('W','0')
#bit = int(bit_str, base=2)

cost = [0]*N
cost[0] = (N-1) - sum(s[1:N])
for i in range(1,N):
    now = s[i]
    bef = s[i-1]
    cost[i] = cost[i-1] + bef - (1^now)

print(min(cost))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

s = list(S)
s.reverse()
s_bit = np.array([1 if i == 'E' else 0 for i in s])
bit_mask = np.array([pow(2,i) for i in range(N)])
bit = np.dot(s_bit, bit_mask)

min = N
for i in range(N):
    a = bit & (1 << i)
    b = (pow(2,N) - 1) - (pow(2,i+1) - 1)
    c = b | a
    cost = bit ^ c
    actual_cost = bin(cost).count("1")
    if actual_cost < min:
        min = actual_cost

print(min)


Fixed submission:
import numpy as np

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


s = list(S)


s.reverse()
s = np.array([1 if i == 'E' else 0 for i in s])
#str = S.replace('E','1')
#bit_str = str.replace('W','0')
#bit = int(bit_str, base=2)

cost = [0]*N
cost[0] = (N-1) - sum(s[1:N])
for i in range(1,N):
    now = s[i]
    bef = s[i-1]
    cost[i] = cost[i-1] + bef - (1^now)

print(min(cost))
Buggy python submission (verdict: Runtime Error):
N,C = list(map(int,input().split()))

x = [None]*N
rev_x = [None]*N
v = [None]*N

T = [None]*N
Trev = [None]*N

Tall = []

for i in range(N):
    a,b = list(map(int,input().split()))
    x.append(a)
    rev_x.append(C - a)
    v.append(b)

rev_x.reverse()

for i in range(N):
    T.append(sum(v[0:i+1]) - x[i])

v.reverse()

for i in range(N):
    Trev.append(sum(v[0:i+1]) - rev_x[i])

Tall = T + Trev

for i in range(N):
    for j in range(N - i - 1):
        Tall.append(T[i] + Trev[j] - min(x[i], rev_x[j]))

Tmax = max(Tall)
if Tmax < 0:
    Tmax = 0
print(Tmax)



Fixed submission:
S = input()
S = S.replace('x','')
len_S =len(S)
print(len_S * 100 + 700)
Buggy python submission (verdict: Time Limit Exceeded):

def main():
    q, h, s, d = map(int, input().split())
    n = int(input()) * 100
    h = min(h, 2*q)
    s = min(s, 2*h)
    d = min(d, 2*s)
    ans = 0
    vals = [(200, d), (100, s), (50, h), (25, q)]
    while n > 0:
        for m, val in vals:
            if m <= n:
                n -= m
                ans += val
                break
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:

def main():
    q, h, s, d = map(int, input().split())
    n = int(input()) * 100
    h = min(h, 2*q)
    s = min(s, 2*h)
    d = min(d, 2*s)
    ans = 0
    vals = [(200, d), (100, s), (50, h), (25, q)]
    for m, val in vals:
        c = n // m
        n -= m * c
        ans += val*c
    print(int(ans))


if __name__ == '__main__':
    main()