Harryxun/stf_run huggingface dataset:
import bisect
n = int(input())
l = list(map(int, input().split()))
count = 0
l.sort()
for i in range(len(l)-1, 1, -1):
  for j in range(i-1, 0, -1):
    count += max(j - (bisect.bisect_right(l, l[i] - l[j])), 0)
print(count)



### FIXED CODE ###

a, b = map(int, input().split())
print(max(a-2*b, 0))
import sys
import itertools
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        z=s-(x+y)
        if z>=0 andz<=k:
            ans+=1

print(ans)

### FIXED CODE ###

k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        z=s-(x+y)
        if z>=0 and z<=k:
            ans+=1
print(ans)
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
A = []
for i in range(M-1):
A.sort()
print(sum(A[:M-N]))

### FIXED CODE ###

N,M = map(int,input().split())
X = list(map(int,input().split()))
if N >= M:
    print(0)
    exit()
X.sort()
A = []
for i in range(M-1):
    A.append(X[i+1]-X[i])
A.sort()
print(sum(A[:M-N]))
#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

a = clocks[0]
for i in range(1, N):
  a = gcd(a, clocks[i])
  b = b * clocks[i] / a

print(b)

### FIXED CODE ###

#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

b = clocks[0]
for i in range(1, N):
  a = gcd(b, clocks[i])
  b = b * clocks[i] // a

print(b)
i = list(map(int, input().split()))

N = int(i[0])
A = int(i[1])
B = int(i[2])

count_blue = 0

syou = N // (A + B)
amari = N % (A + B)

if amari > A:
    count_blue = A * syou + A
else:
    count_blue = A * syou + amari
   
print(count_blue)

### FIXED CODE ###

S = str(input())
 
if S[0] == S[1] == S[2]:
  print("No")
else:
  print("Yes")
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = list(set(a))
ans = 0
if len(a) == 1:
    print(0)
else:
    for _ in range(n):
        m = a.pop()
        ind = True
        for i in a:
            if m % i == 0:
                ind = False
                break
        if ind:
            ans += 1
    print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
m = max(a)
y = [0] * (m + 1)
for i in a:
    x = i
    while x <= m:
        y[x] += 1
        x += i
ans = 0
for j in a:
    if y[j] == 1:
        ans += 1

print(ans)
n,k = map(int,input().split())

x = list(map(int,input().split()))
#x = [ abs(int(i))  for i in input().split()]
x.append(0)
x.sort()

min = 10**8

zeroIdx = x.index(0)

# plus
if zeroIdx + k < len(x) :
    min = x[zeroIdx + k] 

# minus 
if zeroIdx - k >= 0 :
    tmp = abs(x[zeroIdx - k])
    if tmp < min :
        min = tmp

# plus/minus
plsIdx = k+1
misIdx = k-1
while True:
    p = 0
    m = 0
    if plsIdx + 1 <  len(x):
        p = abs(x[plsIdx])

    if misIdx - 1 >= 0:
        m = abs(x[plsIdx])
    
    if p == 0 :
        misIdx -= 1
    elif m == 0 :
        plsIdx += 1
    elif p < m :
        plsIdx += 1
    else: 
        misIdx -= 1

    if plsIdx - misIdx >= k :
        if abs(x[plsIdx]) > abs(x[misIdx]) :
            tmp = abs(x[plsIdx]) + (abs(x[misIdx])<<1)
        else:
            tmp = (abs(x[plsIdx])<<1) + abs(x[misIdx])
        break

if tmp < min :
    min = tmp
print(min)

### FIXED CODE ###

n,k = map(int,input().split())
x = list(map(int,input().split()))

x.append(0)
x.sort()

#print(x)

min = 10**10

zeroIdx = x.index(0)

for i in range(zeroIdx-k,zeroIdx+1):
    if i < 0 : 
        continue
    elif len(x) <= i + k :
        break

    plsIdx = i + k 
    misIdx = i

    #print(misIdx,plsIdx,x[misIdx],x[plsIdx])

    if abs(x[plsIdx]) > abs(x[misIdx]) :
        tmp = abs(x[plsIdx]) + (abs(x[misIdx])<<1)
    else:
        tmp = (abs(x[plsIdx])<<1) + abs(x[misIdx])

    if tmp < min :
        min = tmp

