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

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

one = list(map(len, s.replace('0', ' ').split()))
zero = list(map(len, s.replace('1', ' ').split()))
if s[0] == '0':
    one.insert(0, 0)
if s[-1] == '0':
    one.append(0)
    
ans = 0
for i in range(len(zero)):
    length = sum(one[i:i+k+1]) + sum(zero[i:i+k])
    ans = max(ans, length)

if s.count('1') == len(s):
    print(len(s))
else:
    print(ans)

### FIXED CODE ###

import numpy as np

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

arr0 = np.array(list(map(len, s.split('1'))))
arr0 = arr0[arr0!=0]

arr1 = np.array(list(map(len, s.split('0'))))
arr1 = arr1[arr1!=0]


ans = 0

if s[0] == '0':
    for i in range(len(arr0)):
        
        if i == 0:
            length = arr0[i:i+k].sum() + arr1[i:i+k].sum()
        else:
            length = arr0[i:i+k].sum() + arr1[i-1:i+k].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        
else:        
    for i in range(len(arr0)):
        
        
        length = arr0[i:i+k].sum() + arr1[i:i+k+1].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        

if len(s) == s.count('1'):
    print(len(s))
else:
    print(ans)
### BUGGY CODE ###

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

L = sorted(L)

import math

seikai = 0
Emu = L[-1]
calc = 0

for i in range (0, N-1):
	P = math.comb(Emu, L[i])
	if P > calc:
		calc = P
		seikai = L[i]

print(L[-1], seikai)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

import math
import bisect
max = L[-1]
maxdiv2 = max//2
posleft = bisect.bisect_left(L, maxdiv2)
posright = bisect.bisect_right(L, maxdiv2)

if len(L) == 2:
	print(L[1], L[0])
	exit()

if posleft!= posright:
	print(max, L[posleft])
	exit()

if abs(max/2 - L[posleft]) > abs(max/2 - L[posleft-1]):
	print(max, L[posleft-1])
else:
	print(max, L[posleft])
### BUGGY CODE ###

import sys

s = sys.stdin.readline().replace('\n','')
q = sys.stdin.readline().replace('\n','')
q = int(q)

prev_cmd = 0
for i in range(0,q):
	str = sys.stdin.readline().replace('\n','')
        if( str[0] == '1'):
	  if( prev_cmd == 1):
            prev_cmd = 0
          else:
            prev_cmd = 1
        if( str[0] == '2'):
	  if( prev_cmd == 1):
	    s = s[::-1]
	  prev_cmd = 0
          if( str[2] == '1'):
	    s = str[4] + s
          if( str[2] == '2'):
	    s = s + str[4]

if( prev_cmd == 1):
  s = s[::-1]

print s
sys.stdout.flush()

### FIXED CODE ###

import sys

s = sys.stdin.readline().replace('\n','')
q = sys.stdin.readline().replace('\n','')
q = int(q)

flag = 0
prev=""
end=""
for i in range(0,q):
	str = sys.stdin.readline().replace('\n','')
        if( str[0] == '1'):
          flag += 1
        if( str[0] == '2'):
          if( str[2] == '1'):
	    if( flag % 2 == 0):
	      prev = str[4] + prev
	    else:
	      end = end + str[4]
          if( str[2] == '2'):
	    if( flag % 2 == 0):
	      end = end + str[4]
	    else:
	      prev = str[4] + prev

ss = prev + s + end
if( flag % 2 == 1):
  ss = ss[::-1]

print ss
sys.stdout.flush()
### BUGGY CODE ###

from collections import defaultdict
from collections import deque
import sys
sys.setrecursionlimit(10**6)

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

graph = defaultdict(deque)

for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

arr = [0] * (n + 1)

for i in range(q):
    p, x = map(int, input().split())
    arr[p] += x


def solve(graph, arr):
    curr, root = 1, -1
    visited = [True] * 2 + [False] * (n - 1)

    def dfs(curr, root):
        stack = graph[curr]

        while stack:
            leaf = stack.pop()
            if visited[leaf]:
                continue
            arr[leaf] += arr[curr]
            visited[leaf] = True
            dfs(leaf, curr)

        return arr

    return dfs(curr, root)


ans = solve(graph, arr)

print(*ans[1:])

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

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

