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

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

import sys
import os

for s in sys.stdin:
    n = int(s)

    T = [0] * 2001
    for a in range(1001):
        for b in range(1001):
            T[a+b] += 1

    sum_n_num = 0
    for a_b_sum in range(0, n+1):
        c_d_sum = n - a_b_sum
        if a_b_sum <= 2000 and c_d_sum <= 2000:
            sum_n_num += T[a_b_sum] * T[c_d_sum]

    print(sum_n_num)

### FIXED CODE ###

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

import sys
import os
import math

T = [0] * 2001
for a in range(1001):
    for b in range(1001):
        T[a + b] += 1

for s in sys.stdin:
    n = int(s)

    sum_n_num = 0
    for a_b_sum in range(0, n+1):
        c_d_sum = n - a_b_sum
        if a_b_sum <= 2000 and c_d_sum <= 2000:
            sum_n_num += T[a_b_sum] * T[c_d_sum]

    print(sum_n_num)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

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

def lcm(a, b):
    return a // gcd(a, b) * b

mod = 10**9+7

x=a[0]

for i in a[1:]:
    x=lcm(x,i)
ans=0
for i in range(n):
    ans+= x//a[i]%mod

print(ans%mod)


### FIXED CODE ###

import sys
import fractions

sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

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

def lcm(a, b):
    return a // fractions.gcd(a, b) * b

mod = 10**9+7

x=a[0]

for i in a[1:]:
    x=lcm(x,i)
ans=0
for i in range(n):
    ans+= x//a[i]

print(ans%mod)
### BUGGY CODE ###

n, k = map(int, input().split())
netas_oishisas = []
for _ in range(n):
    netas_oishisas.append(tuple(map(int, input().split())))
netas_oishisas.sort(key = lambda no: no[1], reverse = True)
tabetaneta = []
second = []
greedyscore = 0
for i in range(k):
    neta, oishisa = netas_oishisas[i]
    if neta in tabetaneta:
        second.append(oishisa)
    else:
        tabetaneta.append(neta)
    greedyscore += oishisa
greedyscore += len(tabetaneta) ** 2
maxscore = greedyscore
currentscore = greedyscore
for i in range(k, n):
    if second == []:
        break
    neta, oishisa = netas_oishisas[i]
    if neta not in tabetaneta:
        currentscore = currentscore - second[-1] + 2*len(tabetaneta) + 1 + oishisa
        maxscore = max(maxscore, currentscore)
        tabetaneta.append(neta)
print(maxscore)


### FIXED CODE ###

n, k = map(int, input().split())
netas_oishisas = []
for _ in range(n):
    netas_oishisas.append(tuple(map(int, input().split())))
netas_oishisas.sort(key = lambda no: no[1], reverse = True)
tabetaneta = set()
second = []
greedyscore = 0
for i in range(k):
    neta, oishisa = netas_oishisas[i]
    if neta in tabetaneta:
        second.append(oishisa)
    else:
        tabetaneta.add(neta)
    greedyscore += oishisa
greedyscore += len(tabetaneta) ** 2
maxscore = greedyscore
currentscore = greedyscore
second.reverse()
secondpointer = 0
secondn = len(second)
for i in range(k, n):
    if secondpointer >= secondn:
        break
    neta, oishisa = netas_oishisas[i]
    if neta not in tabetaneta:
        currentscore = currentscore - second[secondpointer] + 2*len(tabetaneta) + 1 + oishisa
        maxscore = max(maxscore, currentscore)
        secondpointer += 1
        tabetaneta.add(neta)
print(maxscore)
### BUGGY CODE ###

import re


def solve(ms):
    ans = 0
    rpc = 1
    while rpc > 0:
        r = re.subn("BW", "WB", ms)
        rpc = r[1]
        ans = ans + rpc
        ms = r[0]
    return ans


print(solve(input()))

### FIXED CODE ###

def solve(s):
    ans = 0
    d = 0
    sl = len(s)
    for i in range(sl):
        if s[i] == "B":
            ans = ans + (sl - i - 1 - d)
            d = d + 1
    return ans


print(solve(input()))
### BUGGY CODE ###

import math

n = int(raw_input())
mod = pow(10,9) + 7
ans = 1
for i in xrange(1,n+1):
  ans = ans*i

print '{:d}'.format(ans%mod)


