Harryxun/stf_run huggingface dataset:
import math

n,m=map(int,input().split())
r=list(map(int,input().split()))
c=list(map(int,input().split()))
r.sort(reverse=True)
c.sort(reverse=True)
a=min(min(r),min(c))
dict1={}
dict2={}
for i in range(n):
    dict1.setdefault(r[i],0)
    dict1[r[i]]+=1
for i in range(m):
    dict2.setdefault(c[i],0)
    dict2[c[i]]+=1
x,y=0,0
ans=1
if dict1.get(n*m)*dict2.get(n*m)>1:
    print(0)
    exit()
for i in range(n*m,a-1,-1):
    table=x*y
    ex=table-(n*m-i)
    dy=dict1.get(i,0)
    dx=dict2.get(i,0)
    x+=dx
    y+=dy
    if dx*dy==1:
        ans*=1
    elif dx==0 and dy==1:
        ans*=x
    elif dy==0 and dx==1:
        ans*=y
    else:
        ans*=(x*y-(n*m-i))
b=math.factorial(a-1)
mod=10**9+7
ans*=(b%mod)
print(ans%mod)

### FIXED CODE ###

n,m=map(int,input().split())
r=list(map(int,input().split()))
c=list(map(int,input().split()))
r.sort(reverse=True)
c.sort(reverse=True)
dict1={}
dict2={}
for i in range(n):
    dict1.setdefault(r[i],0)
    dict1[r[i]]+=1
for i in range(m):
    dict2.setdefault(c[i],0)
    dict2[c[i]]+=1
x,y=0,0
ans=1
mod=10**9+7
for i in range(n*m,0,-1):
    dy=dict1.get(i,0)
    dx=dict2.get(i,0)
    if dx*dy==1:
        x+=1
        y+=1
    elif dx==0 and dy==1:
        ans*=x
        y+=1
    elif dy==0 and dx==1:
        ans*=y
        x+=1
    else:
        ans*=(x*y-(n*m-i))
        ans%=mod
print(ans%mod)
def makePath(x):
    for y in G[x]:
        if hist[y]==0:
            A.append(y)
            hist[y] = 1
            makePath(y)
            return
N,M = map(int,input().split())
G = {}
for _ in range(M):
    a,b = map(int,input().split())
    if a not in G:
        G[a] = []
    G[a].append(b)
    if b not in G:
        G[b] = []
    G[b].append(a)
A = [1]
hist = [0 for _ in range(N+1)]
hist[1] = 1
makePath(1)
B = A.copy()
A = []
makePath(1)
A = A[::-1]
A += B
print(len(A))
print(*A)

### FIXED CODE ###

from collections import deque
def makePath():
    que = deque([1])
    while que:
        x = que.pop()
        for y in G[x]:
            if hist[y]==0:
                que.append(y)
                A.append(y)
                hist[y]=1
                break
N,M = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
A = [1]
hist = [0 for _ in range(N+1)]
hist[1] = 1
makePath()
B = A[:]
A = []
makePath()
A = A[::-1]
A += B
print(len(A))
print(*A)
N,M=map(int,input().split())                            # 1行2列
List=[list(map(int,input().split())) for i in range(M)] # N行C列・・・Cは任意


if N == 1:
	answer = ' '
elif N == 2:
	answer = '  '
elif N == 3:
	answer = '   '

ok = 0
for search in List:
	# search[0]:桁数
	# search[1]:値
	if answer[search[0]-1] == str(search[1]) or answer[search[0]-1] == ' ':
		if N != 1 and search[0] == 1 and search[1] == 0:
			ok = -1
			break
		else:
			anslist = list(answer)
			anslist[search[0]-1] = str(search[1])
			answer = ''.join(anslist)
	else:
		ok = -1
		break

if ok == -1:
	print(-1)
else:
	for i in range(N):
		if answer[i] == ' ':
			anslist = list(answer)
			
			if i == 0 and N != 1:
				anslist[i] = '1'
			else:
				anslist[i] = '0'
			
			answer = ''.join(anslist)
	print(answer)


### FIXED CODE ###

N=int(input())                                          # 1行1列


if N %2 == 0:
	print(int(N/2))
else:
	print(int((N+1)/2))
from collections import Counter, defaultdict
G = defaultdict(list)
C = Counter()
N = int(input())
ans = {}
o = []
for i in range(N-1):
    a, b = map(int, input().split())
    C[a] += 1
    C[b] += 1
    G[a].append(b)
    G[b].append(a)
    ans[(a, b)] = 0
    o.append((a,b))

a = C.most_common(1)[0][0]
b = C.most_common(1)[0][1]

visited = [False] * (N+1)
def dfs(v, p):
    visited[v] = True
    counter = 1
    for c in G[v]:
        if not visited[c]:
            if p != 0 and counter == ans[(v, p)]:
                counter += 1
            ans[(v, c)] = ans[(c, v)] = counter
            counter += 1
            dfs(c, v)

dfs(a, 0)

print(b)
for a,b in o:
    print(ans[(a,b)])

### FIXED CODE ###

from collections import Counter, defaultdict
from queue import Queue
G = defaultdict(list)

C = Counter()
N = int(input())
ans = {}
o = []
for i in range(N-1):
    a, b = map(int, input().split())
    C[a] += 1
    C[b] += 1
    G[a].append(b)
    G[b].append(a)
    ans[(a, b)] = 0
    o.append((a,b))

cs = [0] * (N+1)
def bfs(v):
    ret = 0
    visited = set()
    q = Queue()
    visited.add(v)
    q.put(v)
    while not q.empty():
        v = q.get()
        counter = 1
        for c in G[v]:
            if not c in visited:
                visited.add(c)
                if counter == cs[v]:
                    counter += 1
                cs[c] = ans[(c,v)] = ans[(v,c)] = counter
                counter += 1
                q.put(c)

bfs(1)
print(C.most_common(1)[0][1])
for a,b in o:
    print(ans[(a,b)])
import math
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
#a=list(set(a))
#n=len(a)

ans=0
if n==2: print(max(a))
else:
    for i in range(n):
        b=np.array([a[j] for j in np.delete(np.array(range(n)),i)]) 
        while len(b)>1:
            d=math.gcd(b[0],b[1])
            b=np.delete(b,0)
            b[0]=d
        c=b[0]
        if ans<c: ans=c
    print(ans)    

### FIXED CODE ###

#c
n=int(input())
a=[int(i) for i in input().split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
l=[1]*n
r=[1]*n
l[0]=a[0]
r[0]=a[n-1]
for i in range(1,n):
    l[i] = gcd(l[i-1],a[i])
    r[i] = gcd(r[i-1],a[n-i-1])
if n>=3:
    ans = max(l[-2],r[-2],max(gcd(l[i-1],r[n-i-2]) for i in range(1,n-1)))
    print(ans)
else:
    print(max(a))
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	switch(a){
		case "A":cout<<"T"<<endl;
		case "T":cout<<"A"<<endl;
		case "C":cout<<"G"<<endl;
		case "G":cout<<"C"<<endl;
	}
	return 0;
}


### FIXED CODE ###

a = input()
if a == "T":
  print("A")
elif a=="A":
  print("T")
elif a=="C":
  print("G")
else:
  print("C")
from math import gcd

n = int(input())
a = list(map(int, input().split()))
b = a[::-1]

left = [0, a[0]]
right = [0, b[0]]
l = a[0]
r = b[0]
for i in range(1, n):
    l = gcd(l, a[i])
    r = gcd(r, b[i])
    left.append(l)
    right.append(r)

gcd_max = 0
for i in range(n+1):
    gcd_tmp = gcd(left[i], right[n-i-1])
    if gcd_tmp > gcd_max:
        gcd_max = gcd_tmp

print(gcd_max)


### FIXED CODE ###

import fractions

n = int(input())
a = list(map(int, input().split()))
b = a[::-1]

left = [0, a[0]]
right = [0, b[0]]
l = a[0]
r = b[0]
for i in range(1, n):
    l = fractions.gcd(l, a[i])
    r = fractions.gcd(r, b[i])
    left.append(l)
    right.append(r)

gcd_max = 0
for i in range(n+1):
    gcd_tmp = fractions.gcd(left[i], right[n-i-1])
    if gcd_tmp > gcd_max:
        gcd_max = gcd_tmp

print(gcd_max)
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

#if len(params) == 1:
#    print(*params[0])

#else:

#Cx, Cy, H = 0, 0, 0
for cxi, cyi in itertools.product(range(101), range(101)):
    hight_ = params[0][2] + abs(params[0][0] - cxi) + abs(params[0][1] - cyi)

    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

            if hight < 1:
                break
            else:
                if hight != hight_:
                    break
                else:
                    hight_ = hight

        elif params[k][2] == 0:
            if 1 > (abs(params[k][0] - cxi) + abs(params[k][1] - cyi)):
                break
    
    else:
        Cx = cxi
        Cy = cyi
        H = hight
    continue

print(Cx, Cy, H)

### FIXED CODE ###

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi in range(101):
    for cyi in range(101):
        for k in range(N):
            if params[k][2] > 0:
                hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

        for k in range(N):
            if params[k][2] != max((hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi)), 0):
                break
        
        else:
            print(cxi, cyi, hight)
s = input()
a = [int(c) for c in s]

if a[-3] != 0:
    ans = int(s) - (a[-4]*1000)
else:
    ans = 0

print(ans)

### FIXED CODE ###

s = input()
a = [int(c) for c in s]


if len(a) < 4:
    print(1000 - int(s))
elif a[-3] != 0:
    print((a[-4]+1)*1000 - int(s))
elif int(s) % 1000 != 0:
    print((a[-4]+1)*1000 - int(s))
else:
    print(0)
def GCD(x, y): 
   if y > x:
      y,x = x,y
    while(y): 
       x, y = y, x % y 
  
   return x 
n = int(input())
l = list(map(int, input().strip().split()))
maxe = -1
     
for i in range(n):
    for j in range(n):
        if i != j:
            g = GCD(l[i],l[j])
            maxe = max(maxe, g)
print(maxe)

### FIXED CODE ###

from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
 
X1 = [0] * (N+2)
X2 = [0] * (N+2)
 
for i in range(N):
    X1[i+1] = gcd(X1[i], A[i])
for i in range(N,0,-1):
    X2[i] = gcd(X2[i+1], A[i-1])

k = []
for i in range(N):
    k.append(gcd(X1[i],X2[i+2]))

print(max(k))
def christmasday():
    print("22から25までの数値を入力して下さい")
    number = int(input())

    if number == 22:
        print("Christmas Eve Eve Eve")
        break
    elif number == 23:
        print("Christmas Eve Eve")
        break
    elif number == 24:
        print("Christmas Eve")
        break
    elif number == 25:
        print("Christmas")
        break
    else:
        print("22から25までの数値を入力して下さい")
        number = int(input())
christmasday()


### FIXED CODE ###

def christmasday():
    D = int(input())
    if D == 22:
        print("Christmas Eve Eve Eve")
    elif D == 23:
        print("Christmas Eve Eve")
    elif D == 24:
        print("Christmas Eve")
    elif D == 25:
        print("Christmas")
christmasday()
s = list(input())
l = len(s)
if s[0] == 'A':
    c_cnt = 0
    cn_l = []
    for i, m in enumerate(s):
        if 1<i<l-1 & m=='C':
            cn_l.append(i)
            c_cnt += 1
    if c_cnt == 1:
        cn = cn_l[0]
        tmp = s
        tmp.pop(0)
        tmp.pop(cn)
        tmp_s = ''.join(tmp)
        if tmp_s == tmp_s.lower():
            print('AC')
else:
    print('WA')

### FIXED CODE ###

