Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import bisect
s = list(input())
t = list(input())
n = len(s)
m = len(t)
alphabet = [[] for _ in range(26)]
for i in range(n):
  alphabet[ord(s[i])-ord('a')+1] += [i] 

loop = 0
pre = -1
for i in range(m):
  c = ord(t[i]) - ord('a') + 1
  if len(alphabet[c]) == 0:
    print(-1)
    exit()
  idx = bisect.bisect_left(alphabet[c], pre+1)
  if idx == len(alphabet[c]):
    loop += 1
    pre = alphabet[c][0]
  else:
    pre = alphabet[c][idx]

print(pre + loop * n + 1)



Fixed submission:
import bisect
s = list(input())
t = list(input())
n = len(s)
m = len(t)
alphabet = [[] for _ in range(26)]
for i in range(n):
  alphabet[ord(s[i])-ord('a')] += [i] 
loop = 0
pre = -1
for i in range(m):
  c = ord(t[i]) - ord('a')
  if len(alphabet[c]) == 0:
    print(-1)
    exit()
  idx = bisect.bisect_left(alphabet[c], pre+1)
  if idx == len(alphabet[c]):
    loop += 1
    pre = alphabet[c][0]
  else:
    pre = alphabet[c][idx]

print(pre + loop * n + 1)

Buggy python submission (verdict: Runtime Error):
import bisect
s = list(input())
t = list(input())
n = len(s)
m = len(t)
alphabet = [[] for _ in range(26)]
for i in range(n):
  alphabet[ord(s[i])-ord('a')+1] += [i] 

loop = 0
pre = -1
for i in range(m):
  c = ord(t[i]) - ord('a') + 1
  idx = bisect.bisect_left(alphabet[c], pre+1)
  if idx == len(alphabet[c]):
    loop += 1
    pre = alphabet[c][0]
  else:
    pre = alphabet[c][idx]

print(pre + loop * n + 1)



Fixed submission:
import bisect
s = list(input())
t = list(input())
n = len(s)
m = len(t)
alphabet = [[] for _ in range(26)]
for i in range(n):
  alphabet[ord(s[i])-ord('a')] += [i] 
loop = 0
pre = -1
for i in range(m):
  c = ord(t[i]) - ord('a')
  if len(alphabet[c]) == 0:
    print(-1)
    exit()
  idx = bisect.bisect_left(alphabet[c], pre+1)
  if idx == len(alphabet[c]):
    loop += 1
    pre = alphabet[c][0]
  else:
    pre = alphabet[c][idx]

print(pre + loop * n + 1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
s = [tuple(sorted(list(input()))) for _ in  range(N)]

d = defaultdict(int)
ans = 0
for i in range(N):
  if s[i] in d.keys():
    ans += d[s[i]]
    d[s[i]] += 1
  else:
    d[s[i]] += 1
print(ans)

Fixed submission:
from collections import defaultdict
N = int(input())
s = ["".join(sorted(list(input()))) for _ in  range(N)]

d = defaultdict(int)
ans = 0
for i in range(N):
  if s[i] in d.keys():
    ans += d[s[i]]
    d[s[i]] += 1
  else:
    d[s[i]] += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ab = sorted(ab, key=lambda x:x[0])
day = 0
pay = 0
q = []
for i in range(1, M+1):
  for j in range(len(ab)):
    if ab[0][0] <= i:
      a, b = ab.pop(0)
      heapq.heappush(q, (-b, a))
    else:
      break
  if len(q) > 0:
    pay += - heapq.heappop(q)[0]

print(pay)


Fixed submission:
import heapq
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
day = {i+1: [] for i in range(M)}
for a, b in ab:
  if a <= M:
    day[a] += [-b]
q = []
heapq.heapify(q)
pay = 0
for i in range(M):
  for b in day[i+1]:
    heapq.heappush(q, b)
  if len(q) > 0:
    pay += -heapq.heappop(q)

print(pay)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
now = -1
while A:
  now = -1
  B = []
  cnt = 0
  used = [0 for _ in range(N)]
  for i in range(len(A)):
    a = A[i]
    if now < a:
      now = a
    else:
      B.append(a)
  A = B[:]
  ans += 1
print(ans)

Fixed submission:
import bisect
N = int(input())
A = [int(input()) for _ in range(N)]
b = []
for a in A[::-1]:
  idx = bisect.bisect_right(b, a)
  if len(b) <= idx:
    b.append(a)
  else:
    b[idx] = a

print(len(b))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
A = list(map(int, input().split()))
X = [0]*(N+1)
S = sum(A)

even_list = deque([A[i] for i in range(1, N) if (i+1) % 2 == 0])
odd_list = deque([A[i] for i in range(1, N) if (i+1) % 2 != 0])

X[1] = S - 2 * sum(even_list)
X[2] = S - 2 * sum(odd_list)
even_idx = N-1
odd_idx = N
for i in range(3, N+1):
  if i%2:
    even_idx += 2 
    even_idx %= N
    even_list.popleft()
    even_list.append(A[even_idx-1])
    X[i] = S - 2 * sum(even_list)
  else:
    odd_idx += 2
    odd_idx %= N
    odd_list.popleft()
    odd_list.append(A[odd_idx-1])
    X[i] = S - 2 * sum(odd_list)

for i in range(1, N+1):
  print(X[i], end=" ")
    


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
even_s, even_t = 2, N-1
even = 0
for i in range(N):
  if (i+1) % 2 == 0:
    even += A[i]
odd_s, odd_t = 3, N
odd = 0
for i in range(2, N):
  if (i+1) % 2 == 1:
    odd += A[i]
odd_s, odd_t = 3, N
X = [0]*N
X[0] = S - even * 2
X[1] = S - odd * 2
for i in range(3, N+1):
  if i % 2:
    even -= A[even_s-1] 
    even += A[(even_t+2)%N-1]
    even_s += 2
    even_t = (even_t+2)%N
    X[i-1] = S - even * 2
  else:
    odd -= A[odd_s-1]
    odd += A[(odd_t+2)%N-1]
    odd_s += 2
    odd_t = (odd_t+2)%N
    X[i-1] = S - odd * 2

X = list(map(str, X))
print(" ".join(X))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000000)
N, K = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(lambda x:int(x)-1, input().split())
  graph[a] += [b]
  graph[b] += [a]

