Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02689 (python)

Fixed submission:
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    cnt = 0
    for i in range(n):
        hh = h[i]
        for j in g[i]:
            if h[j] >= hh:
                break
        else:
            cnt += 1
    print(cnt)


main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    wxyz = [list(map(int, input().split())) for _ in [0]*m]

    class unionfind():
        # size:要素数,tree：unionfind木
        def __init__(self, size):  # self,要素数
            self.size = size
            self.tree_root = list(range(self.size))
            self.tree_depth = [1]*self.size

        # rootを探す
        def root(self, index):
            temp_list = []
            temp = self.tree_root[index]
            while index != temp:
                temp_list.append(index)
                index = temp
                temp = self.tree_root[index]
            for i in temp_list:
                self.tree_root[i] = index
            return index

        # 結合
        def unite(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            if r1 != r2:
                d1, d2 = self.tree_depth[r1], self.tree_depth[r2]
                if d1 <= d2:
                    self.tree_root[r1] = r2
                    self.tree_depth[r2] = max(d1+1, d2)
                else:
                    self.tree_root[r2] = r1
                    self.tree_depth[r1] = max(d2+1, d1)

        # 同じか判定
        def same(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            return r1 == r2

        # 連結成分の個数
        def component(self):
            return len({self.root(i) for i in range(self.size)})

    u = unionfind(2*n)

    for w, x, y, z in wxyz:
        x -= 1
        y -= 1
        if w == 1:
            if z % 2 == 0:
                u.unite(x, y)
                u.unite(x+n, y+n)
            else:
                u.unite(x, y+n)
                u.unite(x+n, y)
        else:
            print(["NO", "YES"][u.same(x, y) or u.same(x+n, y+n)])


main()
Problem p02736 (python)

Fixed submission:
def main():
    n = int(input())
    a = list(map(lambda x: int(x)-1, list(input())))
    b = [i % 2 for i in a]

    def all_a(x):
        ans = 0
        for j, i in enumerate(x):
            ans ^= (n-1 | j == n-1)*i
        return ans

    all_b = all_a(b)
    if all_b == 1:
        print(1)
        return
    if 1 in a:
        print(0)
        return
    b = [i//2 for i in a]
    print(all_a(b)*2)


main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = input()
    if n > 3000:
        return 1/0

    a = list(map(lambda x: int(x)-1, list(a)))
    b = [i % 2 for i in a]

    def lucas(a, b):
        a = bin(a)[2:]
        b = bin(b)[2:]
        a, b = "0"*len(b)+a, "0"*len(a)+b
        for i, j in zip(a, b):
            if i == "0" and j == "1":
                return 0
        return 1

    def all_a(x):
        ans = 0
        for j, i in enumerate(x):
            ans ^= lucas(n-1, j)*i
        return ans

    def calc(b):
        all_b = all_a(b)
        if all_b == 1:
            return 1
        if 1 in a:
            return 0
        b = [i//2 for i in a]
        return all_a(b)*2
    q = calc(b)
    print(q)


main()
Problem p02815 (python)

Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    mod=10**9+7
    if n==1:
        print(2*a[0]%mod)
        return
    a.sort(key=lambda x:-x)
    mod=10**9+7
    ans=0
    for i in range(n):
        ans=(ans+pow(2,n-2,mod)*a[i]*(i+2))%mod
    ans=ans*pow(2,n,mod)%mod
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    mod=10**9+7
    if n==1:
        print(2*a[0]%mod)
        return
    a.sort(key=lambda x:-x)
    mod=10**9+7
    ans=sum([a[i]*(i+2))%mod for i in range(n)])
    ans=ans*pow(2,n,mod)*pow(2,n-2,mod)%mod
    print(ans)

main()
Problem p02864 (python)

Fixed submission:
def main():
    n, K = map(int, input().split())
    H = list(map(int, input().split()))
    s = sorted(set(H+[0]))
    d = {i: j for j, i in enumerate(s)}
    l = len(s)
    m = max(s)
    a = [m-i for i in s]
    dp = [[10**13]*l for _ in range(K+1)]
    dp[0][0] = 0
    for h in H:
        dh = d[h]
        dp2 = [[0]*l for _ in range(K+1)]
        dp2[0] = [10**13]*l
        t = [[0]*l for _ in range(K)]
        for i in range(K):
            for j in range(l):
                t[i][j] = dp[i][j]+a[j]
        min_s = [[10**13]*l for i in range(K+1)]

        for i in range(K):
            for j in range(l-2, -1, -1):
                min_s[i][j] = min(dp[i][j+1], min_s[i][j])
            for j in range(1, l):
                t[i][j] = min(t[i][j-1], t[i][j])
            for j in range(l):
                t[i][j] = t[i][j]-a[j]

        for i in range(K):
            for j in range(l):
                dp2[i+1][j] = min(min_s[i][j], t[i][j])

        for i in range(K+1):
            temp = 10**13
            for j in range(l):
                temp = min(temp, dp[i][j]+max(h-s[j], 0))
            dp2[i][dh] = min(dp2[i][dh], temp)
        dp = dp2
    print(min([min(i) for i in dp]))


main()

Buggy submission (verdict: Runtime Error):
def main():
    import numpy as np
    n, K = map(int, input().split())
    H = list(map(int, input().split()))
    s = np.array(sorted(set(H+[0])))
    d = {i: j for j, i in enumerate(s)}
    l = len(s)
    a = max(s)-s
    dp = np.full((K+1, l), 10**13, dtype=np.int64)
    dp[0, 0] = 0
    for h in H:
        dh = d[h]
        dp2 = np.full((K+1, l), 10**13, dtype=np.int64)
        t = np.zeros((K, l), dtype=np.int64)
        s_plus_a = a+dp
        min_s = np.array([[j for j in i] for i in dp[:-1]], dtype=np.int64)
        for j in range(l-2, -1, -1):
            min_s[:, j] = np.minimum(min_s[:, j+1], min_s[:, j])
        for j in range(1, l):
            s_plus_a[:, j] = np.minimum(s_plus_a[:, j-1], s_plus_a[:, j])
        t = s_plus_a[:-1] - a
        dp2[1:, :] = np.minimum(min_s, t)
        for j in range(l):
            dp2[:, dh] = np.minimum(dp2[:, dh], dp[:, j]+max(h-s[j], 0))
        dp = dp2
    print(np.min(dp))


main()
Problem p02891 (python)

Fixed submission:
s=input()
k=int(input())


l=len(s)


if len(s)==1:
    print(k//2)
else:
    i=0
    cnt=0
    flag1=0
    while(i<l-1):
        if s[i]==s[i+1]:
            cnt+=1
            if i+1==l-1:
                flag1=1
            i+=2
        else:
            i+=1
    
    #cnt2=cnt
    
    i=1
    cnt2=1
    flag2=0
    while(i<l-1):
        if s[i]==s[i+1]:
            cnt2+=1
            if i+1==l-1:
                flag2=1
            i+=2
        else:
            i+=1
    
    #print(cnt,cnt2,flag1,flag2)
    if s[0]==s[-1]:
        if flag1==1:
            ans=cnt*k
        elif flag2==1:
            ans=(k//2+k%2)*cnt+(k//2)*cnt2
        else:
            ans=cnt+cnt2*(k-1)
    else:
        ans=cnt*k
            
    print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())

cnt=0
l=len(s)
i=0
flag=1
while(i<l-1):
    if s[i]==s[i+1]:
        cnt+=1
        i+=2
    else:
        i+=1

cnt2=cnt

if s[0]==s[1]:
    i=1
    cnt2=1
    while(i<l-1):
        if s[i]==s[i+1]:
            if i+1==l-1:
                flag=0
            cnt2+=1
            i+=2
        else:
            i+=1


if s[0]==s[-1]:
    ans=cnt*(k//2+k%2)+cnt2*(k//2)
else:
    ans=cnt*k
        
print(ans)
Problem p02964 (python)

Fixed submission:
def main():
    import bisect
    n,k=map(int,input().split())
    x=list(map(int,input().split()))
    d=dict()
    for j,i in enumerate(x):
        if i in d.keys():
            d[i].append(j)
        else:
            d[i]=[j]
    first_word=[""]
    
    def operation(temp_operated,temp_operator):
        l=[i for i in temp_operated]
        s=set(temp_operated)
        for i in temp_operator:
            if i in s:
                while True:
                    if l[-1]!=i:
                        l.pop()
                    else:
                        l.pop()
                        s=set(l)
                        break
            else:
                l.append(i)
                s.add(i)
        return l
    
    if operation("",x)!=[]:
        first_word.append(operation("",x)[0])
    flag=0

    while True:
        w=first_word[-1]
        if w=="":
            break
        t=d[w][0]
        if t==n-1:
            break
        while True:
            ww=x[t+1]
            temp=bisect.bisect_right(d[ww],t+1)
            if temp>=len(d[ww]):
                first_word.append(ww)
                break
            else:
                t=d[ww][temp]
                if t==n-1:
                    flag=1
                    break
        if flag==1:
            break
    
    l=len(first_word)
    k=k%l
    if len(first_word)==1:
        print("")
    elif k-1==0:
        print(*operation("",x))
    else:
        print(*operation("",x[d[first_word[k-1]][0]+1:]))

main()

Buggy submission (verdict: Runtime Error):
def main():
    import bisect
    n,k=map(int,input().split())
    x=list(map(int,input().split()))
    d=dict()
    for j,i in enumerate(x):
        if i in d.keys():
            d[i].append(j)
        else:
            d[i]=[j]
    first_word=[""]
    
    def operation(temp_operated,temp_operator):
        l=[i for i in temp_operated]
        s=set(temp_operated)
        for i in temp_operator:
            if i in s:
                while True:
                    if l[-1]!=i:
                        l.pop()
                    else:
                        l.pop()
                        s=set(l)
                        break
            else:
                l.append(i)
                s.add(i)
        return l
    
    if operation("",x)!=[]:
        first_word.append(operation("",x)[0])
    flag=0

    while True:
        w=first_word[-1]
        if w=="":
            break
        t=d[w][0]
        if t==n-1:
            break
        while True:
            ww=x[t+1]
            temp=bisect.bisect_right(d[ww],t+1)
            if temp>=len(d[ww]):
                first_word.append(ww)
                break
            else:
                t=d[ww][temp]
                if t==n-1:
                    flag=1
                    break
        if flag==1:
            break
    
    l=len(first_word)
    k=k%l
    if len(first_word)==1:
        print("")
    else:
        print(*operation("",x[d[first_word[k-1]][0]+1:]))

main()
Problem p03011 (python)

Fixed submission:
P,Q,R=map(int,input().split())
print(min(P+Q,Q+R,R+P))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
S=[[i=="." for i in input()+"#"] for _ in range(H)]+[[False]*(W+1)]

map_=[[0]*W for _ in range(H)]
for i in range(H):
    cnt=0
    q=[]
    for j in range(W+1):
        if S[i][j]==False and cnt!=0:
            for Q in q:
                map_[Q[0]][Q[1]]=cnt
            cnt=0
            q=[]
        elif S[i][j]:
            cnt+=1
            q.append([i,j])
for j in range(W):
    cnt=0
    q=[]
    for i in range(H+1):
        if S[i][j]==False and cnt!=0:
            for Q in q:
                map_[Q[0]][Q[1]]+=cnt
            cnt=0
            q=[]
        elif S[i][j]:
            cnt+=1
            q.append([i,j])
print(max([max(i) for i in map_])-1)
Problem p03073 (python)

Fixed submission:
S = [int(i) for i in list(input())]
S2 = len([1 for i in range(len(S)) if S[i] == i%2])
ans = min(S2,len(S)-S2)
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)
A=len([_ for i in range(N) if str(i%2)==S[i]])
print(min(A,N-A))
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce
input()
N=list(map(int,input().split()))
print(reduce(fractions.gcd,N))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
input()
N=list(map(int,input().split()))
print(reduce(math.gcd,N))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
input()
N=list(map(int,input().split()))
reduce(math.gcd,N)
Problem p03291 (python)

Fixed submission:
S=input()
lens=len(S)
mod=10**9+7
cnt=[0,0,0,1]
for s in S:
    if s=="A":
        cnt[0]=(cnt[0]+cnt[3])%mod
    elif s=="B":
        cnt[1]=(cnt[0]+cnt[1])%mod
    elif s=="C":
        cnt[2]=(cnt[1]+cnt[2])%mod
    else:
        cnt[2]=(cnt[1]+3*cnt[2])%mod
        cnt[1]=(cnt[0]+3*cnt[1])%mod
        cnt[0]=(3*cnt[0]+cnt[3])%mod
        cnt[3]=cnt[3]*3%mod
print(cnt[2]%mod)

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)
mod=10**9+7

import sys
sys.setrecursionlimit(200000)

from functools import lru_cache

@lru_cache(maxsize=None)
def dp(cur,i):
	if cur==N:
		if i==3:
			return 1
		else:
			return 0
	else:
		if S[cur]=='ABCD'[i]:
			return (dp(cur+1,i+1)+dp(cur+1,i))%mod
		elif S[cur]=='?' and i!=3:
			return (dp(cur+1,i+1)+3*dp(cur+1,i))%mod
		elif S[cur]=='?':
			return 3*dp(cur+1,i)%mod
		else:
			return dp(cur+1,i)%mod

print(dp(0,0)%mod)

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)
mod=10**9+7

#import sys
#sys.setrecursionlimit(200000)

from functools import lru_cache

@lru_cache(maxsize=None)
def dp(cur,i):
	if cur==N:
		if i==3:
			return 1
		else:
			return 0
	else:
		if S[cur]=='ABCD'[i]:
			return (dp(cur+1,i+1)+dp(cur+1,i))%mod
		elif S[cur]=='?' and i!=3:
			return (dp(cur+1,i+1)+3*dp(cur+1,i))%mod
		elif S[cur]=='?':
			return 3*dp(cur+1,i)%mod
		else:
			return dp(cur+1,i)%mod

print(dp(0,0)%mod)

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)

import sys
sys.setrecursionlimit(200000)

from functools import lru_cache

@lru_cache(maxsize=None)
def dp(cur,i):
	if cur==N:
		if i==3:
			return 1
		else:
			return 0
	else:
		if S[cur]=='ABCD'[i]:
			return dp(cur+1,i+1)+dp(cur+1,i)
		elif S[cur]=='?':
			return dp(cur+1,i+1)+3*dp(cur+1,i)
		else:
			return dp(cur+1,i)

print(dp(0,0))

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)

