Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())

ans=[0]*(N+1)
t=int(N**0.5+1)
for x in range(1, t):
    for y in range(1, t):
        for z in range(1, t):
            v=x*x+y*y+z*z+x*y+y*z+z*x
            if v<=N+1: ans[v]+=1
for i in range(1,N+1):
    print(ans[i])

Fixed submission:
N = int(input())

ans=[0]*(N+1)
t=int(N**0.5+1)
for x in range(1, t):
    for y in range(1, t):
        for z in range(1, t):
            v=x*x+y*y+z*z+x*y+y*z+z*x
            if v<=N: ans[v]+=1
for i in range(1,N+1):
    print(ans[i])

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

for i in range(1,N+1):
    cnt=0
    t=int(N**0.5+1)
    for x in range(1, t):
        for y in range(1, t):
            for z in range(1, t):
                if i == x**2 + y**2 + z**2 + x*y + y*z + z*x:
                    cnt = cnt+1
    print(cnt)

Fixed submission:
N = int(input())

ans=[0]*(N+1)
t=int(N**0.5+1)
for x in range(1, t):
    for y in range(1, t):
        for z in range(1, t):
            v=x*x+y*y+z*z+x*y+y*z+z*x
            if v<=N: ans[v]+=1
for i in range(1,N+1):
    print(ans[i])

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

t = 1001

for i in range(1, N+1):
    cnt = 0
    for x in range(1, t):
        if N < (x**2 + x) : break 
        for y in range(1, t):
            if N < (x**2 + y**2 + x*y + y + x ) : break
            for z in range(1, t):
                if N < (x**2 + y**2 + z**2 + x*y + y*z + z*x ) : break    
                
                if i ==  (x**2 + y**2 + z**2 + x*y + y*z + z*x ):
                    cnt = cnt+1
    print(cnt)

Fixed submission:
N = int(input())

ans=[0]*(N+1)
t=int(N**0.5+1)
for x in range(1, t):
    for y in range(1, t):
        for z in range(1, t):
            v=x*x+y*y+z*z+x*y+y*z+z*x
            if v<=N: ans[v]+=1
for i in range(1,N+1):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
*A,=map(int,input().split())
*B,=map(int,input().split())


AX=[0]*(N+1)
na=N+1
for i in range(1,N+1):
    AX[i]=AX[i-1]+A[i-1]
    if K<AX[i]:
        na=i
        break

BX=[0]*(M+1)
nb=M+1
for i in range(1,M+1):
    BX[i]=BX[i-1]+B[i-1]
    if K<BX[i]:
        nb=i
        break

ans=0
for i in range(na):
 for j in range(nb):
   if K < AX[i]+BX[j]:break
   ans=max(ans,i+j)
            
print(ans)

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

AX=[0]*(N+1)
na=N+1
for i in range(1,N+1):
    AX[i]=AX[i-1]+A[i-1]
    if K<AX[i]:na=min(na,i)

BX=[0]*(M+1)
nb=M+1
for i in range(1,M+1):
    BX[i]=BX[i-1]+B[i-1]
    if K<BX[i]:nb=min(nb,i)

import bisect        
ans=0
for i in range(na):
 j=bisect.bisect_right(BX,K-AX[i])-1
 # print(na,t,i,j)
 ans=max(ans,i+j)
            
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
*A,=map(int,input().split())
*B,=map(int,input().split())


AX=[0]*(N+1)
na=N+1
for i in range(1,N+1):
    AX[i]=AX[i-1]+A[i-1]
    if K<AX[i]:na=min(na,i)

BX=[0]*(M+1)
nb=M+1
for i in range(1,M+1):
    BX[i]=BX[i-1]+B[i-1]
    if K<BX[i]:nb=min(nb,i)

ans=0
for i in range(na):
 for j in range(nb):
   if K < AX[i]+BX[j]:break
   ans=max(ans,i+j)
            
print(ans)

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

AX=[0]*(N+1)
na=N+1
for i in range(1,N+1):
    AX[i]=AX[i-1]+A[i-1]
    if K<AX[i]:na=min(na,i)

BX=[0]*(M+1)
nb=M+1
for i in range(1,M+1):
    BX[i]=BX[i-1]+B[i-1]
    if K<BX[i]:nb=min(nb,i)

import bisect        
ans=0
for i in range(na):
 j=bisect.bisect_right(BX,K-AX[i])-1
 # print(na,t,i,j)
 ans=max(ans,i+j)
            
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
*A,=map(int,input().split())
*B,=map(int,input().split())

AX=[0]*(N+1)
for i in range(1,N+1):AX[i]=AX[i-1]+A[i-1]

BX=[0]*(M+1)
for i in range(1,M+1):BX[i]=BX[i-1]+B[i-1]

import bisect
ni=bisect.bisect_right(AX,K)
mi=bisect.bisect_right(BX,K)
    
ans=0
for i in range(ni):
 for j in range(mi):
   if K < AX[i]+BX[j]:break
   ans=max(ans,i+j)
            
print(ans)

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

AX=[0]*(N+1)
na=N+1
for i in range(1,N+1):
    AX[i]=AX[i-1]+A[i-1]
    if K<AX[i]:na=min(na,i)

BX=[0]*(M+1)
nb=M+1
for i in range(1,M+1):
    BX[i]=BX[i-1]+B[i-1]
    if K<BX[i]:nb=min(nb,i)

import bisect        
ans=0
for i in range(na):
 j=bisect.bisect_right(BX,K-AX[i])-1
 # print(na,t,i,j)
 ans=max(ans,i+j)
            
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
X=list(map(int, input().split()))

ans=1
if 0 in X:
    print(0)
else:
    X.sorted(reverse = True)
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)    

Fixed submission:
N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

Buggy python submission (verdict: Runtime Error):
_=input()
X=int(eval(input().replace(*' *')))
print(X if X <= 1e18 else -1)

Fixed submission:
N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

Buggy python submission (verdict: Runtime Error):
_=input()
X=int(eval(input().replace(*' *')))
print(X if X=<1e18 else -1)

Fixed submission:
N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=list(map(int, input().split()))
ans=1
for i in range(N):
    ans *= X[i]

print(ans if ans<=10**18 else -1)    

Fixed submission:
N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

Buggy python submission (verdict: Runtime Error):
_=input()
X=eval(input().replace(*' *'))
print(X if X<10**18 else -1)

Fixed submission:
N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

Buggy python submission (verdict: Runtime Error):
_=input()
X=eval(input().replace(*' *'))
print(X if X<= 10**18 else -1)

Fixed submission:
N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=tuple(map(int,input().split()))

for i in range(1,N+1):
    print(A.count(i))

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

import bisect

for i in range(1,N+1):
    print(bisect.bisect_right(A,i)-bisect.bisect_left(A,i))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())

X=[A.count(i)for i in range(1,N+1)]

for x in X:print(x)

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

import bisect

for i in range(1,N+1):
    print(bisect.bisect_right(A,i)-bisect.bisect_left(A,i))
Buggy python submission (verdict: Time Limit Exceeded):
r=range(1,int(input())+1)
import math
from functools import reduce
def g(*n):return reduce(math.gcd, n)
print(sum(g(a,b,c) for a in r for b in r for c in r))

Fixed submission:
r=range(1,int(input())+1)
from math import gcd 
print(sum(gcd(gcd(a,b),c) for a in r for b in r for c in r))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*P,=map(int,input().split())

print(sum(P[i] <=min(set(P[:i+1])) for i in range(N)))

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

mi=P[0]
cnt=0
for i in range(N):
    if P[i]<mi:mi=P[i]
    if P[i]<=mi:cnt+=1
       
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*P,=map(int,input().split())

print(sum(P[i] <=min(P[:i+1]) for i in range(N)))

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

mi=P[0]
cnt=0
for i in range(N):
    if P[i]<mi:mi=P[i]
    if P[i]<=mi:cnt+=1
       
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*P,=map(int,input().split())

print(sum(list(filter(lambda x: x<P[i], set(P[:i+1])))==[] for i in range(N)))

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

