#include <bits/stdc++.h>
using namespace std;
#define int long long
#define nline "\n"
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

class Solution{

private:
 
 
public:
  

 
 
 void solve()
 {
   string s;
   cin>>s;
   int n=s.length();
   vector<vector<int>> dp(n,vector<int>(2));
  if(s[0]=='?')
   {
    dp[0][1]=1,dp[0][0]=1;
   }
   else if(s[0]=='0')
{
    dp[0][0]=1;
    dp[0][1]=0;
} else{
  dp[0][1]=1;
  dp[0][0]=0;
}


   for( int i=1;i<n;i++)
   {
      if(s[i]=='?')
      {
        dp[i][0]=1+dp[i-1][1];
        dp[i][1]=1+dp[i-1][0];
      }
      else if(s[i]=='1')
      {

        dp[i][1]=1+dp[i-1][0];
        
      }else{
        dp[i][0]=1+dp[i-1][1];
      
      }
   }

  int ans=0;
   for( int i=0;i<n;i++)
{
   ans+=max(dp[i][0],dp[i][1]);
}
cout<<ans<<nline;
   
 }
     
 
};
 
int32_t main()
{
     FAST; Solution sol;
// #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
// #endif
int t;
 cin>>t;
 while(t--)
{
  sol.solve();
}
 
 
    
  return 0;
}