### FIXED CODE ###

import math
 
n = int(raw_input())
mod = pow(10,9) + 7
ans = 1
for i in xrange(1,n+1):
  ans = (ans*i)%mod
 
print ans
### BUGGY CODE ###

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

def chk():
  v=0
  for j in range(n):
    for i in range(n):
      f=True
      for k in range(n):
        if l[i][j]>l[i][k]+l[k][j]:
          return -1
        if l[i][j]==l[i][k]+l[k][j] and i!=k and k!=j:
          f=False
      if f:v+=l[i][j]
  return v//2
print(chk())

### FIXED CODE ###

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

def chk():
  v=0
  for j in range(n):
    for i in range(n):
      f=True
      for k in range(n):
        if l[i][j]>l[i][k]+l[k][j]:
          return -1
        if l[i][j]==l[i][k]+l[k][j] and i!=k and k!=j:
          f=False
      if f:v+=l[i][j]
  return v//2
print(chk())
### BUGGY CODE ###

import heapq
n,m,s,t = map(int,input().split())
en = []
su = []
for i in range(m):
    x1,y1,z1,a1=[int(i) for i in input().split()]
    en.append([x1-1,y1-1,z1])
    en.append([y1-1,x1-1,z1])
    su.append([x1-1,y1-1,a1])
    su.append([y1-1,x1-1,a1])
def shortest_path(edge,num_v,start):
    inf = float("inf")
    cost = [[inf for i in range(num_v)] for j in range(num_v)]
    for e in edge: cost[e[0]][e[1]] = e[2]
    d = [inf for j in range(num_v)]
    q = []
    heapq.heappush(q, (0, start))
    d[start] = 0
    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if d[src] < prov_cost:
                continue
      for dest in range(num_v):
        you = cost[src][dest]
        if you != float('inf') and d[dest] > d[src] + you:
          d[dest] = d[src] + you
          heapq.heappush(q, (d[dest], dest))
    return d


from collections import deque
ans = deque([])
tori = shortest_path(en,n,s-1)
kae = shortest_path(su,n,t-1)
sai = float("inf")
for i in range(n-1,-1,-1):
  kon = kae[i]+tori[i]
  if sai > kon:
     ans.appendleft(kon)
     sai = kon
  else:
    ans.appendleft(sai)
    
moti = 10**15
for i in range(n):
  print(moti-ans[i])

### FIXED CODE ###

import heapq
n,m,s,t = map(int,input().split())
en = []
su = []
for i in range(m):
    x1,y1,z1,a1=[int(i) for i in input().split()]
    en.append([x1-1,y1-1,z1])
    su.append([x1-1,y1-1,a1])
def shortest_path(edge,num_v,start):
    inf = float("inf")
    cost = [[] for i in range(n+1)]
    for path in edge:
      cost[path[0]].append((path[1],path[2]))
      cost[path[1]].append((path[0],path[2]))
    d = [inf for j in range(num_v)]
    q = []
    heapq.heappush(q, (0, start))
    d[start] = 0
    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if d[src] < prov_cost:
                continue
      for dest,weight in cost[src]:
        if weight != float('inf') and d[dest] > d[src] + weight:
          d[dest] = d[src] + weight
          heapq.heappush(q, (d[dest], dest))
    return d
 
 
from collections import deque
ans = deque([])
tori = shortest_path(en,n,s-1)
kae = shortest_path(su,n,t-1)
sai = float("inf")
for i in range(n-1,-1,-1):
  kon = kae[i]+tori[i]
  if sai > kon:
     ans.appendleft(kon)
     sai = kon
  else:
    ans.appendleft(sai)
    
moti = 10**15
for i in range(n):
  print(moti-ans[i])
### BUGGY CODE ###

N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(N):
  for j in range(N):
   k = M - i - j
   if ( i==j or i==k or j==k): pass
   elif (i + j + k == M): ans += 1
print(ans)

### FIXED CODE ###

N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(i+1, N+1):
   k = M - i - j
   if ( k > N): pass
   elif  k <= j : break
   else: ans += 1
 print(ans)
 ans = 0
 N,M = map(int, input().split())
### BUGGY CODE ###

import sys
import bisect
readline = sys.stdin.readline
n = int(readline())
A = list(map(int,readline().split()))
A.sort()
ans =0
for i in range(1,n):
    for j in range(i+1,n):
        ans += i- bisect.bisect(A,A[j]-A[i],hi=i)