mi=P[0]
cnt=0
for i in range(N):
    if P[i]<mi:mi=P[i]
    if P[i]<=mi:cnt+=1
       
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*P,=map(int,input().split())

print(sum(list(filter(lambda x: x<P[i], P[:i+1]))==[] for i in range(N)))

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

mi=P[0]
cnt=0
for i in range(N):
    if P[i]<mi:mi=P[i]
    if P[i]<=mi:cnt+=1
       
print(cnt)
Buggy python submission (verdict: Runtime Error):
S=input()
print("NYoe s"[len(re.sub("[RUD]",'',S[0::2]))==0==len(re.sub("[LUD]",'',S[1::2]))::2])

Fixed submission:
import re
S=input()
print("NYoe s"[len(re.sub("[RUD]",'',S[0::2]))==0==len(re.sub("[LUD]",'',S[1::2]))::2])
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
A=[int(input()) for _ in range(Q)]

p=[K]*N

for a in A:
    p = list(map(lambda x:x-1, p))
    p[a-1]+=1
for i in p:
    print('Yes' if 0<i else 'No')

Fixed submission:
N,K,Q=map(int,input().split())
A=[0]*N
for _ in range(Q):
    A[int(input())-1]+=1
p=[K-Q]*N

for a,b in zip(A,p):
    print('Yes' if 0<a+b else 'No')
Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())
G=[list(map(int,input().split())) for _ in range(N-1)]
P=[list(map(int,input().split())) for _ in range(Q)]

gr=[[]]*N
for i in G:
    v=i[0]
    gr[v-1]=[*gr[v-1],i[1]]

cnt=[0]*N

def dfs(p,x):
    cnt[p-1]+=x
    for n in gr[p-1]:
        dfs(n,x)
    return

for p,x in P:
    dfs(p,x)
print(' '.join(map(str,cnt)))

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
 
N, Q = map(int, input().split())
graph = [[] for i in range(N)]
cnt = [0]*N

# 入力しながらグラフを作成
for i in range(N-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  graph[a].append(b)
  graph[b].append(a)

# 初期値を設定
for i in range(Q):
  p, x = map(int, input().split())
  cnt[p-1] += x

v = [False]*N

# stack=[]
def dfs(n,prv):
  # stack.append(n)
  if v[n]: return
  cnt[n] += prv
  v[n] = True
  for nv in graph[n]:
    dfs(nv, cnt[n])
   
dfs(0,0)
print(*cnt)
# print(stack)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[''.join(sorted(input())) for _ in range(N)]
import itertools
l=itertools.combinations(range(N), 2)
cnt=0
for x,y in l:
     if S[x]==S[y]: cnt+=1
print(cnt)

Fixed submission:
N=int(input())
S=[''.join(sorted(input())) for _ in range(N)]
ans=0
import collections
from math import factorial
c = collections.Counter(S)
for i in c.values():
    if 2<=i:
        ans+=factorial(i)//(factorial(i-2)*factorial(2))

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

p1=p2=0
for i in H:
   print(prv,i,i<prv-1,prv<=i, prv-1<=i)
   if i<max(p2,p1-1):
    #print('No')
    break
   if i<p1:
    p2=p1-1
   else:
    p2=p1
   p1=i
else:
    print('Yes')

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

for i in range(-1,-len(H),-1):
   #print(i,H[i],H[i-1])
   if H[i]<H[i-1]-1:
    print('No')
    break
   if H[i-1]-1 == H[i]:
    H[i-1]=H[i]
else:
   print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):

N,M=map(int,input().split())
LR=[list(map(int,input().split())) for _ in range(M)]
cnt=0
for i in range(1,N+1):
    for l,r in LR:
        if i<l or r<i:
            break
    else:
        cnt+=1
print(cnt)

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

mm=0
mx=10**5
for _ in range(M):
    l,r = map(int,input().split())
    mm = max(mm,l)
    mx= min(mx,r)
print(max(mx-mm+1,0))
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
LR=[list(map(int,input().split())) for _ in range(Q)]

