Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#D問題
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)
for j in range(M):
    A[0] = A[0]//2
    A.sort(reverse=True)
    
print(sum(A))

Fixed submission:
#D問題
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))

B = []
for a in A:
    heapq.heappush(B,-a)

for j in range(M):
    b = -heapq.heappop(B)
    b = b//2
    heapq.heappush(B,-b)
    
print(-sum(B))
Buggy python submission (verdict: Time Limit Exceeded):
#C問題
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
div = 0
flag = 1
while flag == 1:
    flag = 0
    for i in range(N):
        if B[i]-B[i-1]-B[(i+1)%N] >= A[i]:
            div = (B[i]-A[i])//(B[i-1]+B[(i+1)%N])
            B[i] -= (B[i-1]+B[(i+1)%N])*div
            ans+=div
            flag = 1
            
print(ans if A == B else -1)

Fixed submission:
#C問題
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
div = 0
flag = 1
while flag == 1:
    flag = 0
    for i in range(N):
        if B[i]-B[i-1]-B[(i+1)%N] >= A[i]:
            div = (B[i]-A[i])//(B[i-1]+B[(i+1)%N])
            B[i] -= (B[i-1]+B[(i+1)%N])*div
            ans+=div
            flag = 1
            
print(ans if A == B else -1)

Buggy python submission (verdict: Time Limit Exceeded):
#C問題
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
div = 0
flag = True
while flag:
    flag = False
    for i in range(N):
        if B[i] > B[i-1]+B[(i+1)%N] and B[i] != A[i]:
            div = (B[i]-A[i])//(B[i-1]+B[(i+1)%N])
            B[i] -= (B[i-1]+B[(i+1)%N])*div
            ans+=div
            flag = True
            
print(ans if A == B else -1)

Fixed submission:
#C問題
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
div = 0
flag = 1
while flag == 1:
    flag = 0
    for i in range(N):
        if B[i]-B[i-1]-B[(i+1)%N] >= A[i]:
            div = (B[i]-A[i])//(B[i-1]+B[(i+1)%N])
            B[i] -= (B[i-1]+B[(i+1)%N])*div
            ans+=div
            flag = 1
            
print(ans if A == B else -1)
Buggy python submission (verdict: Time Limit Exceeded):
#D問題
import heapq
N,M = map(int,input().split())
AB = []
for i in range(N):
    ab = list(map(int,input().split()))
    heapq.heappush(AB,ab)
    
ans = 0
cand = []
for i in range(M):
    for ab in AB:
        if ab[0] <= (i+1):
            heapq.heappush(cand,10**5-ab[1])
            ind = AB.index(ab)
            del AB[ind]
    
    if len(cand) >= 1:
        cd = heapq.heappop(cand)
        ans+=(10**5-cd)
    
print(ans)

Fixed submission:
#D問題
import heapq
N,M = map(int,input().split())
AB = []
for i in range(N):
    ab = list(map(int,input().split()))
    heapq.heappush(AB,ab)
    
ans = 0
cand = []
for i in range(M):
    while AB:
        ab = heapq.heappop(AB)
        if ab[0] <= (i+1):
            heapq.heappush(cand,10**5-ab[1])
        else:
            heapq.heappush(AB,ab)
            break
    
    if len(cand) >= 1:
        cd = heapq.heappop(cand)
        ans+=(10**5-cd)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
#B問題
N,X = map(int,input().split())
L = list(map(int,input().split()))
land = [0]
for i in range(N):
    land.append(land[-1]+L[i])
land.sort()
count = 0
for l in land:
    if land <= X:
        count+=1
        
print(count)

Fixed submission:
#B問題
N,X = map(int,input().split())
L = list(map(int,input().split()))
land = [0]
for i in range(N):
    land.append(land[-1]+L[i])
land.sort()
count = 0
for l in land:
    if l <= X:
        count+=1
        
print(count)
Buggy python submission (verdict: Runtime Error):
#B問題
N = int(input())
XY = [list(map(int,input().split())) for i in range(N)]
edges = []
for i in range(N):
    x1,y1 = XY[i][0],XY[i][1]
    for j in range(N-i-1):
        J = i+j+1
        x2,y2 = XY[J][0],XY[J][1]
        dx = x2-x1
        dy = y2-y1
        if dx < 0:
            dx = -dx
            dy = -dy
        edges.append([dx,dy])
        
