Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
import math
import numpy as np

if __name__ == '__main__':
    H, W, M = list(map(lambda x: int(x), sys.stdin.readline().split()))

    dic = {}
    # h = [0 for i in range(H)]
    # w = [0 for i in range(W)]
    h = np.zeros(H, dtype=np.int64)
    w = np.zeros(W, dtype=np.int64)
    for i in range(M):
        # P.append(list(map(lambda x: int(x), sys.stdin.readline().split())))
        x, y = list(map(lambda x: int(x), sys.stdin.readline().split()))
        x -= 1
        y -= 1
        h[x] += 1
        w[y] += 1
        dic[x*H+y] = 1
    
    lh = np.where(h == h.max())
    lw = np.where(w == w.max())

    mx = np.max(h)
    my = np.max(w)
    # print(mx, my)

    # print(lh[0])
    # print(lw[0])
    max = 0
    for i in lh[0]:
        for j in lw[0]:
            tmp = h[i] + w[j]
            if i*H+j in dic:
                tmp -= 1
            if tmp > max:
                max = tmp
    print(max)

### FIXED CODE ###

import sys
import math
import numpy as np

if __name__ == '__main__':
    H, W, M = list(map(lambda x: int(x), sys.stdin.readline().split()))

    dic = {}
    # h = [0 for i in range(H)]
    # w = [0 for i in range(W)]
    h = np.zeros(H, dtype=np.int64)
    w = np.zeros(W, dtype=np.int64)
    for i in range(M):
        # P.append(list(map(lambda x: int(x), sys.stdin.readline().split())))
        x, y = list(map(lambda x: int(x), sys.stdin.readline().split()))
        x -= 1
        y -= 1
        h[x] += 1
        w[y] += 1
        dic[x*H+y] = 1
    
    lh = np.where(h == h.max())
    lw = np.where(w == w.max())

    mx = np.max(h)
    my = np.max(w)
    # print(mx, my)

    # print(lh[0])
    # print(lw[0])


    tmp = mx + my
    for i in lh[0]:
        for j in lw[0]:
            if i*H+j not in dic:
                print(tmp)
                exit()
    print(tmp-1)
    exit()
### BUGGY CODE ###

n=int(input())
listl = [int(i) for i in input().split()]

listl.sort(reverse=True)

#print(listl)
ans=0
for i in range(n-2):
	for j in range(i+1,n-1):
		if listl[j]+listl[j+1]<=listl[i]:
			break
		for k in range(j+1,n):
		#	print(listl[i],listl[j],listl[k])
			if listl[i]<listl[j]+listl[k]:
				ans=ans+1
			else:
				break	
print(ans)
				 
		

### FIXED CODE ###

n=int(input())
listl = [int(i) for i in input().split()]

"""listl.sort(reverse=True)

#print(listl)
	ans=0
for i in range(n-2):
	for j in range(i+1,n-1):
		if listl[j]<=(listl[i]/2):
			break
		for k in range(j+1,n):

			if listl[i]<listl[j]+listl[k]:
				ans=ans+1
			else:
				break	

print(ans)"""
from bisect import bisect_right				 
listl.sort()

ans=0

for i in range(n-1,1,-1):
	a=listl[i]
	for j in range(i-1,0,-1):
		b=listl[j]
		c=bisect_right(listl,a-b)
		#print(c)
		num = j-c
		if num>0:
			ans+=num
print(ans)
### BUGGY CODE ###

import math
a, b = map(int, input().split())
ans = []

for i in range(1,min(a,b)+1):
    if a%i == 0 and b%i ==0:
        while True:
            for j in range(2,int(math.sqrt(i))+1):
                if i%j==0:
                    break
            else:
                ans.append(i)
            break
            
print(len(ans))

### FIXED CODE ###

import collections

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

def trial_division(n):
    a = []  
    while n % 2 == 0:
        a.append(2)
        n /= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n /= f
        else:
            f += 2   
    if n != 1: a.append(n)
    return a

def main():
    a, b = map(int, input().split())
    c = collections.Counter(trial_division(gcd(a, b)))
    print(len(c.keys())+1)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

#4
#1 3 1 1
G, N = [int(_) for _ in input().split(" ")]
ret = ()
for i in range(N):
  ret += (int(input()),)

T = [0]*(G+1)

T[0] = 1
T[1] = 1

if 1 in ret:
  T[1] = 0

for i in range(2, G+1):
	if i in ret:
		T[i] = 0
		continue
	T[i] = (T[i-1] + T[i-2]) % 1000000007

print (T[G])

### FIXED CODE ###

G, N = [int(_) for _ in input().split(" ")]
ret = ()
T = [-1]*(G+1)
T[0] = 1
T[1] = 1
for i in range(N):
  t = int(input())
  T[t] = 0

for i in range(2, G+1):
	if T[i] == -1:
		T[i] = (T[i-1] + T[i-2]) % 1000000007

print (T[G])
### BUGGY CODE ###

import sys
from math import factorial


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod



mod = 10**9 + 7
x, y = map(int, sys.stdin.readline().split())

if (x + y)%3 != 0:
    print(0)
    sys.exit()
if y < x/2 and y > 2*x:
    print(0)
    sys.exit()

count = 0
while(True):
    if y == 1/2*x:
        break
    else:
        x -= 1
        y -= 2
        count += 1
sum = count + y

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, sum + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if count < y:
    a = cmb(sum,count,mod)
else:
    a = cmb(sum, y, mod)

print(a)


### FIXED CODE ###

import sys
from math import factorial


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9 + 7
x, y = map(int, sys.stdin.readline().split())

if (x + y)%3 != 0:
    print(0)
    sys.exit()
if y < x/2 and y > 2*x:
    print(0)
    sys.exit()

count1 = int((y-2*x)/(-3))
count2 = int((x-2*y)/(-3))

sum = count1 + count2

N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, sum + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(sum,count1,mod)

print(a)
### BUGGY CODE ###

N,M = map(int,input().split(' '))
A = list(map(int,input().split(' ')))
l = [list(map(int,input().split())) for i in range(M)]

A.sort()
l = sorted(l,key = lambda x:x[1])

ind =0
for b,c in l[::-1]:
    mx = min(N,ind+b)
    for i in range(ind,mx):
        if c>A[0]:
            A = A[1:]
            A.append(c)
    if mx==N:
        break
    ind += b
print(sum(A))

### FIXED CODE ###

N,M = map(int,input().split(' '))
A = list(map(int,input().split(' ')))
l = [list(map(int,input().split())) for i in range(M)]

A.sort()
l = sorted(l,key = lambda x:x[1])

ind =0
for b,c in l[::-1]:
    mx = min(N,ind+b)
    for i in range(ind,mx):
        if c>A[i]:
            A[i] = c
    if mx==N:
        break
    ind += b
print(sum(A))
### BUGGY CODE ###

n = int(input())
x = list(map(int,input().split()))
cost = 0
for i in range(n):
    y = x[:i]+x[i+1:]
    cost+=abs(y[0])+abs(y[n-2])
    for j in range(n-2):
        cost+=abs(y[j]-y[j+1])
    print(cost)
    cost=0

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
x = [0]+x+[0]
cost = 0
for i in range(n+1):
    cost+=abs(x[i]-x[i+1])
for i in range(1,n+1):
    cost2 = cost - abs(x[i]-x[i-1]) - abs(x[i]-x[i+1]) + abs(x[i-1]-x[i+1])
    print(cost2)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
a,b,k = map(int,input().split())

for i in range(k):
  if a >= 1:
    a = a-1
  elif b >= 1:
    b = b-1
  else:
    pass
print(a,b)

### FIXED CODE ###

a,b,k = map(int,input().split())

if a > k:
  print(a-k,b)
elif a == k:
  print(0,b)
else:
  if (a+b) > k:
    print(0,a+b-k)
  else:
    print(0,0)
### BUGGY CODE ###

N, M = map(int, input().split())
dic = {}
raw = []
dic[1] = []
for i in range(M):
  P, Y = map(int, input().split())
  raw.append([P, Y])
  dic.setdefault(P, list())
  dic[P].append(Y)
for i in dic.keys():
    dic[i].sort()
for i in range(M):
  P, Y = raw[i]
  ind = dic[P].index(Y)
  P = "{0:06d}".format(P)
  Y = "{0:06d}".format(ind+1)
  print(P+Y)

### FIXED CODE ###

N, M = map(int, input().split())
dic = {}
raw = []
dic[1] = []
for i in range(M):
  P, Y = map(int, input().split())
  raw.append([P, Y, i])
raw.sort()
for i in range(M):
  if i == 0:
    raw[i][1] = 1
    p, y, ind = raw[i]
    continue
  pp, yy, iind = raw[i]
  if pp == p:
    raw[i][1] = y + 1
  else:
    raw[i][1] = 1
  p, y, ind = raw[i]
raw.sort(key = lambda x:x[2])
for r in raw:
    p, y, ind = r
    P = "{0:06d}".format(p)
    Y = "{0:06d}".format(y)
    print(P+Y)
### BUGGY CODE ###

import numpy as np

N, K = map(int, input().split())
hs = np.array(list(map(int, input().split())))

i = 0
total_cost = 0
 
a = np.zeros(N, int)
a[0] = 0
a[1] = abs(hs[1] - hs[0])

for i in range(2, N):
    bmin = float('inf')
    for j in range(max(i-K,0),i):
        if i-j+1 >= 0:
        	bmin = min(bmin, a[j] + abs(hs[i] - hs[j]))    
        else:
        	break
    a[i] = bmin
print(a[-1])


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
hs = np.array(list(map(int, input().split())))

i = 0
total_cost = 0
 
a = np.zeros(N, dtype=np.int64)
a[0] = 0
a[1] = abs(hs[1] - hs[0])

for i in range(2, N):
    k = min(K,i)
    a[i] = np.min(a[i-k:i] + np.abs(hs[i] - hs[i-k:i]))    
