Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#C - Many Requirements
#再帰関数(n重のfor文)
N,M,Q = map(int,input().split())
abcd = []
for _ in range(Q):
    a,b,c,d = map(int,input().split())
    abcd.append((a,b,c,d))
def dfs(A):
    if len(A) == N:
        #処理
        score = 0
        for ai,bi,ci,di in abcd:
            if A[bi-1] -A[ai-1] == ci:
                score += di
        return score
    max_score = 0 
    #一つ前の値を保持
    if len(A) > 1:
        prev_last = A[-1]
    else:
        prev_last = 1
    #1つ前の値より大きい値の範囲
    for i in range(prev_last,M+1):
        A.append(i)
        max_score = max(max_score,dfs(A))
        A.pop()
    return max_score#ループの途中のdfs (len(A) != N のとき) に値を返す
print(dfs[])

Fixed submission:
# 入力
N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

# スコア計算
def score(A):
    tmp = 0
    for ai, bi, ci, di in zip(a, b, c, d):
        if A[bi] - A[ai] == ci:
            tmp += di
    return tmp

# DFS
def dfs(A):
    if len(A) == N:
        return score(A) # 数列 A のスコアを返す
    res = 0
    prev_last = A[-1] if len(A) > 0 else 0
    for v in range(prev_last, M):
        A.append(v)
        res = max(res, dfs(A)) # 再帰呼出しながら、スコア最大値も更新
        A.pop()
    return res

# 求める
print(dfs([]))
Buggy python submission (verdict: Runtime Error):
#C - Traveling Salesman around Lake WA(ヒント)
K,N = map(int,input().split())
A = list(map(int, input().split()))

A[N+1:] = [A[0] + K]#Aを二回繰り返して円を表現

distance_list = []
for i in range(N):
    distance = abs(A[i] - A[i+1])
    distance_list.append(distance)
distance_list.remove(max(distance_list))
print(sum(distance_list))

Fixed submission:
S = input()
if (S[2] == S[3]) and (S[4] == S[5]):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
#C - Traveling Salesman around Lake WA(ヒント)
K,N = map(int,input().split())
A = list(map(int, input().split()))

A[N+1:] = A#Aを二回繰り返して円を表現
A_reverse = reversed(A)

distance_list = []
for i in range(N):#スタート地点の数
    distance = 0
    for j in range(N-1):#道の数
        distance += abs(A[i+1] - A[i])#道の距離
    distance_list.append(distance)
for k in range(N):#逆回りについて
    distance = 0
    for j in range(N-1):
        distance += abs(A[i+1] - A[i])
    distance_list.append(distance)
print(min(distance_list))

Fixed submission:
#C - Traveling Salesman around Lake WA(ヒント)
K,N = map(int,input().split())
A = list(map(int, input().split()))

A[N+1:] = [A[0] + K]#Aを二回繰り返して円を表現

distance_list = []
for i in range(N):
    distance = abs(A[i] - A[i+1])
    distance_list.append(distance)
distance_list.remove(max(distance_list))
print(sum(distance_list))

Buggy python submission (verdict: Time Limit Exceeded):
#C - Traveling Salesman around Lake WA(ヒント)
K,N = map(int,input().split())
A = list(map(int, input().split()))

A[N+1:] = A#Aを二回繰り返して円を表現
A_reverse = reversed(A)

distance_list = []
for i in range(N):#スタート地点の数
    distance = 0
    for j in range(N-1):#道の数
        distance += abs(A[i+1] - A[i])#道の距離
    distance_list.append(distance)
for k in range(N):#逆回りについて
    distance = 0
    for j in range(N-1):
        distance += abs(A[i+1] - A[i])
    distance_list.append(distance)
print(min(distance_list))

Fixed submission:
#C - Traveling Salesman around Lake WA(ヒント)
K,N = map(int,input().split())
A = list(map(int, input().split()))

A[N+1:] = [A[0] + K]#Aを二回繰り返して円を表現

distance_list = []
for i in range(N):
    distance = abs(A[i] - A[i+1])
    distance_list.append(distance)
distance_list.remove(max(distance_list))
print(sum(distance_list))
Buggy python submission (verdict: Time Limit Exceeded):
#21 D - Banned K
import collections
from collections import deque
N = int(input())
A = list(map(int,input().split()))
 