print(min)
N,K=map(int,input().split())
h=list(map(int,input().split()))
ans=0
for i in N:
  if h[i]>=K:
    ans+=1
print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
h=list(map(int,input().split()))
ans=0
for i in range(N):
  if h[i]>=K:
    ans+=1
print(ans)
import math
a,b,x =map(int,input().split( ))
if x >= (a**2*b/2):
    k=2*x/(a**2)-b
    cos=math.sqrt((b-k)**2/((a**2)+(b-k)**2))
    print(math.degrees(math.acos(cos)))
else:
    k=2*x/(a*b)
    cos=math.sqrt(b**2/(b**2+k**2))
	print(90-math.degrees(math.acos(cos)))

### FIXED CODE ###

import math
a,b,x =map(int,input().split( ))
if x >= (a**2*b/2):
    k=2*x/(a**2)-b
    cos=math.sqrt((b-k)**2/((a**2)+(b-k)**2))
else:
    k=2*x/(a*b)
    cos=math.sqrt(b**2/(b**2+k**2))
print(90-math.degrees(math.acos(cos)))
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
exits = False

for i in range(n):
    for j in range(m):
        for k in range(n):
            match = False
            if a[i][k: k+m] == b[j] and not exits:
                for l in range(1, m):
                    if a[i+l][k: k+m] == b[l]:
                        match = True
                    else:
                        match = False
                        break
            if match:
                exits = True

print('Yes' if exits else 'No')


### FIXED CODE ###

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
exits = False

for i in range(n-m+1):
    for j in range(n-m+1):
        p = []
        for k in range(m):
            p.append(a[i:i+m][k][j:j+m])
        if p == b:
            exits = True

print('Yes' if exits else 'No')
# -*- coding: utf-8 -*-
from math import factorial
 
n = int(input())
strlist = []
for i in range(n):
    strlist.append(sorted(str(input())))
strlist.sort()

allcount = 0
while (len(strlist) > 1):
    count = 1
    while True:
        if(len(strlist) > 1):
            if(strlist[-1] == strlist[-2]):
                count += 1
                strlist.pop()
            else:
                strlist.pop()
                if(count > 1):
                    allcount += int(factorial(count) / factorial(2) / factorial(count-2))
                break
        else:
            strlist.pop()
            if(count > 1):
                allcount += int(factorial(count) / factorial(2) / factorial(count-2))
            break
print(allcount)

### FIXED CODE ###

n = int(input())
strdict = {}
count = 0
for i in range(n):
    sortedstr = "".join(sorted(str(input())))
    strdict.setdefault(sortedstr, 0)
    count += strdict[sortedstr]
    strdict[sortedstr] += 1
print(count)
n = int(input())
ans =[]
for i in range(1,n//2+2):
     for j in range(2,10):
          if i**j <= n:
print(max(ans))

### FIXED CODE ###

n = int(input())
ans =[]
for i in range(1,n//2+2):
     for j in range(2,10):
          if i**j <= n:
               ans.append(i**j)
print(max(ans))
X = int(input())

if X < 100:
    ans = 0
elif:
    a = str(X)
    a = int(a[:-2])
    b = X - a*100

    if a >= 20:
        ans = 1

    else:
        if a*5 >= b:
            ans = 1
        else:
            ans = 0

print(ans)


### FIXED CODE ###

X = int(input())

if X < 100:
    ans = 0
else:
    a = str(X)
    a = int(a[:-2])
    b = X - a*100

    if a >= 20:
        ans = 1

    else:
        if a*5 >= b:
            ans = 1
        else:
            ans = 0

print(ans)
sa=list(input())
sb=list(input())
sc=list(input())
owner="a"
while True:
    if owner=="a":
        if len(A):
            owner=A[0]
            del A[0]
        else:
            break
    elif owner=="b":
        if len(B):
            owner=B[0]
            del B[0]
        else:
            break
    else:
        if len(C):
            owner=C[0]
            del C[0]
        else:
            break
if owner=="a":
    print("A")
elif owner=="b":
    print("B")
else:
    print("C")

### FIXED CODE ###

sa=list(input())
sb=list(input())
sc=list(input())
owner="a"
while True:
    if owner=="a":
        if len(sa):
            owner=sa[0]
            del sa[0]
        else:
            break
    elif owner=="b":
        if len(sb):
            owner=sb[0]
            del sb[0]
        else:
            break
    else:
        if len(sc):
            owner=sc[0]
            del sc[0]
        else:
            break
if owner=="a":
    print("A")
elif owner=="b":
    print("B")
else:
    print("C")
class CreateList:
    def __init__(self, flg, cnt):
        self.flg = flg
        self.cnt = cnt
        
        

def main():
    
    n, k = map(int, input().split())
    s = list(map(int, input()))
    
    slist = []      #Sを使いやすいように加工した配列
    bkflg = s[0]    #一つ前の連続する値が「1」か「0」かを持ってるやつ
    scnt = 0        #「1」「0」の連続する数
    ecnt = 0        #終了判定のカウンター
    
    #配列作成
    for i in s:
        ecnt += 1
        
        #同じ数字が続く場合はカウントアップ
        if i == bkflg:
           scnt += 1
        
        #数字が変わったら配列にこれまでの合計数を入れてカウンターを初期化
        else:
            slist.append(CreateList(bkflg, scnt))
            scnt = 1
            bkflg = i
        
        #最後の1回が拾えないのでここで強引に配列に突っ込む
        if ecnt == len(s):
            slist.append(CreateList(bkflg, scnt))
    
    #本ちゃんで使う勇者たち
    maxsum = 0      #最大合計値の変数
    skipcnt = k     #連続する「0」を「1」としてカウント出来る回数
    cursor = 0      #Sの配列変数の開始位置
    cursorsum = 0   #一時的な「1」の合計数
    tmpcnt = 0      #一時的なカーソル位置
    
    #本ちゃんスタート
    while tmpcnt <= len(slist) - 1:
        #Sの配列を左からスライドしながら数字を拾ってくので、最初にカウンターとカーソル位置を初期化
        tmpcnt = cursor
        skipcnt = k
        cursorsum = 0
        
        #ここで「1」の合計をSの配列の左からスライドさせながらカウントしていく
        while tmpcnt <= len(slist) - 1:
            if slist[tmpcnt].flg == 0:
                if skipcnt == 0:
                    break
                else:
                    skipcnt -= 1
            
            cursorsum = cursorsum + slist[tmpcnt].cnt
            tmpcnt += 1
        
        #これまでの最大合計数を拾う
        if maxsum < cursorsum:
            maxsum = cursorsum
        
        cursor += 1
        
    print(maxsum)
    
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    l = list(map(int, input().split()))
    if max(l) != min(l):
        print((max(l) * 2) - 1)
    else:
        print(max(l) * 2)
    

if __name__ == "__main__":
  main()
H,W=input().split()
h,w=input().split()
print((H-h)*(W-w))

### FIXED CODE ###

H,W=map(int,input().split())
h,w=map(int,input().split())
print((H-h)*(W-w))
# -*- coding: utf-8 -*-

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]

xy.sort()
xy = xy[::-1]
aaa = []
for i in range(len(xy)-1):
    for j in range(i+1, len(xy)):
        a, b = xy[i]
        c, d = xy[j]
        aaa.append(str(a-c)+str(b-d))

# import itertools
#
# # itertools.permutations(xy, 2)
#
# aaa = []
# for i in list(itertools.combinations(xy, 2)):
#     a, b, c, d = sum(i, [])
#     aaa.append([str(a-c)+str(b-d)])
#     # print(a,b,c,d)
# # print(aaa)
# aaa = sum(aaa, [])
# print(aaa)
import collections
bbb = collections.Counter(aaa)
# print(bbb.most_common())
print(n-bbb.most_common()[0][1])






### FIXED CODE ###

# -*- coding: utf-8 -*-

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
if len(xy) == 1:
    print(1)
    exit()

xy.sort()
xy = xy[::-1]
aaa = []
for i in range(len(xy)-1):
    for j in range(i+1, len(xy)):
        a, b = xy[i]
        c, d = xy[j]
        aaa.append(str(a-c)+str(b-d))

# import itertools
#
# # itertools.permutations(xy, 2)
#
# aaa = []
# for i in list(itertools.combinations(xy, 2)):
#     a, b, c, d = sum(i, [])
#     aaa.append([str(a-c)+str(b-d)])
#     # print(a,b,c,d)
# # print(aaa)
# aaa = sum(aaa, [])
# print(aaa)
import collections
bbb = collections.Counter(aaa)
# print(bbb.most_common())
print(n-bbb.most_common()[0][1])
import sys
import numpy as np
input = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
# import profile

def LCS(s, t):
	n, m = len(s), len(t)
	dp = [[0 for i in range(m+1)] for j in range(n+1)]
	for i in range(n+1):
		for j in range(m+1):
			if i == 0 or j == 0:
				dp[i][j] = 0
			elif s[i-1] == t[j-1]:
				dp[i][j] = 1 + dp[i-1][j-1]
			else:
				dp[i][j] = max(dp[i-1][j], dp[i][j-1])
	# print("    ", end="")
	# for i in t:print(i, end = " ")
	# s += " "
	# # print("\n")
	# for k in range(n+1):
	# 	print(s[k-1], *dp[k])
	index = dp[n][m]
	ans = [" "]*index
	i, j = n, m
	while index:
		if s[i-1] == t[j-1]:
			ans[index-1] =  s[i-1]
			index -= 1
			i -= 1; j -= 1
		elif dp[i-1][j] > dp[i][j-1]:
			i -= 1
		else:
			j -= 1
	return(("").join(ans))

def solve():
	s1 = input().strip(); s2 = input().strip()
	print(LCS(s1, s2))









if __name__ == "__main__":
	solve()

### FIXED CODE ###

import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def LCS(s, t):
	n, m = len(s), len(t)
	dp = [[0 for i in range(m+1)] for j in range(n+1)]
	for i in range(n+1):
		for j in range(m+1):
			if i == 0 or j == 0:
				dp[i][j] = 0
			elif s[i-1] == t[j-1]:
				dp[i][j] = 1 + dp[i-1][j-1]
			else:
				dp[i][j] = max(dp[i-1][j], dp[i][j-1])
	index = dp[n][m]
	ans = [" "]*index
	i, j = n, m
	while index:
		if s[i-1] == t[j-1]:
			ans[index-1] =  s[i-1]
			index -= 1
			i -= 1; j -= 1
		elif dp[i-1][j] > dp[i][j-1]:
			i -= 1
		else:
			j -= 1
	return(("").join(ans))

def solve():
	s1 = inp().strip(); s2 = inp().strip()
	print(LCS(s1, s2))


if __name__ == "__main__":
	solve()
def solution(a, b):
    total = a + b
    if (total % 3 == 0) and total >= 3:
        print('Possible')
    else:
        print('Impossible')

A, B = input().split(' ')
A, B = int(A), int(B)

solution(A, B)

### FIXED CODE ###

def solution(a, b):
    total = a + b
    if total % 3 == 0:
        print('Possible')
    elif a % 3 == 0:
        print('Possible')
    elif b % 3 == 0:
        print('Possible')
    else:
        print('Impossible')

A, B = input().split(' ')
A, B = int(A), int(B)

solution(A, B)
a, b =map(int, input().split())
x = a*b
if x%2 == 0:
  print 'Even'
else:
  print 'Odd'

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b)%2 == 0:
  print ('Even')