print(ans)

### FIXED CODE ###

import sys
import bisect
readline = sys.stdin.readline
n = int(readline())
A = list(map(int,readline().split()))
memo1 = {}
memo2 = {}
A.sort()
memo1[A[0]+A[1]] =1
memo2[A[0]] =1
if A[1] in memo2:
    memo2[A[1]] +=1
else:
    memo2[A[1]] =1
ans = 0
for c in A[2:]:
    for l,amount in memo1.items():
        if c<l:
            ans +=amount
    for a,amount in memo2.items():
        ac = a+c
        if ac in memo1:
            memo1[ac] += memo2[a]
        else:
            memo1[ac] = memo2[a]
    if c in memo2:
        memo2[c] +=1
    else:
        memo2[c] =1

print(ans)
### BUGGY CODE ###

from collections import deque
# リストの両端の要素に対する編集が必要
# 同一方向に進むときは移動回数が増えないためリストのの先頭に挿入
# この仕組みを実装するためdequeを読み込み

H, W, K = map(int, input().split())
# HとWとKの値それぞれを取得

x1, y1, x2, y2 = map(int, input().split())
x1 -= 1
y1 -= 1
x2 -= 1
y2 -= 1
# リストの先頭要素は0番目として数えられる
# 座標のそれぞれの値から1を引いて取得

grid = [input() for _ in range(H)]
# グリッド部分をH行にわたって取得

INF = float('inf')
path = [[[(INF, INF)] * 4 for _ in range(W)] for _ in range(H)]
# 無限大の浮動小数点を管理

D = [(-1, 0), (0, 1), (1, 0), (0, -1)]
# 進行方向を座標で管理

q = deque()
for d in range(4):
	path[x1][y1][d] = (1, 0)
	# スタート地点を(1, 0)に設定
	q.append((x1, y1, d, 1, 0))
	# (x, y, 進行方向, 移動回数, 進行済マス数)を要素に追加

while q:
	x, y, d, c, k = q.popleft()
	#要素の削除
	
	# nx, ny: 次の座標
	# nd: 次の進行方向
	# nc: 次の移動回数
	# nk: 次の進行済マス数
	
	for nd in range(4):
		if nd == d:
			dx, dy = D[nd]
			nk = 1 if k == K else k + 1
			nc = c + 1 if k == K else c
		else:
			dx, dy = 0, 0
			nk = 0
			nc = c + 1
		nx = x + dx; ny = y + dy
		if 0 <= nx < H and 0 <= ny < W and grid[nx][ny] == '.' and path[nx][ny][nd] > (nc, nk):
			path[nx][ny][nd] = (nc), (nk)
			if nc == c:
				q.appendleft((nx, ny, nd, nc, nk))
			else:
				q.append((nx, ny, nd, nc, nk))
				
# コストの算出
ans = INF
for d in range(4):
	ans = min(ans, path[x2][y2][d][0])
ans = -1 if ans == INF else ans

print(ans)

### FIXED CODE ###

from collections import deque
# リストの両端の要素に対する編集が必要
# 同一方向に進むときは移動回数が増えないためリストのの先頭に挿入
# この仕組みを実装するためdequeを読み込み

H, W, K = map(int, input().split())
# HとWとKの値それぞれを取得

x1, y1, x2, y2 = map(int, input().split())
x1 -= 1
y1 -= 1
x2 -= 1
y2 -= 1
# リストの先頭要素は0番目として数えられる
# 座標のそれぞれの値から1を引いて取得

grid = [input() for _ in range(H)]
# グリッド部分をH行にわたって取得

INF = float('inf')
path = [[[(INF, INF)] * 4 for _ in range(W)] for _ in range(H)]
# 無限大の浮動小数点を管理

D = [(-1, 0), (0, 1), (1, 0), (0, -1)]
# 進行方向を座標で管理

q = deque()
for d in range(4):
	path[x1][y1][d] = (1, 0)
	# スタート地点を(1, 0)に設定
	q.append((x1, y1, d, 1, 0))
	# (x, y, 進行方向, 移動回数, 進行済マス数)を要素に追加

