Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# from itertools import product, permutations,combinations
from math import factorial

n = int(input())

# c_hash = {}
c_list = []
# n = 3
for i in range(n):
    s = input()
    c_list.append(''.join(sorted(s)))

# print(sorted(c_list))

c_hash = {}
for c in c_list:
    if c not in c_hash:
        c_hash[c] = 0
    c_hash[c] += 1
count = 0    
for k, v in c_hash.items():
    if v >= 2:

        
        temp = factorial(v) / factorial(2) / factorial(v - 2)
        # temp = len(list(combinations(range(v),2)))
        count += temp

print(round(count))        

Fixed submission:

n = int(input())

# c_hash = {}
c_list = []
# n = 3
for i in range(n):
    s = input()
    c_list.append(''.join(sorted(s)))

# print(sorted(c_list))

c_hash = {}
for c in c_list:
    if c not in c_hash:
        c_hash[c] = 0
    c_hash[c] += 1
count = 0    
for k, v in c_hash.items():
    if v >= 2:

        
        # temp = factorial(v) / factorial(2) / factorial(v - 2)
        # temp = len(list(combinations(range(v),2)))
        temp = v * (v-1)/ 2
        count += temp

print(int(count))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product, permutations,combinations

n = int(input())

# c_hash = {}
c_list = []
# n = 3
for i in range(n):
    s = input()
    c_list.append(''.join(sorted(s)))

# print(sorted(c_list))

c_hash = {}
for c in c_list:
    if c not in c_hash:
        c_hash[c] = 0
    c_hash[c] += 1
count = 0    
for k, v in c_hash.items():
    if v >= 2:
        temp = len(list(combinations(range(v),2)))
        count += temp

print(count)        

Fixed submission:

n = int(input())

# c_hash = {}
c_list = []
# n = 3
for i in range(n):
    s = input()
    c_list.append(''.join(sorted(s)))

# print(sorted(c_list))

c_hash = {}
for c in c_list:
    if c not in c_hash:
        c_hash[c] = 0
    c_hash[c] += 1
count = 0    
for k, v in c_hash.items():
    if v >= 2:

        
        # temp = factorial(v) / factorial(2) / factorial(v - 2)
        # temp = len(list(combinations(range(v),2)))
        temp = v * (v-1)/ 2
        count += temp

print(int(count))
Buggy python submission (verdict: Time Limit Exceeded):
def calc_total_reward(m, data):
    
    # day_to_rewardsをset
    day_to_rewards = {}
    for row in data:
        day = row['day']
        reward = row['reward']
        if day not in day_to_rewards:
            day_to_rewards[day] = []
        day_to_rewards[day].append(row['reward'])

    for day, reward_list in day_to_rewards.items():
        day_to_rewards[day] = sorted(reward_list)

    total_reward = 0
    for day in range(1, m+1) :
        max_reward_day = None
        
        for day2 in range(1, day+1):
             if day2 in day_to_rewards and len(day_to_rewards[day2]) > 0:
                    
                # 初期化
                if max_reward_day is None:
                    max_reward_day = day2

                # max 更新
                reward = day_to_rewards[day2][-1]
                if reward > day_to_rewards[max_reward_day][-1]:
                    max_reward_day = day2
        
        if max_reward_day is not None:
            total_reward += day_to_rewards[max_reward_day].pop()
        
#         while work_day > 0:
#             if work_day in day_to_rewards and len(day_to_rewards[work_day]) > 0:

#                 reward = day_to_rewards[work_day].pop()
#                 total_reward += reward
#                 print('find', work_day, reward)
#                 break
#             else:
#                 print('not find')
#                 work_day -= 1
#         print(day)
    return total_reward

n, m = map(int, input().split())

data = []
for i in range(n):
    day, reward = map(int, input().split())
    data.append({
        'day': day,
        'reward': reward
    })

total_reward = calc_total_reward(m, data)    
print(total_reward)    

Fixed submission:
import sys
import heapq

N, M = list(map(int, input().split()))
jobs = []
for line in sys.stdin:
    A, B = map(int, line.split())
    if A > M:
        continue
    jobs.append((A, B))

