11293 - Caesar's Cipher   

Description

Caesar's cipher is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.

 


The cipher illustrated here uses a left shift of 3,
so that each occurrence of E in the plaintext becomes B in the ciphertext.
(https://en.wikipedia.org/wiki/Caesar_cipher)

 

But a problem of the Caesar's cipher is that in most case, the occurrence each alphabet has its frequency, and some of them are significantly higher than others' in an article. For example, the letter 'E' appears much more than other letters, and the frequency is typically more than 12%. Then there are less 'A' and 'T', which may be 8%. If the frequency of the letters in an article is analysised, one may easily break the Caesar's cipher.

In this problem, you are given an article in ciphertext in each test case. You have to find the most frequent letter in the ariticle, and restore the ariticle from the ciphertext to its plaintext.

 

Hint:

  1. You may have to store the ciphertext lines you get, so you can recover it later.
  2. You can use an array int number[128]={0} to count the occurrences of each letter in the ciphertext. There are uppercases as well as lowercases, and they are treated the same.
  3. Then you find the most frequent letter. Try to shift and turn it to 'E' or 'e'.
  4. Let everything that is not a letter remain the same.
  5. In the sample input, you should find 16 'B's in the ciphertext. So you shift 3 to get the plaintext.

 

Input

The input is a ciphertext.

There are no more than 10 lines in the input, and there are no longer than 100 characters in each line.

Output

Print the plaintext after you break the Caesar's cipher.

Remain all the format (space, newline and non-alphabet characters) the same as the ciphertext.

Sample Input  Download

Sample Output  Download

Tags




Discuss