Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
rr = 0
gg = 0
bb = 0
for i in range(n):
    if s[i] == "R":
        rr += 1
    if s[i] == "G":
        gg += 1
    if s[i] == "B":
        bb += 1

ans = rr * gg * bb

for i in range(n):
    for j in range(n):
        if j - i >= 0 and j + i < n:
            if s[j - i] != s[j] and s[j] != s[j + i] and s[j + i] != s[j - i]:
                ans -= 1
print(ans)


Fixed submission:
n = int(input())
s = input()
rr = 0
gg = 0
bb = 0
for i in range(n):
    if s[i] == "R":
        rr += 1
    if s[i] == "G":
        gg += 1
    if s[i] == "B":
        bb += 1

ans = rr * gg * bb

for j in range(n):
    for i in range(min(j+1, n-j)):
        if s[j - i] != s[j] and s[j] != s[j + i] and s[j + i] != s[j - i]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def fun(a, b, c):
    global ans
    for i in range(len(a)):
        for j in range(len(b)):
            if (a[i] > b[j]):
                continue
            for k in range(len(c)):
                if (b[j] > c[k]):
                    continue
                if b[j] - a[i] != c[k] - b[j]:
                    ans += 1


n = int(input())
s = input()
r = [0] * n
g = [0] * n
b = [0] * n
rr = 0
gg = 0
bb = 0
ans = 0
for i in range(n):
    if s[i] == "R":
        r[rr] = i
        rr += 1
    if s[i] == "G":
        g[gg] = i
        gg += 1
    if s[i] == "B":
        b[bb] = i
        bb += 1

r = r[:rr]
g = g[:gg]
b = b[:bb]

fun(r, g, b)
fun(r, b, g)
fun(g, r, b)
fun(g, b, r)
fun(b, r, g)
fun(b, g, r)

print(ans)


Fixed submission:
n = int(input())
s = input()
rr = 0
gg = 0
bb = 0
for i in range(n):
    if s[i] == "R":
        rr += 1
    if s[i] == "G":
        gg += 1
    if s[i] == "B":
        bb += 1

ans = rr * gg * bb

for j in range(n):
    for i in range(min(j+1, n-j)):
        if s[j - i] != s[j] and s[j] != s[j + i] and s[j + i] != s[j - i]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def fun(a, b, c):
    global ans
    for i in range(len(a)):
        for j in range(len(b)):
            for k in range(len(c)):
                if a[i] < b[j] and b[j] < c[k] and b[j] - a[i] != c[k] - b[j]:
                    ans += 1


n = int(input())
s = input()
r = [0] * n
g = [0] * n
b = [0] * n
rr = 0
gg = 0
bb = 0
ans = 0
for i in range(n):
    if s[i] == "R":
        r[rr] = i
        rr += 1
    if s[i] == "G":
        g[gg] = i
        gg += 1
    if s[i] == "B":
        b[bb] = i
        bb += 1

r = r[:rr]
g = g[:gg]
b = b[:bb]

fun(r, g, b)
fun(r, b, g)
fun(g, r, b)
fun(g, b, r)
fun(b, r, g)
fun(b, g, r)

print(ans)


Fixed submission:
n = int(input())
s = input()
rr = 0
gg = 0
bb = 0
for i in range(n):
    if s[i] == "R":
        rr += 1
    if s[i] == "G":
        gg += 1
    if s[i] == "B":
        bb += 1

ans = rr * gg * bb

for j in range(n):
    for i in range(min(j+1, n-j)):
        if s[j - i] != s[j] and s[j] != s[j + i] and s[j + i] != s[j - i]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p)
q=sorted(q)
r=sorted(r)
p=p[(a-x):]
q=q[(b-y):]
res=sum(p)+sum(q)
tp=0
tq=0
tr=c-1
while(p[tp]<r[tr] or q[tq]<r[tr]):
  if(p[tp]<q[tq]):
    res+=r[tr]-p[tp]
    tp+=1
  else:
    res+=r[tr]-q[tq]
    tq+=1
  tr-=1
print(res)