global ans
ans = K

def npr(n, r, p):
  e = 1
  for i in range(n, n-r, -1):
    e *= i
    e %= p

  return e
p=10**9+7

def dfs(u, pre):
  global ans
  child = 0
  for v in graph[u]:
    if v != pre:
      dfs(v, u)
      child += 1
  
  if u == 0:
    ans *= npr(K-1, child, p)
  else:
    ans *= npr(K-2, child, p)

dfs(0, -1)
print(ans%p)


Fixed submission:
import sys
sys.setrecursionlimit(100000000)
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N-1)]
graph = [[] for _ in range(N)]
used = [-1]*N
ans = K
mod = 10**9+7

for a, b in ab:
  a -= 1
  b -= 1
  graph[a] += [b]
  graph[b] += [a]


def npr(n, r, p):
  e = 1
  for i in range(n, n-r, -1):
    e *= i
    e %= p

  return e

def dfs(u, pre):
  global ans
  child = 0
  for v in graph[u]:
    if v != pre:
      dfs(v, u)
      child += 1
  if u == 0:
    ans *= npr(K-1, child, mod)
  else:
    ans *= npr(K-2, child, mod)

  ans %= mod

dfs(0, -1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
time = 0
ab = sorted(ab, key=lambda x:x[1])
while ab:
  a, b = ab.pop(0)
  time += a
  if time <= b:
    pass
  else:
    print('No')
    exit()
print('Yes')

Fixed submission:
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
time = 0
ab = sorted(ab, key=lambda x:x[1])
for a, b in ab:
  time += a
  if time <= b:
    pass
  else:
    print('No')
    exit()
print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
time = 0
ab = sorted(ab, key=lambda x:x[1])
while ab:
  a, b = ab.pop(0)
  time += a
  if time <= b:
    pass
  else:
    print('No')
    exit()
print('Yes')

Fixed submission:
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
time = 0
ab = sorted(ab, key=lambda x:x[1])
for a, b in ab:
  time += a
  if time <= b:
    pass
  else:
    print('No')
    exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
mod = 10**9+7
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
count = [0 for _ in range(n+1)]
for num in a:
  count[num] = -1
count[1] = 1
count[2] = 1
for i in range(2, n+1):
  if count[i] != -1:
    count[i] += (count[i-1] + count[i-2])%mod
  else:
    count[i] = 0

print(count[-1])

Fixed submission:
mod = 1000000007
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
count = [0 for _ in range(n+1)]
count[1] = 1
count[0] = 1
for num in a:
  count[num] = -1

for i in range(1, n+1):
  if count[i] != -1:
    if i == 1:
      count[1] = 1
      continue
    count[i] = (count[i-1] + count[i-2])
    count[i] %= mod
  else:
    count[i] = 0
print(count[-1]%mod)

Buggy python submission (verdict: Runtime Error):
mod = 10**9+7
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
count = [0 for _ in range(n+1)]
for num in a:
  count[num] = -1
count[1] = 1
count[2] = 1
for i in range(2, n+1):
  if count[i] != -1:
    count[i] += (count[i-1] + count[i-2])%mod
  else:
    count[i] = 0
print(count)
print(count[-1])

Fixed submission:
mod = 1000000007
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
count = [0 for _ in range(n+1)]
count[1] = 1
count[0] = 1
for num in a:
  count[num] = -1

for i in range(1, n+1):
  if count[i] != -1:
    if i == 1:
      count[1] = 1
      continue
    count[i] = (count[i-1] + count[i-2])
    count[i] %= mod
  else:
    count[i] = 0
print(count[-1]%mod)
Buggy python submission (verdict: Time Limit Exceeded):
L = int(input())
l = len(str(L))
dp = [[0]*2 for _ in range(100005)]
# dp[i][smaller]: i桁目までみる　未満なら1
# dp[i][1] : i桁目までみて、a, bどちらもL未満
# dp[i][0] : i桁目までみて、a+b = L
dp[0][0] = 1
mod = 10**9+7

for i in range(l):
  n = int(str(L)[i])
  # a + b = 0
  if n == 0: # a+bとn[i]が一致
    dp[i+1][0] = dp[i][0]
    dp[i+1][1] = dp[i][1]
  else: # a+b = 0, n[i] = 1のとき
    dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod

  # a + b = 1
  if n == 0: # a+b=1, n[i]=0
    # 未満のとき、(0, 1), (1, 0)を選べる
    dp[i+1][1] += dp[i][1] * 2 % mod
    # これまで一致しているとき、どれを選んでも超えてしまう
  else: # a+b=n[i]=1のとき
    # これまで一致しているとき、(0, 1), (1, 0)を選べる
    dp[i+1][0] += dp[i][0] * 2 % mod
    # 未満のとき、(0, 1), (1, 0)を選べる
    dp[i+1][1] += dp[i][1] * 2 % mod

print((dp[l][0]+dp[l][1])%mod)




Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
# ----------

INF = float("inf")
MOD = 10 ** 9 + 7

s = input().strip()

dp = [[0] * 2 for _ in range(100005)]
dp[0][0] = 1

n = len(s)
for i in range(n):
    if s[i] == "0":
        dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = dp[i][1]
    else:
        dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD

    if s[i] == "0":
        dp[i + 1][1] += dp[i][1] * 2 % MOD
    else:
        dp[i + 1][0] += dp[i][0] * 2 % MOD
        dp[i + 1][1] += dp[i][1] * 2 % MOD

ans = (dp[n][0] + dp[n][1]) % MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = list(map(int, input()))
count_1 = 0


def re_cum_list(li):
  count_0 = 0
  count_1 = 0
  re_li = []
  for i in li:
    if i == 0:
      count_0 -= 1
      if count_1 > 0:
        re_li.append(count_1)
        count_1 = 0
    else:
      count_1 += 1
      if count_0 < 0:
        re_li.append(count_0)
        count_0 = 0
  if count_1 > 0:
    re_li.append(count_1)
  if count_0 < 0:
    re_li.append(count_0)
  return re_li


cum_1_s = re_cum_list(s)

sum_list = []
su = 0
count = 0
j = 0
while j <= len(cum_1_s):
  for i in range(j, len(cum_1_s)):
    if cum_1_s[i] > 0:
      pass
    else:
      if count >= k:
        break
      count += 1
    su += abs(cum_1_s[i])
  sum_list.append(su)
  j += 1
  count = 0
  su = 0


print(max(sum_list))

Fixed submission:
from collections import deque
N, K = map(int, input().split())
S = deque(input())
T = []
P = []
pre = S[0]
cnt = 0
while S:
  s = S.popleft()
  cnt += 1
  if pre != s:
    cnt -= 1
    T += [cnt]
    P += [pre]
    pre = s
    cnt = 1
T += [cnt]
P += [pre]

cum_T = T[:]
for i in range(len(T)-1):
  cum_T[i+1] = cum_T[i] + T[i+1]

cum_T += [0]
l = len(P)
ans = 0
for i in range(l):
  if P[i] == '1':
    r = min(l-1, i+2*K)
    ans = max(ans,-cum_T[i-1]+cum_T[r] )
  else:
    r = min(l-1, i+2*K-1)
    ans = max(ans, -cum_T[i-1]+cum_T[r])
print(ans)
Buggy python submission (verdict: Runtime Error):
li = [int(input()) for _ in range(5)]
li_mod = [[i % 10, i] for i in li if i % 10 != 0]
li_mod_r = [i for i in li if i % 10 == 0]
li_mod = sorted(li_mod, reverse = True)
time = 0
for lis in li_mod[:-1]:
  time += lis[1] + (10-lis[0])
time += sum(li_mod_r)
time += li_mod[-1][1]
print(time)

Fixed submission:
li = [int(input()) for _ in range(5)]
li_mod = [[i % 10, i] for i in li if i % 10 != 0]
li_mod_r = [i for i in li if i % 10 == 0]
li_mod = sorted(li_mod, reverse = True)
time = 0
if li_mod != []:
  for lis in li_mod[:-1]:
    time += lis[1] + (10-lis[0])
  time += li_mod[-1][1]
if li_mod_r != []:
  time += sum(li_mod_r)
#time += li_mod[-1][1]
print(time)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = [int(input()) for _ in range(5)]
li.insert(0, 0)
#print(li)
plot = [n, 0, 0, 0, 0, 0]
count = 0
"""for i in range(1, 5):
    print(i)"""
time = 0
while plot[5] != n:
  for i in range(5, 0, -1):
    #print(i)
    if plot[i-1] - li[i] >= 0:
      plot[i-1] -= li[i]
      plot[i] += li[i]
    else:
      plot[i] += plot[i-1]
      plot[i-1] = 0
    #print(plot, time)
    count += 1
  #if count >= 100:
      #break
  time += 1

print(time)


Fixed submission:
N = int(input())
abcde = [int(input()) for _ in range(5)]
mx = min(abcde)
if N % mx == 0:
  ans = 5 + N // mx -1
else:
  ans = 5 + N // mx

print(ans)
Buggy python submission (verdict: Runtime Error):
for i in range(len(S)):
    for j in range(i, len(S)):
        count = 0
        print(list(S[i:j+1]))
        for s in list(S[i:j+1]):
            if s in ['A', 'G', 'T', 'C']:
                count += 1
            else:
                if m <= count:
                    m = count
                count = 0
print(m)

Fixed submission:
S = list(input())
m = 0
count = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        count = 0
        #switch = False
        for s in list(S[i:j+1]):
            #print(s, list(S[i:j+1]), count)
            if s in ['A', 'G', 'T', 'C']:
                count += 1
            else:
                if m <= count:
                    m = count
                count = 0
                switch = True
            if m <= count:
                m = count


print(m)
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
ans = A
for i in range(A+1, B+1):
    ans = ans ^ i
print(ans)


Fixed submission:
A, B = map(int, input().split())
A -= 1
ak, amod = divmod(A, 4)

cum_a = 0
if amod == 0:
    cum_a = A
elif amod == 1:
    cum_a = 1
elif amod == 2:
    cum_a = 4*ak + 3
else:
    cum_a = 0

bk, bmod = divmod(B, 4)
cum_b = 0
if bmod == 0:
    cum_b = B
elif bmod == 1:
    cum_b = 1
elif bmod == 2:
    cum_b = 4*bk + 3
else:
    cum_b = 0

print(cum_a ^ cum_b)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
for i in range(n):
  for j in range(1, min(i, k)+1):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]), dp[i])
print(dp[-1])

Fixed submission:
import numpy as np
n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))
dp = np.array([0 for _ in range(n)])
dp[0] = 0
for i in range(1, n):
  j = max(0, i-k)
  dp[i] = min(dp[j:i] + np.abs(h[i]-h[j:i]))

print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0 for _ in range(n)]

for i in range(n):
  for j in range(1, min(i, k)+1):
    if dp[i] == 0:
      dp[i] = dp[i-j]+abs(h[i]-h[i-j])
    else:
      dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]), dp[i])
print(dp[-1])

Fixed submission:
import numpy as np
n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))
dp = np.array([0 for _ in range(n)])
dp[0] = 0
for i in range(1, n):
  j = max(0, i-k)
  dp[i] = min(dp[j:i] + np.abs(h[i]-h[j:i]))

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
  for j in range(W+1):
    if j - wv[i][0] >= 0:
      dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]]+wv[i][1])
    else:
      dp[i+1][j] = dp[i][j]

print(max(dp[N]))

Fixed submission:
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
  for j in range(W+1):
    if j - wv[i][0] >= 0:
      dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]]+wv[i][1])
    else:
      dp[i+1][j] = dp[i][j]

print(max(dp[N]))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h = sorted(h)
diff_h = []
for i in range(N-1):
  diff_h += [h[i+1] - h[i]]