F=[0]*len(S)
for i in range(N):
    if S[i:i+2]=='AC':
        F[i]=1
for l,r in LR:
    print(sum(F[l-1:r-1]))

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

F=[0]*len(S)
for i in range(N-1):
    F[i+1]+=F[i]+(1 if S[i:i+2]=='AC' else 0)
    #print(i,F,S[i:i+2])
for l,r in LR:
    print(F[r-1]-F[l-1])

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

for l,r in LR:
    tmp=S[l-1:r]
    ans=0
    for i in range(len(tmp)-1):
        #print(tmp, tmp[i:i+2])
        if tmp[i:i+2]=='AC':
            ans+=1
    print(ans)

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

F=[0]*len(S)
for i in range(N-1):
    F[i+1]+=F[i]+(1 if S[i:i+2]=='AC' else 0)
    #print(i,F,S[i:i+2])
for l,r in LR:
    print(F[r-1]-F[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*H,=map(int,input().split())
L=len(H)

ans=False
cnt=0
while ans==False:
    cnt+=1
    m=max(H)
    for i in range(H.index(m), L):
        if H[i]==m:
            H[i]-=1
        else:
            break
    if sum(H)==0: ans=True
print(cnt)

Fixed submission:
N=int(input())
*H,=map(int,input().split())
L=len(H)

cnt=0
prv=0

for i in range(N):
    if  prv < H[i]:
        cnt+=H[i]-prv
    prv=H[i]
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
*H,=map(int,input().split())

D=[float("inf")]*N
D[0]=0
D[1]=abs(H[1]-H[0])
for i in range(2,N):
  # print(i, "before:",D)
    D[i]=min(abs(H[i]-H[i-k])+D[i-k] for k in range(1,K+1))
  # print(i, "after:",D)

print(D[-1])

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

D=[float("inf")]*N
D[0]=0
D[1]=abs(H[1]-H[0])
for i in range(2,N):
  # print(i, "before:",D)
  #  print(i,i-1,i-K, max(1, i-K))
  D[i]=min(abs(H[i]-H[k])+D[k] for k in range(max(0,i-K),i))
  # print(i, "after:",D)

print(D[-1])

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

D=[float("inf")]*N
D[0]=0
D[1]=abs(H[1]-H[0])
for i in range(2,N):
  # print(i, "before:",D)
    D[i]=min(D[i], *[abs(H[i]-H[i-k])+D[i-k] for k in range(1,K+1)])
  # print(i, "after:",D)

print(D[-1])

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

D=[float("inf")]*N
D[0]=0
D[1]=abs(H[1]-H[0])
for i in range(2,N):
  # print(i, "before:",D)
  #  print(i,i-1,i-K, max(1, i-K))
  D[i]=min(abs(H[i]-H[k])+D[k] for k in range(max(0,i-K),i))
  # print(i, "after:",D)

print(D[-1])

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

D=[float("inf")]*N
D[0]=0

for i in range(1,N):
  # print(i, "before:",D)
  for k in range(1,K+1):
    if i-k<0:continue
    D[i]=min(D[i], abs(H[i]-H[i-k])+D[i-k])
  # print(i, "after:",D)

print(D[-1])

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

D=[float("inf")]*N
D[0]=0
D[1]=abs(H[1]-H[0])
for i in range(2,N):
  # print(i, "before:",D)
  #  print(i,i-1,i-K, max(1, i-K))
  D[i]=min(abs(H[i]-H[k])+D[k] for k in range(max(0,i-K),i))
  # print(i, "after:",D)

print(D[-1])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

N,K=map(int,input().split())
H=[int(input()) for _ in range(N)]

ans=10**9
for i in combinations(H, K):
    ans=min(ans,max(i)-min(i))
print(ans)

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

H=sorted(H)
ans=10**9
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):
N,M=map(int,input().split())
d={}
PY=[]
for _ in range(M):
    p,y=map(int,input().split())
    PY.append((p,y))
    d[p]=d.get(p, [])+[y]

dx={}
for k, v in d.items():
    sv=sorted(v)
    for i in range(len(sv)):
        dx[(k,sv[i])]=i+1
        
for p,y in PY:
    print(str(p).zfill(6)+str(dx[(p,y)]).zfill(6))

Fixed submission:
N,M=map(int,input().split())
d={}
PY=[]
import bisect
for _ in range(M):
    p,y=map(int,input().split())
    PY.append((p,y))
    t=d.get(p, [0])
    i=bisect.bisect_left(t,y)
    t.insert(i,y)
    d[p]=t
    
dx={}
for k, v in d.items():
    for i in range(len(v)):
        dx[(k,v[i])]=i
        
for p,y in PY:
    print(str(p).zfill(6)+str(dx[(p,y)]).zfill(6))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
d={}
PY=[]
for _ in range(M):
    p,y=map(int,input().split())
    PY.append((p,y))
    d[p]=d.get(p, [])+[y]

import bisect

for k, v in d.items():
    d[k]=sorted(v)

for p,y in PY:
    print(str(p).zfill(6)+str(bisect.bisect_left(d[p],y)+1).zfill(6))

Fixed submission:
N,M=map(int,input().split())
d={}
PY=[]
import bisect
for _ in range(M):
    p,y=map(int,input().split())
    PY.append((p,y))
    t=d.get(p, [0])
    i=bisect.bisect_left(t,y)
    t.insert(i,y)
    d[p]=t
    
dx={}
for k, v in d.items():
    for i in range(len(v)):
        dx[(k,v[i])]=i
        
for p,y in PY:
    print(str(p).zfill(6)+str(dx[(p,y)]).zfill(6))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for _ in range(M)]
d={}
import bisect

for p,y in PY:
    d[p]=d.get(p, [])+[y]

for k, v in d.items():
    d[k]=sorted(v)

for p,y in PY:
    print(str(p).zfill(6)+str(bisect.bisect_left(d[p],y)+1).zfill(6))

Fixed submission:
N,M=map(int,input().split())
d={}
PY=[]
import bisect
for _ in range(M):
    p,y=map(int,input().split())
    PY.append((p,y))
    t=d.get(p, [0])
    i=bisect.bisect_left(t,y)
    t.insert(i,y)
    d[p]=t
    
dx={}
for k, v in d.items():
    for i in range(len(v)):
        dx[(k,v[i])]=i
        
for p,y in PY:
    print(str(p).zfill(6)+str(dx[(p,y)]).zfill(6))
Buggy python submission (verdict: Runtime Error):
N=int(input())
*V,=map(int,input().split())
import Counter from collections 

c1=Counter(V[0::2]).most_common()+[(0,0)]
c2=Counter(V[1::2]).most_common()+[(0,0)]
if c1[0][0]!=c2[0][0]:
    print(N-c1[0][1]-c2[0][1])
else:
    print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))

Fixed submission:
N=int(input())
*V,=map(int,input().split())
import collections

import collections

c1=collections.Counter(V[0::2])
c1=sorted(c1.items(), key=lambda x: x[1], reverse=True)
e=c1[0][0]

c2=collections.Counter(V[1::2])
c2=sorted(c2.items(), key=lambda x: x[1], reverse=True)
o=c2[0][0]

cnt=0
if e!=o:
    cnt=sum(e!=i for i in V[0::2])
    cnt+=sum(o!=i for i in V[1::2])
