#include <bits/stdc++.h>

#define ll                  long long
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define sz(x)               x.size()
#define all(c)              c.begin(), c.end()
#define ci(X)               ll X; cin>>X
#define cii(X, Y)           ll X, Y; cin>>X>>Y
#define ciii(X, Y, Z)       ll X, Y, Z; cin>>X>>Y>>Z
#define ciiii(W, X, Y, Z)   ll W, X, Y, Z; cin>>W>>X>>Y>>Z
#define shurukiajaye             ll ___T; cin>>___T; while (___T-- > 0)
#define bakchodi      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n)          for(ll i = 0; i < n; i++)
#define fore(i, n)          for(ll i = 1; i <= n; i++)
#define forl(i, l, r)       for(ll i = l; i < r; i++)
#define forr(i, l, r)       for(ll i = l; i >= r; i--)
#define mem0(X)             memset(X, 0, sizeof(X))
#define mem1(X)             memset(X, -1, sizeof(X))
using namespace std;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

ll count(ll n) {
	return (n*(n+1)/2);
}

void solve() {
	string s;
	cin >> s;
	ll n = s.length();
	ll dp[n+1][2];
	dp[n][0] = dp[n][1] = 0;
	forr (i, n-1, 0) {
		if (s[i] == '?') {
			dp[i][0] = dp[i+1][1] + 1;
			dp[i][1] = dp[i+1][0] + 1;
		} else if (s[i] - '0' == 0) {
			dp[i][0] = dp[i+1][1] + 1;
			dp[i][1] = 0;
		} else {
			dp[i][1] = dp[i+1][0]+1;
			dp[i][0] = 0;
		}
	}
	ll ans = 0;
	forn (i, n) {
		ans += max(dp[i][0], dp[i][1]);
	}
	cout << ans << endl;
}

int main() {
	bakchodi;
	#ifndef ONLINE_JUDGE
	freopen("/home/devsebastian/cpp/inout/input.txt", "r", stdin);
	freopen("/home/devsebastian/cpp/inout/output.txt", "w", stdout);
	#endif
	shurukiajaye {
		solve();
	}
	return 0;
}