Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
inf = float('inf')

N,W = map(int,input().split())
w, v = [], []
for _ in range(N):
    wi, vi = map(int,input().split())
    w.append(wi)
    v.append(vi)

dp = [[0]*(W+1) for _ in range(N+1)]

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

ans = dp[N][W]
print(ans)

Fixed submission:
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

Fixed submission:
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(max(dp[N]))

Fixed submission:
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
grid = [["#"]*(W+2) for i in range(H+2)]
for i in range(H):
    s = input()
    for j in range(W):
        grid[i+1][j+1] = s[j]
ans = 0
def dfs(i = 1,j = 1):
    if (i,j) == (H,W):
        global ans
        ans += 1
        return
    if grid[i+1][j] == ".":
        dfs(i+1,j)
    if grid[i][j+1] == ".":
        dfs(i,j+1)
dfs()
ans %= 10**9 + 7   
print(ans)

Fixed submission:
H,W = map(int,input().split())
grid = [["#"]*(W+2) for i in range(H+2)]
for i in range(H):
    s = input()
    for j in range(W):
        grid[i+1][j+1] = s[j]
dp = [[0]*(W+2) for i in range(H+2)]
dp[1][1] = 1
for i in range(H):
    for j in range(W):
        if (i,j) == (0,0):
            continue
        dp[i+1][j+1] = 0
        if grid[i+1][j] == ".":
            dp[i+1][j+1] += dp[i+1][j]
        if grid[i][j+1] == ".":
            dp[i+1][j+1] += dp[i][j+1]
ans = dp[H][W] % (10**9 + 7)   
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = list(map(float,input().split()))
# dp[i][j] コインiまで投げて表の個数がjとなる確率
dp = [[0] * (N+1) for i in range(N+1)]
dp[1][1] = p[0]
dp[1][0] = 1 - p[0]
for i in range(2,N+1):
    dp[i][0] = dp[i-1][0] * (1 - p[i-1])
    for j in range(1,N+1):
        dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1 - p[i-1])
ans = sum(dp[N][(N+1)//2:])
print(ans)

Fixed submission:
N = int(input())
p = list(map(float,input().split()))
# dp[i][j] コインiまで投げて表の個数がjとなる確率
dp = [[0] * (N+1) for i in range(N+1)]
dp[1][1] = p[0]
dp[1][0] = 1 - p[0]
for i in range(2,N+1):
    dp[i][0] = dp[i-1][0] * (1 - p[i-1])
    for j in range(1,N+1):
        dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1 - p[i-1])
ans = sum(dp[N][(N+1)//2:])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0] * (K+1) for i in range(K+1)]
for i in range(min(A)):
    dp[0][i] = 1 # 負け
ans = "Second"
for i in range(K):
    for k in range(K+1):
        for x in A:
            if k + x <= K:   
                if (i == 0 or (i + 1) % 2 == 0) and dp[i][k] > 0:
                    dp[i+1][k+x] += 1
                elif (i + 1) % 2 == 1 and dp[i][k] == N:
                    dp[i+1][k+x] += 1
    if (i + 1) % 2 == 1 and dp[i+1][k] > 0:
        ans = "First"
print(ans)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
# firstが負けの状態を押し付け続けることが可能ならば勝ち
dp = [False]*(K+1)
# dp[i](0,A[0]) = False 
for i in range(K):
    if not dp[i]:
        for a in A:
            if i+a <= K:
                dp[i+a] = 1
print("First" if dp[K] else "Second")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
X,Y = 0,0
dp = [[0] * (N+1) for i in range(N+1)]
# dp[i][j] ans = dp[1][N]
for i in range(1,N+1):
    if N % 2 == 1:
        dp[i][i] = a[i-1]
    else:
        dp[i][i] = -a[i-1]
for i in range(N-1,0,-1):
    for j in range(1,N+1):
        if i >= j: continue
        if (j - i) % 2 != N % 2:
            dp[i][j] = max(a[i-1] + dp[i+1][j],a[j-1] + dp[i][j-1])
        else:
            dp[i][j] = min(-a[i-1] + dp[i+1][j],-a[j-1] + dp[i][j-1])
print(dp[1][N])

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
X,Y = 0,0
dp = [[0] * (N+1) for i in range(N+1)]
# dp[i][j] ans = dp[1][N]
for i in range(1,N+1):
    if N % 2 == 1:
        dp[i][i] = a[i-1]
    else:
        dp[i][i] = -a[i-1]
for i in range(N-1,0,-1):
    for j in range(1,N+1):
        if i >= j: continue
        if (j - i) % 2 != N % 2:
            dp[i][j] = max(a[i-1] + dp[i+1][j],a[j-1] + dp[i][j-1])
        else:
            dp[i][j] = min(-a[i-1] + dp[i+1][j],-a[j-1] + dp[i][j-1])
print(dp[1][N])
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9 + 7

def accmulate(array):
    cs = [0]*(len(array)+1)
    for i in range(len(array)):
        cs[i+1] = cs[i] + array[i]
    return cs

def query(l,r):
    return cs[r+1] - cs[l]

N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [[0]*(K+1) for _ in range(N+1)]

dp[0][0] = 1

for i in range(1,N+1):
    cs = accmulate(dp[i-1])
    for j in range(K+1):
        dp[i][j] += query(max(j-A[i-1], 0), j)
        dp[i][j] %= mod

ans = dp[N][K]
print(ans)

Fixed submission:
mod = 10**9 + 7

def accmulate(array):
    cs = [0]*(len(array)+1)
    for i in range(len(array)):
        cs[i+1] = cs[i] + array[i]
    return cs

def query(l,r):
    return cs[r+1] - cs[l]

N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [[0]*(K+1) for _ in range(N+1)]

dp[0][0] = 1

for i in range(1,N+1):
    cs = accmulate(dp[i-1])
    for j in range(K+1):
        dp[i][j] += query(max(j-A[i-1], 0), j)
        dp[i][j] %= mod

ans = dp[N][K]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
a = list(map(int,input().split()))
c = []
c_re = [0]
tmp = 0
for e in a:
    tmp += e
    c.append(tmp)
tmp = 0
for e in reversed(a):
    tmp += e
    c_re.append(tmp)
c_re = list(reversed(c_re))
# sum(a) < K ならば0通り
# dp[i][j]:i番目までの子供,残っている飴の個数j ans = dp[N][0]
# 0 <= k <= min(c[i] ,K) - j
# dp[i][j] += dp[i-1][j+k]
dp = [[0]*(K+1) for i in range(N+1)]
dp[0][K] = 1
for i in range(1,N+1):
    inf = K - c[i-1] if K - c[i-1] > 0 else 0
    for j in range(inf,min(c_re[i],K) + 1):
        for k in range(min(a[i-1],K-j) + 1): 
            dp[i][j] += dp[i-1][j+k]
ans = dp[N][0] % (10**9 + 7)
print(ans)

Fixed submission:
mod = 10**9 + 7

def accmulate(array):
    cs = [0]*(len(array)+1)
    for i in range(len(array)):
        cs[i+1] = cs[i] + array[i]
    return cs

def query(l,r):
    return cs[r+1] - cs[l]

N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [[0]*(K+1) for _ in range(N+1)]

dp[0][0] = 1

for i in range(1,N+1):
    cs = accmulate(dp[i-1])
    for j in range(K+1):
        dp[i][j] += query(max(j-A[i-1], 0), j)
        dp[i][j] %= mod

ans = dp[N][K]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
inf = float('inf')

def accmulate(array):
    global cs
    cs = [0]*(len(array)+1)
    for i in range(len(array)):
        cs[i+1] = cs[i] + array[i]

def query(l,r):
    return cs[r+1] - cs[l]

N = int(input())
A = list(map(int,input().split()))

accmulate(A)

dp = [[inf]*(N+1) for _ in range(N+1)]

for i in range(N):
    dp[i][i+1] = 0

for i in range(N-1):
    dp[i][i+2] = A[i] + A[i+1]

for b in range(3,N+1):
    for i in range(N-b+1):
        j = i + b
        for k in range(i+1,j):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + query(i,j-1))

ans = dp[0][N]
print(ans)

Fixed submission:
inf = float('inf')

def accmulate(array):
    global cs
    cs = [0]*(len(array)+1)
    for i in range(len(array)):
        cs[i+1] = cs[i] + array[i]

def query(l,r):
    return cs[r+1] - cs[l]

N = int(input())
A = list(map(int,input().split()))

accmulate(A)

dp = [[inf]*(N+1) for _ in range(N+1)]

for i in range(N):
    dp[i][i+1] = 0

for i in range(N-1):
    dp[i][i+2] = A[i] + A[i+1]

for b in range(3,N+1):
    for i in range(N-b+1):
        j = i + b
        for k in range(i+1,j):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + query(i,j-1))

ans = dp[0][N]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
H = list(map(int,input().split()))
A = list(map(int,input().split()))

N += 1

# N: 処理する区間の長さ
N0 = 2**(N-1).bit_length()
INF = 2**31-1
data = [-INF]*(2*N0)
# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2*k+1], data[2*k+2])
# 区間[l, r)の最小値
def query(l, r):
    L = l + N0; R = r + N0
    s = -INF
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])

        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