Fixed submission:
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p)
q=sorted(q)
r=sorted(r)
p=p[(a-x):]
q=q[(b-y):]
res=sum(p)+sum(q)
tp=0
tq=0
tr=c-1
while 1:
  if(tr<0 ):
    break
  if(tp>=x):
    pp=100000000000
  else:
    pp=p[tp]
  if(tq>=y):
    qq=100000000000
  else:
    qq=q[tq]

  if(pp>r[tr] and qq>r[tr]):
    break
  if(pp<qq ):
    res+=r[tr]-pp
    tp+=1
  else:
    res+=r[tr]-qq
    tq+=1
  tr-=1
print(res)

Buggy python submission (verdict: Runtime Error):
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p)
q=sorted(q)
r=sorted(r)
p=p[(a-x):]
q=q[(b-y):]
res=sum(p)+sum(q)
tp=0
tq=0
tr=c-1
while(p[tp]<r[tr] or q[tq]<r[tr]):
  if(p[tp]<q[tq]):
    res+=r[tr]-p[tp]
    tp-=1
  else:
    res+=r[tr]-q[tq]
    tq-=1
  tr-=1
print(res)
    



Fixed submission:
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p)
q=sorted(q)
r=sorted(r)
p=p[(a-x):]
q=q[(b-y):]
res=sum(p)+sum(q)
tp=0
tq=0
tr=c-1
while 1:
  if(tr<0 ):
    break
  if(tp>=x):
    pp=100000000000
  else:
    pp=p[tp]
  if(tq>=y):
    qq=100000000000
  else:
    qq=q[tq]

  if(pp>r[tr] and qq>r[tr]):
    break
  if(pp<qq ):
    res+=r[tr]-pp
    tp+=1
  else:
    res+=r[tr]-qq
    tq+=1
  tr-=1
print(res)
Buggy python submission (verdict: Runtime Error):

A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())
b=[0]*N
for i in range(N):
  print(i)
  b[i]=int(input())
C1=any([i == A1[0] for i in b])
C2=any([i == A1[1] for i in b])
C3=any([i == A1[2] for i in b])
C4=any([i == A2[0] for i in b])
C5=any([i == A2[1] for i in b])
C6=any([i == A2[2] for i in b])
C7=any([i == A3[0] for i in b])
C8=any([i == A3[1] for i in b])
C9=any([i == A3[2] for i in b])

if(any(all(C1,C2,C3),all(C4,C5,C6),all(C7,C8,C9),all(C1,C4,C7),all(C2,C5,C8),all(C3,C6,C9),all(C1,C5,C9),all(C3,C5,C7)):
   print("Yes")
else:
   print("No")

Fixed submission:
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())
b=[0]*N
for i in range(N):
  b[i]=int(input())
C1=any([i == A1[0] for i in b])
C2=any([i == A1[1] for i in b])
C3=any([i == A1[2] for i in b])
C4=any([i == A2[0] for i in b])
C5=any([i == A2[1] for i in b])
C6=any([i == A2[2] for i in b])
C7=any([i == A3[0] for i in b])
C8=any([i == A3[1] for i in b])
C9=any([i == A3[2] for i in b])

if(any([all([C1,C2,C3]),all([C4,C5,C6]),all([C7,C8,C9]),all([C1,C4,C7]),all([C2,C5,C8]),all([C3,C6,C9]),all([C1,C5,C9]),all([C3,C5,C7])])):
   print("Yes")
else:
   print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=[int(e) for e in input().split()]
flg=0
for i in range(N-1):
    if(flg==0):
        for j in range(i+1,N):
            if(flg==0):
                if a[i]==a[j]:
                    flg=1
                    print("NO")

if(flg==0):
    print("YES")

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

a.sort()
flg=0
if(a[0]==a[1]):
    flg=1
for i in range(1,N-1):
    if(a[i]==a[i-1]):
        flg=1
if flg==1:
    print("NO")
else:
    print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=[int(e) for e in input().split()]
flg=0
for i in range(N-1):
    for j in range(i+1,N):
      if a[i]==a[j]:
          flg=1
if(flg==1):
    print("NO")
else:
    print("YES")

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

a.sort()
flg=0
if(a[0]==a[1]):
    flg=1
for i in range(1,N-1):
    if(a[i]==a[i-1]):
        flg=1
if flg==1:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))