from functools import lru_cache

@lru_cache(maxsize=None)
def dp(cur,i):
	if cur==N:
		if i==3:
			return 1
		else:
			return 0
	else:
		if S[cur]=='ABCD'[i]:
			return dp(cur+1,i+1)+dp(cur+1,i)
		elif S[cur]=='?':
			return dp(cur+1,i+1)+3*dp(cur+1,i)
		else:
			return dp(cur+1,i)

print(dp(0,0))
Problem p03430 (python)

Fixed submission:
def main():
    s = input()
    n = len(s)
    k = int(input())
    # dp[使った回数][左端からの距離][左端]
    dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]

    for i in range(n-1):
        if s[i] == s[i+1]:
            dp[0][1][i] = 2
    if k > 0:
        for cnt in range(1, k+1):
            for i in range(n-1):
                dp[cnt][1][i] = 2

    for cnt in range(k):
        for d in range(2, n):
            for left in range(n-d):
                right = left+d
                plus = (s[left] == s[right])*2
                dp[cnt][d][left] = max(
                    dp[cnt][d][left], dp[cnt][d-1][left],
                    dp[cnt][d-1][left+1], dp[cnt][d-2][left+1]+plus)
                dp[cnt+1][d][left] = max(
                    dp[cnt+1][d][left], dp[cnt][d][left], dp[cnt][d-2][left+1]+2)
    for d in range(2, n):
        for left in range(n-d):
            right = left+d
            plus = (s[left] == s[right])*2
            dp[k][d][left] = max(
                dp[k][d][left], dp[k][d-1][left], dp[k][d-1][left+1], dp[k][d-2][left+1]+plus)
    print(dp[-1][-1][0])


