Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
bits = ''.join(input() for _ in range(h))
bits = bits.replace('.', '1').replace('#', '0')
bits = int(bits, 2)
count = 0
     
line_b = (1 << w) - 1
line_t = line_b << w * (h - 1)
line_r = sum(1 << b for b in range(0, h * w, w))
line_l = line_r << w - 1
while bits:
    mask_t = (bits << w) | line_b
    mask_b = (bits >> w) | line_t
    mask_l = (bits << 1) | line_r
    mask_r = (bits >> 1) | line_l
    bits &= mask_t & mask_b & mask_l & mask_r
    count += 1
print(count)


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

a = ''.join(input() + '#' for _ in range(h))
a = a.replace('.', '1').replace('#', '0')

bits = int(a, 2)

w1 = w + 1
h1 = h + 1
bits <<= w1

frame = (1 << w1) - 1
frame |= frame << h1 * w1
frame |= sum(1 << b for b in range(w1, h1 * w1, w1))

count = 0
while bits:
    count += 1
    mask = bits | frame
    #       up             down           left          right
    bits &= (mask << w1) & (mask >> w1) & (mask << 1) & (mask >> 1)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
hw = h * w
if hw == 1:
    print(0)
    exit()
a = ''.join(input() for _ in range(h))
a = ''.join(map(lambda c: '0' if c == '#' else '1', a))
bits = int(a, 2)
count = 0

line_b = (1 << w) - 1
line_t = line_b << w * (h - 1)
line_r = sum(1 << b for b in range(0, hw, w))
line_l = line_r << w - 1
while bits:
    mask_t = (bits << w) | line_b
    mask_b = (bits >> w) | line_t
    mask_l = (bits << 1) | line_r
    mask_r = (bits >> 1) | line_l
    bits &= mask_t & mask_b & mask_l & mask_r
    count += 1
print(count)


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

a = ''.join(input() + '#' for _ in range(h))
a = a.replace('.', '1').replace('#', '0')

bits = int(a, 2)

w1 = w + 1
h1 = h + 1
bits <<= w1

frame = (1 << w1) - 1
frame |= frame << h1 * w1
frame |= sum(1 << b for b in range(w1, h1 * w1, w1))

count = 0
while bits:
    count += 1
    mask = bits | frame
    #       up             down           left          right
    bits &= (mask << w1) & (mask >> w1) & (mask << 1) & (mask >> 1)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
S = input()

i = S.find('#')
if i < 0:
    print(0)
    sys.exit()

a = 0
Min = 200000
for j in range(i, n):
    if S[j:j+1] == '#':
        b = S[j:n].count('.')
        Min = min(Min, a+b)
        a += 1
        
print(Min)

Fixed submission:
n = int(input())
S = input()

c = S.count('.')
Min = c


for j in range(n):
    if S[j] == '#':
        c += 1
    else:
        c -= 1
    Min = min(Min, c)
        
print(Min)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
S = input()

i = S.find('#')
if i < 0:
    print(0)
    sys.exit()

Min = 200000
for j in range(i, n):
    if S[j:j+1] == '#':
        a = S[:j].count('#') 
        b = S[j:n].count('.')
        Min = min(Min, a+b)
        
print(Min)

Fixed submission:
n = int(input())
S = input()

c = S.count('.')
Min = c


for j in range(n):
    if S[j] == '#':
        c += 1
    else:
        c -= 1
    Min = min(Min, c)
        
print(Min)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
dp = np.array([ [0] * (N+1), [0] * (N+1), [0] * (N+1) ])

for i in range(1, N+1):
	a, b, c = map(int, input().split())
	dp[0, i] = dp[1:, i-1].max() + a
	dp[1, i] = dp[::2, i-1].max() + b
	dp[2, i] = dp[:2, i-1].max() + c
	#print('i, dp[i] =',i, dp[:, i])

print(dp[:, N].max())


Fixed submission:
# numpyだとTLE。よって普通の2次元リストで。
# import numpy as np

N = int(input())
# dp = np.array([ [0] * (N+1), [0] * (N+1), [0] * (N+1) ])
dp = [ [0] * (N+1), [0] * (N+1), [0] * (N+1) ]