jobs.sort(reverse=True)

q = []
ans = 0
for i in range(1, M + 1):
    while jobs and jobs[-1][0] <= i:
        A, B = jobs.pop()
        heapq.heappush(q, -B)

    if q:
        ans += -heapq.heappop(q)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
L = [list(map(str,input().split())) for i in range(Q)]

cnt = 0
FR = ""
BA = ""

for i in range(Q):
    if len(L[i]) == 1:
        cnt += 1
    else:
        if (int(L[i][1])+cnt)%2 == 0:
            BA = BA + L[i][2]
        else:
            FR = L[i][2]+FR

if cnt%2 == 0:
    print(FR+S+BA)
else:
    new_S = ''.join(list(reversed(FR+S+BA)))
    print(new_S)

Fixed submission:
S = input()
Q = int(input())
L = [list(map(str,input().split())) for i in range(Q)]

cnt = 0
FR = ""
BA = ""

for i in range(Q):
    if len(L[i]) == 1:
        cnt += 1
    else:
        if (int(L[i][1])+cnt)%2 == 0:
            BA = BA + L[i][2]
        else:
            FR = L[i][2]+FR

if cnt%2 == 0:
    print(FR+S+BA)
else:
    new_S = ''.join(list(reversed(FR+S+BA)))
    print(new_S)

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

cnt = 0

for i in range(Q):
    if len(L[i]) == 1:
        cnt += 1
    else:
        if (int(L[i][1])+cnt)%2 == 0:
            S = S+L[i][2]
        else:
            S = L[i][2]+S

if cnt%2 == 0:
    print(S)
else:
    new_S = ''.join(list(reversed(S)))
    print(new_S)

Fixed submission:
S = input()
Q = int(input())
L = [list(map(str,input().split())) for i in range(Q)]

cnt = 0
FR = ""
BA = ""

for i in range(Q):
    if len(L[i]) == 1:
        cnt += 1
    else:
        if (int(L[i][1])+cnt)%2 == 0:
            BA = BA + L[i][2]
        else:
            FR = L[i][2]+FR

if cnt%2 == 0:
    print(FR+S+BA)
else:
    new_S = ''.join(list(reversed(FR+S+BA)))
    print(new_S)

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

cnt = 0

for i in range(Q):
    if len(L[i]) == 1:
        cnt += 1
    else:
        if (int(L[i][1])+cnt)%2 == 0:
            S = S+L[i][2]
        else:
            S = L[i][2]+S

if cnt%2 == 0:
    print(S)
else:
    new_S = ''.join(list(reversed(S)))
    print(new_S)

Fixed submission:
S = input()
Q = int(input())
L = [list(map(str,input().split())) for i in range(Q)]

cnt = 0
FR = ""
BA = ""

for i in range(Q):
    if len(L[i]) == 1:
        cnt += 1
    else:
        if (int(L[i][1])+cnt)%2 == 0:
            BA = BA + L[i][2]
        else:
            FR = L[i][2]+FR

if cnt%2 == 0:
    print(FR+S+BA)
else:
    new_S = ''.join(list(reversed(FR+S+BA)))
    print(new_S)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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

E = [0 for i in range(max(K)-min(K))]

for i in range(max(K)-min(K)):
    E[i] = 0
    for x in K:
        E[i] += (x-(i+min(K)))**2

print(min(E))

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

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

E = [0 for i in range(100)]

for i in range(100):
    E[i] = 0
    for x in K:
        E[i] += (x-i)**2

print(min(E))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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

E = [0 for i in range(max(K)-min(K))]

for i in range(max(K)-min(K)):
    E[i] = 0
    for x in K:
        E[i] += (x-(i+min(K)))**2

print(min(E))

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

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

E = [0 for i in range(100)]

for i in range(100):
    E[i] = 0
    for x in K:
        E[i] += (x-i)**2

print(min(E))
Buggy python submission (verdict: Runtime Error):
import sys

T, X = sys.argv[1], sys.argv[2]
T, X = int(T), int(X)
time = T/X
print(time)

Fixed submission:
T, X = [int(_) for _ in input().split()]
T, X = int(T), int(X)
time = T/X
print(time)
Buggy python submission (verdict: Runtime Error):
input_line = int(input())
for i in range(input_line):
  s = input().rstrip().split(' ')
  print("hello = "+s[0]+" , world = "+s[1])

Fixed submission:
s = input().split()

K = int(s[0])
N = int(s[1])

if K >= 10:
  print(N)
else:
  print(N + 100*(10-K))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
d = a*c
if d%2 == 0:
  print("No")
else:
  print("Yes")


Fixed submission:
a, b = map(int, input().split())
d = a*b
if d%2 == 0:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Query = [input().split() for i in range(Q)]

ans = S
mode = True  # True: Normal False: Reverse
for query in Query:
    T = query[0]
    if T == '1':
        # モードを反転
        mode = not mode
    else:
        F = query[1]
        if (mode and (F == '1')) or (not mode and (F == '2')):
            ans = query[2] + ans
        else:
            ans = ans + query[2]
    
if not mode:
    ans = ans[::-1]

print(ans)

Fixed submission:
S = input()
Q = int(input())
Query = [input().split() for i in range(Q)]

mode = True  # True: Normal False: Reverse
pre = []
aft = []
for query in Query:
    if query[0] == '1':
        # モードを反転
        mode = not mode
    else:
        if (mode and (query[1] == '1')) or (not mode and (query[1] == '2')):
            pre.append(query[2])
        else:
            aft.append(query[2])
    
ans = ''.join(pre[::-1]) +  S + ''.join(aft)
    
if not mode:
    ans = ans[::-1]
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Query = [input().split() for i in range(Q)]

ans = S
mode = True  # True: Normal False: Reverse
for query in Query:
    T = query[0]
    if T == '1':
        # モードを反転
        mode = not mode
    else:
        F = query[1]
        if (mode and (F == '1')) or (not mode and (F == '2')):
            ans = query[2] + ans
        else:
            ans = ans + query[2]
    
if not mode:
    ans = ans[::-1]

print(ans)

Fixed submission:
S = input()
Q = int(input())
Query = [input().split() for i in range(Q)]

mode = True  # True: Normal False: Reverse
pre = []
aft = []
for query in Query:
    if query[0] == '1':
        # モードを反転
        mode = not mode
    else:
        if (mode and (query[1] == '1')) or (not mode and (query[1] == '2')):
            pre.append(query[2])
        else:
            aft.append(query[2])
    
ans = ''.join(pre[::-1]) +  S + ''.join(aft)
    
if not mode:
    ans = ans[::-1]
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Query = [input().split() for i in range(Q)]

ans = S
for query in Query:
    T = query[0]
    if T == '1':
        # Sの前後を反転
        ans = ans[::-1]
    else:
        F = query[1]
        if F == '1':
            # 文字列Sの先頭にCを追加
            ans = query[2] + ans
        else:
            # 文字列Sの末尾にCを追加
            ans = ans + query[2]

print(ans)

Fixed submission:
S = input()
Q = int(input())
Query = [input().split() for i in range(Q)]

mode = True  # True: Normal False: Reverse
pre = []
aft = []
for query in Query:
    if query[0] == '1':
        # モードを反転
        mode = not mode
    else:
        if (mode and (query[1] == '1')) or (not mode and (query[1] == '2')):
            pre.append(query[2])
        else:
            aft.append(query[2])
    
ans = ''.join(pre[::-1]) +  S + ''.join(aft)
    
if not mode:
    ans = ans[::-1]
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H = int(input())

