#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, i, j, n, t, m;     cin >> t;     while (t--) {       string s;       cin >> s;       n = s.size();       vector<long long> ans;       long long count = 0;       for (i = 0; i < n; i++) {         if (s[i] ==  1 )           count++;         else {           ans.push_back(count);           count = 0;         }       }       if (count != 0) ans.push_back(count);       long long sum = 0;       sort(ans.rbegin(), ans.rend());       for (i = 0; i < ans.size(); i++) {         if (i % 2 == 0) sum += ans[i];       }       cout << sum << endl;     }   }   