while q:
	x, y, d, c, k = q.popleft()
	#要素の削除
	
	# nx, ny: 次の座標
	# nd: 次の進行方向
	# nc: 次の移動回数
	# nk: 次の進行済マス数
	
	for nd in range(4):
		if nd == d:
			dx, dy = D[nd]
			nk = 1 if k == K else k + 1
			nc = c + 1 if k == K else c
		else:
			dx, dy = 0, 0
			nk = 0
			nc = c + 1
		nx = x + dx; ny = y + dy
		if 0 <= nx < H and 0 <= ny < W and grid[nx][ny] == '.' and path[nx][ny][nd] > (nc, nk):
			path[nx][ny][nd] = (nc), (nk)
			if nc == c:
				q.appendleft((nx, ny, nd, nc, nk))
			else:
				q.append((nx, ny, nd, nc, nk))
				
# コストの算出
ans = INF
for d in range(4):
	ans = min(ans, path[x2][y2][d][0])
ans = -1 if ans == INF else ans

print(ans)
### BUGGY CODE ###

x,y= list(map(int, input().split()))
n=input()
for k in range(y):
    i,j= list(map(int, input().split()))
    i-=1
    ans=n.count('AC', i, j)
    print(ans)

### FIXED CODE ###

x,y= list(map(int, input().split()))
s=input()
anslis=[0]*x
ans=0
for k in range(1,x):
    if s[k-1:k+1]=="AC":
        ans+=1
    anslis[k]+=ans

for k in  range(y):
    i,j= list(map(int, input().split()))
    i-=1
    j-=1
    print(anslis[j]-anslis[i])
### BUGGY CODE ###

#python3
import collections as col
n=int(input())
a=[input() for i in range(n)]

b=col.defaultdict(int)
for i in a:
  b[''.join(sorted(i))]+=1


c = [''.join(sorted(a)) for _ in range(n)]
d = {string: a.count(string) for string in a}
sum2=0
for i in d.values():
  sum2+=i*(i-1)//2 
#print(sum2)

sum1=0
for i in b.values():
  sum1+=i*(i-1)//2
print(sum1)







### FIXED CODE ###

#python3
n = int(input())
s = [str(input()) for _ in range(n)]
sep = ''
dic = dict()
for string in s:
  tmp = sep.join(sorted(string))
  if tmp in dic:
    dic[tmp] += 1 
  else :
    dic[tmp] = 1
ans = 0
for i in dic.values(): 
  ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

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

dp = [10 ** 8 + 1 for i in range(h + 10**4 + 1)]
dp[0] = 0

for i in range(h+1):
  if dp[i] == 10 ** 8 + 1:
      continue
  for j in range(n):
    x = dp[i] + l[j][1]
    if dp[i + l[j][0]] > x:
      dp[i + l[j][0]] = x

print(min(dp[h:]))


### FIXED CODE ###

