#K58377. Rotate List
Rotate List
Rotate List
You are given a list of integers and a non-negative integer k. Your task is to rotate the list to the right by k steps. In other words, each element in the list is shifted to the right by k positions. If k is larger than the length of the list (n), then the effective rotation is given by \(k \mod n\).
Example: For the list [1, 2, 3, 4, 5, 6, 7] with k = 3, the resulting rotated list is [5, 6, 7, 1, 2, 3, 4].
Your solution should read from standard input and write the result to standard output.
inputFormat
The first line contains two integers, n and k, where n is the number of elements in the list and k is the number of positions to rotate the list.
The second line contains n space-separated integers representing the list.
outputFormat
Output the rotated list as a sequence of space-separated integers on a single line.
## sample7 3
1 2 3 4 5 6 7
5 6 7 1 2 3 4