Problem:


Score : 900 points

Problem Statement

Takahashi has an empty string S and a variable x whose initial value is 0.

Also, we have a string T consisting of 0 and 1.

Now, Takahashi will do the operation with the following two steps |T| times.

Insert a 0 or a 1 at any position of S of his choice.

Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is 01101, the digits in the odd positions are 0, 1, 1 from left to right, so x is incremented by 2.

Print the maximum possible final value of x in a sequence of operations such that S equals T in the end.

Constraints

1 \leq |T| \leq 2 \times 10^5

T consists of 0 and 1.

Input

Input is given from Standard Input in the following format:

T

Output

Print the maximum possible final value of x in a sequence of operations such that S equals T in the end.

Sample Input 1

1101

Sample Output 1

5

Below is one sequence of operations that maximizes the final value of x to 5.

Insert a 1 at the beginning of S. S becomes 1, and x is incremented by 1.

Insert a 0 to the immediate right of the first character of S. S becomes 10, and x is incremented by 1.

Insert a 1 to the immediate right of the second character of S. S becomes 101, and x is incremented by 2.

Insert a 1 at the beginning of S. S becomes 1101, and x is incremented by 1.

Sample Input 2

0111101101

Sample Output 2

26



Sample input:
1101


Sample output:
5

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

t = input()
n = len(t)
ki = 0
gu = 0
fi = -1
maxv = -1 * n
for i in range(n-1, -1, -1):
    if i % 2 == 0:
        # 偶数
        if t[i] == '1': gu += 1
        if maxv < (ki - gu):
            maxv = ki - gu
            fi = i
    else:
        # 奇数
        if t[i] == '1': ki += 1
        if maxv < (ki - gu):
            maxv = ki - gu
            fi = i
s = ''
for i in range(n):
    if i == fi: continue
    s += t[i]
ans = gu - maxv
for i in range(n-1):
    if s[i] == '1' and i % 2 == 0:
        ans += n - i
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import re
T=input()
x=0
Td=T
d = len(re.sub(r'0', '', Td))
x += math.ceil((d/2+1)*d/2)
azz = len(T) - d
for i in range(d, len(T)):
    tmpIdx = -1
    for i in range(len(Td)):
        if Td[i] == '0':
            tmpIdx =i
            if i%2==1:
                break
    if tmpIdx > 1:
        x += len(re.sub(r'0', '', Td[::2]))

print(x)

Submission status: Wrong Answer

Solution code:
import re

t=input()

x=0
s=''

k=len(t)
k0=len(t.replace('0',''))

iti=[m.start() for m in re.finditer('0', t)]
#print(iti)
GU=0
KI=0
anst=0
for i in iti:
    if (i+1)%2==0:
        GU+=1
    else:
        KI+=1
if k-k0>=2:
    for i in range(k-k0-1):
        if iti[i]+1==iti[i+1]:
            anst+=1

#print(KI)
if k0%2==1:
    anst=(k0+1)*(1+k0)/4
    #print(anst)

    #if KI>=:
    #    anst=anst+(k0+1)/2*GU+(k0+1)/4*KI+(((k0+1)/2)-1)*KI/2
    #else:
    anst=anst+(k0+1)/2*GU+(((k0+1)/2)-1)*KI
    #print(anst)
else:
    anst=k0/2+k0*k0/4
    anst=anst+((k0/2)+0)*GU+(k0/2)*KI

print(int(anst))

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    s = ns()
    n = len(s)
    o = s.count('1')
    z = n - o
    c = o
    cz = 0
    ans = 0
    for x in reversed(s):
        if x == '1':
            if c % 2:
                ans += o - c + 1 + cz
                ans += (z - cz) // 2
            else:
                ans += (z - cz - 1) // 2 + 1
            c -= 1
        else:
            cz += 1
    print(ans)
    return

solve()

Submission status: Wrong Answer

Solution code:
t = input()
one = t.count("1")
zero = t.count("0")
if one % 2 == 0:
    tmp = one // 2
    ans = tmp * (tmp + 1)
else:
    tmp = one // 2
    ans = (tmp + 1) ** 2
    