for i in range(1, N+1):
	a, b, c = map(int, input().split())
	dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a
	dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b
	dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c
	# dp[0, i] = dp[1:, i-1].max() + a
	# dp[1, i] = dp[::2, i-1].max() + b
	# dp[2, i] = dp[:2, i-1].max() + c	
	# print('i, dp[i] =',i, dp[:, i])

#print(dp[:, N].max())
print(max(dp[0][N], dp[1][N], dp[2][N]))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

dp = np.zeros((N+1, W+1), dtype =int)

for i in range(1, N+1):
	w, v = map(int, input().split())
	for sum_w in range(1, W+1):
		if w > sum_w:
			dp[i, sum_w] = dp[i-1, sum_w]
		else:
			dp[i, sum_w] = max(dp[i-1, sum_w], dp[i-1, sum_w - w] + v)
		#print(sum_w, dp)

print(dp.max())

Fixed submission:
import numpy as np

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

dp = np.zeros((N+1, W+1), dtype =int)

for i in range(1, N+1):
    w, v = map(int, input().split())
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.maximum( dp[i-1, w:], dp[i-1, :W+1-w] + v )

print(dp[N,:].max())
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N

def cnt(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(cnt(k)+1, dp[j])
        return dp[j]

print(max([ cnt(i) for i in range(N) ]))


Fixed submission:
import sys
sys.setrecursionlimit(10**5)

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

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N
length = [0] * N

def cnt(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(cnt(k)+1, dp[j])
        return dp[j]

for i in range(N):
    length[i] = cnt(i)

print(max(length))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
 
graph = [ [] for _ in range(N) ]
 
for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)
 
dp = [-1] * N
length = [0] * N
 
def count(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(count(k)+1, dp[j])
        return dp[j]
 
for i in range(N):
    length[i] = count(i)
 
print(max(length))

Fixed submission:
import sys
sys.setrecursionlimit(10**5)

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

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N
length = [0] * N

def cnt(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(cnt(k)+1, dp[j])
        return dp[j]

for i in range(N):
    length[i] = cnt(i)

print(max(length))

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

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N
length = [0] * N

def count(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(count(k)+1, dp[j])
        return dp[j]

for i in range(N):
    length[i] = count(i)

print(max(length))
    


Fixed submission:
import sys
sys.setrecursionlimit(10**5)

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

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N
length = [0] * N

def cnt(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(cnt(k)+1, dp[j])
        return dp[j]

for i in range(N):
    length[i] = cnt(i)

print(max(length))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = -10**14

for i in range(N+1):
    left = sorted(A[:N+i])
    right = sorted(A[N+i:])
    diff = sum(left[i:]) - sum(right[:N])
    ans = max(ans, diff)

print(ans)



Fixed submission:
import heapq

N = int(input())
A = list(map(int, input().split()))
 
L = A[:N]
heapq.heapify(L) 

sum_L = [0] * (N+1)
sum_L[0] = sum(L)

for i in range(N):
    min_L = heapq.heappushpop(L, A[N+i])
    sum_L[i+1] = sum_L[i] + A[N+i] - min_L
    #print(L, i, A[N+i], min_L, sum_L)

R = A[N*2:]
rev_R = list(map(lambda x: x*(-1), R))
heapq.heapify(rev_R) 

sum_R = [0] * (N+1)
sum_R[N] = sum(R)

for i in range(N-1, -1, -1):
    max_R = heapq.heappushpop( rev_R, A[N+i]*(-1) ) * (-1)
    sum_R[i] = sum_R[i+1] + A[N+i] - max_R
    # print(rev_R, i, A[N+i], max_R, sum_R)

ans = -10**14

for i in range(N+1):
    ans = max(ans, sum_L[i] - sum_R[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

ans = []
for i in range(N):
    a, b = map(int, input().split())
    for _ in range(b):
        ans.append(a)

print(sorted(ans)[K-1])

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

A = [0] * 10**5

for i in range(N):
    a, b = map(int, input().split())
    A[a-1] += b

c = 0

for i in range(10**5):
    c += A[i]
    if c >= K:
        break

print(i+1)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

a = []
b = []
c = []
d = []

for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

for j in range(M):
    x, y = map(int, input().split())
    c.append(x)
    d.append(y)

for i in range(N):
    minDist = 10**8 * 2
    for j in range(M):
        dist = abs(c[j]-a[i]) + abs(d[j]-b[i]) 
        if dist < minDist:
            minDist = dist
            ans = j
        
    print(ans+1)


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

a = []
b = []
c = []
d = []

for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

for j in range(M):
    x, y = map(int, input().split())
    c.append(x)
    d.append(y)

for i in range(N):
    ans = 0
    minDist = 10**8 * 2
    for j in range(M):
        dist = abs(c[j]-a[i]) + abs(d[j]-b[i]) 
        if dist < minDist:
            minDist = dist
            ans = j
        
    print(ans+1)
Buggy python submission (verdict: Runtime Error):
N = int(input())

Soinsuu = [1]

for i in range(2, N+1):
    while N % i == 0:
        Soinsuu.append(i)
        N = N // i
    else:
        if N == 1:
            break

Soinsuu.sort(reverse=True)

a = Soinsuu[0]
b = Soinsuu[1]

for i in Soinsuu[2:]:
    if a > b:
        b *= i
    else:
        a *= i
        
print(max(len(str(a)), len(str(b))))


Fixed submission:
import math
N = int(input())
for i in range(1, int(math.sqrt(N))+1):
    if N % i == 0:
        ans = len(str(N//i))
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

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


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

num = 0
for x in range(K+1):
    for y in range(K+1):
#        for z in range(K+1):
#            if x + y + z == S:
        if 0 <= S - x- y <= K:
            num += 1
                
print(num)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = map(int, input().split(" "))
result = 1

for i in range(n):
  viewable = False
  for j in range(i):
    if h[j] > h[i]:
      break
    else if j == i - 1:
      viewable = True
  
  if viewable == True:
    result += 1
    
print("{}".format(result))

Fixed submission:
n = int(input())
h = list(map(int, input().split(" ")))
result = 1

for i in range(n):
  viewable = False
  for j in range(i):
    if h[j] > h[i]:
      break
    elif j == i - 1:
      viewable = True
      
  if viewable == True:
    result += 1

print("{}".format(result))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
B = [abs(i) for i in A]
for i in range(N-1):
    if(A[i]<0):
        A[i] = -A[i]
        A[i+1] = -A[i+1]
if(A[N]<0):
    flag = False
else:
    flag = True

if(flag):
    print(sum(A))
else:
    m = min(B)
    print(sum(B))

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
B = [abs(i) for i in A]
for i in range(N-1):
    if(A[i]<0):
        A[i] = -A[i]
        A[i+1] = -A[i+1]
if(A[N-1]<0):
    flag = False
else:
    flag = True

if(flag):
    print(sum(A))
else:
    m = min(B)
    print(sum(B)-2*m)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
s = input()
t,d = [],[]
for i in range(Q):
    t_next,d_next = input().split()
    t.append(t_next),d.append(d_next)
def golem_out(index):
    golem = [i for i in range(N)]
    for i in range(Q):
        if(s[golem[index]]==t[i]):
            if(d[i]=='R'):
                golem[index] += 1
                if(golem[index]==N):
                    return 'R'
            elif(d[i]=='L'):
                golem[index] -= 1
                if(golem[index]==-1):
                    return 'L'
    return False
#左にそれるゴーレムの数
def count_left():
    left,right = 0,N-1
    if(golem_out(0)!='L'):
        return 0
    if(golem_out(N-1)=='L'):
        return N
    while(right-left>1):
        if(golem_out(int((left+right)/2)) == 'L'):
            left = int((left+right)/2)
        else:
            right = int((left+right)/2)
    return right
def count_right():
    left,right=0,N-1
    if(golem_out(N-1)!='R'):
        return 0
    if(golem_out(0)=='R'):
        return N
    while(right-left>1):
        if(golem_out(int((left+right)/2)) == 'R'):
            right = int((left+right)/2)
        else:
            left = int((left+right)/2)
    return N-1-left
print(N - count_left()-count_right())

Fixed submission:
N,Q = map(int,input().split())
S = '_'+input()+'_'
td = [input().split() for _ in range(Q)]
R = N+1
L = 0
for i in range(Q-1,-1,-1):
    t,d = td[i]
    if t == S[R-1] and d == 'R':
        R -= 1
    elif t == S[R] and d == 'L':
        R += 1
    if t == S[L+1] and d == 'L':
        L += 1
    elif t == S[L] and d == 'R':
        L -= 1
print(max(0,R-L-1))
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
counter = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        counter[i+1] += counter[i] + 1
    else:
        counter[i+1] += counter[i]

for i in range(Q):
    print(counter[r[i]-1] - counter[l[i]-1])

Fixed submission:
def main():
    b = input()
    if(b=='A'):
        return print('T')
    if(b=='T'):
        return print('A')
    if(b=='C'):
        return print('G')
    if(b=='G'):
        return print('C')
main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, Q = map(int, input().split())
    S = input()
    l = [0] * Q
    r = [0] * Q
    for i in range(Q):
        l[i], r[i] = map(int, input().split())
    for i in range(Q):
        count = 0
        sub_S = S[l[i]-1:r[i]]
        for i in range(len(sub_S)-1):
            if(sub_S[i:i+2]=='AC'):
                count = count+1
        print(count)
main()

Fixed submission:
N, Q = map(int, input().split())
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
counter = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        counter[i+1] += counter[i] + 1
    else:
        counter[i+1] += counter[i]

for i in range(Q):
    print(counter[r[i]-1] - counter[l[i]-1])

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, Q = map(int, input().split())
    S = input()
    l = [0] * Q
    r = [0] * Q
    for i in range(Q):
        l[i], r[i] = map(int, input().split())
    count = [S[l[i]-1:r[i]].count('AC') for i in range(Q)]
    for i in range(Q):
        print(count[i])
main()

Fixed submission:
N, Q = map(int, input().split())
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
counter = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        counter[i+1] += counter[i] + 1
    else:
        counter[i+1] += counter[i]

for i in range(Q):
    print(counter[r[i]-1] - counter[l[i]-1])

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, Q = map(int, input().split())
    S = input()
    l = [0] * Q
    r = [0] * Q
    count = []
    for i in range(Q):
        l[i], r[i] = map(int, input().split())
    for i in range(Q):
        sub_S = S[l[i]-1:r[i]]
        print(sub_S.count('AC'))
main()

Fixed submission:
N, Q = map(int, input().split())
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
counter = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        counter[i+1] += counter[i] + 1
    else:
        counter[i+1] += counter[i]

for i in range(Q):
    print(counter[r[i]-1] - counter[l[i]-1])
Buggy python submission (verdict: Runtime Error):
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 10**9

def dfs(cur,a,b,c):
    if(cur == N):
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c)>0 else INF
    ret0 = dfs(cur+1, a, b, c)
    re1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b+l[cur],c)+10
    ret3 = dfs(cur + 1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Fixed submission:
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 10**9

def dfs(cur,a,b,c):
    if(cur == N):
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c)>0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b+l[cur],c)+10
    ret3 = dfs(cur + 1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))
Buggy python submission (verdict: Runtime Error):
A,B = int(input().split())
if(B%A==0):
  print(A+B)
else:
  print(B-A)

Fixed submission:
A,B = map(int, input().split())
if(B%A == 0):
    print(A+B)
else:
    print(B-A)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
def gcd(number):
    return reduce(math.gcd,number)
print(gcd(A))

Fixed submission:
from sys import stdin
from functools import reduce
import fractions
#input = stdin.readline
N = int(input())
A = list(set(map(int,input().split())))
answer = reduce(fractions.gcd, A)
print(answer)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
def gcd(number):
    return reduce(math.gcd,number)
print(gcd(A))

Fixed submission:
from sys import stdin
from functools import reduce
import fractions
#input = stdin.readline
N = int(input())
A = list(set(map(int,input().split())))
answer = reduce(fractions.gcd, A)
print(answer)

Buggy python submission (verdict: Runtime Error):
n = int(input())
2.b = list(map(int,input().split()))
3.b.sort()
4.     
5.d = b[0] + 0
6. 
7.while len(b) > 1 :
8.    for i in range(1,len(b)) :
9.        b[i] = b[i] % b[0]
10.    if b.count(0) == len(b)-1 :
11.        d = b[0]
12.        break
13.    else :
14.        b.sort()
15.        for j in range(b.count(0)) :
16.            b.remove(0)
17.print(d)


Fixed submission:
from sys import stdin
from functools import reduce
import fractions
#input = stdin.readline
N = int(input())
A = list(set(map(int,input().split())))
answer = reduce(fractions.gcd, A)
print(answer)

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

while(1):
    
    for i in range(len(A)-1):
        A[i+1] = A[i+1]%A[0]
        if(A[i+1] ==0):
            del A[i+1]
            A.sort()
            break
    if(len(A)==1):
        break
    A.sort()
print(A[0])

Fixed submission:
from sys import stdin
from functools import reduce
import fractions
#input = stdin.readline
N = int(input())
A = list(set(map(int,input().split())))
answer = reduce(fractions.gcd, A)
print(answer)

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

while(1):
    
    for i in range(len(A)-1):
        A[i+1] = A[i+1]-A[0]
        if(A[i+1] <=0):
            del A[i+1]
            break
    if(len(A)==1):
        break
    A.sort()
print(A[0])

Fixed submission:
from sys import stdin
from functools import reduce
import fractions
#input = stdin.readline
N = int(input())
A = list(set(map(int,input().split())))
answer = reduce(fractions.gcd, A)
print(answer)
Buggy python submission (verdict: Runtime Error):
import collections

def solve():
    n = int(input())
    v = [int(i) for i in input().split()]
    v_odd = [j for i,j in enumerate(v) if i%2==1]
    v_even = [j for i,j in enumerate(v) if i%2==0]

    v_count = collections.Counter(v)
    #すべて同じ数字
    if(len(v_count)==1):
        return print(int(n/2))
    #異なる数字の時
    elif(len(v_count)!=1):
        
        
        v_odd_max = collections.Counter(v_odd).most_common()[0]
        v_even_max = collections.Counter(v_even).most_common()[0]
        if(v_odd_max[0] != v_even_max[0]):
            return print(int(n/2-v_odd_max[1])+int(n/2-v_even_max[1]))
        else:
            a = v_even.most_common()[1]
            return print(int(n/2-v_odd_max[1])+int(n/2-a[1]))
solve()

Fixed submission:
import collections
n = int(input())
v = [int(i) for i in input().split()]
v_even = [v[2*i] for i in range(int(n/2))]
v_odd = [v[2*i-1] for i in range(int(n/2))]
c_even = collections.Counter(v_even)
c_odd = collections.Counter(v_odd)
if(c_even.most_common()[0][0]!=c_odd.most_common()[0][0]):
    print(n - c_even.most_common()[0][1] - c_odd.most_common()[0][1])
elif(len(collections.Counter(v))==1):
    print(int(n/2))
else:
    if(c_even.most_common()[0][1]>c_odd.most_common()[0][1]):
        print(n-c_even.most_common()[0][1] - c_odd.most_common()[1][1])
    elif(c_even.most_common()[0][1]<c_odd.most_common()[0][1]):
        print(n - c_odd.most_common()[0][1] - c_even.most_common()[1][1])
    else:
        print(n - c_odd.most_common()[0][1] - max(c_odd.most_common()[1][1],c_even.most_common()[1][1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())

total = 0
for i in range(1,N+1):
    
    flag = True
    res = 0
    j = i
    while(flag):
        res = res + j%10
        j = int(j/10)
        if(j==0):
            flag = False
    if(A<=res & res<=B):
        total = total + i
print(total)

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

total = 0
for i in range(1,N+1):
    
    flag = True
    res = 0
    j = i
    while(flag):
        res = res + j%10
        j = int(j/10)
        if(j==0):
            flag = False
    if(A<=res & res<=B):
        total = total + i
print(total)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input())
t=s[k]
c=''
for i in range(0,n):
    if s[i] != t:
        c += '*'
    else: c += s[i]

print(c)

Fixed submission:
n=int(input())
s=input()
k=int(input())
t=s[k-1]
c=''
for i in range(0,n):
    if s[i] != t:
        c += '*'
    else: c += s[i]

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

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")

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

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")

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

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")

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

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")

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

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")

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

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
line = input()

ans = N
for i in range(N):
 west = line[:i]
 tmp = west.count('W')
 east = line[i+1:]
 tmp += east.count('E')
 if ans>tmp:
  ans = tmp


print(ans)

Fixed submission:
N = int(input())
line = input()

ans = line[1:N].count('E')
tmp = ans
for i in range(1,N):
 if line[i] == 'E':
  tmp -= 1
 if line[i-1] == 'W':
  tmp += 1
 if ans>tmp:
  ans = tmp

print(ans)