Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp

min_mp = 10**9
for i in range(N):
    if min_mp > AB[i][1]:
        min_mp = AB[i][1]
        min_mp_i = i

for h in range(1,AB[min_mp_i][0]+1):
    DP[h] = min_mp

for h in range(AB[min_mp_i][0]+1,H+1):
    DP[h] = min((DP[h - a] + b) for a,b in AB )
    #最小消費mpの技で初期化しないとh - a >= 0を満たすaの存在が怪しい

print(DP[H])


Fixed submission:
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp

min_mp = 10**9
for i in range(N):
    if min_mp > AB[i][1]:
        min_mp = AB[i][1]
        min_mp_i = i

for h in range(1,min(AB[min_mp_i][0],H)+1):
    #最小消費mpの技でオーバーキルの場合にDP[h]がout of rangeになる
    DP[h] = min_mp

for h in range(AB[min_mp_i][0]+1,H+1):
    DP[h] = min((DP[h - a] + b) for a,b in AB )
    #最小消費mpの技で初期化しないとh - a >= 0を満たすaの存在が怪しい

print(DP[H])

Buggy python submission (verdict: Runtime Error):
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp

for h in range(1,H+1):
    DP[h] = min((DP[h - a] + b) for a,b in AB )

print(DP[H])


Fixed submission:
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp

min_mp = 10**9
for i in range(N):
    if min_mp > AB[i][1]:
        min_mp = AB[i][1]
        min_mp_i = i

for h in range(1,min(AB[min_mp_i][0],H)+1):
    #最小消費mpの技でオーバーキルの場合にDP[h]がout of rangeになる
    DP[h] = min_mp

for h in range(AB[min_mp_i][0]+1,H+1):
    DP[h] = min((DP[h - a] + b) for a,b in AB )
    #最小消費mpの技で初期化しないとh - a >= 0を満たすaの存在が怪しい

print(DP[H])

Buggy python submission (verdict: Runtime Error):
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

INF = 10**9
DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp
min_mp = INF

for i in range(N):
    if min_mp > AB[i][1]:
        min_mp = AB[i][1]
        min_mp_i = i #消費mpが最小の技の番号

for h in range(1,AB[min_mp_i][0]+1):
    DP[h] = AB[min_mp_i][1]

for h in range(AB[min_mp_i][0]+1,H+1):
    min = INF
    for i in range(N):
        if h - AB[i][0] >= 0:
        #これを満たすiの存在を保証するために消費mp最小の技でDPに初期設定を与えた
            if min > DP[h - AB[i][0]] + AB[i][1]:
                min = DP[h - AB[i][0]] + AB[i][1]
    DP[h] = min

print(DP[H])


Fixed submission:
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp

min_mp = 10**9
for i in range(N):
    if min_mp > AB[i][1]:
        min_mp = AB[i][1]
        min_mp_i = i

for h in range(1,min(AB[min_mp_i][0],H)+1):
    #最小消費mpの技でオーバーキルの場合にDP[h]がout of rangeになる
    DP[h] = min_mp

for h in range(AB[min_mp_i][0]+1,H+1):
    DP[h] = min((DP[h - a] + b) for a,b in AB )
    #最小消費mpの技で初期化しないとh - a >= 0を満たすaの存在が怪しい

print(DP[H])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))

count = 0
for i in range(N):
    if min(P[0:i+1]) >= P[i]:
        count += 1
print(count)


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

count,min = 0,P[0]
for i in range(N):
    if min >= P[i]:
        count += 1
        min = P[i]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def c_ab(n,a,b):
    ret = 0
    for i in range(1,n+1):
        max_digit = int(str(i)[0]) #iを文字列にしたときの頭
        min_digit = int(str(i)[-1]) #iを文字列にしたときの末尾
        if max_digit == a and min_digit == b:
            ret += 1
    return ret

C_ab = [[0 for i in range(10)] for j in range(10)]
for i in range(10):
    for j in range(10):
            C_ab[i][j] = c_ab(N,i,j)

count = 0
for i in range(10):
    for j in range(10):
        count += C_ab[i][j]*C_ab[j][i]

print(count)


Fixed submission:
N = int(input())

