peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer

# 出力
a, b = map(int, input().split())

# 処理&出力
if (a + b) / 3 >= 1 :
    print('Possible')
else:
    print('Impossible')
# Judge status: Wrong Answer
K = int(input())

K_list = [i+1 for i in range(K)]
gcd = sorted(K_list, reverse=True)[:-1]
res = 0
for l in range(len(gcd)):
  GCD = gcd[l]
  for i in range(len(K_list)):
    a = K_list[i]
    for j in range(len(K_list)):
      b = K_list[j]
      for k in range(len(K_list)):
        c = K_list[k]
        if a % GCD == 0 and b % GCD == 0 and c % GCD == 0:
          res += GCD
        elif 1 in [a, b, c]:
          res += 1
        
print(res)
# Judge status: Accepted
a, b = map(int, input().split())
print('IMPOSSIBLE' if (b - a) % 2 else (b + a) // 2)
# Judge status: Accepted
#!/usr/bin/env python3

def main():
    A,B,C = map(int, input().split())
    if (A+B) >= C:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()
# Judge status: Accepted
s = input()

print('2018'+s[4:])
# Judge status: Accepted
import numpy as np
N , M = map(int, input().split())
ans = np.zeros(N)
S_C = []
for _ in range(M):
  s, c = map(int, input().split())
  for i, j in S_C:
    if s == i and c != j:
      print(-1)
      quit()
  ans[s-1] = c
  S_C.append([s, c])

if ans[0] == 0 and [1, 0] in S_C and N > 1:
  print(-1)
  quit()
if ans[0] == 0 and [1, 0] not in S_C and N > 1:
  ans[0] = 1
print(int("".join([str(int(x)) for x in ans])))
# Judge status: Accepted
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

Size = 3
bingo = False
for row in a:
    if all(item in b for item in row):
        bingo = True
for col in zip(*a):
    if all(item in b for item in col):
        bingo = True
if all(a[i][i] in b for i in range(Size)):
    bingo = True
if all(a[i][Size - 1 - i] in b for i in range(Size)):
    bingo = True
 
print("Yes" if bingo else "No")
# Judge status: Accepted
n,m = map(int,input().split())
X = list(map(int,input().split()))
if n>=m:
    print(0)
    exit()
X.sort()
D = []
prev = X[0]
for i in range(1,m):
    x = X[i]
    D.append(abs(x-prev))
    prev = x
D.sort()
print(sum(D[0:m-n]))
# Judge status: Wrong Answer
#関数リスト
import sys
input = sys.stdin.readline


def RD(): return input().rstrip()
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))

def main():
    A, B, C, X, Y = MI()
    if C >= (A+B) / 2:
        print(A*X+B*Y)
    else:
        temp = min(X,Y)
        print(C*temp*2+(X-temp)*A+(Y-temp)*B)
    
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b = map(int, input().split())

ans = float("inf")
for i in range(4):
	tmp = 0
	x = a
	y = b
	if i == 0:

		if x > y:
			continue

		tmp += y-x

	elif i == 1:
		tmp += 1
		x *= -1
		if x > y:
			continue
		tmp += y-x

	elif i == 2:
		tmp += 1
		y *= -1
		if x > y:
			continue
		tmp += y-x

	else:
		tmp += 2
		x *= -1
		y *= -1
		
		if x > y:
			continue

		tmp += y-x

	ans = min(ans,tmp)

print(ans)
# Judge status: Accepted
import math

N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)

K = int(math.log2(N-1))

if N == 2:
    print(A[0])
else:
    ans = A[0]
    ind = 1
    num = 0
    for i in range(N-2):
        if num < 2:
            ans += A[ind]
            num += 1
        else:
            ind += 1
            ans += A[ind]
            num = 1
        
    print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 0
x = 0
y = 0
while i < n-1:
    if x == 0:
        if a[i] == a[i+1]:
            x = a[i]
            i += 1
    elif y == 0:
        if a[i] == a[i+1]:
            y = a[i]
            i += 1
    i += 1
print(x*y)
# Judge status: Accepted
li=list(input())
a=li[2]
b=li[3]
c=li[4]
d=li[5]
if a==b:
    if c==d:
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

print(c-a+b)
# Judge status: Wrong Answer
import sys

N=int(input())
S=input()
if(N%2==0 and S[0:int(N/2)-1]==S[int(N/2):N-1]):
  print("Yes")
  sys.exit()
print("No")
# Judge status: Accepted
n = int(input())
W = list(map(int,input().split()))
ans = sum(W)
for t in range(1,100):
  x = 0
  y = 0
  for i in range(n):
    if i<=t:
      x+=W[i]
    else:
      y+=W[i]
  ans = min(ans,abs(x-y))
print(ans)
# Judge status: Wrong Answer
#097
# 1 <= a,b,c <= 100
# 1 <= d <= 100
a,b,c,d =map(int,input().split())

AB = abs(a - b)
BC = abs(b - c)
AC = abs(a - c)

if AC <=d:
    print("Yes")
elif AB <=d and BC <=d:
    print("Yes")
else:
    print("NO")
# Judge status: Accepted
import math

l = [int(input()) for i in range(5)]

time = 0
last = 0
for i in range(5):
    time += math.ceil(l[i] / 10) * 10
    if l[i] % 10 == 0:
        continue
    else:
        last = max(last, 10 - (l[i] % 10))

print(time - last)
# Judge status: Wrong Answer
n=int(input())
m=int(n/1.08)
if n!=int(m*1.08):
  print(":(")
else:
  print(m)
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
count = 0
ans = []
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        count += 1
    else:
        ans.append(count)
        count = 0
ans.append(count)
print(max(ans))
# Judge status: Wrong Answer
n=int(input())
a=[int(i) for i in input().split()]
b=sorted(a)
x=sum(b[-1:])
y=sum(b[:-1])
if y<x:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
a, b, x = map(int, input().split())
fa = max(a - 1, 0) // x
fb = b // x
ans = fb - fa if a != 0 else fb - fa + 1
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
if N == 1:
    if M == 1:
        ans = 1
    else:
        ans = M-2
else:
    ans = (N-2)*(M-2)