cnt = collections.Counter(A)

ans = deque([])
for i in A:
    cnt_cpy = cnt.copy()
    cnt_cpy[i] -= 1
    comb = 0
    for j in cnt_cpy.values():
        if j >= 2:
            comb += (j*(j-1))//2
    ans.append(comb)
for k in ans:
    print(k)

Fixed submission:
#21 D - Banned K AC TLE(hint)
import collections
N = int(input())
A = list(map(int,input().split()))

cnt = collections.Counter(A)
#先に組み合わせの個数を計算しておく
combinations = {}
for j in cnt.keys():
    if cnt[j] >= 2:
        comb = (cnt[j]*(cnt[j]-1))//2
        combinations[j] = comb      

#あるボールを選ばないとき、組み合わせの総数は
#(全組み合わせ数) - (選ばないボールと同じボールの数 - 1)
tot = sum(combinations.values())
ans = []
for i in A:
    a = tot - (cnt[i] - 1)
    ans.append(a)
    
for k in ans:
    print(k)

Buggy python submission (verdict: Time Limit Exceeded):
#21 D - Banned K
import collections
N = int(input())
A = list(map(int,input().split()))

cnt = collections.Counter(A)

ans = []
for i in A:
    cnt_cpy = cnt.copy()
    cnt_cpy[i] -= 1
    comb = 0
    for j in cnt_cpy.values():
        if j >= 2:
            comb += (j*(j-1))//2
    ans.append(comb)
for k in ans:
    print(k)

Fixed submission:
#21 D - Banned K AC TLE(hint)
import collections
N = int(input())
A = list(map(int,input().split()))

cnt = collections.Counter(A)
#先に組み合わせの個数を計算しておく
combinations = {}
for j in cnt.keys():
    if cnt[j] >= 2:
        comb = (cnt[j]*(cnt[j]-1))//2
        combinations[j] = comb      

#あるボールを選ばないとき、組み合わせの総数は
#(全組み合わせ数) - (選ばないボールと同じボールの数 - 1)
tot = sum(combinations.values())
ans = []
for i in A:
    a = tot - (cnt[i] - 1)
    ans.append(a)
    
for k in ans:
    print(k)

Buggy python submission (verdict: Time Limit Exceeded):
#21 D - Banned K
import collections
N = int(input())
A = list(map(int,input().split()))

cnt = collections.Counter(A)

ans = []
for i in A:
    cnt_cpy = cnt.copy()
    cnt_cpy[i] -= 1
    comb = 0
    for j in cnt_cpy.values():
        if j >= 2:
            comb += (j*(j-1))//2
    ans.append(comb)
for k in ans:
    print(k)

Fixed submission:
#21 D - Banned K AC TLE(hint)
import collections
N = int(input())
A = list(map(int,input().split()))

cnt = collections.Counter(A)
#先に組み合わせの個数を計算しておく
combinations = {}
for j in cnt.keys():
    if cnt[j] >= 2:
        comb = (cnt[j]*(cnt[j]-1))//2
        combinations[j] = comb      

#あるボールを選ばないとき、組み合わせの総数は
#(全組み合わせ数) - (選ばないボールと同じボールの数 - 1)
tot = sum(combinations.values())
ans = []
for i in A:
    a = tot - (cnt[i] - 1)
    ans.append(a)
    
for k in ans:
    print(k)
Buggy python submission (verdict: Runtime Error):
#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
if H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)

Fixed submission:
#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
    count = 1
elif H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
#B - Bishop
H,W = map(int,input().split())

count = 0
for i in range(H):#縦の動き
    for j in range(W):#横の動き
        if (i + j) % 2 == 0:
            count += 1
print(count)

Fixed submission:
#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
    count = 1
elif H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
#B - Bishop
H,W = map(int,input().split())

count = 0
for i in range(H):#縦の動き
    for j in range(W):#横の動き
        if (i + j) % 2 == 0:
            count += 1
print(count)

Fixed submission:
#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
    count = 1
elif H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)
Buggy python submission (verdict: Runtime Error):
# C - Sqrt Inequality
import decimal
a,b,c = input().split()
a,b,c = map(decimal.Decimal,[a,b,c])
rta,rtb,rtc = map(math.sqrt,[a,b,c])
sqrt = decimal.Decimal(0.5)
if a**sqrt + b**sqrt < c**sqrt:
    print('Yes')
else:
    print('No')

Fixed submission:
# C - Sqrt Inequality
import decimal
a,b,c = input().split()
a,b,c = map(decimal.Decimal,[a,b,c])
sqrt = decimal.Decimal(0.5)
if a**sqrt + b**sqrt < c**sqrt:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
# C - Sqrt Inequality
import math
import decimal
a,b,c = input().split()
a,b,c = map(decimal.Decimal,[a,b,c])
rta,rtb,rtc = map(math.sqrt,[a,b,c])
rta,rtb,rtc = map(srt,[rta,rtb,rtc])
rta,rtb,rtc = map(decimal.Decimal,[rta,rtb,rtc])

if rta + rtb < rtc:
    print('Yes')
else:
    print('No')

Fixed submission:
# C - Sqrt Inequality
import decimal
a,b,c = input().split()
a,b,c = map(decimal.Decimal,[a,b,c])
sqrt = decimal.Decimal(0.5)
if a**sqrt + b**sqrt < c**sqrt:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
# C - Sqrt Inequality
a,b,c = map(int,input().split())
rta,rtb,rtc = map(math.sqrt,[a,b,c])

if rta + rtb < rtc:
    print('Yes')
else:
    print('No')

Fixed submission:
# C - Sqrt Inequality
import decimal
a,b,c = input().split()
a,b,c = map(decimal.Decimal,[a,b,c])
sqrt = decimal.Decimal(0.5)
if a**sqrt + b**sqrt < c**sqrt:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
#C - Poll
N = int(input())
S = [input() for _ in range(N)]
S_set = list(sorted(set(S)))

counter = [0]*(len(S_set))

for i in S:
    counter[S_set.index(i)] += 1

maxim = max(counter)
ans= [S_set[i] for i in range(len(S_set)) if counter[i] == maxim ]
for j in ans:
    print(j)

Fixed submission:
#C - Poll
N = int(input())
S = [input() for _ in range(N)]
S_set = list(sorted(set(S)))

counter = {}
for k in S_set:
    counter[k] = 0
for i in S:
    counter[i] += 1
    
maxim = max(counter.values())
ans = [i for i in S if counter[i] == maxim]
ans = list(sorted(set(ans))) 

for j in ans:
    print(j)
Buggy python submission (verdict: Runtime Error):
import math
X = int(input())

def is_prime(x):
    a = int(math.sqrt(X)) + 1#ある数が素数かどうかはO(√A)で判定できる
    for i in range(2,a):
        if x % i == 0:
            return False
    return True#xは素数

for j in range(X,10**5):
    if is_prime(j):
        ans = j    
        break
print(ans)

Fixed submission:
import math
X = int(input())

def is_prime(x):
    a = int(math.sqrt(X)) + 1
    for i in range(2,a):
        if x % i == 0:
            return False
    return True

for j in range(X,X+100):
    if is_prime(j):
        ans = j    
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
# D - Prediction and Restriction 
N,K = map(int,input().split())
RSP = tuple(map(int,input().split()))
T = input()

# じゃんけんの勝敗を返す関数
def judge(a,b):
    if a == 'r' and b == 2:
        return True
    elif a == 's' and b == 0:
        return True
    elif a == 'p' and b == 1:
        return True
    return False

# dp[i][j]: i 回目のじゃんけんで j を出したときの最大値
# グー:0, チョキ:1, パー:2
dp = [[0]*3 for _ in range(N+1)]

# v 回目のじゃんけん
for v in range(1,N+1):
    # v 回目に出した手
    for w in range(3):
        # v-K 回目に出した手 
        for k in range(3):
            if w == k:
                continue
            # じゃんけんで勝ったとき
            if judge(T[v-1],w):
                dp[v][w] = max(dp[v][w],dp[v-K][k] + RSP[w])
            # じゃんけんで負けか引き分けたとき
            else;
                dp[v][w] = max(dp[v][w],dp[v-K][k])    
# K 個に分けた各グループの部分和の最大値の総和を求める
ans = 0
for a in range(1,K+1):
    ans += max(dp[-a])
print(ans)

Fixed submission:
# D - Prediction and Restriction 
N,K = map(int,input().split())
RSP = tuple(map(int,input().split()))
T = input()

# じゃんけんの勝敗を返す関数
def judge(a,b):
    if a == 'r' and b == 2:
        return True
    elif a == 's' and b == 0:
        return True
    elif a == 'p' and b == 1:
        return True
    return False

# dp[i][j]: i 回目のじゃんけんで j を出したときの最大値
# グー:0, チョキ:1, パー:2
dp = [[0]*3 for _ in range(N+1)]

# v 回目のじゃんけん
for v in range(1,N+1):
    # v 回目に出した手
    for w in range(3):
        # v-K 回目に出した手 
        for k in range(3):
            if w == k:
                continue
            # じゃんけんで勝ったとき
            if judge(T[v-1],w):
                dp[v][w] = max(dp[v][w],dp[v-K][k] + RSP[w])
            # じゃんけんで負けか引き分けたとき
            else:
                dp[v][w] = max(dp[v][w],dp[v-K][k])         
# K 個に分けた各グループの部分和の最大値の総和を求める
ans = 0
for a in range(1,K+1):
    ans += max(dp[-a])
print(ans)
Buggy python submission (verdict: Runtime Error):
#70 C - 100 to 105 WA
X = int(input())

dp = [0]*(X+1)
lst = [100,101,102,103,104,105]
for i in range(100,106):
    dp[i] = 1

# dp[v] が存在するなら 1, しないなら 0
for v in range(100,X+1):
    for w in range(6):
        n = lst[w]
        if dp[v-n] == 1:
            dp[v] = 1
print(dp[X])

Fixed submission:
#70 C - 100 to 105 WA
X = int(input())

dp = [0]*(100010)
lst = [100,101,102,103,104,105]
for i in range(100,106):
    dp[i] = 1

# dp[v] が存在するなら 1, しないなら 0
for v in range(100,X+1):
    for w in range(6):
        n = lst[w]
        if dp[v-n] == 1:
            dp[v] = 1
print(dp[X])
Buggy python submission (verdict: Time Limit Exceeded):
# D - Lucky PIN
N = int(input())
S = list(input())
S = [int(s) for s in S]

# dp[i][j][k]: パスワード ijk を作ることができるか
dp = [[[False]*10 for _ in range(10)] for _ in range(10)]

for v in range(N):
    for w in range(v+1,N):
        for x in range(w+1,N):
            tgt = dp[S[v]][S[w]][S[x]]
            if tgt:
                continue
            dp[S[v]][S[w]][S[x]] = True

ans = 0
for i in dp:
    for j in i:
        for k in j:
            if k == True:
                ans += 1
print(ans)

Fixed submission:
# D - Lucky PIN
N = int(input())
S = input()

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            a = S.find(str(i))
            if a == -1:
                continue
            # i が含まれるとき
            b = S.find(str(j),a+1)
            if not(a < b):
                continue
            # j の index が a以降のとき
            c = S.find(str(k),b+1)
            if not(b < c):
                continue
            # k の index が b　以降のとき
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# D - Lucky PIN
N = int(input())
S = list(input())
S = [int(s) for s in S]

# dp[i][j][k]: パスワード ijk を作ることができるか
dp = [[[False]*10 for _ in range(10)] for _ in range(10)]

for v in range(N):
    for w in range(v+1,N):
        for x in range(w+1,N):
            tgt = dp[S[v]][S[w]][S[x]]
            if tgt:
                continue
            dp[S[v]][S[w]][S[x]] = True

ans = 0
for i in dp:
    for j in i:
        for k in j:
            if k == True:
                ans += 1
print(ans)

Fixed submission:
# D - Lucky PIN
N = int(input())
S = input()

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            a = S.find(str(i))
            if a == -1:
                continue
            # i が含まれるとき
            b = S.find(str(j),a+1)
            if not(a < b):
                continue
            # j の index が a以降のとき
            c = S.find(str(k),b+1)
            if not(b < c):
                continue
            # k の index が b　以降のとき
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#D - Triangles

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

L_sorted = sorted(L, reverse = False)#昇順

def judge(A,B,x):#cが三角形になるか判定する関数
    if A + B <= L_sorted[x]:#a + b = cの時はfinを持ってくる
        return 'high'
    else :
        return 'low'