C_ab = [[0 for i in range(10)] for j in range(10)]
for i in range(1,N+1):
    C_ab[int(str(i)[0])][int(str(i)[-1])] += 1

count = 0
for i in range(1,10):
    for j in range(1,10):
        count += C_ab[i][j]*C_ab[j][i]

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def trush(XL):
    pt,output = 1,len(XL)
    while pt < len(XL)-1:
        if XL[pt-1][2] > XL[pt][1] and XL[pt][2] > XL[pt+1][1]:
            XL = XL[:pt] + XL[pt+1:]
            output -= 1
        else:
            pt += 1

    pt = 0
    while pt < len(XL)-1:
        if XL[pt][2] > XL[pt+1][1]:
            if XL[pt][0]-XL[pt][1] > XL[pt+1][0]-XL[pt+1][1]:
                XL = XL[:pt] + XL[pt+1:]
            else:
                XL = XL[:pt+1] + XL[pt+2:]
            output -= 1
        else:
            pt += 1

    return output

def main():
    N = int(input())
    XL = [list(map(int,input().split())) for _ in range(N)]
    for i in range(N):
        XL[i] = [XL[i][0],XL[i][0]-XL[i][1],XL[i][0]+XL[i][1]]
    XL.sort(key = lambda x:x[0])
    
    ans = trush(XL)
    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
def cal(XL):
    N = len(XL)
    XL.sort(key = lambda x:x[0])
    for i in range(N):
        XL[i] = [XL[i][0],XL[i][0]-XL[i][1],XL[i][0]+XL[i][1]]
    OP = [XL[0]]

    for i in range(1,N):
        if OP[len(OP)-1][2] > XL[i][1]:
            if OP[len(OP)-1][2] < XL[i][2]:
                #右方向により腕が伸びている方がより邪魔
                pass
            else:
                OP.pop()
                OP.append(XL[i])
        else:
            OP.append(XL[i])

    return len(OP)

def main():
    N = int(input())
    XL = [list(map(int,input().split())) for _ in range(N)]
    ans = cal(XL)
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def trush(XL):
    pt,output = 1,len(XL)
    while pt < len(XL)-1:
        if XL[pt-1][2] > XL[pt][1] and XL[pt][2] > XL[pt+1][1]:
            XL = XL[:pt] + XL[pt+1:]
            output -= 1
        else:
            pt += 1

    pt = 0
    while pt < len(XL)-1:
        if XL[pt][2] > XL[pt+1][1]:
            if XL[pt][0]-XL[pt][1] > XL[pt+1][0]-XL[pt+1][1]:
                XL = XL[:pt] + XL[pt+1:]
            else:
                XL = XL[:pt+1] + XL[pt+2:]
            output -= 1
        else:
            pt += 1

    return output

def main():
    N = int(input())
    XL = [list(map(int,input().split())) for _ in range(N)]
    for i in range(N):
        XL[i] = [XL[i][0],XL[i][0]-XL[i][1],XL[i][0]+XL[i][1]]
    XL.sort(key = lambda x:x[0])
    
    ans = trush(XL)
    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
def cal(XL):
    N = len(XL)
    XL.sort(key = lambda x:x[0])
    for i in range(N):
        XL[i] = [XL[i][0],XL[i][0]-XL[i][1],XL[i][0]+XL[i][1]]
    OP = [XL[0]]

    for i in range(1,N):
        if OP[len(OP)-1][2] > XL[i][1]:
            if OP[len(OP)-1][2] < XL[i][2]:
                #右方向により腕が伸びている方がより邪魔
                pass
            else:
                OP.pop()
                OP.append(XL[i])
        else:
            OP.append(XL[i])

    return len(OP)

def main():
    N = int(input())
    XL = [list(map(int,input().split())) for _ in range(N)]
    ans = cal(XL)
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split(" ")))

def Lsearch(B,key,pt):
    for i in range(len(B)-pt):
        if B[i+pt] == key:
            return i
    return -1

num,pt,n_pt,count = 1,0,0,0
while Lsearch(A,num,pt) != -1:
    n_pt = Lsearch(A,num,pt) + 1
    count += n_pt - pt -1
    pt = n_pt
    num += 1
if pt != 0:
    count += len(A) - pt
    print(count)
else:
    print(-1)


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

