#include <iostream> using namespace std; void _measure(int index, string str) { char c = str[index]; // format of output cout << c << ":" << index; for (int i = index + 1; i < str.size(); i++) { if (str[i] == c) cout << "," << c << ":" << i; } cout << endl; } int main() { string str; while (cin >> str) { // measure // record the measured char string visited = ""; for (int i = 0; i < str.size(); i++) { if (visited.find(str[i]) == string::npos && str.substr(i+1).find(str[i]) != string::npos) { // need to be measured : haven't be visited and have other repeat elements visited += str[i]; _measure(i, str); } } } }