Problem: At an arcade, Takahashi is playing a game called _RPS Battle_ , which is played as follows:    * The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)   * Each time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):     * R points for winning with Rock;     * S points for winning with Scissors;     * P points for winning with Paper.   * However, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)  Before the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.  The information Takahashi obtained is given as a string T. If the i-th character of T (1 \leq i \leq N) is `r`, the machine will play Rock in the i-th round. Similarly, `p` and `s` stand for Paper and Scissors, respectively.  What is the maximum total score earned in the game by adequately choosing the hand to play in each round?

Submission attempts (in order):
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
p_list=[]
score=0
for i in range(len(t)):
    if i<k:
        if t[i]=='r':
            p_list.appned('p')
            score+=p
        elif t[i]=='s':
            p_list.appned('r')
            score+=r
        else:
            p_list.appned('s')
            score+=s
    else:
        if t[i]=='r':
            if t[i-k]=='p':
                if i+k>=len(t):
                    score+=0
                else:
                    p_list.appned(t[i+k])
            else:
                p_list.appned('p')
                score+=p
        elif t[i]=='s':
            if t[i-k]=='r':
                if i+k>=len(t):
                    score+=0
                else:
                    p_list.appned(t[i+k])
            else:
                p_list.appned('r')
                score+=r
        else:
            if t[i-k]=='s':
                if i+k>=len(t):
                    score+=0
                else:
                    p_list.appned(t[i+k])
            else:
                p_list.appned('s')
                score+=s
print(score)


n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
p_list=[]
score=0
for i in range(len(t)):
    if i<k:
        if t[i]=='r':
            p_list.append('p')
            score+=p
        elif t[i]=='s':
            p_list.append('r')
            score+=r
        else:
            p_list.append('s')
            score+=s
    else:
        if t[i]=='r':
            if p_list[i-k]=='p':
                if i+k>=len(t):
                    p_list.append('a')
                else:
                    p_list.append(t[i+k])
            else:
                p_list.append('p')
                score+=p
        elif t[i]=='s':
            if p_list[i-k]=='r':
                if i+k>=len(t):
                    p_list.append('a')
                else:
                    p_list.append(t[i+k])
            else:
                p_list.append('r')
                score+=r
        else:
            if p_list[i-k]=='s':
                if i+k>=len(t):
                    p_list.append('a')
                else:
                    p_list.append(t[i+k])
            else:
                p_list.append('s')
                score+=s
print(score)

Verdicts: Runtime Error

Accepted