num,pt,n_pt,count = 1,-1,0,0
while n_pt < len(A):
    if A[n_pt] == num:
        count += n_pt - pt -1
        pt = n_pt
        num += 1
    n_pt += 1
if pt != -1:
    count += len(A) - pt -1
    print(count)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split(" ")))

def Lsearch(B,key):
    for i in range(len(B)):
        if B[i] == key:
            return i
    return -1

num,pt,n_pt,count = 1,0,0,0
while Lsearch(A[pt:],num) != -1:
    n_pt = Lsearch(A[pt:],num) + 1
    count += n_pt - pt -1
    pt = n_pt
    num += 1
if pt != 0:
    count += len(A) - pt
    print(count)
else:
    print(-1)


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

num,pt,n_pt,count = 1,-1,0,0
while n_pt < len(A):
    if A[n_pt] == num:
        count += n_pt - pt -1
        pt = n_pt
        num += 1
    n_pt += 1
if pt != -1:
    count += len(A) - pt -1
    print(count)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split(" ")))

def Lsearch(B,key):
    B.append(key)
    for i in range(len(B)):
        if B[i] == key:
            if i != len(B)-1:
                B.pop() #pythonは参照渡しが基本なので元のリストに戻しておく
                return i
            else:
                B.pop()
                return -1

num,count,tmp,pt,flag = 1,0,0,0,0
if Lsearch(A,1) == -1:
    flag = 1
else:
    while pt < len(A):
        if Lsearch(A[pt:],num) != -1:
            tmp = Lsearch(A[pt:],num) + 1
            count += tmp - 1
            pt = pt + tmp
            num += 1
        else:
            count += len(A[pt:])
            break

if flag == 0:
    print(count)
else:
    print(-1)


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

num,pt,n_pt,count = 1,-1,0,0
while n_pt < len(A):
    if A[n_pt] == num:
        count += n_pt - pt -1
        pt = n_pt
        num += 1
    n_pt += 1
if pt != -1:
    count += len(A) - pt -1
    print(count)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
def pad(S,N):
    return (N-len(S)) * "0" + S

def xor_sum(A,M):
    N = len(A)
    bit_count = [0 for _ in range(60)]
    #bit_count[i]:iビット目が1であるa in Aの個数

    for i in range(N):
        A[i] = pad(bin(A[i])[2:],60)
        for j in range(60):
            if A[i][60-j-1] == "1":
                bit_count[j] += 1

    output = 0
    for j in range(60):
        tmp1 = (N-bit_count[j])*bit_count[j] % M
        tmp2 = pow(2,j,M)
        tmp = (tmp1 * tmp2) % M
        output += tmp
        output %= M

    return output

def main():
    N = int(input())
    A = list(map(int,input().split()))
    M = 10**9+7

    print(xor_sum(A,M))

if __name__ == "__main__":
    main()


Fixed submission:
def pad(S,N):
    return (N-len(S)) * "0" + S

def xor_sum(A,M):
    N = len(A)
    bit_count = [0 for _ in range(60)]
    #bit_count[i]:iビット目が1であるa in Aの個数

    for i in range(N):
        A[i] = pad(bin(A[i])[2:],60)
        for j in range(60):
            if A[i][60-j-1] == "1":
                bit_count[j] += 1

    output = 0
    for j in range(60):
        tmp1 = (N-bit_count[j])*bit_count[j] % M
        tmp2 = pow(2,j,M)
        tmp = (tmp1 * tmp2) % M
        output += tmp
        output %= M

    return output

def main():
    N = int(input())
    A = list(map(int,input().split()))
    M = 10**9+7

    print(xor_sum(A,M))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import Counter

def cal(D,M):
    C = Counter(D)
    MC = C.most_common()
    MC = sort(key = lambda x:x[0])
    n = len(MC)
    #頂点1が根じゃないときも連結の仕方を変えずに見方を変えることで
    #頂点1を根にできる.
    #従ってD[i-1]は頂点iの深さと見なせる
    for i in range(n):
        if MC[i][0] != i:
            #深さiと深さi-1又は深さiと深さi+1を繋げない
            return 0
    if MC[0][1] != 1 or D[0] != 0:
        #1以外の根がある又は1が根になってない
        return 0

    output = 1
    for i in range(n-1):
        output *= pow(MC[i][1],MC[i+1][1],M)
        output %= M
    return output

