Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A =list(map(int,input().split()))
new_list = sorted(A, reverse=True)
ans = 0
for i in range(M):
    if not new_list:
        break
    else:
        del new_list[0]
        
if not new_list:
    print(ans)
else:
    ans +=sum(new_list)
    print(ans)

Fixed submission:
N,M = map(int,input().split())
A =list(map(int,input().split()))
new_list = sorted(A, reverse=True)
ans = 0

del new_list[0:M]
        
if not new_list:
    print(ans)
else:
    ans +=sum(new_list)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
a,b = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(int(lcm(a, b)))

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(int(lcm(a, b)))

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))


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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(int(lcm(a, b)))
Buggy python submission (verdict: Runtime Error):
a =int(input())
B =list(input())

D =[1]


def dfs(x):
    for dx in D:
        C =B[x]
        B[x] = "."
        nx = x + dx
        if nx >= 0 and nx <= a-1 and B[nx] == C:
            dfs(nx)

res = 0
for i in range(a):
        if B[i] != ".":
            dfs(i)
            res += 1
print(res)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

a =int(input())
B =list(input())

def dfs(x):
    
    C =B[x]
    B[x] = "."
    nx = x + 1
    if nx >= 0 and nx <= a-1 and B[nx] == C:
        dfs(nx)

res = 0
for i in range(a):
        if B[i] != ".":
            # Wが残っているならそこから dfs をはじめる
            dfs(i)
            res += 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
N = int(input())
L = list(map(int,input().split()))
L_1 = sorted(L)

ans = 0

for i in range(N-1):
  for j in range(i+1,N-1):
      A = bisect_left(L_1,L_1[i]+L_1[j])
      for k in range(j+1,A):
          if L_1[i]+L_1[j] > L_1[k]:
              ans += 1
      
print(ans)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int,input().split()))
L_1 = sorted(L)

ans = 0

for i in range(N-1):
  for j in range(i+1,N-1):
      ans +=bisect_left(L_1,L_1[i]+L_1[j])-j-1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
n = lens(S)