s = 2
l = [0]*n
maxs = 0
suma = sum(a)
while s < suma:
    if s > math.sqrt(suma):
        break
    if sum(a)%s == 0:
        for i in range(n):
            l[i] = a[i]%s
        l.sort()
        sml = sum(l)
        ns = sml//s
        if sml%s == 0 and -sum(l[len(l)-ns:len(l)])+ns*s<=k:
            maxs = s
        s = s + 1
    else:
        s = s + 1
print(maxs)

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


def d(x):
    l = []
    for i in range(1, int(x**0.5)+1):
        if x%i==0:
            l.append(i)
            if i != x//i:
                l.append(x//i)
    l.sort(reverse=True)
    return l

s = d(sum(a))
for i in s:
    x = [0 for k in range(n)]
    for j in range(len(a)):
        x[j] = a[j] % i
    x.sort()
    l = [0 for k in range(n+1)]
    r = [0 for k in range(n+1)]
    for j in range(n+1):
        if j == 0:
            l[0] = 0
            r[n-0] = 0
        else:
            l[j] = l[j-1] + x[j-1]
            r[n-j] = r[n-j+1] + (i-x[n-j])
    ans = 1
    for j in range(n+1):
        if l[j] == r[j] and l[j] <= k:
            ans = i
            print(ans)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(1,n+1):
    a.append(int(input()))
    
mx = max(a)
for j in range(1,n+1):
    if a[j-1] == mx:
        print(max(a[0:j-1]+a[j:n]))
    else:
        print(mx)


Fixed submission:
n = int(input())
a = []
mx12 = [0,0]
for i in range(1,n+1):
    a.append(int(input()))
    if min(mx12) <= a[-1]:
        mx12.sort()
        mx12[0] = mx12[1]
        mx12[1] = a[-1]
mx12.sort()
for j in range(1,n+1):
    if a[j-1] == mx12[1]:
        print(mx12[0])
    else:
        print(mx12[1])
Buggy python submission (verdict: Runtime Error):
5 1
1
2
3
4
5

Fixed submission:
import math
n,d = map(int,input().split())
x = []
for i in range(0,n):
    x.append(list(map(int,input().split())))
def f(a,b):
    s = 0
    for l in range(0,d):
        s+=(a[l]-b[l])**2
    return math.sqrt(s)
count = 0
for j in range(0,n):
    for k in range(0,n):
        if not (j==k):
            if f(x[j],x[k])%1==0:
                count = count + 1

print(int(count/2))
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
s = 2019
for k in range(l,r):
    i = k
    for l in range(i+1,r+1):
        j = l
        mo = (i*j)%2019
        if s > mo:
            s = mo
print(s)

Fixed submission:
l,r = map(int,input().split())
r=min(r,l+2019)
s = 2019
for k in range(l,r):
    i = k
    for l in range(i+1,r+1):
        j = l
        mo = (i*j)%2019
        if s > mo:
            s = mo
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
s = 2019
for k in range(l,r):
    i = k
    for l in range(i+1,r+1):
        j = l
        if s > i*j%2019:
            s = i*j%2019
print(s)

Fixed submission:
l,r = map(int,input().split())
r=min(r,l+2019)
s = 2019
for k in range(l,r):
    i = k
    for l in range(i+1,r+1):
        j = l
        mo = (i*j)%2019
        if s > mo:
            s = mo
print(s)
Buggy python submission (verdict: Runtime Error):


import sys
sys.setrecursionlimit(10000)

n, k = map(int,input().split())
nck = {}

def c(n,k):
    if k == 0 or n==k:
        return 1
    elif n<k:
        return 0
    elif k == 1:
        return n  
    elif (n,k) in nck:
        return nck[(n,k)]
    else:
        nck[n,k] = c(n-1,k-1)+c(n-1,k)
        return nck[n,k]

for j in range(1,k+1):
    r = (c(n-k+1,j)*c(k-1,j-1))%(10**9+7)
    print(r)

Fixed submission:
s = input()


s1 = s[0]
if s.count(s1) == 2:
    s = s.replace(s1,"")
    s2 = s[0]
    if s.count(s2) == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
p,q,r = map(int,input().split())
print(min(min(p+q,q+r),r+p)))

Fixed submission:
p,q,r = map(int,input().split())
print(min(p+q,q+r,r+p))

