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):
import math
import sys

n, k = map(int, sys.stdin.readline().rstrip().split())
r, s, p = map(int, sys.stdin.readline().rstrip().split())
t = sys.stdin.readline().rstrip()
ans = 0
sim = []
for i, ti in enumerate(t):
    if ti == 'r':
        if i >= k and sim[i - k] == 'p':
            sim.append('x')
        else:
            ans += p
            sim.append('p')
    elif ti == 's':
        if i >= k and sim[i - k] == 'r':
            sim.append('x')
        else:
            ans += r
            sim.append('r')
    else:
        if i >= k and sim[i - k] == 's':
            sim.append('x')
        else:
            ans += s
            sim.append('s')
print(sim)
print(ans)

import math
import sys

n, k = map(int, sys.stdin.readline().rstrip().split())
r, s, p = map(int, sys.stdin.readline().rstrip().split())
t = sys.stdin.readline().rstrip()
ans = 0
sim = []
for i, ti in enumerate(t):
    if ti == 'r':
        if i >= k and sim[i - k] == 'p':
            sim.append('x')
        else:
            ans += p
            sim.append('p')
    elif ti == 's':
        if i >= k and sim[i - k] == 'r':
            sim.append('x')
        else:
            ans += r
            sim.append('r')
    else:
        if i >= k and sim[i - k] == 's':
            sim.append('x')
        else:
            ans += s
            sim.append('s')
# print(sim)
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())
T=''.join(list(reversed(T)))

print(T)
d={}

for j in range(N):
    if T[j]=='r':
        d[j]=p
    elif T[j]=='s':
        d[j]=r
    else:
        d[j]=s

for i in range(N):
    if i-K in d:
        if d[i]==d[i-K]:
            d[i]=0

score=0

for _,val in d.items():
    score+=val

print(score)

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

a=[[] for i in range(k)]
for i in range(n):
    a[i%k].append(T[i])

d={'r':p,'s':r,'p':s}
score=0
for j in range(k):
    b=a[j]
    flg=0
    for l in range(len(b)):
        if l==0:
            score+=d[b[l]]
        else:
            if b[l-1]==b[l] and flg==0:
                flg=1
                continue
            elif b[l-1]==b[l] and flg==1:
                score+=d[b[l]]
            elif b[l-1]!=b[l]:
                score+=d[b[l]]
            flg=0
print(score)




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):
#D
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())


ans = 0
for i in range(n):
    if t[i] == "r":
        if i >= k and t[i - k] == "r":
            t[i] = 'm'
        else:
            ans += p
    if t[i] == "t":
        if i >= k and t[i - k] == "t":
            t[i] = 'm'
        else:
            ans += r
    if t[i] == "p":
        if i >= k and t[i - k] == "p":
            t[i] = 'm'
        else:
            ans += s
print(ans)


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

ans = 0
for i in range(n):
    if t[i] == "r":
        if i >= k and t[i - k] == "r":
            t[i] = 'm'
        else:
            ans += p
    if t[i] == "t":
        if i >= k and t[i - k] == "t":
            t[i] = 'm'
        else:
            ans += r
    if t[i] == "p":
        if i >= k and t[i - k] == "p":
            t[i] = 'm'
        else:
            ans += s
print(ans)

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


ans = 0
for i in range(n):
    if t[i] == "r":
        if i >= k and t[i - k] == "r":
            t[i] = 'm'
        else:
            ans += p
    if t[i] == "s":
        if i >= k and t[i - k] == "s":
            t[i] = 'm'
        else:
            ans += r
    if t[i] == "p":
        if i >= k and t[i - k] == "p":
            t[i] = 'm'
        else:
            ans += s
print(ans)


Verdicts: Wrong Answer

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):
H = list(map(int, input().split()))
A = list(map(int, input().split()))
T = input()
P=A[2]
R=A[0]
S=A[1]
k=H[1]
ans = 0
T = list(T)