main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    n = len(s)
    k = int(input())
    # dp[使った回数][左端からの距離][左端]
    dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]

    dp2 = dp[0][1]
    for i in range(n-1):
        if s[i] == s[i+1]:
            dp2[i] = 2
    if k > 0:
        for cnt in range(1, k+1):
            dp2 = dp[cnt][1]
            for i in range(n-1):
                dp2[i] = 2

    for cnt in range(k):
        dp2 = dp[cnt]
        for d in range(2, n):
            dp3 = dp2[d]
            for left in range(n-d):
                right = left+d
                plus = (s[left] == s[right])*2
                dp3[left] = max(
                    dp3[left], dp2[d-1][left],
                    dp2[d-1][left+1], dp2[d-2][left+1]+plus)
                dp[cnt+1][d][left] = max(
                    dp[cnt+1][d][left], dp3[left], dp2[d-2][left+1]+2)
    dp2 = dp[k]
    for d in range(2, n):
        dp3 = dp[d]
        for left in range(n-d):
            right = left+d
            plus = (s[left] == s[right])*2
            dp3[left] = max(
                dp3[left], dp2[d-1][left], dp2[d-1][left+1], dp2[d-2][left+1]+plus)
    print(dp[-1][-1][0])


main()
Problem p03631 (python)