before_zero = []
zero_cnt = 0
zero_start = 99999999
one_cnt = 0
new_str = ""
before_even = 0
before_pos = 0
for i, num in enumerate(t):
    if num == "1":
        new_str += "1"
        before_zero.append(zero_cnt)
        one_cnt += 1
    else:
        try:
            if t[i + 1] == "1" and len(new_str) % 2 == 1:
                before_even += (i - before_pos + 1) // 2
                ans += (one - one_cnt + 1) // 2 + before_even
                new_str += "0"
                before_zero.append(zero_cnt)
                zero -= 1
            else:
                zero_cnt += 1
            before_pos = i
        except IndexError:
            pass
for i, num in enumerate(new_str):
    if num == "0":
        continue
    if i % 2 == 0:
        ans += (zero - before_zero[i]) + (before_zero[i]) // 2
    else:
        ans += (before_zero[i] + 1) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

t = input()
n = len(t)
ki = 0
gu = 0
fi = -1
maxv = -1 * n
for i in range(n-1, -1, -1):
    if i % 2 == 0:
        # 偶数
        if t[i] == '1': gu += 1
        if maxv < (ki - gu):
            maxv = ki - gu
            fi = i
    else:
        # 奇数
        if t[i] == '1': ki += 1
        if maxv < (ki - gu):
            maxv = ki - gu
            fi = i
s = ''
for i in range(n):
    if i == fi: continue
    s += t[i]
ans = gu
for i in range(n):
    if t[i] == '1' and i % 2 == 0:
        ans += n - i
print(ans)

Submission status: Wrong Answer

