Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(len(L)-1):
    for j in range(i+1,len(L)-1):
        a = L[i]
        b = L[j]
        c = L[j+1]
        if c-a < b and b < c+a:
            ans += bisect.bisect_left(L,b+a)-j-1
print(ans)

Fixed submission:
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(len(L)-1):
    for j in range(i+1,len(L)-1):
        a = L[i]
        b = L[j]
        c = L[j+1]
        if c-a < b and b < c+a:
            ans += bisect.bisect_left(L,b+a)-j-1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import os

S = input()
K = int(input())

cnt = 1
ans = 0
i = 0
while i < len(S)-1:
    for j in range(i+1,len(S)):
        if S[i] == S[j]:
            cnt +=1
        else:
            i = j
            break
    if cnt > 1:
        ans += cnt//2
        cnt = 1
        i = j
ans = K*ans
if S[0] == S[-1]:
    if S[0] != S[1] and S[-2] != S[-1]:
        ans += K-1
print(ans)


Fixed submission:
import sys
S = input()
K = int(input())
if len(S) == 1:
    print(K//2)
    sys.exit()
cnt0 = 1
cntL = 1
cnt = 1
ans = 0
i = 0
while i < len(S)-1:
    for j in range(i+1,len(S)):
        if S[i] == S[j]:
            cnt +=1
        else:
            if i == 0:
                cnt0 = cnt
            i = j
            break
    if cnt > 1:
        ans += cnt//2
        cnt = 1
        i = j

for i in range(len(S)-1,0,-1):
    if S[i] == S[i-1]:
        cntL +=1
    else:
        break
ans = K*ans
if S[0] == S[-1] and cnt0%2 != 0 and cntL %2 != 0:
    ans += K-1
if cntL == len(S):
    if (K*cntL)%2==0:
        print((K*cntL)//2)
    else:
        print((K*cntL-1)//2)
    sys.exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
#解説放送見てからの書き直し
import sys
import os

INF = 10**12
ans = INF
N, M = map(int,input().split())
A = [0 for _ in range(M)]
B = [0 for _ in range(M)]
C = []
for i in range(M):
    a, b = map(int,input().split())
    A[i] = a  #鍵の金額
    B[i] = b  #開けられる宝箱の種類数
    tmp = list((map(int,input().split())))
    s = 0
    for j in range(b):
        t = tmp.pop(0)-1
        s |= 1 << t
    C.append(s)
dp = [INF]*(1<<N) #2^N
dp[0] = 0
for s in range(1<<N):
    for j in range(M):
        t = s | C[j]
        cost = dp[s] + A[j]
        dp[t] = min(dp[t],cost)
ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)


Fixed submission:
import sys
import os
import math

N  = int(input())
if N%2==0:
    print((N/2)/N)
else:
    print(math.ceil(N/2)/N)
Buggy python submission (verdict: Runtime Error):
import sys
import os
import math
A, B = map(int,input().split())
gcdAB = math.gcd(A,B)
P = []
for i in range(2,gcdAB):
    if gcdAB%i==0:
        P.append(i)
        gcdAB /=i
    i+=2
cnt =1
for p in P:
    if p!= 0:
        cnt +=1
print(cnt)


Fixed submission:
import sys
import os
sys.setrecursionlimit(100000)

def gcd(a,b):
    if b>=a:
        a,b = b,a
    if b<= 0:
        return a
    return gcd(b,a%b)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

A, B = map(int,input().split())
P = factorize(gcd(A,B))
P = set(P)

print(len(P)+1)
Buggy python submission (verdict: Time Limit Exceeded):
#解説放送見てからの書き直し
import sys
import os
INF = 10**12
ans = INF
N, M = map(int,input().split())
A = [0 for _ in range(M)]
B = [0 for _ in range(M)]
C = []
for i in range(M):
    a, b = map(int,input().split())
    A[i] = a  #鍵の金額
    B[i] = b  #開けられる宝箱の種類数
    tmp = list((map(int,input().split())))
    s = 0
    for j in range(b):
        t = tmp.pop(0)-1
        s |= 1 << t
    C.append(s)
dp = [INF]*(1<<N) #2^N
dp[0] = 0
for s in range(1<<N):
    for j in range(M):
        t = s | C[j]
        cost = dp[s] + A[j]
        dp[t] = min(dp[t],cost)
ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)


Fixed submission:
#解説放送見てからの書き直し
import sys
import os
INF = 10**12
ans = INF
N, M = map(int,input().split())
A = [0 for _ in range(M)]
B = [0 for _ in range(M)]
C = []
for i in range(M):
    a, b = map(int,input().split())
    A[i] = a  #鍵の金額
    B[i] = b  #開けられる宝箱の種類数
    tmp = list((map(int,input().split())))
    s = 0
    for j in range(b):
        t = tmp.pop(0)-1
        s |= 1 << t
    C.append(s)
dp = [INF]*(1<<N) #2^N
dp[0] = 0
for s in range(1<<N):
    for j in range(M):
        t = s | C[j]
        cost = dp[s] + A[j]
        dp[t] = min(dp[t],cost)
ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)
Buggy python submission (verdict: Runtime Error):
def move(str):
    returnR = 0
    returnL = 0
    cntR = str.count("R")
    cntL = str.count("L")
    if cntR%2 == 0:
        returnL += cntR//2
        returnR += cntR//2
    else:
        returnL += cntR//2
        returnR += cntR//2 + 1
        
    if cntL%2 == 0:
        returnR += cntL//2
        returnL += cntL//2
    else:
        returnR += cntL//2 
        returnL += cntL//2 + 1

    for i in range(cntR-1):
        print(0+" ",end="")
    print(returnR,end="")

    print(returnL,end="")
    for i in range(cntL-1):
        print(0+" ",end="")

    
s = input()
listS = []

while s.find("LR") > 0:
    listS.append(s[:s.find("LR")+1])
    s=s[s.find("LR")+1:]
listS.append(s)

for s in listS:
    move(s)

Fixed submission:
def move(s):
    returnR = 0
    returnL = 0
    cntR = s.count("R")
    cntL = s.count("L")
    if cntR%2 == 0:
        returnL += cntR//2
        returnR += cntR//2
    else:
        returnL += cntR//2
        returnR += cntR//2 + 1
        
    if cntL%2 == 0:
        returnR += cntL//2
        returnL += cntL//2
    else:
        returnR += cntL//2 
        returnL += cntL//2 + 1

    for i in range(cntR-1):
        print("0"+" ",end="")
    print(str(returnR)+" ",end="")

    print(str(returnL)+" ",end="")
    for i in range(cntL-1):
        print("0"+" ",end="")

    
s = input()
listS = []

while s.find("LR") > 0:
    listS.append(s[:s.find("LR")+1])
    s=s[s.find("LR")+1:]
listS.append(s)

for s in listS:
    move(s)
Buggy python submission (verdict: Runtime Error):
S = int(input())
KL = [i for i in range(S)]
for i in range(1,S):
    for j in range(1,S):
        id = bisect.bisect_right(KL,i*j-S)
        if KL[id-1] == i*j-S:
            print(0,0,i,KL[id-1],j,1)
            exit()

Fixed submission:
S = int(input())
X2 = 10**9
Y2 = 1
X3 = (X2-(S%X2))%(10**9)
Y3 = (S+X3)//X2
print(0,0,X2,Y2,X3,Y3)

Buggy python submission (verdict: Runtime Error):
S = int(input())
KL = [i for i in range(S)]
for i in range(1,S):
    for j in range(1,S):
        id = bisect.bisect_right(KL,i*j-S)
        if KL[id-1] == i*j-S:
            if [i,KL[id-1]] == [j,1]:
                continue
            else:
                print(0,0,i,KL[id-1],j,1)
                exit()

Fixed submission:
S = int(input())
X2 = 10**9
Y2 = 1
X3 = (X2-(S%X2))%(10**9)
Y3 = (S+X3)//X2
print(0,0,X2,Y2,X3,Y3)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
tmp = sorted(a)
mx = max(a)
cnt = a.count(mx)