listcount = []
count = []
for edge in edges:
    if edge == [0,0]:
        pass
    elif edge in listcount:
        count[listcount.index(edge)]+=1
    else:
        listcount.append(edge)
        count.append(1)
        
most = max(count)
print(N-most)
        


Fixed submission:
#B問題
N = int(input())
XY = [list(map(int,input().split())) for i in range(N)]
edges = []
for i in range(N):
    x1,y1 = XY[i][0],XY[i][1]
    for j in range(N-i-1):
        J = i+j+1
        x2,y2 = XY[J][0],XY[J][1]
        dx = x2-x1
        dy = y2-y1
        if dx <= 0:
            if dx == 0:
                if dy < 0:
                    dy = -dy
            else:
                dx = -dx
                dy = -dy
        edges.append([dx,dy])

listcount = []
count = []
if N == 1:
    listcount.append([0,0])
    count.append(1)

for edge in edges:
    if edge == [0,0]:
        if [0,0] not in listcount:
            listcount.append([0,0])
            count.append(1)
    elif edge in listcount:
        count[listcount.index(edge)]+=1
    else:
        listcount.append(edge)
        count.append(1)
        
most = max(count)
if N == 1:
    print(1)
else:
    print(N-most)
Buggy python submission (verdict: Runtime Error):
#C問題
N,M = map(int,input().split())
K = []
S = []
for i in range(M):
    ks =list(map(int,input().split()))
    ss = []
    kk = ks[0]
    K.append(kk)
    for j in range(kk):
        ss.append(ks[j+1])
    
    S.append(ss)
P = list(map(int,input().split()))
Bit = 2**N
ans = 0
for i in range(Bit):
    b = bin(i)
    b = b.lstrip("0b")
    lenb = len(b)
    j = 0
    for j in range(N-lenb):
        b = "0"+b
        
    sw = []
    j = 0

    for j in range(M):
        if b[j] == "1":
            sw.append(1)
        else:
            sw.append(0)
    
    j = 0
    flag = 0
    for j in range(M):
        cond = P[j]
        now = 0
        for k in range(K[j]):
            now+=sw[S[j][k]-1]
            
        if now%2 == cond:
            pass
        else:
            flag = 1
            break
            
    if flag == 0:
        ans+=1
    
print(ans)

Fixed submission:
#C問題
N,M = map(int,input().split())
K = []
S = []
for i in range(M):
    ks =list(map(int,input().split()))
    ss = []
    kk = ks[0]
    K.append(kk)
    for j in range(kk):
        ss.append(ks[j+1])
    
    S.append(ss)
P = list(map(int,input().split()))
Bit = 2**N
ans = 0
for i in range(Bit):
    b = bin(i)
    b = b.lstrip("0b")
    lenb = len(b)
    j = 0
    for j in range(N-lenb):
        b = "0"+b
        
    sw = []
    j = 0

    for j in range(N):
        if b[j] == "1":
            sw.append(1)
        else:
            sw.append(0)
    
    j = 0
    flag = 0
    for j in range(M):
        cond = P[j]
        now = 0
        for k in range(K[j]):
            now+=sw[S[j][k]-1]
            
        if now%2 == cond:
            pass
        else:
            flag = 1
            break
            
    if flag == 0:
        ans+=1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
#C問題
N=int(input())
A=list(map(int,input().split()))
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
def gcdlist(xlist):
    xlen=len(xlist)
    GCD=0
    for i in range(xlen-1):
        GCD=gcd(xlist[i],xlist[i+1])
        xlist[i+1]=GCD
    return GCD
MAX=0
kari=0
for i in range(N):
    B=A[::]
    del B[i]
    kari=gcdlist(B)
    MAX=max(MAX,kari)
if N == 2:
    MA=max(A)
    g=gcd(A[0],A[1])
    MAX=max(MA,g)
print(MAX)
    

Fixed submission:
#A問題
A,B,T=map(int,input().split())
print(B*int(T/A))
Buggy python submission (verdict: Time Limit Exceeded):
#C問題
N=int(input())
A=list(map(int,input().split()))
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
def gcdlist(xlist):
    xlen=len(xlist)
    GCD=0
    for i in range(xlen-1):
        GCD=gcd(xlist[i],xlist[i+1])
        xlist[i+1]=GCD
    return GCD
MAX=0
kari=0
for i in range(N):
    B=A[::]
    del B[i]
    kari=gcdlist(B)
    MAX=max(MAX,kari)
if N == 2:
    MA=max(A)
    g=gcd(A[0],A[1])
    MAX=max(MA,g)
print(MAX)
    


Fixed submission:
#C問題
N=int(input())
A=list(map(int,input().split()))
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
def gcdlist(xlist):
    xlen=len(xlist)
    GCD=0
    for i in range(xlen-1):
        GCD=gcd(xlist[i],xlist[i+1])
        xlist[i+1]=GCD
    return GCD
MAX=0
kari=0
gcdf=[]
for i in range(N):
    if i == 0:
        gcdf.append(A[i])
    else:
        gcdf.append(gcd(A[i],gcdf[-1]))
gcdb=[]
for i in range(N):
    if i == 0:
        gcdb.append(A[-1])
    else:
        gcdb.append(gcd(A[-1-i],gcdb[-1]))
MAX=0
gcdb=gcdb[::-1]
for i in range(N):
    if i == 0:
        kari=gcdb[1]
    elif i == N-1:
        kari=gcdf[-2]
    else:
        f=gcdf[i-1]
        b=gcdb[i+1]
        kari=gcd(f,b)
    MAX=max(kari,MAX)
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
#C問題
N=int(input())
A=list(map(int,input().split()))
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
def gcdlist(xlist):
    xlen=len(xlist)
    GCD=0
    for i in range(xlen-1):
        GCD=gcd(xlist[i],xlist[i+1])
        xlist[i+1]=GCD
    return GCD
MAX=0
kari=0
for i in range(N):
    B=A[::]
    del B[i]
    kari=gcdlist(B)
    MAX=max(MAX,kari)
if N == 2:
    MA=max(A)
    g=gcd(A[0],A[1])
    MAX=max(MA,g)
print(MAX)
    

Fixed submission:
#C問題
N=int(input())
A=list(map(int,input().split()))
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
def gcdlist(xlist):
    xlen=len(xlist)
    GCD=0
    for i in range(xlen-1):
        GCD=gcd(xlist[i],xlist[i+1])
        xlist[i+1]=GCD
    return GCD
MAX=0
kari=0
gcdf=[]
for i in range(N):
    if i == 0:
        gcdf.append(A[i])
    else:
        gcdf.append(gcd(A[i],gcdf[-1]))
gcdb=[]
for i in range(N):
    if i == 0:
        gcdb.append(A[-1])
    else:
        gcdb.append(gcd(A[-1-i],gcdb[-1]))
MAX=0
gcdb=gcdb[::-1]
for i in range(N):
    if i == 0:
        kari=gcdb[1]
    elif i == N-1:
        kari=gcdf[-2]
    else:
        f=gcdf[i-1]
        b=gcdb[i+1]
        kari=gcd(f,b)
    MAX=max(kari,MAX)
print(MAX)
Buggy python submission (verdict: Time Limit Exceeded):
#D問題
N,K=map(int,input().split())
S=str(input())
Slist=list(S)
#偶数が”1”
hu=[]
ima=""
imal=0
for i in range(N):
    if i == 0:
        ima=Slist[0]
        imal=1
        if Slist[0] == "0":
            hu.append(0)
    else:
        if ima==Slist[i]:
            imal+=1
        else:
            hu.append(imal)
            ima=Slist[i]
            imal=1
hu.append(imal)
Ngu=len(hu)
MAX=0
for i in range(Ngu):
    I=i
    kari=0
    k=0
    for j in range(Ngu):
        J=I+j
        if J == Ngu:
            break    
        if J%2==0:
            kari+=hu[J]
        else:
            if k<K:
                kari+=hu[J]
                k+=1
            else:
                break
    MAX=max(MAX,kari)
print(MAX)
            

Fixed submission:
#D問題
N,K=map(int,input().split())
S=str(input())
Slist=list(S)
#偶数が”1”
hu=[]
ima=""
imal=0
for i in range(N):
    if i == 0:
        ima=Slist[0]
        imal=1
        if Slist[0] == "0":
            hu.append(0)
    else:
        if ima==Slist[i]:
            imal+=1
        else:
            hu.append(imal)
            ima=Slist[i]
            imal=1