ans = float('inf')
for i in range(N-K+1):
  ans = min(ans, sum(diff_h[i:i+K-1]))
print(ans)

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h = sorted(h)

ans = float('inf')
for i in range(N-K+1):
  ans = min(ans, h[i+K-1]-h[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())
c = 0
while True:
    if A % 2 == 0:
        pass
    else:
        A -= 1

    B += A / 2
    A -= A / 2
    c += 1

    if B % 2 == 0:
        pass
    else:
        B -= 1

    A += B / 2
    B -= B / 2
    c += 1

    if c == K:
        break

print(int(A), int(B))


Fixed submission:
import numpy as np
A, B, K = map(int, input().split())
coo = np.array([A, B])
c = 0
for _ in range(K):
    if coo[0] % 2 == 0:
        pass
    else:
        coo[0] -= 1

    half = coo[0] / 2
    coo[1] += half
    coo[0] -= half
    coo = coo[::-1]

if K % 2 == 0:
    print(*coo)
else:
    print(*coo[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
N, M = list(map(int, input().split()))
S = input()
T = input()

L = int(N * M / fractions.gcd(N, M))
LN = int(L / N)
LM = int(L / M)

count = 0
dic1 = {LN*n:S[n] for n in range(N)}
dic2 = {LM*n:T[n] for n in range(M)}

for n in range(L):
    if (n in dic1) and (n in dic2) and dic1[n] != dic2[n]:
        count += 1
        break

if count == 0:
    print(L)
else:
    print('-1')


Fixed submission:
import fractions
N, M = list(map(int, input().split()))
S = input()
T = input()

L = int(N * M / fractions.gcd(N, M))
LN = int(L / N)
LM = int(L / M)

count = 0
dic1 = {LN*n:S[n] for n in range(N)}
dic2 = {LM*n:T[n] for n in range(M)}

for k in dic1.keys():
    if k in dic2 and dic1[k] != dic2[k]:
        count += 1
        print(-1)
        break

if count == 0:
    print(L)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from collections import defaultdict
N, M = list(map(int, input().split()))
S = input()
T = input()

L = int(N * M / fractions.gcd(N, M))
LN = int(L / N)
LM = int(L / M)

count = 0
dic1 = defaultdict(int)
dic2 = defaultdict(int)
for n in range(N):
    dic1[LN*n] = S[n]

for n in range(M):
    dic2[LM*n] = T[n]

for n in range(L):
    if dic1[n] != 0 and dic2[n] != 0 and dic1[n] != dic2[n]:
        count += 1
        break

if count == 0:
    print(L)
else:
    print('-1')




Fixed submission:
import fractions
N, M = list(map(int, input().split()))
S = input()
T = input()

L = int(N * M / fractions.gcd(N, M))
LN = int(L / N)
LM = int(L / M)

count = 0
dic1 = {LN*n:S[n] for n in range(N)}
dic2 = {LM*n:T[n] for n in range(M)}

for k in dic1.keys():
    if k in dic2 and dic1[k] != dic2[k]:
        count += 1
        print(-1)
        break

if count == 0:
    print(L)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
for_set_v = v # set用
set_v = set(v)
even = []
odd = []
count = 0 # 置き換えた回数
count_list = []
for num in range(n):
    if num % 2 == 0:
        even.append(v[num])
    else:
        odd.append(v[num])

even_most = Counter(even).most_common()
odd_most = Counter(odd).most_common()
#print(even_most)
#print(odd_most)
if len(set(v)) >= 2:
    if even_most[0][0] != odd_most[0][0]:
        if len(set(even)) != 1:
            count += (n/2) - int(even_most[0][1])
        if len(set(odd)) != 1:
            count += (n/2) - int(odd_most[0][1])
    else:
        try:
            count_list.append(n-int(even_most[0][1])-int(odd_most[1][1]))
            count_list.append(n-int(even_most[1][1])-int(odd_most[0][1]))
            #print(count_list)
            count += int(min(count_list))
        except:
            if len(even_most) == 1:
                count += (n/2)-int(odd_most[1][1])
            elif len(odd_most) == 1:
                count += (n/2)-int(even_most[1][1])
else:
    count += (n/2)
print(int(count))


Fixed submission:
n = list(input())
result = ''
for num in n:
    if num == '1':
        result += '9'
    elif num == '9':
        result += '1'
print(int(result))
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
print(difference)
print(gcd([2, 4, 6, 8]))


Fixed submission:
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]

if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
print(difference)
print(gcd([2, 4, 6, 8]))

Fixed submission:
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]

if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)


Fixed submission:
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]

if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
for city in cityies[1:]:
    diff = abs(city - stan)
    difference.append(diff)

max_num = gcd(difference)
print(max_num)


Fixed submission:
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]

if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)