Harryxun/stf_run huggingface dataset:
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(n):
  ct=0
  score=0
  s=[]
  pos=i
  while ct<k:
    ct+=1
    pos=p[pos]-1
    score+=c[pos]
    s.append(score)
    if pos==i:
      break
  if s[-1]<0:
    ans.append(max(s))
  elif pos!=i:
    ans.append(max(s))
  elif max(s)==max(s[0:k%len(s)]):
    ans.append(s[-1]*(k//len(s))+max(max(s[0:k%len(s)]),0))
  else:
    ans.append(s[-1]*(k//len(s)-1)+max(s))
print(max(ans))

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(n):
  ct=0
  score=0
  s=[]
  pos=i
  while ct<k:
    ct+=1
    pos=p[pos]-1
    score+=c[pos]
    s.append(score)
    if pos==i:
      break
  if s[-1]<0:
    ans.append(max(s))
  elif pos!=i:
    ans.append(max(s))
  elif k%len(s)==0:
    ans.append(s[-1]*(k//len(s)-1)+max(s))
  else:
    ans.append(max(s[-1]*(k//len(s)-1)+max(s),s[-1]*(k//len(s))+max(s[0:k%len(s)])))
print(max(ans))
import numpy as np

N,K=list(map(int,input().split()))
h=np.zeros(N)
for i in range(N):
    h[i]=int(input())
    
h=np.sort(h)
h_min=10**9
for i in range(N-K+1):
    dh=h[i+K-1]-h[i]
    if dh<dh_min:
        dh_min=dh
print(dh_min)

### FIXED CODE ###

import numpy as np
 
N,K=list(map(int,input().split()))
h=np.zeros(N)
for i in range(N):
    h[i]=int(input())
    
h=np.sort(h)
dh_min=10**9
for i in range(N-K+1):
    dh=h[i+K-1]-h[i]
    if dh<dh_min:
        dh_min=dh
print(int(dh_min))
import bisect
import math
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int, input().split()))
A.sort()
A_set = []
num = []
a_cur = float('inf')
for a in A:
    if a != a_cur:
        A_set.append(a)
        num.append(1)
        a_cur = a
    else:
        num[-1] += 1

ans = 0
for i in range(len(A_set) - 1, -1, -1):
    if num[i] > 0:
        A_i = A_set[i]
        comp = 2 ** math.ceil(math.log2(A_i + 1)) - A_i
        j = bisect.bisect_left(A_set, comp, 0, i)
        while True:
            if A_set[j] == comp:
                if num[j] > 0:
                    if i != j:
                        ans += 1
                        num[j] -= 1
                        break
                    elif num[j] >= 2:
                        add = num[j] // 2
                        ans += add
                        num[j] = num[j] % 2
                        break
                    else:
                        break
                else:
                    break
            else:
                break

print(ans)


### FIXED CODE ###

import bisect
import math
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int, input().split()))
A.sort()
A_set = []
num = []
a_cur = float('inf')
for a in A:
    if a != a_cur:
        A_set.append(a)
        num.append(1)
        a_cur = a
    else:
        num[-1] += 1

ans = 0
for i in range(len(A_set) - 1, -1, -1):
    if num[i] > 0:
        A_i = A_set[i]
        comp = 2 ** math.ceil(math.log(A_i + 1, 2)) - A_i
        j = bisect.bisect_left(A_set, comp, 0, i)
        while True:
            if A_set[j] == comp:
                if num[j] > 0:
                    if i != j:
                        ans += min(num[j], num[i])
                        num[j] = max(num[j] - num[i], 0)
                        break
                    elif num[j] >= 2:
                        add = num[j] // 2
                        ans += add
                        num[j] = num[j] % 2
                        break
                    else:
                        break
                else:
                    break
            else:
                break

print(ans)
while True:
    a,b=map(int,input().split(' '))
    print(len(str(a+b)))

### FIXED CODE ###

while True:
    try:
        a,b=map(int,input().split(' '))
        print(len(str(a+b)))
    except:
        break
A, B, C, D, E, F = list(map(int, input().split()))

water = set()
sugar = set()
res = {}
noudo = []

counter = max([int(F / A), int(F / B)])
A_counter = int(F / (A * 100))
B_counter = int(F / (B * 100))
for i in range(A_counter + 1):
    for j in range(B_counter + 1):
        tmp = A * i * 100 + B * 100 * j
        if tmp <= F:
            water.add(tmp)

C_counter = int(F / C)
D_counter = int(F / D)
for i in range(C_counter + 1):
    for j in range(D_counter + 1):
        tmp = i * C + D * j
        if tmp < F:
            sugar.add(tmp)

water.remove(0)
sugar.remove(0)

for w in water:
    for s in sugar:
        if w + s <= F and s <= E * (w / 100):
            n = s / (w + s)
            noudo.append(n)
            res[n] = {"satoumizu": w + s, "sugar": s}
ans = res[max(noudo)]
# print(" ".join([str(ans["satoumizu"]), str(ans["sugar"])]))
print(str(ans["satoumizu"]) + " " + str(ans["sugar"]))


### FIXED CODE ###

A, B, C, D, E, F = list(map(int, input().split()))

water = set()
sugar = set()
res = {}
noudo = []

counter = max([int(F / A), int(F / B)])
A_counter = int(F / (A * 100))
B_counter = int(F / (B * 100))
for i in range(A_counter + 1):
    for j in range(B_counter + 1):
        tmp = A * i * 100 + B * 100 * j
        if tmp <= F:
            water.add(tmp)

C_counter = int(F / C)
D_counter = int(F / D)
for i in range(C_counter + 1):
    for j in range(D_counter + 1):
        tmp = i * C + D * j
        if tmp < F:
            sugar.add(tmp)

water.remove(0)
# sugar.remove(0)

for w in water:
    for s in sugar:
        if w + s <= F and s <= E * (w / 100):
            n = s / (w + s)
            noudo.append(n)
            res[n] = {"satoumizu": w + s, "sugar": s}
ans = res[max(noudo)]
# print(" ".join([str(ans["satoumizu"]), str(ans["sugar"])]))
print(str(ans["satoumizu"]) + " " + str(ans["sugar"]))
from collections import deque

def bfs(s_l, visited, sy, sx, gy, gx, h, w):
    q = deque([[sy,sx]])
    visited[0][0] = 0
    while q:
        y, x = q.popleft()
        if [y, x] == [gy, gx]:
            return visited[gy][gx]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            n_y, n_x = y+j, x+k
            if n_y >= h or n_x >= w or n_y < 0 or n_x < 0:
                continue
            if s_l[n_y][n_x] == '.' and visited[n_y][n_x] == -1:
                visited[n_y][n_x] = visited[y][x] + 1
                q.append([n_y,n_x])

def main():
    h, w = map(int, input().split()) 
    s_l = []
    all_dot_cnt = 0
    for i in range(h):
        row = list(input())
        s_l.append(row)
        all_dot_cnt += row.count('.')
    
    visited = [ [-1]*w for i in range(h)]
    res = bfs(s_l, visited, 0, 0, h-1, w-1, h, w)
    # print(res)
    # print(all_dot_cnt)
    print(all_dot_cnt-res-1)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque

def bfs(s_l, visited, sy, sx, gy, gx, h, w):
    q = deque([[sy,sx]])
    visited[0][0] = 0
    while q:
        y, x = q.popleft()
        if [y, x] == [gy, gx]:
            return visited[gy][gx]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            n_y, n_x = y+j, x+k
            if n_y >= h or n_x >= w or n_y < 0 or n_x < 0:
                continue
            if s_l[n_y][n_x] == '.' and visited[n_y][n_x] == -1:
                visited[n_y][n_x] = visited[y][x] + 1
                q.append([n_y,n_x])
    return -1

def main():
    h, w = map(int, input().split()) 
    s_l = []
    all_dot_cnt = 0
    for i in range(h):
        row = list(input())
        s_l.append(row)
        all_dot_cnt += row.count('.')
    
    visited = [ [-1]*w for i in range(h)]
    res = bfs(s_l, visited, 0, 0, h-1, w-1, h, w)
    if res == -1:
        print(-1)
    else:
        # print(res)
        # print(all_dot_cnt)
        print(all_dot_cnt-res-1)

if __name__ == "__main__":
    main()
a = []
while True:
    n = input()
    if n == -1:
        break
    a.append(n)

for i in range(len(a)):
    if(a[i]==0):
        break
    else:
        print('Case '+str(i)+': 'str(a[i]))

### FIXED CODE ###

i=1
while(1):
    n=input()
    if(int(n)==0):
        break
    else:
        print('Case '+str(i)+': '+n)
        i+=1
A = input()
B = input()

0<=int(A)<=100
0<=int(B)<=100

if int(A)>int(B)*2:
  print(int(A)-int(B)*2)

else:
  print(0)


### FIXED CODE ###

A, B = [int(i) for i in input().split()]
0<=A<=100
0<=B<=100

if A>B*2:
  print(A-B*2)

else:
  print(0)
A,B,C,D,E,F = map(int,input().split())

ans_con = 0
max_con = E/(100+E)*100

a = 0
while F > 100*A*a:
    b = 0
    while F-100*A*a > 100*B*b:
        c = 0
        while F-100*(A*a+B*b) > C*c and c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//D)
            mass = water + sugar
            if mass == 0 or mass > F:
                break
            con = sugar/mass*100
            if ans_con < con <= max_con:
                ans_con = con
                ans_mass = mass
                ans_sugar = sugar
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

### FIXED CODE ###

A,B,C,D,E,F = map(int,input().split())

ans_con = -1
max_con = E/(100+E)*100

a = 0
while F >= 100*A*a:
    b = 0
    while F-100*A*a >= 100*B*b:
        water = 100*(A*a+B*b)
        c = 0
        while F-water >= C*c:
            d = 0
            while F-water-C*c >= D*d:
                sugar = C*c+D*d
                mass = water + sugar
                if 0 < mass <= F:
                    con = sugar/mass*100
                    if ans_con < con <= max_con:
                        ans_con = con
                        ans_mass = mass
                        ans_sugar = sugar
                d += 1
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    H, W = map(int, input().split())
    s = [input() for _ in range(H)]

    ans = [[0]*W for _ in range(H)]
    if s[0][0]=='#':
        ans[0][0] = 1
    for i in range(1, W+H-1):
        for j in range(max(W, H)):
            if 0<=i-j<min(W, H):
                if j==0:
                    if s[j][i-j-1]=='.' and s[j][i-j]=='#':
                        ans[j][i-j] = ans[j][i-j-1] + 1
                    else:
                        ans[j][i-j] = ans[j][i-j-1]
                elif i-j==0:
                    if s[j-1][i-j]=='.' and s[j][i-j]=='#':
                        ans[j][i-j] = ans[j-1][i-j] + 1
                    else:
                        ans[j][i-j] = ans[j-1][i-j]
                else:
                    if (s[j-1][i-j]=='.' or s[j][i-j-1]=='.') and s[j][i-j]=='#':
                        ans[j][i-j] = min(ans[j-1][i-j], ans[j][i-j-1]) + 1
                    else:
                        ans[j][i-j] = min(ans[j-1][i-j], ans[j][i-j-1])
    # print(ans)
    print(ans[-1][-1])

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    H, W = map(int, input().split())
    s = [input() for _ in range(H)]

    ans = [[0]*W for _ in range(H)]
    if s[0][0]=='#':
        ans[0][0] = 1
    for i in range(1, W+H-1):
        for y in range(max(0, i-(W-1)), min(i+1, H)):
            x = i-y
            if y==0:
                if s[y][x-1]=='.' and s[y][x]=='#':
                    ans[y][x] = ans[y][x-1] + 1
                else:
                    ans[y][x] = ans[y][x-1]
            elif x==0:
                if s[y-1][x]=='.' and s[y][x]=='#':
                    ans[y][x] = ans[y-1][x] + 1
                else:
                    ans[y][x] = ans[y-1][x]
            else:
                if s[y][x]=='#':
                    ans[y][x] = min(ans[y-1][x]+(1 if s[y-1][x]=='.' else 0), ans[y][x-1]+(1 if s[y][x-1]=='.' else 0))
                else:
                    ans[y][x] = min(ans[y-1][x], ans[y][x-1])
    print(ans[-1][-1])

if __name__ == '__main__':
    resolve()
def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp
def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m)

n,k = map(int, open(0).read().split())
dp = [0] * n
dp[0] = 1
dp[1] = (n * (n-1)) % m
m = 1000000007
memf = []
mfappend = memf.append
for x in memfact(n,m):
    mfappend(x)
for i in range(2,min(k+1,n)):
    dp[i] = (dp[i-1]+comb(n,i,m)*comb(n-1,i,m)) % m
print((dp[min(n-1,k)]+1)%m)

### FIXED CODE ###

def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp
def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m)

n,k = map(int, open(0).read().split())
dp = [0] * n
dp[0] = 1
m = 1000000007
dp[1] = (n * (n-1)) % m
memf = []
mfappend = memf.append
for x in memfact(n,m):
    mfappend(x)
for i in range(2,min(k+1,n)):
    dp[i] = (dp[i-1]+comb(n,i,m)*comb(n-1,i,m)) % m
print((dp[min(n-1,k)]+1)%m)
s,t = input().sprit()
a=0
for i in range(len(s)):
  if s[i]==t[i]:
      a=a+1
  else:
      a=a+0
print(a)

### FIXED CODE ###

s,t = input(), input()
a = 0
for i in range(len(s)):
    if s[i]!=t[i]:
        a = a + 1
print(a)
N, M = map(int, input().split()) 
ans = ['', '', '']
if M == 0:
    print(0)
    exit()
for i in range(M):
    s, c = input().split()
    s = int(s)-1
    if ans[s] in ['', c]:
        ans[s] = c
    else:
        print(-1)
        exit()

if ans[0] == '0' and n >1:
    ans = -1
 
elif ans[0] == '' and ans[1] == '0' and n == 3:
    ans = -1

if ans == -1:
    print(ans)
    exit()

if ans[1] == '':
    ans[1] = '0'
if ans[2] == '':
    ans[2] = '0'

if N == 2:
    ans.pop()
if N == 1:
    ans = ans[0]

print(''.join(ans))

### FIXED CODE ###

n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
for i in range(1000):
    i = str(i)
    if len(i) != n:
        continue
    for [x, y] in lst:
        if i[x-1] != str(y):
            break
    else: 
        print(i)
        exit()

print(-1)
a,b=map(str,input().split())
b1=int(b*100)
a1=int(a)
ans=int(a1*b1/100)
print(int(ans))

### FIXED CODE ###

n=int(input())
a=list(input().split())
ans=1
f=0
i=0
while(i<n):
    if f==0:
        ans=ans*int(a[i])
    if f==0 and ans>1000000000000000000:
        f=1
    if int(a[i])==0:
        print(0)
        exit()
    i+=1
if f==1:
    print(-1)
    exit()
print(ans)
x=int(input())
for i in range(-1000:1000:1):
  for j in range(-1000:1000:1):
    if i**5-j**5==x:
      print(i,j)
      exit()

### FIXED CODE ###

x=int(input())
for i in range(-1000,1000,1):
  for j in range(-1000,1000,1):
    if i**5-j**5==x:
      print(i,j)
      exit()
# import sys
# input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))
if n==1:
    print(0)
    exit()
else:
    count_list = []
    count = 0
    i = n-1
    while 0<i<n:
        if h[i-1]>=h[i]:
            count += 1
            i -= 1
        else:
            count_list.append(count)
            count = 0
            i = i-1
print(max(count_list))

### FIXED CODE ###

# import sys
# input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))
if n==1:
    print(0)
    exit()
else:
    count_list = []
    count = 0
    i = n-1
    while i<n:
        # print(i)
        if i>0 and h[i-1]>=h[i]:
            count += 1
            i -= 1
        else:
            count_list.append(count)
            count = 0
            if i>0:
                i = i-1
            elif i==0:
                break
print(max(count_list))
mojiretsu=input()
kakunin="abcdefghijklmnopqrstuvwxyz"
nagasa=len(mojiretsu)
bunkai=[]
for i in range(nagasa): 
    bunkai.append(mojiretsu[i:i+1])
bunkai1=list(set(bunkai))
bunkai1.sort()
ans="None"


for k in range(len(bunkai)):
    if bunkai1[k]!=kakunin[k:k+1]:
        ans=kakunin[k:k+1]
        
        break
    
print(ans)

### FIXED CODE ###

S=input()

if "a" not in S:
    print("a")
elif "b"  not in S:
    print("b")
elif "c"  not in S:
    print("c")
elif "d"  not in S:
    print("d")
elif "e"  not in S:
    print("e")
elif "f"  not in S:
    print("f")
elif "g"  not in S:
    print("g")
elif "h"  not in S:
    print("h")
elif "i"  not in S:
    print("i")
elif "j"  not in S:
    print("j")
elif "k"  not in S:
    print("k")
elif "l"  not in S:
    print("l")
elif "m"  not in S:
    print("m")
elif "n"  not in S:
    print("n")
elif "o"  not in S:
    print("o")
elif "p"  not in S:
    print("p")
elif "q"  not in S:
    print("q")
elif "r"  not in S:
    print("r")
elif "s"  not in S:
    print("s")
elif "t"  not in S:
    print("t")
elif "u"  not in S:
    print("u")
elif "v"  not in S:
    print("v")
elif "w"  not in S:
    print("w")
elif "x"  not in S:
    print("x")
elif "y"  not in S:
    print("y")
elif "z"  not in S:
    print("z")
else:
    print("None")
n = int(input())
p = 0
for i in range(26)
  for j in range(16)
    if 4*i + 7*j == n:
      p == 1
      break
if p == 0:
  print("No")
else: 
  print("Yes")

### FIXED CODE ###

n = int(input())
p = 0
for i in range(26):
  for j in range(16):
    if 4*i + 7*j == n:
      p = 1
      break
if p == 0:
  print("No")
else: 
  print("Yes")
n = int(input())
a = list(map(int, input().split()))

t = True
x = 0

while T == True:
  x +=1
  for i in a:
    if i%2 == 0:
      a = list(map(lambda x:x/2, a))
    else:
      t = False
      
print(x)
    

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

t = True
x = -1

while t == True:
  x += 1
  for i in a:
    if i%2 == 0:
      continue
    else:
      t = False
  a = list(map(lambda x:x/2, a))  

      
print(x)
def main():
    import sys
    input = sys.stdin.readline

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

    cnt = [0] * 3
    for a in A:
        cnt[a-1] += 1

    dp = [[[0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]
    for k in range(N+1):
        for j in range(N+1):
            for i in range(N+1):
                ijk = i + j + k
                if ijk > N:
                    continue
                x = N / ijk
                tmp = 0
                if i > 0:
                    tmp += (dp[i-1][j][k] + x) * (i / ijk)
                if j > 0 and i < N:
                    tmp += (dp[i+1][j-1][k] + x) * (j / ijk)
                if k > 0 and j < N:
                    tmp += (dp[i][j+1][k-1] + x) * (k / ijk)
                dp[i][j][k] = tmp
    print(dp[cnt[0]][cnt[1]][cnt[2]])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline

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

    cnt = [0] * 3
    for a in A:
        cnt[a-1] += 1

    dp = [[[0.] * (N+1) for _ in range(N+1)] for _ in range(N+1)]
    for k in range(N+1):
        for j in range(N+1-k):
            for i in range(N+1-j-k):
                ijk = float(i + j + k)
                if ijk == 0:
                    continue
                x = N / ijk
                tmp = 0
                if i > 0:
                    tmp += (dp[i-1][j][k] + x) * (i / ijk)
                if j > 0 and i < N:
                    tmp += (dp[i+1][j-1][k] + x) * (j / ijk)
                if k > 0 and j < N:
                    tmp += (dp[i][j+1][k-1] + x) * (k / ijk)
                dp[i][j][k] = tmp
    print(dp[cnt[0]][cnt[1]][cnt[2]])


if __name__ == '__main__':
    main()
s = input()

x = -1

if len(s) == 1:
    x = 0
else:
    s2 = s.replace('x', '')

    if len(s2) % 2 == 0:
        flg = True
    else:
        flg = False

    nf = len(s2) // 2

    if flg:
        s2_pre = s2[:nf+1]
        s2_post = s2[nf+1:]
    else:
        s2_pre = s2[:nf]
        s2_post = s2[nf+1:]

    if s2_pre == s2_post[::-1]:
        cnt_s = 0
        cnt_s2 = 0
        while True: # 元の文字列の中心を求める
            if s[cnt_s] == 'x':
                cnt_s += 1
            if s[cnt_s] == s2[cnt_s2]:
                cnt_s += 1
                cnt_s2 += 1
            if cnt_s2 >= nf:
                break

        if len(s) % 2 == 0:
            s_pre = s[:cnt_s+1]
            s_post = s[cnt_s+1:]
        else:
            s_pre = s[:cnt_s]
            s_post = s[cnt_s+1:]

        s_postR = s_post[::-1]

        s_pre = list(s_pre)
        s_postR =  list(s_postR)

        cnt = 0
        cnt_pre = 0
        cnt_post = 0
        while True:
            try:
                if s_pre[cnt_pre] == s_postR[cnt_post]:
                    cnt_pre += 1
                    cnt_post += 1
            except IndexError:
                pass
            
            if len(s_pre) > cnt_pre:
                if s_pre[cnt_pre] == 'x':
                    s_postR.insert(cnt_post, 'x')
                    cnt_pre += 1
                    cnt_post += 1
                    cnt += 1
            elif len(s_postR) > cnt_post:
                if str(s_pre) == str(s_postR):
                    break
                else:
                    s_pre.insert(cnt_pre, s_postR[cnt_post])
                    cnt_pre += 1
                    cnt_post += 1
                    cnt += 1
                    
            if len(s_postR) > cnt_post:
                if s_postR[cnt_post] == 'x':
                    s_pre.insert(cnt_pre, 'x')
                    cnt_pre += 1
                    cnt_post += 1
                    cnt += 1
            elif len(s_pre) > cnt_pre:
                if str(s_pre) == str(s_postR):
                    break
                else:
                    s_postR.insert(cnt_post, s_pre[cnt_pre])
                    cnt_pre += 1
                    cnt_post += 1
                    cnt += 1

            if str(s_pre) == str(s_postR):
                break

        x = cnt
    
print(x)

### FIXED CODE ###

s = input()

cnt = 0
ans = 0

if len(s) == 1:
    cnt = 0
else:
    l = 0
    k = 0
    while True:
        if s[l] == s[-k-1]:
            l += 1
            k += 1
            if l + k >= len(s)-1:
                break
        elif s[l] == 'x':
            l += 1
            cnt += 1
            if l + k >= len(s)-1:
                break
        elif s[-k-1] == 'x':
            k += 1
            cnt += 1
            if l + k >= len(s)-1:
                break
        else:
            ans = -1
            break

if ans == -1:
    print(ans)
else:
    print(cnt)
import sys
input = sys.stdin.readline
h,w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]
grid = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    grid[i][j] = abs(a[i][j]-b[i][j])
dp = [[[False for i in range(12881)] for j in range(w)] for k in range(h)]
dp[0][0][grid[i][j]] = True
for j in range(1,w):
  for k in range(80*j+1):
    t = grid[0][j]
    dp[0][j][k] = dp[0][j][k] or dp[0][j-1][k+t] or dp[0][j-1][abs(k-t)]
for i in range(1,h):
  for k in range(80*i+1):
    t = grid[i][0]
    dp[i][0][k] = dp[i][0][k] or dp[i-1][0][k+t] or dp[i-1][0][abs(k-t)]
for i in range(1,h):
  for j in range(1,w):
    for k in range(80*(i+j)+1):
      t = grid[i][j]
      dp[i][j][k] = dp[i][j][k] or dp[i][j-1][k+t] or dp[i][j-1][abs(k-t)] or dp[i-1][j][k+t] or dp[i-1][j][abs(k-t)]
for i in range(12801):
  if dp[h-1][w-1][i]:
    print(i)
    break


### FIXED CODE ###

a,b,c=map(int,input().split())
if a+b+c>21:
  print("bust")
else:
  print("win")
a,b = int(input())
ans = 0
for i in range(a,b+1):
  j = str(i)[::-1]
  if i == int(j):
    ans += 1
print(ans)

### FIXED CODE ###

a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
  j = str(i)[::-1]
  if i == int(j):
    ans += 1
print(ans)
# coding: utf-8
import sys
input = sys.stdin.readline

N = input()
S = sum([int(x) for x in N])
print("Yes" if int(N)%S==0 else "No")

### FIXED CODE ###

# coding: utf-8
N= input()
S = sum(map(int, N))
print("Yes" if int(N)%S==0 else "No")
try:c,d=map(int,input().split())
except:d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

### FIXED CODE ###

s=list(map(int,input().split()))
if len(s)>1:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)