Problem: There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white.  Consider performing the following operation:    * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.  Find the maximum possible number of times this operation can be performed.

Submission attempts (in order):
t = input()
s = input()
s = s.split()
list=[]
for i in range(len(s)):
  list.append(int(s[i]))

kind = 1
counter=0

for i in range(len(list)-1):
  if(list[i]>=list[i+1]):
    if(kind==1):
      kind = kind + 1
    else:
      if(counter==kind-1):
        kind = kind + 1
        counter=0    
      else:
        counter = counter + 1
      
print(kind)
    

s = input()
list = list(s)
count=0
b=0

for i in range(len(list)-1):
  if(list[i] == "W"):
    count+=b
    continue
  else:
    if(i == len(list)-1):
      break
    b += 1
      
print(count)


list = list(s)
count=0
b=0

for i in range(len(list)):
  if(list[i] == "W"):
    count+=b
    continue
  else:
    if(i == len(list)-1):
      break
    b += 1
      
print(count)

s=input()
t=input()
list=[]
list = t.split()
print(list)
ans=0

def even(i,k):
  for j in range(k+1,len(list)):
    if(int(list[j])%2==0):
      s = i + int(list[j])
      if(power(s)):
        return 1
    else:
      continue
      
  return 0
  
def odd(i,k):
  for j in range(k+1,len(list)):
    if(int(list[j])%2==0):
      continue
    else:
      s = i + int(list[j])
      if(power(s)):
        return 1
      
  return 0
      

def power(s):
  while(True):
    s = int(s / 2)
    if(s==1):
       return 1

    if(s % 2 != 0):
      break      
      return 0

for i in range(len(list)-1):
  if(int(list[i]) % 2 == 0):
    if(even(int(list[i]),i)):
      ans = ans+1
  else:
    if(odd(int(list[i]),i)):
      ans = ans+1

print(ans)

s=input()
t=input()
list=[]
list = t.split()
print(list)
ans=0

def even(i,k):
  for j in range(k+1,len(list)):
    if(int(list[j])%2==0):
      s = i + int(list[j])
      if(power(s)):
        return 1
    else:
      continue
      
  return 0
  
def odd(i,k):
  for j in range(k+1,len(list)):
    if(int(list[j])%2==0):
      continue
    else:
      s = i + int(list[j])
      if(power(s)):
        return 1
      
  return 0
      

def power(s):
  while(True):
    s = int(s / 2)
    if(s==1):
       return 1

    if(s % 2 != 0):
      break      
      return 0

for i in range(len(list)-1):
  if(int(list[i]) % 2 == 0):
    if(even(int(list[i]),i)):
      ans = ans+1
  else:
    if(odd(int(list[i]),i)):
      ans = ans+1

print(ans)

s = input()
list = list(s)
count=0
b=0

for i in range(len(list)):
  if(list[i] == "W"):
    count+=b
    continue
  else:
    if(i == len(list)-1):
      break
    b += 1
      
print(count)


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted