Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# C - Typical Stairs
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]

# dp[i]: i 段目まで来た時の移動方法の総数
dp = [0]*(N+1)

dp[0] = 1

for v in range(1,N+1):
    if v in A:
        continue
    if v == 1:
        dp[v] = (dp[v-1])%(1000000007)
    if v > 1:
        dp[v] = (dp[v-1] + dp[v-2])%(1000000007)
print(dp[N])

Fixed submission:
# C - Typical Stairs
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
A = set(A)

# dp[i]: i 段目まで来た時の移動方法の総数
dp = [0]*(N+1)

# 初期条件
dp[0] = 1

for v in range(1,N+1):
    if v in A:
        continue
    dp[v] = (dp[v] + dp[v-1])%(1000000007)
    if v > 1:
        dp[v] = (dp[v] + dp[v-2])%(1000000007)
print(dp[N])

Buggy python submission (verdict: Time Limit Exceeded):
# C - Typical Stairs
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]

# dp[i]: i 段目まで来た時の移動方法の総数
dp = [0]*(N+1)

dp[0] = 1

for v in range(1,N+1):
    if v in A:
        continue
    dp[v] = (dp[v] + dp[v-1])%(1000000007)
    if v > 1:
        dp[v] = (dp[v] + dp[v-2])%(1000000007)
print(dp[N])

Fixed submission:
# C - Typical Stairs
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
A = set(A)

# dp[i]: i 段目まで来た時の移動方法の総数
dp = [0]*(N+1)

# 初期条件
dp[0] = 1

for v in range(1,N+1):
    if v in A:
        continue
    dp[v] = (dp[v] + dp[v-1])%(1000000007)
    if v > 1:
        dp[v] = (dp[v] + dp[v-2])%(1000000007)
print(dp[N])

Buggy python submission (verdict: Time Limit Exceeded):
# C - Typical Stairs
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]

# dp[i]: i 段目まで来た時の移動方法の総数
dp = [0]*(N+1)

dp[0] = 1


for v in range(1,N+1):
    if v in A:
        continue
    dp[v] = (dp[v] + dp[v-1])%(1000000007)
    if v > 1:
        dp[v] = (dp[v] + dp[v-2])%(1000000007)
print(dp[N])

Fixed submission:
# C - Typical Stairs
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
A = set(A)

# dp[i]: i 段目まで来た時の移動方法の総数
dp = [0]*(N+1)

# 初期条件
dp[0] = 1

for v in range(1,N+1):
    if v in A:
        continue
    dp[v] = (dp[v] + dp[v-1])%(1000000007)
    if v > 1:
        dp[v] = (dp[v] + dp[v-2])%(1000000007)
print(dp[N])
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)

count = list(range(L_list[0],R_list[0]+1))
for i in range(1,M):
    count = list(count)
    if L_list[i] > count[0]:
        sta = L_list[i]
    else:
        sta = count[0]
    if R_list[i] > count[-1]:
        fin = count[-1]
    else:
        fin = R_list[i]
    count = set(count) & set(range(sta,fin+1))

ans = len(count)
print(ans)

Fixed submission:
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)
L_max = max(L_list)
R_min = min(R_list)
    
if L_max <= R_min:
    ans = R_min - L_max + 1
else:
    ans = 0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)

count = set(range(L_list[0],R_list[0]+1))
for i in range(1,M):
    count = count & set(range(L_list[i],R_list[i]+1))

ans = len(count)
print(ans)

Fixed submission:
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)
L_max = max(L_list)
R_min = min(R_list)
    
if L_max <= R_min:
    ans = R_min - L_max + 1
else:
    ans = 0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)

count = [0]*(N+1)
for i in range(M):
    for j in range(L_list[i],R_list[i]+1):
        count[j] += 1

ans = count.count(M)
print(ans)


Fixed submission:
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)
L_max = max(L_list)
R_min = min(R_list)
    
if L_max <= R_min:
    ans = R_min - L_max + 1
else:
    ans = 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#19 B - RGB Boxes
R,G,B,N = map(int,input().split())
lis = sorted([R,G,B])
MA, MID, MI = lis[0],lis[1],lis[2]

cnt = 0
for ma in range(N//MA+1):
    for mid in range(N//MID+1):
        mi = (N - (MA*ma+MID*mid))//MI
        mi_judge = (N - (MA*ma+MID*mid))%MI
        if mi>= 0 and (mi_judge == 0):
            cnt += 1
print(cnt)

Fixed submission:
#19 B - RGB Boxes
R,G,B,N = map(int,input().split())
lis = sorted([R,G,B])
MA, MID, MI = lis[0],lis[1],lis[2]

cnt = 0
for ma in range(N//MA+1):
    for mid in range(N//MID+1):
        mi = (N - (MA*ma+MID*mid))//MI
        mi_judge = (N - (MA*ma+MID*mid))%MI
        if mi>= 0 and (mi_judge == 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//R+1):
    for g in range(N//G+1):
        b = (N - (R*r+G*g))//B
        b_judge = (N - (R*r+G*g))%B
        if b>= 0 and (b_judge == 0):
            cnt += 1

print(cnt)

Fixed submission:
#19 B - RGB Boxes
R,G,B,N = map(int,input().split())
lis = sorted([R,G,B])
MA, MID, MI = lis[0],lis[1],lis[2]

cnt = 0
for ma in range(N//MA+1):
    for mid in range(N//MID+1):
        mi = (N - (MA*ma+MID*mid))//MI
        mi_judge = (N - (MA*ma+MID*mid))%MI
        if mi>= 0 and (mi_judge == 0):
            cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
#C - Unification
S = list(input())

count = 0
i = 0
while len(set(S))>1:
    if S[i] != S[i+1]:
        S.pop(i)
        S.pop(i)
        count += 2
        if i != 0:
            i -= 1
    else:
        i += 1
print(count)

Fixed submission:
S = list(input())
one = S.count('1')
zero = S.count('0')

print(2*min(one,zero))

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())

count = 0
i = 0
while len(set(S))>1:
    if S[i] != S[i+1]:
        S.remove('0')
        S.remove('1')
        count += 2
        if i != 0:
            i -= 1
    else:
        i += 1
print(count)

Fixed submission:
S = list(input())
one = S.count('1')
zero = S.count('0')

print(2*min(one,zero))

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())

count = 0
i = 0
while len(set(S))>1:
    if S[i] != S[i+1]:
        S.remove('0')
        S.remove('1')
        count += 2
        i = 0
    else:
        i += 1
print(count)

Fixed submission:
S = list(input())
one = S.count('1')
zero = S.count('0')

print(2*min(one,zero))
Buggy python submission (verdict: Time Limit Exceeded):
# B - Frog 2
import sys
sys.setrecursionlimit(10**6)

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

# 無限大の値
INF = 10**10

# DP テーブル
dp = [0]*(100010)

# DP テーブル全体を初期化
for i in range(100010):
    dp[i] = INF 

# 初期条件
def rec(v):
    # DP の値が既に更新されていたらそのままリターン 
    if dp[v] < INF:
        return dp[v]
    if v == 0:
        dp[0] = 0
        return 0
    
    res = INF
    for k in range(1,K+1):
        # 遷移元の足場がないとき

        if v-k < 0:
            continue
        # 足場 v-k から足場 v に移動する
        res = min(res, rec(v-k) + abs(h[v]-h[v-k]))
        # 結果をメモして返す
        dp[v] = res
    return res
print(rec(N-1))

Fixed submission:
# B - Frog 2
N,K = map(int,input().split())
h = list(map(int,input().split()))

# 無限大の値
INF = 10**10

# DP テーブル
dp = [0]*(100010)

# DP テーブル全体を初期化
for i in range(100010):
    dp[i] = INF 

# 初期条件
dp[0] = 0

for v in range(1,N):
    for k in range(1,K+1):
        # 遷移元の足場がないとき
        if v-k < 0:
            continue
        # 足場 v-k から足場 v に移動する
        dp[v] = min(dp[v], dp[v-k] + abs(h[v]-h[v-k]))
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
# B - Frog 2
import sys
sys.setrecursionlimit(10**6)

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

# 無限大の値
INF = 10**10

# DP テーブル
dp = [0]*(100010)

# DP テーブル全体を初期化
for i in range(100010):
    dp[i] = INF 

# 初期条件
def rec(v):
    # DP の値が既に更新されていたらそのままリターン 
    if dp[v] < INF:
        return dp[v]
    if v == 0:
        dp[0] = 0
        return 0
    
    res = INF
    for k in range(1,K+1):
        # 遷移元の足場がないとき

        if v-k < 0:
            continue
        # 足場 v-k から足場 v に移動する
        res = min(res, rec(v-k) + abs(h[v]-h[v-k]))
        # 結果をメモして返す
        dp[v] = res
    return res
print(rec(N-1))

Fixed submission:
# B - Frog 2
N,K = map(int,input().split())
h = list(map(int,input().split()))

# 無限大の値
INF = 10**10

# DP テーブル
dp = [0]*(100010)

# DP テーブル全体を初期化
for i in range(100010):
    dp[i] = INF 

# 初期条件
dp[0] = 0

for v in range(1,N):
    for k in range(1,K+1):
        # 遷移元の足場がないとき
        if v-k < 0:
            continue
        # 足場 v-k から足場 v に移動する
        dp[v] = min(dp[v], dp[v-k] + abs(h[v]-h[v-k]))
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
# B - Frog 2
N,K = map(int,input().split())
h = list(map(int,input().split()))

# 無限大の値
INF = 10**10

# DP テーブル
dp = [0]*(100010)

# DP テーブル全体を初期化
for i in range(100010):
    dp[i] = INF 

# 初期条件
dp[0] = 0

for v in range(1,N):
    for k in range(1,K+1):
        # 遷移元の足場がないとき
        if v-k < 0:
            continue
        # 足場 v-k から足場 v に移動する
        dp[v] = min(dp[v], dp[v-k] + abs(h[v]-h[v-k]))
print(dp[N-1])

Fixed submission:
# B - Frog 2
N,K = map(int,input().split())
h = list(map(int,input().split()))

# 無限大の値
INF = 10**10

# DP テーブル
dp = [0]*(100010)

# DP テーブル全体を初期化
for i in range(100010):
    dp[i] = INF 

# 初期条件
dp[0] = 0

for v in range(1,N):
    for k in range(1,K+1):
        # 遷移元の足場がないとき
        if v-k < 0:
            continue
        # 足場 v-k から足場 v に移動する
        dp[v] = min(dp[v], dp[v-k] + abs(h[v]-h[v-k]))
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
import sys
# inputを高速化する。
input = sys.stdin.readline
# 入力
vacation = int(input())
lst_happiness = [list(map(int, input().split())) for i in range(vacation)]
# DPテーブル
# 最大化問題なので0で初期化
dp = [[0 for i in range(3)] for j in range(vacation+1)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b
# dp[i][0] から dp[i + 1][1] への遷移
# dp[i][0] から dp[i + 1][2] への遷移
# dp[i][1] から dp[i + 1][0] への遷移
# dp[i][1] から dp[i + 1][2] への遷移
# dp[i][2] から dp[i + 1][0] への遷移
# dp[i][2] から dp[i + 1][1] への遷移
# 各 j (= 0, 1, 2) と各 k (= 0, 1, 2) に対して、j ≠ k ならば
# chmin(dp[i + 1][k], dp[i [j] + lst_happiness[i][k])
for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])
ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])
print(ans)

Fixed submission:
# D - Knapsack 1
N,W = map(int,input().split())
value = []
weight = []
for _ in range(N):
    w,v = map(int,input().split())
    value.append(v)
    weight.append(w)

# DP テーブル
# dp[i][j]: i-1 番目までの品物から重さが j を超えないように選んだときの価値の最大値
# W <= 100000, N <= 100 よりテーブルの個数を決める
dp = [[0]*100010 for _ in range(102)]

# DP テーブル全体を初期化
for i in range(102):
    for j in range(100010):
        dp[i][j] = 0# 最大化問題

# DP ループ
# v-1 番目の荷物に対する情報を dp[v] に記録
for v in range(1,N+1):
    for w in range(W+1):
        # v-1 番目の品物を選ぶ場合
        if (w - weight[v-1]) >= 0:
            dp[v][w] = max(dp[v][w],dp[v-1][w - weight[v-1]] + value[v-1])
        # v-1 番目の品物を選ばない場合
        dp[v][w] =  max(dp[v][w],dp[v-1][w])
        
# 価値の総和の最大値を出力
print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
# F - LCS
s = input()
t = input()

m = len(s)
n = len(t)

# dp[i][j]: s の i 文字目、 t の j 文字目までを比較したときの LSC の長さ
dp = [[0]*(n+1) for _ in range(m+1)]

# 初期条件
# 0 文字目 (i=0 or j=0) のとき LSC は 0
for i in range(m+1):
    dp[i][0] = 0
for j in range(n+1):
    dp[0][j] = 0

# s の v 文字目について
for v in range(1,m+1):
    # t の w 文字目について
    for w in range(1,n+1):
        # s の v 文字目と t の w 文字目が同じとき
        if s[v-1] == t[w-1]:
            dp[v][w] = dp[v-1][w-1] + 1
        # s の v 文字目と t の w 文字目が異なるとき
        else:
            dp[v][w] = max(dp[v-1][w],dp[v][w-1])

# 文字列を 「復元」
# DP テーブルの値を見ながら、今いるノード (i,j) がどのノードから更新されて来たのかを特定する

# 遡った文字を保持する配列
res = []

# DP テーブルの末端の index
i = m
j = n
while (i>0 and j>0):
    # (i-1, j) -> (i, j) と遷移していた場合 (s[i-1] != t[j-1]) 
    if (dp[i][j] == dp[i-1][j]):
        # DP の遷移を i について 1 遡る
        i -= 1
    else:
        # (i, j-1) -> (i, j) と遷移していた場合 (s[i-1] != t[j-1]) 
        if (dp[i][j] == dp[i][j-1]):
            # DP の遷移を j について 1 遡る
            j -= 1
        # (i-1, j-1) -> (i, j) と遷移していた場合 (s[i-1] == t[j-1]) 
        else:
            # s[i-1] == t[j-1] なので、res.append(t[j-1]) でも良い
            res.append(s[i-1])
            # DP の遷移を遡る
            i -= 1
            j -= 1
            
# res は逆方向から取得したので reverse する
ans = list(reversed(res))
print(''.join(ans))

Fixed submission:
# F - LCS
s = input()
t = input()

m = len(s)
n = len(t)

# dp[i][j]: s の i 文字目、 t の j 文字目までを比較したときの LSC の長さ
dp = [[0]*(n+1) for _ in range(m+1)]

# 初期条件
# 0 文字目 (i=0 or j=0) のとき LSC は 0
for i in range(m+1):
    dp[i][0] = 0
for j in range(n+1):
    dp[0][j] = 0

# s の v 文字目について
for v in range(1,m+1):
    # t の w 文字目について
    for w in range(1,n+1):
        # s の v 文字目と t の w 文字目が同じとき
        if s[v-1] == t[w-1]:
            dp[v][w] = dp[v-1][w-1] + 1
        # s の v 文字目と t の w 文字目が異なるとき
        else:
            dp[v][w] = max(dp[v-1][w],dp[v][w-1])

# 文字列を 「復元」
# DP テーブルの値を見ながら、今いるノード (i,j) がどのノードから更新されて来たのかを特定する

# 遡った文字を保持する配列
res = []

# DP テーブルの末端の index
i = m
j = n
while (i>0 and j>0):
    # (i-1, j) -> (i, j) と遷移していた場合 (s[i-1] != t[j-1]) 
    if (dp[i][j] == dp[i-1][j]):
        # DP の遷移を i について 1 遡る
        i -= 1
    else:
        # (i, j-1) -> (i, j) と遷移していた場合 (s[i-1] != t[j-1]) 
        if (dp[i][j] == dp[i][j-1]):
            # DP の遷移を j について 1 遡る
            j -= 1
        # (i-1, j-1) -> (i, j) と遷移していた場合 (s[i-1] == t[j-1]) 
        else:
            # s[i-1] == t[j-1] なので、res.append(t[j-1]) でも良い
            res.append(s[i-1])
            # DP の遷移を遡る
            i -= 1
            j -= 1
            
# res は逆方向から取得したので reverse する
ans = list(reversed(res))
print(''.join(ans))
Buggy python submission (verdict: Runtime Error):
#100 C - /\/\/\/ AC
import collections
n = int(input())
A = list(map(int,input().split()))

A1 = A[::2]
A2 = A[1::2]
cnt1 = collections.Counter(A1)
cnt2 = collections.Counter(A2)

items1 = list(cnt1.most_comon())
items2 = list(cnt2.most_comon())

if items1[0][0] != items2[0][0]:
    ans = (len(A1) - items1[0][1]) + (len(A2) - items2[0][1])
else:
    if len(items1) == len(items2) == 1:
        ans = min(len(A1),len(A2))

    else:
        ans1 = (len(A1) - items1[0][1]) + (len(A2) - items2[1][1])
        ans2 = (len(A1) - items1[1][1]) + (len(A2) - items2[0][1])
        ans = min(ans1,ans2)
print(ans)

Fixed submission:
#100 C - /\/\/\/
import collections
n = int(input())
A = list(map(int,input().split()))

A1 = A[::2]
A2 = A[1::2]
cnt1 = collections.Counter(A1)
cnt2 = collections.Counter(A2)

items1 = list(cnt1.items())
items2 = list(cnt2.items())
items1 = sorted(items1,key = lambda x:x[1],reverse = True)
items2 = sorted(items2,key = lambda x:x[1],reverse = True)

if items1[0][0] != items2[0][0]:
    ans = (len(A1) - items1[0][1]) + (len(A2) - items2[0][1])
else:
    if len(items1) == len(items2) == 1:
        ans = min(len(A1),len(A2))

    else:
        ans1 = (len(A1) - items1[0][1]) + (len(A2) - items2[1][1])
        ans2 = (len(A1) - items1[1][1]) + (len(A2) - items2[0][1])
        ans = min(ans1,ans2)
print(ans)

Buggy python submission (verdict: Runtime Error):
#100 C - /\/\/\/
import collections
n = int(input())
A = list(map(int,input().split()))

A1 = A[::2]
A2 = A[1::2]
cnt1 = collections.Counter(A1)
cnt2 = collections.Counter(A2)

items1 = list(cnt1.items())
items2 = list(cnt2.items())

if items1[0][0] != items2[0][0]:
    ans = (len(A1) - items1[0][1]) + (len(A2) - items2[0][1])
else:
    ans1 = (len(A1) - items1[0][1]) + (len(A2) - items2[1][1])
    ans2 = (len(A1) - items1[1][1]) + (len(A2) - items2[0][1])
    ans = min(ans1,ans2)
print(ans)

Fixed submission:
#100 C - /\/\/\/
import collections
n = int(input())
A = list(map(int,input().split()))

A1 = A[::2]
A2 = A[1::2]
cnt1 = collections.Counter(A1)
cnt2 = collections.Counter(A2)

items1 = list(cnt1.items())
items2 = list(cnt2.items())
items1 = sorted(items1,key = lambda x:x[1],reverse = True)
items2 = sorted(items2,key = lambda x:x[1],reverse = True)

if items1[0][0] != items2[0][0]:
    ans = (len(A1) - items1[0][1]) + (len(A2) - items2[0][1])
else:
    if len(items1) == len(items2) == 1:
        ans = min(len(A1),len(A2))

    else:
        ans1 = (len(A1) - items1[0][1]) + (len(A2) - items2[1][1])
        ans2 = (len(A1) - items1[1][1]) + (len(A2) - items2[0][1])
        ans = min(ans1,ans2)
print(ans)
Buggy python submission (verdict: Runtime Error):
if K%2 == 0:
    ans = A - B 
else:
    ans = B - A
print(ans)

Fixed submission:
A,B,C,K = map(int,input().split())

if K%2 == 0:
    ans = A - B 
else:
    ans = B - A
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
X = int(input())
def expo(x):
    ans = 1
    for i in reversed(range(1,x+1)):
        for j in range(int(math.sqrt(x))+1):
            for k in range(2,x+1):
                if i == j**k:
                    ans = i
                    return ans
    return ans
print(expo(X))

Fixed submission:
#B - Exponential
import math
X = int(input())
def expo(x):
    ans = 1
    for i in reversed(range(1,x+1)):
        for j in range(int(math.sqrt(x))+1):
            for k in range(2,int(math.sqrt(x))):
                if i == j**k:
                    ans = i
                    return ans
    return ans
print(expo(X))
Buggy python submission (verdict: Runtime Error):
A,B,C,X,Y = map(int,input().split())

#全部Cで買うとき
a = 2*C*min(X,Y) + 2*C*(max(X,Y)-min(X,Y))

#片方を全部Cで買うとき
if X > Y:
    b = 2*C*Y + (X-Y)*A
elif Y > X:
    b = 2*C*X + (Y-X)*B
else:
    b = a
print(b)
    
#全部AとBで買うとき
c = A*X + B*Y
print(c)

print(min(a,b,c))    

Fixed submission:
S = input()
cnt = S.count('o')
print(700+100*cnt)
Buggy python submission (verdict: Runtime Error):
A,B,C,X,Y = map(int,input().split())

#全部Cで買うとき
a = 2*C*min(X,Y) + 2*C*(max(X,Y)-min(X,Y))

#片方を全部Cで買うとき
if X > Y:
    b = 2*C*Y + (X-Y)*A
elif Y > X:
    b = 2*C*X + (Y-X)*A

#全部AとBで買うとき
c = A*X + B*Y

print(min(a,b,c))    

Fixed submission:
A,B,C,X,Y = map(int,input().split())

#全部Cで買うとき
a = 2*C*min(X,Y) + 2*C*(max(X,Y)-min(X,Y))

#片方を全部Cで買うとき
if X > Y:
    b = 2*C*Y + (X-Y)*A
elif Y > X:
    b = 2*C*X + (Y-X)*B
else:
    b = a
    
#全部AとBで買うとき
c = A*X + B*Y

print(min(a,b,c))
Buggy python submission (verdict: Time Limit Exceeded):
#51 C - Many Medians
N = int(input())
X = list(map(int,input().split()))
Xsrt = sorted(X,reverse = False)

ans = []
for x in X:
    Xc = Xsrt.copy()
    Xc.remove(x)
    B = Xc[len(Xc)//2]
    ans.append(B)

for i in ans:
    print(i)

Fixed submission:
#51 C - Many Medians
N = int(input())
X = list(map(int,input().split()))
Xsrt = sorted(X,reverse = False)
XL = set(Xsrt[:N//2])
XR = set(Xsrt[N//2:])

ans = []
for x in X:
    if x in XR:
        ans.append(Xsrt[N//2-1])
    elif x in XL:
        ans.append(Xsrt[N//2])
for a in  ans:
    print(a)
Buggy python submission (verdict: Runtime Error):
#13 C - Traveling
N = int(input())

plan = []
for _ in range(N):
    ti,xi,yi = map(int,input().split())
    plan.append((ti,xi,yi))
    
#今いる場所の座標と時間
spot = (0,0,0)#始点
result = 'Yes'
for t,x,y in plan:
    tdiff = t-spot[0]
    xdiff = abs(x-spot[1])
    ydiff = abs(y-spot[2])
    #(x,y)の変化量の和の偶奇と時間の差の偶奇が一致している
    #時間の変化量より(x,y)の変化量の方が小さい
    if (tdiff%2 == (xdiff+ydiff)%2) and ((xdiff + ydiff)<=tdiff):
    '''
    xdiff<=tdiff and ydiff<=t だと(3,3,2)などの範囲外に対応できない
    if (tdiff%2 == (xdiff+ydiff)%2) and (xdiff<=tdiff) and (ydiff<=tdiff):
    '''
        spot = (t,x,y)
    else:
        result = 'No'
        break
print(result)

Fixed submission:
#13 C - Traveling
N = int(input())

plan = []
for _ in range(N):
    ti,xi,yi = map(int,input().split())
    plan.append((ti,xi,yi))
    
#今いる場所の座標と時間
spot = (0,0,0)#始点
result = 'Yes'
for t,x,y in plan:
    tdiff = t-spot[0]
    xdiff = abs(x-spot[1])
    ydiff = abs(y-spot[2])
    #(x,y)の変化量の和の偶奇と時間の差の偶奇が一致している
    #時間の変化量より(x,y)の変化量の方が小さい
    if (tdiff%2 == (xdiff+ydiff)%2) and ((xdiff + ydiff)<=tdiff):
        '''
        xdiff<=tdiff and ydiff<=t だと(3,3,2)などの範囲外に対応できない
        if (tdiff%2 == (xdiff+ydiff)%2) and (xdiff<=tdiff) and (ydiff<=tdiff):
        '''
        spot = (t,x,y)
    else:
        result = 'No'
        break
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
#A - AKIBA △
S = input()
S = list(S)

SS = []
for p in S:#Aを追加する空白を作る
    SS.append('')
    SS.append(p)
SS.append('')


result = 'NO'
if len(S) <= 9 and S.count('K') == S.count('I') == S.count('H') == S.count('B') == S.count('R') == 1 :
    for i in range(1<<(len(SS))):
        SSS = SS.copy()
        for j in range(len(SS)):
            mask = 1 << j
            if mask & i != 0:#処理を行う
                if SSS[j] == '':
                    SSS[j] = 'A'
        for k in SSS:
            if k == '':
                SSS.remove('')
        if SSS == ['A','K','I','H','A','B','A','R','A']:
            result = 'YES'
print(result)

Fixed submission:
#A - AKIBA △
S = input()
S = list(S)

SS = []
for p in S:#Aを追加する空白を作る
    SS.append('')
    SS.append(p)
SS.append('')


result = 'NO'
if len(S) <= 9 and 'K' in S and 'I' in S and 'H' in S and 'B' in S and 'R' in S:
    for i in range(1<<(len(SS))):
        SSS = SS.copy()
        for j in range(len(SS)):
            mask = 1 << j
            if mask & i != 0:#処理を行う
                if SSS[j] == '':
                    SSS[j] = 'A'
        for k in SSS:
            if k == '':
                SSS.remove('')
        if SSS == ['A','K','I','H','A','B','A','R','A']:
            result = 'YES'
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
#A - AKIBA △
S = input()
S = list(S)

SS = []
for p in S:#Aを追加する空白を作る
    SS.append('')
    SS.append(p)
SS.append('')


result = 'NO'
if len(S) <= 9 and 'K' in S and 'I' in S and 'H' in S and 'B' in S and 'R' in S:
    for i in range(1<<(len(SS))):
        SSS = SS.copy()
        for j in range(len(SS)):
            mask = 1 << j
            if mask & i != 0:#処理を行う
                if SSS[j] == '':
                    SSS[j] = 'A'
        for k in SSS:
            if k == '':
                SSS.remove('')
        if SSS == ['A','K','I','H','A','B','A','R','A']:
            result = 'YES'
print(result)

Fixed submission:
#A - AKIBA △
S = input()
S = list(S)

SS = []
for p in S:#Aを追加する空白を作る
    SS.append('')
    SS.append(p)
SS.append('')


result = 'NO'
if len(S) <= 9 and 'K' in S and 'I' in S and 'H' in S and 'B' in S and 'R' in S:
    for i in range(1<<(len(SS))):
        SSS = SS.copy()
        for j in range(len(SS)):
            mask = 1 << j
            if mask & i != 0:#処理を行う
                if SSS[j] == '':
                    SSS[j] = 'A'
        for k in SSS:
            if k == '':
                SSS.remove('')
        if SSS == ['A','K','I','H','A','B','A','R','A']:
            result = 'YES'
print(result)
Buggy python submission (verdict: Runtime Error):
#78 C - HSI
N,M = map(int,input().split())
# 全て AC となる確率
p = (1/2)**M

# E = 1/p になる
E = 1/p
ans = (1900*M + 100*(N-M))*E
ans = round(ans)
print(ans)

Fixed submission:
X,Y = map(ord,input().split())

if X > Y:
  print('>')
elif X < Y:
  print('<')
else:
  print('=')
Buggy python submission (verdict: Time Limit Exceeded):
#38 B - Problem Set
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

result = 'YES'
for t in T:
    if not(t in D):
        result = 'NO'
        break
    D.remove(t)
print(result)

Fixed submission:
#38 B - Problem Set
import collections
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

cntD = collections.Counter(D)
cntT = collections.Counter(T)

result = 'YES'
for t in cntT.keys():
    if not(t in cntD):
        result = 'NO'
        break
    if cntT[t] > cntD[t]:
        result = 'NO'
        break
print(result)