graph = defaultdict(set)

for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a].add(b)
    graph[b].add(a)

arr = [0] * (n + 1)

for i in range(q):
    p, x = map(int, input().split())
    arr[p] += x


def solve():
    stack = [1]
    visited = [True] * 2 + [False] * (n - 1)

    while stack:
        curr = stack.pop()
        for leaf in graph[curr]:
            if visited[leaf]:
                continue
            stack.append(leaf)
            visited[leaf] = True
            arr[leaf] += arr[curr]

    return arr


arr = solve()

print(*arr[1:])
### BUGGY CODE ###

N = int(input())
res = 200
tmp = N
for i in range(1, N+1):
    if N%i == 0:
        if max(len(str(i)),len(str(int(N/i)))) < res:
            res = max(len(str(i)),len(str(int(N/i))))
    
    if tmp < N//i:
            break
    tmp = N//i
print(res)

### FIXED CODE ###

N = int(input())

def prime_factor(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

res = prime_factor(N)

result = 10 ** 10
for i in range(1, N+1):
    if N%i == 0:
        result = min(result, max(len(str(i)), len(str(N//i))))
    if i*i > N:
        break


print(result)
### BUGGY CODE ###

from fractions import gcd

def lcm(a):
    ans = a[0]
    
    for i in range(1,len(a)):
        ans = (ans//gcd(ans,a[i]))*a[i]
    
    return ans

N = int(input())
A = tuple(map(int,input().split(" ")))
g = lcm(A)
ans = 0
mod = 10**9+7

for i in A:
    ans += (g//i)%(mod)

print(ans%mod)

### FIXED CODE ###

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

N = int(input())
A = tuple(map(int,input().split(" ")))
ans = 0
mod = 10**9+7
l = 1
for i in range(N):
    l = lcm(l,A[i])
l %= mod

for i in A:
    ans += l*pow(i,mod-2,mod)
    ans %= mod

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

s = input()
q = int(input())
query = []
lead = ''
end = ''
inversion_flg = False

for i in range(q):
    query.append(input().split())
for i in query:
    if int(i[0]) == 1:
        inversion_flg = False if inversion_flg else True
    else:
        if inversion_flg:
            i[1] = 2 if int(i[1]) == 1 else 1
        if int(i[1]) == 1:
            lead+=i[2]
        else:
            end+=i[2]

lead = lead[::-1]
s = lead+s+end
if inversion_flg:
    s = s[::-1]
print(s)

### FIXED CODE ###

s = input()
q = int(input())
query = []
lead = ''
end = ''
inversion_flg = False
 
for j in range(q):
    i = input().split()
    if i[0] == "1":
        if inversion_flg:
            inversion_flg = False 
        else:
            inversion_flg = True
    else:
        if inversion_flg:
            if i[1] == "1":
                i[1] = "2"
            else:
                i[1] = "1"
        if i[1] == "1":
            lead+=i[2]
        else:
            end+=i[2]
 
lead = lead[::-1]
s = lead+s+end
if inversion_flg:
    s = s[::-1]
print(s)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n,m=map(int,input().split())
l=[[0,0] for _ in range(n)]
for i in range(n):
        l[i][1],l[i][0]=map(int,input().split())
l.sort()
l=l[::-1]
ans=0
for k in range(1,m+1):
        for j in range(n):
                if l[j][1]<=k:
                        ans+=l[j][0]
                        l[j][0]=0
                        l.sort()
                        l=l[::-1]
                        break
print(ans)

### FIXED CODE ###

import heapq

n,m=map(int,input().split())
L=[[] for _ in range(m)]
for _ in range(n):
        a,b=map(int,input().split())
        if a<=m:
                L[a-1].append(-b)
h=[]
heapq.heapify(h)

ans=0
for i in range(m):
        for j in L[i]:
                heapq.heappush(h,j)
        if len(h)==0:
                continue
        ans+=heapq.heappop(h)*(-1)
print(ans)
### BUGGY CODE ###

n = int(input())

ans=0

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

print(ans)

### FIXED CODE ###

n = int(input())

ans = n*(n-1)//2

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

#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]
    A.sort()

    if N == 1:
        print(1)
        return
    if A[0] == 1:
        print(0 if A[1] == 1 else 1)
        return

    ax = set()
    ans = 0
    for i in range(1, N):
        a0 = A[i-1]
        if A[i-1] == A[i]:
            ax.add(a0)
            continue

        for x in ax:
            if a0 % x == 0:
                break
        else:
            ax.add(a0)
            ans += 1

    a0 = A[-1]
    for x in ax:
        if a0 % x == 0:
            break
    else:
        ans += 1

    print(ans)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]

    if N == 1:
        print(1)
        return

    ax = max(A)+1
    dp = [0]*ax
    for ai in A:
        da = dp[ai]
        if da > 1:
            continue
        dp[ai] += 1
        if da == 0:
            for aj in range(2*ai, ax, ai):
                dp[aj] = 2
        #print(dp)
    print(dp.count(1))


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

from collections import deque

def main():
  s = deque(input())
  q = int(input())
  query = [input() for i in range(q)]

  for i in range(q):
    temp = query[i].split()
    if int(temp[0]) == 1:
      s.reverse()
    else:
      if int(temp[1]) == 1:
        s.appendleft(temp[2])
      else:
        s.append(temp[2])

  print(''.join(s))

if __name__ == '__main__':
  main()


### FIXED CODE ###

from collections import deque

def main():
  rev = False
  s = deque(input())
  q = int(input())
  query = tuple(input() for i in range(q))

  for i in range(q):
    temp = query[i].split()
    if int(temp[0]) == 1:
      rev = not rev
    else:
      if (int(temp[1]) == 1 and (not rev)) or (int(temp[1]) == 2 and rev):
        s.appendleft(temp[2])
      else:
        s.append(temp[2])

  if rev:
    s.reverse()

  print(''.join(s))

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

N,P = map(int, input().split())

i = 1
ans = 1
R = int(P**(1/N)) + 1
if N > 1:
	for l in range(R): 
		if P % i**N == 0:
			ans = i
		i += 1
else:
	ans = P
print(ans)


### FIXED CODE ###

N,P = map(int, input().split())

ans = 1
R = int(P**(1/N)) + 1
if N == 1:
	ans = P
elif N > 40:
	ans = 1
else:
	for l in range(R):
		if P % (R-l)**N == 0:
			ans = R-l
			break
print(ans)
### BUGGY CODE ###

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

B = [[i, a] for i, a in enumerate(A)]

C = sorted(B, key=lambda b: b[1], reverse=True)

l = 0
r = N - 1

ans = 0
queue = [[C, l, r, 0]]
while queue:
    D, l, r, total = queue.pop()

    total2 = total + abs(D[0][0] - l) * D[0][1]
    if len(D) == 1:
        ans = max(ans, total2)
        continue
    else:
        queue.append([D[1:], l+1, r, total2])

    total2 = total + abs(D[0][0] - r) * D[0][1]
    if len(D) == 1:
        ans = max(ans, total2)
        continue
    else:
        queue.append([D[1:], l, r-1, total2])

print(ans)


### FIXED CODE ###

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

B = [[i, a] for i, a in enumerate(A)]

C = sorted(B, key=lambda b: b[1], reverse=True)

dp = [[-1 for _ in range(N + 1)] for _ in range(N + 1)]

dp[1][0] = (C[0][0] - 0) * C[0][1]
dp[0][1] = ((N - 1) - C[0][0]) * C[0][1]

ans = 0
for i in range(2, N + 1):
    for j in range(0, i + 1):
        t1, t2 = 0, 0

        if j - 1 >= 0:
            t1 = dp[j - 1][i - j] + abs((C[i - 1][0] - (j - 1))) * C[i - 1][1]

        if i - j - 1 >= 0:
            t2 = dp[j][i - j - 1] + abs((C[i - 1][0] - (N - (i - j)))) * C[i - 1][1]

        dp[j][i - j] = max(t1, t2)

        if i == N:
            ans = max(ans, dp[j][i - j])

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

n=int(input())
h=list(map(int,input().split()))
max=0
now=0
i=0
while i<n-1:
    now=0
    for j in range(i+1,n):
        if h[j]<=h[j-1]:
            now+=1
            if j==n-1:
                if now>=max:
                    max=now
                break
        else:
            if now>=max:
                max=now
            i=j-1
            break
    i+=1
print(max)

### FIXED CODE ###

def main():
    n = int(input())
    h = input().split()
    h = [int(n) for n in h]
    max = 0
    now = 0
    i = 0
    for i in range(n-1):
        if h[i] >= h[i+1]:
            now += 1
        else:
            if now >= max:
                max = now
            now=0
        if now >= max:
            max = now
    print(max)

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

N=int(input())
A=[]
for i in range(N):
  a=int(input())
  A.append(a)
  
print(max(A[1:]))
for i in range(1,N-1):
  b=A[:i]
  c=A[i+1:]
  aa=b+c
  print(max(aa))
  
print(max(A[:N-1]))

### FIXED CODE ###

N=int(input())
A=[]
for i in range(N):
  a=int(input())
  A.append(a)
  
ans=max(A)
for i in range(N):
  if A[i]==ans:
    b=A[:i]
    c=A[i+1:]
    aa=b+c
    an=max(aa)
    if an==ans:
      for j in range(N-i):
        print(ans)
      break
    else:
      print(an)
  else:
    print(ans)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C, D = [int(x) for x in input().split()]

    MOD = 998244353

    dp = [[0] * (D - B + 1) for j in range(C - A + 1)]

    for j in range(C - A + 1):
        if j == 0:
            dp[j][0] = 1
        else:
            dp[j][0] = B ** j % MOD
        for i in range(1, D - B + 1):
            if j == 0:
                dp[j][i] = dp[j][i - 1] * (A + j) % MOD
            else:
                dp[j][i] = (dp[j][i - 1] * (A + j) + (B + i) * dp[j - 1][i] - dp[j - 1][i - 1] * (
                            (A + j - 1) * (B + i - 1))) % MOD

    print(dp[-1][-1] % MOD)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C, D = [int(x) for x in input().split()]

    MOD = 998244353

    dp = [[0] * (D - B + 1) for j in range(C - A + 1)]

    for j in range(C - A + 1):
        if j == 0:
            dp[j][0] = 1
        else:
            dp[j][0] = pow(B, j, MOD)
        for i in range(1, D - B + 1):
            if j == 0:
                dp[j][i] = dp[j][i - 1] * (A + j) % MOD
            else:
                dp[j][i] = (dp[j][i - 1] * (A + j) + (B + i) * dp[j - 1][i] - dp[j - 1][i - 1] * (
                            (A + j - 1) * (B + i - 1))) % MOD

    print(dp[-1][-1] % MOD)


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

import numpy as np


N = int(input())

A = [None] * N
B = [None] * N

for n in range(N):
    a, b = map(int, input().split())
    A[n] = a
    B[n] = b

P = 0
Q = 0

F = True

for i in range(N):
    if F:
        C    = zip(A, B)
        C    = sorted(C, key=lambda x: [x[0], x[1]], reverse=True)
        A, B = map(list, zip(*C))
        P   += A[0]
        A.pop(0)
        B.pop(0)
        F = False
    else:
        D    = zip(B, A)
        D    = sorted(D, key=lambda x: [x[0], x[1]], reverse=True)
        B, A = map(list, zip(*D))
        Q   += B[0]
        A.pop(0)
        B.pop(0)
        F = True

print(P-Q)


### FIXED CODE ###

N = int(input())

A = [None] * N
B = [None] * N
C = [None] * N

for n in range(N):
    a, b = map(int, input().split())
    A[n] = a
    B[n] = b
    C[n] = a + b

Z = zip(A, B, C)
Z = sorted(Z, key=lambda x: [x[2]], reverse=True)

A, B, C = map(list, zip(*Z))

T = True
R = 0

for i in range(N):
    if T:
        R += A[i]
        T  = False
    else:
        R -= B[i]
        T  = True

print(R)
### BUGGY CODE ###

n,k= list(map(int, input().split()))
li= list(map(int, input().split()))
c=[1]
nex=1
first=0
flag=0
for i in range(k):
    nex=li[nex-1]
    if nex in c:
        first=c.index(nex)
        flag=1
        break
    c.append(nex)
if flag:
    k-=first
    k%=len(c)-first
    print(c[first+k])
else:
    print(c[-1])

### FIXED CODE ###

n,k= list(map(int, input().split()))
li= list(map(int, input().split()))
d = [0 for i in range(n)]
c=[1]
nex=1
first=0
flag=0
for i in range(k):
    nex=li[nex-1]
    if d[nex-1]:
        first=c.index(nex)
        flag=1
        break
    d[nex-1]=1
    c.append(nex)
if flag:
    k-=first
    k%=len(c)-first
    print(c[first+k])
else:
    print(c[-1])
### BUGGY CODE ###

def solve():
    matrix = [[0]*(w+1) for _ in range(n)]
    for i in range(n):
        for j in range(1, w+1):
            if i >= 1 and j-dp[i][0] >= 0:
                matrix[i][j] = max(matrix[i-1][j], dp[i][1]+matrix[i-1][j-dp[i][0]])
            elif i < 1 and j-dp[i][0] >= 0:
                matrix[i][j] = dp[i][1]
            else:
                matrix[i][j] = matrix[i-1][j]
    return matrix[n-1][w]


if __name__ == '__main__':
    n, w = map(int, input().split())
    dp = []
    for i in range(n):
        dp.append(list(map(int,input().split())))
    print(solve())

### FIXED CODE ###

import numpy as np

n, W = map(int, input().split())
dp = np.array([[0]*(W+1)]*(n+1))
for i in range(1, n+1):
    w, v = map(int, input().split())
    dp[i] = dp[i-1]
    dp[i][w:W+1] = np.maximum(dp[i-1][w:W+1], dp[i-1][:W+1-w]+v)
print(dp[n][W])
### BUGGY CODE ###

n = int(input())
a = [0]*n
for i in range(n):
  a[i] = int(input())
for i in range(n):
  b = a[:]
  b[i] = 0
  print(max(b))

### FIXED CODE ###

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

Q = int(input())

ls = [list(map(int,input().split())) for i in range(Q)]
n_max = max(ls)[1]

prime = []
data = [i for i in range(2,n_max+1)]
limit = n_max**(1/2)
while True:
    p = data[0]
    if limit<=p:
        break
    prime.append(p)
    data = [i for i in data if i%p!=0]
prime = prime +data

ans_ls = [0]*len(prime)
for i in range(len(prime)):
    if (prime[i]+1)//2 in prime:
        ans_ls[i] =1

for l,r in ls:
    ans = 0
    for i in range(len(prime)):
        if (prime[i]>r):
            break
        elif (l<=prime[i]):
           ans += ans_ls[i]
            
    print(ans)



### FIXED CODE ###

Q = int(input())

ls = [list(map(int,input().split())) for i in range(Q)]

n_max = 10**5

prime = []
data = [i for i in range(2,n_max+1)]
limit = n_max**(1/2)

while True:
    p = data[0]
    if limit<=p:
        break
    prime.append(p)
    data = [i for i in data if i%p!=0]

prime = prime +data

ans_ls = [0]*(1+n_max)
for i in prime:
    if (i + 1) // 2 in prime:
        ans_ls[i] = 1

ans_cs = [0]*(1+n_max)
for i in range(n_max):
    ans_cs[i+1] = ans_cs[i]+ans_ls[i+1]
    
for l,r in ls:
    print(ans_cs[r]-ans_cs[l-1])
### BUGGY CODE ###

def solve(c, sushis):
    clockwise = solve_one_direction(c, sushis, True)
    counter = solve_one_direction(c, sushis[::-1], False)
    return max(clockwise, counter)

def solve_one_direction(c, sushis, clockwise=True, already_turn=False):
    total_v = 0
    max_v = 0
    for i, sushi in enumerate(sushis):
        total_v += sushi[1]
        x = sushi[0] if clockwise else c - sushi[0]
        v = total_v - x
        if max_v < v:
            max_v = v
        if not already_turn and x <= c / 2:
            rev = v - x + solve_one_direction(c, sushis[i + 1::][::-1], not clockwise, True)
            if max_v < rev:
                max_v = rev

    return max_v


n, c = map(int, input().split())
sushis = []
for _ in range(n):
    sushis.append([int(x) for x in input().split()])
print(solve(c, sushis))

### FIXED CODE ###

def solve(c, sushis):
    cw_maxs, cw_rets = create_accs(sushis, c, True)
    ccw_maxs, ccw_rets = create_accs(reversed(sushis), c, False)
    cw_max = cw_maxs[-1]
    ccw_max = ccw_maxs[-1]
    cw_ccw_max = turn_max(cw_rets, ccw_maxs)
    ccw_cw_max = turn_max(ccw_rets, cw_maxs)
    return max(cw_max, ccw_max, cw_ccw_max, ccw_cw_max)


def turn_max(rets, maxs):
    m = 0
    for i, r in enumerate(rets):
        ind = len(maxs) - 2 - i
        add = maxs[ind] if ind >= 0 else 0
        v = r + add
        if m < v:
            m = v
    return m


def create_accs(sushis, c, cw):
    maxs, vs_ret = [], []
    v_sum, v_max = 0, 0
    for d, v in sushis:
        v_sum += v
        dist = d if cw else c - d
        v_cur = v_sum - dist
        if v_max < v_cur:
            v_max = v_cur
        maxs.append(v_max)
        vs_ret.append(v_sum - dist*2)
    return maxs, vs_ret


n, c = map(int, input().split())
sushis = []
for _ in range(n):
    sushis.append([int(x) for x in input().split()])
print(solve(c, sushis))
### BUGGY CODE ###

n = int(input())
li = list(str(input()) for i in range(n))
gou = []
count = 0
for g in range(len(li)):
    lis = []
    for k in range(len(li[g])):
        lis.append(li[g][k])
    lis.sort()
    gou.append(lis)
for p in range(len(gou)):
    for u in range(len(gou)):
        if gou[p] == gou[u] and p!=u:
            count += 1
print(count//2)

### FIXED CODE ###

# -*- coding: utf-8 -*-
from sys import stdin

n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip() for _ in range(n)]
new = []
for i in range(n):
    sort = sorted(data[i])
    sorting = "".join(sort)
    new.append(sorting)
new.sort()
score = 0
s = 0
count  = 0
while s<n-1:
    daburi = 1
    for p in range(s,n-1):
        if new[p] == new[p+1]:
            daburi += 1
        else:
            break
    score += daburi*(daburi-1)//2
    count += daburi
    s = count
print(score)
### BUGGY CODE ###

n, k = map(int, input().split())
p_n = list(map(int, input().split()))
v_n = p_n

# リストの値を期待値に変換
for i in range(n):
    v_n[i] = (p_n[i] + 1) / 2

s = 0
max_s = 0

for i in range(n - k + 1):
    s = sum(v_n[i:i + k])

    if s > max_s:
        max_s = s

print(max_s)

### FIXED CODE ###

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

s = sum(p[:k])
max_s = s

for i in range(n - k):
    s = s - p[i] + p[i + k]

    if max_s < s:
        max_s = s

print((max_s + k) / 2)
### BUGGY CODE ###

import sys
N,M = map(int,input().split())
shops = dict()
price = []
takahashi = 0
money = 0
for i in range(N):
    bottle,stock = map(int,input().split())
    if bottle not in shops:
        shops[bottle] = 0
    shops[bottle] += stock
    if bottle not in price:
        price.append(bottle)
price.sort()
for y in price:
    if shops[y] <= (M-takahashi):
        takahashi += shops[y]
        money += shops[y]*y
        shops[y] = 0
        if takahashi == M:
            print(money)
            sys.exit(0)
    else:
        money += y*(M-takahashi)
        takahashi += (M-takahashi)
        shops[y] -= (M-takahashi)
        if takahashi == M:
            print(money)
            sys.exit(0)

### FIXED CODE ###

N,M = map(int,input().split())
shops = []
for i in range(N):
    price,B = map(int,input().split())
    shops.append([price,B])
shops.sort()
i = 0
money = 0
while M > 0:
    if shops[i][1] > M:
        money += M*shops[i][0]
        break
    else:
        money += shops[i][1] * shops[i][0]
        M -= shops[i][1]
    i += 1
print(money)
### BUGGY CODE ###

import numpy as np

n = int(input())
p = np.array(list(map(int, input().split())))

ans = 1

for i in range(1, p.shape[0]):
    tmp = p[:i].copy()
    tmp = tmp - p[i]
    if tmp[:i].min() >= 0:
        ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
m = float('inf')
ans = 0

for p in P:
    if p <= m:
        ans += 1
        m = p

print(ans)