TnT/Multi_CodeNet4Repair huggingface dataset:
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):
# coding: utf-8
# Your code here!
def pin(type=int):
    return map(type,input().split())
N,K =pin()
R,S,P =pin()
T, =pin(str)



winT = []
win = "rpsr"
for i in range(N):
    for j in range(3):
        if T[i] ==win[j]:
            winT.append(win[j+1])
print(winT)


print(K,"個前を使えない")

for i in range (N-K):
    if winT[i] == winT[i+K]:
        winT[i+K] = "0"
        print(i)
print(winT)

ans=0
for i in range(N):
    if winT[i]=="p":
        ans+=P
    elif winT[i]=="r":
        ans+=R
    elif winT[i]=="s":
        ans+=S
print(ans)

# coding: utf-8
# Your code here!
def pin(type=int):
    return map(type,input().split())
N,K =pin()
R,S,P =pin()
T, =pin(str)



winT = []
win = "rpsr"
for i in range(N):
    for j in range(3):
        if T[i] ==win[j]:
            winT.append(win[j+1])
#print(winT)




for i in range (N-K):
    if winT[i] == winT[i+K]:
        winT[i+K] = "0"
        #print(i)
#print(winT)

ans=0
for i in range(N):
    if winT[i]=="p":
        ans+=P
    elif winT[i]=="r":
        ans+=R
    elif winT[i]=="s":
        ans+=S
print(ans)

Verdicts: Wrong Answer

Accepted
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()

mp_score = {"r": P, "s": R, "p": S}

lines = [""] * K
for ix in range(K):
    for t in range(len(T)):
        if t%K == ix:
            lines[ix] += T[t]

print(lines)
ans = 0
for l in lines:
    before = ""
    for c in l:
        if before == c:
            before = ""

        else:
            ans += mp_score[c]
            before = c

print(ans)
        

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

mp_score = {"r": P, "s": R, "p": S}

lines = [""] * K
for ix in range(len(T)):
    lines[ix%K] += T[ix]

ans = 0
for l in lines:
    before = ""
    for c in l:
        if before == c:
            before = ""

        else:
            ans += mp_score[c]
            before = c

print(ans)
        

Verdicts: Internal error

Accepted
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()
scoremap = {
    "r": p,
    "p": s,
    "s": r
}
t_ls = [scoremap[i] for i in t]

def best(ls: list):
    print(ls)
    for i in range(len(ls) - 1):
        if ls[i] == ls[i + 1]:
            ls[i + 1] = 0
    print(ls)
    num=sum(ls)
    return num

total=0
for i in range(k):
    ls = t_ls[i::k]
    total+=best(ls)
print(total)

n, k = map(int,input().split())
r, s, p = map(int, input().split())
t = input()
scoremap = {
    "r": p,
    "p": s,
    "s": r,
    "-": 0
}
t=[i for i in t]

def best(ls: list):
    for i in range(len(ls) - 1):
        if ls[i] == ls[i + 1]:
            ls[i + 1] = '-'
    num=sum([scoremap[i] for i in ls])
    return num

total=0
for i in range(k):
    ls = t[i::k]
    total+=best(ls)
print(total)

Verdicts: Wrong Answer

Accepted
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()

dic = {"r":"p" , "s":"r" , "p":"s"}
ANS = []

for i in range(N):
    ANS.append(dic[T[i]])
    
ans = "".join(ANS)

VANISH = []
    
for i in range(N-K):
    if ans[i] == ans[i+K]:
        VANISH.append(ans[i])

print(VANISH)
        
if N - (2*K) > 0:
    for i in range(N - (2*K)):
        if ans[i] == ans[i+(2*K)]:
            VANISH.remove(ans[i])
            
print(VANISH)
            
vanish = "".join(VANISH)
        
point = ((ans.count("r")-vanish.count("r"))*R + (ans.count("s")-vanish.count("s"))*S + (ans.count("p")-vanish.count("p"))*P)

print(point)

N , K = map(int , input().split())
R , S , P = map(int , input().split())
T = input()

dic = {"r":"p" , "s":"r" , "p":"s"}
ANS = []

for i in range(N):
    ANS.append(dic[T[i]])
    
ans = "".join(ANS)

for i in range(K , N):
    if ans[i] == ans[i-K]:
        ans = ans[:i] + "X" + ans[i+1:]
        
point = ans.count("r")*R + ans.count("s")*S + ans.count("p")*P

print(point)

Verdicts: Runtime Error

Accepted
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 = list(input())

def score(s):
  if s == 'r':
    output = P
  elif s == 's':
    output = R
  else:
    output = S
  return output

k_list = [0]*K 
answer = 0
for i in range(K):
  s = T[i]
  ind = i%K
  k_list[ind] = s
  answer += score(s)
  print(answer, k_list)
for j in range(K,N):
  s = T[j]
  ind = j%K
  if s == T[j-K] and k_list[ind] == s:
    k_list[ind] = 0
  elif s == T[j-K] and k_list[ind] != s:
    k_list[ind] = s
    answer += score(s)
  else:
    k_list[ind] = s
    answer += score(s)
  print(answer, k_list) 

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

def score(s):
  if s == 'r':
    output = P
  elif s == 's':
    output = R
  else:
    output = S
  return output

k_list = [0]*K 
answer = 0
for i in range(K):
  s = T[i]
  ind = i%K
  k_list[ind] = s
  answer += score(s)
for j in range(K,N):
  s = T[j]
  ind = j%K
  if s == T[j-K] and k_list[ind] == s:
    k_list[ind] = 0
  elif s == T[j-K] and k_list[ind] != s:
    k_list[ind] = s
    answer += score(s)
  else:
    k_list[ind] = s
    answer += score(s)
print(answer) 

Verdicts: Wrong Answer

Accepted
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()



T_list = []
# N_list = list(range(N))

ans = 0

for i in range(N):
    if T[i] == 'r':
        
        if i < K or T_list[i - K] != 'p':
            ans += P
            T_list.append('p')

        
        elif i != N-1:
            
            if T[i + 1] == 'r' or T[i + 1] == 'p':
                T_list.append('r')
            
            else:
                T_list.append('s')

    elif T[i] == 's':
        
        if i < K or T_list[i - K] != 'r':
            ans += R
            T_list.append('r')

        
        elif i != N-1:
            
            if T[i + 1] == 'p' or T[i + 1] == 'r':
                T_list.append('s')
            
            else:
                T_list.append('p')

    elif T[i] == 'p':
        
        if i < K or T_list[i - K] != 's':
            ans += S
            T_list.append('s')

        
        elif i != N-1:
            
            if T[i + 1] == 's' or T[i + 1] == 'p':
                T_list.append('p')
            
            else:
                T_list.append('r')


N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()



# T_list = []
# N_list = list(range(N))

ans = 0

for i in range(N):
    if T[i] == 'r':
        
        if i < K or T[i - K] != 'r':
            ans += P
        else:
            T = T[:i] + 'x' + T[i + 1:]

    elif T[i] == 's':
        
        if i < K or T[i - K] != 's':
            ans += R
        else:
            T = T[:i] + 'x' + T[i + 1:]

    elif T[i] == 'p':
        
        if i < K or T[i - K] != 'p':
            ans += S
        else:
            T = T[:i] + 'x' + T[i + 1:]

print(ans)

Verdicts: Wrong Answer

Accepted
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 = [int(x) for x in input().split()]
r, s, p = [int(x) for x in input().split()]

win_point = {
    'r': r,
    's': s,
    'p': p,
}

next_hands = {
    'r': ['s', 'p'],
    's': ['r', 'p'],
    'p': ['r', 's'],
}

enemy_hands = input()


def can_win(enemy_hand, my_hands):
    
    if enemy_hand == 'r' and 'p' in my_hands:
        return True, 'p'
    if enemy_hand == 's' and 'r' in my_hands:
        return True, 'r'
    if enemy_hand == 'p' and 's' in my_hands:
        return True, 's'

    
    return False, None


point = 0

for index in range(K):
    now_hands = ['r', 'p', 's']
    for i in range(index, N, K):
        win, hand = can_win(enemy_hands[i], now_hands)

        if win:
            point += win_point[hand]
            now_hands = next_hands[hand]
        else:
            
            
            now_hans = ['r', 'p', 's']

print(point)


N, K = [int(x) for x in input().split()]
r, s, p = [int(x) for x in input().split()]

win_point = {
    'r': r,
    's': s,
    'p': p,
}

next_hands = {
    'r': ['s', 'p'],
    's': ['r', 'p'],
    'p': ['r', 's'],
}

enemy_hands = input()


def can_win(enemy_hand, my_hands):
    
    if enemy_hand == 'r' and 'p' in my_hands:
        return True, 'p'
    if enemy_hand == 's' and 'r' in my_hands:
        return True, 'r'
    if enemy_hand == 'p' and 's' in my_hands:
        return True, 's'

    
    return False, None


point = 0

for index in range(K):
    now_hands = ['r', 'p', 's']
    for i in range(index, N, K):
        win, hand = can_win(enemy_hands[i], now_hands)

        if win:
            point += win_point[hand]
            now_hands = next_hands[hand]
        else:
            
            
            now_hands = ['r', 'p', 's']

print(point)


Verdicts: Wrong Answer

Accepted
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())
S = input()
ans = 0
for i in range(k):
    Ssep = S[i::k] 
    flg = False
    for j in range(len(Ssep)):
        if j >= 1 and Ssep[j] == Ssep[j-1] and not flg:
            flg = True
            continue
        if Ssep[j] == "r":
            ans += p
        if Ssep[j] == "s":
            ans += r
        if Ssep[j] == "p":
            ans += s
        flg = False
    print(Ssep,ans)
print(ans)

n,k = map(int, input().split())
r,s,p = map(int, input().split())
S = input()
ans = 0
for i in range(k):
    Ssep = S[i::k] 
    flg = False
    for j in range(len(Ssep)):
        if j >= 1 and Ssep[j] == Ssep[j-1] and not flg:
            flg = True
            continue
        if Ssep[j] == "r":
            ans += p
        if Ssep[j] == "s":
            ans += r
        if Ssep[j] == "p":
            ans += s
        flg = False
print(ans)

Verdicts: Internal error

Accepted
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 = list(input())

o = ''
for j in range(k):
    o1 = (''.join(t[j::k]))
    print(o1)
    o2 = o1.replace('rr', 'r')
    print(o2)
    o3 = o2.replace('pp', 'p')
    print(o3)
    o4 = o3.replace('ss', 's')
    print(o4)
    o += o4

print(o)
x = 0
for i, h in enumerate(o):
    if h == 'r':
        x += p
    elif h == 's':
        x += r
    else:
        x += s

print(x)

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

o = ''
for j in range(k):
    o += (''.join(t[j::k])).replace('rr', 'r').replace(
        'pp', 'p').replace('ss', 's')

x = 0
for i, h in enumerate(o):
    if h == 'r':
        x += p
    elif h == 's':
        x += r
    else:
        x += s

print(x)


Verdicts: Internal error

Accepted
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=tuple(input())
te=[]
ans=0
for i in range(k):
  if t[i]=='r':
    ans+=P
    te.append('p')
  elif t[i]=='s':
    ans+=R
    te.append('r')
  else:
    ans+=S
    te.append('s')
for j in range(k,n):
  if t[j]=='r':
      if te[j-k]!='p' or (te[j-k]=='p' and j+k>=n):
        ans+=P
        te.append('p')
      else:
        te.append('0')
  elif t[j]=='s':
      if te[j-k]!='r' or (te[j-k]=='r' and j+k>=n):
        ans+=R
        te.append('r')
      else:
        te.append('0')
  elif t[j]=='p':
      if te[j-k]!='s' or (te[j-k]=='s' and j+k>=n):
        ans+=S
        te.append('s')
      else:
        te.append('0')
print(ans)
print(te)

n,k=map(int, input().split())
R,S,P=map(int, input().split())
t=list(input())
aite=[]
tetuple=('r','s','p')
def kati(te,ans):
  if te=='r':
    ans+=P
  elif te=='s':
    ans+=R
  else:
    ans+=S
  return ans
for _ in range(k):
  aite.append([])
for i in range(n):
  aite[i%k].append(t[i])
ans=0
for i in range(k):
  ans=kati(aite[i][0],ans)
  for j in range(1,len(aite[i])):
    if aite[i][j]!=aite[i][j-1]:
      ans=kati(aite[i][j],ans)
    else:
      for m in range(3):
        if j!=len(aite[i])-1 and aite[i][j]==aite[i][j+1]==tetuple[m]:
          aite[i][j]=tetuple[(m+1)%3]
        elif j!=len(aite[i])-1 and aite[i][j]!=aite[i][j+1] and aite[i][j]!=tetuple[m] and aite[i][j+1]!=tetuple[m]:
          aite[i][j]=tetuple[m]
print(ans)

Verdicts: Wrong Answer

Accepted
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())
s,p,r=map(int,input().split())
f={'s':s,'p':p,'r':r}
t=str(input())
ans=0
for i in range(k):
  a=i+k
  last=t[i]
  ans+=f[last]
  while a<n-k:
    if t[a-k]==last:
      if t[a+k]==last:
        if last=='s':
          last='r'
        else:
          last='s'
      else:
        if last=='s':
          if t[a+k]=='r':
            last='p'
          else:
            last='r'
        elif last=='r':
          if t[a+k]=='s':
            last='p'
          else:
            last='s'
        else:
          if 
            

      
      
      
      
      






#abc149-d
n,k=map(int,input().split())
s,p,r=map(int,input().split())
f={'s':s,'p':p,'r':r}
t=str(input())
ans=0
for i in range(k):
    a=i+k
    last=t[i]
    ans+=f[last]
    while a<n-k:
        if t[a]==last:
            if t[a+k]==last:
                if last=='s':
                    last='r'
                else:
                    last='s'
            else:
                if last=='s':
                    if t[a+k]=='r':
                        last='p'
                    else:
                        last='r'
                elif last=='r':
                    if t[a+k]=='s':
                        last='p'
                    else:
                        last='s'
                else:
                    if t[a+k]=='r':
                        last='s'
                    else:
                        last='r'
        else:
            last=t[a]
            ans+=f[last]
        a+=k
    
    if a<n:
        if t[a]!=last:
            ans+=f[t[a]]

print(ans)

Verdicts: Runtime Error

Accepted
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())
rsp = list(map(int, input().split()))
t = input()
ans = 0
d = {'r': 2, 's':0, 'p': 1}
for c in t:
  ans += rsp[d[c]]
for i in range(k):
  prev = t[i]
  seq = 1
  for j in range(i+k, n, k):
    if t[j] == prev:
      seq += 1
    else:
      ans -= rsp[d[prev]] * (seq // 2)
      prev = t[j]
      seq = 1
    ans -= rsp[d[prev]] * (seq // 2)
print(ans)    

n, k = map(int, input().split())
rsp = list(map(int, input().split()))
t = input()
ans = 0
d = {'r': 2, 's':0, 'p': 1}
for c in t:
  ans += rsp[d[c]]
for i in range(k):
  prev = t[i]
  seq = 1
  for j in range(i+k, n, k):
    if t[j] == prev:
      seq += 1
    else:
      ans -= rsp[d[prev]] * (seq // 2)
      prev = t[j]
      seq = 1
  ans -= rsp[d[prev]] * (seq // 2)
print(ans)

Verdicts: Wrong Answer

Accepted
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()

winners = [R, S, P]
min_win = min(winners)
min_win_index = winners.index(min_win)

if min_win_index == 0:
    min_winner = 'r'
elif min_win_index == 1:
    min_winner = 's'
else:
    min_winner = 'p'

mapping = {'r': 'p', 's': 'r', 'p': 's'}

ans = 0
done = []
for t in T:
    win = mapping.get(t)
    if len(done) >= K:
        if done[len(done) - K] == win:
            if len(T) > len(done) + K and mapping.get(T[len(done) + K]) != min_winner:
                done.append(min_winner)
            else:
                done.append(win)
            continue
    if win =='r':
        ans += R
    elif win == 's':
        ans += S
    else:
        ans += P
    done.append(win)
print(ans)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

from collections import Counter
winners_nums = sorted([R, S, P])
winners = Counter({R:'r', S: 's', P: 'p'})

min_winner = winners.get(winners_nums[0])
mapping = {'r': 'p', 's': 'r', 'p': 's'}

ans = 0
done = []
for t in T:
    win = mapping.get(t)
    if len(done) >= K:
        if done[len(done) - K] == win:
            hands = set(['r', 's', 'p']) - set([win])
            if len(T) > len(done) + K:
                not_next = mapping.get(T[len(done) + K])
                hands -= set([not_next])
            done.append(hands.pop())
            continue
    if win =='r':
        ans += R
    elif win == 's':
        ans += S
    else:
        ans += P
    done.append(win)
print(ans)

Verdicts: Wrong Answer

Accepted
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 = str(input())
janken = {"r":"p","s":"r","p":"s"}
point = {"r":P,"s":R,"p":S}
kekka = []
ans = 0

for i in range(K):
    kekka.append(janken[T[i]]) 
    ans += point[T[i]]

for i in range(K,N):
    if janken[T[i]] == kekka[i-K]:
        kekka.append(T[i])
    else:
        kekka.append(janken[T[i]])
        ans += point[T[i]]

N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = str(input())
janken = {"r":"p","s":"r","p":"s"}
point = {"r":P,"s":R,"p":S}
kekka = []
ans = 0

for i in range(K):
    kekka.append(janken[T[i]]) 
    ans += point[T[i]]

for i in range(K,N):
    if janken[T[i]] == kekka[i-K] and kekka[i-K] != T[i-K]: 
        kekka.append(T[i])
    else:
        kekka.append(janken[T[i]])
        ans += point[T[i]]

print(ans)

Verdicts: Wrong Answer

Accepted
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 = list(input())


ban = []
st = []
score1 = 0
score2 = 0

for i in t:
    if i == 'r' :
        st.append('p')
    elif i == 's' :
        st.append('r')
    else:
        st.append('s')
            
def score(l, m):
    c = 0       
    for i in range(len(l)):
        if l[i] != m[i]:
            if l[i] == 'r' :
                c += r
            elif l[i] == 's' :
                c += s
            elif l[i] == 'p' :
                c += p
    return c
           
                
st1 = st
for i in range(k):
    st1_sub = st1[i::k]
    st2_sub = st2[i::k]
    t_sub = t[i::k]
    
    for j in range(len(st1_sub)-1):
        if st1_sub[j+1] == st1_sub[j]:
            st1_sub[j+1] = t_sub[j+1]
            st2_sub[j] = t_sub[j]
    if score(st1_sub, t_sub) > score(st2_sub, t_sub):
        st[i::k] = st1_sub
    else:
        st[i::k] = st2_sub

print(score(st,t))




n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())


st = [0 for _ in range(n)]
for i in range(n):
    if i < k: 
        if t[i] == 'r' :
            st[i] = 'p'
        elif t[i] == 's' :
            st[i] = 'r'
        elif t[i] == 'p':
            st[i] = 's'
    else:
        if t[i] == 'r' and st[i-k] != 'p':
            st[i] = 'p'
        elif t[i] == 's' and st[i-k] != 'r':
            st[i] = 'r'
        elif t[i] == 'p'and st[i-k] != 's':
            st[i] = 's'
        
score = 0
for i in st:
    if i == 'r' :
        score += r
    elif i == 's' :
        score += s
    elif i == 'p' :
        score += p

print(score)
    
    

Verdicts: Runtime Error

Accepted
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):
def main():
  [n, k] = [int(i) for i in input().split()]
  [r, s, p] = [int(i) for i in input().split()]
  T =  input()
  
  my = T.replace("r", "hoge").replace("s", "r").replace("p", "s").replace("hoge", "p") 
  for i in range(k, n):
    if my[i] == my[i-k]:
      my = my[:i] + "l" + my[i+1:]  
  print(my)
  print(my.count("r")* r + my.count("s")*s + my.count("p")* p)
  
if __name__ == "__main__":
  main()

def main():
  [n, k] = [int(i) for i in input().split()]
  [r, s, p] = [int(i) for i in input().split()]
  T =  input()
  
  my = T.replace("r", "hoge").replace("s", "r").replace("p", "s").replace("hoge", "p") 
  for i in range(k, n):
    if my[i] == my[i-k]:
      my = my[:i] + "l" + my[i+1:]  
  print(my)
  print(my.count("r")* r + my.count("s")*s + my.count("p")* p)
  
if __name__ == "__main__":
  main()

def main():
  [n, k] = [int(i) for i in input().split()]
  [r, s, p] = [int(i) for i in input().split()]
  T =  input()
  
  my = T.replace("r", "hoge").replace("s", "r").replace("p", "s").replace("hoge", "p") 
  for i in range(k, n):
    if my[i] == my[i-k]:
      my = my[:i] + "l" + my[i+1:]  

  print(my.count("r")* r + my.count("s")*s + my.count("p")* p)
  
if __name__ == "__main__":
  main()

Verdicts: Internal error

Internal error

Accepted
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 = str(input())
point = []

for i in range(n):
    if t[i] == "r":
        point.append(p)
    elif t[i] == "s":
        point.append(r)
    else:
        point.append(s)

for i in range(k, n):
    if t[i-k] == t[i]:
        point[i] = 0

print(sum(point))

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
f = [0] * n
point = []
 
for i in range(n):
    if t[i] == "r":
        point.append(p)
    elif t[i] == "s":
        point.append(r)
    else:
        point.append(s)
 
for i in range(k, n):
    if t[i-k] == t[i] and f[i-k] == 0:
        point[i] = 0
        f[i] = 1
 
print(sum(point))

Verdicts: Wrong Answer

Accepted
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())
point = [int(i) for i in input().split()]
janken = input()
print(janken)

for i in range(k,n):
  if janken[i] == janken[i-k]:
    janken= janken[0:i]+'0'+janken[i+1:n]
print(janken)

count=0

for i in range(n):
  if janken[i] == 'r':
    count += point[2]
  elif janken[i] == 's':
    count += point[0]
  elif janken[i] == 'p':
    count += point[1]

print(count)

n,k=map(int, input().split())
point = [int(i) for i in input().split()]
janken = input()

for i in range(k,n):
  if janken[i] == janken[i-k]:
    janken= janken[0:i]+'0'+janken[i+1:n]

count=0

for i in range(n):
  if janken[i] == 'r':
    count += point[2]
  elif janken[i] == 's':
    count += point[0]
  elif janken[i] == 'p':
    count += point[1]

print(count)

Verdicts: Internal error

Accepted
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()

d = {"s":r, "p":s, "r":p}
score = 0
for idx in range(k):
    List = []
    for i in range(n):
        if idx+i*k > n-1:
            break
        else:
           List.append(t[idx+i*k])
    print(List)
    not_liset = True
    tmp = List[0]
    score += d[tmp]
    for i in range(1, len(List)):
        if tmp == List[i] and not_liset:
            not_liset = False
        else:
            score += d[List[i]]
            not_liset = True
        tmp = List[i]
print(score)

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

d = {"s":r, "p":s, "r":p}
score = 0
for idx in range(k):
    List = []
    for i in range(n):
        if idx+i*k > n-1:
            break
        else:
           List.append(t[idx+i*k])
    not_liset = True
    tmp = List[0]
    score += d[tmp]
    for i in range(1, len(List)):
        if tmp == List[i] and not_liset:
            not_liset = False
        else:
            score += d[List[i]]
            not_liset = True
        tmp = List[i]
print(score)

Verdicts: Wrong Answer

Accepted
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_map = {
    "r": p,
    "p": s,
    "s": r,
    "n": 0,
}
t = list(t)
ans = 0
for i in range(k):
    skipped_list = t[i::k]
    print(f"{skipped_list}===")
    for j, c in enumerate(skipped_list[1:]):
        if skipped_list[j] == c:
            skipped_list[j+1] = "n"
    for c in skipped_list:
        ans += score_map[c]
print(ans)


n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
score_map = {
    "r": p,
    "p": s,
    "s": r,
}
score = [0] * n
for i, c in enumerate(t):
    score[i] = score_map[c]
print(score)
for i, c in enumerate(score[k:]):
    print(c, score[i])
    if score[i] == c:
        score[i+k] = 0
print(score, sum(score))


n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
score_map = {
    "r": p,
    "p": s,
    "s": r,
    "n": 0,
}
t = list(t)
ans = 0
for i in range(k):
    skipped_list = t[i::k]
    for j, c in enumerate(skipped_list[1:]):
        if skipped_list[j] == c:
            skipped_list[j+1] = "n"
    for c in skipped_list:
        ans += score_map[c]
print(ans)


Verdicts: Runtime Error

Wrong Answer

Accepted