for i in range(int(H[0])):
    a=i-k
    b=T[0]
    if(a<0):
        if(T[i]=="r"):
                ans+=P
                print("p")
        if(T[i]=="s"):
                ans+=R
                print("r")
        if(T[i]=="p"):
                ans+=S
                print("s")
    else:
        if(T[i]=="r"):
            if(T[a] !="r"):
                ans+=P
                print("p")
            else:
                T[i]="l"
                print("n")

        if(T[i]=="s"):
            if(T[a] !="s"):
                ans+=R
                print("r")
            else:
                T[i]="l"
                print("n")
        if(T[i]=="p"):
            if(T[a] !="p"):
                ans+=S
                print("s")
            else:
                T[i]="l"
                print("n")
print(ans)


H = list(map(int, input().split()))
A = list(map(int, input().split()))
T = input()
P=A[2]
R=A[0]
S=A[1]
k=H[1]
ans = 0
T = list(T)

for i in range(int(H[0])):
    a=i-k
    b=T[0]
    if(a<0):
        if(T[i]=="r"):
                ans+=P
                #print("p")
        if(T[i]=="s"):
                ans+=R
                #print("r")
        if(T[i]=="p"):
                ans+=S
                #print("s")
    else:
        if(T[i]=="r"):
            if(T[a] !="r"):
                ans+=P
                #print("p")
            else:
                T[i]="l"
                #print("n")

        if(T[i]=="s"):
            if(T[a] !="s"):
                ans+=R
                #print("r")
            else:
                T[i]="l"
                #print("n")
        if(T[i]=="p"):
            if(T[a] !="p"):
                ans+=S
                #print("s")
            else:
                T[i]="l"
                #print("n")
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())

ans = 0
# count for 0 ~ K
for i in range(N-K):
    if(T[i] == 'r'):
        point = P
    elif(T[i] == 's'):
        point = R
    elif(T[i] == 'p'):
        point = S
    else: # already used
        point = 0
    ans += point

    if(T[i+K] == T[i]):
        print(i, "taken")
        T[i+K] = 'n'

# count for K ~ N
for i in range(N-K, N):
    if(T[i] == 'r'):
        point = P
    elif(T[i] == 's'):
        point = R
    elif(T[i] == 'p'):
        point = S
    else: # already used
        point = 0
    ans += point

print(ans)


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

ans = 0
# count for 0 ~ K
for i in range(N-K):
    if(T[i] == 'r'):
        point = P
    elif(T[i] == 's'):
        point = R
    elif(T[i] == 'p'):
        point = S
    else: # already used
        point = 0
    ans += point

    if(T[i+K] == T[i]):
        T[i+K] = 'n'

# count for K ~ N
for i in range(N-K, N):
    if(T[i] == 'r'):
        point = P
    elif(T[i] == 's'):
        point = R
    elif(T[i] == 'p'):
        point = S
    else: # already used
        point = 0
    ans += point

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):
,k = map(int,input().split())
R,S,P =map(int,input().split())
T = list(input())
value= {'r':P,'s':R,'p':S}
ans = 0
pre = ''

for i in range(k):
    num = i
    while num<n:
        if pre == T[num]:
            pre = ''
        else:
            pre = T[num]
            ans += value[pre]
        num += k
print(ans)


n,k = map(int,input().split())
R,S,P =map(int,input().split())
T = list(input())
value= {'r':P,'s':R,'p':S}
ans = 0

for i in range(k):
    num = i
    pre = ''
    while num<n:
        if pre == T[num]:
            pre = ''
        else:
            pre = T[num]
            ans += value[pre]
        num += k
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):
for i in range(n):
    if i<k:
        if t[i] =='r':
            ans+=p
        elif t[i] =='s':
            ans+=r
        else :
            ans+=s
    else:
        if t[i] =='r' and t[i-k]!='r':
            ans+=p
        elif t[i] =='s' and t[i-k]!='s':
            ans+=r
        elif t[i] =='p' and t[i-k]!='p':
            ans+=s
        else:
            t[i]='a'
            continue
print(ans)

n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
ans =0
for i in range(n):
    if i<k:
        if t[i] =='r':
            ans+=p
        elif t[i] =='s':
            ans+=r
        else :
            ans+=s
    else:
        if t[i] =='r' and t[i-k]!='r':
            ans+=p
        elif t[i] =='s' and t[i-k]!='s':
            ans+=r
        elif t[i] =='p' and t[i-k]!='p':
            ans+=s
        else:
            t[i]='a'
            continue
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):
import sys
bbn=1000000007
	
#+++++
		
def main():
	n, k = map(int, input().split())
	r, s, p =  map(int, input().split())
	t = input()
	dd={'s':r, 'p':s, 'r':p}
	point = lambda c : dd[c]
	
	max_p=sum([point(c) for c in t])
	same_k={'s':0, 'p':0, 'r':0}
	tn=t
	for i in range(k,n):
		if tn[i]==tn[i-k] and tn[i]!='_':
			same_k[tn[i]] += 1
			tn[i] = '_'
	down=0
	for cc in ['r','s','p']:
		down+=same_k[cc]*point(cc)
			
	print(max_p-down)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

import sys
bbn=1000000007
	
#+++++
		
def main():
	n, k = map(int, input().split())
	r, s, p =  map(int, input().split())
	t = input()
	dd={'s':r, 'p':s, 'r':p}
	point = lambda c : dd[c]
	
	max_p=sum([point(c) for c in t])
	same_k={'s':0, 'p':0, 'r':0}
	tn=list(t)
	for i in range(k,n):
		if tn[i]==tn[i-k] and tn[i]!='_':
			same_k[tn[i]] += 1
			tn[i] = '_'
	down=0
	#print(tn)
	for cc in ['r','s','p']:
		down+=same_k[cc]*point(cc)
			
	print(max_p-down)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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=input()
RA,SA,PA=0,0,0
for i in range(0,N-K):
  if T[i]!=T[i+K]:
    if T[i]=='r':
      RA+=1
    if T[i]=='s':
      SA+=1
    if T[i]=='p':
      PA+=1
for i in range(N-K,N):
  if T[i]=='r':
    RA+=1
  if T[i]=='s':
    SA+=1
  if T[i]=='p':
    PA+=1         
ans=RA*P+SA*R+PA*S
print(ans)

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
ans = [0] * n
for i, c in enumerate(t):
    if i >= k and c == t[i - k] and ans[i - k] > 0:
        continue
    if c == 'r':
        ans[i] = p
    elif c == 's':
        ans[i] = r
    else:
        ans[i] = s
print(sum(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())
S = input()
ans = 0
for i in range(K):
    if S[i] == “r”:
        ans += P
    elif S[i] == “s”:
        ans += R
    else:
        ans += S
T = []
for i in range(K,N):
    if S[i] ==“r”:
        if S[i-K] == “r”:
            if i in T:
                ans += P
            else:
                T.append(i)
        else:
             ans += P
    elif S[i] == “s”:
        if S[i-K] == “s”:
            if i in T:
                ans += R
            else:
                T.append(i)
        else:
             ans += R
       else:
            if S[i-K] == “p”:
                if i in T:
                    ans += S
                else:
                    T.append(i)
            else:
                ans +=S
print(ans)

N,K = map(int,input().split())
R,S,P  =  map(int,input().split())
t = input()
s = []
for i in range(N):
    s.append(t[i])
ans = 0
for i in range(K):
    if s[i] == 'r':
        ans += P
        s[i] = 'a'
    elif s[i] == 's':
        ans += R
        s[i] = 'b'
    else:
        ans += S
        s[i] = 'c'
T = []
for i in range(K,N):
    if s[i] == 'r':
        if s[i-K] != 'a':
            ans += P
            s[i] = 'a'
    elif s[i] == 's':
        if s[i-K] != 'b':
            ans += R
            s[i] = 'b'
    else:
        if s[i-K] != 'c':
            ans += S
            s[i] = 'c'
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):
#149d