count = 0
for i in range(N):#aの選び方
    for j in range(i+1,N):#bの選び方
        a = L_sorted[i]
        b = L_sorted[j]#b <= c < a+b
        sta = 0
        fin = N#Lの個数+1
        while fin > sta + 1:#cの選び方
            m = ((fin - sta) // 2) + sta
            if judge(a,b,m) == 'high':
                fin = m
            elif judge(a,b,m) == 'low':
                sta = m
        count += sta  - j    
print(count)

Fixed submission:
#D - Triangles

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

L_sorted = sorted(L, reverse = False)#昇順

def judge(A,B,x):#cが三角形になるか判定する関数
    if A + B <= L_sorted[x]:#a + b = cの時はfinを持ってくる
        return 'high'
    else :
        return 'low'

count = 0
for i in range(N):#aの選び方
    for j in range(i+1,N):#bの選び方
        a = L_sorted[i]
        b = L_sorted[j]#b <= c < a+b
        sta = 0
        fin = N#Lの個数+1
        while fin > sta + 1:#cの選び方
            m = ((fin - sta) // 2) + sta
            if judge(a,b,m) == 'high':
                fin = m
            elif judge(a,b,m) == 'low':
                sta = m
        count += sta  - j    
print(count)
Buggy python submission (verdict: Runtime Error):
# A - Connection and Disconnection
S = input()
K = int(input())
S = S + '1'# 番兵

# 連続する文字数をカウント
cnt = []
conti = 1
for i in range(1,len(S)):
    if S[i-1] == S[i]:
        conti += 1
    else:
        cnt.append(conti)
        conti = 1

# 最初と最後の文字が同じとき
if S[0] == S[-2]:
    # 奇数個 + 奇数個のとき
    if cnt[0]%2 == 1 and cnt[-1]%2 == 1:
        comp = K - 1
        
ans = [a//2 for a in cnt if a >= 2]
ans = sum(ans)*K + comp
print(ans)        

Fixed submission:
# A - Connection and Disconnection
S = input()
K = int(input())
S = S + '1'# 番兵

# 連続する文字数をカウント
cnt = []
conti = 1
for i in range(1,len(S)):
    if S[i-1] == S[i]:
        conti += 1
    else:
        cnt.append(conti)
        conti = 1
        
# 最初と最後の文字が同じときの補正値
comp = 0
if S[0] == S[-2]:
    # 奇数個 + 奇数個のとき
    if cnt[0]%2 == 1 and cnt[-1]%2 == 1:
        comp = K - 1
    # S =aaa などのとき
    if len(set(S[:-1])) == 1 and len(S[:-1])%2 == 1:
        comp = K // 2
        
ans = [a//2 for a in cnt if a >= 2]
ans = sum(ans)*K + comp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

A = [A.index(i)+1 for i in range(1,N+1)]
print(*A)

Fixed submission:
# C - Go to School TLE
N = int(input())
A = list(map(int, input().split()))

attend = [i for i in range(1,N+1)]
for j in range(1,N+1):
    attend[A[j-1] - 1] = j
print(*attend)

Buggy python submission (verdict: Time Limit Exceeded):
#C - Go to School
N = int(input())
A = list(map(int, input().split()))

A = [A.index(i)+1 for i in range(1,N+1)]
A = [str(j) for j in A]
print(' '.join(A))

Fixed submission:
# C - Go to School TLE
N = int(input())
A = list(map(int, input().split()))

attend = [i for i in range(1,N+1)]
for j in range(1,N+1):
    attend[A[j-1] - 1] = j
print(*attend)
Buggy python submission (verdict: Runtime Error):
#C - Maximal Value
N = int(input())
B = list(map(int,input().split()))
A = [B[0]]
for i in range(1,N-1):
    if B[i] > B[i-1]:
        A.append(B[i-1])
    else:
        A.append(B[i])
A.append(B[-1])
print(sum(A))

Fixed submission:
N = int(input())
print(N**3)

Buggy python submission (verdict: Runtime Error):
#C - Maximal Value
N = int(input())
B = list(map(int,input().split()))
print(B)
A = [B[0]]
for i in range(1,N-1):
    if B[i] > B[i-1]:
        A.append(B[i-1])
    else:
        A.append(B[i])
A.append(B[-1])
print(sum(A))

Fixed submission:
N = int(input())
print(N**3)
Buggy python submission (verdict: Runtime Error):
#B - Power Socket
A,B = list(map(int,input().split()))

count = 0
total_plug = 1
for i in range(1,100):
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)


Fixed submission:
S = input()
T = input()
count = 0
for i in range(3):
  if S[i] == T[i]:
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
#B - Power Socket
A,B = input().split()
A = int(A)
B = int(B)

count = 0
total_plug = 1
for i in range(1,20):
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)

Fixed submission:
S = input()
T = input()
count = 0
for i in range(3):
  if S[i] == T[i]:
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
#B - Power Socket
A,B = input().split()
A = int(A)
B = int(B)

count = 0
total_plug = 1
for i in range(1,100):
    print(total_plug)
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)

Fixed submission:
S = input()
T = input()
count = 0
for i in range(3):
  if S[i] == T[i]:
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
#B - Power Socket
A,B = list(map(int,input().split()))

count = 0
total_plug = 1
for i in range(1,100):
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)

