#include //#include using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; vector> encode(string &S){ vector> encoded; int l = 0, r, N=S.size(); while(l != N){ r = l+1; while(r1011で1引いて持ち越し、 偶数ならそのまま持ち越し、0より前にある連続する1の数/2の和が答え。 */ string S; cin >> S; vector> v = encode(S); ll ans=0, sm=0; for (auto [c, x] : v){ if (c == '1') sm += x; else{ ans += sm/2; sm = sm/2*2; } } cout << ans << endl; return 0; }