print(a[-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Thu May  7 13:56:40 2020

@author: shinba
"""
import sys
from collections import deque

s = input()
q = int(input())

dq = deque(s)

for i in range(q):
    t = sys.stdin.readline().rstrip().split()
    if t[0] == "1":
        dq.reverse()
    else:
        if t[1] == "1":
            dq.appendleft(t[2])
        else:
            dq.append(t[2])

print("".join(list(dq)))
        
        


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Thu May  7 13:56:40 2020

@author: shinba
"""
import sys
from collections import deque

s = input()
q = int(input())

dq = deque(s)
rev = False

for i in range(q):
    t = sys.stdin.readline().rstrip().split()
    if t[0] == "1":
        rev = not rev
    else:
        if t[1] == "1":
            if rev:
                dq.append(t[2])
            else:
                dq.appendleft(t[2])
        else:
            if rev:
                dq.appendleft(t[2])
            else:
                dq.append(t[2])

s = "".join(list(dq))

if rev:
    print(s[::-1])
else:
    print(s)
### BUGGY CODE ###

import copy
n=int(input())
a=list(int(input())for _ in range(n))

for i in range(n):
    x=copy.copy(a)
    del x[i]
    print(max(x))
    

### FIXED CODE ###

n=int(input())
a=list(int(input())for _ in range(n))
b=sorted(a,reverse=True)
for i in range(n):
    if b[0]!=a[i]:
        print(b[0])
    else:
     print(b[1])
### BUGGY CODE ###

from collections import deque
import sys

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

s = deque(list(input()))
q = int(input())

rev_cnt = 0
for i in range(q):
    query = input().split()
    if query[0] == '2':
        if (query[1] == '1' and rev_cnt % 2 == 0) or ((query[1] == '2' and rev_cnt % 2 == 1)):
            s.appendleft(query[2])
        else:
            s.append(query[2])
    else:
        rev_cnt += 1

if rev_cnt % 2 == 1:
    res = ''.join([s[i] for i in range(len(s) - 1, -1, -1)])
else:
    res = ''.join([s[i] for i in range(len(s))])

print(res)


### FIXED CODE ###

from collections import deque
import sys

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

s = deque(list(input()))
q = int(input())

rev_cnt = 0
for i in range(q):
    query = input().split()
    if query[0] == '2':
        if (query[1] == '1' and rev_cnt % 2 == 0) or ((query[1] == '2' and rev_cnt % 2 == 1)):
            s.appendleft(query[2])
        else:
            s.append(query[2])
    else:
        rev_cnt += 1

if rev_cnt % 2 == 1:
    print(''.join([s[len(s) - i - 1] for i in range(len(s))]))
else:
    print(''.join([c for c in s]))
### BUGGY CODE ###

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

def readInts():
  return [int(s) for s in input().split(" ")]

MOD = 10 ** 9 + 7

def main():
  S = input()
  dp = [[0 for _ in range(13)] for _a in range(len(S)+1)]

  coef = 1
  dp[0][0] = 1
  for i in range(len(S)):
    c = S[len(S) - 1 - i]
    if c == '?':
      for n in range(10):
        m = (coef * n) % 13
        for k in range(13):
          dp[i+1][(m + k) % 13] += dp[i][k]
          dp[i+1][(m + k) % 13] %= MOD
    else:
      n = int(c)
      m = (coef * n) % 13
      for k in range(13):
        dp[i+1][(m + k) % 13] += dp[i][k]
        dp[i+1][(m + k) % 13] %= MOD
    coef = (coef * 10) % 13
  print(dp[len(S)][5])

if __name__ == "__main__":
  main()


### FIXED CODE ###

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

def readInts():
  return [int(s) for s in input().split(" ")]

MOD = 10 ** 9 + 7

def main():
  S = input()
  dp = [[0 for _ in range(13)] for _a in range(len(S)+1)]

  coef = 1
  dp[0][0] = 1
  for i in range(len(S)):
    c = S[len(S) - 1 - i]
    if c == '?':
      for n in range(10):
        m = (coef * n) % 13
        for k in range(13):
          dp[i+1][(m + k) % 13] += dp[i][k]
          dp[i+1][(m + k) % 13] %= MOD
    else:
      n = int(c)
      m = (coef * n) % 13
      for k in range(13):
        dp[i+1][(m + k) % 13] += dp[i][k]
        dp[i+1][(m + k) % 13] %= MOD
    coef = (coef * 10) % 13
  print(dp[len(S)][5])

if __name__ == "__main__":
  main()
### BUGGY CODE ###

q = list(map(int, input().split()))
w= list(map(int, input().split()))
memo=0
a=0
for i in range(q[0]-q[1]+1):
  k=0
  for j in range(q[1]):
    k+=w[i+j]
  if a<k:
    a=k
    memo=i
print((a+q[1])/2)

### FIXED CODE ###

n,k= list(map(int, input().split()))
j = list(map(int, input().split()))
s=0
sumlist=[0]*(n+1)
anslist=[0]*(n-k+1)
for i in range(n):
    s+=j[i]
    sumlist[i+1]=s
for i in range(len(anslist)):
     z=sumlist[i+k]-sumlist[i]
     anslist[i]=z
ans=max(anslist)
ans+=k
ans=ans/2
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a for a in A if a <K]
N = len(A)
dp2 = [1] + [0]*K
dpm = [[0]*(K+1) for _ in range(N+1)]
dpm[0][0] = 1
for i, a in enumerate(A):
    for j in range(K, -1, -1):
        dpm[i+1][j] = dpm[i][max(0, j-a)] + dpm[i][j]
#print(dpm)

r = 0
for i, a in enumerate(A[::-1]):
    f = True
    for j in range(K, -1, -1):
        # 後ろiこの合計がjのもの
        if f and dp2[j] > 0:
            # K-j > x >= K-j-a
            if dpm[N-i-1][max(0, K-j-a)] > dpm[N-i-1][K-j]:
                f = False
        if j-a>=0:
            dp2[j] = dp2[j] + dp2[j-a]
    if f:
        r += 1
#    for j in range(K-1, 0, -1):
#        print("aa", i, N-i-1)
print(r)


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a for a in A if a <K]
N = len(A)
#dpm = [+1) for _ in range(N+1)]
dpm = [0]*(N+1)
dpm[0] = 1<<(K-1)
for i, a in enumerate(A):
    dpm[i+1] = dpm[i] | (dpm[i] >> a)

r = 0
dp2 = 1
for i, a in enumerate(A[::-1]):
    for j in range(a):
        if dp2 & dpm[N-i-1]:
            break
        dpm[N-i-1] >>= 1
    else:
        r += 1
    dp2 |= dp2<<a
    dp2 &= (1<<K)-1
print(r)
### BUGGY CODE ###

#https://atcoder.jp/contests/abc113/tasks/abc113_c


n,m=map(int,input().split())
PY=[list(map(int,input().split()))+[0] for i in range(m)]

sortPY=sorted(PY,key=lambda x: (x[0],x[1]))
Plist=[sortPY[i][0] for i in range(m)]

for i in range(m):
	sortPY[i][2]=Plist[0:i+1].count(Plist[i])


for i in range(m):
	print(str(PY[i][0]).zfill(6)+str(PY[i][2]).zfill(6))