Fixed submission:
a=input();print(["No","Yes"][a[0]==a[2]])

Buggy submission (verdict: Runtime Error):
print(["No","Yes"][input()[0]==input()[2]])
Problem p03724 (python)

Fixed submission:
def main():
    n, m = map(int, input().split())
    ab = [sorted(list(map(int, input().split()))) for _ in [0] * m]
    l = [0] * (n - 1)
    for i in range(m):
        a, b = ab[i]
        if a != 1:
            l[a-2]+=1
        l[b - 2] += 1
    l=[i%2 for i in l]
    if sum(l) > 0:
        print("NO")
    else:
        print("YES")
main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    ab = [sorted(list(map(int, input().split()))) for _ in [0] * n]
    l = [0] * (n - 1)
    for i in range(m):
        a, b = ab[i]
        if a != 1:
            l[a-2]+=1
        l[b - 2] += 1
    l=[i%2 for i in l]
    if sum(l) > 0:
        print("NO")
    else:
        print("YES")
main()
Problem p03776 (python)

Fixed submission:
from statistics import mean
from collections import Counter
n,a,b=map(int,input().split())
v=sorted(list(map(int,input().split())),reverse=True)
avg=mean(v[:a])
print(avg)

p=Counter(v[:a])[v[a-1]]
q=Counter(v)[v[a-1]]

