Getting TLE

#include <bits/stdc++.h>
using namespace std;

int main()
{
//write your code here
int t;
cin>>t;
while(t!=0){

bool flag=false;
string s;
cin>>s;
sort(s.begin(),s.end());
for(int i=0;i<s.length();i++){
  int count=0;
   if(s[i]!=s[i+1]){
  for(int j=0;j<s.length();j++){
    if(s[i]==s[j])
    count++;
  }
  if(count>1){
  cout<<s[i]<<"="<<count<<" ";
  flag=true;
  }
}

}
if(flag==false)
cout<<"-1";
cout<<endl;
t=t-1;
}
return 0;
}
How can I reduce time for this( time limit 1 second).
Question posted below.
If possible please provide the code

Efficient approach would be to just create a map of each alphabet and then just increment the count for that particular alphabet.