else:
  print ('Odd')
N = input()
print(N**3)


### FIXED CODE ###

N = int(input())
print(N**3)
n = int(input())
s = input()

cnt = 0
for i in range(1000):
    
    t = str(i)
    u = '0'*(3-len(t))+t
    
    j = 0
    p = u[0]
    for x in s:
        if x == p:
            j += 1
            if j == 3:
                cnt += 1
                break
            p = u[j]
            
print(ans)

### FIXED CODE ###

n=int(input())
s=input()
list=["" for _ in range(1000)]
ans=0
for i in range(1000):
  t=str(i)
  u="0"*(3-len(t))+t
  j=0
  exi=0
  p=u[0]
  for x in s:
    if x==p:
      j+=1
      if j==3:
        ans+=1
        break
      p=u[j]
    
print(ans)
import sys
sys.setrecursionlimit(100000000)


def gcd(aa, b):
    if b == 0:
        return a
    return gcd(b, aa % b)


mod = 1e9 + 7
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) / gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek / a[i]
print(int(s % mod))




### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)


def gcd(aa, b):
    if b == 0:
        return aa
    return gcd(b, aa % b)


mod = int(1e9 + 7)
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) // gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek // a[i]
print(int(s % mod))
import itertools
def main():
    n,k = map(int, input().split())
    ds =  map(int, input().split())
    canuse = [i for i in range(10)]
    for d in ds: canuse.remove(d)
    canuse = [str(c) for c in canuse]
    digit = len(str(n))
    x = [int("".join(a)) for a in itertools.product(canuse, repeat=digit) if int("".join(a))>=n]
    print(min(x))