Buggy python submission (verdict: Runtime Error):
p,q,r = map(int,input().split)
print(min(p+q,q+r,r+p))

Fixed submission:
p,q,r = map(int,input().split())
print(min(p+q,q+r,r+p))
Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
s = []
for i in range(h):
    s.append(input())

u = [[0 for i in range(w)] for j in range(h)]
d = [[0 for i in range(w)] for j in range(h)]
l = [[0 for i in range(w)] for j in range(h)]
r = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            u[i][j] = 0
        else:
            if i == 0:
                u[i][j] = 1
            else:
                u[i][j] = u[i-1][j] + 1

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            l[i][j] = 0
        else:
            if j == 0:
                l[i][j] = 1
            else:
                l[i][j] = l[i][j-1] + 1

for i in range(h-1,-1,-1):
    for j in range(w):
        if s[i][j] == "#":
            d[i][j] = 0
        else:
            if i == h-1:
                d[i][j] = 1
            else:
                d[i][j] = d[i+1][j] + 1

for i in range(h):
    for j in range(w-1,-1,-1):
        if s[i][j] == "#":
            r[i][j] = 0
        else:
            if j == w-1:
                r[i][j] = 1
            else:
                r[i][j] = r[i][j+1] + 1

s = [[0 for i in range(w)] for j in range(h)] 
maxs = 0
for i in range(h):
    for j in range(w):
        s[i][j] = u[i][j] + l[i][j] + d[i][j] + r[i][j] - 3
        maxs = max(maxs,s[i][j])

print(maxs)

Fixed submission:


h,w = map(int,input().split())
s = []
for i in range(h):
    s.append(input())

u = [[0 for i in range(w)] for j in range(h)]
d = [[0 for i in range(w)] for j in range(h)]
l = [[0 for i in range(w)] for j in range(h)]
r = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            u[i][j] = 0
        else:
            if i == 0:
                u[i][j] = 1
            else:
                u[i][j] = u[i-1][j] + 1

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            l[i][j] = 0
        else:
            if j == 0:
                l[i][j] = 1
            else:
                l[i][j] = l[i][j-1] + 1

for i in range(h-1,-1,-1):
    for j in range(w):
        if s[i][j] == "#":
            d[i][j] = 0
        else:
            if i == h-1:
                d[i][j] = 1
            else:
                d[i][j] = d[i+1][j] + 1

for i in range(h):
    for j in range(w-1,-1,-1):
        if s[i][j] == "#":
            r[i][j] = 0
        else:
            if j == w-1:
                r[i][j] = 1
            else:
                r[i][j] = r[i][j+1] + 1

s = [[0 for i in range(w)] for j in range(h)] 
maxs = 0
for i in range(h):
    for j in range(w):
        s[i][j] = u[i][j] + l[i][j] + d[i][j] + r[i][j] - 3
        maxs = max(maxs,s[i][j])
print(maxs)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(0,m):
    b,c = map(int,input().split())
    for j in range(0,b):
        if a[j]<c:
            a[j] = c
        else:
            break
    a.sort()
print(sum(a))

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
bc = []
for i in range(0,m):
    temp_bc = list(map(int,input().split()))
    bc.append(temp_bc)
bc.sort(key=lambda x:x[1])
bc.reverse()
i = 0
for j in range(0,m):
    for k in range(0,bc[j][0]):
        if a[i] < bc[j][1]:
            a[i] = bc[j][1]
        i += 1
        if i == n:
            break
    if i == n:
        break

print(sum(a))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()
 
if s[k-1] == "A":
  s=s[0:k-1]+"a"+s[k:n]
elif s[k] == "B":
  s=s[0:k-1]+"b"+s[k:n]
else:
  s=s[0:k-1]+"c"+s[k:n]
print(s)

Fixed submission:
n,k = map(int,input().split())
s = input()
 
if s[k-1] == "A":
  s=s[0:k-1]+"a"+s[k:n]
elif s[k-1] == "B":
  s=s[0:k-1]+"b"+s[k:n]
else:
  s=s[0:k-1]+"c"+s[k:n]
print(s)

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()

if s[k] == "A":
  s=s[0:k]+"a"+s[k+1:n]