def win(n):
	if n=='r':
		return p
	elif n=='s':
		return r
	else:
		return s

n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
score=0
for i in t:
	score += win(i)

#hands=list(t)

for i in range(n):
	if i+k<n:
		if t[i]==t[i+k]:
			score-=win(t[i+k])
			t[i+k].upper()
print(score)

#149d

def win(n):
	if n=='r':
		return p
	elif n=='s':
		return r
	else:
		return s

n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
score=0
for i in t:
	score += win(i)

#hands=list(t)

for i in range(n):
	if i+k<n:
		if t[i]==t[i+k]:
			score-=win(t[i+k])
			t[i+k]='x'
print(score)


def win(n):
	if n=='r':
		return p
	elif n=='s':
		return r
	else:
		return s

n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
score=0
for i in t:
	score += win(i)

hands=list(t)

for i in range(n):
	if i+k<n:
		if hands[i]==hands[i+k]:
			score-=win(hands[i+k])
			hands[i+k]='x'
print(score)

Verdicts: Wrong Answer

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

# hash
point_dict = {"s": r, "p": s, "r": p}
 
cnt = 0
for i in range(len(t)):
    if i - k >= 0:
        if t[i - k] == t[i]:
          continue
    cnt += point_dict[t[i]]
print(cnt)

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

cnt = 0
ans = []

for i in range(n):
  if i > k:
    if t[i] == 'r':
      if t[i-k] == 'p':
        ans.append('r')
      else:
        ans.append('p')
        cnt+=p
    elif t[i] == 's':
      if t[i-k] == 'r':
        ans.append('s')
      else:
        ans.append('r')
        cnt+=r
    elif t[i] == 'p':
      if t[i-k] == 's':
        ans.append('p')
      else:
        ans.append('s')
        cnt+=s
  else:
    if t[i] == 'r':
      ans.append('p')
      cnt+=p
    elif t[i] == 's':
      ans.append('r')
      cnt+=r
    elif t[i] == 'p':
      ans.append('s')
      cnt+=s
print(cnt)

n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = list(input())
cnt = 0
for i in range(k):
    if t[i] == 'r':
        cnt += p
    elif t[i] == 's':
        cnt += r
    else:
        cnt += s
 
for i in range(k, n):
    if t[i] != t[i-k]:
        if t[i] == 'r':
            cnt += p
        elif t[i] == 's':
            cnt += r
        else:
            cnt += s
    else:
        t[i] = ''
 
print(cnt)

Verdicts: Wrong Answer

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()
point=0
l=[]
point_list=[r,s,p]
kind=['r','s','p','r']
for i in range(n):
  for j in range(len(kind)-1):
    if t[i]==kind[j]:
      if i-k>=0 and t[i]==kind[l[i-k]+1]:
        if i+k<n and t[i+k]==kind[j+1]:
          if j==2:j=-1
          l.append(j+1)
        else:
          l.append(j)
      else:
        point+=point_list[j-1]
        if j==0:j=3
        l.append(j-1)
      break
print(l)
print(point)

n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
point=0
l=[]
point_list=[r,s,p]
kind=['r','s','p','r']
for i in range(n):
  for j in range(len(kind)-1):
    if t[i]==kind[j]:
      if i-k>=0 and t[i]==kind[l[i-k]+1]:
        if i+k<n and t[i+k]==kind[j+1]:
          if j==2:j=-1
          l.append(j+1)
        else:
          l.append(j)
      else:
        point+=point_list[j-1]
        if j==0:j=3
        l.append(j-1)
      break
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):

def solve(N,K,R,S,P,T):
    check = [0]*N
    ans = 0
    for i in range(N):
        if i < K or T[i] != T[i-K] or not check[i-K]:
            ans += P if T[i] == 'r' else R if T[i] == 's' else S
            check[i] = 1
    print(ans)

def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()
    solve()