if __name__ == "__main__":
    main()

### FIXED CODE ###

import itertools
import sys
def main():
    n,k = map(int, input().split())
    ds =  list(map(int, input().split()))
    for i in range(n, 10**6):
        s = str(i)
        for d in ds:
            if str(d) in s:
                f = False
                break
            else:
                f = True
        if f:
            print(i)
            sys.exit()
if __name__ == "__main__":
    main()
friends=input()
friends.split('')
friends_all=friends[0]
friends_cake=friends[1]
cakes=input()
cakes.split('')
cakes_amount(sum(cakes))
one_person=cakes_amount//friends_all
if cakes_amount%friends_all==0:
        pass
else:
        one_person+=1
preint(one_person)



### FIXED CODE ###

friends=input()
friends=friends.split()
friends_all=friends[0]
person=int(friends_all)+1
cakes=input()
cakes_amount=0
for a in cakes.split():
        cakes_amount+=int(a)
one_person=cakes_amount//person

if cakes_amount%person!=0:
        one_person+=1
else:
        pass
print(one_person)
N, T = map(int, input().split())
A = [int(c) for c in input().split()]
p = A[0]
flag = True
ls = []
st = A[0]
for i in range(1,N):
  if A[i]>=A[i-1]:
    flag = True
  else:
    if flag:
      ls += [A[i-1]-st]
    flag = False
    st = A[i]
ls.sort()
ans = ls.count(ls[-1])
print(ans)

### FIXED CODE ###

N, T = map(int, input().split())
A = [int(c) for c in input().split()]
flag = True
ls = []
st = A[-1]
for i in range(N-2,-1,-1):
  if st-A[i]>0:
    ls += [st-A[i]]
  else:
    st = A[i]
ls.sort()
ans = ls.count(ls[-1])
print(ans)
n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
for aa in a:
  if aa>=sum(a)/4m:
    count+=1
if count>=m:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
sum=sum(a)
for aa in a:
  if aa>=sum/4/m:
    count+=1
if count>=m:
  print('Yes')
else:
  print('No')
import math
a,b,x=map(int,input().split())
x=x/a
d=(3*x)/b
X=x/3

if b<=x:
  atan1 = math.degrees(math.atan(a/(2*b-(2*x)/a)))
elif b>x:
  atan1 = math.degrees(math.atan(b/d))
                       
print(atan1)

### FIXED CODE ###

import math
a,b,x=map(int,input().split())
ans=0
flag=False
if x==a*a*b/2:
  ans=a/b
elif x<a*a*b/2:
  t=a-2*x/(a*b)
  ans=(a-t)/b
else:
  t=2*x/(a**2)-b
  if (b-t)!=0:
    ans=a/(b-t)
  else:
    flag=True
if flag==False:
  print(90-math.degrees(math.atan(ans)))
else:
  print(0)
S = input()
T = input()
tmp = ''
res = ''

count = 0
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            flag = 1
        elif S[i+j] == '?':
            flag = 0
        else:
            start = 0
            end = 0
            flag = 0
            break
    if flag == 1:
        break
            
if (start == 0) and (end == 0):
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

### FIXED CODE ###