def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    dp = [100000000] * (H + 10 ** 4 + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == 100000000:
            continue
        for a, b in AB:
            t = dp[i] + b
            if t < dp[i + a]:
                dp[i + a] = t
    print(min(dp[H:]))


main()
### BUGGY CODE ###

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

def popMaxOishisa(sushis):
    t, d = sushis.pop()
    return t, d


def popMinOishisa_nonUniqueNeta(sel_sushis):
    if len(sel_sushis["min"]) == 0:
        return -1, -1
    t, d = min(sel_sushis["min"].items(), key=lambda i:i[1])
    sel_sushis[t].pop()
    if len(sel_sushis[t]) == 1:
        sel_sushis["min"].pop(t)
    else:
        sel_sushis["min"][t] = sel_sushis[t][-1]
    return t, d


def popMaxOishisa_uniqueNeta(sushis, netas):
    t, d = -1, -1
    while True:
        t, d = sushis.pop()
        if not t in netas:
            break
    return t, d


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

# Store data
sushis = []
neta_set = set()
sel_sushis = {}
for i in range(n):
    t, d = map(int, input().split())
    sushis.append((t,d))
    neta_set.add(t)


# Formatting
sushis.sort(key=lambda i:i[1])
tMax = len(neta_set)

# Select sushi set as maximum oishisa point
sum_oishisa = 0
for i in range(k):
    t, d = popMaxOishisa(sushis)
    if not t in sel_sushis:
        sel_sushis[t] = [d]
    else:
        sel_sushis[t].append(d)
    sum_oishisa += d
sel_sushis["min"] = {t:sel_sushis[t][-1] for t in sel_sushis if len(sel_sushis[t]) > 1}
sel_neta = list(sel_sushis.keys())

tMin = len(sel_sushis) - 1
max_score = tMin**2 + sum_oishisa

for nNeta in range(tMin+1, tMax + 1, 1):

    # Find sushi having minimum oishisa and being not unique for neta
    t1, d1 = popMinOishisa_nonUniqueNeta(sel_sushis)
    if t1 < 0:
        break
    sum_oishisa -= d1

    # Find sushi having maximum oishisa and unique for neta
    t2, d2 = popMaxOishisa_uniqueNeta(sushis, sel_neta)
    sum_oishisa += d2

    if not t2 in sel_sushis:
        sel_sushis[t2] = [d2]
    else:
        sel_sushis[t2].append(d2)
    sel_neta.append(t2)

    score = nNeta**2 + sum_oishisa
    if score > max_score:
        max_score = score

print(max_score)


### FIXED CODE ###

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


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

# Store data
sushis = []
neta_set = set()
for i in range(n):
    t, d = map(int, input().split())
    sushis.append((t,d))
    neta_set.add(t)


# Formatting
sushis.sort(key=lambda i:i[1])
tMax = len(neta_set)


# Select sushi set as maximum oishisa point
sel_sushis = []
neta_set = set()
sum_oishisa = 0
for i in range(k):
    t, d = sushis.pop()
    if t in neta_set:
        sel_sushis.append((t,d))
    else:
        neta_set.add(t)
    sum_oishisa += d

sel_sushis.sort(key=lambda i:i[1], reverse=True)
tMin = len(neta_set)
max_score = tMin**2 + sum_oishisa

for nNeta in range(tMin+1, tMax + 1, 1):

    # Find sushi having minimum oishisa and being not unique for neta
    if len(sel_sushis) == 0:
        break
    t1, d1 = sel_sushis.pop()
    sum_oishisa -= d1

    # Find sushi having maximum oishisa and unique for neta
    while True:
        t2, d2 = sushis.pop()
        if not t2 in neta_set:
            break

    sum_oishisa += d2
    neta_set.add(t2)

    score = nNeta**2 + sum_oishisa
    if score > max_score:
        max_score = score

print(max_score)
### BUGGY CODE ###

from collections import deque

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    graph[r].append((l, i, -d))
    graph[l].append((r, i, d))

check_v = [False for _ in range(n)]
check_e = [False for _ in range(m)]
max_int = 10 ** 10
point = [max_int for _ in range(n)]

for v in range(n):
    Q = deque()
    if not check_v[v]:
        Q.append(v)
    while Q:
        v = Q.popleft()
        for next_v, e, d in graph[v]:                
            if not check_e[e]:
                if point[v] == max_int:
                    point[v] = 0
                if point[next_v] == max_int:
                    point[next_v] = point[v] + d
                else:
                    if point[next_v] != point[v] + d:
                        print('No')
                        exit()
            check_e[e] = True
            if not check_v[next_v]:
                Q.append(next_v)
            check_v[v] = True
print('Yes')

### FIXED CODE ###

from collections import deque

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    graph[r].append((l, r, -d))
    graph[l].append((r, l, d))

max_int = 10 ** 10
point = [None for _ in range(n)]

for v in range(n):
    Q = deque()
    if point[v] is not None:
        continue
    Q.extend(graph[v])
    while Q:
        next_v, v, d = Q.popleft()
        if point[v] is None:
            point[v] = 0
        if point[next_v] is not None:
            if point[next_v] != point[v] + d:
                print('No')
                exit()
            else:
                continue
        point[next_v] = point[v] + d
        Q.extend(graph[next_v])
print('Yes')
### BUGGY CODE ###

import sys
import numpy as np
input = sys.stdin.readline


def main():
    N = int(input())
    A = np.array([int(input()) for _ in range(N)])

    for j in range(N):
        # if j != A.index(max(A)):
        #     print(np.max(A))
        # else:
        ans = [x for i, x in enumerate(A) if i != j]
        print(np.max(ans))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    As = [int(input()) for _ in range(n)]

    As_sort = sorted(As)
    second, first = As_sort[-2:]
    for i in range(n):
        if As[i] == first:
            print(second)
        else:
            print(first)


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

l, r = map(int, input().split())

ans = 2019
for i in range(l, r):
    for j in range(l+1, r+1):
        if ans == 0:
            break
        ans = min(ans, (i * j) % 2019)
print(ans)

### FIXED CODE ###

l, r = map(int, input().split())

ans = 2019
if r - l >= 2019:
    print(0)
    exit()
else:
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j)%2019)
print(ans)
### BUGGY CODE ###