for t in a:
    if t == mx and -cnt-1 < len(a):
        print(tmp[-cnt-1])
    else:
        print(mx)        

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
b = a[:]
mx = max(b)
b.remove(mx)
mx2 = max(b)

for t in a:
    if t == mx:
        print(mx2)
    else:
        print(mx)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
tmp = sorted(a)
mx = max(a)
cnt = a.count(mx)

for t in a:
    if t == mx:
        print(tmp[-cnt-1])
    else:
        print(mx)        

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
b = a[:]
mx = max(b)
b.remove(mx)
mx2 = max(b)

for t in a:
    if t == mx:
        print(mx2)
    else:
        print(mx)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

for i in range(n):
    t = a[i]
    a.remove(t)
    print(max(a))
    a.insert(i,t)

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
b = a[:]
mx = max(b)
b.remove(mx)
mx2 = max(b)

for t in a:
    if t == mx:
        print(mx2)
    else:
        print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
mod = 2019
mn = L*R
for i in range(L,R):
    for j in range(i+1,R+1):
        mn = min(mn,(i*j)%mod)
print(mn)

Fixed submission:
import sys
L, R = map(int, input().split())
mod = 2019
mn = L*R
for i in range(L,R):
    if R-L > 673:
        print(0)
        sys.exit()
    for j in range(i+1,R+1):
        mn = min(mn,(i*j)%mod)
print(mn)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = list(map(int, input().split()))

#右側のindex
r=0

sum = 0
cnt = 0

for l in range(N):
    while sum < K:
        if r == N:
            break
        else:
            sum += a[r]
            r += 1
    if sum < K :
        break
    cnt += N-r+1
    sum -= a[l]

print(cnt)

Fixed submission:
x, a = map(int, input().split())
print(0 if x<a else 10)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

a = []
#通過できない階段をaに格納
for _ in range(m):
    a.append(int(input()))
    
count = [0]*(n+1)
count[0] = 1
for i in range(1,n+1):
    if i in a:
        continue
    else:
        count[i] = count[i-1]+count[i-2]

print(count[-1]%(10**9+7))


Fixed submission:
p,q,r = map(int, input().split())
print(p+q+r-max(p,q,r))
Buggy python submission (verdict: Runtime Error):
import sys
import os
import bisect
from operator import itemgetter

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [ 0  for _ in range(M)]
for i in range(M):
    b,c = map(int,input().split())
    B[i] = [b,c]
B = sorted(B,key=itemgetter(1),reverse=True)
ans = 0
for i in range(M):
    id = bisect.bisect_left(A,B[i][1])
    if id > 0:
        for j in range(min(B[i][0],id+1)):
            if A[0] < B[i][1]:
                ans += B[i][1]
                del A[0]
    else:
        break
print(sum(A)+ans)


Fixed submission:
import sys
import os
import bisect
from operator import itemgetter

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [ 0  for _ in range(M)]
for i in range(M):
    b,c = map(int,input().split())
    B[i] = [b,c]
B = sorted(B,key=itemgetter(1),reverse=True)
ans = 0
for i in range(M):
    id = bisect.bisect_left(A,B[i][1])
    if id > 0:
        for j in range(min(B[i][0],id+1)):
            if len(A) > 0 and A[0] < B[i][1]:
                ans += B[i][1]
                del A[0]
    else:
        break