S = input()
T = input()


    
if True:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
    if tmp == -1:
        print('UNRESTORABLE')
    else:
        res = ''
        count = 0
        for i in range(len(S)):
            if tmp <= i < tmp + len(T):
                res += T[count]
                count += 1
            elif S[i] == '?':
                res += 'a'
            else:
                res += S[i]

        print(res)
n,k,*a=map(int,open(0).read().split())
b,c=[],[0]
for i in a:
    if i<0:
        b+=[-i]
    elif i==0:
        k-=1
    else:
        c+=[i]
b=[0]+b[::-1]        
ans=10**9
B,C=len(b),len(c)
for i in range([0,abs(C-k-1)][C-k-1<0],B):
    ans=min(ans,b[i]+c[k-i]+min(b[i],c[k-i]))
print(ans)

### FIXED CODE ###

n,k,*a=map(int,open(0).read().split())
ans=10**9
for i in range(n-k+1):
    b,c=a[i],a[i+k-1]
    ans=min(ans,min(abs(b),abs(c))+abs(b-c))
print(ans)
input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

flag = True
for i in range(N-3):
	if abs(A[i]-A[i+1]) != abs(A[i+2]-A[i+1]):
		flag = False
		break

if flag==True:
	print(POSSIBLE)
else:
	print(IMPOSSIBLE)

### FIXED CODE ###

def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)

input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

temp = A[0]
for i in range(1,N):
	temp = gcd(temp,A[i])

if K <= max(A) and K % temp == 0:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')
N,K,R,S,P = map(int,input().split())
T = str(input())
point = 0
for i in range(N):
  if T[i] == "r" and T[K] != "p":
    point += P
  elif T[i] == "s" and T[K] != "r":
    point += R
  elif T[i] == "p" and T[K] != "s":
    point += S
  else:
    break
  i += 1
print(point)

### FIXED CODE ###

N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = str(input())
i = 0
point = 0
L = [""]*N
for i in range(N):
  if T[i] == "r": 
    if i >= K and L[i-K] == "p":
      pass
    else:
      point += P
      L[i] = "p"
  elif T[i] == "s":
    if i >= K and L[i-K] == "r":
      pass
    else:
      point += R
      L[i] = "r"
  elif T[i] == "p":
    if i >= K and L[i-K] == "s":
      pass
    else:
      point += S
      L[i] = "s"
  else:
    break
print(point)
ans=10**8
h,w,K=map(int,input().split())
s=[]
import copy
def two(x):
	return "0"*(h-1-len(bin(x)[2:]))+bin(x)[2:]
for i in range(h):
	s.append(input())
for i in range(2**(h-1)):
	r=two(i)
	pre_ans=r.count("1")
	d=[0]*(pre_ans+2)
	cnt=0
	for j in range(w):
		now=0
		for k in range(h):
			if s[k][j]=="1":
				d[now]+=1
			if k!=h-1:
				if r[k]=="1":
					now+=1
		if max(d)>K:
			e=[]
			for x in range(len(d)):
				e.append(d[x]-dd[x])
			d=copy.copy(e)
			cnt+=1
		if max(d)>K:
			pre_ans=10**7
			break
		dd=copy.copy(d)
	pre_ans+=cnt
	ans=min(ans,pre_ans)
print(ans)

### FIXED CODE ###

ans=10**8
h,w,K=map(int,input().split())
s=[]
import copy
def two(x):
	return "0"*(h-1-len(bin(x)[2:]))+bin(x)[2:]
for i in range(h):
	s.append(input())
for i in range(2**(h-1)):
	r=two(i)
	pre_ans=r.count("1")
	d=[0]*(pre_ans+1)
	dd=copy.copy(d)
	cnt=0
	for j in range(w):
		now=0
		for k in range(h):
			if s[k][j]=="1":
				d[now]+=1
			if k!=h-1:
				if r[k]=="1":
					now+=1
		if max(d)>K:
			e=[]
			for x in range(len(d)):
				e.append(d[x]-dd[x])
			d=copy.copy(e)
			cnt+=1
		if max(d)>K:
			cnt=10**7
		dd=copy.copy(d)
	pre_ans+=cnt
	ans=min(ans,pre_ans)
print(ans)