#include <iostream>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
const int mod=1e9 + 7;
int T, n ;
char s[maxn];
ll dp[maxn][3];
int main(){
    scanf("%d",&T);
    while(T--){

        scanf("%s",s + 1);
        n = strlen(s + 1);
        for(int i = 0; i <= n; i ++){
            for(int j = 0; j <= 1; j ++){
                dp[i][j] = 0;
            }
        }
        //dp[0][0] = dp[0][1] = 1;
        s[0] = '?';
        for(int i = 1; i <= n; i ++){
            if(s[i] == '0'){
                dp[i][0] += dp[i - 1][1] + 1;
                dp[i][1] = 0;
            }
            if(s[i] == '1'){
                dp[i][1] += dp[i - 1][0] + 1;
                dp[i][0] = 0;
            }
            if(s[i] == '?'){
                dp[i][0] += dp[i - 1][1] + 1;
                dp[i][1] += dp[i - 1][0] + 1;
            }
           // printf ("%d %lld %lld\n",i , dp[i][0],dp[i][1]);
        }
        ll ans = 0;
        for(int i = 1; i <= n; i ++){
            ans += max(dp[i][0] , dp[i][1]);
        }
        printf ("%lld\n",ans);

    }

}

