感觉实质为数学题
#include <iostream>
#include<string>
#include<map>
using namespace std;

int main() {
	string str;
	map<string, int > mymap;
	while (cin >> str) {
		mymap.clear();
		for(int i = 1;i < str.size();i++)
			for (int j = 0; j <= str.size()-i; j++) {
				mymap[str.substr(j, i)]++;
			}
		for (map<string, int>::iterator it = mymap.begin(); it != mymap.end(); it++) {
			if (it->second >= 2)
				cout << it->first << ' ' << it->second << endl;
		}
	}

	return 0;
}