def main():
    N = int(input())
    D = list(map(int,input().split()))
    M = 998244353

    ans = cal(D,M)
    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
from collections import Counter

def cal(D,M):
    C = Counter(D)
    MC = C.most_common()
    MC.sort(key = lambda x:x[0])
    n = len(MC)
    #頂点1が根じゃないときも連結の仕方を変えずに見方を変えることで
    #頂点1を根にできる.
    #従ってD[i-1]は頂点iの深さと見なせる
    for i in range(n):
        if MC[i][0] != i:
            #深さiと深さi-1又は深さiと深さi+1を繋げない
            return 0
    if MC[0][1] != 1 or D[0] != 0:
        #1以外の根がある又は1が根になってない
        return 0

    output = 1
    for i in range(n-1):
        output *= pow(MC[i][1],MC[i+1][1],M)
        output %= M
    return output

def main():
    N = int(input())
    D = list(map(int,input().split()))
    M = 998244353

    ans = cal(D,M)
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(x) for x in input().split()]

def retInd(A, k):
    for i in range(len(A)):
        if A[i]-1== k:
            return i

for i in range(N):
    print(retInd(A,i)+1, end=" ")


Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

AB = [(A[i],i) for i in range(N)]

AB.sort(key = lambda x:x[0])

B = [AB[i][1]+1 for i in range(N)]

ans = " ".join(map(str,B))
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

def GCD(a,b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return GCD(b, a % b)

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

g = GCD(A,B)
P = primes(g)
Q = []
for p in P:
    if g % p == 0:
        Q.append(p)

n = len(Q)
print(n + 1)


Fixed submission:
from math import sqrt

A,B = map(int,input().split())

def gcd(a,b):
    if a < b:
        a,b = b,a
    while a % b != 0:
        r = a % b
        a,b = b,r
    return b

def count_prime(n):
    #nを割り切る素数の個数
    if n == 1:
        return 0
    n_is_prime = True
    P = []
    for i in range(2,int(sqrt(n))+1):
        if n % i == 0:
            n_is_prime = False
            P.append(i)
            while n % i == 0:
                n //= i
    if n_is_prime:
        return 1
    elif n == 1:
        return len(P)
    else:
        #この時点で割り切れずに残ったnは未発見の素数
        return len(P)+1

g = gcd(A,B)
c_p = count_prime(g)
print(c_p+1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
if 14*N <= M:
    print(0)
else:
    sum = sum(A)

    for i in range(M):
        sum -= A[A.index(max(A))] - (A[A.index(max(A))] // 2)
        A[A.index(max(A))] //= 2

    print(sum)


Fixed submission:
import heapq
from math import ceil

N, M = map(int, input().split())
A = [(-1)*int(x) for x in input().split()]

if len(A) == 1:
    for i in range(M):
        A[0] = ceil(A[0]/2)
    A[0] = -A[0]
    print(A[0])
else:
    count = 0
    heapq.heapify(A)
    a = heapq.heappop(A)
    b = heapq.heappop(A)
    while count < M:
        while a <= b:
            a = ceil(a/2)
            count += 1
            if count == M:
                break
        if count == M:
            break
        heapq.heappush(A,a)
        a = b
        b = heapq.heappop(A)
    heapq.heappush(A,a)
    heapq.heappush(A,b)
    ans = (-1)*sum(A)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
sum = sum(A)

for i in range(M):
    sum -= A[A.index(max(A))] - (A[A.index(max(A))] // 2)
    A[A.index(max(A))] //= 2

print(sum)


Fixed submission:
import heapq
from math import ceil

N, M = map(int, input().split())
A = [(-1)*int(x) for x in input().split()]

if len(A) == 1:
    for i in range(M):
        A[0] = ceil(A[0]/2)
    A[0] = -A[0]
    print(A[0])
else:
    count = 0
    heapq.heapify(A)
    a = heapq.heappop(A)
    b = heapq.heappop(A)
    while count < M:
        while a <= b:
            a = ceil(a/2)
            count += 1
            if count == M:
                break
        if count == M:
            break
        heapq.heappush(A,a)
        a = b
        b = heapq.heappop(A)
    heapq.heappush(A,a)
    heapq.heappush(A,b)
    ans = (-1)*sum(A)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]

for i in range(M):
    A[A.index(max(A))] //= 2

print(sum(A))


Fixed submission:
import heapq
from math import ceil

N, M = map(int, input().split())
A = [(-1)*int(x) for x in input().split()]

if len(A) == 1:
    for i in range(M):
        A[0] = ceil(A[0]/2)
    A[0] = -A[0]
    print(A[0])
else:
    count = 0
    heapq.heapify(A)
    a = heapq.heappop(A)
    b = heapq.heappop(A)
    while count < M:
        while a <= b:
            a = ceil(a/2)
            count += 1
            if count == M:
                break
        if count == M:
            break
        heapq.heappush(A,a)
        a = b
        b = heapq.heappop(A)
    heapq.heappush(A,a)
    heapq.heappush(A,b)
    ans = (-1)*sum(A)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=[]
for i in range(N):
	s.append(input())

for i in range(N):
	s[i]=sorted(s[i])

t=[]
flag=0
for i in range(N):
	for j in range(len(t)):
		flag=0
		if s[i]==t[j][0]: #tは二次元リストで定義していたことに気を付けよう
			t[j][1] += 1
			flag=1
			break
	if flag==0:
		t.append([s[i],1])

count=0
for i in range(len(t)):
	if t[i][1]>=2:
		count += int(t[i][1]*(t[i][1]-1)/2)

print(count)


Fixed submission:
N = int(input())
S = [list(input()) for _ in range(N)]

for i in range(N):
	S[i].sort()

for i in range(N):
	S[i] = "".join(S[i])

S.sort()
S.append(None)

pt,count,C = 1,0,[]
while pt <= N:
	if S[pt-1] == S[pt]:
		count += 1
	else:
		if count > 0:
			C.append(count+1)
			count = 0
	pt += 1

ans = 0
for i in range(len(C)):
	ans += C[i]*(C[i]-1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=[]
for i in range(N):
	s.append(input())

for i in range(N):
	s[i]=sorted(s[i])

count=0
for i in range(N):
	for j in range(i+1,N):
		if s[i]==s[j]:
			count += 1
print(count)


Fixed submission:
N = int(input())
S = [list(input()) for _ in range(N)]

for i in range(N):
	S[i].sort()

for i in range(N):
	S[i] = "".join(S[i])

S.sort()
S.append(None)

pt,count,C = 1,0,[]
while pt <= N:
	if S[pt-1] == S[pt]:
		count += 1
	else:
		if count > 0:
			C.append(count+1)
			count = 0
	pt += 1

ans = 0
for i in range(len(C)):
	ans += C[i]*(C[i]-1) // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split(" ")))

if N>1:
	flag=0
	for i in reversed(range(N-1)):
		if H[i-1]-H[i}>1:
			flag=1
		if H[i-1]-H[i]==1:
			H[i-1] -= 1
	if flag==0:
		print("Yes")
	else:
		print("No")
else:
	print("Yes")


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

if N>1:
	flag=0
	for i in reversed(range(1,N)):
		if H[i-1]-H[i]>1:
			flag=1
		if H[i-1]-H[i]==1:
			H[i-1] -= 1
	if flag==0:
		print("Yes")
	else:
		print("No")
else:
	print("Yes")
Buggy python submission (verdict: Runtime Error):
import math

line = list(map(int, input().split(" ")))
N = line[0]
D = line[1]

bord = math.ceil(N/(2*D+1))

print(bord)


Fixed submission:
r=int(input())
S=3*r*r
print(S)
Buggy python submission (verdict: Runtime Error):
S = input()

if (S[0]==S[1] and S[2]==S[3}) or (S[0]==S[2] and S[1]==S[3]) or (S[0]==S[3] and S[1]==S[2]):
	print('Yes')
else:
	print('No')


Fixed submission:
S = input()

if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]) or (S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]) or (S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]):
	print('Yes')
else:
	print('No')

Buggy python submission (verdict: Runtime Error):
S = input()

if S[1]==S[0]:
	count1=count1+1
	if S[2]==S[0] or S[3]==S[0]:
		print('No')
	elif S[3]==S[2]:
		print('Yes')