hu.append(imal)
Ngu=len(hu)
rui=[0]
for i in range(Ngu):
    if i == 0:
        rui.append(hu[0])
    else:
        karui=rui[i]+hu[i]
        rui.append(karui)

        
MAX=0

for i in range(Ngu+1):
    if i%2==0:
        if 2*K+i-1<Ngu+1:
            if i > 0:
                kari=rui[2*K+i-1]-rui[i-1]
            else:
                kari=rui[2*K+i-1]
        else:
            if i > 0:
                kari=rui[-1]-rui[i-1]
            else:
                kari=rui[-1]
    else:
        if 2*K+i<Ngu+1:
            if i > 0:
                kari=rui[2*K+i]-rui[i-1]
            else:
                kari=rui[2*K+i]
        else:
            if i > 0:
                kari=rui[-1]-rui[i-1]
            else:
                kari=rui[-1]
    MAX=max(kari,MAX) 
print(MAX)
Buggy python submission (verdict: Time Limit Exceeded):
#C問題  
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
LR=[list(map(int,input().split())) for i in range(Q)]
pile=[0 for i in range(N)]
for i in range(N-1):
    if Slist[i] == "A" and Slist[i+1] == "C":
        pile[i]=1
pile_sum=[0 for i in range(N)]
for i in range(N):
    pile_sum[i]=sum(pile[:i])
for i in range(Q):
    right=pile_sum[LR[i][1]-1]
    left=pile_sum[LR[i][0]-1]
    print(right-left)

Fixed submission:
#C問題  
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
pile=[0 for i in range(N)]
for i in range(N-1):
    if i == 0:
        pass
    else:
        pile[i]=pile[i-1]
  
    if Slist[i] == "A" and Slist[i+1] == "C":
        pile[i]+=1
