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

#200426C
N = int(input())

X = []
ans = 0
for i in range(N):
    S = str(input())
    X.append(S)
for i in range(N):
    if len(X)==0:
        break
    else:
        for j in range(X.count(X[0])):
            X.remove(X[0])
        ans += 1
print(ans)

### FIXED CODE ###

#200426C
import collections
N = int(input())

X = []
ans = 0
for i in range(N):
    S = str(input())
    X.append(S)
Y = collections.Counter(X)
print(len(Y))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split())) * 2
B = [0] * N
for i in range(N):
    B[i] = sum(A[i:i+N:2]) - sum(A[i+1:i+N:2])
print(*B)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = [0] * N
B[0] = sum(A[::2]) - sum(A[1::2])
for i in range(1, N):
    B[i] = 2 * A[i - 1] - B[i - 1]
print(*B)
### BUGGY CODE ###

N = int(input())
word_list = []
count_list = []
for i in range(N):
    tmp = input()
    if tmp in word_list:
        count_list[word_list.index(tmp)] += 1
    else:
        word_list.append(tmp)
        count_list.append(1)
        
MAX = -1
for i in range(len(count_list)):
    if count_list[i]>MAX:
        MAX = count_list[i]

        
ans_list = []
for i in range(len(count_list)):
    if count_list[i]==MAX:
        ans_list.append(word_list[i])

ans_list.sort()

for ans in ans_list:
    print(ans)

### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
MAX = 0
cnt = 0
WORD = []
for i in range(N):
    if i == 0:
        cnt = 1
        MAX = 1
        WORD.append(S[i])
    elif S[i] == S[i-1]:
        cnt+=1
        if cnt == MAX:
            WORD.append(S[i])
        if cnt > MAX:
            MAX = cnt
            WORD.clear()
            WORD.append(S[i])
    else:
        cnt = 1
        if cnt == MAX:
            WORD.append(S[i])

for ans in WORD:
    print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
rank = [0] * n
for idx in range(n) :
    rank[idx] = a.index(idx+1)

for _ in range(n) :
    print(rank[_]+1,end=" ")


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
rank = [0] * n
for idx in range(n) :
    rank[a[idx]-1] = idx + 1

for i in range(n) :
    print(rank[i], end=" ")
### BUGGY CODE ###

def main():
    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))
    cost = [0 for _ in range(n)]
    cost[0] = 0
    cost[1] = abs(h[1] - h[0])
    for i in range(2, n):
        cost[i] = min((cost[i-1-j] + abs(h[i]-h[i-1-j]) for j in range(min(i, k))))
    print(cost[-1])
main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))
    cost = [0 for _ in range(n)]
    cost[0] = 0
    cost[1] = abs(h[1] - h[0])
    for i in range(2, n):
        cost[i] = min((cost[i-1-j] + abs(h[i]-h[i-1-j]) for j in range(min(i, k))))
    print(cost[-1])
main()
### BUGGY CODE ###

def main():
        num = int(input())
        list_num = list(map(int, input().split()))
        flag = False
        for i,v in enumerate(list_num):
                if v in list_num[i+1:]:
                        flag = True
                        break

        if flag:
                print("NO")
        else:
                print("YES")

if __name__ == "__main__":
        main()


### FIXED CODE ###

import os

def main():
	num = int(input())
	list_num = set(map(int, input().split()))
	if len(list_num) != num:
		print("NO")
	else:
		print("YES")

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

H,W = map(int,input().split())
Ch, Cw = map(int,input().split())
Dh, Dw = map(int,input().split())
S = [list(input()) for _ in range(H)]

INF = H * W

dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]

num_step = [[INF for w in range(W)] for h in range(H)]
num_step[Ch - 1][Cw - 1] = 0

# スタート地点を定義
queue = [(Ch - 1, Cw - 1)]
num_warp = 0

# 幅優先探索
while not queue == []:
    magic_tiles = []
    while not queue == []:
        h = queue.pop() # here 
        if h[0] == Dh - 1 and h[1] == Dw - 1:
            print(num_warp)
            exit()
        for i in range(4):
            if 0 <= h[0]+dy[i] < H and 0 <= h[1]+dx[i] < W and S[h[0]+dy[i]][h[1]+dx[i]] == '.' \
                 and num_step[h[0]+dy[i]][h[1]+dx[i]] > num_warp:
                queue.append((h[0]+dy[i], h[1]+dx[i]))
                num_step[h[0]+dy[i]][h[1]+dx[i]] = num_warp

        # 魔法を使っていける場所を検討
        mx = [-2, -1 , 0, 1, 2]
        my = [-2, -1 , 0, 1, 2]

        for x in mx:
            for y in my:
                 if 0 <= h[0] + y < H and 0 <= h[1] + x < W and S[h[0] + y][h[1] + x] == '.' \
                     and num_step[h[0] + y][h[1] + x] == INF:
                    magic_tiles.append((h[0] + y, h[1] + x))

    num_warp += 1

    # キューの追加
    for magic in magic_tiles:
        if num_step[magic[0]][magic[1]] == INF:
            num_step[magic[0]][magic[1]] = num_warp
            queue.append((magic[0], magic[1]))

print(-1)

### FIXED CODE ###

H,W = map(int,input().split())
Ch, Cw = map(int,input().split())
Dh, Dw = map(int,input().split())
S = [list(input()) for _ in range(H)]

INF = H * W

dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]

num_step = [[INF for w in range(W)] for h in range(H)]
num_step[Ch - 1][Cw - 1] = 0

# スタート地点を定義
queue = [(Ch - 1, Cw - 1)]
num_warp = 0

# 幅優先探索
while not queue == []:
    magic_tiles = []
    while not queue == []:
        h = queue.pop() # here 
        if h[0] == Dh - 1 and h[1] == Dw - 1:
            print(num_warp)
            exit()
        for i in range(4):
            if 0 <= h[0]+dy[i] < H and 0 <= h[1]+dx[i] < W and S[h[0]+dy[i]][h[1]+dx[i]] == '.' \
                 and num_step[h[0]+dy[i]][h[1]+dx[i]] > num_warp:
                queue.append((h[0]+dy[i], h[1]+dx[i]))
                num_step[h[0]+dy[i]][h[1]+dx[i]] = num_warp

        # 魔法を使っていける場所を検討
        mx = [-2, -1 , 0, 1, 2]
        my = [-2, -1 , 0, 1, 2]

        for x in mx:
            for y in my:
                 if 0 <= h[0] + y < H and 0 <= h[1] + x < W and S[h[0] + y][h[1] + x] == '.' \
                     and num_step[h[0] + y][h[1] + x] == INF:
                    magic_tiles.append((h[0] + y, h[1] + x))

    num_warp += 1

    # キューの追加
    for magic in magic_tiles:
        if num_step[magic[0]][magic[1]] == INF:
            num_step[magic[0]][magic[1]] = num_warp
            queue.append((magic[0], magic[1]))

print(-1)
### BUGGY CODE ###

N=int(input())
P=list(map(int,input().split()))
R=[[True for i in range(N)] for j in range(N)]
R1=['' for i in range(N)]

for j in range(N):
  for i in range(j,N):
    if P[i]<=P[j]:
      R[i][j]=True
    else:
      R[i][j]=False

for i in range(N):
  if all(R[i]):
    R1[i]=True
print(R1.count(True))

### FIXED CODE ###

N=int(input())
P=list(map(int,input().split()))
cnt=0
bar=P[0]
for i in range(N):
  if P[i]<=bar:
    bar=P[i]
    cnt+=1
print(cnt)
### BUGGY CODE ###

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

#import numpy as np
#A = np.array(A, dtype=int)
lenA = len(A)
for i in range(K):
#    B = np.zeros(lenA, dtype=int)
    B = [0 for _ in range(lenA)]
#    print(B)
    for j in range(lenA):
        num = A[j]
#        print(j, num)
#        B[max(0, j - num): min(lenA, j + num + 1)] += 1
        B[max(0, j - num): min(lenA, j + num + 1)] = [b + 1 for b in B[max(0, j - num): min(lenA, j + num + 1)]]
#        print(j, B)
#    print([a == b for a, b in zip(A,B)])
    if all([a == b for a, b in zip(A,B)]):
#        print('same')
        break
    else:
        A = B
print(' '.join(map(str, A)))

### FIXED CODE ###

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

lenA = len(A)
for i in range(K):
    B = [0 for _ in range(lenA)]
#    print(B)
    for j in range(lenA):
        num = A[j]
#        print(j, num)
        if j - num >= 0:
            B[max(0, j - num)] += 1
        else:
            B[0] += 1
        if j + num + 1 < lenA:
            B[min(lenA, j + num + 1)] -= 1
#        print(j, B)
    for i in range(1, lenA):
        B[i] = B[i-1] + B[i]
    if all([a == b for a, b in zip(A,B)]):
#        print('same')
        break
    else:
        A = B
#print(i+1)
print(' '.join(map(str, A)))
### BUGGY CODE ###

n = int(input())
semi_max = 0
aa = []
for i in range(n):
    a = int(input())
    if i > 0:
        if a >= semi_max and a < max(aa):
            semi_max = a
        elif a == max(aa):
            semi_max = max(aa)
    aa.append(a)
    # print(semi_max)
for each in aa:
    print(max(aa) if each <= semi_max else semi_max)


### FIXED CODE ###

n = int(input())
aa = [int(input()) for _ in range(n)]
aho = sorted(aa)
for a in aa:
    print(aho[-1] if a < aho[-1] else aho[-2])
### BUGGY CODE ###

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

card = [[] for _ in range(n)]

for _ in range(m):
    x, y, _ = map(int, input().split())
    card[x-1].append(y-1)
    card[y-1].append(x-1)

checked = [False] * n

count = 0
from collections import deque
for i in range(n):
    if checked[i]:
        continue
    count += 1
    q = deque([i])
    while q:
        j = q.popleft()
        checked[j] = True
        for k in card[j]:
            if not checked[k]:
                q.append(k)
print (count) 



### FIXED CODE ###

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

card = [[] for _ in range(n)]

for _ in range(m):
    x, y, _ = map(int, input().split())
    card[x-1].append(y-1)
    card[y-1].append(x-1)

checked = [False] * n

count = 0
import queue
q = queue.Queue()
for i in range(n):
    if checked[i]:
        continue
    count += 1
    q.put(i)
    while not q.empty():
        j = q.get()
        checked[j] = True
        for k in card[j]:
            if not checked[k]:
                q.put(k)

print (count)
### BUGGY CODE ###

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

Answer = 1
for i in range(N):
    Answer *= A[i]

if Answer > 10**18:
    print(-1)
else:
    print(Answer)

### FIXED CODE ###


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

B = set(A)
Answer = 1
if 0 in B:
    print(0)
    exit()
for i in range(N):
    Answer *= A[i]
    if Answer > 1000000000000000000:
        print(-1)
        exit()
print(Answer)
### BUGGY CODE ###

a,b = map(int, input().split())
ans = 1
count = 2

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
num=gcd(a,b)

if a==1 or b==1:
    print(1)
else:
    while num!=1:
        if num%count==0:
            ans+=1
            while num%count==0:
                num= num/count
            count+=1
        else:
            count+=1
    print(ans)


### FIXED CODE ###

from fractions import gcd
a,b = map(int, input().split())
# ans = 1
count = 2
n=gcd(a,b)

ans = set([1])
while n % 2 == 0:
    ans.add(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        ans.add(f)
        n //= f
    else:
        f += 2
if n != 1:
    ans.add(n)
print(len(ans))
### BUGGY CODE ###

alp = {"a":2, "b":3,"c":5,"d":7,"e":11,"f":13,"g":17,"h":19,"i":23,"j":29,
       "k":31,"l":37,"m":41,"n":43,"o":47,"p":53,"q":59,"r":61,"s":67,"t":71,
       "u":73,"v":79,"w":83,"x":89,"y":97,"z":101}

n = int(input())

s = []

for i in range(n):
    tss= str(input()) # tss; temporary str s
    ts = 1
    for j in range(10):
      ts *= alp[tss[j]] # ts; temporary s
    s.append(ts)

a = 0 # a; pre ans

for i in range(n):
    for j in range(1, n - i):
        if s[i] == s[i + j]:
            a += 1

print(a)  


### FIXED CODE ###

n = int(input())
d = dict()

for _ in range(n):
    s = "".join(sorted([x for x in input()]))
    d[s] = d.get(s, 0) + 1

ans = 0

for v in d.values():
    if v >= 2:
        ans += (v * (v-1)) // 2

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

N,C = map(int,input().split())
XV = [[int(i) for i in input().split()] for _ in range(N)]
ans = 0


Sum_left = [[0]*(N+1) for _ in range(N+1)]

for j in range(N):
    if j == 0:
        Sum_left[0][j+1] = Sum_left[0][j] + XV[j][1] - XV[j][0]
    else:
        Sum_left[0][j+1] = Sum_left[0][j] + XV[j][1] - (XV[j][0] - XV[j-1][0])
    ans = max(ans,Sum_left[0][j+1])

for i in range(N):
    if i == 0:
        Sum_left[i+1][0] = Sum_left[i][0] + XV[-i-1][1] - 2 * (C - XV[-i-1][0])
    else:
        Sum_left[i+1][0] = Sum_left[i][0] + XV[-i-1][1] - 2 * (XV[-i][0] - XV[-i-1][0])

for i in range(1,N):
    for j in range(1,N+1-i):
        Sum_left[i][j] = Sum_left[i][0] + Sum_left[0][j]
        ans = max(ans,Sum_left[i][j])



Sum_right = [[0]*(N+1) for _ in range(N+1)]

for j in range(N):
    if j == 0:
        Sum_right[0][j+1] = Sum_right[0][j] + XV[-1-j][1] - (C-XV[-1-j][0])
    else:
        Sum_right[0][j+1] = Sum_right[0][j] + XV[-1-j][1] - (XV[-j][0] - XV[-1-j][0])
    ans = max(ans,Sum_right[0][j+1])

for i in range(N):
    if i == 0:
        Sum_right[i+1][0] = Sum_right[i][0] + XV[i][1] - 2 * XV[i][0]
    else:
        Sum_right[i+1][0] = Sum_right[i][0] + XV[i][1] - 2 * (XV[i][0] - XV[i-1][0])

for i in range(1,N):
    for j in range(1,N+1-i):
        Sum_right[i][j] = Sum_right[i][0] + Sum_right[0][j]
        ans = max(ans,Sum_right[i][j])

print(ans)

### FIXED CODE ###

N,C = map(int,input().split())
XV = [[0,0]] + [[int(i) for i in input().split()] for _ in range(N)] + [[C,0]]

Sum_left = [0] * (N+1)
Sum_right = [0] * (N+1)
for i in range(N):
    Sum_left[i+1] = Sum_left[i] + XV[i+1][1]
    Sum_right[i+1] = Sum_right[i] + XV[N-i][1]

Sum_right_maxA = [0] * (N+1)
Sum_right_maxB = [0] * (N+1)
for i in range(1,N+1):
    Sum_right_maxA[i] = max(Sum_right_maxA[i-1], Sum_right[i] - 2 * (C - XV[N+1-i][0]))
    Sum_right_maxB[i] = max(Sum_right_maxB[i-1], Sum_right[i] - (C - XV[N+1-i][0]))

ans = 0
for i in range(N+1):
    ans = max(ans, Sum_left[i] + Sum_right_maxA[N-i] - XV[i][0], Sum_left[i] + Sum_right_maxB[N-i] - 2*XV[i][0])
print(ans)
### BUGGY CODE ###

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

for i in range(n):
    x = copy.copy(a)
    x.pop(i)
    print(max(x))


### FIXED CODE ###

import copy
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
b = copy.copy(a)
a.sort(reverse=True)
for i in range(n):
    if b[i] == a[0]:
        print(a[1])
    else:
        print(a[0])
### BUGGY CODE ###

import math

A, B = list(map(int, input().strip().split()))

def decompose(n):
	result = []
	
	i = 2
	while i <= n:
		if n % i == 0:
			result.append(i)
			n //= i
		else:
			i += 1
	return result

def calc_gcm(a, b):
	if a > b:
		r = a % b
		a = r
	
	while a > 0:
		r = b % a
		b = a
		a = r
	
	return b

primes = decompose(calc_gcm(A, B))
count = 1
prev = 0
for p in primes:
	if prev != p:
		count += 1
	prev = p
print(count)


### FIXED CODE ###

import math

A, B = list(map(int, input().strip().split()))

def decompose(n):
	result = []
	
	i = 2
	n2 = math.floor(math.sqrt(n)) + 1
	while i <= n2:
		if n % i == 0:
			result.append(i)
			n //= i
			n2 = math.floor(math.sqrt(n)) + 1
		else:
			i += 1
	if n > 1:
		result.append(n)
	return result

def calc_gcm(a, b):
	if a > b:
		r = a % b
		a = r
	
	while a > 0:
		r = b % a
		b = a
		a = r
	
	return b

primes = decompose(calc_gcm(A, B))
count = 1
prev = 0
for p in primes:
	if prev != p:
		count += 1
	prev = p
print(count)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = int(1)
for i in range(n):
    ans *= a[i]
if ans <= 10 ** 18:
    print(ans)
else:
    print("-1")

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = int(1)
a.sort(reverse=True)
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        ans = ("-1")
        break
if 0 in a:
    ans = 0
print(ans)
### BUGGY CODE ###

def rev(a):
    L = []
    for i in range(N):
        L.append(a % 3)
        a //= 3
    return int("".join(map(str, L)), 3)
    
def salsa():
    lazy[0] *= -1

def rumba():
    i = 0
    for k in range(N):
        if lazy[i] < 0:
            lazy[3*i+1] *= -1
            lazy[3*i+2] *= -1
            lazy[3*i+3] *= -1
            lazy[i] = 1
            value[3*i+1] ^= 3
            value[3*i+2] ^= 3
            value[3*i+3] ^= 3
        value[3*i+1] += 1
        value[3*i+2] += 1
        value[3*i+3] += 1
        value[3*i+1] %= 3
        value[3*i+2] %= 3
        value[3*i+3] %= 3
        i = 3 * i + (1 if value[3*i+1] == 0 else 2 if value[3*i+2] == 0 else 3)

def calcall():
    a = 1
    i = 0
    for k in range(1, N + 1):
        for _ in range(3 ** k):
            i += 1
            if lazy[(i-1)//3] < 0:
                lazy[i] *= -1
                if value[i]: value[i] ^= 3
            value[i] = value[i] * a + value[(i-1) // 3]
        a *= 3
        
N = int(input())
NN = 3 ** (N + 1) // 2
value = [(i-1) % 3 if i else 0 for i in range(NN)]
lazy = [1 for i in range(NN)]

for t in input():
    if t == "R":
        rumba()
    else:
        salsa()

calcall()

ANS = [0] * (3 ** N)
for i in range(3 ** N):
    ANS[rev(i)] = value[i + (NN - 1) // 3]

print(*ANS)

### FIXED CODE ###

def rev(a):
    L = []
    for i in range(N):
        L.append(a % 3)
        a //= 3
    return int("".join(map(str, L)), 3)
    
def salsa():
    lazy[0] *= -1

def rumba():
    i = 0
    for k in range(N):
        if lazy[i] < 0:
            lazy[3*i+1] *= -1
            lazy[3*i+2] *= -1
            lazy[3*i+3] *= -1
            lazy[i] = 1
            value[3*i+1] ^= 3
            value[3*i+2] ^= 3
            value[3*i+3] ^= 3
        value[3*i+1] += 1
        value[3*i+2] += 1
        value[3*i+3] += 1
        value[3*i+1] %= 3
        value[3*i+2] %= 3
        value[3*i+3] %= 3
        i = 3 * i + (1 if value[3*i+1] == 0 else 2 if value[3*i+2] == 0 else 3)

def calcall():
    a = 1
    i = 0
    for k in range(1, N + 1):
        for _ in range(3 ** k):
            i += 1
            if lazy[(i-1)//3] < 0:
                lazy[i] *= -1
                if value[i]: value[i] ^= 3
            value[i] = value[i] * a + value[(i-1) // 3]
        a *= 3
        
N = int(input())
NN = 3 ** (N + 1) // 2
value = [(i-1) % 3 if i else 0 for i in range(NN)]
lazy = [1 for i in range(NN)]

for t in input():
    if t == "R":
        rumba()
    else:
        salsa()

calcall()

ANS = [0] * (3 ** N)
for i in range(3 ** N):
    ANS[rev(i)] = value[i + (NN - 1) // 3]

print(*ANS)
### BUGGY CODE ###

nq = input().split()
n = int(nq[0])
q = int(nq[1])
block_word = [""]
block_num = [""]
block_move = [""]
golem = n
s = input()
t = ""
d = ""

for word in s:
  block_word += [word]
  block_move += [0]
  block_num += [1]

for i in range(q):
  td = input().split()
  t = td[0]
  d = td[1]
  for j in range(1, n+1):
    if t == block_word[j]:
      if j == n and d == "R":
        golem -= block_num[n]
        block_num[n] = 0
      elif j == 1 and d == "L":
        golem -= block_num[1]
        block_num[1] = 0
      else:
        if d == "R":
          block_move[j+1] = block_num[j]
          block_num[j] = 0
        if d == "L":
          block_move[j-1] = block_num[j]
          block_num[j] = 0
    else:
        j=j
  for k in range(1,n+1):
    block_num[k] += block_move[k]
  for i in range(1,n+1):
    block_move[i] = 0

print(golem)

### FIXED CODE ###

N,Q=map(int,input().split())
s="0"+input()+"0"
queri=[input().split() for i in range(Q)]
 
L,R=0,N+1
for i in range(Q-1,-1,-1):
    t,d=queri[i]
    if t==s[L] and d=="R":
        L-=1
    elif t==s[L+1] and d=="L":
        L+=1
    if t==s[R] and d=="L":
        R+=1
    elif t==s[R-1] and d=="R":
        R-=1
 
print(R-L-1)
### BUGGY CODE ###

def dist(ai:int, bi:int, aj:int, bj:int):
    return abs(ai-aj)+abs(bi-bj)

h, w, d = map(int, input().split())
p = {}
for i in range(h):
    tmpstr = input().split()
    for j in range(w):
        tmpchar = int(tmpstr[j])
        p[tmpchar] = (i, j)

q = int(input())
for _ in range(q):
    ans = 0
    l, r = map(int, input().split())
    curnum = l
    t = (r-l)//d
    for _ in range(t):
        curl, curr = p[curnum]
        nextl, nextr = p[curnum+d]
        ans += dist(curl, curr, nextl, nextr)
        curnum += d
    print(ans)

### FIXED CODE ###

def dist(ai:int, bi:int, aj:int, bj:int):
    return abs(ai-aj)+abs(bi-bj)

h, w, d = map(int, input().split())
p = {}
for i in range(h):
    tmpstr = input().split()
    for j in range(w):
        tmpchar = int(tmpstr[j])
        p[tmpchar] = (i, j)
dsum = [0]*d
for i in range(d, h*w):
    curl, curr = p[i+1]
    prel, prer = p[i-d+1]
    diff = dist(curl, curr, prel, prer)
    tmpd = dsum[i-d]+diff
    dsum.append(tmpd)

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

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

blk_list = []
for i in range(len(s)):
  if i==0:
    blk = {'n':0, 's':s[i]}
  if i > 1 and s[i-1]!=s[i]:
    blk_list.append(blk)
    blk = {'n':0, 's':s[i]}

  blk['n'] += 1
blk_list.append(blk)

# iblkの始点を1が連続する箇所の始点とするときの数を見る

mx = 0
for i, blk in enumerate(blk_list):
  if blk['s'] == '0':
    if i == 0:
      endi = i + 2*k - 1
    else:
      continue
  if blk['s'] == '1':
    endi = i + 2*k
    
  sm = blk['n']
  for j in range(i+1, min(len(blk_list), endi+1)):
    sm += blk_list[j]['n']
      
  if sm > mx:
    mx = sm
print(mx)
      





### FIXED CODE ###

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

blk_num = []
blk_sum = []
for i in range(len(s)):
  if i == 0 or s[i-1]!=s[i]:
    if i!= 0:
      blk_sum.append(n)
    blk_num.append(s[i])
    n = 0
  n += 1

blk_sum.append(n)

def cumsum(x):
    y = []
    current = 0
    for i in x:
        y.append(current + i)
        current += i
    return y

blk_csum = cumsum(blk_sum)
# iblkの始点を1が連続する箇所の始点とするときの数を見る

mx = 0
for i, n in enumerate(blk_num):
  if n == '0':
    endi = i + 2*k - 1
    endi = min(len(blk_num)-1, endi)
    if i == 0:
      sm = blk_csum[endi]
    else:
      continue
  else:
    endi = i + 2*k
    endi = min(len(blk_num)-1, endi)
    if i == 0:
      sm = blk_csum[endi]
    else:
      sm = blk_csum[endi] - blk_csum[i-1]
  if sm > mx:
    mx = sm
print(mx)
### BUGGY CODE ###

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

dp = [0 for i in range(n+1)]
dp[0] = 1

for i in range(1, n+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[-1])


### FIXED CODE ###

n, m = map(int, input().split())
A = [False for i in range(n+1)]
for i in range(m):
    a = int(input())
    A[a] = True

dp = [0 for i in range(n+1)]
dp[0] = 1

for i in range(1, n+1):
    if A[i]:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[-1])
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
for i in range(Q):
	l, r = map(int, input().split())
	print(S[l - 1: r].count("AC"))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
count = [0]*N  # count[i] は i 番目まで S[:i+1] の解
for i in range(1, N):
    count[i] = count[i-1]
    if S[i-1: i+1] == "AC":
        count[i] += 1
for _ in range(Q):
    l,r = map(int, input().split())
    print(count[r-1] - count[l-1])
### BUGGY CODE ###

N = int(input())
S = list(input())

rli = []
gli = []
bli = []
for i in range(N):
    if S[i] == "R":
        rli.append(i+1)
    if S[i] == "G":
        gli.append(i+1)
    if S[i] == "B":
        bli.append(i+1)

ans = 0
for i in rli:
    for j in gli:
        sa = max(i,j)-min(i,j)
        scr = len(bli)
        if min(i,j)-sa in bli:
            scr -= 1
        if (i+j)/2 in bli:
            scr -= 1
        if max(i,j)+sa in bli:
            scr -= 1
        ans += scr

print(ans)

### FIXED CODE ###

N = int(input())
S = list(input())
rli = []
gli = []
bli = []
for i in range(N):
    if S[i] == "R":
        rli.append(i+1)
    if S[i] == "G":
        gli.append(i+1)
    if S[i] == "B":
        bli.append(i+1)
ans = len(rli)*len(gli)*len(bli)
for i in range(N):
    for j in range(i+1, ((N-i)//2+(N-i)%2)+i):
        if S[i] != S[j] and S[j] != S[2*j-i] and S[2*j-i] != S[i]:
            ans -= 1
print(ans)
### BUGGY CODE ###

n=int(input())

ans=0

for i in range(n):
    ans=ans+i

print(ans)

### FIXED CODE ###

n=int(input())

if n%2==0:
    neko=int(n/2)
    ans=neko*(n-1)
    print(ans)

if n%2==1:
    neko=int((n-1)/2)
    ans=neko*n
    print(ans)