#include using namespace std; #ifdef ONLINE_JUDGE #define dbg(...) #else #include "debug.h" #endif #define ll long long #define endl '\n' #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define yes cout<<"YES"<>=1;}return ans;} void solve() { string s; cin>>s; ll ans=0,ct=0; for(auto c:s) { if(c=='1') ct++; else if(c=='0' && ct) ans += ct+1; } cout<> TC; while (TC--) solve(); }