print(ans)
# Judge status: Wrong Answer
a = [int(input()) for i in range(6)]
mi=min(a)
if(a[0]==mi):print(5)
else: print(5+(a[0]//mi))
#pythonではなくpython3で実行して
# Judge status: Accepted
n=int(input())
l=[0,0]
from collections import Counter as co
for k,a in co(list(map(int,input().split()))).items():
    if a>=4:l+=[k,k]
    elif a>=2:l.append(k)
    l.sort()
    l=l[-2:]

print(l[0]*l[1])
# Judge status: Wrong Answer
N = int(input())
L = [int(x) for x in input().split()]
L.sort(reverse = True)

if(L[0]> sum(L[1:])):
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
a=input()
if(ord(a)>=65 and ord(a)<=90):
  print('a')
else:
  print('A')
# Judge status: Wrong Answer
x = int(input())
ans = 0

ans += (x // 500) * 1000
x -= (x // 500) * 500
print(x, ans)
ans += (x // 5) * 5
# Judge status: Accepted
N = int(input())
print((1000 - N) % 1000)
# Judge status: Wrong Answer
s = input()
print(s+'es' if s[-1]==s else s+'s')
# Judge status: Accepted
import numpy as np
if __name__ == "__main__":
    N, Y = map(int, input().split())
    ans = [-1, -1, -1]
    for i in range(N+1):
        for j in range(N+1-i):
            k = N - i - j
            y = 10000 * i + 5000 * j + 1000 * k
            if y == Y:
                ans = [i, j, k]
    print("{} {} {}".format(ans[0], ans[1], ans[2]))
# Judge status: Accepted
x=["A","G","C","T"]
ans=0
now=0
for i in input():
    if i in x:
        now+=1
    else:
        now=0
    ans=max(now,ans)
print(ans)
# Judge status: Accepted
S = input()
ans = 0

for i in range(2, len(S), 2):
    if S[0:i//2] == S[i//2:i]:
        ans = i

print(ans)
# Judge status: Wrong Answer
a,b,x=map(int, input().split())

import math
if 0.5*a**2*b<=x:
    ans=math.atan(2*(1/(a**2)*(a*b-x/a)))
    ans=math.degrees(ans)
else:
    ans=math.atan((a*b**2)/(x/2))
    ans=math.degrees(ans)

print(round(ans,10))
# Judge status: Accepted
S=input()

if "RRR" in S:
	print(3)
elif "RR" in S:
	print(2)
elif "R" in S:
	print(1)
else:
	print(0)
# Judge status: Accepted
a, b = map(int, input().split())

if a + b < 24:
    print(a + b)
else:
    print(a + b -24)
# Judge status: Accepted
a , b = map(int , input().split())
if a <= b:
    print(a)
else:
    print(a-1)
# Judge status: Accepted
N = int(input())

match_list = list(set([i * j for i in range(1, 10) for j in range(1, 10)]))

if N in match_list:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N=int(input())
count=0
list=[]
for i in range(1,N+1):
  if str(input()) in list:
    pass
  else:
    count+=1
print(count)
# Judge status: Accepted
import sys
input=sys.stdin.readline

# n=int(input())
# A=list(map(int,input().split()))
mod=1000000007
n,k=map(int,input().split())
n+=1
ans=0
l=0
r=0
for i in range(k):
    l+=i
posl=k-1
for i in range(n-k,n):
    r+=i
posr=n-k


while l!=r:
    ans+=r-l+1
    ans%=mod
    posl+=1
    l+=posl
    posr-=1
    r+=posr
print(ans+1)
# Judge status: Wrong Answer
import os, sys, re, math

(N, K) = [int(n) for n in input().split()]

lk = math.log2(K)

p = 0
for i in range(1, N + 1):
    if i >= K:
        p += 1.0
    else:
        p += (0.5 ** (int(lk - math.log2(i) + 1)))

print(p / N)
# Judge status: Accepted
n, y = map(int, input().split())
ans =[-1, -1, -1]
for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        if i * 10 + j * 5 + k == y / 1000:
            ans = [i, j, k]
            print(i, j, k)
            exit()
ans = [str(a) for a in ans]
print(' '.join(ans))
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
p = sorted([int(i) for i in input().split()], reverse=True)
q = sorted([int(i) for i in input().split()], reverse=True)
r = sorted([int(i) for i in input().split()], reverse=True)
l = sorted(p[:X] + q[:Y])

i = 0
ans = 0
for a in l:
    if i < C and r[i] <= a:
        ans += a
    elif i < C and r[i] > a:
        ans += r[i]
        i += 1
    else:
        ans += a

print(ans)
# Judge status: Accepted
S = input()

for i in range(len(S)):
    if S[i] in S[i+1:]:
        print('no')
        break
else:
    print('yes')
# Judge status: Accepted
n,m=list(map(int,input().split()))
if n==1 and m==0:
  print(0)
  exit(0)
d=[-1]*4
for _ in range(m):
  s,c=list(map(int,input().split()))
  if d[s]!=-1 and d[s]!=c:
    print(-1)
    exit(0)
  d[s]=c
ans=0
for i in range(1,n+1):
  if d[i]==-1:
    if ans==0:d[i]=1
    else:d[i]=0
  ans=10*ans+d[i]
if len(str(ans))==n:
  print(ans)
else:
  print(-1)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    if i%2 == 0 and a[i]%2 != 0:
        ans+=1
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=(i+1)
median=-1
a.sort()
if n%2==0:
    median=(a[n//2]+a[n//2-1])//2
else:
    median=a[n//2]
def comp(x):
    su=0
    for i in a:
        su+=abs(i-x)
    return su
print(min(comp(median-1),comp(median),comp(median+1)))
# Judge status: Accepted
def solve():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    list.sort(H, reverse=True)
    return sum(H[min(K, N):])

print(solve())
# Judge status: Accepted
def chmin(a, b):
  if a > b:
    return b
  return a

def main():
  N = int(input())
  hs = [i for i in map(int, input().split())]
  
  INF = 1e12
  dp = [INF]*N
  dp[0] = 0
  for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(hs[i]-hs[i-1]))
    if i > 1:
      dp[i] = chmin(dp[i], dp[i-2] + abs(hs[i]-hs[i-2]))
  print(dp[N-1])
  return

if __name__ == '__main__':
  main()
# Judge status: Accepted
S = input()
N = len(S)

ans = 0
tmp = 0
ACGT = {"A", "C", "G", "T"}
i = 0
while i < N:
  if S[i] in ACGT:
    tmp += 1
  else:
    ans = max(ans, tmp)
    tmp = 0
  i += 1
    
ans = max(ans, tmp)  

print(ans)
# Judge status: Wrong Answer
S=input()
z=0
o=0
for i in range(len(S)):
    if S[i]==0:
        z+=1
    elif S[i]==1:
        o+=1
print(2*min(z,o))
# Judge status: Accepted
from collections import deque

N = int(input())
A = list(map(int, input().split()))

answer = deque([])
for i, a in enumerate(A):
  if i % 2 == 0:
    answer.appendleft(a)
  else:
    answer.append(a)
    
answer = list(answer)
answer = answer if N % 2 else answer[::-1]

print(*answer)
# Judge status: Accepted
N, x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

a.sort()

cnt = 0
for i, child in enumerate(a):
    if x == 0:
        break
    if child == x:
        cnt += 1
        break
    if child < x:
        # 最後の要素か判定
        if i == len(a) - 1:
            break
        x -= child
        cnt += 1

print(cnt)
# Judge status: Wrong Answer
(a,b,c,k)=map(int,input().split(' '))
if k<=a+b:
  print(a)
else:
  print(a-(k-a-b))
# Judge status: Wrong Answer
K=int(input())
l=[]
cnt=0
def dfs(s, depth):
    if depth>8:
        return
    S=str(s)
    ls=int(S[-1])
    for i in range(max(0,ls-1),min(10,ls+2)):
        n=int(S+str(i))
        l.append(n)
        dfs(n, depth+1)
for i in range(1, 10):
    dfs(i, 0)
l.sort()
print(l[K])
# Judge status: Accepted
n, l = map(int, input().split())
taste = [0]*n
taste2 = [0]*n
for i in range(n):
    taste[i] = l + i
    taste2[i] = abs(l + i)
ate_idx = taste2.index(min(taste2))
taste[ate_idx] = 0
print(sum(taste))
# Judge status: Accepted
N = int(input())

L = [0]*(N+1)
L[0], L[1] = 2, 1

for i in range(2,N+1):
  L[i] = L[i-2] + L[i-1]

print(L[N])
# Judge status: Accepted
N,M=map(int,input().split())
h=list(map(int,input().split()))

pair=[]
for _ in range(M):
    inp=list(map(int,input().split()))
    pair.append(inp)

loser=[]
for i in range(M):
    if h[pair[i][0]-1]<h[pair[i][1]-1]:
        loser.append(pair[i][0])
    elif h[pair[i][0]-1]>h[pair[i][1]-1]:
        loser.append(pair[i][1])
    else:
        loser.append(pair[i][0])
        loser.append(pair[i][1])

set_loser=set(loser)
ans=N-int(len(set_loser))
print(ans)
# Judge status: Accepted
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

mx = 9
L = [0] * N
for i in range(N):
  x, y = xy[i]
  L[i] = x + y
  mx = max(mx, x)

L.sort()
ans = L[-1] - L[0]

for i in range(N):
  x, y = xy[i]
  L[i] = mx - x + y

L.sort()
ans = max(ans, L[-1] - L[0])

print(ans)
# Judge status: Accepted
from collections import deque
s = [deque(input()) for _ in range(3)]
d = {"a":0, "b":1, "c":2}
D = {0:"A", 1:"B", 2:"C"}
player = 0
for _ in range(301):
    x = s[player].popleft()
    player = d[x]
    if not s[player]:
        print(D[player])
        exit()
# Judge status: Accepted
import sys
input=sys.stdin.readline
 
n,w=map(int,input().split())
dp=[0]*(w+1)
 
def ans(n,w):
  for _ in range(n):
    c,p=map(int,input().split())
    for j in range(w,c-1,-1):
      tmp=dp[j-c]+p
      if dp[j]<tmp:
        dp[j]=tmp
  return dp[-1]
print(ans(n,w))
# Judge status: Accepted
split = input().split()

num1 = int(split[0])
num2 = int(float(split[1])*1000)
print(int(num1*num2)//1000)
# Judge status: Accepted
import numpy as np
n, d = map(int, input().split())
num = 2 * d + 1
ans = np.ceil(n / num)
print(int(ans))
# Judge status: Accepted
N, K = map(int, input().split())
A=list(map(int, input().split()))

num=0
while num*K-(num-1)<N:
    num+=1
print(num)
# Judge status: Accepted
n = int(input())
print((10**n - 9**n*2 + 8**n) % (10 ** 9 + 7))
# Judge status: Accepted
import fractions
def main():
    A, B, C, D = map(int, input().split())
    num = (B - A + 1)  - (get_num(B, C, D) - get_num(A-1, C, D))
    print(num)

def get_num(x, C, D):
    num_C = x // C
    num_D = x // D
    f = fractions.gcd(C, D)
    f2 = C*D//f
    num_CD = x // f2
    return num_C  + num_D - num_CD

if __name__  == '__main__':
    main()
# Judge status: Accepted
w, h, n = map(int, input().split())

x_min = 0
x_max = w
y_min = 0
y_max = h

for _ in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    x_min = max(x_min, x)
  elif a == 2:
    x_max = min(x_max, x)
  elif a == 3:
    y_min = max(y_min, y)
  else:
    y_max = min(y_max, y)

print(
  (x_max - x_min) * (y_max - y_min)
  if x_min < x_max and y_min < y_max else 0
)
# Judge status: Wrong Answer
a, b = (int(i) for i in input().split())
if abs(a-b) > 1:
  print(max(a,b)*2 - 1)
else:
  print(max(a,b)*2)
# Judge status: Accepted
import numpy as np
N, _ = map(int, input().split())
D = np.bincount(tuple(map(int, input().split())), minlength=10)
while True:
    n = N
    while n:
        if D[n % 10]:
            break
        n //= 10
    else:
        break
    N += 1
print(N)
# Judge status: Accepted
A=list(input())
right_cnt=[0]
left_cnt=[0]
cnt=0
for i in range(len(A)):
   if A[i] == "<":
      right_cnt.append(right_cnt[-1]+1)
   else:
      right_cnt.append(0)
   if A[-i-1] == ">":
      left_cnt.append(left_cnt[-1]+1)
   else:
      left_cnt.append(0)
left_cnt=left_cnt[::-1]
for i in range(len(A)+1):
   cnt+=max(left_cnt[i],right_cnt[i])
print(cnt)
# Judge status: Accepted
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

s = list(map(int, list(input())))[::-1] + [0]*2
n = len(s) - 1
cnt = 0
fl = 0
for i in range(n+1):
    if s[i] > 5 or (s[i] == 5 and s[i+1] >= 5):
        cnt += 10 - s[i]
        s[i+1] += 1
    else:
        cnt += s[i]

print(cnt)
# Judge status: Accepted
N = int(input())
A = [int(x) for x in input().split()]

total = 0
for i in range(1, N):
    d = max(A[i-1] - A[i], 0)
    A[i] += d
    total += d
print(total)
# Judge status: Wrong Answer
from sys import exit
n = int(input())
hh = list(map(int, input().split()))

ans = True
down = False
for i in range(n-1):
    if hh[i] <= hh[i+1]:
        continue
    elif not down and hh[i] - 1 == hh[i+1]:
        down = True
        continue
    else:
        print('No')
        exit()
        break
print('Yes')
# Judge status: Accepted
import sys
from math import floor, ceil
inputs = sys.stdin.readlines()

h = int(inputs[0])
w = int(inputs[1])
n = int(inputs[2])

print(ceil(n / max(h, w)))
# Judge status: Accepted
x=int(input())
if x>=30:
    print('Yes')
else:    
    print('No')
# Judge status: Wrong Answer
n, k, s = map(int, input().split())

def sieve(n):
    prime = [True] * (n + 1)
    prime[0] = prime[1] = False
    i = 2
    while i * i <= n:
        if prime[i]:
            for j in range(i * i, n + 1, i):
                prime[j] = False
        i += 1
    return [i for i in range(i) if prime[i]]

primes = sieve(1000)
a = s
b = None
for p in primes:
    if s % p != 0:
        b = p
        break
print([a] * k + [b] * (n - k))
# Judge status: Wrong Answer
import sys
s = list(set(input()))
s.sort()
alp = list('abcdefghijklmnopqrstuvwxyz')
count=0
#if s include all alp, print None and exit 
if len(s) == 25:
    print('None')
    sys.exit()

for s_,alp_ in zip(s,alp):
    count += 1  
    if s_ != alp_ :
        print(alp_)
        sys.exit()
    
print(alp[count])
# Judge status: Wrong Answer
N = int(input())
B = list(map(int, input().split()))

# a1 a2 a3 a4 a5
# b1 b2 b3 b4

# b1 b2 b3 b4 b4

A = (B + [B[-1]]).copy()
for i in range(0, N - 1):
    a1 = A[i]
    a2 = A[i + 1]
    if (a1 < a2 and a1 == B[i]):
        A[i + 1] = a1
A[-1] = B[-1]

print(sum(A))
# Judge status: Wrong Answer
n = int(input())
intlist = list(map(int,input().split()))
mod = 1000000007

sum = 0
for i in range(n):
  sum += intlist[i]
  sum %= mod

ans = sum*sum%mod

for i in range(n):
  ans -= intlist[i]*intlist[i]%mod
  if ans < 0:
    ans += mod

ans *= (mod+1)/2
ans %= mod
print(int(ans))
# Judge status: Wrong Answer
h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
answer = "No"
i = 0
while (i < n):
  if(a[i] <= 0):
    answer = "Yes"
    break
  else:
    i += 1
print(answer)
# Judge status: Accepted
n = int(input())
a = list(int(input()) for i in range(n))

ans = a[0]
count = 0
for i in range(1, n):
    count += 1
    if ans == 2:
        print(count)
        exit()
    ans = a[ans-1]


print(-1)
# Judge status: Wrong Answer
mod = 10**9 + 7
n, a, b = map(int, input().split())

#2**nをmodしたもの
ans = pow(2, n, mod) - 1

x = 1
for i in range(a):
  x *= n-i
  x %= mod
  x *= pow(i+1, mod-2, mod)
  x %= mod
ans = (ans + mod-x)%mod


for i in range(b):
  x *= n-i
  x %= mod
  x *= pow(i+1, mod-2, mod)
  x %= mod
ans = (ans + mod-x)%mod

print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
ans = 0
for i in range(k):
    if t[i] == 'r':
        ans += p
    elif t[i] == 's':
        ans += r
    else:
        ans += s
for i in range(k , n):
    if t[i - k] == t[i]:
        t[i] = 'v' #
    if t[i] == 'r':
        ans += p
    elif t[i] == 's':
        ans += r
    elif t[i] == 'p':
        ans += s
print(ans)
# Judge status: Accepted
n = int(input())
if n%2 == 0:
	print (n//2)
if n%2 == 1:
  	print ((n+1)//2)
# Judge status: Accepted
x=int(input())
ans=10**13
for i in range(1,round((x**0.5))+2):
	if x%i==0:
		if ans>(i-2+(x//i)):
			ans=(i-2+(x//i))
print(ans)
# Judge status: Accepted
import collections

n, m = map(int,input().split())
a = []

for i in range(m):
  x, y = map(int,input().split())
  if x == 1: #1の島から行ける島
    a.append(y)
  if y == n: #5の島へ行ける島
    a.append(x)

c = collections.Counter(a)

if c.most_common()[0][1] == 2:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
# Judge status: Accepted
def trans(c):
    return ord(c)-ord('a')

S=[input() for _ in range(3)]
now=0
while True:
    if len(S[now])==0:
        break
    tmp=trans(S[now][0])
    S[now]=S[now][1:]
    now=tmp

print(chr(ord('A')+now))
# Judge status: Accepted
A, B, K = map(int, input().split())
ans = set()
arr = range(A, B+1)
for a in arr[:K]:
    ans.add(a)
for a in arr[-K:]:
    ans.add(a)

ans = list(ans)
ans.sort()

for a in ans:
    print(a)
# Judge status: Accepted
import sys
N, K, Q = map(int, input().split())
A = (int(x) for x in sys.stdin.read().split())
score = [K - Q] * N
for a in A:
  score[a - 1] += 1
for s in score:
  print('Yes' if s > 0 else 'No')
# Judge status: Wrong Answer
from collections import Counter

N = int(input())
S = input()
MOD = 10**9 + 7

c = Counter(S)
ans = 1

for v in c.values():
    ans *= v+1

print(ans-1)
# Judge status: Accepted
S,T = map(str,input().split())
A,B = map(int,input().split())
U = input()

if(S==U):
	A=A-1
elif(T==U):
	B=B-1
print(A,B)
# Judge status: Accepted

A, B = map(int, input().split())
S = input()

checkset = [str(x) for x in range(10)]

def main():
    SA = S[:A]; SB = S[A+1:]
    for i in SA:
        if i not in checkset:
            print('No')
            return

    if S[A] != '-':
        print('No')
        return

    for i in SB:
        if i not in checkset:
            print('No')
            return

    print('Yes')

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n = int(input())
a = [int(x) for x in input().split()]
 
if a[0] != 0:
    print(-1)
    exit()
 
ans = 1
sm = sum(a)
limit = 1
for i in range(1, n):
    ans += a[i]
    limit = 2*limit - a[i]
    if limit <= 0:
        print(-1)
        exit()
    else:
        sm -= a[i]
        if limit <= sm:
            ans += limit
        else:
            ans += sm
 
ans += a[-1]
 
print(ans)
# Judge status: Accepted
x = int(input())
print(x//500*1000+(x-x//500*500)//5*5)
# Judge status: Wrong Answer
s = input()
ans = 0
t = 0
for i in s:
  if(i=='R'):
    t += 1
  else:
    ans = t
    t = 0
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
nums = []
total = 0
for num in a:
    total += num
    nums.append(total)
minVal = 10 ** 9 * 2 + 1
for i in range(n - 1):
    sub = total - nums[i]
    minVal = min(abs(sub - nums[i]), minVal)
print(minVal)
# Judge status: Accepted
S = input()

if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print("Bad")
else:
    print("Good")
# Judge status: Accepted
n, k = map(int, input().split())

s = list(input())

s[k-1] = s[k-1].lower()

print(''.join(s))
# Judge status: Accepted
a, b, c = map(int, input().split())
if a-b<c:
    print(c-a+b)
else:
    print(0)
# Judge status: Accepted
A,B = map(int,input().split())
if A == B:
    print(A*2)
else:
    print(max(A,B)+max(A-1,B-1))
# Judge status: Accepted
count = 0
S=int(input())
for i in range(1,S+1):
    if len(str(i))%2==1:
        count +=1
print(count)
# Judge status: Wrong Answer
a, b = map(int, input().split())

result = a*b
if (result < 1 and  result > 81):
    print(-1)
else:
    print(result)