if __name__ == "__main__":
    main()

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
d = {'r': 'p', 's': 'r', 'p': 's'}
a = {'r' : R, 's' : S, 'p' : P}
l = [d[s] for s in T]
cnt = 0
for i, s in enumerate(T):
    if i < K:
        cnt += a[l[i]]
        continue
    if s == 'r' and l[i-K] != 'p':
        cnt += P
    elif s == 'r' and l[i-K] == 'p':
        #cnt += R
        l[i] = 'a'

    if s == 's' and l[i-K] != 'r':
        cnt += R
    elif s == 's' and l[i-K] == 'r':
        #cnt += S
        l[i] = 'a'

    if s == 'p' and l[i-K] != 's':
        cnt += S
    elif s == 'p' and l[i-K] == 's':
        #cnt += P
        l[i] = 'a'
print(cnt)
    


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 = input()
ans = 0
ls = list
for i in range(k):
    if t[i] == "r":
        ls.append("p")
        ans += p
    elif t[i] == "s":
        ls.append("r")
        ans += r
    elif t[i] == "p":
        ls.append("s")
        ans += s
        
for i in range(n):
        if ls[-k] != "r":
            ans += p
            ls.append("p")
        else:
            ls.append("x")
    elif t[i] == "s":
        if ls[-k] != "s":
            ans += r
            ls.append("r")
        else:
            ls.append("x")
    else:
        if ls[-k] != "p":
            ans += s
            ls.append("s")
        else:
            ls.append("x")
print(ans)

n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
ans = 0
ls = []
for i in range(n):
    if t[i] == "r":
        if len(ls) >= k:
            if ls[-k] != "r":
                ans += p
                ls.append("r")
            else:
                ls.append("x")
        else:
            ans += p
            ls.append("r")
    elif t[i] == "s":
        if len(ls) >= k:
            if ls[-k] != "s":
                ans += r
                ls.append("s")
            else:
                ls.append("x")
        else:
            ans += r
            ls.append("s")
    else:
        if len(ls) >= k:
            if ls[-k] != "p":
                ans += s
                ls.append("p")
            else:
                ls.append("x")
        else:
            ans += s
            ls.append("p")
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):
import math
from functools import reduce
import itertools

def input1():
	return int(input())


def input2():
	return map(int,input().split())


def input_array():
	return list(map(int,input().split()))






n,k=input2()
r,s,p=input2()
t=str(input())


ans_list=[]
b_k=0
flag=False
for i,hand in enumerate(t):
	if len(ans_list)>=k:
		b_k=ans_list[-k]

	if hand=="r":
		if  b_k==p:
			ans_list.append(0)
		else:
			ans_list.append(p)
	elif hand=="s":
		if b_k==r:
			ans_list.append(0)
		else:
			ans_list.append(r)
	elif hand=="p":
		if b_k==s:
			ans_list.append(0)
		else:
			ans_list.append(s)

import math
from functools import reduce
import itertools

def input1():
	return int(input())


def input2():
	return map(int,input().split())


def input_array():
	return list(map(int,input().split()))






n,k=input2()
r,s,p=input2()
t=str(input())
V = {'r':p, 's':r, 'p':s}

ans_list=[]
ans=0

for i in range(k):
	check=t[i]
	ans+=V[check]
	for _ in range(n):
		i+=k
		if i>=n:
			break
		elif check==t[i]:
			check="-1"
		else:
			check=t[i]
			ans+=V[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):
def check_hands(last,next):
    result = ''
    for j in ['r','s','p']:
        if j!=last and j!=next:
            result = j
            break
    print(result)
    return result

n,k = map(int,input().split())
r,s,p = map(int,input().split())
points = {'r':r, 's':s, 'p':p}
hands = {'r':'p', 's':'r', 'p':'s'}
t = list(input())
rpsList = ['']*n
ans = 0

for i in range(n):
    rpsList[i] += hands[t[i]]
    if i-k>=0 and rpsList[i]==rpsList[i-k]:
        lastHand = rpsList[i-k]
        nextHand = rpsList[i+k] if i+k<n  else ''
        rpsList[i] = check_hands(lastHand,nextHand)
    else:
        ans += points[rpsList[i]]

print(ans)

n,k = map(int,input().split())
r,s,p = map(int,input().split())
points = {'r':r, 's':s, 'p':p}
hands = {'r':'p', 's':'r', 'p':'s'}
t = list(input())
rpsList = ['']*n
ans = 0

for i,hand in enumerate(t):
    rpsList[i] += hands[hand]
    if i>=k and rpsList[i]==rpsList[i-k]:
        last_hand= rpsList[i-k]
        next_hand = hands[t[i+k]] if i+k<n else ''
        for j in ['r','s','p']:
            if j!=last_hand and j!=next_hand:
                rpsList[i] = j
    else:
        ans += points[hands[hand]]

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):
import math
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T  = input()
G =  []
for i in range(K):
  G.append([])
for i in range(len(T)):
  G[i % K].append(T[i])

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
su = 0
kinshi = ''
dashita = [''] * N
for i in range(len(T)):
  s = T[i]
  if i - K >= 0:
    if s == dashita[i - K]:    
      continue
  if s == 'r':
    su += P
  elif s == 's':
    su += R
  elif s == 'p':
    su += S
  dashita[i] = s
print(su)
  

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

def MaxScore(rsp, t):
    Score = 0
    t = t + 't'
    for i in range(len(t)):
        if t[i] == t[i+1]:
            pass
        else:
            if t[i] == 'r':
                Score = Score + rsp[2]
            elif t[i] == 's':
                Score = Score + rsp[0]
            else:
                Score = Score + rsp[1]
    return Score

def strsplit(n, t, k):
    tList = [""] * k
    for i in range(n):
        tList[i % k] = tList[i % k] + t[i]
    return tList

RSP = [R, S, P]
Answer = 0
for i in range(K):
    Answer = MaxScore(RSP, strsplit(N, T, K)[i]) + Answer

print(Answer)

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

def MaxScore(rsp, s):
    Score = 0
    t = list(s)
    t = t + ['t']
    for i in range(len(t)-1):
        if t[i] == t[i+1]:
            t[i+1] = 'x' + t[i+1]
    for i in range(len(t)):
        if t[i] == 'r':
            Score = Score + rsp[2]
        elif t[i] == 's':
            Score = Score + rsp[0]
        elif t[i] == 'p':
            Score = Score + rsp[1]
    return Score

def strsplit(n, t, k):
    tList = [""] * k
    for i in range(n):
        tList[i % k] = tList[i % k] + t[i]
    return tList

RSP = [R, S, P]
Answer = 0
for i in range(K):
    Answer = MaxScore(RSP, strsplit(N, T, K)[i]) + Answer

print(MaxScore(RSP,T))

N, K = map(int,input().split())
R, S, P = map(int,input().split())
T = input()
 
def EarnScore(rsp, t):
    if t == 'r':
        return rsp[2]
    elif t == 's':
        return rsp[0]
    elif t == 'p':
        return rsp[1]
    else:
        return 0
 
RSP = [R, S, P]
Answer = 0
ListT = list(T)
for i in range(N):
    Answer = EarnScore(RSP, ListT[i]) + Answer
    if i + K < N:
        if ListT[i] == ListT[i+K]:
            ListT[i+K] = 'x'
 
print(Answer)

Verdicts: Runtime Error

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

hand = {"r":p,"s":r,"p":s}
ans = 0
for i in range(n):
    if a[i-k] == a[i] and i-k >= 0:
        ans += 0
    else:
        ans += hand[a[i]]
print(ans)


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

hand = {"r":p,"s":r,"p":s}
ans = 0
for i in range(n):
    if a[i-k] == a[i] and i-k >= 0:
        a[i] = "0"
    else:
        ans += hand[a[i]]
print(ans)


Verdicts: Wrong Answer

Accepted