### FIXED CODE ###

#https://atcoder.jp/contests/abc113/tasks/abc113_c


n,m=map(int,input().split())
PY=[list(map(int,input().split()))+[0] for i in range(m)]

sortPY=sorted(PY,key=lambda x: x[1])

city={}

for i in range(m):
	p=sortPY[i][0]
	if p in city:
		city[p]+=1
	else:
		city[p]=1
	sortPY[i][2]=city[p]


for i in range(m):
	print(str(PY[i][0]).zfill(6)+str(PY[i][2]).zfill(6))
### BUGGY CODE ###

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''


num = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()
res = []
for el in range(1, num + 1):
    res.append(str(data.index(str(el)) + 1))
print(' '.join(res))


### FIXED CODE ###

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''


num = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()
lis = [''] * num
res = ''
count = 1
for el in data:
    lis[int(el)-1] = str(count)
    count += 1
print(' '.join(lis))
### BUGGY CODE ###

n=int(input())
a=[int(_) for _ in input().split()]
ans=-10**15
for i in range(n,2*n+1):ans=max(ans, sum(sorted(a[:i])[i-n:])-sum(sorted(a[i:])[:n]))
print(ans)

### FIXED CODE ###

from heapq import heappush,heappop
n=int(input()); a=[int(_) for _ in input().split()]
fh=[]; lh=[]
for i in range(n):
    heappush(fh, a[i])
    heappush(lh, -1*a[-i-1])
f=[sum(fh)]; l=[-1*sum(lh)]
for i in range(n,2*n):
    heappush(fh, a[i]); f.append(f[-1]+a[i]-heappop(fh))
    heappush(lh, -1*a[-i-1]); l.append(l[-1]+a[-i-1]+heappop(lh))
ans=-10**15
for i,j in zip(f,l[::-1]):ans=max(ans, i-j)
print(ans)
### BUGGY CODE ###

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


[N, Q] = ii()
S = input()
Q_list = [ii() for _ in range(Q)]

for q in Q_list:
    sub_s = S[q[0] - 1:q[1]]
    print(sub_s.count("AC"))


### FIXED CODE ###

from bisect import bisect_left, bisect_right


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


[N, Q] = ii()
S = input()
Q_list = [ii() for _ in range(Q)]

AC_idx = []
try:
    start_idx = 0
    while True:
        found_idx = S.index("AC", start_idx)
        AC_idx.append(found_idx)
        start_idx = found_idx + 1
except ValueError as e:
    pass

for q in Q_list:
    left_idx = bisect_left(AC_idx, q[0] - 1)
    right_idx = bisect_right(AC_idx, q[1] - 2)
    print(right_idx - left_idx)
### BUGGY CODE ###

from collections import deque
N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

ab.sort(key=lambda x :x[1])
ab=deque(ab)
num=0
while(ab):
    p=ab.popleft()
    num+=1
    e=p[1]
    q=deque()
    for i in range(len(ab)):
        if ab[i][0]>=e:
            q.append(ab[i])
    ab=q
print(num)

### FIXED CODE ###

from collections import deque
N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

ab.sort(key=lambda x :x[1])
ans=deque()
for i in ab:
    if len(ans)>0:
        if i[0]<ans[-1] :
            continue
    ans.append(i[1])