Solution code:


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    T=input()
    N=len(T)
    cnt=T.count("1")
    
    def sum2(x):
        return (x*(x+1))//2
    
    
    L=[]
    aaa=0
    for i in range(N-1,0,-1):
        if T[i]=="1":
            aaa+=1
        else:
            if aaa!=0:
                L.append(aaa%2)
                aaa=0
            
    if T[0]=="1":
        L.append((aaa+1)%2)
    else:
        L.append((aaa)%2)
        
    #print(L)
        
    for i in range(len(L)-1):
        L[i+1]+=L[i]
        L[i+1]=L[i+1]%2
        
        
    
    
    ans=sum2(cnt//2)*2
    if cnt%2==1:
        ans+=(cnt)//2 +1
        
    target=0
    for i in range(0,N,2):
        if T[i] =="1":
            target+=1
        
    zero=N-cnt
    
    if zero==0:
       print(ans)
    else:
        #全部maxをとれると仮定したとき
        ans+=(cnt//2 + cnt%2)*zero
        
        #targetまで減っていくので
        ans-=sum2((cnt//2 + cnt%2)-target)
        
        #Nが奇数でall奇数なら-1で
        if sum(L)==len(L) and cnt%2==1:
            if N-cnt>1:
                ans-=1
        #print(L)
        
        print(ans)
    
        
    

main()

Submission status: Wrong Answer

Solution code:
from sys import stdin

def getpoint(stri):
    point = 0
    i = 0
    for a in stri:
        if (i+1) % 2 == 1 and a == '1':
            point += 1
        i += 1
    return point

def getmax(stri):
    max = 0
    temp = 0
    stri2 = ''
    return_stri = ''
    for a in range(len(stri)):
        if a  <= len(stri)-1:
            stri2 = stri[0:a]+stri[a+1:]
        else:
            stri2 = stri[0:a]
        temp = getpoint(stri2)
        if temp >= max:
            max = temp
            return_stri = stri2
    return max, return_stri


T = stdin.readline().strip("\n")
T2 = ''
point = getpoint(T)
while True:
    temp_point,T2 = getmax(T)
    point += temp_point
    T = T2
    if len(T) == 0:
        break
print(point)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


def solve(T):
    # 先頭が 10101010 だったらずっとそれを続ける
    i = 0
    ans = 0
    while T[i:i+2] == "10":
        ans += len(T) - i
        i += 2

    return ans + solve2(T[i:])
        

def solve2(T):
    size = len(T)
    num1 = T.count("1")
    num0 = size - num1

    # 1だけ並べる
    half = num1 // 2
    ans = half * (half + 1)
    if num1 % 2 == 1:
        ans += (num1 // 2) + 1

    # この時点で奇数番目、偶数番目にいる1の数
    # print("num1:", num1)
    even1 = num1 // 2
    odd1 = num1 - even1
    # print("  even1, odd1 = ", even1, odd1)

    # 反転するぶん
    even_rev = 0
    odd_rev = 0

    # 0を後ろから入れていく
    last_idx = size - 1
    for _ in range(num0):
        zero_idx = T.rfind("0", 0, last_idx + 1)
        last_idx = zero_idx
        # 後ろにずれる要素の数は？
        insert_num = size - zero_idx - 1

        # 反転させる
        if insert_num % 2:
            even_rev, odd_rev = odd_rev, even_rev

        # insert_numの分を
        if insert_num % 2 == 0:
            even1 -= insert_num // 2
            odd1 -= insert_num // 2
            even_rev += insert_num // 2
            odd_rev += insert_num // 2
        else:
            mn = insert_num // 2
            mx = mn + 1
            if even1 == odd1:
                even1 -= mx
                odd1 -= mn
                even_rev += mn
                odd_rev += mx
            else:
                # odd1 > even1
                odd1 -= mx
                even1 -= mn
                odd_rev += mn
                even_rev += mx

        ans += odd1 + odd_rev
        # print("even1, odd1, even_rev, odd_rev = ", even1, odd1, even_rev, odd_rev)


    return ans
        



def main():
    T = input()
    print(solve(T))


main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import deque

T=deque(map(int,list(input().strip())))

LEN=len(T)
E=0
O=0

for i in range(len(T)):
    if i%2==0 and T[i]==1:
        E+=1
    elif i%2==1 and T[i]==1:
        O+=1

ANS=0
ERASE=0
while T:
    #print(T,ANS,O,E)
    if T[0]==0:
        if ERASE==0:           
            ANS+=E
            T.popleft()
            E,O=O,E
        else:
            ANS+=O
            T.popleft()
            E,O=O,E
            

    else:
        if ERASE==0:
            ANS+=len(T)
            T.popleft()
            ERASE=1-ERASE
            E,O=E-1,O
        else:
            T.popleft()
            ERASE=1-ERASE
            E,O=E,O-1

print(ANS)

Submission status: Wrong Answer

Solution code:
import math

t=input()
l=len(t)
ones=t.count("1")

if l%2==0:
  base=round(l/2)*(round(l/2)+1)
else:
  base=math.floor(l/2)*(math.floor(l/2)+1)+math.ceil(l/2)

zl=[]
for i in range(l):
  if t[i]=="0":
    zl.append(i)
  
for i in range(len(zl)):
  long=i+1
  finp=zl[i]
  stap=zl[i]-i
  if long%2==0:
    base-=round(long/2)
  else:
    if finp%2==0:
      base-=math.ceil(long/2)
    else:
      base-=math.floor(long/2)
      
print(base)

Submission status: Wrong Answer

Solution code:
T = str(input())


def score(tt):
    sc = 0
    for i in range(len(tt)):
        v = int(tt[i])
        if (i + 1) % 2 == 1:
            if v == 1:
                sc += 1
    return sc


scores = score(T)
while T is not '':

    t1 = T[:-1]
    t2 = T[1:]

    if score(t1) >= score(t2):
        T = t1
        scores += score(T)
    else:
        T = t2
        scores += score(T)

    if T == '1':
        scores += 1
        
print(scores)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
k = len([1 for i in s if i == "1"])
print(k * (k + 1) // 2 + k * (n - k))

Submission status: Wrong Answer

Solution code:
T = input()
T = list(map(int, T))
x = 0
for i in range(len(T)):
    x += sum(T[0::2])
    if sum(T[0::2]) > sum(T[1::2]):
        if T[1::2].count(0) > 0:
            T.pop(2 * T[1::2].index(0) + 1)
        else:
            if len(T) > 1:
                T.pop(1)
            else:
                break;
    else:
        if T[0::2].count(0) > 0:
            T.pop(2 * T[0::2].index(0))
        else:
            T.pop(0)
print(x)

Submission status: Wrong Answer

Solution code:
s = input()

ans = 0

def cc(t):
    ss = 0
    if len(t) == 1:
        return int(t)
    else:
        for i in range(0, len(t), 2):
            ss += int(t[i])
        return ss
tmp = ""
tmp += s
ans += cc(tmp)

for i in range(len(s)):
    if len(tmp)%2 != 0:
        if tmp[0] == "0":
            tmp = tmp[1:]
        elif tmp[-1] == "0":
            tmp = tmp[:-1]
        else:
            tmp = tmp[:-1]
    else:
        if tmp[0] == "0":
            tmp = tmp[1:]
        elif tmp[-1] == "0":
            tmp = tmp[:-1]
        else:
            tmp = tmp[1:]
    ans += cc(tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
T = str(input())

def add_x(S):
    x = 0
    loop = len(S)//2
    for i in range(loop):
        x += int(S[i*2])
    
    return x

def remove_str_idx(s, idx):
    return s[:idx] + s[idx+1:]

# print(T)
# TT = remove_str_idx(T, 0)
# print(TT)

xx = add_x(T)
TAN = len(T)
for _ in range(TAN):
    TN = len(T)
    max_i = 0
    max_xxx = 0
    for i in range(TN):
        TT = remove_str_idx(T, i)
        xxx = add_x(TT)
        if max_xxx < xxx:
            max_xxx = xxx
            max_i = i
    T = remove_str_idx(T, max_i)
    xx += max_xxx
    #print(T)

print(xx)

Submission status: Wrong Answer

Solution code:
t = input()
one = t.count("1")
zero = t.count("0")
if one % 2 == 0:
    tmp = one // 2
    ans = tmp * (tmp + 1)
else:
    tmp = one // 2
    ans = (tmp + 1) ** 2
    
before_zero = []
zero_cnt = 0
zero_start = 99999999
one_cnt = 0
new_str = ""
before_even = 0
before_pos = 0
for i, num in enumerate(t):
    if num == "1":
        new_str += "1"
        before_zero.append(zero_cnt)
        one_cnt += 1
    else:
        try:
            if t[i + 1] == "1" and len(new_str) % 2 == 1:
                before_even += (i - before_pos + (len(new_str)) % 2) // 2
                before_pos = i
                ans += (one - one_cnt + 1) // 2 + before_even
                new_str += "0"
                before_zero.append(zero_cnt)
                zero -= 1
            else:
                zero_cnt += 1
        except IndexError:
            pass
for i, num in enumerate(new_str):
    if num == "0":
        continue
    if i % 2 == 0:
        ans += (zero - before_zero[i]) + (before_zero[i]) // 2
    else:
        ans += (before_zero[i] + 1) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
ans = 0
a = 0
for i in range(0, n, 2):
    if s[i] == "1":
        a += 1
b = 0
c = 0
no = n
for i in reversed(range(n)):
    if s[i] == "1":
        if i % 2 == 0:
            a -= 1
            b += 1
        else:
            c += 1
    else:
        no -= 1
        ans += b + a
        b, c = c, b
for i in range(no + 1):
    ans += (i + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
t = input()
one = t.count("1")
zero = t.count("0")
if one % 2 == 0:
    tmp = one // 2
    ans = tmp * (tmp + 1)
else:
    tmp = one // 2
    ans = (tmp + 1) ** 2
    
before_zero = []
zero_cnt = 0
zero_start = 99999999
one_cnt = 0
new_str = ""
flg = 0
before_even = 0
before_pos = 0
for i, num in enumerate(t):
    if num == "1":
        new_str += "1"
        before_zero.append(zero_cnt)
        one_cnt += 1
    else:
        try:
            if t[i + 1] == "1" and len(new_str) % 2 == 1:
                before_even = (i - before_pos + (len(new_str)) % 2) // 2
                before_pos = i
                flg = (flg + 1) % 2
                ans += (one - one_cnt + 1) // 2 + before_even
                new_str += "0"
                before_zero.append(zero_cnt)
                zero -= 1
            else:
                zero_cnt += 1
        except IndexError:
            pass
for i, num in enumerate(new_str):
    if num == "0":
        continue
    if i % 2 == 0:
        ans += (zero - before_zero[i]) + (before_zero[i]) // 2
    else:
        ans += (before_zero[i] + 1) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
def count_kisu(moji):
  i=0
  counter=0
  while(i<len(moji)):
    if moji[i:i+1] == '1':
      counter = counter + 1
    i = i+2
  return counter

def count_guu(moji):
  i=1
  counter=0
  while(i<len(moji)):
    if moji[i:i+1] == '1':
      counter = counter + 1
    i = i+2
  return counter




T = input()
n = len(T)
ans = 0
for i in range(n):
  ans = ans + count_kisu(T)
  if(i==len(T)-1):
    break
  max = 0
  max_j = 0
  for j in range(n):
    if max < count_kisu(T[0:j])+count_guu(T[j+1:]):
      max = count_kisu(T[0:j])+count_guu(T[j+1:])
      max_j = j
  T = T[0:max_j] + T[max_j+1:]
  #print(T)

print(ans)

Submission status: Wrong Answer

Solution code:
def removeOdd0(t):
    for i in range(len(t)//2):
        if t[2*i]=='0':
            t.pop(2*i)
            return t
        else:
            pass
    else:
        t.pop(0)
        return t

T=input()
t=list(T)

x=0

for j in range (len(t)):
    _tOdd=t[::2]
    _x=_tOdd.count('1')
    x+=_x
    removeOdd0(t)

print(x)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


def solve(T):
    size = len(T)
    num1 = T.count("1")
    num0 = size - num1

    # 1だけ並べる
    half = num1 // 2
    ans = half * (half + 1)
    if num1 % 2 == 1:
        ans += (num1 // 2) + 1

    # この時点で奇数番目、偶数番目にいる1の数
    # print("num1:", num1)
    even1 = num1 // 2
    odd1 = num1 - even1
    # print("  even1, odd1 = ", even1, odd1)

    # 反転するぶん
    even_rev = 0
    odd_rev = 0

    # 0を後ろから入れていく
    last_idx = size - 1
    for _ in range(num0):
        zero_idx = T.rfind("0", 0, last_idx + 1)
        last_idx = zero_idx
        # 後ろにずれる要素の数は？
        insert_num = size - zero_idx - 1

        # 反転させる
        if insert_num % 2:
            even_rev, odd_rev = odd_rev, even_rev

        # insert_numの分を
        if insert_num % 2 == 0:
            even1 -= insert_num // 2
            odd1 -= insert_num // 2
            even_rev += insert_num // 2
            odd_rev += insert_num // 2
        else:
            mn = insert_num // 2
            mx = mn + 1
            if even1 == odd1:
                even1 -= mx
                odd1 -= mn
                even_rev += mn
                odd_rev += mx
            else:
                # odd1 > even1
                odd1 -= mx
                even1 -= mn
                odd_rev += mn
                even_rev += mx

        ans += odd1 + odd_rev
        # print("even1, odd1, even_rev, odd_rev = ", even1, odd1, even_rev, odd_rev)


    return ans
        



def main():
    T = input()
    print(solve(T))


main()

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

t = ns()
n = len(t)

a = 0
b = 0
c = 0
ans = 0

for i in range(n)[::-1]:
    m = n-i
    if i%2 == 0:#奇数
        if t[i] == '1':
            a += m
    else:#偶数
        if t[i] == '1' and t[i-1] == '0':
            b += m-1
            c += 1
        if a < c and i < n-1:
            ans += b+c
            a,b,c = 0,0,0

ans += a+b

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    T = [int(x) for x in input()]
    lenT = len(T)
    if set(T) == {0}:
        print(0)
        return
    idx = T.index(1)
    oddT = T[idx:][::2]
    ans = 0
    if set(oddT) == {1}:
        oddi = 0
        oddn = len(oddT)
        for i in range(idx, lenT):
            if (i-idx)%2==1:
                oddi += T[i] == 1
            ans += (i-idx+2)//2
        for i in range(idx):
            if i%2 == 0:
                ans += oddi
            else:
                ans += oddn
        print(ans)
        return
        
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s = input()
T = [int(s[i]) for i in range(len(s))]
x = 0


count_0 = s.count('0')
for i in range(count_0):
    for j in range(0,len(T),2):
        x += T[j]
    T.remove(0)


count_1 = len(s)-count_0
if count_1 % 2 == 0:
    m = count_1 // 2
    x += m**2 + m
else:
    m = (count_1+1) //2
    x += m**2
    
print(x)

Submission status: Wrong Answer

Solution code:
t = input()
zero = []

for i in range(len(t)):
  if t[i] == '0':
    zero.append(i - len(t))

total = 0
for i in range(len(t) - len(zero)):
  total += 1 + i // 2

t = t.replace('0', '')
zero = sorted(zero, reverse=True)

for i in range(len(zero)):
  #print(t, '*', t[:zero[i] + 1], '*', t[zero[i] + 1:])
  t = t[:zero[i] + 1] + '0' + t[zero[i] + 1:]
  for j in range(len(t)):
    if j % 2 == 0 and t[j] == '1':
      total += 1
print(total)

Submission status: Wrong Answer

Solution code:
t = input()
one = t.count("1")
zero = t.count("0")
if one % 2 == 0:
    tmp = one // 2
    ans = tmp * (tmp + 1)
else:
    tmp = one // 2
    ans = (tmp + 1) ** 2
    
before_zero = []
zero_cnt = 0
zero_start = 99999999
one_cnt = 0
new_str = ""
flg = 0
before_even = 0
before_pos = 0
for i, num in enumerate(t):
    if num == "1":
        new_str += "1"
        before_zero.append(zero_cnt)
        one_cnt += 1
    else:
        try:
            if t[i + 1] == "1" and len(new_str) % 2 == 1:
                before_even = (i - before_pos + (i + 1) % 2) // 2
                before_pos = i
                flg = (flg + 1) % 2
                ans += (one - one_cnt + 1) // 2 + before_even
                new_str += "0"
                before_zero.append(zero_cnt)
                zero -= 1
            else:
                zero_cnt += 1
        except IndexError:
            pass
for i, num in enumerate(new_str):
    if num == "0":
        continue
    if i % 2 == 0:
        ans += (zero - before_zero[i]) + (before_zero[i]) // 2
    else:
        ans += (before_zero[i] + 1) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))


s=s_in()

odd=[s[::2].count('0'),s[::2].count('1')]
even=[s[1::2].count('0'),s[1::2].count('1')]

res = 0
for i in range(len(s)):
    if i%2 == 0:
        res += odd[1]
    else:
        res += even[1]

    if odd[0] > 0:
        odd[0] -= 1
    elif even[0] > 0:
        even[0] -= 1
    elif odd[1] > even[1]:
        even[1] -= 1
    elif odd[1] < even[1]:
        odd[1] -= 1
    else:
        if i%2 == 0:
            odd[1] -= 1
        else:
            even[1] -= 1

print(res)

Submission status: Wrong Answer

Solution code:
T = list(input())

x = 0
while len(T) != 0:
    x += sum([int(f) for f in T[::2]])

    xmax = 0
    delIdx = 0
    for i in range(len(T)):
        if i % 2 == 0 and T[i] == "0":
            delIdx = i
            break
            # T_copy = T.copy()
            # _tmp = T_copy.pop(i)

            # _x = sum([int(f) for f in T_copy[::2]])

            # if _x > xmax:
            #     xmax = _x
            #     delIdx = i

    T.pop(delIdx)

print(x)

Submission status: Wrong Answer

Solution code:
t=input()
l=len(t)
a=t.count("0")
b=t.count("11")
c=l-a-b
print((c+1)*c//2+a*((l-a)+1)//2)

Submission status: Wrong Answer

Solution code:
T = list(input())

x = 0
while len(T) != 0:
    x += sum([int(f) for f in T[::2]])

    xmax = 0
    delIdx = 0
    for i in range(len(T)):
        if T[i] == "0":
            delIdx = i
            break
            # T_copy = T.copy()
            # _tmp = T_copy.pop(i)

            # _x = sum([int(f) for f in T_copy[::2]])

            # if _x > xmax:
            #     xmax = _x
            #     delIdx = i

    T.pop(delIdx)

print(x)

Submission status: Wrong Answer

Solution code:
t=input()
l=len(t)
a=t.count("0")
b=t.count("11")
c=l-a-b
print((c+1)*c//2+a*c)

Submission status: Wrong Answer

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

T = list(map(int, list(input())))
l = len(T)
ones = sum(T)

T.reverse()

cnt = 0

for i in range(1, ones + 1):
    cnt += (i + 1) // 2

a = 0
b = 0
it = 0
oc = 0
for i in range(l):
    if T[i] == 1:
        oc += 1
    else:
        if (ones - oc + it) % 2 == 0:
            b += 1
        else:
            a += 1
        it += 1
        cnt += (ones + 1) // 2 - a
        a, b = b, a

print(cnt)

Submission status: Wrong Answer

Solution code:
def getpoint(stri):
    point = 0
    i = 0
    for a in stri:
        if (i+1) % 2 == 1 and a == '1':
            point += 1
        i += 1
    return point

def getmax(stri):
    max = 0
    temp = 0
    stri2 = ''
    return_stri = ''
    for a in range(len(stri)):
        if a  <= len(stri)-1:
            stri2 = stri[0:a]+stri[a+1:]
        else:
            stri2 = stri[0:a]
        # print(stri2)
        temp = getpoint(stri2)
        if temp > max:
            max = temp
            return_stri = stri2
    return max, return_stri


T = input()
T2 = ''
point = getpoint(T)
while True:
    temp_point,T2 = getmax(T)
    point += temp_point
    T = T2
    if len(T) == 0:
        break
print(point)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[67]:


T = list(map(int, list(input())))


# In[70]:


cnt0 = T.count(0)
cnt1 = T.count(1)
if cnt0 <= cnt1:
    print(cnt0*(cnt0+1) + cnt0*(cnt1-cnt0) - (-(cnt1-cnt0))//2)
else:
    print(cnt1*(cnt1+1) + cnt1*(cnt0-cnt1))

Submission status: Wrong Answer

Solution code:
s = input()

x = 0

n = len(s)
for i in range(n):
  x += sum(map(int,s[0::2]))
  if s.find('0') > -1:
    s = s.replace('0','',1)
  else:
    s = s.replace('1','',1)

print(x)

Submission status: Wrong Answer

Solution code:
import re

t=input()

x=0
s=''

k=len(t)
k0=len(t.replace('0',''))

iti=[m.start() for m in re.finditer('0', t)]
#print(iti)
GU=0
KI=0
for i in iti:
    if (i+1)%2==0:
        GU+=1
    else:
        KI+=1

anst=0
#print(KI)
if k0%2==1:
    anst=(k0+1)*(1+k0)/4
    #print(anst)
    anst=anst+(k0+1)/2*GU+(((k0+1)/2)-1)*KI
    #print(anst)
else:
    anst=k0/2+k0*k0/4
    anst=anst+((k0/2)+0)*GU+(k0/2)*KI

print(int(anst))

Submission status: Wrong Answer

Solution code:
t=input()
l=len(t)
a=t.count("0")
b=t.count("11")
c=l-a-b
print((c+1)*c//2+a+b)

Submission status: Wrong Answer

Solution code:
a=input()
b=len(a)
a=list(a)
c=b
k=1
while k<b+1:

    if k%2==1:
        a[k-1]=int(a[k-1])
        c=a[k-1]+c
    k=k+1
print(c)

Submission status: Wrong Answer

Solution code:
"""t = list(input())

ans = 0
zero = 0

for i in range(len(t)):
    if t[i] == "0":
        zero = zero + 1
    elif i % 2 == 0 and t[i] == "1":
        ans = ans + 1

for i in range(zero):
    t.remove("0")
    for i in range(len(t)):
        if i % 2 == 0 and t[i] == "1":
            ans = ans + 1

n = len(t)

if n % 2 == 0:
    ans = ans + ((n - 2) // 2) * ((n - 2) // 2 + 1) + n // 2
else:
    ans = ans + (n // 2) * (n // 2 + 1)


print(ans)"""

t = list(input())

zero = t.count("0")
one = len(t) - zero
rev = 1
count = 0
zero_n = 0
ans = 0

for i in range(len(t)):
    if t[0] == "0" and t[i] == "1" and i % 2 == 0:
        ans = ans + 1
    if t[i] == "1" and i % 2 == 0 and rev == 1:
        count = count + 1
    elif t[i] == "1" and i % 2 == 1 and rev == -1:
        count = count + 1
    elif t[i] == "0":
        ans = ans + count * (zero - zero_n)
        rev = rev * -1
        zero_n = zero_n + 1

n = one

if n % 2 == 0:
    ans = ans + (n // 2) * (n // 2 + 1)
else:
    ans = ans + (n // 2) * (n // 2 + 1) + n // 2 + 1


print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
T = input()
t0 = T.count('0')
x = 0
for i in range(t0):
    x += T[::2].count('1')
    T = T.replace('0', '', 1)

t1 = T.count('1')
if t1 % 2 == 0:
    x += int(t1/2) * (int(t1/2) + 1)
else:
    x += int((t1+1)/2) * (int((t1+1)/2) + 1) - int((t1+1)/2)
print(x)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
from itertools import accumulate

input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

T = list(input())[:-1]
T = [int(t) for t in T]

T1 = [0] + list(accumulate(T[0::2]))
T2 = [0] + list(accumulate(T[1::2]))

res = T1[-1]

for _ in range(len(T)):
    # print(T, T1, T2)
    val = -1
    same = len(T1)==len(T2)

    # 全て1ならどこでも同じ
    if sum(T)==len(T):
        idx = 0
        flg = True
        if len(T) % 2 == 0:
            res += sum(T)//2
        else:
            res += sum(T) // 2 + 1
    else:
        for i in range(1, len(T1)):
            val1 = T1[i-1] + T2[-1] - T2[i-1]
    
            if (i == len(T1)-1) and (not same):
                val2 = -1
            else:
                val2 = T1[i] + T2[-1] - T2[i]
            # print(i, val1, val2)
    
            if max(val1, val2) > val:
                val = max(val1, val2)
                idx, flg = i-1, val1 > val2
        res += val

    # print(i, idx)
    if flg:
        T.pop(idx*2)
    else:
        T.pop(idx*2+1)

    T1 = [0] + list(accumulate(T[0::2]))
    T2 = [0] + list(accumulate(T[1::2]))

print(res)

Submission status: Wrong Answer

Solution code:
input()
print(1)

Submission status: Wrong Answer

Solution code:
def getBinVal(s):
	v=0
	ar=list(s)
	#print(ar)
	#print(len(s))


	for j in range(len(s)):
		if j%2==0:
			v+=int(ar[j])
	#print('getdata:' + s + ' >>> ' + str(v))
	return v
T=input()
n=len(T)

aT1=list(T)

zeros=aT1.count('0')
ones=aT1.count('1')

s=''
x=0

#one
if ones>0 :
	for i in range(ones):
		s=s + '1'
		x+=getBinVal(s)

#zero
idx=0

if zeros >0 :
	for k in range(zeros):
		idx=T.find('0',idx)
		s=s[0:idx] + '0' + s[idx:]
		x+=getBinVal(s)
		idx=idx+1

#x+=getBinVal('11111101')
#x+=getBinVal('111101101')
#x+=getBinVal('0111101101')

print(x)


#for i in range(n):
#	s=s + aT1[i]
#	x+=getBinVal(s)


#aT2=list(T)
#aT2.reverse()
#s=''
#x=0
#print(aT2)
#for i in range(n):
#	s=aT2[i] + s
#	x+=getBinVal(s)
#print(s)
#print(x)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

t = ns()
n = len(t)

a = 0
b = 0
c = 0

for i in range(n):
    m = n-i
    if i%2 == 0:#奇数
        if t[i] == '1':
            a += m
    else:#偶数
        if t[i] == '1' and t[i-1] == '0':
            b += m if i == n-1 and t[0] == '1' else (m-1)
            c += 1

ans = a+b

if a < c:
    ans = b+c

print(ans)

Submission status: Wrong Answer

Solution code:
T = input()

kisu = T[::2].count('1')
gusu = T[1::2].count('1')
ans = 0
length = len(T)

for _ in range(len(T)):
    ans += kisu
    if length > kisu + gusu:
        kisu,gusu = gusu,kisu
        length -= 1
    else:
        kisu -= 1
        kisu,gusu = gusu,kisu
        length -= 1
print(ans)