else:
    if len(c1)==1 and len(c2)==1:
        cnt=N//2
    elif len(c1)==1:
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(e!=i for i in V[0::2])
        cnt2+=sum(c2[1][1]!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    elif len(c2)==1:
        cnt1=sum(c1[1][0]!=i for i in V[0::2])
        cnt1+=sum(o!=i for i in V[1::2])

        cnt2=sum(c1[1][1]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    else:    
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(c1[1][0]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
print(cnt)

Buggy python submission (verdict: Runtime Error):
N=int(input())
*V,=map(int,input().split())
import collections import Counter

c1=Counter(V[0::2]).most_common()+[(0,0)]
c2=Counter(V[1::2]).most_common()+[(0,0)]
if c1[0][0]!=c2[0][0]:
    print(N-c1[0][1]-c2[0][1])
else:
    print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))

Fixed submission:
N=int(input())
*V,=map(int,input().split())
import collections

import collections

c1=collections.Counter(V[0::2])
c1=sorted(c1.items(), key=lambda x: x[1], reverse=True)
e=c1[0][0]

c2=collections.Counter(V[1::2])
c2=sorted(c2.items(), key=lambda x: x[1], reverse=True)
o=c2[0][0]

cnt=0
if e!=o:
    cnt=sum(e!=i for i in V[0::2])
    cnt+=sum(o!=i for i in V[1::2])
else:
    if len(c1)==1 and len(c2)==1:
        cnt=N//2
    elif len(c1)==1:
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(e!=i for i in V[0::2])
        cnt2+=sum(c2[1][1]!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    elif len(c2)==1:
        cnt1=sum(c1[1][0]!=i for i in V[0::2])
        cnt1+=sum(o!=i for i in V[1::2])

        cnt2=sum(c1[1][1]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    else:    
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(c1[1][0]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
*X,=map(int,input().split())

import bisect

i=bisect.bisect_left(X,0)
L=max(0, bisect.bisect_right(X,0)-K)
R=min(N-1, bisect.bisect_left(X,0)+K-1)

ans=float('inf')
for i in range(L,R-K+2):
    t=0
    s=X[i:i+K]
    if s[-1]<=0:
        t+=abs(s[0])
    elif 0<=s[0]:
        t+=s[-1]
    else:
        t+=min(abs(s[0]),s[-1])*2+max(abs(s[0]),s[-1]) 
    # print(s,t)
    ans=min(ans,t)
print(ans)

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

import bisect

i=bisect.bisect_left(X,0)
L=max(0, bisect.bisect_right(X,0)-K)
R=min(N-1, bisect.bisect_left(X,0)+K-1)

ans=float('inf')

for i in range(L,R-K+2):
    t=0
    l=X[i]
    r=X[i+K-1]
    if r<=0:
        t=abs(l)
    elif 0<=l:
        t=r
    else:
        t=min(abs(l),r)*2+max(abs(l),r) 
    # print(X[i:i+K],t)
    ans=min(ans,t)
print(ans)

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

import bisect

i=bisect.bisect_left(X,0)
L=max(0, bisect.bisect_right(X,0)-K)
R=min(N-1, bisect.bisect_left(X,0)+K-1)

ans=float('inf')
for i in range(L,R-K+2):
    t=0
    s=X[i:i+K]
    if s[0]<0:
        t+=abs(s[0])
    if 0<X[-1]:
        t+=t+s[-1]
    # print(s,t)
    ans=min(ans,t)
print(ans)

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

import bisect

i=bisect.bisect_left(X,0)
L=max(0, bisect.bisect_right(X,0)-K)
R=min(N-1, bisect.bisect_left(X,0)+K-1)

ans=float('inf')

for i in range(L,R-K+2):
    t=0
    l=X[i]
    r=X[i+K-1]
    if r<=0:
        t=abs(l)
    elif 0<=l:
        t=r
    else:
        t=min(abs(l),r)*2+max(abs(l),r) 
    # print(X[i:i+K],t)
    ans=min(ans,t)
print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())

for i in range(K):
    if s[i]!='1':
        print(int(s[i]))
        break
else:
    print(1)

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

for i in range(K):
    if S[i]!='1':
        print(int(S[i]))
        break
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*X,=map(int,input().split())


import statistics

for i in range(len(X)):
    t=X[:i]+X[i+1:]
    print(statistics.median(t))

Fixed submission:
N=int(input())
*X,=map(int,input().split())
s=sorted(X)

t1=s[N//2-1]
t2=s[N//2]

for x in X:
    if x<=t1:
        print(t2)
    else:
        print(t1)
Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv

# print(args[0])

x1 = int(args[1])
x2 = int(args[2])

if (x1 * x2) % 2 == 0 :
    print("Even")
else:
    print("Odd")

Fixed submission:
a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")