Hotfix

시간 제한8초메모리 제한1024 MB

요약
문자열이 주어질 때 모든 서로 다른 부분 문자열과 그 등장 횟수를 나열한 출력에서 각 문자의 총 등장 횟수를 구한다.
난이도

어려움10점 중 8점

유형
문자열, 누적 합, 수학, 조합론
정답자
아직 제출이 없습니다

문제

In an earlier contest, contestants had to solve a simple problem. They were given a string and had to print each unique substring of it, along with the number of occurrences it had in the original string. For example AB would print A 1 B 1 AB 1 and AAA would print A 3 AA 2 AAA 1.

When copying over this problem for reuse in this contest, several mistakes were made. The input constraints were changed significantly, making the problem absolutely impossible! Luckily this was partially cancelled out by the output validator being mangled as well. Now instead of checking for absolute correctness it only requires the number of occurrences of each character in the output to be correct. With a quick hotfix of applying run length encoding to the output, the problem was finally solvable again and the contest could continue on as planned. Right?

입력

The input contains a single string of length at least 11 and at most 10610^6. It contains only ASCII upper and lower case characters. This string is then followed by a single newline character.

출력

For each non-whitespace character that appears a non-zero number of times in the output of the problem described above, print it along with its number of occurrences on a single line, separated by a space. Print the lines ordered by ascending values of the ASCII characters.

예제2

  1. 예제 1

    입력
    ABC
    
    예상 출력
    1 6
    A 3
    B 4
    C 3
    
  2. 예제 2

    입력
    aaaab
    
    예상 출력
    1 6
    2 1
    3 1
    4 1
    a 20
    b 5