#C4424. Circular String Rotation

    ID: 47961 Type: Default 1000ms 256MiB

Circular String Rotation

Circular String Rotation

You are given a string \(s\) and an integer \(k\). Your task is to perform a circular left rotation on \(s\) by \(k\) positions. This means moving the first \(k \mod |s|\) characters of \(s\) to the end of the string.

The rotation operation can be mathematically defined as:

[ \text{result} = s[k:] + s[:k] ]

For example, if \(s = \texttt{cba}\) and \(k = 1\), the rotated string will be \(\texttt{bac}\). Similarly, if \(s = \texttt{abcdef}\) and \(k = 2\), the output should be \(\texttt{cdefab}\).

Your program should read the input from stdin and output the result to stdout.

inputFormat

The input consists of two lines:

  • The first line contains the string \(s\).
  • The second line contains an integer \(k\), representing the number of positions to rotate the string.

outputFormat

Output a single line containing the string after performing the circular left rotation by \(k\) positions.

## sample
cba
1
bac