def dfs(i,k):
  if i == n-1:
    return(sum(list(map(int,f.split("+")))
  return dfs(i+1,K+S[i+1])+dfs(i+1,K+"+"+S[i+1])
print(dfs(0,S[0])
               


Fixed submission:

S = input()
n = len(S)
 
def dfs(i, k):
    
    if i == n-1:
        return sum(list(map(int,k.split("+"))))
    
    return dfs(i+1,k+S[i+1])+dfs(i+1,k+"+"+S[i+1])
 
print(dfs(0,S[0]))
Buggy python submission (verdict: Runtime Error):
import numpy as np
H, N = map(int, input().split())
A = np.array([int(num) for num in input().split()])
if H <= A.sum():
    print('Yes')
else:
    print('No')

Fixed submission:
import numpy as np
H, A = map(int, input().split())
num = int(np.ceil(H/A))
print(num)

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

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

s_sum = sum(s)

if s_sum < H:
  print('No')
else:
  print('Yes')

Fixed submission:
H, A = map(int, input().split())
counter = 0

while H > 0:
  H -= A
  counter += 1
  
print(counter)
Buggy python submission (verdict: Runtime Error):
x = input()

if x%2 == 0:
  count = int(x/2)
else:
  count = int(x/2) + 1

Fixed submission:
x = input()
xNum = int(x)

if xNum%2 == 0:
  count = xNum/2
else:
  count = int(xNum/2) + 1

print(count/xNum)
Buggy python submission (verdict: Runtime Error):
H = int(input())
count = 0

def helper(x):
  if x == 1:
    return 1
  return helper(x/2) * 2 + 1

print(helper(H))

Fixed submission:
H = int(input())
count = 0

def helper(x):
  if x == 1:
    return 1
  return helper(x//2) * 2 + 1

print(helper(H))

Buggy python submission (verdict: Runtime Error):
H = int(input())
count = 0

def helper(x):
  if x == 1:
    global count
    count += 1
    return
  count += 1
  helper(x/2)
  helper(x/2)

helper(H)
print(count)

Fixed submission:
H = int(input())
count = 0

def helper(x):
  if x == 1:
    return 1
  return helper(x//2) * 2 + 1

print(helper(H))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = input().split()
count = 0

for i in range(N):
  flag = True
  for j in range(i):
    if int(P[i]) > int(P[j]):
      flag = False
      break
  if flag:
    count += 1
print(count)


Fixed submission:
N = int(input())
P = input().split()
count = 0
cur_min = int(P[0])

for i in range(N):
  if cur_min >= int(P[i]):
    cur_min = int(P[i])
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
num = [0 for _ in range(N)]

for i in range(N):
  for j in range(i):
    if S[j] == 'W':
      num[i] += 1
  for j in range(i+1, N):
    if S[j] == 'E':
      num[i] += 1

print(min(num))

Fixed submission:
N = int(input())
S = input()
num = [0 for _ in range(N)]

for i in range(1, N):
  if S[i] == 'E':
    num[0] += 1

for i in range(1, N):
  diff = 0
  if S[i-1] == 'W':
    diff += 1
  if S[i] == 'E':
    diff -= 1
  num[i] = num[i-1] + diff
  
print(min(num))
Buggy python submission (verdict: Runtime Error):
ab = a * b
if ab % 2 == 0:
  print('Even')
else:
  print('Odd')

Fixed submission:
a, b = map(int, input().split())
ab = a * b
if ab % 2 == 0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
s = input()
count = 0
if s[0] == '1':
  count += 1
if s[1] == '1':
  count += 1
if s[2] == '1':
  count += 1

return count

Fixed submission:
s = input()
count = 0
if s[0] == '1':
  count += 1
if s[1] == '1':
  count += 1
if s[2] == '1':
  count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
A = input().split()
count = 0
flag = True

while flag:
  for i in range(N):
    if A[i] % 2 != 0:
      flag = False
      break
  if !flag:
    print(count)
  count += 1
  for i in range(N):
    A[i] = A[i] / 2

Fixed submission:
N = int(input())
A = [int(s) for s in input().split()]
count = 0
flag = True

while flag:
  for i in range(N):
    if A[i] % 2 != 0:
      flag = False
      break
  if flag == False:
    print(count)
  count += 1
  for i in range(N):
    A[i] = A[i] / 2

Buggy python submission (verdict: Runtime Error):
A = input().split()
count = 0
flag = True

while flag:
  fot i in range(N):
    if A[i] % 2 != 0:
      flag = False
      break
  if !flag:
    print(count)
  count += 1
  A[i] = A[i] / 2
   


Fixed submission:
N = int(input())
A = [int(s) for s in input().split()]
count = 0
flag = True

while flag:
  for i in range(N):
    if A[i] % 2 != 0:
      flag = False
      break
  if flag == False:
    print(count)
  count += 1
  for i in range(N):
    A[i] = A[i] / 2
Buggy python submission (verdict: Time Limit Exceeded):
KS = input().split()
K,S = int(KS[0]), int(KS[1])
S_count = 0

for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x + y + z == S:
        S_count += 1
print(S_count)

Fixed submission:
KS = input().split()
K,S = int(KS[0]), int(KS[1])
S_count = 0

for x in range(K+1):
  for y in range(K+1):
    if S - x - y <= K and S - x - y >= 0:
      S_count += 1
print(S_count)
Buggy python submission (verdict: Runtime Error):
def takahashi(A,B):
    if A and B >= 1:
        if A and B <= 9:
            print(A * B)
        else:
            print('-1')
    else:
        print('-1')

A = int(input('数字を入力してくださいA'))
B = int(input('数字を入力してくださいB'))

takahashi(A,B)

Fixed submission:
A, B = map(int, input().split())
 
if A < 10 and B < 10:
    print(A*B)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
 
def takahashi:
  if A and B >= 1:
  	if A and B <= 9:
    
    else print('-1')
    	print(A * B)

Fixed submission:
A, B = map(int, input().split())
 
if A < 10 and B < 10:
    print(A*B)
else:
    print(-1)

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

def takahashi:
  if A and B >= 1
  	if A and B <= 9
    
    else print('-1')
    	print(A * B)
      

Fixed submission:
A, B = map(int, input().split())
 
if A < 10 and B < 10:
    print(A*B)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N,K,X,Y = [input() for i in range(4)]

if N <= K:
    print(N * K)
else:
    S = N * K
    s = N * (N - K)
    S += s
    print(S)

Fixed submission:
N,K,X,Y = [int(input()) for i in range(4)]

if N <= K:
    print(N * X)
else:
    S = K * X #最初の宿泊金額
    p = N - K #残りの日数
    s = p * Y #残りの宿泊金額
    S += s #足す
    print(S)
Buggy python submission (verdict: Runtime Error):
N = int(input())
t = 0

for i in range(N)
	t += i
  
print(i)


Fixed submission:
N = int(input())
t = 0

for i in range(N):
	t += i + 1 

print(t)

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

j=0

for i in N:
  j = j + i

else:
  print(j)

Fixed submission:
N = int(input())
t = 0

for i in range(N):
	t += i + 1 

print(t)

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

j=0

for i in N:
  j = j + N

else:
  print(j)

Fixed submission:
N = int(input())
t = 0

for i in range(N):
	t += i + 1 

print(t)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())

if A == 5 or A == 7:
  if B == 5 or B == 7:
    if C == 5 or C == 7:
      if A + B + C == 17:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  else:
  	print('No')
else:
  print('No')
  

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

if A == 5 or A == 7:
  if B == 5 or B == 7:
    if C == 5 or C == 7:
      if A + B + C == 17:
        print('YES')
      else:
        print('NO')
    else:
      print('NO')
  else:
  	print('NO')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(h) for h in map(int, input().split())]

for i in range(k):
	try:
		h.remove(max(h))
	except ValueError as e:
		pass
print(sum(h))

Fixed submission:
n, k = map(int, input().split())
h = [int(h) for h in map(int, input().split())]
if k >= len(h) and k > 0:
	print(0)
else:
	h.sort()
	print(sum(h[:n-k]))
Buggy python submission (verdict: Runtime Error):
h,a=map(int, input().split())
count = 0
while True:
  result = h - a
  if (result > 0):
    count += 1
  else:
  	break 
return count

Fixed submission:
h,a=map(int, input().split())
count = 0
while True:
  h = h - a
  if (h > 0):
    count += 1
  else:
    break
print(count + 1)
Buggy python submission (verdict: Runtime Error):
h,n=map(int, input().split())
aList=list(map(int, input().split()))
result = h
for a in aList:
  result -= a
return 'Yes' if result <= 0 else 'No'

Fixed submission:
h,n=map(int, input().split())
aList=list(map(int, input().split()))
result = h
for a in aList:
  result -= a
print('Yes') if result <= 0 else print('No')
Buggy python submission (verdict: Runtime Error):
n,s = map(str,input().split())

print(s.count('ABC'))

Fixed submission:
n = input()
s = input()
 
print(s.count('ABC'))
Buggy python submission (verdict: Runtime Error):
import itertools

n = input()
p = map(int, input().split())
q = map(int, input().split())

x = itertools.permutations(list(range(n)), n)
pnum = 0
qnum = 0
for index, xx in enumerate(x):
  if(xx == p):
    pnum = index
  if(xx == q):
    qnum = index
    
print(abs(pnum - qnum))

Fixed submission:
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

x = itertools.permutations(list(range(1, n+1)), n)
pnum = 0
qnum = 0
for index, xx in enumerate(x):
  if(list(xx) == p):
    pnum = index
  if(list(xx) == q):
    qnum = index
    
print(abs(pnum - qnum))
Buggy python submission (verdict: Runtime Error):
M1 = int(input())
D1 = int(input())
M2 = int(input())
D2 = int(input())

if D2 == 1:
    print(1)
else:
    print(0)


Fixed submission:
date_entry_1 = input()
M1, D1 = map(int, date_entry_1.split(' '))
date_entry_2 = input()
M2, D2 = map(int, date_entry_2.split(' '))

if D2 == 1:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
M1 = int(input())
D1 = int(input())
M2 = int(input())
D2 = int(input())

if D2 == 1:
    print(1)
else:
    print(0)


Fixed submission:
date_entry_1 = input()
M1, D1 = map(int, date_entry_1.split(' '))
date_entry_2 = input()
M2, D2 = map(int, date_entry_2.split(' '))

if D2 == 1:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N = input()

prob_odd = (N //2 + N % 2) / N

print(prob_odd)

Fixed submission:
N = int(input())

prob_odd = (N //2 + N % 2) / N

print(prob_odd)
Buggy python submission (verdict: Runtime Error):

x = input()
hights_str = input()

low_limit = int(x.split(" ")[1]
hights = map(int, hights_str.split(" "))

count = 0
for hight in hights:
    if hight >= low_limit:
        count += 1

print(count)

Fixed submission:

x = input()
hights_str = input()

low_limit = int(x.split(" ")[1])
hights = map(int, hights_str.split(" "))

count = 0
for hight in hights:
    if hight >= low_limit:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
import pandas as pd
N = input()
cum_numbers = input()

series_cum_numbers = pd.Series(list(map(int, cum_numbers.split(" "))))

student_order = series_cum_numbers.sort_values().index + 1

print(" ".join(map(str, list(student_order))))

Fixed submission:
import numpy as np
N = input()
cum_numbers = input()

array_cum_numbers = np.array(list(map(int, cum_numbers.split(" "))))

studentId_order = array_cum_numbers.argsort() + 1

print(" ".join(map(str, list(studentId_order))))
Buggy python submission (verdict: Time Limit Exceeded):
import math


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


inf = float('inf')


def main():
  H, N = inputIntList()
  AB = [inputIntList() for _ in range(N)]
  dp = [inf for _ in range(H + 1)]

  dp[0] = 0
  for (a, m) in AB:
    for h in range(H):
      nxt = min(H, h+a)
      dp[nxt] = min(dp[h]+m, dp[nxt])
  # print(dp)
  return dp[H]


if __name__ == "__main__":
  print(main())


Fixed submission:
import math


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


inf = float('inf')


def main():
  H, N = inputIntList()
  AB = [inputIntList() for _ in range(N)]
  dp = [inf for _ in range(H + 1)]

  dp[0] = 0
  for (a, m) in AB:
    for h in range(H):
      nxt = min(H, h+a)
      dp[nxt] = min(dp[h]+m, dp[nxt])
  # print(dp)
  return dp[H]


if __name__ == "__main__":
  print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    a = inputIntList()
    ans = 0
    index = 0
    while index < len(a):
        if a[index] - 1 != index:
            a.remove(a[index])
            ans += 1
        else:
            index += 1
    return ans if ans != N else -1


if __name__ == "__main__":
    print(main())


Fixed submission:
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    a = inputIntList()
    ans = 0
    look = 1
    for i in a:
        if look == i:
            look += 1
        else:
            ans += 1

    return ans if ans != N else -1


if __name__ == "__main__":
    print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    a = inputIntList()
    ans = 0
    index = 0
    while index < len(a):
        if a[index] - 1 != index:
            a.remove(a[index])
            ans += 1
        else:
            index += 1
    return ans if ans != N else -1


if __name__ == "__main__":
    print(main())


Fixed submission:
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    a = inputIntList()
    ans = 0
    look = 1
    for i in a:
        if look == i:
            look += 1
        else:
            ans += 1

    return ans if ans != N else -1


if __name__ == "__main__":
    print(main())
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
import re
import sys


def inputs():
    return [int(s) for s in input().split()]


def main():
    M1, _ = inputs()
    M2, _ = inputs()

    if (M1 + 1) % 12 == M2 % 12:
        return 1
    else:
        return 0


if __name__ == '__main__':
    print(main())


Fixed submission:


def inputs():
    return [int(s) for s in input().split()]


def main():
    M1, _ = inputs()
    M2, _ = inputs()

    if (M1 + 1) % 12 == M2 % 12:
        return 1
    else:
        return 0


if __name__ == '__main__':
    print(main())
Buggy python submission (verdict: Runtime Error):
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    A = inputIntList()

    pattern = [0] * N
    pattern[0] = 3

    ret = 1
    for a in A:
        ret *= pattern[a]
        pattern[a] -= 1
        pattern[a + 1] += 1
        # print(pattern)
    return ret


if __name__ == "__main__":
    print(main())


Fixed submission:
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    A = inputIntList()

    pattern = [0 for _ in range(N + 1)]
    pattern[0] = 3

    ret = 1
    for a in A:
        ret *= pattern[a]
        pattern[a] -= 1
        pattern[a + 1] += 1
        # print(pattern)
    return ret % 1000000007


if __name__ == "__main__":
    print(main())

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


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    A = inputIntList()

    pattern = [0] * 4
    pattern[0] = 3

    ret = 1
    for a in A:
        ret *= pattern[a]
        pattern[a] -= 1

        pattern[a + 1] += 1
        # print(pattern)
    return ret


if __name__ == "__main__":
    print(main())


Fixed submission:
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    A = inputIntList()

    pattern = [0 for _ in range(N + 1)]
    pattern[0] = 3

    ret = 1
    for a in A:
        ret *= pattern[a]
        pattern[a] -= 1
        pattern[a + 1] += 1
        # print(pattern)
    return ret % 1000000007


if __name__ == "__main__":
    print(main())
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    _SP = np.array(SP)
    for i in _SP[:, 2]:
        print(i)


if __name__ == '__main__':
    main()


Fixed submission:
import math


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    for i in map(lambda x: x[2], SP):
        print(i)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    SP = np.array(SP)
    for i in SP[:, 2]:
        print(i)


if __name__ == '__main__':
    main()


Fixed submission:
import math


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    for i in map(lambda x: x[2], SP):
        print(i)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    S = input()
    upper = int(S[:2])
    lower = int(S[2:4])

    if upper > 12 and lower > 12:
        print('NA')

    elif upper > 12 and lower > 0:
        print('YYMM')

    elif lower > 12 and upper > 0:
        print('MMYY')

    elif lower == 0 or upper == 0:
        print('NA')

    else:
        print('AMBIGUOUS')

    else:
        print('NA')


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    S = input()
    upper = int(S[:2])
    lower = int(S[2:4])
    s = ''
    if upper <= 12 and upper > 0:
        s += 'MM'

    else:
        s += 'YY'

    if lower <= 12 and lower > 0:
        s += 'MM'

    else:
        s += 'YY'

    if s == 'MMMM':
        print('AMBIGUOUS')

    elif s == 'YYYY':
        print('NA')

    else:
        print(s)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    cnt = 0
    for r in range(N + 1):
        for g in range(N + 1 - (R * r)):
            if (N - (R * r) - (G * g)) % B == 0 and N - (R * r) - (G * g) >= 0:
                cnt += 1
 
    print(cnt)
 
 
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    cnt = 0
    for r in range(N + 1):
        for g in range(N + 1 - (R * r)):
            if (N - (R * r) - (G * g)) % B == 0 and N - (R * r) - (G * g) >= 0:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
if N == 1:
    print(0)
    exit()
elif N == 2 and (S[0] == '.' and S[1] == '#'):
    print(0)
    exit()
else:
    S = S[0] + S + S[N - 1]
    S = list(S)
    for n in range(N):
        if S[n] == '.' and S[n + 2] == '.' and S[n + 1] == '#':
            ans += 1
            S[n + 1] = '.'
        elif S[n] == '#' and S[n + 2] == '#' and S[n + 1] == '.':
            ans += 1
            S[S + 1] = '#'
print(ans)


Fixed submission:
N = int(input())
S = input()
ans = N
sumB = [0] * (N + 1)
tmp = 0
for i in range(N):
    if S[i] == '#':
        tmp += 1
    sumB[i+1] = tmp
for i in range(N+1):
    ans = min(sumB[i] + (N - i) - (sumB[N] - sumB[i]), ans)
    # print(sumB[i] , (N - i), (sumB[N] - sumB[i]), ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
if N == 1:
    print(0)
    exit()
elif N == 2 and (S[0] == '#' and S[1] == '.'):
    print(1)
    exit()
else:
    S = '#' + S + '#'
    for n in range(N+1):
        if S[n] == '.' and S[n + 2] == '.' and S[n + 1] == '#':
            ans += 1
        elif S[n] == '#' and S[n + 2] == '#' and S[n + 1] == '.':
            ans += 1
print(ans)


Fixed submission:
N = int(input())
S = input()
ans = N
sumB = [0] * (N + 1)
tmp = 0
for i in range(N):
    if S[i] == '#':
        tmp += 1
    sumB[i+1] = tmp
for i in range(N+1):
    ans = min(sumB[i] + (N - i) - (sumB[N] - sumB[i]), ans)
    # print(sumB[i] , (N - i), (sumB[N] - sumB[i]), ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M, C = map(int, raw_input().split())
B = map(int , raw_input().split())
ans = 0
for i in range(0, N):
    A = map(int , raw_input().split())
    tmp = [A[m] * B[m] for m in range(M)]

    if sum(tmp) + c > 0:
        ans+=1

print(ans)


Fixed submission:
N, M, C = map(int, raw_input().split())
B = map(int , raw_input().split())
ans = 0
for i in range(0, N):
    A = map(int , raw_input().split())
    tmp = [A[m] * B[m] for m in range(M)]

    if sum(tmp) + C > 0:
        ans+=1

print(ans)