def n_func(n):
    ans=1
    for i in range(1,n+1):ans=(ans*i)
    return ans

def nCr(n,r):
    return (n_func(n)//n_func(r))//n_func(n-r)

if v[0]==v[a-1]:
    print(sum([nCr(q,a+i) for i in range(0,min(b,q)-a+1)]))
else:
    print(nCr(q,p))

Buggy submission (verdict: Runtime Error):
from statistics import mean
from collections import Counter
n,a,b=map(int,input().split())
v=sorted(list(map(int,input().split())),reverse=True)
avg=mean(v[:a])
print(avg)

p=Counter(v[:a])[v[a]]
q=Counter(v)[v[a]]

def n_func(n):
    ans=1
    for i in range(1,n+1):ans=(ans*i)
    return ans

def nCr(n,r):
    return (n_func(n)//n_func(r))//n_func(n-r)

if v[0]==v[a]:
    print(sum([nCr(b,a+i) for i in range(0,b-a+1)]))
else:
    print(nCr(q,p))
Problem p03785 (python)

Fixed submission:
N,C,K=map(int,input().split())
T=sorted([int(input()) for _ in range(N)])
First=T[0]
bus_rider=1
bus_cnt=1
for i in range(1,N):
    if bus_rider<C and T[i]-First<=K:
        bus_rider+=1
    else:
        First=T[i]
        bus_rider=1
        bus_cnt+=1
print(bus_cnt)

Buggy submission (verdict: Runtime Error):
N,C,K=map(int,input().split())
T=[int(input()) for _ in range(N)]
flag=0
bus_cnt=0
First=T[i]
bus_rider=1
bus_cnt=1
for i in range(N):
    if bus_rider<C and T[i]-First<=K:
        bus_rider+=1
    else:
        First=T[i]
        bus_rider=1
        bus_cnt+=1
print(bus_cnt)
Problem p03805 (python)

Fixed submission:
N,M=map(int,input().split())
inp=[list(map(int,input().split())) for _ in range(M)]
g=[[] for _ in range(N)]
[g[a-1].append(b-1) for a,b in inp]
[g[b-1].append(a-1) for a,b in inp]
 
from itertools import permutations
seq=[i for i in range(N)]
test=list(permutations(seq))
cnt=0
for t in test:
    if t[0]==0:
        for i in range(N-1):
            if t[i+1] not in g[t[i]]:
                break
        else:
            cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
inp=[list(map(int,input().split())) for _ in range(N)]
g=[[] for _ in range(N)]
[g[a-1].append(b-1) for a,b in inp]
[g[b-1].append(a-1) for a,b in inp]
 
from itertools import permutations
seq=[i for i in range(N)]
test=list(permutations(seq))
cnt=0
for t in test:
    if t[0]==0:
        for i in range(len(t)-1):
            if t[i+1] not in g[t[i]]:
                break
        else:
            cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
inp=[list(map(int,input().split())) for _ in range(N)]
g=[[] for _ in range(N)]
[g[a-1].append(b-1) for a,b in inp]
[g[b-1].append(a-1) for a,b in inp]

from itertools import permutations
seq=[i for i in range(N)]
test=list(permutations(seq))
cnt=0
for t in test:
    if t[0]==0:
        for i in range(len(t)-1):
            if t[i+1] not in g[t[i]]:
                break
        cnt+=1
print(cnt)
Problem p03822 (python)

Fixed submission:
def main():
    import sys
    sys.setrecursionlimit(100000)
    n=int(input())
    a=[int(input()) for _ in [0]*(n-1)]
    a=[[i+2,a[i]] for i in range(n-1)]
    l=[[] for _ in [0]*n]
    for i,j in a:
        l[j-1].append(i-1)
    def dps(i):
        if l[i]==[]:
            return 0
        temp=[]
        for j in l[i]:
            temp.append(dps(j))
        temp.sort(reverse=True)
        temp=[temp[i]+i+1 for i in range(len(temp))]
        return max(temp)
    print(dps(0))
main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=[int(input()) for _ in [0]*(n-1)]
    a=[[i+2,a[i]] for i in range(n-1)]
    l=[[] for _ in [0]*n]
    for i,j in a:
        l[j-1].append(i-1)
    def dps(i):
        if l[i]==[]:
            return 1
        _max=0
        _min=10**6
        for j in l[i]:
            temp=dps(j)
            _max=max(temp,_max)
            _min=min(temp,_min)
        return max(_max,_min+1)
    print(dps(0))
main()
Problem p03986 (python)

Fixed submission:
s=input()
ss=0
tt=0
for i in range(len(s)):
    if s[i]=="S":
        ss+=1
    if s[i]=="T" and tt<ss:
        tt+=1
print(len(s)-2*tt)

Buggy submission (verdict: Runtime Error):
s=input()
l=s.find("S")
r=s.rfind("T")
if l==-1 or r==-1:
    print(len(s))
else:
    rest=l+len(s)-r-1
    s=s[l:r+1]
    from collections import Counter
    s=list(Counter(s).values())
    print(rest+abs(s[0]-s[1]))
Problem p03137 (python)

Fixed submission:
n,m = map(int,input().split(' '))
if n >= m:
    print(0)
else:
    X = list(map(int,input().split(' ')))
    X.sort()
    dis = []
    for i in range(m - 1):
        dis.append(X[i + 1] - X[i])
    dis.sort(reverse = True)
    div = 0
    total = X[m - 1] - X[0]

    for i in range(n - 1):
        div += dis[i]
    print(total - div)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split(' '))
X = list(map(int,input().split(' ')))
X.sort(reverse = True)
dis = []
div = 0
for i in range(m - 1):
    dis.append(X[i + 1] = X[i])
dis.sort(Reverse = True)
for i in range(n - 1):
    div += dis[i]
print(sum(dis) - div)
Problem p02549 (python)

Fixed submission:
n, k = map(int, input().split())
s = []
for i in range(k):
    l, r = map(int, input().split())
    s.append([l, r])

mod = 998244353
dp = [0] * (n+1)
cumsum = [0] * (n+1)

dp[1] = 1
s = sorted(s)
counter = 0
for i in range(1, n+1):
    counter += cumsum[i]
    dp[i] += counter
    dp[i] %= mod
    for l, r in s:
        if i+l <= n:
            cumsum[i+l] += dp[i]
        if i+r+1 <= n:
            cumsum[i+r+1] -= dp[i]
print(dp[n] % mod)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = []
for i in range(k):
    l, r = map(int, input().split())
    s += list(range(l, r+1)

mod = 998244353
dp = [0] * (n+1)
dp[1] = 1
s = sorted(s)
for i in range(1, n):
    dp[i] %= mod
    for add in s:
        if i+add <= n:
            dp[i+add] += dp[i]
print(dp[n] % mod)