s = list(input())
l = len(s)
if s[0] == 'A':
    c_cnt = 0
    cn_l = []
    for i, m in enumerate(s):
        if 1<i<l-1 and m=='C':
            cn_l.append(i)
            c_cnt += 1
    if c_cnt == 1:
        cn = int(cn_l[0])
        tmp = s
        tmp.pop(0)
        tmp.remove('C')
        tmp_s = ''.join(tmp)
        if tmp_s == tmp_s.lower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')
from collections import deque
H, W = map(int, input().split())
C = list(map(int, input().split()))
D = list(map(int, input().split()))
S = [list(map(str, input())) for _ in range(H)]
T = [[-1 for _ in range(W)] for __ in range(H)] #その点にスタート地点から到達するためのワープの回数
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
ddx = [1,1,-1,-1,2,2,2,2,2,1,1,0,0,-1,-1,-2,-2,-2,-2,-2]
ddy = [1,-1,1,-1,-2,-1,0,1,2,2,-2,-2,2,-2,2,-2,-1,0,1,2]
def dfs(y,x,warp):
  # 移動Aで行けるところを埋める
  T[y][x] = warp
  for i in range(4):
    nx = x + dx[i]
    ny = y + dy[i]
    if 0 <= nx < W and 0 <= ny < H:
      if S[ny][nx] != "#" and T[ny][nx] == -1:
        dfs(ny,nx,warp)
  for i in range(len(ddx)):
    nx = x + ddx[i]
    ny = y + ddy[i]
    if 0 <= nx < W and 0 <= ny < H:
      if S[ny][nx] != "#" and T[ny][nx] == -1:
        dfs(ny,nx,warp+1)
  

dfs(C[0]-1,C[1]-1,0)
print(T[D[0]-1][D[1]-1])

### FIXED CODE ###

from collections import deque
f_inf = float('inf')
H, W = map(int, input().split())
sh, sw = map(int, input().split())
sh, sw = sh-1, sw-1
eh, ew = map(int, input().split())
eh, ew = eh-1, ew-1
S = [list(input()) for _ in range(H)]
m = [[f_inf]*W for _ in range(H)]
m[sh][sw] = 0
que = deque([])
que.appendleft([sh,sw])
while que:
  h, w = que.popleft()
  for dh, dw in ((1,0), (-1,0), (0, 1), (0, -1)):
    next_h, next_w = h + dh, w + dw
    if 0 <= next_h < H and 0 <= next_w < W and S[next_h][next_w] == ".":
        if m[next_h][next_w] > m[h][w]:
          m[next_h][next_w] = m[h][w] # 移動Aで行けるところにmの値を合わせる
          que.appendleft([next_h,next_w])
  for dh in range(-2, 3):
    for dw in range(-2, 3): # 移動Bで行ける範囲
      next_h, next_w = h + dh, w + dw
      if 0 <= next_h < H and 0 <= next_w < W and S[next_h][next_w] == ".":
        if m[next_h][next_w] > m[h][w] + 1: # h,wから移動Aですでに行けているところは更新されない
          m[next_h][next_w] = m[h][w] + 1 
          que.append([next_h, next_w]) # appendleftではなくappend 優先順位が後
print(m[eh][ew] if m[eh][ew] != f_inf else -1)
A=int(input())
B=int(input())
print(A*B)

### FIXED CODE ###

a,b= map(int,input().split())
print(a*b)
N = int(input())
A = list(map(int, input().split(' ')))

answer = 'YES'
check = [False] * max(A)
for a in A:
    if check[a-1] == True:
        answer = 'NO'
        break
    else:
        check[a-1] = True
print(answer)

### FIXED CODE ###

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

answer = 'YES'
check_dic = {}
for a in A:
    if a in check_dic:
        answer = 'NO'
        break
    else:
        check_dic[a] = True
print(answer)
n = int(input())
H = list(map(int, input().split()))
dp = [0]*n
dp[0] = 1
for i in range(1, n-1):
    if H[i] >= H[i+1]:
        dp[i] += dp[i-1]+1
    else:
        dp[i] = 0
