Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
N, M = map(int, input().split())
A = sorted(map(int, input().split()))
for _ in range(M):
    b, c = map(int, sys.stdin.readline().split())
    x = bisect.bisect_left(A, c)
    y = min(x, b)
    A = [c] * y + A[y:]
    if x != y:
        A.sort()
print(sum(A))

Fixed submission:
import sys
import bisect
N, M = map(int, input().split())
A = sorted(map(int, input().split()))
CB = [None] * M
for i in range(M):
    b, c = map(int, sys.stdin.readline().split())
    CB[i] = (c, b)
CB.sort(reverse=True)

i = 0
ans = 0
for c, b in CB:
    x = bisect.bisect_left(A, c, i)
    count = min(x - i, b)
    ans += c * count
    i += count
for j in range(i, N):
    ans += A[j]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
H, W = map(int, input().split())
m = [[0] * (W + 1) for _ in range(H + 1)]
todo = deque()
for h in range(H):
    for w, c in enumerate(input()):
        if c == ".":
            m[h][w] = -1
        else:
            todo.append((h, w))
ans = 0
while todo:
    h, w = todo.popleft()
    count = m[h][w] + 1
    for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nh = h + dh
        nw = w + dw
        if m[nh][nw] == -1:
            m[nh][nw] = count
            todo.append((nh, nw))
            ans = count
print(ans)

Fixed submission:
from collections import deque
H, W = map(int, input().split())
m = [[-1 if c == "." else 0 for c in input() + "#"] for _ in range(H)]
m.append([0] * (W + 1))
todo = deque(((h, w) for h in range(H) for w in range(W) if m[h][w] == 0))
ans = 0
while todo:
    h, w = todo.popleft()
    count = m[h][w] + 1
    for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nh = h + dh
        nw = w + dw
        if m[nh][nw] == -1:
            m[nh][nw] = count
            todo.append((nh, nw))
            ans = count
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
H, W = map(int, input().split())
m = [[-1 if c == "." else 0 for c in input() + "#"] for _ in range(H)]
m.append([0] * (W + 1))
todo = deque(((h, w) for h in range(H) for w in range(W) if m[h][w] == 0))
ans = 0
while todo:
    h, w = todo.popleft()
    count = m[h][w] + 1
    for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nh = h + dh
        nw = w + dw
        if m[nh][nw] == -1:
            m[nh][nw] = count
            todo.append((nh, nw))
            ans = count
print(ans)

Fixed submission:
from collections import deque
H, W = map(int, input().split())
m = [[-1 if c == "." else 0 for c in input() + "#"] for _ in range(H)]
m.append([0] * (W + 1))
todo = deque(((h, w) for h in range(H) for w in range(W) if m[h][w] == 0))
ans = 0
while todo:
    h, w = todo.popleft()
    count = m[h][w] + 1
    for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nh = h + dh
        nw = w + dw
        if m[nh][nw] == -1:
            m[nh][nw] = count
            todo.append((nh, nw))
            ans = count
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    raise RuntimeError()

for k in range(2, N + 1):
    sn = k - 1
    if k * sn != 2 * N:
        continue

    print("Yes")
    print(k)
    s = [[0] * sn for _ in range(sn)]
    for i in range(sn):
        s[i][i] = s[i-1][i-1] + (i + 1)
        for j in range(i + 1, sn):
            s[i][j] = s[i][j-1] + j
            s[j][i] = s[i][j]
    s.append([s[i][i] for i in range(sn)])
    for x in s:
        print(sn, " ".join(map(str, x)))
    break
else:
    print("No")

Fixed submission:
N = int(input())
for k in range(1, N + 2):
    sn = k - 1
    if k * sn != 2 * N:
        continue

    print("Yes")
    print(k)
    s = [[0] * sn for _ in range(sn)]
    for i in range(sn):
        s[i][i] = s[i-1][i-1] + (i + 1)
        for j in range(i + 1, sn):
            s[i][j] = s[i][j-1] + j
            s[j][i] = s[i][j]
    s.append([s[i][i] for i in range(sn)])
    for x in s:
        print(sn, " ".join(map(str, x)))
    break
else:
    print("No")

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

for k in range(2, N + 1):
    slen = k - 1
    if k * slen == 2 * N:
        print("Yes")
        print(k)
        x = [0] * N
        for i in range(k):
            s = [None] * slen
            for j in range(slen):
                n = (i + j) % N
                if x[n] < 2:
                    s[j] = str(n)
                    x[n] += 1
            print(slen, " ".join(s))
        break
else:
    print("No")

Fixed submission:
N = int(input())
for k in range(1, N + 2):
    sn = k - 1
    if k * sn != 2 * N:
        continue

    print("Yes")
    print(k)
    s = [[0] * sn for _ in range(sn)]
    for i in range(sn):
        s[i][i] = s[i-1][i-1] + (i + 1)
        for j in range(i + 1, sn):
            s[i][j] = s[i][j-1] + j
            s[j][i] = s[i][j]
    s.append([s[i][i] for i in range(sn)])
    for x in s:
        print(sn, " ".join(map(str, x)))
    break
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
N, M, Q = map(int, readline().split())
X = [[0] * N for _ in range(N)]
for _ in range(M):
    l, r = map(int, readline().split())
    X[l-1][r-1] += 1

S = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(N):
        S[i+1][j+1] = S[i+1][j] + X[i][j]

for _ in range(Q):
    p, q = map(int, readline().split())
    p -= 1
    q -= 1
    ans = sum(S[i][q+1] - S[i][p] for i in range(p + 1, q + 2))
    print(ans)

Fixed submission:
import sys
readline = sys.stdin.readline
N, M, Q = map(int, readline().split())
X = [[0] * N for _ in range(N)]
for _ in range(M):
    l, r = map(int, readline().split())
    X[l-1][r-1] += 1

S = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(N):
        S[i+1][j+1] = S[i+1][j] + X[i][j]

for _ in range(Q):
    p, q = map(int, readline().split())
    p -= 1
    q -= 1
    ans = sum(S[i][q+1] - S[i][p] for i in range(p + 1, q + 2))
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
result = N
for i in range(N):
    r = S[:i].count("W") + S[i+1:].count("E")
    if r < result:
        result = r
print(result)

Fixed submission:
N = int(input())
S = input()
left_w_count = 0
right_e_count = S[1:].count("E")
result = right_e_count
for i in range(1, N):
    if S[i - 1] == "W":
        left_w_count += 1
    if S[i] == "E":
        right_e_count -= 1
    r = left_w_count + right_e_count
    if r < result:
        result = r
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
result = min([ S[:i].count("W") + S[i+1:].count("E") for i in range(N) ])
print(result)

Fixed submission:
N = int(input())
S = input()
left_w_count = 0
right_e_count = S[1:].count("E")
result = right_e_count
for i in range(1, N):
    if S[i - 1] == "W":
        left_w_count += 1
    if S[i] == "E":
        right_e_count -= 1
    r = left_w_count + right_e_count
    if r < result:
        result = r
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from functools import lru_cache
Q = int(input())
LR = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]

@lru_cache(maxsize=None)
def isprime(x):
    if x == 1:
        return False
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True

like = [False] * (10 ** 5 + 1)
for x in range(1, len(like), 2):
    like[x] = isprime(x) and isprime((x + 1) // 2)

for l, r in LR:
    ans = len([1 for x in like[l:r+1] if x])
    print(ans)

Fixed submission:
import sys
from functools import lru_cache
Q = int(input())
LR = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]

@lru_cache(maxsize=None)
def isprime(x):
    if x == 1:
        return False
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True

s = [0] * (10 ** 5 + 1)
for x in range(1, len(s)):
    s[x] = s[x-1]
    if isprime(x) and isprime((x + 1) // 2):
        s[x] += 1

for l, r in LR:
    ans = s[r] - s[l-1]
    print(ans)

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

@lru_cache(maxsize=None)
def isprime(x):
    if x == 1:
        return False
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True

Q = int(input())
for _ in range(Q):
    l, r = map(int, sys.stdin.readline().split())
    ans = 0
    for x in range(l, r + 1, 2):
        if isprime(x) and isprime((x + 1) // 2):
            ans += 1
    print(ans)

Fixed submission:
import sys
from functools import lru_cache
Q = int(input())
LR = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]

@lru_cache(maxsize=None)
def isprime(x):
    if x == 1:
        return False
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True

s = [0] * (10 ** 5 + 1)
for x in range(1, len(s)):
    s[x] = s[x-1]
    if isprime(x) and isprime((x + 1) // 2):
        s[x] += 1

for l, r in LR:
    ans = s[r] - s[l-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

m = 10 ** 9 + 7

sum = 0

for i in range(n):
  for j in range(i+1, n):
    sum += a[i] * a[j]
    sum %= m

print(sum)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = 10 ** 9 + 7
s = sum(a) % m


sum = 0

for i in range(n):
  s -= a[i]
  if s < 0:
    s += m
  sum += a[i] * s
  sum %= m

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

cur_m = 1000
cur_s = 0

state = -1 # 1:up 0:down
prev = 0
for ai in a:
  if state == -1:
    prev = ai
    state = 0
  elif state == 1:
    if prev > ai: # peak
      # sell at prev
      cur_m += (prev * cur_s)
      cur_s = 0
      state = 0
  else:
    if prev <= ai:
      # buy at prev
      while cur_m >= prev:
        cur_s += 1
        cur_m -= prev
      state = 1
  prev = ai

if cur_s > 0:
  cur_m += (a[-1] * cur_s)

print(cur_m)





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

cur_m = 1000
cur_s = 0

state = -1 # 1:up 0:down
prev = 0
for ai in a:
  if state == -1:
    prev = ai
    state = 0
  elif state == 1:
    if prev > ai: # peak
      # sell at prev
      cur_m += (prev * cur_s)
      cur_s = 0
      state = 0
  else:
    if prev < ai:
      # buy at prev
      buy_num = cur_m // prev
      cur_s += buy_num
      cur_m -= prev * buy_num
      state = 1
  prev = ai

if cur_s > 0:
  cur_m += (a[-1] * cur_s)

print(cur_m)
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = [0] * 10010

# x = y = z
x = 1
while True:
  a[6 * x * x] += 1
  x += 1
  if 6 * x * x > n:
    break

# x = y, z
for x in range(1, n+1):
  for z in range(1, n+1):
    if x == z:
      continue
    a[3 * x * x + z * z + 2 * x * z] += 1
    if 3 * x*x + z*z + 2*x*z > n:
      break
  if x * x > n:
    break

# x,y,z
for x in range(1, n+1):
  for y in range(x+1, n+1):
    for z in range(y+1, n+1):
      a[x*x + y*y + z*z + x*y + y*z + z*x] += 1
      if x*x + y*y + z*z + x*y + y*z + z*x > n:
        break
    if x*x + y*y + x*y > n:
      break
  if x*x > n:
    break

for i in range(n):
  print(a[i])



Fixed submission:
n = int(input())

a = [0] * 10010

# x,y,z
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      if x*x + y*y + z*z + x*y + y*z + z*x > n:
        continue
      a[x*x + y*y + z*z + x*y + y*z + z*x] += 1


for i in range(1, n+1):
  print(a[i])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
f = ''
b = ''
r = False
for i in range(Q):
    q = input()
    if q[0] == '1':
        r = not r
    else:
        T, F, C = q.split()
        if (F == '1') ^ r:
            f = C + f
        else:
            b = b + C
S = f + S + b
S = ''.join(list(reversed(S))) if r else S
print(S)

Fixed submission:
S = list(input())
Q = int(input())
f = list()
b = list()
r = False
for i in range(Q):
    q = input()
    if q[0] == '1':
        r = not r
    else:
        T, F, C = q.split()
        if (F == '1') ^ r:
            f.append(C)
        else:
            b.append(C)
if r:
    S = list(reversed(S + b)) + f
else:
    S = list(reversed(f)) + S + b

print(''.join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for i in range(Q):
    q = input()
    if q[0] == '1':
        S = ''.join(list(reversed(S)))
    else:
        T, F, C = q.split()
        S = C + S if F == '1' else S + C
print(S)

Fixed submission:
S = list(input())
Q = int(input())
f = list()
b = list()
r = False
for i in range(Q):
    q = input()
    if q[0] == '1':
        r = not r
    else:
        T, F, C = q.split()
        if (F == '1') ^ r:
            f.append(C)
        else:
            b.append(C)
if r:
    S = list(reversed(S + b)) + f
else:
    S = list(reversed(f)) + S + b

print(''.join(S))
Buggy python submission (verdict: Runtime Error):
n = int(input())

s = list()
for i in range(1, int(n**0.5 + 1)):
    if n % i == 0:
        s.append(int(i + n/i))
print(min(s)-2

Fixed submission:
n = int(input())
 
s = list()
for i in range(1, int(n**0.5 + 1)):
    if n % i == 0:
        s.append(int(i + n/i))
print(min(s)-2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))

l.sort(reverse=True)
c = 0
for i in range(len(l) - 2):
    for j in range(i + 1, len(l) - 1):
        if l[i] >= l[j] + l[j+1]:
            break
        for k in range(j + 1, len(l)):
            if l[i] < l[j] + l[k]:
                c += 1
            else:
                break
print(c)

Fixed submission:
import bisect

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

l.sort()
c = 0
for i in range(len(l) - 2):
    for j in range(i + 1, len(l) - 1):
        c += bisect.bisect(l[j+1:], l[i]+l[j]-1)
print(c)

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

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

c = 0
for x in itertools.combinations(l_lst, 3):
    if (x[0] < x[1] + x[2] and
            x[1] < x[0] + x[2] and
            x[2] < x[0] + x[1]):
        c += 1

print(c)

Fixed submission:
import bisect

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

l.sort()
c = 0
for i in range(len(l) - 2):
    for j in range(i + 1, len(l) - 1):
        c += bisect.bisect(l[j+1:], l[i]+l[j]-1)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import math

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

com_div = []
for n in range(1, min(a, b) + 1):
    if a % n == 0 and b % n == 0:
        com_div.append(n)

ans = []
for n in com_div:
    if n == 1:
        ans.append(n)
        continue
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            break
    else:
        ans.append(n)

print(len(ans))

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

xx = []
for n in [a, b]:
    x = []
    if n == 1:
        xx.append([n])
        continue

    x.append(1)
    while n % 2 == 0:
        x.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            x.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        x.append(n)
    xx.append(x)

print(len(set(xx[0]) & set(xx[1])))

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

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

com_div = []
for n in range(1, min(a, b) + 1):
    if a % n == 0 and b % n == 0:
        com_div.append(n)

ans = []
for n in com_div:
    if n == 1:
        ans.append(n)
        continue
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            break
    else:
        ans.append(n)

print(len(ans))

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

xx = []
for n in [a, b]:
    x = []
    if n == 1:
        xx.append([n])
        continue

    x.append(1)
    while n % 2 == 0:
        x.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            x.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        x.append(n)
    xx.append(x)

print(len(set(xx[0]) & set(xx[1])))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
a_len = len(a_list)

a_list.sort(reverse=True)

for x in range(m):
    a_list[0] /= 2

    i = 0
    while i+1 < a_len and a_list[i] < a_list[i + 1]:
        a_list[i], a_list[i + 1] = a_list[i + 1], a_list[i]
        i += 1

print(sum([int(x // 1) for x in a_list]))

Fixed submission:
import heapq

n, m = map(int, input().split())
a_list = []
for i in input().split(): heapq.heappush(a_list, -int(i))

for x in range(m):
	tmp = heapq.heappop(a_list) / 2
	heapq.heappush(a_list, tmp)

print(sum([int(-x // 1) for x in a_list]))

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

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

for x in range(m):
	idx = a_list.index(max(a_list))
	a_list[idx] /= 2

print(sum([math.floor(x) for x in a_list]))

Fixed submission:
import heapq

n, m = map(int, input().split())
a_list = []
for i in input().split(): heapq.heappush(a_list, -int(i))

for x in range(m):
	tmp = heapq.heappop(a_list) / 2
	heapq.heappush(a_list, tmp)

print(sum([int(-x // 1) for x in a_list]))
Buggy python submission (verdict: Runtime Error):
tree = {}
ans = []
def resolve():
    N, Q = map(int, input().split())
    ans.extend([0 for _ in range(N)])

    for i in range(N-1):
        a, b = map(lambda x: int(x) - 1, input().split())
        tree.setdefault(a, []).append(b)
        tree.setdefault(b, []).append(a)

    for i in range(Q):
        p, x = map(int, input().split())
        ans[p-1] += x

    dfs(0, ans[0])

    print(' '.join([str(x) for x in ans]))


def dfs(k, val, par=0):
    if k not in tree:
        return
    for c in tree.get(k, []):
        if c == par:
            continue
        ans[c] += val
        dfs(c, ans[c], k)
    return

if __name__ == "__main__":
    resolve()

Fixed submission:
N, Q = map(int, input().split())
tree = {}
ans = []
ans.extend([0 for _ in range(N)])

for i in range(N-1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree.setdefault(a, []).append(b)
    tree.setdefault(b, []).append(a)

for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

sta = [(0, 0)]
while sta:
    k, p = sta.pop()
    for c in tree.get(k, []):
        if c == p:
            continue
        ans[c] += ans[k]
        sta.append((c, k))

print(' '.join([str(x) for x in ans]))
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 2019
L, R = map(int, input().split())
ans = 2020
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j) % MOD)
        if ans == 0:
            break
print(ans)

Fixed submission:
MOD = 2019
L, R = map(int, input().split())
ans = 2020
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j) % MOD)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
acIdx = []
i = -1
while True:
    i = s.find('AC', i+1)
    if i == -1:
        break
    acIdx.append(i+1)

for i in range(q):
    l, r = map(int, input().split())
    print(len(list(filter(lambda x: l <= x <= (r-1), acIdx))))

Fixed submission:
n, q = map(int, input().split())
s = input()
cnt = 0
acIdx = [0]
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cnt += 1
    acIdx.append(cnt)

for i in range(q):
    l, r = map(int, input().split())
    print(acIdx[r-1] - acIdx[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
for i in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count('AC'))

Fixed submission:
n, q = map(int, input().split())
s = input()
cnt = 0
acIdx = [0]
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cnt += 1
    acIdx.append(cnt)

for i in range(q):
    l, r = map(int, input().split())
    print(acIdx[r-1] - acIdx[l-1])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
xli = list(map(int, input().split()))

ans = 0
if n < m:
    xli.sort()
    wli = list()
    for i in range(len(xli)-1):
        wli.append(xli[i+1]-xli[i])
    sortWli = list(reversed(sorted(wli)))
    su = 0
    for i in range(n-1):
        su += sortWli[i]
    ans = xli[-1] - xli[0] - su
print(ans

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

ans = 0
if n < m:
    xli.sort()
    wli = list()
    for i in range(len(xli)-1):
        wli.append(xli[i+1]-xli[i])
    sortWli = list(reversed(sorted(wli)))
    su = 0
    for i in range(n-1):
        su += sortWli[i]
    ans = xli[-1] - xli[0] - su
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

cost = [sys.maxsize] * n
cost[0] = 0

for i in range(n-1):
    for j in range(1, k+1):
        if i+j < n:
            diff = int(abs(h_list[i] - h_list[i+j]))
            cost[i+j] = min(cost[i]+diff, cost[i+j])
print(cost[n-1])

Fixed submission:
import sys

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

cost = [sys.maxsize] * n
cost[0] = 0

for i in range(n-1):
    for j in range(1, k+1):
        if i+j < n:
            diff = int(abs(h_list[i] - h_list[i+j]))
            cost[i+j] = min(cost[i]+diff, cost[i+j])
print(cost[n-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))

evenv, oddv = Counter(v[0::2]).most_common(), Counter(v[1::2]).most_common()
ans = 0
if evenv == oddv and len(evenv) == 1:
    ans = n // 2
elif evenv[0][0] == oddv[0][0]:
    ans = n - max(evenv[0][1] + oddv[1][1], evenv[1][1] + oddv[0][1])
else:
    ans = n - evenv[0][1] - oddv[0][1]
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

evenv, oddv = Counter(v[0::2]).most_common(), Counter(v[1::2]).most_common()
ans = 0
if evenv == oddv and len(evenv) == 1:
    ans = n // 2
elif evenv[0][0] == oddv[0][0]:
    ans = n - max(evenv[0][1] + oddv[1][1], evenv[1][1] + oddv[0][1])
else:
    ans = n - evenv[0][1] - oddv[0][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

sum1 = 0
sum2 = 0

for _ in a:
  sum1 += _
  sum2 += (a*a)
sum1 = (sum1 * sum1)
print(sum1 - sum2)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

sum1 = 0
sum2 = 0

for _ in a:
  sum1 += _
  sum2 += (_*_)
sum1 = (sum1 * sum1)
print(((sum1 - sum2)//2)%1000000007)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

result = []
for i in range(len(s)-len(t)):
    tmp = 0
    for j in range(i,len(t)+i):
        if s[j] == t[j-i]:

            tmp += 1
    result.append(tmp)

print(len(t)-max(result))


Fixed submission:
s = input()
t = input()

result = []
for i in range(len(s)-len(t)+1):
    tmp = 0
    for j in range(i,len(t)+i):
        if s[j] == t[j-i]:

            tmp += 1
    result.append(tmp)

print(len(t)-max(result))