#include #define pr(x) cout << #x << "= " << x << " " ; #define pl(x) cout << #x << "= " << x << endl; #define ll __int64 using namespace std; //typedef long long ll; #define mst(ss,b) memset(ss,b,sizeof(ss)); #define For(i,j,n) for(int i=j;i<=n;i++) template void read(T&num) { char CH; bool F=false; for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar()); for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar()); F && (num=-num); } int stk[70], tp; template inline void print(T p) { if(!p) { puts("0"); return; } while(p) stk[++ tp] = p%10, p/=10; while(tp) putchar(stk[tp--] + '0'); putchar('\n'); } const int dx[] = {0, 0, 1, -1}; const int dy[] = {1, -1, 0, 0}; const ll mod=1e9+7; const double pi=acos(-1.0); const int inf=0x3f3f3f3f; //const ll inf= 0x3f3f3f3f3f3f3f3fLL; const int N=3e5+10; const int maxn=1e3+20; const double eps=1e-12; int main(){ /* std::ios::sync_with_stdio(false); std::cin.tie(0);*/ /* #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif*/ int t; scanf("%d",&t); while(t--){ string s; ll ans=0; cin>>s; int n=s.size(); ll cnt=0; for(int i=0; i0)ans+=cnt*(cnt+1)/2; printf("%I64d\n",ans); } return 0; }