/**
 * Given a list of music tempos and a shift value, this function shifts the tempos to left or right based on the shift value.
 *
 * @param tempoList A list of music tempos.
 * @param shiftValue The value by which the tempos need to be shifted. If positive, they should be shifted to the right;
 *                   if negative, they should be shifted to the left.
 * @return The modified music tempo list after the shift.
 */
fun musicTempoShift(tempoList: List<Int>, shiftValue: Int): List<Int> {

    if (tempoList.any { it !is Int }) {
        return listOf()
    }

    if (shiftValue !is Int) {
        return listOf()
    }

    return when {
        shiftValue > 0 -> tempoList.takeLast(shiftValue) + tempoList.dropLast(shiftValue)
        shiftValue < 0 -> tempoList.takeLast(-shiftValue) + tempoList.dropLast(-shiftValue)
        else -> tempoList
    }
}
/**
 * Given a list of music tempos and a shift value, this function shifts the tempos to left or right based on the shift value.
 *
 * @param tempoList A list of music tempos.
 * @param shiftValue The value by which the tempos need to be shifted. If positive, they should be shifted to the right;
 *                   if negative, they should be shifted to the left.
 * @return The modified music tempo list after the shift.
 */
fun musicTempoShift(tempoList: List<Int>, shiftValue: Int): List<Int> {
/**
 * Given a list of music tempos and a shift value, this function shifts the tempos to left or right based on the shift value.
 *
 * @param tempoList A list of music tempos.
 * @param shiftValue The value by which the tempos need to be shifted. If positive, they should be shifted to the right;
 *                   if negative, they should be shifted to the left.
 * @return The modified music tempo list after the shift.
 */
fun musicTempoShift(tempoList: List<Int>, shiftValue: Int): List<Int> {

    if (tempoList.any { it !is Int }) {
        return listOf()
    }

    if (shiftValue !is Int) {
        return listOf()
    }

    return when {
        shiftValue > 0 -> tempoList.takeLast(shiftValue) + tempoList.dropLast(shiftValue)
        shiftValue < 0 -> tempoList.takeLast(-shiftValue) + tempoList.dropLast(-shiftValue)
        else -> tempoList
    }
}