elif (S[2]==S[0] and S[3]==S[1]) or (S[2]==S[1] and S[3]==S[0]):
	print('Yes')
else:
	print('No')


Fixed submission:
S = input()

if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]) or (S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]) or (S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]):
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Time Limit Exceeded):
def DP(N,M):
    dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
    dp_sum = [[0 for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0] = 1
    for j in range(N+1):
        dp_sum[0][j] = 1
    #dp[i][j]:i個の項で和がj
    #dp_sum[i][j]:dp[i][0]+...+dp[i][j]
    for i in range(1,N+1):
        for j in range(1,N+1):
            dp[i][j] = (dp_sum[i-1][j-1] - dp_sum[i-1][i-1] + dp[i-1][i-1]) % M
            dp_sum[i][j] = (dp_sum[i][j-1] + dp[i][j]) % M

    return dp

def main():
    N,K = map(int,input().split())
    M = 10**9+7

    dp = DP(N,M)

    comb = 1
    for i in range(1,K+1):
        comb *= (N - K + 2 - i)
        comb *= pow(i,M-2,M)
        comb %= M
        if i > N - K + 1:
            comb = 0
        print((comb * dp[i][K]) % M)

if __name__ == "__main__":
    main()


Fixed submission:
def DP(N,M):
    dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
    dp_sum = [[0 for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0] = 1
    for j in range(N+1):
        dp_sum[0][j] = 1
    #dp[i][j]:i個の項で和がj
    #dp_sum[i][j]:dp[i][0]+...+dp[i][j]
    for i in range(1,N+1):
        for j in range(1,N+1):
            dp[i][j] = (dp_sum[i-1][j-1] - dp_sum[i-1][i-1] + dp[i-1][i-1]) % M
            dp_sum[i][j] = (dp_sum[i][j-1] + dp[i][j]) % M

    return dp

def main():
    N,K = map(int,input().split())
    M = 10**9+7

    dp = DP(N,M)

    comb = 1
    for i in range(1,K+1):
        comb *= (N - K + 2 - i)
        comb *= pow(i,M-2,M)
        comb %= M
        if i > N - K + 1:
            comb = 0
        print((comb * dp[i][K]) % M)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def burst(S,k):
    S = "_" + S + "_"
    OP = []
    pt_l,pt_r = None,None
    for i in range(len(S)):
        if S[i] == k:
            if pt_l == None:
                pt_l = i-1
        elif pt_l != None:
            pt_r = i-2
            OP.append((pt_l,pt_r))
            pt_l,pt_r = None,None
    return OP

def merge(burst,k):
    if len(burst) <= k + 1:
        return burst[0][1] - burst[0][0] + 1
    else:
        output = 0
        for i in range(len(burst)-k):
            tmp = burst[k+i][1] - burst[i][0] + 1
            output = max(output,tmp)
        return output

N,K = map(int,input().split())
S = input()

burst1 = burst(S,"1")

if burst1[0][0] != 0:
    burst1 = [(0,0)] + burst1
if burst1[len(burst1)-1][1] != N-1:
    burst1 = burst1 + [(N-1,N-1)]

ans = merge(burst1,K)
print(ans)


Fixed submission:
def burst(S):
    S += "_" #dummyを追加
    st,sp,ep = S[0],0,0
    S0,S1 = [],[]
    for i in range(1,len(S)):
        if st == S[i]:
            ep += 1
        else:
            if st == "0":
                S0.append((sp,ep))
            else:
                S1.append((sp,ep))
            st,sp,ep = S[i],i,i

    return [S0,S1]

def connect(S0,S1,K,len_S):
    if len(S0) == 0 or len(S1) == 0:
        return len_S
    else:
        if S1[0][0] != 0:
            S1 = [(0,0)] + S1
        if S1[len(S1)-1][1] != len_S-1:
            S1.append((len_S-1,len_S-1))
        if len(S1)-1 <= K:
            return len_S
        else:
            output = 0
            for i in range(len(S1)-K):
                output = max(output,S1[i+K][1]-S1[i][0]+1)
            return output

def main():
    N,K = map(int,input().split())
    S = input()

    T = burst(S)
    S0,S1 = T[0],T[1]
    print(connect(S0,S1,K,N))

if __name__ == "__main__":
    main()