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()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
command= []
mm = []
ans = 0
print(score)




for i in range(N):
    if i <= K-1:
        ans += score[T[i]]
        mm.append(m[T[i]])
        print(mm)
    else:
        if m[T[i]] != mm[i-2]:
            ans += score[T[i]]
            mm.append(m[T[i]])
        else:
            mm.append("")
                 
print(ans)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
command= []
mm = []
ans = 0

for i, t in enumerate(T):
    if t == "r":
      c = "p"
      point = P
    elif t == "s":
      cc ="r" 
      point = R
    elif t == "p":
      c = "s"
      point = P
    
    if (i - K >= 0) and (command[i - K] == c):
        c = ""
        point = 0
    
    ans += point
    command.append(c)
print(ans)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
command= []
mm = []
ans = 0


for i, t in enumerate(T):
    if t == "r":
      command = "p"
      point = P
    elif t == "s":
      command ="r" 
      point = R
    elif t == "p":
      command = "s"
      point = P
    
    if (i - K > 0) and (command[i - K] == command):
        command = ''
        point = 0
    
    ans += point
    command.append(command)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
command= []
mm = []
ans = 0

for i, t in enumerate(T):
    if t == "r":
      c = "p"
      point = P
    elif t == "s":
      cc ="r" 
      point = R
    elif t == "p":
      c = "s"
      point = P
    
    if (i - K >= 0) and (c[i - K] == c):
        c = ''
        point = 0
    
    ans += point
    command.append(c)
print(ans)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
command= []
mm = []
ans = 0


for i, t in enumerate(T):
    if t == "r":
      command = "p"
      point = P
    elif t == "s":
      command ="r" 
      point = R
    elif t == "p":
      command = "s"
      point = P
    
    if (i - K > 0) and (command[i - K] == command):
        command = ''
        point = 0
    
    ans += point
    command.append(command)
print(ans)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
mm = []
ans = 0
print(score)



for i in range(N):
    if i <= K-1:
        ans += score[T[i]]
        mm.append(m[T[i]])
        print(mm)
    else:
        if m[T[i]] != mm[i-2]:
            ans += score[T[i]]
            mm.append(m[T[i]])
        
                 
print(ans)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
command= []
mm = []
ans = 0



for i, t in enumerate(T):
    if t == "r":
      command = "p"
      point = P
    elif t == "s":
      command ="r" 
      point = R
    elif t == "p":
      command = "s"
      point = P
    
    if (i - K >= 0) and (command[i - K] == command):
        command = ''
        point = 0
    
    ans += point
    command.append(command)
print(ans)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
command= []
mm = []
ans = 0


for i, t in enumerate(T):
    if t == "r":
      c = "p"
      point = P
    elif t == "s":
      c ="r" 
      point = R
    elif t == "p":
      c = "s"
      point = S
    
    if (i - K >= 0) and (command[i - K] == c):
        c = ""
        point = 0
    
    ans += point
    command.append(c)
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted