Buggy python submission (verdict: Runtime Error):
#AGC030 B - Powers of two
beki=[]
for i in range(1,32):
    beki.append(2**i)#bekiは２のべき乗の配列
N=int(input())
A=input().split()
for i in range(N):
    A[i]=int(A[i])
sorted(A)#Aを昇順にソート
for i in (reversed(beki)):
    inverseA=[]
    for j in range(len(A)):
        inverseA.append(i-A[j])#inverseA
    for j in range(len(A)):
        if inverseA[j] in A:
            A.remove(inverseA[j])
print((N-len(A))//2)

Fixed submission:
#AGC029 A - Irreversible operation
def countB(data):#dataのBの個数kosuとiの総和sumを返す
    sum=0
    kosu=0
    for i in range(len(data)):
        if data[i]=="B":
            kosu=kosu+1
            sum=sum+i
    return[sum,kosu]

text=input()
S=[]
N=len(text)
for i in range(N):
    S.append(text[i])
result=countB(S)
x=result[1]
Ans=int((2*N-x-1)*x/2-result[0])
print(Ans)

Buggy python submission (verdict: Runtime Error):
#AGC030 B - Powers of two
beki=[]
for i in range(1,32):
    beki.append(2**i)#bekiは２のべき乗の配列
N=int(input())
for i in range(N):
    A[i]=int(A[i])
sorted(A)#Aを昇順にソート
for i in (reversed(beki)):
    inverseA=[]
    for j in range(len(A)):
        inverseA.append(i-A[j])#inverseA
    for j in range(len(A)):
        if inverseA[j] in A:
            A.remove(inverseA[j])
print((N-len(A))%2)

Fixed submission:
#AGC029 A - Irreversible operation
def countB(data):#dataのBの個数kosuとiの総和sumを返す
    sum=0
    kosu=0
    for i in range(len(data)):
        if data[i]=="B":
            kosu=kosu+1
            sum=sum+i
    return[sum,kosu]

text=input()
S=[]
N=len(text)
for i in range(N):
    S.append(text[i])
result=countB(S)
x=result[1]
Ans=int((2*N-x-1)*x/2-result[0])
print(Ans)

Buggy python submission (verdict: Runtime Error):
#AGC030 B - Powers of two
beki=[]
for i in range(1,32):
    beki.append(2**i)#bekiは２のべき乗の配列
N=int(input())
for i in range(N):
    A[i]=int(A[i])
sorted(A)#Aを昇順にソート
for i in (reversed(beki)):
    inverseA=[]
    for j in range(len(A)):
        inverseA.append(i-A[j])#inverseA
    for j in range(len(A)):
        A.remove(inverseA[j])
print((N-len(A))%2)

Fixed submission:
#AGC029 A - Irreversible operation
def countB(data):#dataのBの個数kosuとiの総和sumを返す
    sum=0
    kosu=0
    for i in range(len(data)):
        if data[i]=="B":
            kosu=kosu+1
            sum=sum+i
    return[sum,kosu]

text=input()
S=[]
N=len(text)
for i in range(N):
    S.append(text[i])
result=countB(S)
x=result[1]
Ans=int((2*N-x-1)*x/2-result[0])
print(Ans)

Buggy python submission (verdict: Runtime Error):
#AGC030 B - Powers of two
beki=[]
for i in range(1,32):
    beki.append(2**i)#bekiは２のべき乗の配列
def tasitekesu(data,n):#dataの中で足したらnになるやつを消し、消した結果とペア数を報告する
    result=[]
    kosu=0
    for i in range(len(data)):
        if i in result:
            continue
        for j in range(i):
            if j in result:
                continue
            if data[i]+data[j]==n:
                result.append(i)
                result.append(j)
                kosu=kosu+1
                break
    result.sort(reverse=True)
    for i in result:
        del data[i]
    return [data,kosu]

N=int(input())
A=input().split()
ans=0
for i in range(N):
    A[i]=int(A[i])
for i in (reversed(beki)):
    R=tasitekesu(A,i)
    A=R[0]
    ans=ans+R[1]
print(ans)

Fixed submission:
#AGC029 A - Irreversible operation
def countB(data):#dataのBの個数kosuとiの総和sumを返す
    sum=0
    kosu=0
    for i in range(len(data)):
        if data[i]=="B":
            kosu=kosu+1
            sum=sum+i
    return[sum,kosu]

text=input()
S=[]
N=len(text)
for i in range(N):
    S.append(text[i])
result=countB(S)
x=result[1]
Ans=int((2*N-x-1)*x/2-result[0])
print(Ans)