lst = [H]
cnt = 0
while len(lst) > 0:
    cnt += 1
    mon = lst.pop()
    if mon == 1:
        continue
    else:
        new_mon = (mon // 2)
        lst.append(new_mon)
        lst.append(new_mon)
        
print(cnt)

Fixed submission:
H = int(input())

import math
n = int(math.log(H, 2))

ans = 0
for i in range(n + 1):
    ans += pow(2, i)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [int(p_) for p_ in input().split()]

ans = [1]
for i in range(1, len(P)):
    #print(i+1, P[0:i], min(P[0:i]), P[i])
    if P[i] <= min(P[0:i]):
        ans.append(i+1)
        
print(len(ans))

Fixed submission:
N = int(input())
P = [int(p_) for p_ in input().split()]

ans = [1]
mini = P[0] 
for i in range(1, len(P)):
    if mini > P[i]:
        mini = P[i]
        ans.append(i+1)

print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [int(p_) for p_ in input().split()]

ans = [1]
for i in range(1, len(P)):
    #print(i+1, P[0:i], min(P[0:i]), P[i])
    if P[i] <= min(P[0:i]):
        ans.append(i+1)
        
print(len(ans))

Fixed submission:
N = int(input())
P = [int(p_) for p_ in input().split()]

ans = [1]
mini = P[0] 
for i in range(1, len(P)):
    if mini > P[i]:
        mini = P[i]
        ans.append(i+1)

print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [list(map(int, input().split())) for _ in range(N)]

P.sort(key=lambda x: x[0]+x[1])

leave = []
for i in range(N):
    # ロボットpiが既に残すと決めたロボットに重ならないことをチェック
    # print('Checking Robot P{}: {}'.format(i, P[i])) 
    # print('S:{} P:{} T:{}'.format(P[i][0]-P[i][1], P[i][0] , P[i][0]+P[i][1]))
    
    if len(list([leave_ for leave_ in leave if leave_[0] + leave_[1] > P[i][0] - P[i][1]])) == 0:
        leave.append(P[i])
        #print(leave)
    else:
        #print('Not Added')
        #print(leave)
        continue

print(len(leave))

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

P.sort(key=lambda x: x[0]+x[1])

leave = [P[0]]
for i in range(1, N):
    # leaveの最大を取得
    leave_max = leave[-1][0] + leave[-1][1]
    p_min = P[i][0] - P[i][1]
    if leave_max <= p_min:
        leave.append(P[i])
    else:
        continue
        
print(len(leave))
Buggy python submission (verdict: Runtime Error):
N, A, B = (int(i) for i in input().split())

def f(A, B):
  return int((B - A) / 2)
  
def f2(N, A, B):
    if (B - A) % 2 == 0:
        ans = f(A, B)
    else:
        # Aが1に向かうとき
        ans_a = A + f(1, B - A)
        # BがNに向かうとき
        if (A + N - B +1) <  N:
            ans_b = (N - B + 1) + f(A + N - B +1, N)
            ans_b = N
            
        ans = min(ans_a, ans_b)
    
    return ans
  
print(f2(N, A, B))

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

t = float('inf')
if abs(A - B) % 2 == 0:
    t = min(abs(A - B) // 2, t)
    
t = min(B - 1, t)
t = min(N - A, t)
t = min((A - 1 + 1) + (B - A - 1) // 2, t)
t = min((N - B + 1) + (N - (A + (N - B + 1))) // 2, t)

print(t)
Buggy python submission (verdict: Runtime Error):
A, B  = (int(i) for i in input().split())

import math

print((A * B) // math.gcd(A, B))

Fixed submission:
A, B  = (int(i) for i in input().split())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
  
print((A * B) // gcd(A, B))
Buggy python submission (verdict: Runtime Error):
n = (int(i) for i in input().split()) 

if (n*100 // 108) == (n*100 / 108):
  print((n*100 // 108))
else:
  print(':(')

Fixed submission:
import math

n = int(input())

nontax = math.floor(n / 1.08)

if math.floor(nontax * 1.08) == n:
    print(nontax)
elif math.floor((nontax + 1) * 1.08) == n:
    print(nontax+1)
else:
    print(':(')

Buggy python submission (verdict: Runtime Error):
n = (int(i) for i in input().split())  

if (n // 1.08) == (n % 1.08):
  print(int(n // 1.08))
else:
  print(':(')


Fixed submission:
import math

n = int(input())

nontax = math.floor(n / 1.08)

if math.floor(nontax * 1.08) == n:
    print(nontax)
elif math.floor((nontax + 1) * 1.08) == n:
    print(nontax+1)
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
import numpy as np
 
a, b, c = map(int, input().split())

if c - a - b > 0 and 4 * a * b < (c - a - b)**2:
  print("Yes")
else:
  print("No")


Fixed submission:
a, b, c = map(int, input().split())
 
if c - a - b > 0 and 4 * a * b < (c - a - b)**2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
num_rev = 0

for i in range(Q):
  inp = input()
  if len(inp) == 1:
    num_rev += 1
  else:
    T, F, C = inp.split()
    if ((num_rev % 2 == 0) and int(F) == 1) or ((num_rev % 2 == 1) and int(F) == 2):
      S = C + S
    else:
      S = S + C

if num_rev % 2 == 0:
  print(S)
else:
  print(S[::-1])


Fixed submission:
S = input()
Q = int(input())
num_rev = 0
S_front = [""] * Q
S_back = [""] * Q
 
for i in range(Q):
  inp = input()
  if len(inp) == 1:
    num_rev += 1
  else:
    T, F, C = inp.split()
    if ((num_rev % 2 == 0) and int(F) == 1) or ((num_rev % 2 == 1) and int(F) == 2):
      S_front[i] = C
    else:
      S_back[i] = C

S = "".join(S_front)[::-1] + S + "".join(S_back)
if num_rev % 2 == 0:
  print(S)
else:
  print(S[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
T = [0] * Q
F = [0] * Q
C = [0] * Q
for i in range(Q):
  inp = input()
  if len(inp) == 1:
    S = S[::-1]
  else:
    T[i], F[i], C[i] = inp.split()
    if int(F[i]) == 1:
      S = C[i] + S
    else:
      S = S + C[i]

print(S)

Fixed submission:
S = input()
Q = int(input())
num_rev = 0
S_front = [""] * Q
S_back = [""] * Q
 
for i in range(Q):
  inp = input()
  if len(inp) == 1:
    num_rev += 1
  else:
    T, F, C = inp.split()
    if ((num_rev % 2 == 0) and int(F) == 1) or ((num_rev % 2 == 1) and int(F) == 2):
      S_front[i] = C
    else:
      S_back[i] = C

S = "".join(S_front)[::-1] + S + "".join(S_back)
if num_rev % 2 == 0:
  print(S)
else:
  print(S[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]
A = np.array(A)
B = np.zeros(N)
list_B = [0] * N

for i in range(N)[::-1]:
  if A[i] != (np.sum(B[i::i+1]) % 2):
    B[i] = 1
    list_B[i] = i + 1

print(int(np.sum(B)))
list_B = ' '.join([str(a) for a in [i for i in list_B if i != 0]])
print(list_B)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
B = [0] * N
list_B = [0] * N

for i in range(N)[::-1]:
  if A[i] != (sum(B[i::i+1]) % 2):
    B[i] = 1
    list_B[i] = i + 1

print(int(sum(B)))
list_B = ' '.join([str(a) for a in [i for i in list_B if i != 0]])
print(list_B)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, D = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for m in range(N)]
X = np.array(X)
l = 0

for i in range(N):
  for j in range(i+1, N):
    if sum((X[i] - X[j])**2)**0.5 % 1 == 0:
      l += 1

print(l)

Fixed submission:
import numpy as np

N, D = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for m in range(N)]
X = np.array(X)
l = 0

for i in range(N):
  for j in range(i+1, N):
    if sum((X[i] - X[j])**2)**0.5 % 1 == 0:
      l += 1

print(l)
Buggy python submission (verdict: Runtime Error):
import math
import fractions

A, B, C, D = map(int, input().split())
E = (C * D) // fractions.gcd(C, D)
count_div = 0

n_ = (A-1) // C
n = math.ceil(A / C) - 1
m = B // C
if m >= n:
  count_div += m - n

l_ = (A-1) // D
l = math.ceil(A / D) - 1
k = B // D
if k >= l:
  count_div += k - l

j_ = (A-1) // E
j = math.ceil(A / E) - 1
i = B // E
if i >= j:
  count_div -= i - j

if (n_ != n) or (l_ != l) or (j_ != j):
  sleep(2)
else:
  print(B - A + 1 - count_div)

Fixed submission:
import math
import fractions

A, B, C, D = map(int, input().split())
E = (C * D) // fractions.gcd(C, D)
count_div = 0
 
n = (A-1) // C
m = B // C
count_div += m - n

l = (A-1) // D
k = B // D
count_div += k - l

j = (A-1) // E
i = B // E
count_div -= i - j

print(B - A + 1 - count_div)
Buggy python submission (verdict: Runtime Error):
N = int(input()) 
W = list(map(int, input().split()))
x = sum(W)

for i in range(N):
	S_1 = sum(W[:i+1])
	S_2 = sum(W) - S_1
    x_current = abs(S_2 - S_1)
    if x_current < x:
      x = x_current

print(x)

Fixed submission:
N = int(input()) 
W = list(map(int, input().split()))
x = sum(W)
 
for i in range(N):
	S_1 = sum(W[:i+1])
	S_2 = sum(W) - S_1
	x_current = abs(S_2 - S_1)
	if x_current < x:
		x = x_current

print(x)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
# import math
import numpy as np
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

N = int(stdin.readline().rstrip().split()[0])
S = stdin.readline().rstrip().split()[0]

white = S.count(".")
ans1=0
if white == N:
  ans1=0
else:
  first_black = S.index("#")
  ans1 = white - first_black
  
ans2=0
black = N-white
last_white = S[::-1].index(".")
ans2=black-last_white

if ans1>ans2:
  print(ans2)
else:
  print(ans1)


Fixed submission:
from sys import stdin
# import math
import numpy as np
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

N = int(stdin.readline().rstrip().split()[0])
S = stdin.readline().rstrip().split()[0]

B =[]
W =[]
b=0
w=0
for i in range(N):
  if S[i]==".":
    w+=1
  W.append(w)
  
  if S[N-1-i]=="#":
    b+=1
  B.append(b)

W=np.array(W)
B=np.array(B[::-1])
ans = N-np.max(W+B)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
# import math
# import numpy as np
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
N, K = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip().split()[0]

B = []
count = 0
oz = 1
for s in S:
  if int(s) == oz:
    count+=1
  else:
    B.append(count)
    count=1
    oz=int(s)
B.append(count)
if oz==0:
  B.append(0)
# print(B)
L = len(B)
if 2*K+1>L:
  K = int(L/2)
# print("K",K)
C = []
for i in range(L):
  start = 2*i
  last = 2*i+2*K+1
  if last>L:
    # print("break",last)
    break
  C.append(sum(B[start:last]))
# print(C)
ans = max(C)
print(ans)


Fixed submission:
from sys import stdin
# import math
import numpy as np
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
N, K = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip().split()[0]

B = [0]
count = 0
oz = 1
for s in S:
  if int(s) == oz:
    count+=1
  else:
    B.append(count)
    count=1
    oz=int(s)
B.append(count)
if oz==0:
  B.append(0)
# print(B)
L = len(B)-1
if 2*K+1>L:
  K = int(L/2)
# print("K",K)
B = np.cumsum(B)
# print(B)
C = []
for i in range(L):
  start = 2*i
  last = 2*i+2*K+1
  if last>L:
    # print("break",last)
    break
  C.append(B[last]-B[start])
# print(C)
ans = max(C)
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

def LCM(_a, _b):
  if _a < _b:
    a, b = _b, _a
  else:
    a, b = _a, _b
  while True:
    c = a%b
    if c==0:
      break
    a,b = b,c
  return (_a*_b)//b

def func(a_list):
  size = len(a_list)
  if size ==2:
    return LCM(a_list[0],a_list[1])
  else:
    return LCM(a_list[0], func(a_list[1:]))

lcm_1 = func(A)-1
print(sum(list(map(lambda x: lcm_1%x, A))))

Fixed submission:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

print(sum(A)-len(A))
Buggy python submission (verdict: Runtime Error):
S, T = map(input().split())
print(T+S)

Fixed submission:
S, T = input().split()
print(T+S)