Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import fractions
def lcm(C,D):
    return C*D/fractions.gcd(C,D)
A,B,C,D = map(int, input().split())
X = B - A
print(X - int(X/C) - int(X/D) + int(X/(C*D/math.gcd(C,D))))

Fixed submission:
import fractions
def lcm(C,D):
    return C*D//fractions.gcd(C,D)
A,B,C,D = map(int, input().split())
b = (B - B//C - B//D + B//lcm(C,D))
a = ((A-1) - (A-1)//C- (A-1)//D + (A-1)//lcm(C,D))
print(b-a)

Buggy python submission (verdict: Runtime Error):
import math
def lcm(C,D):
    return int(C*D/math.gcd(C,D))
A,B,C,D = map(int, input().split())
X = B - A + 1
print(int(X - X/C - X/D + X/lcm(C,D)))

Fixed submission:
import fractions
def lcm(C,D):
    return C*D//fractions.gcd(C,D)
A,B,C,D = map(int, input().split())
b = (B - B//C - B//D + B//lcm(C,D))
a = ((A-1) - (A-1)//C- (A-1)//D + (A-1)//lcm(C,D))
print(b-a)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = list(map(int,input().split()))
integer = (i for i in range(A, B+1))
cnt = 0
for x in integer:
    if x % C != 0:
        if x % D != 0:
            cnt += 1
print(cnt)

Fixed submission:
import fractions
def lcm(C,D):
    return C*D//fractions.gcd(C,D)
A,B,C,D = map(int, input().split())
b = (B - B//C - B//D + B//lcm(C,D))
a = ((A-1) - (A-1)//C- (A-1)//D + (A-1)//lcm(C,D))
print(b-a)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = list(map(int,input().split()))
integer = (i for i in range(A, B+1))
cnt = 0
for x in integer:
    if x % C != 0 and x % D != 0:
        cnt += 1
print(cnt)

Fixed submission:
import fractions
def lcm(C,D):
    return C*D//fractions.gcd(C,D)
A,B,C,D = map(int, input().split())
b = (B - B//C - B//D + B//lcm(C,D))
a = ((A-1) - (A-1)//C- (A-1)//D + (A-1)//lcm(C,D))
print(b-a)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools 
N = int(input())
X = [list(map(int, input().split())) for n in range(N)]
X = list(itertools.permutations(X, len(X)))
isOK = False
for x in X:
    cnt = 0
    check = []
    for n in x:
        cnt += n[0]
        #print('x:{}, cnt:{}, limit:{}'.format(x,cnt,n[1]))
        if cnt > n[1]:
            check.append(0)
        else:
            check.append(1)
    if sum(check) == len(x):
        isOK = True
        break
if isOK:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
X = [list(map(int, input().split())) for n in range(N)]
X = sorted(X, key=lambda x: x[0])
X = sorted(X, key=lambda x: x[1])
cnt = 0
isLimitOver = False
for x in X:
    cnt += x[0]
    if cnt > x[1]:
        isLimitOver = True
        break
if isLimitOver:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
costs = []
N = int(input())
x, y = [], []
# (x,y)の値を取得
for n in range(N):
    temp = list(map(int, input().split()))
    x.append(temp[0])
    y.append(temp[1])
# コスト計算
for n, perm in enumerate(itertools.permutations(zip(x,y), N)):
    sol = 0
    cost = 1
    for i in range(1, N):
        if i == 1:
            sol = [perm[i][0] - perm[i-1][0], perm[i][1] - perm[i-1][1]]
        else:
            if perm[i][0] - sol[0] == perm[i-1][0] and perm[i][1] - sol[1] == perm[i-1][1]:
                cost += 0
            else:
                cost += 1
    costs.append(cost)
print(np.min(costs))

Fixed submission:
N, K = map(int, input().split())
if K == 1:
    print(0)
elif N > K:
    print(N - K)
elif N == K:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
costs = []
N = int(input())
x, y = [], []
# (x,y)の値を取得
for n in range(N):
    temp = list(map(int, input().split()))
    x.append(temp[0])
    y.append(temp[1])
# コスト計算
for n, perm in enumerate(itertools.permutations(zip(x,y), N)):
    sol = 0
    cost = 1
    for i in range(1, N):
        if i == 1:
            sol = [perm[i][0] - perm[i-1][0], perm[i][1] - perm[i-1][1]]
        else:
            if perm[i][0] - sol[0] == perm[i-1][0] and perm[i][1] - sol[1] == perm[i-1][1]:
                cost += 0
            else:
                cost += 1
    costs.append(cost)
print(min(costs))

Fixed submission:
N = int(input())
arr = sorted([list(map(int, input().split())) for _ in range(N)])
cnt = {}
for i in range(N):
    for j in range(i+1,N):
        pq = (arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])
        cnt.setdefault(pq, 0)
        cnt[pq] += 1
print(1 if cnt == {} else N - max(cnt.values()))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np
costs = []
N = int(input())
x, y = [], []
# (x,y)の値を取得
for n in range(N):
    temp = list(map(int, input().split()))
    x.append(temp[0])
    y.append(temp[1])
# コスト計算
for n, perm in enumerate(itertools.permutations(zip(x,y), N)):
    sol = 0
    cost = 1
    for i in range(1, N):
        if i == 1:
            sol = [perm[i][0] - perm[i-1][0], perm[i][1] - perm[i-1][1]]
        else:
            if perm[i][0] - sol[0] == perm[i-1][0] and perm[i][1] - sol[1] == perm[i-1][1]:
                cost += 0
            else:
                cost += 1
    costs.append(cost)
print(np.min(costs))

Fixed submission:
N = int(input())
arr = sorted([list(map(int, input().split())) for _ in range(N)])
cnt = {}
for i in range(N):
    for j in range(i+1,N):
        pq = (arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])
        cnt.setdefault(pq, 0)
        cnt[pq] += 1
print(1 if cnt == {} else N - max(cnt.values()))

Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
from sympy import *
p = Symbol('p')
q = Symbol('q')
costs = []
N = int(input())
x, y = [], []
# (x,y)の値を取得
for n in range(N):
    temp = list(map(int, input().split()))
    x.append(temp[0])
    y.append(temp[1])
# コスト計算
for n, perm in enumerate(itertools.permutations(zip(x,y), N)):
    sol = 0
    cost = 1
    for i in range(1, N):
        if i == 1:
            sol = solve([perm[i][0]-p-perm[i-1][0], perm[i][1]-q-perm[i-1][1]], [p,q])
            #print(sol)
        else:
            if perm[i][0] - sol[p] == perm[i-1][0] and perm[i][1] - sol[q] == perm[i-1][1]:
                cost += 0
            else:
                cost += 1
    costs.append(cost)
#print(costs)
print(np.min(costs))

Fixed submission:
N = int(input())
arr = sorted([list(map(int, input().split())) for _ in range(N)])
cnt = {}
for i in range(N):
    for j in range(i+1,N):
        pq = (arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])
        cnt.setdefault(pq, 0)
        cnt[pq] += 1
print(1 if cnt == {} else N - max(cnt.values()))
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

name_union = set(s) | set(t)
money = {}0
for i, n in enumerate(name_union):
  money.setdefault(n, 0)
  money[n] += sum(map(lambda x: 1 if x == n else 0, s))
  money[n] -= sum(map(lambda x: 1 if x == n else 0, t))
print(0 if max(money.values()) < 0 else max(money.values()))

Fixed submission:
N = int(input())
s, t = [], []
for n in range(N):
  s.append(input())

M = int(input())
for m in range(M):
  t.append(input())

name_union = set(s) | set(t)
money = {}
for i, n in enumerate(name_union):
  money.setdefault(n, 0)
  money[n] += sum(map(lambda x: 1 if x == n else 0, s))
  money[n] -= sum(map(lambda x: 1 if x == n else 0, t))
#print(money)
#print(money.values())
print(0 if max(money.values()) < 0 else max(money.values()))
Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator
n = int(input())
a = list(map(int,input().split()))
lim = 10**18
ans = functools.reduce(operator.mul, a)

if ans > lim:
  ans = -1
    
print(ans)

Fixed submission:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
b = np.sqrt(a)

lim = 10**9
lim_1 = 10**18
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
if ans > lim_1:
  ans = -1
elif ans < 0:
  ans = -1
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
lim = 10**18
ans = 1
for i in range(n):
  ans = ans*a[i]

if ans > lim:
  ans = -1
    
print(ans)

Fixed submission:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
b = np.sqrt(a)

lim = 10**9
lim_1 = 10**18
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
if ans > lim_1:
  ans = -1
elif ans < 0:
  ans = -1
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = np.concatenate([np.array([0]),np.array(list(map(int,input().split())))])

for i in range(n):
  ans = np.sum(np.where(a == (i+1),1,0))
  print(ans)

Fixed submission:
import numpy as np

n = int(input())
base = np.zeros(n)
a = np.array(list(map(int,input().split())))

for i in range(n-1):
  base[a[i]-1] += 1
  
for i in range(n):
  print(int(base[i]))
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

matrix = np.ones(num[0]) * (-1)
sign_0 = []
sign_1 = []
ans = 0

if num[1] == 0:
  if not matrix[0] == 0:
    ans = 10**(num[0]-1)
  elif matrix[0] == 0:
    ans = -1

elif not num[1] == 0:
  for i in range(0,num[1]):
    temp = list(map(int,input().split()))
    if (temp[0] in sign_0 and) (temp not in sign_1) :
      ans = -1
      break
    else:
      matrix[temp[0]-1] = temp[1]
      sign_0.append(temp[0])
      sign_1.append(temp)
  
  if not ans == -1:
    if matrix[0] == -1:
       matrix[0] = 1
        
    for i in range(1,num[0]):
      if matrix[i] == -1:
        matrix[i] = 0
        
    ans = matrix[0]*(10**(num[0]-1))
    
    for i in range(1,num[0]):
      ans = ans + matrix[i]*(10**(num[0]-1-i))
    ans = int(ans)
      
  judge_a = len(list(str(ans)))
  judge = judge_a - num[0]
  
  if not judge == 0:
    ans = -1
    
  
print(int(ans))

Fixed submission:
import numpy as np
n,m = map(int,input().split())
base = np.zeros(n)
seen = np.zeros(n)
base[0] = 1
sign = 0

for i in range(m):
  s,c = map(int,input().split())
  if (seen[s-1] == 0) or (base[s-1] == c):
    base[s-1] = c
    seen[s-1] = 1
    sign = 1
  else:
    sign = 2
    break
ans = 0
if (sign == 2) or ((base[0] == 0) and (n > 1)):
  ans = -1
else:
  for i in range(1,len(base)+1):
    ans += base[-i]*(10**(i-1))
    
if (m == 0) and (n == 1):
  ans = 0
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())

num_list = []
count_list = []

for i in range(0,num):
  num_list.append(input())

num_set = list(set(num_list))

for i in range(0,len(num_set)):
  count_list.append(num_list.count(num_set[i]))

ans = []
max = 0

for i in range(0,len(num_set)):
  temp = count_list[i]
  
  if temp == max:
    ans.append(num_set[i])
  
  if temp > max:
    max = temp
    ans = []
    ans.append(num_set[i])
ans.sort()

for i in range(0,len(ans)):
  print(ans[i])

Fixed submission:
import collections

num = int(input())

num_list = []
count_list = []
ans = []

for i in range(0,num):
  num_list.append(input())

num_list_2 =collections.Counter(num_list).most_common()

for i in range(0,len(num_list_2)):
  if num_list_2[0][1] > num_list_2[i][1]:
    break
  
  ans.append(num_list_2[i][0])

ans.sort()

for i in range(0,len(ans)):
  print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())

num_list = []

for i in range(0,num):
  num_list.append(input())

num_set = list(set(num_list))
count_list = []

num_list_len = len(num_list)

for i in range(0,len(num_set)):
  while num_set[i] in num_list:
    num_list.remove(num_set[i])
    
  count_list.append(num_list_len - len(num_list))
  num_list_len = len(num_list)

ans = []
max = 0

for i in range(0,len(num_set)):
  temp = count_list[i]
  
  if temp == max:
    ans.append(num_set[i])
  
  if temp > max:
    max = temp
    ans = []
    ans.append(num_set[i])
ans.sort()

for i in range(0,len(ans)):
  print(ans[i])

Fixed submission:
import collections

num = int(input())

num_list = []
count_list = []
ans = []

for i in range(0,num):
  num_list.append(input())

num_list_2 =collections.Counter(num_list).most_common()

for i in range(0,len(num_list_2)):
  if num_list_2[0][1] > num_list_2[i][1]:
    break
  
  ans.append(num_list_2[i][0])

ans.sort()

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

if num[1] == 0:     
  count_ac_all = 0
  count_wa_all = 0 

else:  
  num_list = []
  for i in range(0,num[1]):
    num_list.append(list(input().split()))

  group=set()
  new_num = []

  for i in range(0,num[1]):
    group.add(num_list[i][0])

  set_list = list(group)

  for i in range(0,len(set_list)):
    for j in range(0,len(num_list)):
      if num_list[j][0] == set_list[i]:
        new_num.append(num_list[j])

  count_ac = 0
  count_wa = 0
  count_ac_all = 0
  count_wa_all = 0
  base = new_num[0][0]
  count = 0


  for i in range(0,len(new_num)):
    if not new_num[i][0] == base:
      base = new_num[i][0]
      count = 0
      count_ac = 0
      count_wa = 0

    if count == 0:
      if new_num[i][1] == 'WA':
        count_wa = count_wa+1
      elif new_num[i][1] == 'AC':
        count_ac = count_ac+1
        count = 1

    if count == 1:
      count_ac_all = count_ac_all + count_ac
      count_wa_all = count_wa_all + count_wa
      count = -1
    
print(count_ac_all,count_wa_all)

Fixed submission:
import numpy as np

n,m = map(int,input().split())
base = np.zeros(n)
pena = np.zeros(n)

for i in range(m):
  s = list(input().split())
  if (s[1] == "WA") and (base[int(s[0])-1] == 0):
    pena[int(s[0])-1] += 1
  elif (s[1] == "AC"):
    base[int(s[0])-1] = 1
    
ans_1 = np.multiply(base,pena)
print(int(np.sum(base)),int(np.sum(ans_1)))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
count = 0
now = 0
i= 0
j = 0

dp = [0]*(n+1)
if 1 == base[j]:
  dp[1] = 0
  j = 1
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not (i == base[j]):
    dp[i] = dp[i-1] + dp[i-2]
  elif i == base[j]:
    if j < m-1:
      j = j + 1
  
  
print(int(dp[n]%1000000007))

Fixed submission:
n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
i= 0
j = 0

dp = [0]*(n+1)
if m == 0:
  base = [n+1]

if 1 == base[j]:
  dp[1] = 0
  if j < m-1:
    j = j + 1
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not (i == base[j]):
    dp[i] = dp[i-1] + dp[i-2]
  elif i == base[j]:
    if j < m-1:
      j = j + 1
  
  
print(int(dp[n]%1000000007))

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
count = 0
now = 0
i= 0
j = 0

dp = [0]*(n+1)
if 1 == base[j]:
  dp[1] = 0
  if j < m-1:
    j = j + 1
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not (i == base[j]):
    dp[i] = dp[i-1] + dp[i-2]
  elif i == base[j]:
    if j < m-1:
      j = j+1
  
  
print(int(dp[n]%1000000007))

Fixed submission:
n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
i= 0
j = 0

dp = [0]*(n+1)
if m == 0:
  base = [n+1]

if 1 == base[j]:
  dp[1] = 0
  if j < m-1:
    j = j + 1
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not (i == base[j]):
    dp[i] = dp[i-1] + dp[i-2]
  elif i == base[j]:
    if j < m-1:
      j = j + 1
  
  
print(int(dp[n]%1000000007))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
count = 0
now = 0
i= 0

dp = [0]*(n+1)
if 1 in base:
  dp[1] = 0
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not(i in base):
    dp[i] = dp[i-1] + dp[i-2]
  
  
print(int(dp[n]%1000000007))

Fixed submission:
n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
i= 0
j = 0

dp = [0]*(n+1)
if m == 0:
  base = [n+1]

if 1 == base[j]:
  dp[1] = 0
  if j < m-1:
    j = j + 1
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not (i == base[j]):
    dp[i] = dp[i-1] + dp[i-2]
  elif i == base[j]:
    if j < m-1:
      j = j + 1
  
  
print(int(dp[n]%1000000007))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
count = 0
now = 0
i= 0

dp = [0]*(n+1)
if 1 in base:
  dp[1] = 0
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not(i in base):
    dp[i] = dp[i-1] + dp[i-2]
  
  
print(int(dp[n]%1000000007))

Fixed submission:
n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
i= 0
j = 0

dp = [0]*(n+1)
if m == 0:
  base = [n+1]

if 1 == base[j]:
  dp[1] = 0
  if j < m-1:
    j = j + 1
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not (i == base[j]):
    dp[i] = dp[i-1] + dp[i-2]
  elif i == base[j]:
    if j < m-1:
      j = j + 1
  
  
print(int(dp[n]%1000000007))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,w = map(int,input().split())
w_i = [0]
v_i = [0]
for i in range(n):
  temp = list(map(int,input().split()))
  w_i.append(temp[0])
  v_i.append(temp[1])

dp = np.zeros(((n+1),(w+1)))

for i in range(1,n+1):
#  print(dp)
  for j in range(w+1):
    temp_1 = -float("inf")
    if j-w_i[i] >= 0:
      temp_1 = dp[i-1][j-w_i[i]] + v_i[i]
    
    temp_2 = dp[i-1][j]
    
    if temp_1 <= temp_2:
      dp[i][j] = temp_2
    elif temp_2 < temp_1:
      dp[i][j] = temp_1
      
print(int(dp[n][w]))

Fixed submission:
n,w = map(int,input().split())
w_i = [0]
v_i = [0]
for i in range(n):
  temp = list(map(int,input().split()))
  w_i.append(temp[0])
  v_i.append(temp[1])

dp = []
for i in range(n+1):
  temp = []
  for j in range(w+1):
    temp.append(0)
  
  dp.append(temp)

for i in range(1,n+1):
#  print(dp)
  for j in range(w+1):
    temp_1 = -float("inf")
    if j-w_i[i] >= 0:
      temp_1 = dp[i-1][j-w_i[i]] + v_i[i]
    
    temp_2 = dp[i-1][j]
    
    if temp_1 <= temp_2:
      dp[i][j] = temp_2
    elif temp_2 < temp_1:
      dp[i][j] = temp_1
      
print(dp[n][w])
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
base = []
base_1 = []
key = {}
ans_str = []
ans_n = []

for i in range(m):
  p,y = map(int,input().split())
  base.append([p,y])
  base_1.append([p,y])
  
base_1.sort(key = lambda x:x[1])

for i in range(m):
  p_str = str(base_1[i][0])
  len_p = len(list(p_str))
  temp = "p"+p_str
  
  if temp not in key:
    key[temp] = 1
    count = str(1)
  else :
    a = key[temp]
    key[temp] = a + 1
    count = str(key[temp])
    
  len_count = len(list(count))
  
  for j in range(6-len_p):
    p_str = "0" + p_str
    
  for j in range(6-len_count):
    count = "0" + count
    
  ans_str.append(p_str + count)
  ans_n.append(base_1[i])

for i in range(m):
  print(ans_str[ans_n.index(base[i])])

Fixed submission:
n,m = map(int,input().split())
base_1 = []
key = {}
ans_str = []
ans_n = []

for i in range(m):
  p,y = map(int,input().split())
  base_1.append([p,y,i])
  
base_1.sort(key = lambda x:x[1])

for i in range(m):
  p_str = str(base_1[i][0])
  len_p = len(list(p_str))
  temp = "p"+p_str
  
  if temp not in key:
    key[temp] = 1
    count = str(1)
  else :
    a = key[temp]
    key[temp] = a + 1
    count = str(key[temp])
    
  len_count = len(list(count))
  
  for j in range(6-len_p):
    p_str = "0" + p_str
    
  for j in range(6-len_count):
    count = "0" + count
    
  base_1[i].append(p_str + count)
    
base_1.sort(key = lambda x:x[2])

for i in range(m):
  print(base_1[i][3])
Buggy python submission (verdict: Runtime Error):
n = int(input())
base = list(map(int,input().split()))
even = [0]*(10**5)
odd = [0]*(10**5)

for i in range(1,n+1):
  sign = i%2
  num = base[i-1]
  
  if sign == 0:
    even[num] += 1
  elif sign == 1:
    odd[num] += 1

ans_e = max(even)
ans_o = max(odd)
even_i = even.index(ans_e)
odd_i = odd.index(ans_o)

if even_i == odd_i:
  even.sort()
  odd.sort()
  if even[10**5 - 2] <= odd[10**5 - 2]:
    ans_o = odd[10**5 - 2]
  else:
    ans_e = even[10**5 - 2]
  
print(n - ans_e - ans_o)

Fixed submission:
n = int(input())
base = list(map(int,input().split()))
even = [0]*(10**5)
odd = [0]*(10**5)

for i in range(1,n+1):
  sign = i%2
  num = base[i-1]
  
  if sign == 0:
    even[num-1] += 1
  elif sign == 1:
    odd[num-1] += 1

ans_e = max(even)
ans_o = max(odd)
even_i = even.index(ans_e)
odd_i = odd.index(ans_o)

if even_i == odd_i:
  even.sort()
  odd.sort()
  if even[10**5 - 2] <= odd[10**5 - 2]:
    ans_o = odd[10**5 - 2]
  else:
    ans_e = even[10**5 - 2]
  
print(n - ans_e - ans_o)

Buggy python submission (verdict: Runtime Error):
n = int(input())
base = list(map(int,input().split()))
even = [0]*(10**5)
odd = [0]*(10**5)

for i in range(1,n+1):
  sign = i%2
  num = base[i-1]
  
  if sign == 0:
    even[num] += 1
  elif sign == 1:
    odd[num] += 1

ans_e = max(even)
ans_o = max(odd)
even_i = even.index(ans_e)
odd_i = odd.index(ans_o)

if even_i == odd_i:
  even.sort()
  odd.sort()
  if even[10*5 - 2] <= odd[10*5 - 2]:
    ans_o = odd[10**5 - 2]
  else:
    ans_e = even[10**5 - 2]
  
print(n - ans_e - ans_o)

Fixed submission:
n = int(input())
base = list(map(int,input().split()))
even = [0]*(10**5)
odd = [0]*(10**5)

for i in range(1,n+1):
  sign = i%2
  num = base[i-1]
  
  if sign == 0:
    even[num-1] += 1
  elif sign == 1:
    odd[num-1] += 1

ans_e = max(even)
ans_o = max(odd)
even_i = even.index(ans_e)
odd_i = odd.index(ans_o)

if even_i == odd_i:
  even.sort()
  odd.sort()
  if even[10**5 - 2] <= odd[10**5 - 2]:
    ans_o = odd[10**5 - 2]
  else:
    ans_e = even[10**5 - 2]
  
print(n - ans_e - ans_o)

Buggy python submission (verdict: Runtime Error):
n = int(input())
base = list(map(int,input().split()))
even = [0]*100000
odd = [0]*100000

for i in range(n):
  sign = i%2
  num = base[i]
  if sign == 0:
    even[num] += 1
  elif sign == 1:
    odd[num] += 1

ans_e = max(even)
ans_o = max(odd)
even_i = even.index(ans_e)
odd_i = odd.index(ans_o)

if even_i == odd_i:
  even.sort()
  odd.sort()
  if even[10*5 - 2] <= odd[10*5 - 2]:
    ans_o = odd[10*5 - 2]
  else:
    ans_e = even[10*5 - 2]
  
print(n - ans_e - ans_o)

Fixed submission:
n = int(input())
base = list(map(int,input().split()))
even = [0]*(10**5)
odd = [0]*(10**5)

for i in range(1,n+1):
  sign = i%2
  num = base[i-1]
  
  if sign == 0:
    even[num-1] += 1
  elif sign == 1:
    odd[num-1] += 1

ans_e = max(even)
ans_o = max(odd)
even_i = even.index(ans_e)
odd_i = odd.index(ans_o)

if even_i == odd_i:
  even.sort()
  odd.sort()
  if even[10**5 - 2] <= odd[10**5 - 2]:
    ans_o = odd[10**5 - 2]
  else:
    ans_e = even[10**5 - 2]
  
print(n - ans_e - ans_o)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**9
  
for i in range(n-k+1):
  if x[k-1+i]*x[i] < 0:
    if x[k-1+i] <= abs(x[i]) :
      temp = 2*x[k-1+i] - x[i]
    elif abs(x[i]) < x[k-1+i]:
      temp = x[k-1+i] - 2*x[i]
      
  elif (0 <= x[i]):
    temp = x[k+i-1]

  elif (x[k+i-1] <= 0) and ():
    temp = -x[0]
    
  if temp < ans:
    ans = temp
    
print(ans)

Fixed submission:
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**9
  
for i in range(n-k+1):
  if x[k-1+i]*x[i] < 0:
    if x[k-1+i] <= abs(x[i]) :
      temp = 2*x[k-1+i] - x[i]
    elif abs(x[i]) < x[k-1+i]:
      temp = x[k-1+i] - 2*x[i]
      
  elif (0 <= x[i]):
    temp = x[k+i-1]

  elif (x[k+i-1] <= 0):
    temp = -x[i]
    
  if temp < ans:
    ans = temp
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

print(math.log10(2**5000000000000000))

Fixed submission:
s = list(str(input()))
k = int(input())
ans = '1'

for i in range(k):
  if s[i] != '1':
    ans = s[i]
    break
  if len(s)-1 == i:
    break
    
print(int(ans))