print(max(dp[1:]))
         


### FIXED CODE ###

n = int(input())
H = list(map(int, input().split()))
dp = [0]*n
dp[0] = 1

if n == 1:
    print(0)
else:
    for i in range(1, n-1):
        if H[i] >= H[i+1]:
            dp[i] += dp[i-1]+1
        else:
            dp[i] = 0
    print(max(dp[1:]))
import numpy as np

from sys import stdin


def main():
    n, m = map(int, stdin.readline().split())
    a = list(map(int, stdin.readline().split()))
    a = np.array(a)

    ans = n - np.sum(a)

    print(-1) if ans < 0 else print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import numpy as np

from sys import stdin


def main():
    n, m = map(int, stdin.readline().split())
    a = list(map(int, stdin.readline().split()))
    a = np.array(a)

    ans = n - np.sum(a)

    print(-1) if ans < 0 else print(ans)


if __name__ == "__main__":
    main()
h, w = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(h)]
visited = [[False] * w for _ in range(h)]

dt = "right"
c = [0, 0]
cnt = 0
ans = []
while cnt < h * w:
    cnt += 1
    visited[c[0]][c[1]] = True
    if dt == "right":
        if arr[c[0]][c[1]] % 2 == 1:
            arr[c[0]][c[1]] -= 1
            arr[c[0]][c[1] + 1] += 1
            ans.append([c[0] + 1, c[1] + 1, c[0] + 1, c[1] + 2])
        if c[1] + 1 == w - 1 or visited[c[0]][c[1] + 1]:
            dt = "down"
        c = [c[0], c[1] + 1]
        continue
    if dt == "down":
        if arr[c[0]][c[1]] % 2 == 1:
            arr[c[0]][c[1]] -= 1
            arr[c[0] + 1][c[1]] += 1
            ans.append([c[0] + 1, c[1] + 1, c[0] + 2, c[1] + 1])
        if c[0] + 1 == h - 1 or visited[c[0] + 1][c[1]]:
            dt = "left"
        c = [c[0] + 1, c[1]]
        continue
    if dt == "left":
        if arr[c[0]][c[1]] % 2 == 1:
            arr[c[0]][c[1]] -= 1
            arr[c[0]][c[1] - 1] += 1
            ans.append([c[0] + 1, c[1] + 1, c[0] + 1, c[1]])
        if c[1] - 1 == 0 or visited[c[0]][c[1] - 1]:
            dt = "up"
        c = [c[0], c[1] - 1]
        continue
    if dt == "up":
        if arr[c[0]][c[1]] % 2 == 1:
            arr[c[0]][c[1]] -= 1
            arr[c[0] - 1][c[1]] += 1
            ans.append([c[0] + 1, c[1] + 1, c[0], c[1] + 1])
        if c[0] - 1 == 0 or visited[c[0] - 1][c[1]]:
            dt = "right"
        c = [c[0] - 1, c[1]]
        continue

print(len(ans))
for x in ans:
    print(*x)

### FIXED CODE ###

h, w = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(h)]

ans = []
for i in range(h):
    for j in range(w - 1):
        if arr[i][j] % 2 == 1:
            arr[i][j] -= 1
            arr[i][j + 1] += 1
            ans.append([i + 1, j + 1, i + 1, j + 2])

for i in range(h - 1):
    if arr[i][w - 1] % 2 == 1:
        arr[i][w - 1] -= 1
        arr[i + 1][w - 1] += 1
        ans.append([i + 1, w, i + 2, w])