update(0,0)

for h,a in zip(H,A):
    update(h,query(0,h) + a)

ans = query(0,N+1)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

N = int(input())
H = list(map(int,input().split()))
A = list(map(int,input().split()))

N += 1

# N: 処理する区間の長さ
N0 = 2**(N-1).bit_length()
INF = 2**31-1
data = [-INF]*(2*N0)
# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2*k+1], data[2*k+2])
# 区間[l, r)の最小値
def query(l, r):
    L = l + N0; R = r + N0
    s = -INF
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])

        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

update(0,0)

for h,a in zip(H,A):
    update(h,query(0,h) + a)

ans = query(0,N+1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9 + 7

K = input()
D = int(input())

N = len(K)

dp = [[[0]*2 for _ in range(D)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(1,N+1):
    for j in range(D):
        dp[i][(j+int(K[i-1])) % D][0] += dp[i-1][j][0]
        for k in range(int(K[i-1])):
            dp[i][(j+k) % D][1] += dp[i-1][j][0]
        for k in range(10):
            dp[i][(j+k) % D][1] += dp[i-1][j][1]
        
        dp[i][j][0] %= mod
        dp[i][j][1] %= mod

ans = (dp[N][0][0] + dp[N][0][1] - 1) % mod
print(ans)

Fixed submission:
mod = 10**9 + 7

K = input()
D = int(input())

N = len(K)

dp = [[[0]*2 for _ in range(D)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(1,N+1):
    for j in range(D):
        dp[i][(j+int(K[i-1])) % D][0] += dp[i-1][j][0]
        for k in range(int(K[i-1])):
            dp[i][(j+k) % D][1] += dp[i-1][j][0]
        for k in range(10):
            dp[i][(j+k) % D][1] += dp[i-1][j][1]
        
        dp[i][j][0] %= mod
        dp[i][j][1] %= mod

ans = (dp[N][0][0] + dp[N][0][1] - 1) % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
S = list(input())
def rec(list1,t):
    for i in range(len(list1)-1):
        if list1[i] == "B" and list1[i+1] == "W":
            list1[i] = "W"
            list1[i+1] = "B"
            return rec(list1,t+1)
    return t
result = rec(S,0)
print(result)

Fixed submission:
S = list(input())
count_B = 0
ans = 0
for i in range(len(S)):
    if S[i] == "B":
        count_B += 1
    elif S[i] == "W":
        ans += count_B
print(ans)
Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
if N == 0:
    print(1)
    exit()
# a:バンの数  b:パティの数
a,b = [1],[1]
for i in range(N):
    a.append(2*a[i] + 3)
    b.append(2*b[i] + 1)
def f(N,X):
    if X == 1:
        return 0
    elif 1 < X <= a[N-1] + 1:
        return f(N-1,X-1)
    elif X == a[N-1] + 2:
        return b[N-1] + 1
    elif a[N-1] + 2 < X <= 2*a[N-1] + 2:
        return b[N-1] + 1 + f(N-1,X-(a[N-1]+2))
    elif X = 2*a[N-1] + 3:
        return 2*b[N-1] + 1
ans = f(N,X)
print(ans)

Fixed submission:
N,X = map(int,input().split())
# a:バンの数  b:パティの数
a,b = [1],[1]
for i in range(N):
    a.append(2*a[i] + 3)
    b.append(2*b[i] + 1)
def f(N,X):
    if N == 0:
        return 1
    if X == 1:
        return 0
    elif 1 < X <= a[N-1] + 1:
        return f(N-1,X-1)
    elif X == a[N-1] + 2:
        return b[N-1] + 1
    elif a[N-1] + 2 < X <= 2*a[N-1] + 2:
        return b[N-1] + 1 + f(N-1,X-(a[N-1]+2))
    elif X == 2*a[N-1] + 3:
        return 2*b[N-1] + 1
ans = f(N,X)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
if N == 0:
    print(1)
    exit()
# a:バンの数  b:パティの数
a,b = [1],[1]
for i in range(N):
    a.append(2*a[i] + 3)
    b.append(2*b[i] + 1)
def f(N,X):
    if X == 1:
        return 0
    elif 1 < X <= a[N-1] + 1:
        return f(N-1,X-1)
    elif X == a[N-1] + 2:
        return b[N-1] + 1
    elif a[N-1] + 2 < X <= 2*a[N-1] + 2:
        return b[N-1] + 1 + f(N-1,X-(a[N-1]+2))
    elif X = 2*a[N-1] + 3:
        return 2*b[N-1] + 1
ans = def(N,X)
print(ans)

Fixed submission:
N,X = map(int,input().split())
# a:バンの数  b:パティの数
a,b = [1],[1]
for i in range(N):
    a.append(2*a[i] + 3)
    b.append(2*b[i] + 1)
def f(N,X):
    if N == 0:
        return 1
    if X == 1:
        return 0
    elif 1 < X <= a[N-1] + 1:
        return f(N-1,X-1)
    elif X == a[N-1] + 2:
        return b[N-1] + 1
    elif a[N-1] + 2 < X <= 2*a[N-1] + 2:
        return b[N-1] + 1 + f(N-1,X-(a[N-1]+2))
    elif X == 2*a[N-1] + 3:
        return 2*b[N-1] + 1
ans = f(N,X)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()

Fixed submission:
N = int(input())
if N == 1:
  print("Hello World")
elif N == 2:
  A,B = [int(input()) for i in range(2)]
  print(A+B)
Buggy python submission (verdict: Time Limit Exceeded):
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()

Fixed submission:
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(2,m.floor(pow(M,1/2)) + 1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()

Fixed submission:
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
if N == 1:
    print(M)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        ans = i
        break
print(ans)

Fixed submission:
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
for i in range(M // N,0,-1):
    if M % i == 0:
        ans = i
        break
print(ans)

Fixed submission:
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int,input().split()))
o = v[0::2]
e = v[1::2]
o_s = list(set(o))
e_s = list(set(e))
o_c = [o.count(o_s[i]) for i in range(len(o_s))]
e_c = [e.count(e_s[i]) for i in range(len(e_s))]
if o == e:
  print(int(n/2))
else:
  print(n-max(o_c)-max(e_c))

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
o= v[0::2]
e =v[1::2]
o_mode = Counter(o).most_common(2)
e_mode = Counter(e).most_common(2)
if o_mode[0][0] == e_mode[0][0]:
  if len(o_mode) == 1:
    print(int(n/2)) 
  else:
    print(n-max(o_mode[1][1],e_mode[1][1])-o_mode[0][1])
else:
  print(n-o_mode[0][1]-e_mode[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int,input().split()))
o = v[0::2]
e = v[1::2]
o_s = list(set(o))
e_s = list(set(e))
o_c = [o.count(o_s[i]) for i in range(len(o_s))]
e_c = [e.count(e_s[i]) for i in range(len(e_s))]
if o == e:
  print(int(n/2))
else:
  print(n-max(o_c)-max(e_c))

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
o= v[0::2]
e =v[1::2]
o_mode = Counter(o).most_common(2)
e_mode = Counter(e).most_common(2)
if o_mode[0][0] == e_mode[0][0]:
  if len(o_mode) == 1:
    print(int(n/2)) 
  else:
    print(n-max(o_mode[1][1],e_mode[1][1])-o_mode[0][1])
else:
  print(n-o_mode[0][1]-e_mode[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
import math
def factoring(n,dict_count = {}):
    sup = math.floor(pow(n,1/2))
    n_new = n
    for i in range(2,sup + 1):
        if n % i == 0:
            n_new = n // i
            if i in dict_count:
                dict_count[i] += 1
            else:
                dict_count[i] = 1
            break
    if n == n_new:
        if n_new in dict_count:
            dict_count[n_new] += 1
        else:
            dict_count[n_new] = 1
        return sorted(list(dict_count.items()))
    return factoring(n_new,dict_count)

# 組み合わせ　n_C_r
import math
def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N,M = map(int,input().split())
if M == 1:
    print(1)
    exit()
ans = 1
for a,b in factoring(M):
    ans *= comb(b+N-1,b)
    ans %= 10**9 + 7
print(ans)

Fixed submission:
# 素因数分解 ソート済みリスト (素因数,指数)
import math
def factoring(n,dict_count = {}):
    sup = math.floor(pow(n,1/2))
    n_new = n
    for i in range(2,sup + 1):
        if n % i == 0:
            n_new = n // i
            if i in dict_count:
                dict_count[i] += 1
            else:
                dict_count[i] = 1
            break
    if n == n_new:
        if n_new in dict_count:
            dict_count[n_new] += 1
        else:
            dict_count[n_new] = 1
        return sorted(list(dict_count.items()))
    return factoring(n_new,dict_count)

def comb(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

N,M = map(int,input().split())
if M == 1:
    print(1)
    exit()
ans = 1
for a,b in factoring(M):
    ans *= comb(b+N-1,b)
    ans %= 10**9 + 7
print(ans)
Buggy python submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int,input().split())
x3 = x2+y1-y2
y3 = -x1+x2+y2
x4 = x1+y1-y2
y4 = -x1+x2+y1
print(x3,y3,x4,y4)

Fixed submission:
k = int(input())
m = (k-1)/2
n = (k-1)/2 + 1
if k % 2 == 0:
  print(int((k/2)**2))
else :
  print(int(m*n))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
S = (A-1)*(B-1)
print(S)

Fixed submission:
A,B = map(int,input().split())
S = (A-1)*(B-1)
print(S)
Buggy python submission (verdict: Runtime Error):
N = int(input())
# N = 4n+7m 
if (N % 4 == 0) or (N % 7 == 0) or (N % 7 == 4):
  print("Yes")
else:
  print("No")

Fixed submission:
N,K = map(int,input().split())
if N%K == 0:
  print(0)
else :
  print(1)

Buggy python submission (verdict: Runtime Error):
N=input(':')

K=input(':')

N=int(N)

K=int(K)

if N%K==0 :
    print(0)

else :
    print(1)

Fixed submission:
N,K = map(int,input().split())
if N%K == 0:
  print(0)
else :
  print(1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
# N = 4n+7m 
if N % 4 == 0 or N % 7 ==　0 or N % 7 == 4:
  print("Yes")
else:
  print("No")



Fixed submission:
N = int(input())
m = 0
for i in range(15):
  n = N-7*m
  if n < 0:
    print("No")
    break
  elif n % 4 == 0:
    print("Yes")
    break
  elif m == 14:
    print("No")
  m += 1

Buggy python submission (verdict: Runtime Error):
N = int(input())
# N = 4n+7m 
if N % 4 == 0 or N % 7 ==0 or N % == 4:
  print("Yes")
else:
  print("No")



Fixed submission:
N = int(input())
m = 0
for i in range(15):
  n = N-7*m
  if n < 0:
    print("No")
    break
  elif n % 4 == 0:
    print("Yes")
    break
  elif m == 14:
    print("No")
  m += 1