pile[-1]=pile[-2]
pile.insert(0,0)
for i in range(Q):
    l,r=map(int,input().split())
    print(pile[r-1]-pile[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
#C問題  
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
LR=[list(map(int,input().split())) for i in range(Q)]
pile=[0 for i in range(N)]
for i in range(N-1):
    if Slist[i] == "A" and Slist[i+1] == "C":
        pile[i]=1
for i in range(Q):
    right=sum(pile[:LR[i][1]-1])
    left=sum(pile[:LR[i][0]-1])
    print(right-left)

Fixed submission:
#C問題  
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
pile=[0 for i in range(N)]
for i in range(N-1):
    if i == 0:
        pass
    else:
        pile[i]=pile[i-1]
  
    if Slist[i] == "A" and Slist[i+1] == "C":
        pile[i]+=1
pile[-1]=pile[-2]
pile.insert(0,0)
for i in range(Q):
    l,r=map(int,input().split())
    print(pile[r-1]-pile[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
#C問題
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
LR=[list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
    karis=Slist[LR[i][0]-1:LR[i][1]]
    karistr="".join(karis)
    ans=karistr.count("AC")
    print(ans)

Fixed submission:
#C問題  
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
pile=[0 for i in range(N)]
for i in range(N-1):
    if i == 0:
        pass
    else:
        pile[i]=pile[i-1]
  
    if Slist[i] == "A" and Slist[i+1] == "C":
        pile[i]+=1
pile[-1]=pile[-2]
pile.insert(0,0)
for i in range(Q):
    l,r=map(int,input().split())
    print(pile[r-1]-pile[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
#C問題
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
LR=[list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
    karis=Slist[LR[i][0]-1:LR[i][1]]
    n=LR[i][1]-LR[i][0]+1
    count=0
    for j in range(n-1):
        if karis[j] == "A" and karis[j+1] == "C":
            count+=1
    print(count)

Fixed submission:
#C問題  
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
pile=[0 for i in range(N)]
for i in range(N-1):
    if i == 0:
        pass
    else:
        pile[i]=pile[i-1]
  
    if Slist[i] == "A" and Slist[i+1] == "C":
        pile[i]+=1
pile[-1]=pile[-2]
pile.insert(0,0)
for i in range(Q):
    l,r=map(int,input().split())
    print(pile[r-1]-pile[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
#A問題
import sys
sys.setrecursionlimit(500000)
N=int(input())
S=str(input())
Slist=list(S)
count=-1
kari=[]
def ans(n):
    global count
    global Slist
    if n == N-1:
        if Slist[n] in kari:
            count+=1
            return
        else:
            count+=2
            return
    else:
        if Slist[n] in kari:
            ans(n+1)
        else:
            kari.append(Slist[n])
            ans(n+1)
            kari.remove(Slist[n])
            ans(n+1)
ans(0)
count%=1000000007
print(count)

Fixed submission:
#A問題
import collections
N=int(input())
S=str(input())
Slist=list(S)
c = collections.Counter(Slist)
d = c.most_common()
dlen=len(d)
count=1
for i in range(dlen):
    count*=(d[i][1]+1)
count-=1
count%=1000000007
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
#A問題
import collections
N=int(input())
S=str(input())
Slist=list(S)
count=0
maxn=2**N
for i in range(maxn):
    I=bin(i)
    I=I.lstrip("0b")
    Ilen=len(I)
    if Ilen<N:
        Id=N-Ilen
        j=0
        for j in range(Id):
            I="0"+I
    
    k=0
    klist=[]
    flag=0
    for k in range(N):
        if I[k]=="0":
            pass
        else:
            if Slist[k] in klist:
                flag=1
                break
            else:
                klist.append(Slist[k])
    if flag == 0 and len(klist)>0:
        count+=1
    count=count%1000000007
print(count)

Fixed submission:
#A問題
import collections
N=int(input())
S=str(input())
Slist=list(S)
c = collections.Counter(Slist)
d = c.most_common()
dlen=len(d)
count=1
for i in range(dlen):
    count*=(d[i][1]+1)
count-=1
count%=1000000007
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
S=str(input())
Slist=list(S)
horyu=[]
Slen=len(S)
count=0
for i in range(Slen):
    if Slist[i] == "0":
        if "1" in horyu:
            horyu.remove("1")
            count+=1
        else:
            horyu.append("0")
    else:
        if "0" in horyu:
            horyu.remove("0")
            count+=1
        else:
            horyu.append("1")
print(count*2)

Fixed submission:
S=str(input())
Slist=list(S)
onecount=Slist.count("1")
zerocount=Slist.count("0")
print(2*min(zerocount,onecount))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [ 0 for i in range(N)]
for j in range(N):
    if j == 0:
        dp[j] = 0
    elif j == 1:
        dp[j] = abs(h[1]-h[0])
    elif j < K:
        check = []
        for a in range(j):
            check.append(dp[j-a-1]+abs(h[j]-h[j-a-1]))
        dp[j] = min(check)
    else:
        check = []
        for a in range(K):
            check.append(dp[j-a-1]+abs(h[j]-h[j-a-1]))
        dp[j] = min(check)
print(dp[N-1])

Fixed submission:
#B
inf = float("inf")
N,K = map(int,input().split())
H = list(map(int,input().split()))

dp = [inf for _ in range(N)] #dp[i] = cost
dp[0] = 0
for i in range(N):
    for j in range(K):
        if i+j+1 < N:
            dp[i+j+1] = min(dp[i+j+1],dp[i]+abs(H[i]-H[i+j+1]))
            
#print(dp)
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
a = 1
count=0
while True:
    a = S.count("BW")
    count+=a
    if S == S.replace("BW","WB"):
        break
    else:
        S = S.replace("BW","WB")
print(count)

Fixed submission:
S = str(input())
slist = list(S)
L = len(slist)
count = 0
fcount = 0
for i in range(L):
  if slist[i] == "W":
    count+=(i-fcount)
    fcount+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
a = 1
count=0
while a != 0:
    a = S.count("BW")
    count+=a
    S = S.replace("BW","WB")
print(count)

Fixed submission:
S = str(input())
slist = list(S)
L = len(slist)
count = 0
fcount = 0
for i in range(L):
  if slist[i] == "W":
    count+=(i-fcount)
    fcount+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
slist = list(str(input()))
L = len(slist)
count = 0
fcount = 0
i = 0
while i < L:
    if i < L-1 and slist[i] == "B" and slist[i+1] == "W":
        slist[i],slist[i+1] = slist[i+1],slist[i]
        count+=1
        fcount+=1
        i+=1
    elif i == L-1:
        if fcount == 0:
            break
        else:
            i = 0
            fcount = 0
    else:
        i+=1
print(count)

Fixed submission:
S = str(input())
slist = list(S)
L = len(slist)
count = 0
fcount = 0
for i in range(L):
  if slist[i] == "W":
    count+=(i-fcount)
    fcount+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
slist = list(S)
L = len(slist)
count = 0
fcount = 0
i = 0
while i < L:
    if i < L-1 and slist[i] == "B" and slist[i+1] == "W":
        slist[i],slist[i+1] = slist[i+1],slist[i]
        count+=1
        fcount+=1
        i+=1
    elif i == L-1:
        if fcount == 0:
            break
        else:
            i = 0
            fcount = 0
    else:
        i+=1
print(count)

Fixed submission:
S = str(input())
slist = list(S)
L = len(slist)
count = 0
fcount = 0
for i in range(L):
  if slist[i] == "W":
    count+=(i-fcount)
    fcount+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
slist = list(S)
L = len(slist)
count = 0
for i in range(L):
  if i < L-1 and slist[i] == "B" and slist[i+1] == "W":
    slist[i],slist[i+1] = slist[i+1],slist[i]
    count+=1
  else:
    fcount = 0
    for j in range(L-1):
        if j < L-1 and slist[j] == "B" and slist[j+1] == "W":
          slist[j],slist[j+1] = slist[j+1],slist[j]
          fcount+=1
    if fcount != 0:
      count+=fcount
      i = 0
print(count)

Fixed submission:
S = str(input())
slist = list(S)
L = len(slist)
count = 0
fcount = 0
for i in range(L):
  if slist[i] == "W":
    count+=(i-fcount)
    fcount+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split(" "))
height = []
for i in range(N):
    height.append(int(input()))
height.sort()
min = 10**9
n = N-K+1
for j in range(n):
    light = height[j:j+K]
    hmin = light[0]
    hmax = light[K-1]
    hei = hmax-hmin
    if hei <= min:
        min = hei
print(min)

Fixed submission:
N,K = map(int,input().split(" "))
height = []
for i in range(N):
    height.append(int(input()))
height.sort()
min = 10**9
n = N-K+1
for j in range(n):
    hmin = height[j]
    hmax = height[j+K-1]
    hei = hmax-hmin
    if hei <= min:
        min = hei
print(min)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split(" "))
height = []
for i in range(N):
    height.append(int(input()))
height.sort()
min = 10**9
for j in range(K):
    light = height[j:j+K]
    hmin = light[0]
    hmax = light[K-1]
    hei = hmax-hmin
    if hei <= min:
        min = hei
print(min)

Fixed submission:
N,K = map(int,input().split(" "))
height = []
for i in range(N):
    height.append(int(input()))
height.sort()
min = 10**9
n = N-K+1
for j in range(n):
    hmin = height[j]
    hmax = height[j+K-1]
    hei = hmax-hmin
    if hei <= min:
        min = hei
print(min)
Buggy python submission (verdict: Time Limit Exceeded):
#B問題
N,K = map(int,input().split())
A = list(map(int,input().split()))
rui = [0]

for i in range(N):
    if i == 0:
        rui.append(A[0])
    else:
        rui.append(rui[-1]+A[i])
    
bubun = []
for i in range(N):
    I = i
    for j in range(N-i):
        J = i+j+1
        bubun.append(rui[J]-rui[I])
    
bubun.sort(reverse=True)
m = 40
MAX = 0
kari = 0
while m > 0:
    kari = 2**(m-1)
    count = 0
    for b in bubun:
        if (MAX+kari)&b == MAX+kari:
            count+=1
            
    if count >= K:
        MAX+=kari
    m-=1
    
print(MAX)

Fixed submission:
#B問題
N,K = map(int,input().split())
A = list(map(int,input().split()))
rui = [0]

for i in range(N):
    if i == 0:
        rui.append(A[0])
    else:
        rui.append(rui[-1]+A[i])
    
bubun = []
for i in range(N):
    I = i
    for j in range(N-i):
        J = i+j+1
        bubun.append(rui[J]-rui[I])
    
bubun.sort(reverse=True)
m = 40
MAX = 0
kari = 0
while m > 0:
    kari = 2**(m-1)
    count = 0
    for b in bubun:
        if (MAX+kari)&b == MAX+kari:
            count+=1
            
    if count >= K:
        MAX+=kari
    m-=1
    
print(MAX)
Buggy python submission (verdict: Runtime Error):
X,Y = int(input())
print(int(X+(1/2)*Y))

Fixed submission:
X,Y = map(int,input().split(" "))
print(int(X+(1/2)*Y))