print(len(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
S = input()
c0, c1 = [], []
if S[0] == '1':
    c0.append(0)
i = 0
while i < N:
    p = S[i]
    c = 1
    i += 1
    while i < N and S[i] == p:
        i += 1
        c += 1
    if p == '0':
        c0.append(c)
    else:
        c1.append(c)
if S[N-1] == '0':
    c1.append(0)
ans = sum(c0[0:K]) + sum(c1[0:K])
for i in range(1, len(c1) - K + 1):
    tmp = sum(c0[i:i + K]) + sum(c1[i-1:i + K])
    if ans < tmp:
        ans = tmp
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
S = input()
c0, c1 = [], []
if S[0] == '1':
    c0.append(0)
i = 0
while i < N:
    p = S[i]
    c = 1
    i += 1
    while i < N and S[i] == p:
        i += 1
        c += 1
    if p == '0':
        c0.append(c)
    else:
        c1.append(c)
if S[N-1] == '0':
    c1.append(0)
l0 = len(c0)
if l0 < K:
    K = l0
ans = sum(c0[0:K]) + sum(c1[0:K])
for i in range(1, l0):
    c0[i] += c0[i-1]
    c1[i] += c1[i-1]
l = l0 - K + 1
if l0 == 2 and S[0] == '1':
    ans = N
else:
    for i in range(1, l):
        tmp = c0[i+K-1] - c0[i-1] + c1[i+K-1]
        if i - 2 >= 0:
            tmp -= c1[i-2]
        if ans < tmp:
            ans = tmp
print(ans)
### BUGGY CODE ###

N = int(input())
ST = [[int(i) for i in input().split()] for j in range(N-1)]
for i in range(N-1):
    t = ST[i][1] + ST[i][0]
    for j in range(i+1,N-1):
        t = max(t, ST[j][1])
        while (t-ST[j][1])%ST[j][2] != 0:
            t += 1
        else:
            t += ST[j][0]
    else:
        print(t)
print(0)


### FIXED CODE ###

import math
N = int(input())
ST = [[int(i) for i in input().split()] for j in range(N-1)]
for i in range(N-1):
    t = ST[i][1] + ST[i][0]
    for j in range(i+1,N-1):
        t = max(t, ST[j][1])
        k = math.ceil((t-ST[j][1])/ST[j][2])
        t = k * ST[j][2] + ST[j][1] + ST[j][0]
    else:
        print(t)
print(0)
### BUGGY CODE ###

n, q=map(int, input().split())
s=list(input())
l_list=[]
r_list=[]
for i in range(q):
    l, r=map(int, input().split())
    l_list.append(l)
    r_list.append(r)

for i in range(q):
    count=0
    target_s=s[l_list[i]-1:r_list[i]]
    for j in range(len(target_s)-1):
        if target_s[j]=="A":
            if target_s[j+1]=="C":
                count=count+1
    print(count)


### FIXED CODE ###

n, q=map(int, input().split())
s=input()
l_list=[]
r_list=[]

t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

for i in range(q):
    l, r=map(int, input().split())
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]

s = input()
n = int(s)
l = len(s)
cnt = 0
mod = [[0]*(l-3) for i in range(l-3)]
#print(mod)
for w in range(4,l+1):
    for i in range(l+1-w):
        j = i + w
        if (w == 4):
            m = int(s[i:j])%2019
            mod[w-4][i] = m
            if m == 0:
                cnt += 1
        else:
            m = (int(s[i])*pow(10,w-1)+mod[w-5][i+1])%2019
            mod[w-4][w-4+i] = m
            if m == 0:
                cnt += 1
#print(mod)
print(cnt)

### FIXED CODE ###

def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]

s = input()
n = int(s)
l = len(s)
cnt = 0
mod = [0]*2019
m = 0
for i in range(l):
    m = (int(s[l-1-i])*pow(10,i,2019) + m)%2019
    mod[m] += 1

cnt += mod[0]

for i in range(2019):
    if mod[i] > 1:
        cnt += (mod[i]*(mod[i]-1))/2
        #print(i)
print(int(cnt))
### BUGGY CODE ###

N = int(input())
R = []
G = []
B = []
RD = []
GD = []
BD = []

S = input().rstrip()

for i, s in enumerate(S):
    if s == "R":
        R.append(i)
        RD.append(i*2)
    if s == "G":
        G. append(i)
        GD.append(i*2)
    if s == "B":
        B.append(i)
        BD.append(i*2)

ans = len(R) * len(G) * len(B)
for r in R:
    for b in B:
        if r + b in GD:
            ans -= 1
for b in B:
    for g in G:
        if b + g in RD:
            ans -= 1
for r in R:
    for g in G:
        if r + g in BD:
            ans -= 1
print(ans)


### FIXED CODE ###

N = int(input())
R = []
G = []
B = []
RD = {}
GD = {}
BD = {}

S = input().rstrip()

for i, s in enumerate(S):
    if s == "R":
        R.append(i)
        RD[i*2] = 1
    if s == "G":
        G. append(i)
        GD[i*2] = 1
    if s == "B":
        B.append(i)
        BD[i*2] = 1

ans = len(R) * len(G) * len(B)
for r in R:
    for b in B:
        if r + b in GD:
            ans -= 1
for b in B:
    for g in G:
        if b + g in RD:
            ans -= 1
for r in R:
    for g in G:
        if r + g in BD:
            ans -= 1
print(ans)