print(sum(A)+ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
import bisect
from operator import itemgetter

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [ 0  for _ in range(M)]
for i in range(M):
    b,c = map(int,input().split())
    B[i] = [b,c]
B = sorted(B,key=itemgetter(1),reverse=True)
for i in range(M):
    id = bisect.bisect_left(A,B[i][1])
    if id > 0:
        for j in range(min(B[i][0],id+1)):
            if A[0] < B[i][1]:
                A.append(B[i][1])
                del A[0]
    else:
        break
print(sum(A))


Fixed submission:
import sys
import os
import bisect
from operator import itemgetter

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [ 0  for _ in range(M)]
for i in range(M):
    b,c = map(int,input().split())
    B[i] = [b,c]
B = sorted(B,key=itemgetter(1),reverse=True)
ans = 0
for i in range(M):
    id = bisect.bisect_left(A,B[i][1])
    if id > 0:
        for j in range(min(B[i][0],id+1)):
            if len(A) > 0 and A[0] < B[i][1]:
                ans += B[i][1]
                del A[0]
    else:
        break
print(sum(A)+ans)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
def index(a, x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return True
    return False

R, G, B, N = map(int,input().split())
listB = [ i for i in range(N//B+1) ]
cnt = 0
for r in range(N//R+1):
    for g in range((N-R*r)//G+1):
        v = R*r+G*g
        if (N - v)%B == 0 and index(listB,(N - v)//B):
            cnt += 1
print(cnt)


Fixed submission:
*j, N = map(int,input().split())
j.sort()
a,b,c = j
cnt = 0
for r in range(N//b+1):
    for g in range((N-b*r)//c+1):
        v = b*r+c*g
        if (N-v)%a == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
def index(a, x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return True
    return False
R, G, B, N = map(int,input().split())
listB = [ i for i in range(N//B+1) ]
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        v = R*r+G*g
        if (N - v)%B == 0 and index(listB,(N - v)//B):
            cnt += 1
print(cnt)


Fixed submission:
*j, N = map(int,input().split())
j.sort()
a,b,c = j
cnt = 0
for r in range(N//b+1):
    for g in range((N-b*r)//c+1):
        v = b*r+c*g
        if (N-v)%a == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
from bisect import bisect_left
def index(a, x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return True
    return False

R, G, B, N = map(int,input().split())
listB = [ i for i in range(N//B+1) ]
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        if index(listB,(N - R*r - G*g)/B):
            cnt += 1
print(cnt)


Fixed submission:
*j, N = map(int,input().split())
j.sort()
a,b,c = j
cnt = 0
for r in range(N//b+1):
    for g in range((N-b*r)//c+1):
        v = b*r+c*g
        if (N-v)%a == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
from bisect import bisect_left
def index(a, x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return True
    return False

R, G, B, N = map(int,input().split())
listB = [ i for i in range(N//B+1) ]
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        if (N - R*r - G*g)%B == 0 and  index(listB,(N - R*r - G*g)//B):
            cnt += 1
print(cnt)


Fixed submission:
*j, N = map(int,input().split())
j.sort()
a,b,c = j
cnt = 0
for r in range(N//b+1):
    for g in range((N-b*r)//c+1):
        v = b*r+c*g
        if (N-v)%a == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N+1):
    for g in range(N+1):
        if N - R*r - G*g >= 0 and (N-R*r-G*g)%B == 0:
            cnt += 1
print(cnt)

Fixed submission:
*j, N = map(int,input().split())
j.sort()
a,b,c = j
cnt = 0
for r in range(N//b+1):
    for g in range((N-b*r)//c+1):
        v = b*r+c*g
        if (N-v)%a == 0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import sys
import os
f = open('input.txt','r')
sys.stdin = f

import math

times = [0]*5
for i in range(5):
    times[i] = int(input())

#1桁目が一番小さいものを判断する
mini = 9
idx = 9
for time in times:
    if time%10 < mini and time%10 > 0:
        mini = min(mini,time%10)
        idx = times.index(time)

total = 0
for i in range(5):
    if i == idx:
        total += times[i]
    else:
        total += math.ceil(times[i]/10)*10
print(total)


Fixed submission:
import math

times = [0]*5
for i in range(5):
    times[i] = int(input())

#1桁目が一番小さいものを判断する
mini = 10
idx = 9
for time in times:
    if time%10 < mini and time%10 > 0:
        mini = min(mini,time%10)
        idx = times.index(time)

total = 0
for i in range(5):
    if i == idx:
        total += times[i]
    else:
        total += math.ceil(times[i]/10)*10
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
rides = [0]*5
for i in range(5):
    rides[i] = int(input())

time = 0
p = [0]*6
p[0] = n
while p[5] != n:
    time+=1
    for i in range(4,-1,-1):
        if p[i] > 0:
            if p[i] >= rides[i]:
                p[i+1] += rides[i]
                p[i] -= rides[i]
            else:
                p[i+1] += p[i]
                p[i] = 0

print(time)


Fixed submission:
import math

n = int(input())
rides = [0]*5
for i in range(5):
    rides[i] = int(input())

time = 0
mini = min(rides)
time = math.ceil(n/mini)+4

print(time)
Buggy python submission (verdict: Runtime Error):
import sys
import os
f = open('input.txt','r')
sys.stdin = f

b = input()
out = ""

if b == "A":
    out = "T"
elif b == "C":
    out = "G"
elif b == "G":
    out = "C"
else:
    out = "A"
print(out)


Fixed submission:
b = input()
out = ""

if b == "A":
    out = "T"
elif b == "C":
    out = "G"
elif b == "G":
    out = "C"
else:
    out = "A"
print(out)

Buggy python submission (verdict: Runtime Error):
b = input()
out = ""

if b == "A":
    out = "T"
elif b == "C":
    out = G
elif b = "G":
    out = "C"
else:
    out = "A"
print(out)


Fixed submission:
b = input()
out = ""

if b == "A":
    out = "T"
elif b == "C":
    out = "G"
elif b == "G":
    out = "C"
else:
    out = "A"
print(out)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
S = input()
for i in range(Q):
    l, r = map(int, input().split())
    print(S[l-1:r].count("AC"))


Fixed submission:
N,Q = map(int, input().split())
S = input()
t = [0]*(N+1)
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        t[i+1] = t[i] + 1
        i += 2
    else:
        t[i+1] = t[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
listS = list(S)
setS = set(listS)

#異なる文字から2個を選ぶ場合（2項定理の利用）
if len(listS) == len(setS):
    res = 2**len(setS)-1
    print(res)
    sys.exit()
else:
    res = 0
for x in setS:
    n = listS.count(x)
    if n == 1:
        res += 1
    else:
        res += (2**(len(setS)-1))*n
print(res)

Fixed submission:
mod = 10**9 + 7
N = int(input())
S = list(input())
al = [chr(ord("a") + i ) for i in range(26)]
cntAl = [ S.count(chr(ord("a") + i )) for i in range(26)]
ans = 1
for a in cntAl:
    if a != 0:ans *= (a+1)%mod
print((ans-1)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
w = []
v = []
for _ in range(N):
    x, y = map(int,input().split())
    w.append(x)
    v.append(y)
    
dp = [ [0 for i in range(W+1)] for j in range(N+1) ]

for i in range(N):
    for j in range(W+1):
        if j-w[i] >= 0:
            dp[i+1][j] = max( dp[i][j], dp[i][j-w[i]]+v[i] )
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])

print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
w = []
v = []
for _ in range(N):
    x, y = map(int,input().split())
    w.append(x)
    v.append(y)
    
dp = [ [0 for i in range(W+1)] for j in range(N+1) ]

for i in range(N):
    for j in range(W+1):
        if j-w[i] >= 0:
            dp[i+1][j] = max( dp[i][j], dp[i][j-w[i]]+v[i] )
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])

print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter

N,M = map(int,input().split())
cities = [ 0 for _ in range(M) ]

for i in range(M):
    p,y = map(int,input().split())
    cities[i] = [p,y,i]
cities = sorted(cities,key=itemgetter(1))
cities = sorted(cities,key=itemgetter(0))

out = ["*" for _ in range(M)]

beforeCity = cities[0][0]
cityCnt = 1
for i in range(M):
    if beforeCity != cities[i][0]:
        cityCnt = 1
    if len(str(cities[i][0])) < 6:
        cityNo1 = "0"*(6 - len(str(cities[i][0])))+str(cities[i][0])
    if len(str(cityCnt)) < 6:
        cityNo2 = "0"*(6 - len(str(cityCnt)))+str(cityCnt)
    out[cities[i][2]] = cityNo1+cityNo2
    cityCnt += 1
for a in out:
    print(a)

Fixed submission:
import sys
import os
from operator import itemgetter

N,M = map(int,input().split())
cities = [ 0 for _ in range(M) ]

for i in range(M):
    p,y = map(int,input().split())
    cities[i] = [p,y,i]
cities = sorted(cities,key=itemgetter(1))
cities = sorted(cities,key=itemgetter(0))

out = ["*" for _ in range(M)]
beforeCity = cities[0][0]
cityCnt = 1
for i in range(M):
    curCity = cities[i][0]
    if beforeCity != curCity:
        cityCnt = 1
    cityNo1 = str(curCity).zfill(6)
    cityNo2 = str(cityCnt).zfill(6)
    out[cities[i][2]] = cityNo1+cityNo2
    beforeCity = curCity
    cityCnt += 1

for a in out:
    print(a)
Buggy python submission (verdict: Runtime Error):
import collections

n = input()
line = input().split()
odd = line[::2]
even = line[1::2]
o = collections.Counter(odd)
e = collections.Counter(even)
maxoddcnt = o.most_common()[0][1]
maxevencnt = e.most_common()[0][1]

#すべての値が同じときは半分を置換する
if odd == even:
    print(len(odd))
    exit(0)

#奇数列，偶数列それぞれの最頻の文字が同じ場合は，いずれかを2番目に多い文字に置換しなければならない
if o.most_common()[0][0] == e.most_common()[0][0]:
    if len(o.most_common()) > 1 and len(e.most_common()) <= 1:
        maxoddcnt = o.most_common()[1][1]
    if len(o.most_common()) <= 1 and len(e.most_common()) > 1:
        maxevencnt = e.most_common()[1][1]
    if o.most_common()[1][1] + e.most_common()[0][1] >= o.most_common()[0][1] + e.most_common()[1][1]:
        maxoddcnt = o.most_common()[1][1]
    else: #if o.most_common()[1][1] + e.most_common()[0][1] <= o.most_common()[0][1] + e.most_common()[1][1] :
        maxevencnt = e.most_common()[1][1]
        input()

print(len(odd)-maxoddcnt+len(even)-maxevencnt)


Fixed submission:
n = input()
n = n.replace('9','x')
n = n.replace('1','9')
n = n.replace('x','1')
print(n)

Buggy python submission (verdict: Runtime Error):
import collections

n = input()
line = input().split()
odd = line[::2]
even = line[1::2]
o = collections.Counter(odd)
e = collections.Counter(even)
maxoddcnt = o.most_common()[0][1]
maxevencnt = e.most_common()[0][1]

#すべての値が同じときは半分を置換する
if odd == even:
    print(len(odd))
    exit(0)

#奇数列，偶数列それぞれの最頻の文字が同じ場合は，いずれかを2番目に多い文字に置換しなければならない
if o.most_common()[0][0] == e.most_common()[0][0]:
    if o.most_common()[1][1] + e.most_common()[0][1] > o.most_common()[0][1] + e.most_common()[1][1]:
        maxoddcnt = o.most_common()[1][1]
    else: #if o.most_common()[1][1] + e.most_common()[0][1] <= o.most_common()[0][1] + e.most_common()[1][1] :
        maxevencnt = e.most_common()[1][1]

print(len(odd)-maxoddcnt+len(even)-maxevencnt)


Fixed submission:
n = input()
n = n.replace('9','x')
n = n.replace('1','9')
n = n.replace('x','1')
print(n)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
for i in range(1,K+1):
    if S[i] != "1":
        print(S[i])
        exit()
print(1)

Fixed submission:
S = input()
K = int(input())
cnt = 0
for s in S:
    cnt += 1
    if s == "1" and cnt < K:
        continue
    else:
        print(s)
        exit()