while True: try: inp=input().strip() lenth=len(inp) dict1={} for i in range(1,lenth+1): for j in range(lenth-i+1): index=inp[j:j+i] if index not in dict1: dict1[index]=1 else: dict1[index]+=1 dict1=sorted(dict1.items(),key=lambda x:x[0]) for i in dict1: if i[1]>1: print(i[0]+' '+str(i[1])) except: break
#既然全部循环查找所有的子串,就不使用字符串的count()方法了 while True: try: string = input() stringLen = len(string) result = {} for i in range(stringLen): for j in range(i+1,stringLen+1): tempSub = string[i:j] if tempSub not in result: result[tempSub] = 1 else: result[tempSub] += 1 result = list(filter(lambda x:x[1] != 1,result.items())) result.sort(key=lambda x:x[0]) for i in result: print("%s %d"%(i[0],i[1])) except Exception: break
try: while 1: table = {} s = raw_input() L = len(s) for i in xrange(L): for j in xrange(i + 1, L + 1): current = s[i:j] if not current in table: table[current] = 1 else: table[current] += 1 result = sorted(filter(lambda x:x[1] != 1, table.items()),key=lambda x:x[0]) for u, v in result: print u, v except: pass