n = int(input())
r = []
g = []
b = []
s = input()
for i in range(n):
    if(s[i]=='R'):
        r.append(i)
    elif(s[i]=='G'):
        g.append(i)
    else:
        b.append(i)

ans = 0
for i in r:
    for j in g:
        for k in b:
            mn = min(i,j,k)
            mx = max(i,j,k)
            mid = (i+j+k) - (mn+mx)

            if(mx - mid != mid - mn):
                ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
r = []
g = []
b = []
s = input()
blen = 0
glen = 0
rlen = 0
for i in range(n):
    if(s[i]=='R'):
        r.append(i)
        rlen += 1
    elif(s[i]=='G'):
        g.append(i)
        glen += 1
    else:
        b.append(i)
        blen += 1

ans = 0
minus = 0
t = 0
for i in r:
    for j in g:
        mn = min(i,j)
        mx = max(i,j)

        mid2 = mx + (mx-mn)
        mid3 = mn - (mx-mn)

        if((mx-mn)%2==0):
            mid1 = mn + (mx-mn)//2
            if(mid1 >= 0 and mid1 < n):
                if(s[mid1]=='B'):
                    minus += 1
        if(mid2 >= 0 and mid2 < n):
            if(s[mid2] == 'B'):
                minus += 1
                #print("2",i,j,mid2,s[i],s[j],s[mid2])

                
        if(mid3 >= 0 and mid3 < n):
            if(s[mid3]=='B'):
                minus += 1
                #print("3",i,j,mid3,s[i],s[j],s[mid3])

        t += blen
                

ans = rlen * glen * blen
ans -= minus
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
S = input()

s = []
cnt = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        s.append(cnt)
        cnt = 1
s.append(cnt)

ans = 0
if S[0] == '0':
    s = [0] + s
if S[-1] == '0':
    s = s + [0]

if 2*K + 1 > len(s):
    print(sum(s))
    exit()

for i in range(0, len(s), 2):
    if i + 2*K >= len(s):
        break
    ans = max(ans, sum(s[i:i+2*K+1]))

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()

s = []
cnt = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        s.append(cnt)
        cnt = 1
s.append(cnt)

ans = 0
if S[0] == '0':
    s = [0] + s
if S[-1] == '0':
    s = s + [0]

if 2*K + 1 > len(s):
    print(sum(s))
    exit()

s_cumsum = [s[0]] * len(s)
for i in range(1, len(s)):
    s_cumsum[i] = s_cumsum[i-1] + s[i]
    
for i in range(0, len(s), 2):
    if i + 2*K >= len(s):
        break
    if i < 1:
        ans = s_cumsum[i+2*K]
    ans = max(ans, s_cumsum[i+2*K]-s_cumsum[i-1])
    #ans = max(ans, sum(s[i:i+2*K+1]))

print(ans)
### BUGGY CODE ###

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

def discount(items):
    x = max(items)
    i = items.index(x)
    x_b = x//2
    items[i] = x_b
    return items

for i in range(m):
    a = discount(a)

print(sum(a))

### FIXED CODE ###

import heapq
import math

n, m = map(int, input().split())
a = [-1*int(x) for x in input().split()]
heapq.heapify(a)
 
for _ in range(m):
    min_a = heapq.heappop(a)
    heapq.heappush(a, math.ceil(min_a / 2))
    
print(sum(a)*(-1))
### BUGGY CODE ###

n = int(input())
p = [int(i) for i in input().split()]
count = 0
for i in range(n):
    flg = True
    for j in range(i):
        if not p[i] <= p[j]:
            flg = False
    count += flg
print(count)

### FIXED CODE ###

n = int(input())
p = [int(i) for i in input().split()]
min = n+1
count = 0
for i in range(n):
    if min >= p[i]+1:
        count += 1
        min = p[i]+1
print(count)