elif s[k] == "B":
  s=s[0:k]+"b"+s[k+1:n]
else:
  s=s[0:k]+"c"+s[k+1:n]
print(s)

Fixed submission:
n,k = map(int,input().split())
s = input()
 
if s[k-1] == "A":
  s=s[0:k-1]+"a"+s[k:n]
elif s[k-1] == "B":
  s=s[0:k-1]+"b"+s[k:n]
else:
  s=s[0:k-1]+"c"+s[k:n]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n, k =map(int,input().split())
s = input()

sp = "1"
count = 0
cu = []
cd = []
for i in range(n):
    if sp == s[i]:
        count += 1
    else:
        if sp == "1":
            cu.append(count)
        else:
            cd.append(count)
        count = 1
    sp = s[i]
if sp == "1":
    cu.append(count)
else:
    cd.append(count)
ans = 0
for i in range(len(cd)):
    sn = 0
    ld = i
    rd = min(i + k - 1, len(cd)-1)
    sn += sum(cd[ld:rd+1])
    lu = i
    ru = min(rd+1,len(cu)-1)
    sn += sum(cu[lu:ru+1])
    ans = max(ans,sn)
if len(cd)==0:
    ans = n
print(ans)

Fixed submission:
n, k =map(int,input().split())
s = input()

sp = "1"
count = 0
cu = []
cd = []
for i in range(n):
    if sp == s[i]:
        count += 1
    else:
        if sp == "1":
            cu.append(count)
        else:
            cd.append(count)
        count = 1
    sp = s[i]
if sp == "1":
    cu.append(count)
else:
    cd.append(count)
ans = 0
for i in range(len(cd)):
    ld = i
    rd = min(i + k - 1, len(cd)-1)
    lu = i
    ru = min(rd+1,len(cu)-1)        
    if i == 0:
        sn = 0
        sn += sum(cd[ld:rd+1])
        sn += sum(cu[lu:ru+1])
    else:
        if ldp < ld:
            sn-=cd[ldp]
        if rdp < rd:
            sn+=cd[rd]
        if lup < lu:
            sn-=cu[lup]
        if rup < ru:
            sn+=cu[ru]
    ans = max(ans,sn)
    ldp,rdp,lup,rup = ld,rd,lu,ru
if len(cd)==0:
    ans = n
print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
r = [b-a,c-b,d-c,e-d]
count = 0
for rr in r:
  if rr > k:
    count += 1
print(count

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e-a>k:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,K = map(int,input().split())
ans = 0
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ans = []
for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i+1)*(j+1)*(k+1)<=K:
                ans.append(a[i]+b[j]+c[k])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Fixed submission:
