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

Solution in Rust (1.42.0) (judge verdict: Wrong Answer)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
#[allow(unused_imports)]
use algo;
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Isize1, Usize1};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

fn main() {
    input! {
        T:Chars
    }
    let N = T.len();
    let mut S = Vec::<char>::new();
    let mut tmp = Vec::<char>::new();
    let mut ans = 0;
    let mut even = 0;
    let mut one_sum = 0;
    for i in 0..N {
        if T[i] == '1' {
            tmp.push('1');
            one_sum += 1;
        } else {
            if tmp.len() % 2 == 0 {
                even += tmp.len();
            } else {
                S.extend(tmp.iter());
            }
            tmp.clear();
            S.push('0');
        }
    }
    if tmp.len() > 0 {
        if tmp.len() % 2 == 0 {
            even += tmp.len();
        } else {
            S.extend(tmp.iter());
        }
    }
    let M = S.len();
    let mut zero_sum = 0;
    for i in 0..M {
        if S[i] == '0' {
            zero_sum += 1;
        }
    }
    let mut zero = 0;
    for i in 0..M {
        if S[i] == '1' {
            if i % 2 == 1 {
                ans += zero / 2 + (zero_sum - zero);
            } else {
                ans += (zero + 1) / 2 + (zero_sum - zero);
            }
        } else {
            zero += 1;
            ans += even / 2;
        }
    }
    for i in 1..one_sum + 1 {
        ans += (i + 1) / 2;
    }
    println!("{}", ans);
}
*/

fn main() {
    let exe = "/tmp/binF6DCCA2B";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";