Fixed submission:
S = input()
T = input()
count = 0
for i in range(3):
  if S[i] == T[i]:
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
#B - Power Socket
A,B = list(map(int,input().split()))

count = 0
total_plug = 1
for i in range(1,100):
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)

Fixed submission:
S = input()
T = input()
count = 0
for i in range(3):
  if S[i] == T[i]:
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int,input().split()))

maxim = 0
for i in range(N-1):
    count = 0
    for j in range(i,N-1):
        if H[j] >= H[j+1]:
            count += 1
        else:
            break
    if count > maxim:
        maxim = count
print(maxim)

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

maxim = 0
count = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        count = 0
    if count > maxim:
        maxim = count
print(maxim)
Buggy python submission (verdict: Time Limit Exceeded):
#C - Exception Handling
N = int(input())
A = list(int(input()) for _ in range(N))
A_sorted = list(set(sorted(A, reverse = False)))

ans = []
for i in A:
    A_copy = A.copy()
    A_copy.remove(i)
    ans.append(max(A_copy))

for i in ans:
    print(i)

Fixed submission:
# C - Exception Handling
N = int(input())
A = list(int(input()) for _ in range(N))
A_sorted = list((sorted(A, reverse = True)))
A_sorted = A_sorted[0:2]

ans = []
for i in A:
    if i == A_sorted[0]:
        ans.append(A_sorted[1])
    else:
        ans.append(A_sorted[0])

for j in ans:
    print(j)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
d = list(map(int,input().split()))

count = 0
for K in range(min(d),max(d)+1):
    ARC = [i for i in d if i >= K]
    ABC = [j for j in d if j < K]
    if len(ARC) == len(ABC):
        count += 1
print(count)

Fixed submission:
N = int(input())
d = list(map(int,input().split()))
d_sorted = sorted(d, reverse = False)

count = d_sorted[(N-1) //2 + 1] - d_sorted[(N-1) // 2]
print(count)
Buggy python submission (verdict: Runtime Error):
#35 C - Anti-Division　
import math
A,B,C,D = map(int,input().split())

# C と D の最小公倍数の個数
lcm = C*D//math.gcd(C,D)
cnt_lcm = B//lcm - A//lcm

# C の倍数の個数
cnt_C = B//C - (A-1)//C 

# D の倍数の個数
cnt_D = B//D - (A-1)//D

# (範囲内の整数) - (C の倍数 + D の倍数 - C,D の公倍数)
ans = (B - A + 1) - (cnt_C + cnt_D - cnt_lcm)

# 範囲が 1 しかないとき
if A == B:
    # C でも D でも割り切れるとき
    if A%C == 0 and A%D == 0:
        print(0)
    else:
        print(1)
else:
    print(ans)

Fixed submission:
# 52 D - Megalomania
N = int(input())
work = []
for _ in range(N):
    a,b = map(int,input().split())
    work.append((a,b))

# 締め切りが早い順にソート
work = sorted(work,key = lambda x:x[1],reverse = False)

result = 'Yes'
t = 0
for i,j in work:
    t += i
    if t>j:
        result = 'No'
        break
print(result)