x,y,z,K = map(int,input().split())
ans = 0
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ans = []
for i in range(x):
    for j in range(min(K//(i+1),y)):
        for k in range(min(z,K//((i+1)*(j+1)))):
            if (i+1)*(j+1)*(k+1)<=K:
                ans.append(a[i]+b[j]+c[k])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
s = input()
m = 1000
for i in range(0,len(s)-2):
    m = min(abs(s[i]*100+s[i+1]*10+s[i+2]-753),m)
print(m)

Fixed submission:
s = input()
m = 1000
for i in range(0,len(s)-2):
    m = min(abs(int(s[i])*100+int(s[i+1])*10+int(s[i+2])-753),m)
print(m)
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))
l = []
r = []
for i in range(0,n//2):
    l.append(v[2*i])
    r.append(v[2*i+1])

lc = []
rc = []
vmax =max(max(l),max(r))
for i in range(1,vmax+1):
    lc.append([i, l.count(i)])
    rc.append([i, r.count(i)])
lc.sort(key=lambda x:x[1])
rc.sort(key=lambda x:x[1])
lc.reverse()
rc.reverse()
if lc[0][0] == rc[0][0]:
    if lc[0][1] == rc[0][1]:
        if lc[1][1] == rc[1][1]:
            print(n-lc[0][1]-rc[1][1])
        else:
            print(n-lc[0][1]-max(lc[1][1],rc[1][1]))
    else:
        print(n-max(lc[0][1]+rc[1][1],rc[0][1]+lc[1][1]))
else:
    print(n-lc[0][1]-rc[0][1])        



Fixed submission:
import collections
n = int(input())
v = list(map(int,input().split()))
l = []
r = []
for i in range(0,n//2):
    l.append(v[2*i])
    r.append(v[2*i+1])
       

lc = collections.Counter(l).most_common()
rc = collections.Counter(r).most_common()

if lc[0][0] == rc[0][0]:
    if len(lc)==1:
        print(n//2)
    else:
        print(n-max(lc[0][1]+rc[1][1],lc[1][1]+rc[0][1]))
else:
    print(n-lc[0][1]-rc[0][1])
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
ans = "1"
for i in range(100):
    if s[i] != "1":
        ans = s[i]
        break

print(ans)

Fixed submission:
s = input()
k = int(input())
ans = "1"
n1 = 100
for i in range(len(s)):
    if s[i] != "1":
        ans = s[i]
        n1 = i
        break
if k-1 >= n1:
    print(ans)
else:
    print("1")
Buggy python submission (verdict: Runtime Error):
n = input()

s = 0
for i in range(len(n)):
    s+=n[i]
if int(n)%s:
    print("Yes")
else:
    print("No")

Fixed submission:
n = input()

s = 0
for i in range(len(n)):
    s+=int(n[i])
if int(n)%s==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
import sys
sys.setrecursionlimit(100000+1)
s = input()

ce = {}
#iより右に居て，東を向いている人の数
def counte(s,i):
    if i in ce:
        return ce[i]
    elif i == n-1:
        return 0
    else:
        ce[i] = counte(s,i+1) + s[i+1:i+2].count("E")
        return ce[i]

cw = {}
#iより←に居て，西を向いている人の数
def countw(s,i):
    if i in cw:
        return cw[i]
    elif i == 0:
        return 0
    else:
        cw[i] = countw(s,i-1) + s[i-1:i].count("W")
        return cw[i]

minew = n
for i in range(0,n):
    ew = counte(s,i)+countw(s,i)
    if ew < minew:
        minew = ew
print(minew)

Fixed submission:
n = int(input())
import sys
sys.setrecursionlimit(1000000+1)
s = input()

ce = {}
#iより右に居て，東を向いている人の数
def counte(s,i):
    if i in ce:
        return ce[i]
    elif i == n-1:
        return 0
    else:
        ce[i] = counte(s,i+1) + s[i+1:i+2].count("E")
        return ce[i]

cw = {}
#iより←に居て，西を向いている人の数
def countw(s,i):
    if i in cw:
        return cw[i]
    elif i == 0:
        return 0
    else:
        cw[i] = countw(s,i-1) + s[i-1:i].count("W")
        return cw[i]

minew = n
for i in range(0,n):
    ew = counte(s,i)+countw(s,i)
    if ew < minew:
        minew = ew
print(minew)

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

ce = {}
#iより右に居て，東を向いている人の数
def counte(s,i):
    if i in ce:
        return ce[i]
    elif i == n-1:
        return 0
    else:
        ce[i] = counte(s,i+1) + s[i+1:i+2].count("E")
        return ce[i]

cw = {}
#iより←に居て，西を向いている人の数
def countw(s,i):
    if i in cw:
        return cw[i]
    elif i == 0:
        return 0
    else:
        cw[i] = countw(s,i-1) + s[i-1:i].count("W")
        return cw[i]

minew = n
for i in range(0,n):
    ew = counte(s,i)+countw(s,i)
    if ew < minew:
        minew = ew
print(minew)

Fixed submission:
n = int(input())
import sys
sys.setrecursionlimit(1000000+1)
s = input()

ce = {}
#iより右に居て，東を向いている人の数
def counte(s,i):
    if i in ce:
        return ce[i]
    elif i == n-1:
        return 0
    else:
        ce[i] = counte(s,i+1) + s[i+1:i+2].count("E")
        return ce[i]

cw = {}
#iより←に居て，西を向いている人の数
def countw(s,i):
    if i in cw:
        return cw[i]
    elif i == 0:
        return 0
    else:
        cw[i] = countw(s,i-1) + s[i-1:i].count("W")
        return cw[i]

minew = n
for i in range(0,n):
    ew = counte(s,i)+countw(s,i)
    if ew < minew:
        minew = ew
print(minew)