print(len(ans))
for x in ans:
    print(*x)
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / float(n)
    if n == 0:
        break
    a2 = 0
    for s in score:
        a2 += (s - average) ** 2
    print("{0:.8f}".format(math.sqrt(a2) / n )

### FIXED CODE ###

import math
while True:
    n = int(input())
    if n == 0:
        break
    s = [int(i) for i in input().split(" ")]
    m = sum(s) / n
    print("{:.8f}".format(math.sqrt(sum([(x-m) ** 2 for x in s]) / n)))
N = int(input())
words = []
for i in range(N):
  word = list(input())
  if i == 0:
    words.append(word[len(word)])
  elif i == N-1:
    words.append(word[0])
  else:
    words.append(word[0])
    words.append(word[len(word)])
  
if len(set(words))*2 - len(words) == 0:
  print("Yes")
else:
  print("No")
  
  

### FIXED CODE ###

N = int(input())
words = []
l = []
for i in range(N):
    a = input()
    if i == 0:
        l.append(a)
        b = list(a)
        words.append(b[len(b)-1])
    elif i > 0:
        b = list(a)
        if i == N-1:
            words.append(b[0])
        else:
            words.append(b[0])
            words.append(b[len(b)-1])
        l.append(a)

if len(set(l)) != len(l):
    print("No")
    exit()

for h in range(0,len(words),2):
    if words[h] != words[h+1]:
        print("No")
        exit()
print("Yes")
m,n=map(int,input().split())
a=input().split()
while n>0:
  m= m-a[n-1]
  n=n-1
if m>=0:
  print(m)
else:
  print(-1)

### FIXED CODE ###

m,n=map(int,input().split())
a=list(map(int,input().split()))
while n>0:
  m= m-a[n-1]
  n=n-1
if m>=0:
  print(m)
else:
  print(-1)
from collections import Counter
import heapq

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

cur = n-1
bit = 1
for i in range(n):
    if a[i] == b[i]:
        while a[i]==b[cur]:
            cur-=bit
            if cur == 0:
                bit = -1
            if bit == -1 and cur == n-1:
                print('No')
                exit(0)
        b[i], b[cur] = b[cur], b[i]
print('Yes')
print(' '.join(list(map(str, b))))
    
    


### FIXED CODE ###

from collections import Counter
import heapq

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

cur = n-1
bit = 1
for i in range(n):
    if a[i] == b[i]:
        while a[i]==b[cur] or a[cur]==b[i]:
            if cur == 0:
                bit = -1
            if bit == -1 and cur == n-1:
                print('No')
                exit(0)
            cur-=bit
        b[i], b[cur] = b[cur], b[i]
print('Yes')
print(' '.join(list(map(str, b))))
import numpy as np
N = int(input())
ar = np.arange(1, N)
total = np.sum(ar)
print(total)

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
total = sum(range(1, N))
  
print(total)
from collections import Counter
N=input()
K=int(input())
res = 0
if int(N)<=100:
    for i in range(int(N)):
        c = Counter(str(i+1))
        if len(str(i+1)) - c['0']==K:
            res += 1
    print(res)
    exit()
else:
    for i in range(1,100):
        c = Counter(str(i))
        k = len(str(i)) - c['0']
        dic[str(k)] += 1
def rec(n,k):
    re = 0
    if int(n)<=1000:
        re = 0
        for i in range(int(n)):
            c = Counter(str(i+1))
            if len(str(i+1)) - c['0']==k:
                re += 1
        return re
    if k==1:
        return 9*(len(n)-1)+int(n[0])
    t = ''.join(['9']*(len(n)-1))
    return rec(t, k) + (int(n[0])-1)*rec(t, k-1) + rec(n[1:], k-1)
print(rec(N,K))


### FIXED CODE ###

from collections import Counter
N=input()
K=int(input())
km = len(N)
res = 0
if int(N)<=1000:
    for i in range(int(N)):
        c = Counter(str(i+1))
        if len(str(i+1)) - c['0']==K:
            res += 1
    print(res)
    exit()
d = [[0]*3 for _ in range(100001)]
for i in range(100000):
    d[i+1] = d[i][:]
    c = Counter(str(i+1))
    k=len(str(i+1)) - c['0']
    if k<=3:
        d[i+1][k-1] += 1
def rec(n,k):
    re = 0
    if int(n)<100000:
        re = 0
        return d[int(n)][k-1]
    if k==1:
        n = str(int(n))
        return 9*(len(n)-1)+int(n[0])
    t = ''.join(['9']*(len(n)-1))
    t2 = t
    w = (int(n[0])-1)
    if n[0] == '0':
        t2 = n[1:]
        w = 0
    return rec(t2, k) + w*rec(t2, k-1) + rec(str(int(n[1:])), k-1)
print(rec(N,K))
n = int(input())
h = list(map(int,input().split()))

dp = [0, abs(h[1]-[0])]

for i in range(2,n):
    dp.append(min(dp[i-1] + abs(h[i]-h[i+1]), dp[i] + abs(h[i]-h[i+2])))
    
print(dp[-1])

### FIXED CODE ###

n=int(input())
h=list(map(int, input().split())) 
dp=[float('inf')]*n
dp[0]=0
for i in range(n-1):
  dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
  if i < n - 2:
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
print(dp[n-1])
N,K,C=map(int,input().split())
S=input()
L=[0 for i in range(K)]
R=[0 for i in range(K)]
n=0
rc=0
lc=0
while True:
  if lc==K:
    break
  if S[n]=="o":
    L[lc]=n+1
    n+=C+1
    lc+=1
  else:
    n+=1
n=N-1
while True:
  if rc==K:
    break
  if S[n]=="o":
    R[N-1-rc]=n+1
    n-=C+1
    rc+=1
  else:
    n-=1
for i in range(K):
  if R[i]==L[i]:
    print(R[i])


### FIXED CODE ###

N,K,C=map(int,input().split())
S=input()
L=[0 for i in range(K)]
R=[0 for i in range(K)]
n=0
rc=0
lc=0
while True:
  if lc==K:
    break
  if S[n]=="o":
    L[lc]=n+1
    n+=C+1
    lc+=1
  else:
    n+=1
n=N-1
while True:
  if rc==K:
    break
  if S[n]=="o":
    R[K-1-rc]=n+1
    n-=C+1
    rc+=1
  else:
    n-=1
for i in range(K):
  if R[i]==L[i]:
    print(R[i])
s = input()
if s == 'ABC':
  print()'ARC'
else:
  print('ABC')

### FIXED CODE ###

S = input()
if S == "ABC":
  print("ARC")
else:
  print('ABC')
N,K=map(int,input().split())
S=input()
if N==1:
    print(1)
    exit()

lst0=[]

lst1=[]
if S[0]!="1":
    lst1.append([0,0])
flag=0
for i in range(N):
    if flag==0 and S[i]=="1":
        flag=1
        st=i
    elif flag and S[i]=="0":
        lst1.append([st,i-1])
        flag=0
if S[-1]!="1":
    lst1.append([N-1,N-1])

if flag:
    lst1.append([st,N-1])
flag=0
for i in range(N):
    if flag==0 and S[i]=="0":
        flag=1
        st=i
    elif flag and S[i]=="1":
        lst0.append([st,i-1])
        flag=0
if flag:
    lst0.append([st,N-1])

if K>=len(lst1):
    print(N)
else:
    value=0
    for i in range(len(lst1)-K):
        a=lst1[i+K][1]-lst1[i][0] +1
        if a>value:
            value=a
print(value)


### FIXED CODE ###

N,K=map(int,input().split())
S=input()
if N==1:
    print(1)
    exit()


lst=[]
if S[0]!="1":
    lst.append([0,0])
flag=0
for i in range(N):
    if flag==0 and S[i]=="1":
        flag=1
        st=i
    elif flag and S[i]=="0":
        lst.append([st,i-1])
        flag=0
if S[-1]!="1":
    lst.append([N-1,N-1])

if flag:
    lst.append([st,N-1])

if K>=len(lst):
    print(N)
    exit()
else:
    value=0
    for i in range(len(lst)-K):
        a=lst[i+K][1]-lst[i][0] +1
        if a>value:
            value=a
print(value)